コード例 #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
        public static YDataLoggerProxy FindDataLogger(string name)
        {
            // cases to handle:
            // name =""  no matching unknwn
            // name =""  unknown exists
            // name != "" no  matching unknown
            // name !="" unknown exists
            YDataLogger      func = null;
            YDataLoggerProxy res  = (YDataLoggerProxy)YFunctionProxy.FindSimilarUnknownFunction("YDataLoggerProxy");

            if (name == "")
            {
                if (res != null)
                {
                    return(res);
                }
                res = (YDataLoggerProxy)YFunctionProxy.FindSimilarKnownFunction("YDataLoggerProxy");
                if (res != null)
                {
                    return(res);
                }
                func = YDataLogger.FirstDataLogger();
                if (func != null)
                {
                    name = func.get_hardwareId();
                    if (func.get_userData() != null)
                    {
                        return((YDataLoggerProxy)func.get_userData());
                    }
                }
            }
            else
            {
                // allow to get datalogger from the name of any function
                int p = name.IndexOf(".");
                if (p > 0)
                {
                    name = name.Substring(0, p) + ".dataLogger";
                }
                func = YDataLogger.FindDataLogger(name);
                if (func.get_userData() != null)
                {
                    return((YDataLoggerProxy)func.get_userData());
                }
            }
            if (res == null)
            {
                res = new YDataLoggerProxy(func, name);
            }
            if (func != null)
            {
                res.linkToHardware(name);
                if (func.isOnline())
                {
                    res.arrival();
                }
            }
            return(res);
        }
コード例 #4
0
        private void clearDataLogger(object sender, EventArgs e)
        {
            if (System.Windows.Forms.MessageBox.Show("Do you really want to erase contents of all dataloggers related to this graph?",
                                                     "Erase dataloggers contents?",
                                                     MessageBoxButtons.YesNo) == DialogResult.No)
            {
                return;
            }

            List <YDataLogger> loggers = new List <YDataLogger>();

            for (int i = 0; i < SeriesCount; i++)
            {
                ChartSerie    s      = (ChartSerie)prop.GetType().GetProperty("Graph_series" + i.ToString()).GetValue(prop, null);
                CustomYSensor sensor = s.DataSource_source;
                if (!(sensor is NullYSensor))
                {
                    sensor.stopDataloggerloading();
                    string serial = sensor.get_hardwareId();
                    int    n      = serial.IndexOf(".");
                    serial = serial.Substring(0, n);
                    YDataLogger d = YDataLogger.FindDataLogger(serial + ".dataLogger");
                    if (d.isOnline())
                    {
                        if (loggers.IndexOf(d) < 0)
                        {
                            loggers.Add(d);
                        }
                    }
                }
            }

            for (int i = 0; i < loggers.Count; i++)
            {
                loggers[i].forgetAllDataStreams();
                loggers[i].set_recording(YDataLogger.RECORDING_ON);
            }

            bool tmp = prop.Graph_showRecordedData;

            prop.Graph_showRecordedData = false;
            truncateView();
            prop.Graph_showRecordedData = tmp;
        }