Пример #1
0
        private async void Button_ReadStatus_ClickAsync(object sender, RoutedEventArgs e)
        {
            //ReadStatus --> Search for TELID® data logger and read its status
            textBox_ResultRead.Text          = "";
            progressBar.Value                = 0;
            textBlock_TimeRemaining.Text     = "";
            listBox_Measurements.ItemsSource = null;
            m_LastReadState = null;
            if (m_TelidControl != null)
            {
                if (m_TelidControl.IsInitialized)
                {
                    DateTime startTime = DateTime.UtcNow;
                    //This function blocks & searches for a default time of 1 second (optional parameter)
                    var scanResult = await m_TelidControl.SearchAndReadStatusAsync();

                    TimeSpan processSpan = DateTime.UtcNow - startTime;
                    if (scanResult != null)
                    {
                        m_LastReadState         = scanResult;
                        textBox_ResultRead.Text = "- TELID® found -\n";
                        var telidInfo = scanResult.VersionInfo;
                        textBox_ResultRead.Text += string.Format("SerNo: {0}\n", telidInfo.SerialNumber);
                        textBox_ResultRead.Text += string.Format("Product-Type: {0}\n", telidInfo.ProductType);
                        textBox_ResultRead.Text += "Physical-Data:\n";
                        foreach (var data in telidInfo.PhyisicalData)
                        {
                            textBox_ResultRead.Text += string.Format("\t{0}\n", data);
                        }
                        textBox_ResultRead.Text += string.Format("FW-Version: {0}\n", scanResult.FwVersion);
                        textBox_ResultRead.Text += string.Format("IsLogging: {0}\n", scanResult.IsLogging);
                        textBox_ResultRead.Text += string.Format("Programmed: {0}\n", scanResult.ProgrammedTime);
                        textBox_ResultRead.Text += string.Format("Start: {0}\n", scanResult.StartTime);
                        textBox_ResultRead.Text += string.Format("Stop: {0}\n", scanResult.StopTime);
                        textBox_ResultRead.Text += string.Format("Datasets: {0}\n", scanResult.NumberDatasetsLogged);
                        textBox_ResultRead.Text += string.Format("Mem-Percentage used: {0}\n", scanResult.MemoryPercentageUsed);
                        textBox_ResultRead.Text += "SensorParameters: \n";
                        textBox_ResultRead.Text += scanResult.SensorParameters.ToString();

                        string toLog = string.Format("Result: OK. Duration: {0}\n", processSpan);
                        toLog += "- ReadStatus Result -\n";
                        toLog += string.Format("\tSerNo: {0}\n", telidInfo.SerialNumber);
                        toLog += string.Format("\tProduct-Type: {0}\n", telidInfo.ProductType);
                        toLog += string.Format("\tIsLogging: {0}\n", scanResult.IsLogging);
                        toLog += string.Format("\tDatasets: {0}\n", scanResult.NumberDatasetsLogged);
                        textBox_ThreadLog.Text += toLog;
                        textBox_ThreadLog.ScrollToEnd();
                    }
                    else
                    {
                        //Update result in UI
                        textBox_ThreadLog.Text += string.Format("Result: FAIL. Duration: {0}\n", processSpan);
                        textBox_ThreadLog.ScrollToEnd();
                    }
                }
            }
        }
        private async void Button_Restart_ClickAsync(object sender, RoutedEventArgs e)
        {
            textBox_ResultRead.Text          = "";
            progressBar.Value                = 0;
            textBlock_TimeRemaining.Text     = "";
            listBox_Measurements.ItemsSource = null;
            if (m_LastReadState == null)
            {
                //No status data available! --> First read Status
                textBox_ResultRead.Text = "No TELID® status available --> press \"Read Status\"";
                return;
            }
            if (m_TelidControl != null)
            {
                if (m_TelidControl.IsInitialized)
                {
                    DateTime startTime = DateTime.UtcNow;
                    //This function blocks & searches for a default time of 1 second (optional parameter)
                    bool startResult = await m_TelidControl.RestartLogAsync(
                        LogStartParameters.Initialize_TELID300nfc(
                            m_LastReadState,
                            "SampleCodeBlock_CSharp",
                            DateTime.Now.AddMinutes(5),
                            DateTime.Now.AddHours(1),
                            TELIDLibrary.Utils.SensorParameters.TELID300nfc_SensorParam.Initiailze(
                                TimeSpan.FromSeconds(30),
                                10,
                                30)));

                    TimeSpan processSpan = DateTime.UtcNow - startTime;
                    if (startResult)
                    {
                        m_LastReadState         = null;
                        textBox_ThreadLog.Text += string.Format("Result: OK. Duration: {0}\n", processSpan);
                        textBox_ThreadLog.ScrollToEnd();
                    }
                    else
                    {
                        //Update result in UI
                        textBox_ThreadLog.Text += string.Format("Result: FAIL. Duration: {0}\n", processSpan);
                        textBox_ThreadLog.ScrollToEnd();
                    }
                }
            }
        }
 private void Button_ReadStatus_Click(object sender, RoutedEventArgs e)
 {
     //ReadStatus --> Search for TELID® data logger and read its status
     textBox_ResultRead.Text          = "";
     progressBar.Value                = 0;
     textBlock_TimeRemaining.Text     = "";
     listBox_Measurements.ItemsSource = null;
     m_LastReadState = null;
     if (m_TelidControl != null)
     {
         if (m_TelidControl.IsInitialized)
         {
             startTimeThreadProcess = DateTime.UtcNow;
             //This function runs in a separate thread & reports result using "ReadCompleted"
             m_TelidControl.StartSearchAndReadStatus();
         }
     }
 }
        private async void Button_Search_ClickAsync(object sender, RoutedEventArgs e)
        {
            //Search --> Search for TELID® data loggers
            textBox_ResultRead.Text          = "";
            progressBar.Value                = 0;
            textBlock_TimeRemaining.Text     = "";
            listBox_Measurements.ItemsSource = null;
            m_LastReadState = null;
            if (m_TelidControl != null)
            {
                if (m_TelidControl.IsInitialized)
                {
                    DateTime startTime = DateTime.UtcNow;
                    //This function blocks & searches for a default time of 1 second (optional parameter)
                    var scanResult = await m_TelidControl.SearchForTELIDAsync();

                    TimeSpan processSpan = DateTime.UtcNow - startTime;
                    if (scanResult != null)
                    {
                        textBox_ResultRead.Text  = "- TELID® found -\n";
                        textBox_ResultRead.Text += string.Format("SerNo: {0}\n", scanResult.SerialNumber);
                        textBox_ResultRead.Text += string.Format("Product-Type: {0}\n", scanResult.ProductType);
                        textBox_ResultRead.Text += "Physical-Data:\n";
                        foreach (var data in scanResult.PhyisicalData)
                        {
                            textBox_ResultRead.Text += string.Format("\t{0}\n", data);
                        }

                        string toLog = string.Format("Result: OK. Duration: {0}\n", processSpan);
                        toLog += "- Search Result -\n";
                        toLog += string.Format("\tSerNo: {0}\n", scanResult.SerialNumber);
                        toLog += string.Format("\tProduct-Type: {0}\n", scanResult.ProductType);
                        textBox_ThreadLog.Text += toLog;
                        textBox_ThreadLog.ScrollToEnd();
                    }
                    else
                    {
                        //Update result in UI
                        textBox_ThreadLog.Text += string.Format("Result: FAIL. Duration: {0}\n", processSpan);
                        textBox_ThreadLog.ScrollToEnd();
                    }
                }
            }
        }
        private async void Button_Stop_ClickAsync(object sender, RoutedEventArgs e)
        {
            //Stop --> Stop current log
            textBox_ResultRead.Text          = "";
            progressBar.Value                = 0;
            textBlock_TimeRemaining.Text     = "";
            listBox_Measurements.ItemsSource = null;
            if (m_LastReadState == null)
            {
                //No status data available! --> First read Status
                textBox_ResultRead.Text = "No TELID® status available --> press \"Read Status\"";
                return;
            }
            if (m_TelidControl != null)
            {
                if (m_TelidControl.IsInitialized)
                {
                    DateTime startTime = DateTime.UtcNow;
                    //This function blocks & searches for a default time of 1 second (optional parameter)
                    bool stopResult = await m_TelidControl.StopLogAsync(m_LastReadState);

                    TimeSpan processSpan = DateTime.UtcNow - startTime;
                    if (stopResult)
                    {
                        m_LastReadState         = null;
                        textBox_ThreadLog.Text += string.Format("Result: OK. Duration: {0}\n", processSpan);
                        textBox_ThreadLog.ScrollToEnd();
                    }
                    else
                    {
                        //Update result in UI
                        textBox_ThreadLog.Text += string.Format("Result: FAIL. Duration: {0}\n", processSpan);
                        textBox_ThreadLog.ScrollToEnd();
                    }
                }
            }
        }
        private void TelidControl_ReadCompleted(object _sender, TelidStateInformation _telidStateInfo)
        {
            //Read process finished --> check TelidStateInformation instance
            Dispatcher.Invoke(() =>
            {
                TimeSpan processSpan         = DateTime.UtcNow - startTimeThreadProcess;
                progressBar.Value            = 100;
                textBlock_TimeRemaining.Text = "";
                if (_telidStateInfo != null)
                {
                    m_LastReadState          = _telidStateInfo;
                    textBox_ResultRead.Text  = "- TELID® found -\n";
                    var telidInfo            = _telidStateInfo.VersionInfo;
                    textBox_ResultRead.Text += string.Format("SerNo: {0}\n", telidInfo.SerialNumber);
                    textBox_ResultRead.Text += string.Format("Product-Type: {0}\n", telidInfo.ProductType);
                    textBox_ResultRead.Text += "Physical-Data:\n";
                    foreach (var data in telidInfo.PhyisicalData)
                    {
                        textBox_ResultRead.Text += string.Format("\t{0}\n", data);
                    }
                    textBox_ResultRead.Text += string.Format("FW-Version: {0}\n", _telidStateInfo.FwVersion);
                    textBox_ResultRead.Text += string.Format("IsLogging: {0}\n", _telidStateInfo.IsLogging);
                    textBox_ResultRead.Text += string.Format("Programmed: {0}\n", _telidStateInfo.ProgrammedTime);
                    textBox_ResultRead.Text += string.Format("Start: {0}\n", _telidStateInfo.StartTime);
                    textBox_ResultRead.Text += string.Format("Stop: {0}\n", _telidStateInfo.StopTime);
                    textBox_ResultRead.Text += string.Format("Datasets: {0}\n", _telidStateInfo.NumberDatasetsLogged);
                    textBox_ResultRead.Text += string.Format("Mem-Percentage used: {0}\n", _telidStateInfo.MemoryPercentageUsed);
                    textBox_ResultRead.Text += "SensorParameters: \n";
                    textBox_ResultRead.Text += _telidStateInfo.SensorParameters.ToString();
                    //Check if Measurements read & populate ListBox
                    if (_telidStateInfo.LoggedMeasurements != null)
                    {
                        textBox_ResultRead.Text     += string.Format("\nMeasurements read: {0}\n", _telidStateInfo.LoggedMeasurements.Length);
                        List <MeasListboxItem> items = new List <MeasListboxItem>();
                        foreach (var meas in _telidStateInfo.LoggedMeasurements)
                        {
                            string valuesStr = "";
                            foreach (var value in meas.Values)
                            {
                                valuesStr += string.Format("{0}{1}", value.Magnitude, value.Unit) + "\t";
                            }
                            if (valuesStr.EndsWith("\t"))
                            {
                                valuesStr = valuesStr.TrimEnd('\t');
                            }
                            items.Add(new MeasListboxItem()
                            {
                                Timestamp = meas.Timestamp.ToString("yyyy-MM-dd HH:mm:ss"),
                                Values    = valuesStr,
                                State     = string.Format("{0}", meas.Status),
                                BatState  = string.Format("{0}", meas.BatState)
                            });
                        }
                        listBox_Measurements.ItemsSource = items;
                    }

                    string toLog            = string.Format("Result: OK. Duration: {0}\n", processSpan);
                    toLog                  += "- ReadLog Result -\n";
                    toLog                  += string.Format("\tSerNo: {0}\n", telidInfo.SerialNumber);
                    toLog                  += string.Format("\tProduct-Type: {0}\n", telidInfo.ProductType);
                    toLog                  += string.Format("\tIsLogging: {0}\n", _telidStateInfo.IsLogging);
                    toLog                  += string.Format("\tDatasets: {0}\n", _telidStateInfo.NumberDatasetsLogged);
                    textBox_ThreadLog.Text += toLog;
                    textBox_ThreadLog.ScrollToEnd();
                }
                else
                {
                    //Update result in UI
                    textBox_ThreadLog.Text += string.Format("Result: FAIL. Duration: {0}\n", processSpan);
                    textBox_ThreadLog.ScrollToEnd();
                }
            });
        }
Пример #7
0
        private async void Button_ReadLogProtocol_ClickAsync(object sender, RoutedEventArgs e)
        {
            //ReadLogProtocol --> Start ReadLog process
            textBox_ResultRead.Text          = "";
            progressBar.Value                = 0;
            textBlock_TimeRemaining.Text     = "";
            listBox_Measurements.ItemsSource = null;
            if (m_LastReadState == null)
            {
                //No status data available! --> First read Status
                textBox_ResultRead.Text = "No TELID® status available --> press \"Read Status\"";
                return;
            }
            if (m_TelidControl != null)
            {
                if (m_TelidControl.IsInitialized)
                {
                    DateTime startTime = DateTime.UtcNow;
                    //This function blocks & reads the Log Protocol
                    var logResult = await m_TelidControl.ReadLogProtocolAsync(m_LastReadState);

                    TimeSpan processSpan = DateTime.UtcNow - startTime;
                    progressBar.Value            = 100;
                    textBlock_TimeRemaining.Text = "";
                    if (logResult != null)
                    {
                        m_LastReadState         = logResult;
                        textBox_ResultRead.Text = "- TELID® found -\n";
                        var telidInfo = logResult.VersionInfo;
                        textBox_ResultRead.Text += string.Format("SerNo: {0}\n", telidInfo.SerialNumber);
                        textBox_ResultRead.Text += string.Format("Product-Type: {0}\n", telidInfo.ProductType);
                        textBox_ResultRead.Text += "Physical-Data:\n";
                        foreach (var data in telidInfo.PhyisicalData)
                        {
                            textBox_ResultRead.Text += string.Format("\t{0}\n", data);
                        }
                        textBox_ResultRead.Text += string.Format("FW-Version: {0}\n", logResult.FwVersion);
                        textBox_ResultRead.Text += string.Format("IsLogging: {0}\n", logResult.IsLogging);
                        textBox_ResultRead.Text += string.Format("Programmed: {0}\n", logResult.ProgrammedTime);
                        textBox_ResultRead.Text += string.Format("Start: {0}\n", logResult.StartTime);
                        textBox_ResultRead.Text += string.Format("Stop: {0}\n", logResult.StopTime);
                        textBox_ResultRead.Text += string.Format("Datasets: {0}\n", logResult.NumberDatasetsLogged);
                        textBox_ResultRead.Text += string.Format("Mem-Percentage used: {0}\n", logResult.MemoryPercentageUsed);
                        textBox_ResultRead.Text += "SensorParameters: \n";
                        textBox_ResultRead.Text += logResult.SensorParameters.ToString();
                        textBox_ResultRead.Text += string.Format("\nMeasurements read: {0}\n", logResult.LoggedMeasurements.Length);
                        //populate ListBox
                        if (logResult.LoggedMeasurements != null)
                        {
                            List <MeasListboxItem> items = new List <MeasListboxItem>();
                            foreach (var meas in logResult.LoggedMeasurements)
                            {
                                string valuesStr = "";
                                foreach (var value in meas.Values)
                                {
                                    valuesStr += string.Format("{0}{1}", value.Magnitude, value.Unit) + "\t";
                                }
                                if (valuesStr.EndsWith("\t"))
                                {
                                    valuesStr = valuesStr.TrimEnd('\t');
                                }
                                items.Add(new MeasListboxItem()
                                {
                                    Timestamp = meas.Timestamp.ToString("yyyy-MM-dd HH:mm:ss"),
                                    Values    = valuesStr,
                                    State     = string.Format("{0}", meas.Status),
                                    BatState  = string.Format("{0}", meas.BatState)
                                });
                            }
                            listBox_Measurements.ItemsSource = items;
                        }

                        string toLog = string.Format("Result: OK. Duration: {0}\n", processSpan);
                        toLog += "- ReadLog Result -\n";
                        toLog += string.Format("\tSerNo: {0}\n", telidInfo.SerialNumber);
                        toLog += string.Format("\tProduct-Type: {0}\n", telidInfo.ProductType);
                        toLog += string.Format("\tIsLogging: {0}\n", logResult.IsLogging);
                        toLog += string.Format("\tDatasets: {0}\n", logResult.NumberDatasetsLogged);
                        textBox_ThreadLog.Text += toLog;
                        textBox_ThreadLog.ScrollToEnd();
                    }
                    else
                    {
                        //Update result in UI
                        textBox_ThreadLog.Text += string.Format("Result: FAIL. Duration: {0}\n", processSpan);
                        textBox_ThreadLog.ScrollToEnd();
                    }
                }
            }
        }