Exemplo n.º 1
0
        private void btn_read_rtc_Click(object sender, EventArgs e)
        {
            // !B
            try
            {
                GetSerialPorts();
                if (SelectedPort != "")
                {
                    sense_o = new SENSOR_OBJECT(SENSOR_OBJECT.EBaudRate.Baud250000, SelectedPort);
                    sense_o.TEMP_RESPONSE_ARRAY += sense_o_TEMP_RESPONSE_ARRAY;
                    sense_o.GET_RTC_RESPONSE_RECEIVED += Sense_o_GET_RTC_RESPONSE_RECEIVED;
                    sense_o.TIMEOUT_RESPONSE_RECEIVED += Sense_o_TIMEOUT_RESPONSE_RECEIVED;

                    sense_o.Get_RTC();
                }
            }
            catch (Exception Ex)
            {
                //NEW
                if (sense_o != null)
                {
                    sense_o.Dispose();
                    GC.Collect();
                }

                DisplayData(Ex.Message);
                System.Diagnostics.Debug.WriteLine(Ex.Message);
            }
        }
Exemplo n.º 2
0
        private void Set_RTC()
        {
            try
            {
                GetSerialPorts();
                if (SelectedPort != "")
                {
                    sense_o = new SENSOR_OBJECT(SENSOR_OBJECT.EBaudRate.Baud250000, SelectedPort);
                    sense_o.SET_RTC_RESPONSE_RECEIVED += sense_o_SET_RTC_RESPONSE_RECEIVED;
                    sense_o.TEMP_RESPONSE_ARRAY += sense_o_TEMP_RESPONSE_ARRAY;
                    sense_o.TIMEOUT_RESPONSE_RECEIVED += Sense_o_TIMEOUT_RESPONSE_RECEIVED;

                    sense_o.Set_RTC();
                }
                else
                {
                    string Time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    UpdateListView(0, "NO COM PORT", Time, 0);
                }
            }
            catch (Exception Ex)
            {
                System.Diagnostics.Debug.WriteLine(Ex.ToString());
                DisplayData(Ex.ToString());

                if (sense_o != null)
                {
                    sense_o.Dispose();
                    GC.Collect();
                }
            }
        }
Exemplo n.º 3
0
 private void btn_read_rtc_Click(object sender, EventArgs e)
 {
     // !B
     SENSOR_OBJECT sense_o = new SENSOR_OBJECT(SENSOR_OBJECT.EBaudRate.Baud9600, "COM1");
     sense_o.TEMP_RESPONSE_RECEIVED += sense_o_TEMP_RESPONSE_RECEIVED;
 }