コード例 #1
0
 /// <summary>
 /// 写入
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void m_btnWrite_Click(object sender, EventArgs e)
 {
     try
     {
         TOCTest.comm.CommPort objCommPort = TOCTest.comm.CommPort.Instance;
         string str             = "FF" + "{0}" + "0x13" + "0x08";
         string m_strSampVmax   = Convert.ToInt64(m_tbSampVmax.Text).ToString("X4");   //内部样品流速
         string m_strSampTimer  = Convert.ToInt64(m_tbSampTimer.Text).ToString("X4");  //在线采样周期
         string m_strChannlSum  = Convert.ToInt64(m_tbChannlSum.Text).ToString("X2");  //在线通道数
         string m_strLTests     = Convert.ToInt64(m_tbLTests.Text).ToString("X2");     //离线测试次数
         string m_strLForsake   = Convert.ToInt64(m_tbLForsake.Text).ToString("X2");   //离线抛弃次数
         string m_strLCleartime = Convert.ToInt64(m_tbLCleartime.Text).ToString("X4"); //离线冲洗时间
         string m_strTOCAlarmup = Convert.ToInt64(m_tbTOCAlarmup.Text).ToString("X4"); //TOC报警上限
         string m_strUSAlarmup  = Convert.ToInt64(m_tbUSAlarmup.Text).ToString("X4");  //电导率报警上限
         int    nStorMode       = TOCTest.utils.help.Asc(m_tbStorMode.Text);
         string m_strStorMode   = nStorMode.ToString("X2");;                           //数据存储方式
         str = str + m_strSampVmax + m_strSampTimer + m_strChannlSum + m_strLTests + m_strLForsake + m_strLCleartime + m_strTOCAlarmup + m_strUSAlarmup + m_strStorMode + "00";
         str = string.Format(str, TOCTest.db.dbMrg.QueryDeviceNum(TOCTest.Main.ms_strDeviceName));
         byte[] byDate = TOCTest.utils.help.getCheckSum(str);
         objCommPort.Send(byDate);
         TOCTest.utils.loghelp.log.Debug(string.Format("发送启动测试参数数据{0}", TOCTest.utils.help.ByteToHexStr(byDate).ToString()));
     }
     catch (Exception ex)
     {
         TOCTest.utils.loghelp.log.Error(ex.Message, ex);
     }
 }
コード例 #2
0
        /// <summary>
        /// 写入
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void m_btnWrite_Click(object sender, EventArgs e)
        {
            try
            {
                TOCTest.comm.CommPort objCommPort = TOCTest.comm.CommPort.Instance;
                string str           = "FF" + "{0}" + "0x00" + "0x19" + "0x57" + "0x50";
                string m_strSampVmax = Convert.ToInt64(m_tbSampVmax.Text).ToString("X4");       //内部样品流速
                // string m_strSampTimer = Convert.ToInt64(m_tbSampTimer.Text).ToString("X4");      //在线采样周期
                string m_strChannlSum  = Convert.ToInt64(m_tbChannlSum.Text).ToString("X2");    //在线通道数
                string m_strLTests     = Convert.ToInt64(m_tbLTests.Text).ToString("X2");       //离线测试次数
                string m_strLForsake   = Convert.ToInt64(m_tbLForsake.Text).ToString("X2");     //离线抛弃次数
                string m_strLCleartime = Convert.ToInt64(m_tbLCleartime.Text).ToString("X4");   //离线冲洗时间
                string m_strTOCAlarmup = Convert.ToInt64(m_tbTOCAlarmup.Text).ToString("X4");   //TOC报警上限
                string m_strUSAlarmup  = Convert.ToInt64(m_tbUSAlarmup.Text).ToString("X4");    //电导率报警上限
                int    nStorMode       = 0;
                if (m_cbStorMode.Text == "自动")
                {
                    nStorMode = 1;
                }
                string m_strStorMode = nStorMode.ToString("X2");;       //数据存储方式
                string m_strUvLamp   = Convert.ToInt64(m_tbUvLamp.Text).ToString("X4");
                string m_strPumpPipe = Convert.ToInt64(m_tbPumpPipe.Text).ToString("X4");
                str = str + m_strSampVmax + /*m_strSampTimer + */ m_strChannlSum + m_strLTests + m_strLForsake + m_strLCleartime + m_strTOCAlarmup + m_strUSAlarmup + m_strStorMode + m_strUvLamp + m_strPumpPipe + "00";
                str = string.Format(str, TOCTest.db.dbMrg.QueryDeviceNum(TOCTest.Main.ms_strDeviceName));
                byte[] byDate = TOCTest.utils.help.getCheckSum(str);
                objCommPort.Send(byDate);
                string strDBInfo = "Select * From {0} where [name]='" + Main.ms_strDeviceName.ToString() + "'";
                strDBInfo = string.Format(strDBInfo, Main.ms_strDeviceName.ToString());
                bool bExist = db.dbMrg.QueryExistDB("Provider=Microsoft.Jet.OLEDB.4.0;  Data Source=..\\..\\mdb\\SystemParameter.mdb", strDBInfo);
                if (!bExist)
                {
                    string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;  Data Source=..\\..\\mdb\\SystemParameter.mdb";
                    string strInfo       = String.Format("insert into {0} ([name],[SampVmax],[SampTimer],[ChannlSum],[LTests],[LForsake],[LCleartime],[TOCAlarmup],[USAlarmup],[StorMode],[UvLamp],[PumpPipe])values ('{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}')",
                                                         Main.ms_strDeviceName, Main.ms_strDeviceName, m_tbSampVmax.Text, /*m_tbSampTimer.Text*/ "", m_tbChannlSum.Text,
                                                         m_tbLTests.Text, m_tbLForsake.Text, m_tbLCleartime.Text, m_tbTOCAlarmup.Text, m_tbUSAlarmup.Text,
                                                         m_cbStorMode.Text, m_tbUvLamp.Text, m_tbPumpPipe.Text);
                    TOCTest.db.dbMrg.AlterDB(strConnection, strInfo);
                }
                else
                {
                    string strConnection = "Provider=Microsoft.Jet.OLEDB.4.0;  Data Source=..\\..\\mdb\\SystemParameter.mdb";
                    string strInfo       = "update {0} set [name]='" + "{1}" + "',[SampVmax]='" + "{2}" + "',[SampTimer]='" + "{3}" + "',[ChannlSum]='" + "{4}"
                                           + "',[LTests]='" + "{5}" + "',[LForsake]='" + "{6}" + "',[LCleartime]='" + "{7}" + "',[TOCAlarmup]='" + "{8}"
                                           + "',[USAlarmup]='" + "{9}" + "',[StorMode]='" + "{10}" + "',[UvLamp]='" + "{11}" + "',[PumpPipe]='" + "{12}"
                                           + "' where [name]='" + Main.ms_strDeviceName + "'";
                    strInfo = string.Format(strInfo, Main.ms_strDeviceName, Main.ms_strDeviceName, m_tbSampVmax.Text, /*m_tbSampTimer.Text*/ "", m_tbChannlSum.Text,
                                            m_tbLTests.Text, m_tbLForsake.Text, m_tbLCleartime.Text, m_tbTOCAlarmup.Text, m_tbUSAlarmup.Text,
                                            m_cbStorMode.Text, m_tbUvLamp.Text, m_tbPumpPipe.Text);
                    TOCTest.db.dbMrg.AlterDB(strConnection, strInfo);
                }

                TOCTest.utils.loghelp.log.Debug(string.Format("发送启动测试参数数据{0}", TOCTest.utils.help.ByteToHexStr(byDate).ToString()));
            }
            catch (Exception ex)
            {
                TOCTest.utils.loghelp.log.Error(ex.Message, ex);
            }
        }
コード例 #3
0
 /// <summary>
 /// 读取
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void m_btnRead_Click(object sender, EventArgs e)
 {
     try
     {
         TOCTest.comm.CommPort objCommPort = TOCTest.comm.CommPort.Instance;
         string str = "FF" + "{0}" + "0x00" + "0x07" + "0x52" + "0x50" + "00";
         str = string.Format(str, TOCTest.db.dbMrg.QueryDeviceNum(TOCTest.Main.ms_strDeviceName));
         byte[] byDate = TOCTest.utils.help.getCheckSum(str);
         objCommPort.Send(byDate);
         TOCTest.utils.loghelp.log.Debug(string.Format("发送启动测试参数数据{0}", TOCTest.utils.help.ByteToHexStr(byDate).ToString()));
     }
     catch (Exception ex)
     {
         TOCTest.utils.loghelp.log.Error(ex.Message, ex);
     }
 }
コード例 #4
0
 /// <summary>
 /// 启动测试
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void m_btnStart_Click(object sender, EventArgs e)
 {
     try
     {
         TOCTest.comm.CommPort objCommPort = TOCTest.comm.CommPort.Instance;
         objCommPort.Send(TOCTest.forms.TestMrg.ms_byDate);
         this.m_btnStart.Enabled = false;
         this.m_btnStop.Enabled  = true;
         Main.ms_objMain.timerPollingInquiryStart();
         m_tbUserInfo.Text = m_tbUserInfo.Text + DateTime.Now + "---------用户:" + TOCTest.forms.UserInfo.m_strUserName + "启动测试!\r\n";
     }
     catch (Exception ex)
     {
         TOCTest.utils.loghelp.log.Error(ex.Message, ex);
     }
 }
コード例 #5
0
 private void read()
 {
     try
     {
         TOCTest.comm.CommPort objCommPort = TOCTest.comm.CommPort.Instance;
         string str = "FF" + "{0}" + "0x00" + "0x07" + "0x52" + "0x41" + "00";
         str = string.Format(str, TOCTest.db.dbMrg.QueryDeviceNum(TOCTest.Main.ms_strDeviceName));
         byte[] byDate = TOCTest.utils.help.getCheckSum(str);
         objCommPort.Send(byDate);
         TOCTest.utils.loghelp.log.Debug(string.Format("Sending read audit data {0}", TOCTest.utils.help.ByteToHexStr(byDate).ToString()));
     }
     catch (Exception ex)
     {
         TOCTest.utils.loghelp.log.Error(ex.Message, ex);
     }
 }
コード例 #6
0
 /// <summary>
 /// 停止测试
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void m_btnStop_Click(object sender, EventArgs e)
 {
     try
     {
         TOCTest.comm.CommPort objCommPort = TOCTest.comm.CommPort.Instance;
         string str = "FF" + "{0}" + "0x00" + "0x07" + "0x43" + "0x53" + "00";
         str = string.Format(str, TOCTest.db.dbMrg.QueryDeviceNum(TOCTest.Main.ms_strDeviceName));
         byte[] byDate = TOCTest.utils.help.getCheckSum(str);
         objCommPort.Send(byDate);
         TOCTest.utils.loghelp.log.Debug(string.Format("发送启动测试参数数据{0}", TOCTest.utils.help.ByteToHexStr(byDate).ToString()));
         this.m_btnStart.Enabled = true;
         this.m_btnStop.Enabled  = false;
         Main.ms_objMain.timerPollingInquiryStop();
         m_tbUserInfo.Text = m_tbUserInfo.Text + DateTime.Now + "---------用户:" + TOCTest.forms.UserInfo.m_strUserName + "停止测试!\r\n";
     }
     catch (Exception ex)
     {
         TOCTest.utils.loghelp.log.Error(ex.Message, ex);
     }
 }
コード例 #7
0
        /// <summary>
        /// Update the connection status
        /// </summary>
        public void OnStatusChanged(TOCTest.comm.SystemState data)
        {
            try
            {
                //Handle multi-threading
                if (InvokeRequired)
                {
                    Invoke(new ResultDelegate(OnStatusChanged), new object[] { data });
                    return;
                }
                listArray.Add(data);
                TestTOC(m_zgcTest, data);
                if (data.m_strRunStatus == "S")
                {
                    if (data.m_strTestType == "1")
                    {
                        TestResult objTestResult = new TestResult();
                        objTestResult.ShowDialog();
                    }

                    if (data.m_strTestType == "3")
                    {
                        ConResult objConResult = new ConResult();
                        objConResult.ShowDialog();
                    }

                    TOCTest.comm.CommPort objCommPort = TOCTest.comm.CommPort.Instance;
                    string str = "FF" + "{0}" + "0x00" + "0x07" + "0x52" + "0x52" + "00";
                    str = string.Format(str, TOCTest.db.dbMrg.QueryDeviceNum(TOCTest.Main.ms_strDeviceName));
                    byte[] byDate = TOCTest.utils.help.getCheckSum(str);
                    objCommPort.Send(byDate);
                    TOCTest.utils.loghelp.log.Debug(string.Format("读取测试结果值{0}", TOCTest.utils.help.ByteToHexStr(byDate).ToString()));
                }
            }
            catch (Exception ex)
            {
                utils.loghelp.log.Error(ex.Message, ex);
            }
        }