Ejemplo n.º 1
0
        // automatic running
        //  /*

        private void pTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            string[] lines_sensor  = System.IO.File.ReadAllLines(korea);
            int      which_channel = 0;

            if (lines_sensor.Length != 0)
            {
                if (initial_changdu != lines_sensor.Length)
                {
                    if (lines_sensor[lines_sensor.Length - 1].Contains("+"))
                    {
                        //eg:1+T-2-1  第一channel,第二个meter,关
                        string [] zhong = lines_sensor[lines_sensor.Length - 1].Split('+');
                        which_channel  = Convert.ToInt32(zhong[0]);
                        textBox12.Text = zhong[1];
                        if ((COM1.IsOpen) && (which_channel == 1))
                        {
                            COM1.Write(zhong[1]);
                            COM1.DiscardOutBuffer();
                            order_record(zhong[1]);
                        }
                        else if ((COM2.IsOpen) && (which_channel == 2))
                        {
                            COM2.Write(zhong[1]);
                            COM2.DiscardOutBuffer();
                            order_record_2(zhong[1]);
                        }
                    }
                }
            }
            GC.Collect();
            initial_changdu = lines_sensor.Length;
        }
Ejemplo n.º 2
0
 // control
 private void control1_Click(object sender, EventArgs e)
 {
     if (COM1.IsOpen)
     {
         string output;
         output = textBox3.Text;
         COM1.Write(output);
         textBox3.Text = "";
         COM1.DiscardOutBuffer();
     }
 }