Esempio n. 1
0
        private void AutoRun_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            string RCommand;

            RCommand = ComPort.AutoReceived();

            if (TBOX_Info.InvokeRequired)
            {
                TimeSpan mntOnTime = DateTime.Now - sendOnTime;
                TBOX_Info.Invoke(new Action(() => {
                    WriteMsgToTextBox("MNT ON Time: " + mntOnTime.Seconds + mntOnTime.Milliseconds);
                    File.AppendAllText(@"D:\log.txt", "MNT ON Time: " + mntOnTime.Seconds + mntOnTime.Milliseconds + "\r\n");
                }));
            }
        }
Esempio n. 2
0
        private void SendDataTimerTick()
        {
            if (isTimerInvalid == false)
            {
                ComPort.AutonACSwitch(isACON);
                long   msTimes   = sw.ElapsedMilliseconds; //取得執行時間
                string AC_Status = (isACON == true) ? "ON " : "OFF";
                TBOX_Info.Invoke(new Action(() => {
                    WriteMsgToTextBox(SendDatatCounter + "   " + AC_Status + "    " + "waitTime: " + Math.Abs(msTimes) + " [ms]" + "  Dec = " + decDelayTime + "  rep" + repeatTime);
                    WriteMsgToText(SendDatatCounter + "   " + AC_Status + "    " + "waitTime: " + Math.Abs(msTimes) + " [ms]" + "  Dec = " + decDelayTime + "  rep" + repeatTime);
                }));

                CheckCounter(SendDatatCounter);
                isACON = (isACON == true) ? false : true;
                StartWatchControl();
            }
        }
Esempio n. 3
0
        private void Btn_SaveTextFile_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter       = "txt files (*.txt)|*.txt|all files|*.*";
            sfd.FileName     = "Log";
            sfd.DefaultExt   = "txt";
            sfd.AddExtension = true;
            if (sfd.ShowDialog() == DialogResult.OK &&
                sfd.FileName.Length > 0)
            {
                MessageBox.Show("Save Path: " + sfd.FileName.ToString());  //印出儲存路徑
                File.Copy(@"D:\log.txt", @sfd.FileName.ToString());
            }
            TBOX_Info.Clear();
            File.Delete(@"D:\log.txt");
            Application.Exit();
        }
Esempio n. 4
0
 public void WriteMsgToTextBox(string str) //write message to text box
 {
     TBOX_Info.AppendText(str + Environment.NewLine);
     TBOX_Info.ScrollBars = System.Windows.Forms.ScrollBars.Both;
 }