/** * Registers the callback function that is invoked on every periodic timed notification. The * callback is invoked only during the execution of ySleep or yHandleEvents. This provides control * over the time when the callback is triggered. For good responsiveness, remember to call one of * these two functions periodically. To unregister a callback, pass a null pointer as argument. * * @param callback : the callback function to call, or a null pointer. The callback function * should take two arguments: the function object of which the value has changed, and an * YMeasure object describing the new advertised value. */ public int registerTimedReportCallback(TimedReportCallback callback) { if (callback != null) { YFunction._UpdateTimedReportCallbackList(this, true); } else { YFunction._UpdateTimedReportCallbackList(this, false); } _timedReportCallbackMagnetometer = callback; return 0; }
/** * Retrieves a magnetometer for a given identifier. The identifier can be specified using several * formats: * * <ul> * <li>FunctionLogicalName * <li>ModuleSerialNumber.FunctionIdentifier * <li>ModuleSerialNumber.FunctionLogicalName * <li>ModuleLogicalName.FunctionIdentifier * <li>ModuleLogicalName.FunctionLogicalName * </ul> * * This function does not require that the magnetometer is online at the time it is invoked. The * returned object is nevertheless valid. Use the method YMagnetometer.isOnline() to test if the * magnetometer is indeed online at a given time. In case of ambiguity when looking for a * magnetometer by logical name, no error is notified: the first instance found is returned. The * search is performed first by hardware name, then by logical name. * * @param func : a string that uniquely characterizes the magnetometer * @return a YMagnetometer object allowing you to drive the magnetometer. */ public static YMagnetometer FindMagnetometer(String func) { YMagnetometer obj; obj = (YMagnetometer) YFunction._FindFromCache("Magnetometer", func); if (obj == null) { obj = new YMagnetometer(func); YFunction._AddToCache("Magnetometer", func, obj); } return obj; }
/** * Registers the callback function that is invoked on every change of advertised value. The * callback is invoked only during the execution of ySleep or yHandleEvents. This provides control * over the time when the callback is triggered. For good responsiveness, remember to call one of * these two functions periodically. To unregister a callback, pass a null pointer as argument. * * @param callback : the callback function to call, or a null pointer. The callback function * should take two arguments: the function object of which the value has changed, and the * character string describing the new advertised value. */ public int registerValueCallback(UpdateCallback callback) { String val; if (callback != null) { YFunction._UpdateValueCallbackList(this, true); } else { YFunction._UpdateValueCallbackList(this, false); } _valueCallbackMagnetometer = callback; // Immediately invoke value callback with current value if (callback != null && isOnline()) { val = _advertisedValue; if (!(val.equals(""))) { _invokeValueCallback(val); } } return 0; }