Пример #1
0
        // Datalogger buttons handling
        private void DataLoggerButton_Click(object sender, EventArgs e)
        {
            YSensor s = getSelectedSensor();

            if (s != null)
            {
                YModule     m   = s.get_module(); // get the module harboring the sensor
                YDataLogger dtl = YDataLogger.FindDataLogger(m.get_serialNumber() + ".dataLogger");
                if (dtl.isOnline())
                {
                    if (sender == RecordButton)
                    {
                        dtl.set_recording(YDataLogger.RECORDING_ON);
                    }
                    if (sender == PauseButton)
                    {
                        dtl.set_recording(YDataLogger.RECORDING_OFF);
                    }
                    if (sender == DeleteButton)
                    {
                        dtl.set_recording(YDataLogger.RECORDING_OFF);
                        MessageBox.Show("clear");
                        dtl.forgetAllDataStreams();
                        clearGraph();
                    }
                }
            }
            refreshDatloggerButton(s);
        }
Пример #2
0
 // update the datalogger control buttons
 private void refreshDatloggerButton(YSensor s)
 {
     if (s != null)
     {
         YModule     m   = s.get_module(); // get the module harboring the sensor
         YDataLogger dtl = YDataLogger.FindDataLogger(m.get_serialNumber() + ".dataLogger");
         if (dtl.isOnline())
         {
             if (dtl.get_recording() == YDataLogger.RECORDING_ON)
             {
                 RecordButton.Enabled = false;
                 PauseButton.Enabled  = true;
                 DeleteButton.Enabled = false;
                 return;
             }
             else
             {
                 RecordButton.Enabled = true;
                 PauseButton.Enabled  = false;
                 DeleteButton.Enabled = true;
                 return;
             }
         }
     }
     RecordButton.Enabled = false;
     PauseButton.Enabled  = false;
     DeleteButton.Enabled = false;
 }
Пример #3
0
        async Task deviceArrival(YModule m)
        {
            string serial = await m.get_serialNumber();

            Output.Text += "Device arrival : " + serial + "\n";
            await m.registerLogCallback(deviceLog);

            await m.registerConfigChangeCallback(configChange);

            await m.registerBeaconCallback(beaconChange);

            // First solution: look for a specific type of function (eg. anButton)
            int fctcount = await m.functionCount();

            for (int i = 0; i < fctcount; i++)
            {
                string hardwareId = serial + "." + await m.functionId(i);

                if (hardwareId.IndexOf(".anButton") >= 0)
                {
                    Output.Text += "- " + hardwareId + "\n";
                    YAnButton anButton = YAnButton.FindAnButton(hardwareId);
                    await anButton.registerValueCallback(anButtonValueChangeCallBack);
                }
            }

            // Alternate solution: register any kind of sensor on the device
            YSensor sensor = YSensor.FirstSensor();

            while (sensor != null)
            {
                YModule module = await sensor.get_module();

                if (await module.get_serialNumber() == serial)
                {
                    string hardwareId = await sensor.get_hardwareId();

                    Output.Text += "- " + hardwareId + "\n";
                    string unit = await sensor.get_unit();

                    await sensor.set_userData(unit);

                    await sensor.registerValueCallback(sensorValueChangeCallBack);

                    await sensor.registerTimedReportCallback(sensorTimedReportCallBack);
                }

                sensor = sensor.nextSensor();
            }
        }
Пример #4
0
        static void deviceArrival(YModule m)
        {
            string serial = m.get_serialNumber();

            Console.WriteLine("Device arrival : " + serial);
            m.registerLogCallback(deviceLog);
            m.registerConfigChangeCallback(configChange);
            m.registerBeaconCallback(beaconChange);

            // First solution: look for a specific type of function (eg. anButton)
            int fctcount = m.functionCount();

            for (int i = 0; i < fctcount; i++)
            {
                string hardwareId = serial + "." + m.functionId(i);
                if (hardwareId.IndexOf(".anButton") >= 0)
                {
                    Console.WriteLine("- " + hardwareId);
                    YAnButton anButton = YAnButton.FindAnButton(hardwareId);
                    anButton.registerValueCallback(anButtonValueChangeCallBack);
                }
            }

            // Alternate solution: register any kind of sensor on the device
            YSensor sensor = YSensor.FirstSensor();

            while (sensor != null)
            {
                if (sensor.get_module().get_serialNumber() == serial)
                {
                    string hardwareId = sensor.get_hardwareId();
                    Console.WriteLine("- " + hardwareId);
                    string unit = sensor.get_unit();
                    sensor.set_userData(unit);
                    sensor.registerValueCallback(sensorValueChangeCallBack);
                    sensor.registerTimedReportCallback(sensorTimedReportCallBack);
                }

                sensor = sensor.nextSensor();
            }
        }