public static synchronized void start(HackRFSweepDataCallback dataCallback, int freq_min_MHz, int freq_max_MHz, int fft_bin_width, int num_samples, int lna_gain, int vga_gain, boolean antennaPowerEnable) { hackrf_sweep_lib_start__fft_power_callback_callback callback = new hackrf_sweep_lib_start__fft_power_callback_callback() { @Override public void apply(byte sweep_started, int bins, DoubleByReference freqStart, float fftBinWidth, FloatByReference powerdBm) { double[] freqStartArr = bins == 0 ? null : freqStart.getPointer().getDoubleArray(0, bins); float[] powerArr = bins == 0 ? null : powerdBm.getPointer().getFloatArray(0, bins); dataCallback.newSpectrumData(sweep_started==0 ? false : true, freqStartArr, fftBinWidth, powerArr); } }; Native.setCallbackThreadInitializer(callback, new CallbackThreadInitializer(true)); HackrfSweepLibrary.hackrf_sweep_lib_start(callback, freq_min_MHz, freq_max_MHz, fft_bin_width, num_samples, lna_gain, vga_gain, antennaPowerEnable ? 1 : 0); }
@Test public void testModuleLog() { Pointer module = ssclib.ssc_module_create("layoutarea"); boolean result = ssclib.ssc_module_exec(module, data); assertThat(result).isFalse(); int i = 0; IntByReference itemType = new IntByReference(); FloatByReference time = new FloatByReference(); String logMsg = ssclib.ssc_module_log(module, i, itemType, time); do { assertThat(logMsg).isNotNull(); assertThat(itemType.getValue()).isGreaterThan(0); assertThat(time.getValue()).isNotWithin(EPSILON).of(0f); i++; logMsg = ssclib.ssc_module_log(module, i, itemType, time); } while (logMsg != null); }
/** * Get a numeric input or output number for this module. * * @param variableName The name of the variable to retrieve. * @return If <tt>variableName</tt> is found, an {@link Optional} containing the value. Otherwise, * an empty {@link Optional} * * @throws {@link java.lang.IllegalStateException} if the module has already been {@link #free}ed. * @throws {@link java.lang.NullPointerException} if <tt>variableName</tt> is null */ public Optional<Float> getNumber(String variableName) { checkState(); checkNotNull(variableName); FloatByReference value = new FloatByReference(); boolean present = api.ssc_data_get_number(data, variableName, value); if (present) { return Optional.of(value.getValue()); } else { return Optional.empty(); } }
@Test public void getNonExistentNumber() { when(mockApi.ssc_data_get_number(any(Pointer.class), any(String.class), any(FloatByReference.class))).thenReturn(false); Optional<Float> val = data.getNumber("asdf"); assertThat(val.isPresent()).isFalse(); }
@Test public void setNumber() { float targetVal = 0.5f; String name = "test"; ssclib.ssc_data_set_number(data, name, targetVal); FloatByReference out = new FloatByReference(); boolean status = ssclib.ssc_data_get_number(data, name, out); assertThat(status).isTrue(); assertThat(out.getValue()).isWithin(EPSILON).of(targetVal); }
/** * Private helper to make sure that the data created by the simulation was set as expected. * Assumes that we used the "layoutarea" module */ private static void checkSimulationData(Ssc ssclib, Pointer data) { FloatByReference val = new FloatByReference(); boolean status = ssclib.ssc_data_get_number(data, "area", val); assertThat(status).isTrue(); assertThat(val.getValue()).isAtLeast(0f); IntByReference rows = new IntByReference(); IntByReference cols = new IntByReference(); Pointer mtx = ssclib.ssc_data_get_matrix(data, "convex_hull", rows, cols); assertThat(mtx).isNotNull(); assertThat(rows.getValue()).isGreaterThan(0); assertThat(cols.getValue()).isGreaterThan(0); }
/** * If the mouse addon is installed, return the current mouse position transformed by the given transform. */ protected Point getMousePosTransformed(ALLEGRO_TRANSFORM transform) { FloatByReference mouseX = new FloatByReference(mouseState.x); FloatByReference mouseY = new FloatByReference(mouseState.y); al_transform_coordinates(transform, mouseX, mouseY); return new Point(mouseX.getValue(), mouseY.getValue()); }
String ssc_module_log(Pointer module, int index, IntByReference itemType, FloatByReference time);
@Override public int boxaCompareRegions(Boxa boxa1, Boxa boxa2, int areathresh, IntByReference pnsame, FloatByReference pdiffarea, FloatByReference pdiffxor, PointerByReference ppixdb) { throw new UnsupportedOperationException("Not supported yet."); }
@Override public int pixFindColorRegions(Pix pixs, Pix pixm, int factor, int lightthresh, int darkthresh, int mindiff, int colordiff, float edgefract, FloatByReference pcolorfract, PointerByReference pcolormask1, PointerByReference pcolormask2, Pixa pixadb) { throw new UnsupportedOperationException("Not supported yet."); }
@Override public int pixHasHighlightRed(Pix pixs, int factor, float fract, float fthresh, IntByReference phasred, FloatByReference pratio, PointerByReference ppixdb) { throw new UnsupportedOperationException("Not supported yet."); }
@Override public int pixCompareBinary(Pix pix1, Pix pix2, int comptype, FloatByReference pfract, PointerByReference ppixdiff) { throw new UnsupportedOperationException("Not supported yet."); }
@Override public int pixCompareGrayOrRGB(Pix pix1, Pix pix2, int comptype, int plottype, IntByReference psame, FloatByReference pdiff, FloatByReference prmsdiff, PointerByReference ppixdiff) { throw new UnsupportedOperationException("Not supported yet."); }
@Override public int pixCompareGray(Pix pix1, Pix pix2, int comptype, int plottype, IntByReference psame, FloatByReference pdiff, FloatByReference prmsdiff, PointerByReference ppixdiff) { throw new UnsupportedOperationException("Not supported yet."); }
@Override public int pixCompareRGB(Pix pix1, Pix pix2, int comptype, int plottype, IntByReference psame, FloatByReference pdiff, FloatByReference prmsdiff, PointerByReference ppixdiff) { throw new UnsupportedOperationException("Not supported yet."); }
@Override public int pixGetPerceptualDiff(Pix pixs1, Pix pixs2, int sampling, int dilation, int mindiff, FloatByReference pfract, PointerByReference ppixdiff1, PointerByReference ppixdiff2) { throw new UnsupportedOperationException("Not supported yet."); }
@Override public int pixFindStrokeWidth(Pix pixs, float thresh, IntByReference tab8, FloatByReference pwidth, PointerByReference pnahisto) { throw new UnsupportedOperationException("Not supported yet."); }
public GlobalFloat(NativeLibrary library, String... symbols) { super(library, FloatByReference.class, symbols); }
/** * @param nalloc size of allocated number array<br> * C type : l_int32<br> * @param n number of numbers saved<br> * C type : l_int32<br> * @param refcount reference count (1 if no clones)<br> * C type : l_int32<br> * @param startx x value assigned to array[0]<br> * C type : l_float32<br> * @param delx change in x value as i --> i + 1<br> * C type : l_float32<br> * @param array number array<br> * C type : l_float32* */ public Numa(int nalloc, int n, int refcount, float startx, float delx, FloatByReference array) { super(); this.nalloc = nalloc; this.n = n; this.refcount = refcount; this.startx = startx; this.delx = delx; this.array = array; }
/** * @param w width in pixels<br> * C type : l_int32<br> * @param h height in pixels<br> * C type : l_int32<br> * @param wpl 32-bit words/line<br> * C type : l_int32<br> * @param refcount reference count (1 if no clones)<br> * C type : l_uint32<br> * @param xres image res (ppi) in x direction<br> * C type : l_int32<br> * @param yres image res (ppi) in y direction<br> * C type : l_int32<br> * @param data the float image data<br> * C type : l_float32* */ public FPix(int w, int h, int wpl, int refcount, int xres, int yres, FloatByReference data) { super(); this.w = w; this.h = h; this.wpl = wpl; this.refcount = refcount; this.xres = xres; this.yres = yres; this.data = data; }
/** * @param n actual number of pts<br> * C type : l_int32<br> * @param nalloc size of allocated arrays<br> * C type : l_int32<br> * @param refcount reference count (1 if no clones)<br> * C type : l_uint32<br> * @param x arrays of floats<br> * C type : l_float32*<br> * @param y arrays of floats<br> * C type : l_float32* */ public Pta(int n, int nalloc, int refcount, FloatByReference x, FloatByReference y) { super(); this.n = n; this.nalloc = nalloc; this.refcount = refcount; this.x = x; this.y = y; }
/** * Creates a new {@link CFNumberRef} instance with the value from * {@code value}. * * @param value the value of the new {@link CFNumberRef} instance. * @return The new instance. */ public static CFNumberRef toCFNumberRef(float value) { return INSTANCE.CFNumberCreate(ALLOCATOR, CFNumberType.kCFNumberFloat32Type, new FloatByReference(value)); }
/** * Opus encode float. * * @param st the st * @param pcm the pcm * @param frame_size the frame size * @param data the data * @param max_data_bytes the max data bytes * @return the int */ int opus_encode_float(PointerByReference st, FloatByReference pcm, int frame_size, Pointer data, int max_data_bytes);
/** * Opus decode float. * * @param st the st * @param data the data * @param len the len * @param pcm the pcm * @param frame_size the frame size * @param decode_fec the decode fec * @return the int */ int opus_decode_float(PointerByReference st, Pointer data, int len, FloatByReference pcm, int frame_size, int decode_fec);
/** * Opus multistream encode float. * * @param st the st * @param pcm the pcm * @param frame_size the frame size * @param data the data * @param max_data_bytes the max data bytes * @return the int */ int opus_multistream_encode_float(PointerByReference st, FloatByReference pcm, int frame_size, Pointer data, int max_data_bytes);
/** * Opus multistream decode float. * * @param st the st * @param data the data * @param len the len * @param pcm the pcm * @param frame_size the frame size * @param decode_fec the decode fec * @return the int */ int opus_multistream_decode_float(PointerByReference st, Pointer data, int len, FloatByReference pcm, int frame_size, int decode_fec);
/** * Opus custom encode float. * * @param st the st * @param pcm the pcm * @param frame_size the frame size * @param compressed the compressed * @param maxCompressedBytes the max compressed bytes * @return the int */ int opus_custom_encode_float(PointerByReference st, FloatByReference pcm, int frame_size, Pointer compressed, int maxCompressedBytes);
/** * Opus custom decode float. * * @param st the st * @param data the data * @param len the len * @param pcm the pcm * @param frame_size the frame size * @return the int */ int opus_custom_decode_float(PointerByReference st, Pointer data, int len, FloatByReference pcm, int frame_size);
/** * Original signature : * <code>l_float32* createMatrix2dTranslate(l_float32, l_float32)</code><br> * <i>native declaration : allheaders.h:90</i> */ public static native FloatByReference createMatrix2dTranslate(float transx, float transy);
/** * Original signature : * <code>l_float32* createMatrix2dScale(l_float32, l_float32)</code><br> * <i>native declaration : allheaders.h:92</i> */ public static native FloatByReference createMatrix2dScale(float scalex, float scaley);
/** * Original signature : * <code>l_float32* createMatrix2dRotate(l_float32, l_float32, l_float32)</code><br> * <i>native declaration : allheaders.h:94</i> */ public static native FloatByReference createMatrix2dRotate(float xc, float yc, float angle);
/** * Original signature : * <code>l_int32 boxaCompareRegions(BOXA*, BOXA*, l_int32, l_int32*, l_float32*, l_float32*, PIX**)</code><br> * <i>native declaration : allheaders.h:568</i> */ public static native int boxaCompareRegions(Boxa boxa1, Boxa boxa2, int areathresh, IntByReference pnsame, FloatByReference pdiffarea, FloatByReference pdiffxor, PointerByReference ppixdb);
/** * Original signature : * <code>l_int32 pixFindColorRegions(PIX*, PIX*, l_int32, l_int32, l_int32, l_int32, l_int32, l_float32, l_float32*, PIX**, PIX**, PIXA*)</code><br> * <i>native declaration : allheaders.h:770</i> */ public static native int pixFindColorRegions(Pix pixs, Pix pixm, int factor, int lightthresh, int darkthresh, int mindiff, int colordiff, float edgefract, FloatByReference pcolorfract, PointerByReference pcolormask1, PointerByReference pcolormask2, Pixa pixadb);
/** * Original signature : * <code>l_int32 pixHasHighlightRed(PIX*, l_int32, l_float32, l_float32, l_int32*, l_float32*, PIX**)</code><br> * <i>native declaration : allheaders.h:788</i> */ public static native int pixHasHighlightRed(Pix pixs, int factor, float fract, float fthresh, IntByReference phasred, FloatByReference pratio, PointerByReference ppixdb);
/** * Original signature : * <code>l_int32 pixCompareBinary(PIX*, PIX*, l_int32, l_float32*, PIX**)</code><br> * <i>native declaration : allheaders.h:1056</i> */ public static native int pixCompareBinary(Pix pix1, Pix pix2, int comptype, FloatByReference pfract, PointerByReference ppixdiff);
/** * Original signature : * <code>l_int32 pixCompareGrayOrRGB(PIX*, PIX*, l_int32, l_int32, l_int32*, l_float32*, l_float32*, PIX**)</code><br> * <i>native declaration : allheaders.h:1058</i> */ public static native int pixCompareGrayOrRGB(Pix pix1, Pix pix2, int comptype, int plottype, IntByReference psame, FloatByReference pdiff, FloatByReference prmsdiff, PointerByReference ppixdiff);
/** * Original signature : * <code>l_int32 pixCompareGray(PIX*, PIX*, l_int32, l_int32, l_int32*, l_float32*, l_float32*, PIX**)</code><br> * <i>native declaration : allheaders.h:1060</i> */ public static native int pixCompareGray(Pix pix1, Pix pix2, int comptype, int plottype, IntByReference psame, FloatByReference pdiff, FloatByReference prmsdiff, PointerByReference ppixdiff);
/** * Original signature : * <code>l_int32 pixCompareRGB(PIX*, PIX*, l_int32, l_int32, l_int32*, l_float32*, l_float32*, PIX**)</code><br> * <i>native declaration : allheaders.h:1062</i> */ public static native int pixCompareRGB(Pix pix1, Pix pix2, int comptype, int plottype, IntByReference psame, FloatByReference pdiff, FloatByReference prmsdiff, PointerByReference ppixdiff);
/** * Original signature : * <code>l_int32 pixGetPerceptualDiff(PIX*, PIX*, l_int32, l_int32, l_int32, l_float32*, PIX**, PIX**)</code><br> * <i>native declaration : allheaders.h:1074</i> */ public static native int pixGetPerceptualDiff(Pix pixs1, Pix pixs2, int sampling, int dilation, int mindiff, FloatByReference pfract, PointerByReference ppixdiff1, PointerByReference ppixdiff2);
/** * Original signature : <code>l_float32* fpixGetData(FPIX*)</code><br> * <i>native declaration : allheaders.h:1568</i> */ public static native FloatByReference fpixGetData(FPix fpix);