public void reloadConfig(YModule Source)
        {
            _name       = _sourceSensor.get_friendlyName();;
            _serial     = _sourceSensor.get_module().get_module().get_serialNumber();
            _unit       = _sourceSensor.get_unit();
            _datalogger = YDataLogger.FindDataLogger(_serial + ".dataLogger");
            _tempSensor = YTemperature.FindTemperature(_serial + ".temperature");
            string tt = _sourceSensor.get_hardwareId().Replace("weighScale", "genericSensor");

            _genSensor = YGenericSensor.FindGenericSensor(tt);
        }
示例#2
0
        private async void onLoad(object sender, RoutedEventArgs e)
        {
            try {
                await YAPI.RegisterHub("usb");

                sensor = YWeighScale.FirstWeighScale();
                if (sensor == null)
                {
                    await FatalError("No WeighScale connected");
                }

                display = YDisplay.FirstDisplay();
                if (display != null)
                {
                    //clean up
                    await display.resetAll();

                    // retreive the display size
                    w = await display.get_displayWidth();

                    h = await display.get_displayHeight();

                    // reteive the first layer
                    l0 = await display.get_displayLayer(0);

                    l1 = await display.get_displayLayer(1);

                    // display a text in the middle of the screen
                    await l0.selectFont("Large.yfm");
                }
                await sensor.set_excitation(YWeighScale.EXCITATION_AC);

                await YAPI.Sleep(3000);

                await sensor.tare();

                unit = await sensor.get_unit();

                await sensor.registerValueCallback(sensorValueChangeCallBack);
            } catch (YAPI_Exception ex) {
                await FatalError(ex.Message);
            }

            timer          = new NonReentrantDispatcherTimer();
            timer.Interval = new TimeSpan(0, 0, 0, 0, 100);
            timer.TickTask = async() => { await dispatcherTimer_Tick(); };
            timer.Start();
        }