/// <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); } }
/// <summary> /// 测试曲线 /// </summary> /// <param name="zgc"></param> private void TestTOC(ZedGraphControl zgc, TOCTest.comm.SystemState data) { try { GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); PointPairList list = new PointPairList(); PointPairList listIC = new PointPairList(); PointPairList listCON = new PointPairList(); string strTestType = TestMrg.ms_strTestType; switch (data.m_strTestType) { case "2": strTestType = "在线测试"; break; case "1": strTestType = "离线测试"; break; case "3": strTestType = "系统适应性验证"; break; case "C": strTestType = "零点校准"; break; default: break; } // Set the titles and axis labels string strTitle = string.Format("站点{0},{1}", Main.ms_strDeviceName, strTestType); myPane.Title.Text = strTitle; myPane.XAxis.Title.Text = "时间"; myPane.YAxis.Title.Text = "浓度"; myPane.XAxis.Scale.Min = 0.0; myPane.XAxis.Scale.Max = 6.0; myPane.YAxis.Scale.Min = 0.0; myPane.YAxis.Scale.Max = 1100.0; myPane.XAxis.Scale.MinorStep = 2; myPane.XAxis.Scale.MajorStep = 2; myPane.XAxis.Type = AxisType.DateAsOrdinal; myPane.XAxis.Scale.Format = "mm:ss"; myPane.YAxis.Scale.MinorStep = 11; myPane.YAxis.Scale.MajorStep = 11; LineItem mcurve = myPane.AddCurve("TOC (mg/L)", list, Color.Blue, SymbolType.None); LineItem mcureTIC = myPane.AddCurve("IC (mg/L)", listIC, Color.Green, SymbolType.None); LineItem mcurveCon = myPane.AddCurve("CON (mg/L)", listCON, Color.Chocolate, SymbolType.None); int nTemp = 0; foreach (TOCTest.comm.SystemState objList in listArray) { list.Add(nTemp, Convert.ToInt32(objList.m_strTOCValue)); listIC.Add(nTemp, Convert.ToInt32(objList.m_strTIC_Value)); listCON.Add(nTemp, Convert.ToInt32(objList.m_strCON_Value)); nTemp++; } DealTOCView(listArray); zgc.Refresh(); } catch (Exception ex) { TOCTest.utils.loghelp.log.Error(ex.Message, ex); } }