diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..2796a25 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -19,6 +19,7 @@ int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..2796a25 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -19,6 +19,7 @@ int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..6b8c687 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -321,6 +321,56 @@ } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = new DetectionItem(); + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..2796a25 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -19,6 +19,7 @@ int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..6b8c687 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -321,6 +321,56 @@ } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = new DetectionItem(); + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 9bfde8e..d0f942c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -43,15 +43,14 @@ try { //tcpService.write("INIT"); - //tcpService.write("*WAI"); //freqRequest++; //Thread.Sleep(2000); //tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:FREQ?"); - //tcpService.write("READ?"); + Thread.Sleep(2000); + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); //Thread.Sleep(1000); return tcpService.read(); @@ -68,17 +67,16 @@ { try { - + //tcpService.write("INIT"); + //tcpService.write("*WAI"); //tcpService.write("INIT"); //tcpService.write("*WAI"); - - //tcpService.write("INIT"); - - //tcpService.write("*WAI"); - tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:PERIOD?"); + //tcpService.write("*CLS"); + Thread.Sleep(2000); + //tcpService.write("MEAS:PERIOD?"); + + tcpService.write("READ?"); return tcpService.read(); } @@ -100,5 +98,32 @@ LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setIMP:" + ex.Message); } } + + public static void setFreqModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:FREQ"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setFreqModel:" + ex.Message); + } + } + + public static void setPerModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:PER"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setPerModel:" + ex.Message); + } + } + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..2796a25 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -19,6 +19,7 @@ int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..6b8c687 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -321,6 +321,56 @@ } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = new DetectionItem(); + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 9bfde8e..d0f942c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -43,15 +43,14 @@ try { //tcpService.write("INIT"); - //tcpService.write("*WAI"); //freqRequest++; //Thread.Sleep(2000); //tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:FREQ?"); - //tcpService.write("READ?"); + Thread.Sleep(2000); + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); //Thread.Sleep(1000); return tcpService.read(); @@ -68,17 +67,16 @@ { try { - + //tcpService.write("INIT"); + //tcpService.write("*WAI"); //tcpService.write("INIT"); //tcpService.write("*WAI"); - - //tcpService.write("INIT"); - - //tcpService.write("*WAI"); - tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:PERIOD?"); + //tcpService.write("*CLS"); + Thread.Sleep(2000); + //tcpService.write("MEAS:PERIOD?"); + + tcpService.write("READ?"); return tcpService.read(); } @@ -100,5 +98,32 @@ LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setIMP:" + ex.Message); } } + + public static void setFreqModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:FREQ"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setFreqModel:" + ex.Message); + } + } + + public static void setPerModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:PER"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setPerModel:" + ex.Message); + } + } + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index 8ad1a8a..9916a9c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -89,7 +89,7 @@ hasException = true; } - if (!hasException) _portOperatorBaseTcp.Timeout = 2000; + if (!hasException) _portOperatorBaseTcp.Timeout = 1000; return hasAddress; } @@ -134,12 +134,13 @@ string content = ""; try { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType,"TCPRead:"+DateTime.Now); content = _portOperatorBaseTcp.ReadLine(); } catch (Exception ex) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterId : " + ex.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "TCPRead: " + ex.Message); content = ""; } return content; diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..2796a25 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -19,6 +19,7 @@ int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..6b8c687 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -321,6 +321,56 @@ } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = new DetectionItem(); + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 9bfde8e..d0f942c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -43,15 +43,14 @@ try { //tcpService.write("INIT"); - //tcpService.write("*WAI"); //freqRequest++; //Thread.Sleep(2000); //tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:FREQ?"); - //tcpService.write("READ?"); + Thread.Sleep(2000); + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); //Thread.Sleep(1000); return tcpService.read(); @@ -68,17 +67,16 @@ { try { - + //tcpService.write("INIT"); + //tcpService.write("*WAI"); //tcpService.write("INIT"); //tcpService.write("*WAI"); - - //tcpService.write("INIT"); - - //tcpService.write("*WAI"); - tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:PERIOD?"); + //tcpService.write("*CLS"); + Thread.Sleep(2000); + //tcpService.write("MEAS:PERIOD?"); + + tcpService.write("READ?"); return tcpService.read(); } @@ -100,5 +98,32 @@ LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setIMP:" + ex.Message); } } + + public static void setFreqModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:FREQ"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setFreqModel:" + ex.Message); + } + } + + public static void setPerModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:PER"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setPerModel:" + ex.Message); + } + } + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index 8ad1a8a..9916a9c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -89,7 +89,7 @@ hasException = true; } - if (!hasException) _portOperatorBaseTcp.Timeout = 2000; + if (!hasException) _portOperatorBaseTcp.Timeout = 1000; return hasAddress; } @@ -134,12 +134,13 @@ string content = ""; try { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType,"TCPRead:"+DateTime.Now); content = _portOperatorBaseTcp.ReadLine(); } catch (Exception ex) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterId : " + ex.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "TCPRead: " + ex.Message); content = ""; } return content; diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 936cc37..a3daf40 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -571,7 +571,7 @@ break; case 3: // 频率计数器范围 - CounterCtrlForm counterForm = new CounterCtrlForm(); + CounterCtrlForm counterForm = CounterCtrlForm.GetInstance(); counterForm.Show(); panelMain.Controls.Add(counterForm); break; diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..2796a25 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -19,6 +19,7 @@ int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..6b8c687 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -321,6 +321,56 @@ } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = new DetectionItem(); + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 9bfde8e..d0f942c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -43,15 +43,14 @@ try { //tcpService.write("INIT"); - //tcpService.write("*WAI"); //freqRequest++; //Thread.Sleep(2000); //tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:FREQ?"); - //tcpService.write("READ?"); + Thread.Sleep(2000); + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); //Thread.Sleep(1000); return tcpService.read(); @@ -68,17 +67,16 @@ { try { - + //tcpService.write("INIT"); + //tcpService.write("*WAI"); //tcpService.write("INIT"); //tcpService.write("*WAI"); - - //tcpService.write("INIT"); - - //tcpService.write("*WAI"); - tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:PERIOD?"); + //tcpService.write("*CLS"); + Thread.Sleep(2000); + //tcpService.write("MEAS:PERIOD?"); + + tcpService.write("READ?"); return tcpService.read(); } @@ -100,5 +98,32 @@ LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setIMP:" + ex.Message); } } + + public static void setFreqModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:FREQ"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setFreqModel:" + ex.Message); + } + } + + public static void setPerModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:PER"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setPerModel:" + ex.Message); + } + } + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index 8ad1a8a..9916a9c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -89,7 +89,7 @@ hasException = true; } - if (!hasException) _portOperatorBaseTcp.Timeout = 2000; + if (!hasException) _portOperatorBaseTcp.Timeout = 1000; return hasAddress; } @@ -134,12 +134,13 @@ string content = ""; try { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType,"TCPRead:"+DateTime.Now); content = _portOperatorBaseTcp.ReadLine(); } catch (Exception ex) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterId : " + ex.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "TCPRead: " + ex.Message); content = ""; } return content; diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 936cc37..a3daf40 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -571,7 +571,7 @@ break; case 3: // 频率计数器范围 - CounterCtrlForm counterForm = new CounterCtrlForm(); + CounterCtrlForm counterForm = CounterCtrlForm.GetInstance(); counterForm.Show(); panelMain.Controls.Add(counterForm); break; diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 876c624..b0a8196 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..2796a25 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -19,6 +19,7 @@ int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..6b8c687 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -321,6 +321,56 @@ } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = new DetectionItem(); + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 9bfde8e..d0f942c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -43,15 +43,14 @@ try { //tcpService.write("INIT"); - //tcpService.write("*WAI"); //freqRequest++; //Thread.Sleep(2000); //tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:FREQ?"); - //tcpService.write("READ?"); + Thread.Sleep(2000); + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); //Thread.Sleep(1000); return tcpService.read(); @@ -68,17 +67,16 @@ { try { - + //tcpService.write("INIT"); + //tcpService.write("*WAI"); //tcpService.write("INIT"); //tcpService.write("*WAI"); - - //tcpService.write("INIT"); - - //tcpService.write("*WAI"); - tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:PERIOD?"); + //tcpService.write("*CLS"); + Thread.Sleep(2000); + //tcpService.write("MEAS:PERIOD?"); + + tcpService.write("READ?"); return tcpService.read(); } @@ -100,5 +98,32 @@ LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setIMP:" + ex.Message); } } + + public static void setFreqModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:FREQ"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setFreqModel:" + ex.Message); + } + } + + public static void setPerModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:PER"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setPerModel:" + ex.Message); + } + } + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index 8ad1a8a..9916a9c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -89,7 +89,7 @@ hasException = true; } - if (!hasException) _portOperatorBaseTcp.Timeout = 2000; + if (!hasException) _portOperatorBaseTcp.Timeout = 1000; return hasAddress; } @@ -134,12 +134,13 @@ string content = ""; try { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType,"TCPRead:"+DateTime.Now); content = _portOperatorBaseTcp.ReadLine(); } catch (Exception ex) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterId : " + ex.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "TCPRead: " + ex.Message); content = ""; } return content; diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 936cc37..a3daf40 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -571,7 +571,7 @@ break; case 3: // 频率计数器范围 - CounterCtrlForm counterForm = new CounterCtrlForm(); + CounterCtrlForm counterForm = CounterCtrlForm.GetInstance(); counterForm.Show(); panelMain.Controls.Add(counterForm); break; diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 876c624..b0a8196 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index 4094808..0026ae3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.btn_dropDetecModel = new System.Windows.Forms.Button(); @@ -60,9 +63,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -87,13 +87,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -106,13 +106,13 @@ this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle4.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -121,7 +121,6 @@ this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); this.dataGridView_CounterResult.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellEndEdit); - this.dataGridView_CounterResult.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellValueChanged); // // panelMedian // @@ -147,6 +146,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -158,6 +205,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -438,78 +509,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..2796a25 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -19,6 +19,7 @@ int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..6b8c687 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -321,6 +321,56 @@ } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = new DetectionItem(); + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 9bfde8e..d0f942c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -43,15 +43,14 @@ try { //tcpService.write("INIT"); - //tcpService.write("*WAI"); //freqRequest++; //Thread.Sleep(2000); //tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:FREQ?"); - //tcpService.write("READ?"); + Thread.Sleep(2000); + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); //Thread.Sleep(1000); return tcpService.read(); @@ -68,17 +67,16 @@ { try { - + //tcpService.write("INIT"); + //tcpService.write("*WAI"); //tcpService.write("INIT"); //tcpService.write("*WAI"); - - //tcpService.write("INIT"); - - //tcpService.write("*WAI"); - tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:PERIOD?"); + //tcpService.write("*CLS"); + Thread.Sleep(2000); + //tcpService.write("MEAS:PERIOD?"); + + tcpService.write("READ?"); return tcpService.read(); } @@ -100,5 +98,32 @@ LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setIMP:" + ex.Message); } } + + public static void setFreqModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:FREQ"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setFreqModel:" + ex.Message); + } + } + + public static void setPerModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:PER"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setPerModel:" + ex.Message); + } + } + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index 8ad1a8a..9916a9c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -89,7 +89,7 @@ hasException = true; } - if (!hasException) _portOperatorBaseTcp.Timeout = 2000; + if (!hasException) _portOperatorBaseTcp.Timeout = 1000; return hasAddress; } @@ -134,12 +134,13 @@ string content = ""; try { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType,"TCPRead:"+DateTime.Now); content = _portOperatorBaseTcp.ReadLine(); } catch (Exception ex) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterId : " + ex.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "TCPRead: " + ex.Message); content = ""; } return content; diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 936cc37..a3daf40 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -571,7 +571,7 @@ break; case 3: // 频率计数器范围 - CounterCtrlForm counterForm = new CounterCtrlForm(); + CounterCtrlForm counterForm = CounterCtrlForm.GetInstance(); counterForm.Show(); panelMain.Controls.Add(counterForm); break; diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 876c624..b0a8196 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index 4094808..0026ae3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.btn_dropDetecModel = new System.Windows.Forms.Button(); @@ -60,9 +63,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -87,13 +87,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -106,13 +106,13 @@ this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle4.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -121,7 +121,6 @@ this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); this.dataGridView_CounterResult.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellEndEdit); - this.dataGridView_CounterResult.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellValueChanged); // // panelMedian // @@ -147,6 +146,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -158,6 +205,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -438,78 +509,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index fd7ffee..357a90c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -22,6 +22,7 @@ DeviceService deviceService = new DeviceServiceImpl(); DictService dictService = new DictServiceImpl(); CounterDetecInitService counterDetecInitService = new CounterDetecInitServiceImpl(); + CounterDataService counterDataService = new CounterDataServiceImpl(); SensitivityService sensitivityService = new SensitivityServiceImpl(); @@ -32,8 +33,7 @@ string devPort = "输入A"; long deviceId = 0; bool isAdd = false; - bool detected = false; - public static bool isDetecting = false; + //public static bool isDetecting = false; GPIBService gPIBService = new GPIBServiceImpl(); GPIBService tcpService = new TCPServiceImpl(); @@ -44,8 +44,19 @@ private readonly Color titleBackColor = Color.FromArgb(63, 132, 215); // #3F64D7 private readonly Font titleFont = new Font("微软雅黑", 14F, FontStyle.Regular, GraphicsUnit.Pixel, 134); #endregion + - public CounterCtrlForm() + private static CounterCtrlForm _counterCtrlForm = null; + + public static CounterCtrlForm GetInstance() + { + if (_counterCtrlForm == null) + _counterCtrlForm = new CounterCtrlForm(); + + return _counterCtrlForm; + } + + private CounterCtrlForm() { InitializeComponent(); @@ -56,8 +67,7 @@ comboBox_counters.ValueMember = "Id"; InitTableCounter(); LoadCounterDetecInitList(); - - + if (list != null && list.Count > 0) { string[] ids = gPIBService.getId(); @@ -111,7 +121,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(48, 0), + Location = new Point(46, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); @@ -126,12 +136,27 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(142, 0), + Location = new Point(145, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); colDevNo.BringToFront(); + // 描述/端口 + Label colDevPort = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "描述", + Location = new Point(242, 0), + Size = new Size(50, 50) + }; + dataGridView_CounterResult.Controls.Add(colDevPort); + colDevPort.BringToFront(); + // 标称值 colStdValue = new Label { @@ -141,7 +166,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(247, 0), + Location = new Point(285, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -156,7 +181,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(360, 0), + Location = new Point(377, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colValue); @@ -171,7 +196,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(465, 0), + Location = new Point(480, 0), Size = new Size(95, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); @@ -190,23 +215,11 @@ }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); - - - + } private void LoadCounterDetecInitList() { - //dataGridView_CounterResult.Columns.Add("index", ""); - //dataGridView_CounterResult.Columns.Add("devType", ""); - //dataGridView_CounterResult.Columns.Add("devNo", ""); - //dataGridView_CounterResult.Columns.Add("devPort", ""); - //dataGridView_CounterResult.Columns.Add("stdValue", ""); - //dataGridView_CounterResult.Columns.Add("value", ""); - //dataGridView_CounterResult.Columns.Add("sensitivity", ""); - //dataGridView_CounterResult.Columns.Add("logTime", ""); - //dataGridView_CounterResult.Columns.Add("id", ""); - table_counterDetecInit = new DataTable(); table_counterDetecInit.Columns.Add("index", Type.GetType("System.String")); @@ -221,8 +234,8 @@ table_counterDetecInit.Columns.Add("counterDataId", Type.GetType("System.Int64")); if (text_devName.Text != "") - { - List list =deviceService.search(text_devName.Text,"","","","",""); + { + List list = deviceService.search(text_devName.Text, "", "", "", "", ""); if (null != list && list.Count > 0) { devType = list[0].DevTypeName; @@ -237,7 +250,7 @@ int index = 1; foreach (CounterData counterData in counterDataList) { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterData.OutValue, counterData.Value,counterData.Sensitivity, counterData.LogTime, -1, counterData.Id); + table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterData.OutValue, counterData.Value, counterData.Sensitivity, counterData.LogTime, -1, counterData.Id); index++; } } @@ -260,12 +273,11 @@ } index++; } - } + } } dataGridView_CounterResult.DataSource = table_counterDetecInit; - dataGridView_CounterResult.Columns[3].Visible = false; dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; @@ -273,10 +285,11 @@ dataGridView_CounterResult.Columns[0].Width = 50; dataGridView_CounterResult.Columns[1].Width = 95; dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[4].Width = 110; - dataGridView_CounterResult.Columns[5].Width = 110; - dataGridView_CounterResult.Columns[6].Width = 90; - dataGridView_CounterResult.Columns[7].Width = 140; + dataGridView_CounterResult.Columns[3].Width = 50; + dataGridView_CounterResult.Columns[4].Width = 85; + dataGridView_CounterResult.Columns[5].Width = 105; + dataGridView_CounterResult.Columns[6].Width = 85; + dataGridView_CounterResult.Columns[7].Width = 129; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -300,12 +313,7 @@ text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); - - detected = false; - if (gPIBService.getId() != null && gPIBService.getId().Length > 0) - { - text_signal.Text = gPIBService.getId()[0]; - } + if (tcpService.getId() != null && tcpService.getId().Length > 0) { text_counterIp.Text = tcpService.getId()[0].Split(':')[2]; @@ -350,7 +358,7 @@ } } - + private void benDelete_Click(object sender, EventArgs e) { @@ -466,14 +474,7 @@ { output = cyc * 1000 * 1000 * 1000 + "ns"; } - - //if (output.Contains(".")) - //{ - // if (output.Length >= output.IndexOf('.') + 3) output = output.Substring(0, output.IndexOf('.') + 3) + output.Substring(output.Length-2); - // else output = output.Substring(0, output.IndexOf('.') + 2) + output.Substring(output.Length - 2); - - - //} + } else if (input.Contains("s")) @@ -514,10 +515,6 @@ } - private void dataGridView_CounterResult_CellValueChanged(object sender, DataGridViewCellEventArgs e) - { - - } private void btnStart_Click(object sender, EventArgs e) { @@ -532,106 +529,76 @@ return; } + + dataGridView_CounterResult.ReadOnly = true; - isDetecting = true; btn_add.Enabled = false; benDelete.Enabled = false; btn_dropDetecModel.Enabled = false; - string[] ids = gPIBService.getId(); - //string[] ips = tcpService.getId(); - /*if (ids != null && ids.Length > 0) - { - text_signal.Text = ids[0]; - } - string[] ips = tcpService.getId(); - if (ips != null && ips.Length > 0) - { - text_counterIp.Text = ips[0].Split(':')[2]; - } - else - { - //MessageBox.Show("请连接信号源!"); - return; - } - if (text_counterIp.Text.Equals("")) - { - MessageBox.Show("请输入频率计数器IP!"); - return; - } - else - {*/ string[] arr = text_counterIp.Text.Split('.'); - if (arr.Length != 4) + if (arr.Length != 4) + { + MessageBox.Show("请输入正确的频率计数器IP!"); + return; + } + else + { + foreach (string ipEle in arr) { - MessageBox.Show("请输入正确的频率计数器IP!"); - return; - } - else - { - foreach (string ipEle in arr) + string pattern = @"^[0-9]+$"; + Regex regex = new Regex(pattern); + if (!regex.IsMatch(ipEle)) { - string pattern = @"^[0-9]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(ipEle)) + MessageBox.Show("请输入正确的频率计数器IP!"); + return; + } + else + { + if (Convert.ToInt32(ipEle) < 0 || Convert.ToInt32(ipEle) > 255) { MessageBox.Show("请输入正确的频率计数器IP!"); return; } - else - { - if (Convert.ToInt32(ipEle) < 0 || Convert.ToInt32(ipEle) > 255) - { - MessageBox.Show("请输入正确的频率计数器IP!"); - return; - } - } } } - //} - //if (ips != null && ips.Length > 0) - //{ - // text_counterIp.Text = ips[0]; - //} - //else - //{ - // MessageBox.Show("请连接频率计数器!"); - // return; - //} - + } + text_devName.ReadOnly = true; btn_downCounterList.Enabled = false; btnStart.Enabled = false; btn_dropDetecModel.Enabled = false; textBox_detecModel.ReadOnly = true; - SetDevTestDlg.inDetecCounterId = deviceId; + //SetDevTestDlg.inDetecCounterId = deviceId; + string type = textBox_detecModel.Text.Equals("频率测量") ? "freq" : "period"; string typeId = type.Equals("freq") ? "1" : "2"; new Thread(() => { - // 获取数据 - List counterDetecInitList = counterDetecInitService.getAll(); - - CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); - - int gpibConnection=gPIBService.open(text_signal.Text); - int tcpConnection=tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); - + int gpibConnection = gPIBService.open(text_signal.Text); if (gpibConnection == -1) { MessageBox.Show("未连接信号源"); changeBox(); return; } - else if (tcpConnection == -1) + + int tcpConnection = tcpService.open("TCPIP0::" + text_counterIp.Text + "::INSTR"); + if (tcpConnection == -1) { MessageBox.Show("未连接计数器"); changeBox(); return; } - //tcpService.open(text_counterIp.Text); + detecModelConf(); + + // 获取数据 + List counterDetecInitList = counterDetecInitService.getAll(); + + CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); + int index = 0; foreach (DataGridViewRow row in dataGridView_CounterResult.Rows) { @@ -651,7 +618,7 @@ int re = sensitivityService.beginTest(type, gPIBService, tcpService, counterCheckParam, ref sensitivityContentParam);//0:成功;-1:失败 string value = ""; if (re == 0) - { + { value = type.Equals("freq") ? sensitivityContentParam.ReFreq : sensitivityContentParam.RePeriod; } long dataId = counterDataService.add(deviceId, row.Cells[4].Value.ToString(), value, sensitivityContentParam.VolTage, sensitivityContentParam.CheckTime.ToString("yyyy-MM-dd HH:mm:ss"), typeId); @@ -659,14 +626,18 @@ row.Cells[5].Value = value; row.Cells[6].Value = sensitivityContentParam.VolTage; row.Cells[7].Value = sensitivityContentParam.CheckTime.ToString("yyyy-MM-dd HH:mm:ss"); - + + //dataGridView_CounterResult.Refresh(); index++; } - gPIBService.close(); - tcpService.close(); changeBox(); + + gPIBService.close(); + tcpService.close(); }).Start(); + + } private void changeBox() @@ -684,8 +655,7 @@ dataGridView_CounterResult.ReadOnly = false; btn_add.Enabled = true; benDelete.Enabled = true; - detected = true; - isDetecting = false; + //isDetecting = false; } private void dataGridView_CounterResult_CellEndEdit(object sender, DataGridViewCellEventArgs e) @@ -758,30 +728,17 @@ long initId = counterDetecInitService.addOrUpdate(freq, cycle); dataGridView_CounterResult.Rows[e.RowIndex].Cells[8].Value = initId; } + else if (e.ColumnIndex == 5) { if (!String.IsNullOrEmpty(value)) { string pattern = @"^[0-9.E]+$"; Regex regex = new Regex(pattern); - if (textBox_detecModel.Text.Equals("频率测量")) + if (!regex.IsMatch(value)) { - if (!checkFreq(value)) - { - dataGridView_CounterResult.CurrentCell.Value = ""; - MessageBox.Show("请输入格式正确的、带单位的测量频率!"); - return; - } - } - else - { - if (!checkCyc(value)) - { - dataGridView_CounterResult.CurrentCell.Value = ""; - MessageBox.Show("请输入格式正确的、带单位的测量周期!"); - return; - } - + MessageBox.Show("请输入格式正确的测量值!"); + return; } } } @@ -885,15 +842,18 @@ } } - private int isConnect(string id, string ip) + private void detecModelConf() { - int result = 0; - if (!gPIBService.isOpen()) - result = -1; - else if (!tcpService.isOpen()) - result = -2; - return result; + if (textBox_detecModel.Text == "频率测量") + { + GPIB_TCPIP_OPERATIO.setFreqModel(tcpService); + } + else if (textBox_detecModel.Text == "周期测量") + { + GPIB_TCPIP_OPERATIO.setPerModel(tcpService); + } + } } -} +} \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..2796a25 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -19,6 +19,7 @@ int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..6b8c687 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -321,6 +321,56 @@ } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = new DetectionItem(); + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 9bfde8e..d0f942c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -43,15 +43,14 @@ try { //tcpService.write("INIT"); - //tcpService.write("*WAI"); //freqRequest++; //Thread.Sleep(2000); //tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:FREQ?"); - //tcpService.write("READ?"); + Thread.Sleep(2000); + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); //Thread.Sleep(1000); return tcpService.read(); @@ -68,17 +67,16 @@ { try { - + //tcpService.write("INIT"); + //tcpService.write("*WAI"); //tcpService.write("INIT"); //tcpService.write("*WAI"); - - //tcpService.write("INIT"); - - //tcpService.write("*WAI"); - tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:PERIOD?"); + //tcpService.write("*CLS"); + Thread.Sleep(2000); + //tcpService.write("MEAS:PERIOD?"); + + tcpService.write("READ?"); return tcpService.read(); } @@ -100,5 +98,32 @@ LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setIMP:" + ex.Message); } } + + public static void setFreqModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:FREQ"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setFreqModel:" + ex.Message); + } + } + + public static void setPerModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:PER"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setPerModel:" + ex.Message); + } + } + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index 8ad1a8a..9916a9c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -89,7 +89,7 @@ hasException = true; } - if (!hasException) _portOperatorBaseTcp.Timeout = 2000; + if (!hasException) _portOperatorBaseTcp.Timeout = 1000; return hasAddress; } @@ -134,12 +134,13 @@ string content = ""; try { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType,"TCPRead:"+DateTime.Now); content = _portOperatorBaseTcp.ReadLine(); } catch (Exception ex) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterId : " + ex.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "TCPRead: " + ex.Message); content = ""; } return content; diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 936cc37..a3daf40 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -571,7 +571,7 @@ break; case 3: // 频率计数器范围 - CounterCtrlForm counterForm = new CounterCtrlForm(); + CounterCtrlForm counterForm = CounterCtrlForm.GetInstance(); counterForm.Show(); panelMain.Controls.Add(counterForm); break; diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 876c624..b0a8196 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index 4094808..0026ae3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.btn_dropDetecModel = new System.Windows.Forms.Button(); @@ -60,9 +63,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -87,13 +87,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -106,13 +106,13 @@ this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle4.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -121,7 +121,6 @@ this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); this.dataGridView_CounterResult.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellEndEdit); - this.dataGridView_CounterResult.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellValueChanged); // // panelMedian // @@ -147,6 +146,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -158,6 +205,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -438,78 +509,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index fd7ffee..357a90c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -22,6 +22,7 @@ DeviceService deviceService = new DeviceServiceImpl(); DictService dictService = new DictServiceImpl(); CounterDetecInitService counterDetecInitService = new CounterDetecInitServiceImpl(); + CounterDataService counterDataService = new CounterDataServiceImpl(); SensitivityService sensitivityService = new SensitivityServiceImpl(); @@ -32,8 +33,7 @@ string devPort = "输入A"; long deviceId = 0; bool isAdd = false; - bool detected = false; - public static bool isDetecting = false; + //public static bool isDetecting = false; GPIBService gPIBService = new GPIBServiceImpl(); GPIBService tcpService = new TCPServiceImpl(); @@ -44,8 +44,19 @@ private readonly Color titleBackColor = Color.FromArgb(63, 132, 215); // #3F64D7 private readonly Font titleFont = new Font("微软雅黑", 14F, FontStyle.Regular, GraphicsUnit.Pixel, 134); #endregion + - public CounterCtrlForm() + private static CounterCtrlForm _counterCtrlForm = null; + + public static CounterCtrlForm GetInstance() + { + if (_counterCtrlForm == null) + _counterCtrlForm = new CounterCtrlForm(); + + return _counterCtrlForm; + } + + private CounterCtrlForm() { InitializeComponent(); @@ -56,8 +67,7 @@ comboBox_counters.ValueMember = "Id"; InitTableCounter(); LoadCounterDetecInitList(); - - + if (list != null && list.Count > 0) { string[] ids = gPIBService.getId(); @@ -111,7 +121,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(48, 0), + Location = new Point(46, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); @@ -126,12 +136,27 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(142, 0), + Location = new Point(145, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); colDevNo.BringToFront(); + // 描述/端口 + Label colDevPort = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "描述", + Location = new Point(242, 0), + Size = new Size(50, 50) + }; + dataGridView_CounterResult.Controls.Add(colDevPort); + colDevPort.BringToFront(); + // 标称值 colStdValue = new Label { @@ -141,7 +166,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(247, 0), + Location = new Point(285, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -156,7 +181,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(360, 0), + Location = new Point(377, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colValue); @@ -171,7 +196,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(465, 0), + Location = new Point(480, 0), Size = new Size(95, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); @@ -190,23 +215,11 @@ }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); - - - + } private void LoadCounterDetecInitList() { - //dataGridView_CounterResult.Columns.Add("index", ""); - //dataGridView_CounterResult.Columns.Add("devType", ""); - //dataGridView_CounterResult.Columns.Add("devNo", ""); - //dataGridView_CounterResult.Columns.Add("devPort", ""); - //dataGridView_CounterResult.Columns.Add("stdValue", ""); - //dataGridView_CounterResult.Columns.Add("value", ""); - //dataGridView_CounterResult.Columns.Add("sensitivity", ""); - //dataGridView_CounterResult.Columns.Add("logTime", ""); - //dataGridView_CounterResult.Columns.Add("id", ""); - table_counterDetecInit = new DataTable(); table_counterDetecInit.Columns.Add("index", Type.GetType("System.String")); @@ -221,8 +234,8 @@ table_counterDetecInit.Columns.Add("counterDataId", Type.GetType("System.Int64")); if (text_devName.Text != "") - { - List list =deviceService.search(text_devName.Text,"","","","",""); + { + List list = deviceService.search(text_devName.Text, "", "", "", "", ""); if (null != list && list.Count > 0) { devType = list[0].DevTypeName; @@ -237,7 +250,7 @@ int index = 1; foreach (CounterData counterData in counterDataList) { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterData.OutValue, counterData.Value,counterData.Sensitivity, counterData.LogTime, -1, counterData.Id); + table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterData.OutValue, counterData.Value, counterData.Sensitivity, counterData.LogTime, -1, counterData.Id); index++; } } @@ -260,12 +273,11 @@ } index++; } - } + } } dataGridView_CounterResult.DataSource = table_counterDetecInit; - dataGridView_CounterResult.Columns[3].Visible = false; dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; @@ -273,10 +285,11 @@ dataGridView_CounterResult.Columns[0].Width = 50; dataGridView_CounterResult.Columns[1].Width = 95; dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[4].Width = 110; - dataGridView_CounterResult.Columns[5].Width = 110; - dataGridView_CounterResult.Columns[6].Width = 90; - dataGridView_CounterResult.Columns[7].Width = 140; + dataGridView_CounterResult.Columns[3].Width = 50; + dataGridView_CounterResult.Columns[4].Width = 85; + dataGridView_CounterResult.Columns[5].Width = 105; + dataGridView_CounterResult.Columns[6].Width = 85; + dataGridView_CounterResult.Columns[7].Width = 129; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -300,12 +313,7 @@ text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); - - detected = false; - if (gPIBService.getId() != null && gPIBService.getId().Length > 0) - { - text_signal.Text = gPIBService.getId()[0]; - } + if (tcpService.getId() != null && tcpService.getId().Length > 0) { text_counterIp.Text = tcpService.getId()[0].Split(':')[2]; @@ -350,7 +358,7 @@ } } - + private void benDelete_Click(object sender, EventArgs e) { @@ -466,14 +474,7 @@ { output = cyc * 1000 * 1000 * 1000 + "ns"; } - - //if (output.Contains(".")) - //{ - // if (output.Length >= output.IndexOf('.') + 3) output = output.Substring(0, output.IndexOf('.') + 3) + output.Substring(output.Length-2); - // else output = output.Substring(0, output.IndexOf('.') + 2) + output.Substring(output.Length - 2); - - - //} + } else if (input.Contains("s")) @@ -514,10 +515,6 @@ } - private void dataGridView_CounterResult_CellValueChanged(object sender, DataGridViewCellEventArgs e) - { - - } private void btnStart_Click(object sender, EventArgs e) { @@ -532,106 +529,76 @@ return; } + + dataGridView_CounterResult.ReadOnly = true; - isDetecting = true; btn_add.Enabled = false; benDelete.Enabled = false; btn_dropDetecModel.Enabled = false; - string[] ids = gPIBService.getId(); - //string[] ips = tcpService.getId(); - /*if (ids != null && ids.Length > 0) - { - text_signal.Text = ids[0]; - } - string[] ips = tcpService.getId(); - if (ips != null && ips.Length > 0) - { - text_counterIp.Text = ips[0].Split(':')[2]; - } - else - { - //MessageBox.Show("请连接信号源!"); - return; - } - if (text_counterIp.Text.Equals("")) - { - MessageBox.Show("请输入频率计数器IP!"); - return; - } - else - {*/ string[] arr = text_counterIp.Text.Split('.'); - if (arr.Length != 4) + if (arr.Length != 4) + { + MessageBox.Show("请输入正确的频率计数器IP!"); + return; + } + else + { + foreach (string ipEle in arr) { - MessageBox.Show("请输入正确的频率计数器IP!"); - return; - } - else - { - foreach (string ipEle in arr) + string pattern = @"^[0-9]+$"; + Regex regex = new Regex(pattern); + if (!regex.IsMatch(ipEle)) { - string pattern = @"^[0-9]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(ipEle)) + MessageBox.Show("请输入正确的频率计数器IP!"); + return; + } + else + { + if (Convert.ToInt32(ipEle) < 0 || Convert.ToInt32(ipEle) > 255) { MessageBox.Show("请输入正确的频率计数器IP!"); return; } - else - { - if (Convert.ToInt32(ipEle) < 0 || Convert.ToInt32(ipEle) > 255) - { - MessageBox.Show("请输入正确的频率计数器IP!"); - return; - } - } } } - //} - //if (ips != null && ips.Length > 0) - //{ - // text_counterIp.Text = ips[0]; - //} - //else - //{ - // MessageBox.Show("请连接频率计数器!"); - // return; - //} - + } + text_devName.ReadOnly = true; btn_downCounterList.Enabled = false; btnStart.Enabled = false; btn_dropDetecModel.Enabled = false; textBox_detecModel.ReadOnly = true; - SetDevTestDlg.inDetecCounterId = deviceId; + //SetDevTestDlg.inDetecCounterId = deviceId; + string type = textBox_detecModel.Text.Equals("频率测量") ? "freq" : "period"; string typeId = type.Equals("freq") ? "1" : "2"; new Thread(() => { - // 获取数据 - List counterDetecInitList = counterDetecInitService.getAll(); - - CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); - - int gpibConnection=gPIBService.open(text_signal.Text); - int tcpConnection=tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); - + int gpibConnection = gPIBService.open(text_signal.Text); if (gpibConnection == -1) { MessageBox.Show("未连接信号源"); changeBox(); return; } - else if (tcpConnection == -1) + + int tcpConnection = tcpService.open("TCPIP0::" + text_counterIp.Text + "::INSTR"); + if (tcpConnection == -1) { MessageBox.Show("未连接计数器"); changeBox(); return; } - //tcpService.open(text_counterIp.Text); + detecModelConf(); + + // 获取数据 + List counterDetecInitList = counterDetecInitService.getAll(); + + CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); + int index = 0; foreach (DataGridViewRow row in dataGridView_CounterResult.Rows) { @@ -651,7 +618,7 @@ int re = sensitivityService.beginTest(type, gPIBService, tcpService, counterCheckParam, ref sensitivityContentParam);//0:成功;-1:失败 string value = ""; if (re == 0) - { + { value = type.Equals("freq") ? sensitivityContentParam.ReFreq : sensitivityContentParam.RePeriod; } long dataId = counterDataService.add(deviceId, row.Cells[4].Value.ToString(), value, sensitivityContentParam.VolTage, sensitivityContentParam.CheckTime.ToString("yyyy-MM-dd HH:mm:ss"), typeId); @@ -659,14 +626,18 @@ row.Cells[5].Value = value; row.Cells[6].Value = sensitivityContentParam.VolTage; row.Cells[7].Value = sensitivityContentParam.CheckTime.ToString("yyyy-MM-dd HH:mm:ss"); - + + //dataGridView_CounterResult.Refresh(); index++; } - gPIBService.close(); - tcpService.close(); changeBox(); + + gPIBService.close(); + tcpService.close(); }).Start(); + + } private void changeBox() @@ -684,8 +655,7 @@ dataGridView_CounterResult.ReadOnly = false; btn_add.Enabled = true; benDelete.Enabled = true; - detected = true; - isDetecting = false; + //isDetecting = false; } private void dataGridView_CounterResult_CellEndEdit(object sender, DataGridViewCellEventArgs e) @@ -758,30 +728,17 @@ long initId = counterDetecInitService.addOrUpdate(freq, cycle); dataGridView_CounterResult.Rows[e.RowIndex].Cells[8].Value = initId; } + else if (e.ColumnIndex == 5) { if (!String.IsNullOrEmpty(value)) { string pattern = @"^[0-9.E]+$"; Regex regex = new Regex(pattern); - if (textBox_detecModel.Text.Equals("频率测量")) + if (!regex.IsMatch(value)) { - if (!checkFreq(value)) - { - dataGridView_CounterResult.CurrentCell.Value = ""; - MessageBox.Show("请输入格式正确的、带单位的测量频率!"); - return; - } - } - else - { - if (!checkCyc(value)) - { - dataGridView_CounterResult.CurrentCell.Value = ""; - MessageBox.Show("请输入格式正确的、带单位的测量周期!"); - return; - } - + MessageBox.Show("请输入格式正确的测量值!"); + return; } } } @@ -885,15 +842,18 @@ } } - private int isConnect(string id, string ip) + private void detecModelConf() { - int result = 0; - if (!gPIBService.isOpen()) - result = -1; - else if (!tcpService.isOpen()) - result = -2; - return result; + if (textBox_detecModel.Text == "频率测量") + { + GPIB_TCPIP_OPERATIO.setFreqModel(tcpService); + } + else if (textBox_detecModel.Text == "周期测量") + { + GPIB_TCPIP_OPERATIO.setPerModel(tcpService); + } + } } -} +} \ No newline at end of file diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index c827cf3..a33d35a 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -305,212 +305,229 @@ private void InitTableChannel() { - dataGridView_Channel.Columns.Clear(); - dataGridView_Channel.Rows.Clear(); - - // 添加标题栏 - Panel tableHeader = new Panel + try { - BackColor = Color.White, - Size = new Size(984, 30), - Location = new Point(0, 0) - }; - tableHeader.BackColor = titleBackColor; - dataGridView_Channel.Controls.Add(tableHeader); + lock (obj) + { + dataGridView_Channel.Columns.Clear(); + dataGridView_Channel.Rows.Clear(); - // 通道 - Label colChannelNo = new Label + // 添加标题栏 + Panel tableHeader = new Panel + { + BackColor = Color.White, + Size = new Size(984, 30), + Location = new Point(0, 0) + }; + tableHeader.BackColor = titleBackColor; + dataGridView_Channel.Controls.Add(tableHeader); + + // 通道 + Label colChannelNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "通道", + Location = new Point(0, 0), + Size = new Size(50, 30) + }; + dataGridView_Channel.Controls.Add(colChannelNo); + colChannelNo.BringToFront(); + + // 仪器名称 + Label colDevName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器名称", + Location = new Point(50, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevName); + colDevName.BringToFront(); + + // 仪器编号 + Label colDevNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器编号", + Location = new Point(160, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevNo); + colDevNo.BringToFront(); + + // 客户名称 + Label colCustomName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "送检单位", + Location = new Point(270, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colCustomName); + colCustomName.BringToFront(); + + // 开始时间 + Label colStartTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开始时间", + Location = new Point(380, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colStartTime); + colStartTime.BringToFront(); + + // 结束时间 + Label colEndTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "结束时间", + Location = new Point(500, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colEndTime); + colEndTime.BringToFront(); + + // 状态 + Label colStatus = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "状态", + Location = new Point(620, 0), + Size = new Size(64, 30) + }; + dataGridView_Channel.Controls.Add(colStatus); + colStatus.BringToFront(); + + // 频率稳定度 + Label colStablility = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "稳定度", + + Location = new Point(684, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStablility); + colStablility.BringToFront(); + + // 频率准确度 + Label colAccuracy = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "准确度", + Location = new Point(754, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colAccuracy); + colAccuracy.BringToFront(); + + // 开机特性 + Label colStartup = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开机特性", + + Location = new Point(824, 0), + + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStartup); + colStartup.BringToFront(); + + // 日老化率 + Label colAgingRate = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "日老化率", + Location = new Point(899, 0), + Size = new Size(75, 30) + }; + + + dataGridView_Channel.Controls.Add(colAgingRate); + colAgingRate.BringToFront(); + } + } + catch (Exception ex) { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "通道", - Location = new Point(0, 0), - Size = new Size(50, 30) - }; - dataGridView_Channel.Controls.Add(colChannelNo); - colChannelNo.BringToFront(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "InitTableChannel 错误:" + ex.Message); - // 仪器名称 - Label colDevName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器名称", - Location = new Point(50, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevName); - colDevName.BringToFront(); - - // 仪器编号 - Label colDevNo = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器编号", - Location = new Point(160, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 客户名称 - Label colCustomName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "送检单位", - Location = new Point(270, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colCustomName); - colCustomName.BringToFront(); - - // 开始时间 - Label colStartTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开始时间", - Location = new Point(380, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colStartTime); - colStartTime.BringToFront(); - - // 结束时间 - Label colEndTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "结束时间", - Location = new Point(500, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colEndTime); - colEndTime.BringToFront(); - - // 状态 - Label colStatus = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "状态", - Location = new Point(620, 0), - Size = new Size(64, 30) - }; - dataGridView_Channel.Controls.Add(colStatus); - colStatus.BringToFront(); - - // 频率稳定度 - Label colStablility = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "稳定度", - - Location = new Point(684,0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStablility); - colStablility.BringToFront(); - - // 频率准确度 - Label colAccuracy = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "准确度", - Location = new Point(754, 0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colAccuracy); - colAccuracy.BringToFront(); - - // 开机特性 - Label colStartup = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开机特性", - - Location = new Point(824, 0), - - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStartup); - colStartup.BringToFront(); - - - - // 日老化率 - Label colAgingRate = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "日老化率", - Location = new Point(899, 0), - Size = new Size(75, 30) - }; - - - dataGridView_Channel.Controls.Add(colAgingRate); - colAgingRate.BringToFront(); + } } public void refreshChannelList() { - lock (obj) + try { - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - listChannelStatus = deviceService.getDeviceByChannel(); - if (listChannelStatus != null && listChannelStatus.Count > 0) + lock (obj) { - foreach (DeviceView device in listChannelStatus) + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + } } } } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "refreshChannelList 错误:" + ex.Message); + + } } public void LoadChannelStatus() { @@ -651,24 +668,39 @@ { lock (obj) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); + dataGridView_Channel.ClearSelection(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); int channelNo = e.RowIndex + 1; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); if (channelFreeList.Contains(channelNo + "")) { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); } else { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); } foreach (string no in channelFreeList.ToArray()) { dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; } + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) @@ -735,26 +767,37 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; - long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; - string startTime = ""; - string endTime = ""; - if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) - { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } - if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) - { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + try + { + long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; + string startTime = ""; + string endTime = ""; + if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) + { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } + if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) + { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + if (startTime.Equals("") && endTime.Equals("")) + { + return; + } + DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (dialogResult == DialogResult.Yes) + { - DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (dialogResult == DialogResult.Yes) - { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + } + else + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + } + LoadChannelStatus(); + LoadDevToBeTested(); } - else + catch(Exception ex) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "cellDoubleClick 错误:" + ex.Message); } - LoadChannelStatus(); - LoadDevToBeTested(); return; } else diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..2796a25 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -19,6 +19,7 @@ int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..6b8c687 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -321,6 +321,56 @@ } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = new DetectionItem(); + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 9bfde8e..d0f942c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -43,15 +43,14 @@ try { //tcpService.write("INIT"); - //tcpService.write("*WAI"); //freqRequest++; //Thread.Sleep(2000); //tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:FREQ?"); - //tcpService.write("READ?"); + Thread.Sleep(2000); + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); //Thread.Sleep(1000); return tcpService.read(); @@ -68,17 +67,16 @@ { try { - + //tcpService.write("INIT"); + //tcpService.write("*WAI"); //tcpService.write("INIT"); //tcpService.write("*WAI"); - - //tcpService.write("INIT"); - - //tcpService.write("*WAI"); - tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:PERIOD?"); + //tcpService.write("*CLS"); + Thread.Sleep(2000); + //tcpService.write("MEAS:PERIOD?"); + + tcpService.write("READ?"); return tcpService.read(); } @@ -100,5 +98,32 @@ LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setIMP:" + ex.Message); } } + + public static void setFreqModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:FREQ"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setFreqModel:" + ex.Message); + } + } + + public static void setPerModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:PER"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setPerModel:" + ex.Message); + } + } + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index 8ad1a8a..9916a9c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -89,7 +89,7 @@ hasException = true; } - if (!hasException) _portOperatorBaseTcp.Timeout = 2000; + if (!hasException) _portOperatorBaseTcp.Timeout = 1000; return hasAddress; } @@ -134,12 +134,13 @@ string content = ""; try { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType,"TCPRead:"+DateTime.Now); content = _portOperatorBaseTcp.ReadLine(); } catch (Exception ex) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterId : " + ex.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "TCPRead: " + ex.Message); content = ""; } return content; diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 936cc37..a3daf40 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -571,7 +571,7 @@ break; case 3: // 频率计数器范围 - CounterCtrlForm counterForm = new CounterCtrlForm(); + CounterCtrlForm counterForm = CounterCtrlForm.GetInstance(); counterForm.Show(); panelMain.Controls.Add(counterForm); break; diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 876c624..b0a8196 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index 4094808..0026ae3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.btn_dropDetecModel = new System.Windows.Forms.Button(); @@ -60,9 +63,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -87,13 +87,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -106,13 +106,13 @@ this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle4.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -121,7 +121,6 @@ this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); this.dataGridView_CounterResult.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellEndEdit); - this.dataGridView_CounterResult.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellValueChanged); // // panelMedian // @@ -147,6 +146,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -158,6 +205,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -438,78 +509,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index fd7ffee..357a90c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -22,6 +22,7 @@ DeviceService deviceService = new DeviceServiceImpl(); DictService dictService = new DictServiceImpl(); CounterDetecInitService counterDetecInitService = new CounterDetecInitServiceImpl(); + CounterDataService counterDataService = new CounterDataServiceImpl(); SensitivityService sensitivityService = new SensitivityServiceImpl(); @@ -32,8 +33,7 @@ string devPort = "输入A"; long deviceId = 0; bool isAdd = false; - bool detected = false; - public static bool isDetecting = false; + //public static bool isDetecting = false; GPIBService gPIBService = new GPIBServiceImpl(); GPIBService tcpService = new TCPServiceImpl(); @@ -44,8 +44,19 @@ private readonly Color titleBackColor = Color.FromArgb(63, 132, 215); // #3F64D7 private readonly Font titleFont = new Font("微软雅黑", 14F, FontStyle.Regular, GraphicsUnit.Pixel, 134); #endregion + - public CounterCtrlForm() + private static CounterCtrlForm _counterCtrlForm = null; + + public static CounterCtrlForm GetInstance() + { + if (_counterCtrlForm == null) + _counterCtrlForm = new CounterCtrlForm(); + + return _counterCtrlForm; + } + + private CounterCtrlForm() { InitializeComponent(); @@ -56,8 +67,7 @@ comboBox_counters.ValueMember = "Id"; InitTableCounter(); LoadCounterDetecInitList(); - - + if (list != null && list.Count > 0) { string[] ids = gPIBService.getId(); @@ -111,7 +121,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(48, 0), + Location = new Point(46, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); @@ -126,12 +136,27 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(142, 0), + Location = new Point(145, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); colDevNo.BringToFront(); + // 描述/端口 + Label colDevPort = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "描述", + Location = new Point(242, 0), + Size = new Size(50, 50) + }; + dataGridView_CounterResult.Controls.Add(colDevPort); + colDevPort.BringToFront(); + // 标称值 colStdValue = new Label { @@ -141,7 +166,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(247, 0), + Location = new Point(285, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -156,7 +181,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(360, 0), + Location = new Point(377, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colValue); @@ -171,7 +196,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(465, 0), + Location = new Point(480, 0), Size = new Size(95, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); @@ -190,23 +215,11 @@ }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); - - - + } private void LoadCounterDetecInitList() { - //dataGridView_CounterResult.Columns.Add("index", ""); - //dataGridView_CounterResult.Columns.Add("devType", ""); - //dataGridView_CounterResult.Columns.Add("devNo", ""); - //dataGridView_CounterResult.Columns.Add("devPort", ""); - //dataGridView_CounterResult.Columns.Add("stdValue", ""); - //dataGridView_CounterResult.Columns.Add("value", ""); - //dataGridView_CounterResult.Columns.Add("sensitivity", ""); - //dataGridView_CounterResult.Columns.Add("logTime", ""); - //dataGridView_CounterResult.Columns.Add("id", ""); - table_counterDetecInit = new DataTable(); table_counterDetecInit.Columns.Add("index", Type.GetType("System.String")); @@ -221,8 +234,8 @@ table_counterDetecInit.Columns.Add("counterDataId", Type.GetType("System.Int64")); if (text_devName.Text != "") - { - List list =deviceService.search(text_devName.Text,"","","","",""); + { + List list = deviceService.search(text_devName.Text, "", "", "", "", ""); if (null != list && list.Count > 0) { devType = list[0].DevTypeName; @@ -237,7 +250,7 @@ int index = 1; foreach (CounterData counterData in counterDataList) { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterData.OutValue, counterData.Value,counterData.Sensitivity, counterData.LogTime, -1, counterData.Id); + table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterData.OutValue, counterData.Value, counterData.Sensitivity, counterData.LogTime, -1, counterData.Id); index++; } } @@ -260,12 +273,11 @@ } index++; } - } + } } dataGridView_CounterResult.DataSource = table_counterDetecInit; - dataGridView_CounterResult.Columns[3].Visible = false; dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; @@ -273,10 +285,11 @@ dataGridView_CounterResult.Columns[0].Width = 50; dataGridView_CounterResult.Columns[1].Width = 95; dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[4].Width = 110; - dataGridView_CounterResult.Columns[5].Width = 110; - dataGridView_CounterResult.Columns[6].Width = 90; - dataGridView_CounterResult.Columns[7].Width = 140; + dataGridView_CounterResult.Columns[3].Width = 50; + dataGridView_CounterResult.Columns[4].Width = 85; + dataGridView_CounterResult.Columns[5].Width = 105; + dataGridView_CounterResult.Columns[6].Width = 85; + dataGridView_CounterResult.Columns[7].Width = 129; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -300,12 +313,7 @@ text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); - - detected = false; - if (gPIBService.getId() != null && gPIBService.getId().Length > 0) - { - text_signal.Text = gPIBService.getId()[0]; - } + if (tcpService.getId() != null && tcpService.getId().Length > 0) { text_counterIp.Text = tcpService.getId()[0].Split(':')[2]; @@ -350,7 +358,7 @@ } } - + private void benDelete_Click(object sender, EventArgs e) { @@ -466,14 +474,7 @@ { output = cyc * 1000 * 1000 * 1000 + "ns"; } - - //if (output.Contains(".")) - //{ - // if (output.Length >= output.IndexOf('.') + 3) output = output.Substring(0, output.IndexOf('.') + 3) + output.Substring(output.Length-2); - // else output = output.Substring(0, output.IndexOf('.') + 2) + output.Substring(output.Length - 2); - - - //} + } else if (input.Contains("s")) @@ -514,10 +515,6 @@ } - private void dataGridView_CounterResult_CellValueChanged(object sender, DataGridViewCellEventArgs e) - { - - } private void btnStart_Click(object sender, EventArgs e) { @@ -532,106 +529,76 @@ return; } + + dataGridView_CounterResult.ReadOnly = true; - isDetecting = true; btn_add.Enabled = false; benDelete.Enabled = false; btn_dropDetecModel.Enabled = false; - string[] ids = gPIBService.getId(); - //string[] ips = tcpService.getId(); - /*if (ids != null && ids.Length > 0) - { - text_signal.Text = ids[0]; - } - string[] ips = tcpService.getId(); - if (ips != null && ips.Length > 0) - { - text_counterIp.Text = ips[0].Split(':')[2]; - } - else - { - //MessageBox.Show("请连接信号源!"); - return; - } - if (text_counterIp.Text.Equals("")) - { - MessageBox.Show("请输入频率计数器IP!"); - return; - } - else - {*/ string[] arr = text_counterIp.Text.Split('.'); - if (arr.Length != 4) + if (arr.Length != 4) + { + MessageBox.Show("请输入正确的频率计数器IP!"); + return; + } + else + { + foreach (string ipEle in arr) { - MessageBox.Show("请输入正确的频率计数器IP!"); - return; - } - else - { - foreach (string ipEle in arr) + string pattern = @"^[0-9]+$"; + Regex regex = new Regex(pattern); + if (!regex.IsMatch(ipEle)) { - string pattern = @"^[0-9]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(ipEle)) + MessageBox.Show("请输入正确的频率计数器IP!"); + return; + } + else + { + if (Convert.ToInt32(ipEle) < 0 || Convert.ToInt32(ipEle) > 255) { MessageBox.Show("请输入正确的频率计数器IP!"); return; } - else - { - if (Convert.ToInt32(ipEle) < 0 || Convert.ToInt32(ipEle) > 255) - { - MessageBox.Show("请输入正确的频率计数器IP!"); - return; - } - } } } - //} - //if (ips != null && ips.Length > 0) - //{ - // text_counterIp.Text = ips[0]; - //} - //else - //{ - // MessageBox.Show("请连接频率计数器!"); - // return; - //} - + } + text_devName.ReadOnly = true; btn_downCounterList.Enabled = false; btnStart.Enabled = false; btn_dropDetecModel.Enabled = false; textBox_detecModel.ReadOnly = true; - SetDevTestDlg.inDetecCounterId = deviceId; + //SetDevTestDlg.inDetecCounterId = deviceId; + string type = textBox_detecModel.Text.Equals("频率测量") ? "freq" : "period"; string typeId = type.Equals("freq") ? "1" : "2"; new Thread(() => { - // 获取数据 - List counterDetecInitList = counterDetecInitService.getAll(); - - CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); - - int gpibConnection=gPIBService.open(text_signal.Text); - int tcpConnection=tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); - + int gpibConnection = gPIBService.open(text_signal.Text); if (gpibConnection == -1) { MessageBox.Show("未连接信号源"); changeBox(); return; } - else if (tcpConnection == -1) + + int tcpConnection = tcpService.open("TCPIP0::" + text_counterIp.Text + "::INSTR"); + if (tcpConnection == -1) { MessageBox.Show("未连接计数器"); changeBox(); return; } - //tcpService.open(text_counterIp.Text); + detecModelConf(); + + // 获取数据 + List counterDetecInitList = counterDetecInitService.getAll(); + + CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); + int index = 0; foreach (DataGridViewRow row in dataGridView_CounterResult.Rows) { @@ -651,7 +618,7 @@ int re = sensitivityService.beginTest(type, gPIBService, tcpService, counterCheckParam, ref sensitivityContentParam);//0:成功;-1:失败 string value = ""; if (re == 0) - { + { value = type.Equals("freq") ? sensitivityContentParam.ReFreq : sensitivityContentParam.RePeriod; } long dataId = counterDataService.add(deviceId, row.Cells[4].Value.ToString(), value, sensitivityContentParam.VolTage, sensitivityContentParam.CheckTime.ToString("yyyy-MM-dd HH:mm:ss"), typeId); @@ -659,14 +626,18 @@ row.Cells[5].Value = value; row.Cells[6].Value = sensitivityContentParam.VolTage; row.Cells[7].Value = sensitivityContentParam.CheckTime.ToString("yyyy-MM-dd HH:mm:ss"); - + + //dataGridView_CounterResult.Refresh(); index++; } - gPIBService.close(); - tcpService.close(); changeBox(); + + gPIBService.close(); + tcpService.close(); }).Start(); + + } private void changeBox() @@ -684,8 +655,7 @@ dataGridView_CounterResult.ReadOnly = false; btn_add.Enabled = true; benDelete.Enabled = true; - detected = true; - isDetecting = false; + //isDetecting = false; } private void dataGridView_CounterResult_CellEndEdit(object sender, DataGridViewCellEventArgs e) @@ -758,30 +728,17 @@ long initId = counterDetecInitService.addOrUpdate(freq, cycle); dataGridView_CounterResult.Rows[e.RowIndex].Cells[8].Value = initId; } + else if (e.ColumnIndex == 5) { if (!String.IsNullOrEmpty(value)) { string pattern = @"^[0-9.E]+$"; Regex regex = new Regex(pattern); - if (textBox_detecModel.Text.Equals("频率测量")) + if (!regex.IsMatch(value)) { - if (!checkFreq(value)) - { - dataGridView_CounterResult.CurrentCell.Value = ""; - MessageBox.Show("请输入格式正确的、带单位的测量频率!"); - return; - } - } - else - { - if (!checkCyc(value)) - { - dataGridView_CounterResult.CurrentCell.Value = ""; - MessageBox.Show("请输入格式正确的、带单位的测量周期!"); - return; - } - + MessageBox.Show("请输入格式正确的测量值!"); + return; } } } @@ -885,15 +842,18 @@ } } - private int isConnect(string id, string ip) + private void detecModelConf() { - int result = 0; - if (!gPIBService.isOpen()) - result = -1; - else if (!tcpService.isOpen()) - result = -2; - return result; + if (textBox_detecModel.Text == "频率测量") + { + GPIB_TCPIP_OPERATIO.setFreqModel(tcpService); + } + else if (textBox_detecModel.Text == "周期测量") + { + GPIB_TCPIP_OPERATIO.setPerModel(tcpService); + } + } } -} +} \ No newline at end of file diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index c827cf3..a33d35a 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -305,212 +305,229 @@ private void InitTableChannel() { - dataGridView_Channel.Columns.Clear(); - dataGridView_Channel.Rows.Clear(); - - // 添加标题栏 - Panel tableHeader = new Panel + try { - BackColor = Color.White, - Size = new Size(984, 30), - Location = new Point(0, 0) - }; - tableHeader.BackColor = titleBackColor; - dataGridView_Channel.Controls.Add(tableHeader); + lock (obj) + { + dataGridView_Channel.Columns.Clear(); + dataGridView_Channel.Rows.Clear(); - // 通道 - Label colChannelNo = new Label + // 添加标题栏 + Panel tableHeader = new Panel + { + BackColor = Color.White, + Size = new Size(984, 30), + Location = new Point(0, 0) + }; + tableHeader.BackColor = titleBackColor; + dataGridView_Channel.Controls.Add(tableHeader); + + // 通道 + Label colChannelNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "通道", + Location = new Point(0, 0), + Size = new Size(50, 30) + }; + dataGridView_Channel.Controls.Add(colChannelNo); + colChannelNo.BringToFront(); + + // 仪器名称 + Label colDevName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器名称", + Location = new Point(50, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevName); + colDevName.BringToFront(); + + // 仪器编号 + Label colDevNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器编号", + Location = new Point(160, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevNo); + colDevNo.BringToFront(); + + // 客户名称 + Label colCustomName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "送检单位", + Location = new Point(270, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colCustomName); + colCustomName.BringToFront(); + + // 开始时间 + Label colStartTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开始时间", + Location = new Point(380, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colStartTime); + colStartTime.BringToFront(); + + // 结束时间 + Label colEndTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "结束时间", + Location = new Point(500, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colEndTime); + colEndTime.BringToFront(); + + // 状态 + Label colStatus = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "状态", + Location = new Point(620, 0), + Size = new Size(64, 30) + }; + dataGridView_Channel.Controls.Add(colStatus); + colStatus.BringToFront(); + + // 频率稳定度 + Label colStablility = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "稳定度", + + Location = new Point(684, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStablility); + colStablility.BringToFront(); + + // 频率准确度 + Label colAccuracy = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "准确度", + Location = new Point(754, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colAccuracy); + colAccuracy.BringToFront(); + + // 开机特性 + Label colStartup = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开机特性", + + Location = new Point(824, 0), + + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStartup); + colStartup.BringToFront(); + + // 日老化率 + Label colAgingRate = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "日老化率", + Location = new Point(899, 0), + Size = new Size(75, 30) + }; + + + dataGridView_Channel.Controls.Add(colAgingRate); + colAgingRate.BringToFront(); + } + } + catch (Exception ex) { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "通道", - Location = new Point(0, 0), - Size = new Size(50, 30) - }; - dataGridView_Channel.Controls.Add(colChannelNo); - colChannelNo.BringToFront(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "InitTableChannel 错误:" + ex.Message); - // 仪器名称 - Label colDevName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器名称", - Location = new Point(50, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevName); - colDevName.BringToFront(); - - // 仪器编号 - Label colDevNo = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器编号", - Location = new Point(160, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 客户名称 - Label colCustomName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "送检单位", - Location = new Point(270, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colCustomName); - colCustomName.BringToFront(); - - // 开始时间 - Label colStartTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开始时间", - Location = new Point(380, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colStartTime); - colStartTime.BringToFront(); - - // 结束时间 - Label colEndTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "结束时间", - Location = new Point(500, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colEndTime); - colEndTime.BringToFront(); - - // 状态 - Label colStatus = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "状态", - Location = new Point(620, 0), - Size = new Size(64, 30) - }; - dataGridView_Channel.Controls.Add(colStatus); - colStatus.BringToFront(); - - // 频率稳定度 - Label colStablility = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "稳定度", - - Location = new Point(684,0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStablility); - colStablility.BringToFront(); - - // 频率准确度 - Label colAccuracy = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "准确度", - Location = new Point(754, 0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colAccuracy); - colAccuracy.BringToFront(); - - // 开机特性 - Label colStartup = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开机特性", - - Location = new Point(824, 0), - - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStartup); - colStartup.BringToFront(); - - - - // 日老化率 - Label colAgingRate = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "日老化率", - Location = new Point(899, 0), - Size = new Size(75, 30) - }; - - - dataGridView_Channel.Controls.Add(colAgingRate); - colAgingRate.BringToFront(); + } } public void refreshChannelList() { - lock (obj) + try { - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - listChannelStatus = deviceService.getDeviceByChannel(); - if (listChannelStatus != null && listChannelStatus.Count > 0) + lock (obj) { - foreach (DeviceView device in listChannelStatus) + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + } } } } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "refreshChannelList 错误:" + ex.Message); + + } } public void LoadChannelStatus() { @@ -651,24 +668,39 @@ { lock (obj) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); + dataGridView_Channel.ClearSelection(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); int channelNo = e.RowIndex + 1; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); if (channelFreeList.Contains(channelNo + "")) { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); } else { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); } foreach (string no in channelFreeList.ToArray()) { dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; } + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) @@ -735,26 +767,37 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; - long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; - string startTime = ""; - string endTime = ""; - if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) - { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } - if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) - { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + try + { + long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; + string startTime = ""; + string endTime = ""; + if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) + { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } + if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) + { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + if (startTime.Equals("") && endTime.Equals("")) + { + return; + } + DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (dialogResult == DialogResult.Yes) + { - DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (dialogResult == DialogResult.Yes) - { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + } + else + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + } + LoadChannelStatus(); + LoadDevToBeTested(); } - else + catch(Exception ex) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "cellDoubleClick 错误:" + ex.Message); } - LoadChannelStatus(); - LoadDevToBeTested(); return; } else diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index f99f106..8baed4b 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -47,6 +47,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); int channel = 0; + public Action HideMaskAction { @@ -66,9 +67,7 @@ SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 跨线程访问控件 - CheckForIllegalCrossThreadCalls = false; - - + CheckForIllegalCrossThreadCalls = false; } private void btnExitChannel_Click(object sender, EventArgs e) @@ -158,6 +157,10 @@ MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1] = port; + } } catch (Exception exc) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..2796a25 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -19,6 +19,7 @@ int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..6b8c687 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -321,6 +321,56 @@ } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = new DetectionItem(); + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 9bfde8e..d0f942c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -43,15 +43,14 @@ try { //tcpService.write("INIT"); - //tcpService.write("*WAI"); //freqRequest++; //Thread.Sleep(2000); //tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:FREQ?"); - //tcpService.write("READ?"); + Thread.Sleep(2000); + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); //Thread.Sleep(1000); return tcpService.read(); @@ -68,17 +67,16 @@ { try { - + //tcpService.write("INIT"); + //tcpService.write("*WAI"); //tcpService.write("INIT"); //tcpService.write("*WAI"); - - //tcpService.write("INIT"); - - //tcpService.write("*WAI"); - tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:PERIOD?"); + //tcpService.write("*CLS"); + Thread.Sleep(2000); + //tcpService.write("MEAS:PERIOD?"); + + tcpService.write("READ?"); return tcpService.read(); } @@ -100,5 +98,32 @@ LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setIMP:" + ex.Message); } } + + public static void setFreqModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:FREQ"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setFreqModel:" + ex.Message); + } + } + + public static void setPerModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:PER"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setPerModel:" + ex.Message); + } + } + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index 8ad1a8a..9916a9c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -89,7 +89,7 @@ hasException = true; } - if (!hasException) _portOperatorBaseTcp.Timeout = 2000; + if (!hasException) _portOperatorBaseTcp.Timeout = 1000; return hasAddress; } @@ -134,12 +134,13 @@ string content = ""; try { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType,"TCPRead:"+DateTime.Now); content = _portOperatorBaseTcp.ReadLine(); } catch (Exception ex) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterId : " + ex.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "TCPRead: " + ex.Message); content = ""; } return content; diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 936cc37..a3daf40 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -571,7 +571,7 @@ break; case 3: // 频率计数器范围 - CounterCtrlForm counterForm = new CounterCtrlForm(); + CounterCtrlForm counterForm = CounterCtrlForm.GetInstance(); counterForm.Show(); panelMain.Controls.Add(counterForm); break; diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 876c624..b0a8196 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index 4094808..0026ae3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.btn_dropDetecModel = new System.Windows.Forms.Button(); @@ -60,9 +63,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -87,13 +87,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -106,13 +106,13 @@ this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle4.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -121,7 +121,6 @@ this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); this.dataGridView_CounterResult.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellEndEdit); - this.dataGridView_CounterResult.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellValueChanged); // // panelMedian // @@ -147,6 +146,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -158,6 +205,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -438,78 +509,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index fd7ffee..357a90c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -22,6 +22,7 @@ DeviceService deviceService = new DeviceServiceImpl(); DictService dictService = new DictServiceImpl(); CounterDetecInitService counterDetecInitService = new CounterDetecInitServiceImpl(); + CounterDataService counterDataService = new CounterDataServiceImpl(); SensitivityService sensitivityService = new SensitivityServiceImpl(); @@ -32,8 +33,7 @@ string devPort = "输入A"; long deviceId = 0; bool isAdd = false; - bool detected = false; - public static bool isDetecting = false; + //public static bool isDetecting = false; GPIBService gPIBService = new GPIBServiceImpl(); GPIBService tcpService = new TCPServiceImpl(); @@ -44,8 +44,19 @@ private readonly Color titleBackColor = Color.FromArgb(63, 132, 215); // #3F64D7 private readonly Font titleFont = new Font("微软雅黑", 14F, FontStyle.Regular, GraphicsUnit.Pixel, 134); #endregion + - public CounterCtrlForm() + private static CounterCtrlForm _counterCtrlForm = null; + + public static CounterCtrlForm GetInstance() + { + if (_counterCtrlForm == null) + _counterCtrlForm = new CounterCtrlForm(); + + return _counterCtrlForm; + } + + private CounterCtrlForm() { InitializeComponent(); @@ -56,8 +67,7 @@ comboBox_counters.ValueMember = "Id"; InitTableCounter(); LoadCounterDetecInitList(); - - + if (list != null && list.Count > 0) { string[] ids = gPIBService.getId(); @@ -111,7 +121,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(48, 0), + Location = new Point(46, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); @@ -126,12 +136,27 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(142, 0), + Location = new Point(145, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); colDevNo.BringToFront(); + // 描述/端口 + Label colDevPort = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "描述", + Location = new Point(242, 0), + Size = new Size(50, 50) + }; + dataGridView_CounterResult.Controls.Add(colDevPort); + colDevPort.BringToFront(); + // 标称值 colStdValue = new Label { @@ -141,7 +166,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(247, 0), + Location = new Point(285, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -156,7 +181,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(360, 0), + Location = new Point(377, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colValue); @@ -171,7 +196,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(465, 0), + Location = new Point(480, 0), Size = new Size(95, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); @@ -190,23 +215,11 @@ }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); - - - + } private void LoadCounterDetecInitList() { - //dataGridView_CounterResult.Columns.Add("index", ""); - //dataGridView_CounterResult.Columns.Add("devType", ""); - //dataGridView_CounterResult.Columns.Add("devNo", ""); - //dataGridView_CounterResult.Columns.Add("devPort", ""); - //dataGridView_CounterResult.Columns.Add("stdValue", ""); - //dataGridView_CounterResult.Columns.Add("value", ""); - //dataGridView_CounterResult.Columns.Add("sensitivity", ""); - //dataGridView_CounterResult.Columns.Add("logTime", ""); - //dataGridView_CounterResult.Columns.Add("id", ""); - table_counterDetecInit = new DataTable(); table_counterDetecInit.Columns.Add("index", Type.GetType("System.String")); @@ -221,8 +234,8 @@ table_counterDetecInit.Columns.Add("counterDataId", Type.GetType("System.Int64")); if (text_devName.Text != "") - { - List list =deviceService.search(text_devName.Text,"","","","",""); + { + List list = deviceService.search(text_devName.Text, "", "", "", "", ""); if (null != list && list.Count > 0) { devType = list[0].DevTypeName; @@ -237,7 +250,7 @@ int index = 1; foreach (CounterData counterData in counterDataList) { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterData.OutValue, counterData.Value,counterData.Sensitivity, counterData.LogTime, -1, counterData.Id); + table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterData.OutValue, counterData.Value, counterData.Sensitivity, counterData.LogTime, -1, counterData.Id); index++; } } @@ -260,12 +273,11 @@ } index++; } - } + } } dataGridView_CounterResult.DataSource = table_counterDetecInit; - dataGridView_CounterResult.Columns[3].Visible = false; dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; @@ -273,10 +285,11 @@ dataGridView_CounterResult.Columns[0].Width = 50; dataGridView_CounterResult.Columns[1].Width = 95; dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[4].Width = 110; - dataGridView_CounterResult.Columns[5].Width = 110; - dataGridView_CounterResult.Columns[6].Width = 90; - dataGridView_CounterResult.Columns[7].Width = 140; + dataGridView_CounterResult.Columns[3].Width = 50; + dataGridView_CounterResult.Columns[4].Width = 85; + dataGridView_CounterResult.Columns[5].Width = 105; + dataGridView_CounterResult.Columns[6].Width = 85; + dataGridView_CounterResult.Columns[7].Width = 129; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -300,12 +313,7 @@ text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); - - detected = false; - if (gPIBService.getId() != null && gPIBService.getId().Length > 0) - { - text_signal.Text = gPIBService.getId()[0]; - } + if (tcpService.getId() != null && tcpService.getId().Length > 0) { text_counterIp.Text = tcpService.getId()[0].Split(':')[2]; @@ -350,7 +358,7 @@ } } - + private void benDelete_Click(object sender, EventArgs e) { @@ -466,14 +474,7 @@ { output = cyc * 1000 * 1000 * 1000 + "ns"; } - - //if (output.Contains(".")) - //{ - // if (output.Length >= output.IndexOf('.') + 3) output = output.Substring(0, output.IndexOf('.') + 3) + output.Substring(output.Length-2); - // else output = output.Substring(0, output.IndexOf('.') + 2) + output.Substring(output.Length - 2); - - - //} + } else if (input.Contains("s")) @@ -514,10 +515,6 @@ } - private void dataGridView_CounterResult_CellValueChanged(object sender, DataGridViewCellEventArgs e) - { - - } private void btnStart_Click(object sender, EventArgs e) { @@ -532,106 +529,76 @@ return; } + + dataGridView_CounterResult.ReadOnly = true; - isDetecting = true; btn_add.Enabled = false; benDelete.Enabled = false; btn_dropDetecModel.Enabled = false; - string[] ids = gPIBService.getId(); - //string[] ips = tcpService.getId(); - /*if (ids != null && ids.Length > 0) - { - text_signal.Text = ids[0]; - } - string[] ips = tcpService.getId(); - if (ips != null && ips.Length > 0) - { - text_counterIp.Text = ips[0].Split(':')[2]; - } - else - { - //MessageBox.Show("请连接信号源!"); - return; - } - if (text_counterIp.Text.Equals("")) - { - MessageBox.Show("请输入频率计数器IP!"); - return; - } - else - {*/ string[] arr = text_counterIp.Text.Split('.'); - if (arr.Length != 4) + if (arr.Length != 4) + { + MessageBox.Show("请输入正确的频率计数器IP!"); + return; + } + else + { + foreach (string ipEle in arr) { - MessageBox.Show("请输入正确的频率计数器IP!"); - return; - } - else - { - foreach (string ipEle in arr) + string pattern = @"^[0-9]+$"; + Regex regex = new Regex(pattern); + if (!regex.IsMatch(ipEle)) { - string pattern = @"^[0-9]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(ipEle)) + MessageBox.Show("请输入正确的频率计数器IP!"); + return; + } + else + { + if (Convert.ToInt32(ipEle) < 0 || Convert.ToInt32(ipEle) > 255) { MessageBox.Show("请输入正确的频率计数器IP!"); return; } - else - { - if (Convert.ToInt32(ipEle) < 0 || Convert.ToInt32(ipEle) > 255) - { - MessageBox.Show("请输入正确的频率计数器IP!"); - return; - } - } } } - //} - //if (ips != null && ips.Length > 0) - //{ - // text_counterIp.Text = ips[0]; - //} - //else - //{ - // MessageBox.Show("请连接频率计数器!"); - // return; - //} - + } + text_devName.ReadOnly = true; btn_downCounterList.Enabled = false; btnStart.Enabled = false; btn_dropDetecModel.Enabled = false; textBox_detecModel.ReadOnly = true; - SetDevTestDlg.inDetecCounterId = deviceId; + //SetDevTestDlg.inDetecCounterId = deviceId; + string type = textBox_detecModel.Text.Equals("频率测量") ? "freq" : "period"; string typeId = type.Equals("freq") ? "1" : "2"; new Thread(() => { - // 获取数据 - List counterDetecInitList = counterDetecInitService.getAll(); - - CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); - - int gpibConnection=gPIBService.open(text_signal.Text); - int tcpConnection=tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); - + int gpibConnection = gPIBService.open(text_signal.Text); if (gpibConnection == -1) { MessageBox.Show("未连接信号源"); changeBox(); return; } - else if (tcpConnection == -1) + + int tcpConnection = tcpService.open("TCPIP0::" + text_counterIp.Text + "::INSTR"); + if (tcpConnection == -1) { MessageBox.Show("未连接计数器"); changeBox(); return; } - //tcpService.open(text_counterIp.Text); + detecModelConf(); + + // 获取数据 + List counterDetecInitList = counterDetecInitService.getAll(); + + CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); + int index = 0; foreach (DataGridViewRow row in dataGridView_CounterResult.Rows) { @@ -651,7 +618,7 @@ int re = sensitivityService.beginTest(type, gPIBService, tcpService, counterCheckParam, ref sensitivityContentParam);//0:成功;-1:失败 string value = ""; if (re == 0) - { + { value = type.Equals("freq") ? sensitivityContentParam.ReFreq : sensitivityContentParam.RePeriod; } long dataId = counterDataService.add(deviceId, row.Cells[4].Value.ToString(), value, sensitivityContentParam.VolTage, sensitivityContentParam.CheckTime.ToString("yyyy-MM-dd HH:mm:ss"), typeId); @@ -659,14 +626,18 @@ row.Cells[5].Value = value; row.Cells[6].Value = sensitivityContentParam.VolTage; row.Cells[7].Value = sensitivityContentParam.CheckTime.ToString("yyyy-MM-dd HH:mm:ss"); - + + //dataGridView_CounterResult.Refresh(); index++; } - gPIBService.close(); - tcpService.close(); changeBox(); + + gPIBService.close(); + tcpService.close(); }).Start(); + + } private void changeBox() @@ -684,8 +655,7 @@ dataGridView_CounterResult.ReadOnly = false; btn_add.Enabled = true; benDelete.Enabled = true; - detected = true; - isDetecting = false; + //isDetecting = false; } private void dataGridView_CounterResult_CellEndEdit(object sender, DataGridViewCellEventArgs e) @@ -758,30 +728,17 @@ long initId = counterDetecInitService.addOrUpdate(freq, cycle); dataGridView_CounterResult.Rows[e.RowIndex].Cells[8].Value = initId; } + else if (e.ColumnIndex == 5) { if (!String.IsNullOrEmpty(value)) { string pattern = @"^[0-9.E]+$"; Regex regex = new Regex(pattern); - if (textBox_detecModel.Text.Equals("频率测量")) + if (!regex.IsMatch(value)) { - if (!checkFreq(value)) - { - dataGridView_CounterResult.CurrentCell.Value = ""; - MessageBox.Show("请输入格式正确的、带单位的测量频率!"); - return; - } - } - else - { - if (!checkCyc(value)) - { - dataGridView_CounterResult.CurrentCell.Value = ""; - MessageBox.Show("请输入格式正确的、带单位的测量周期!"); - return; - } - + MessageBox.Show("请输入格式正确的测量值!"); + return; } } } @@ -885,15 +842,18 @@ } } - private int isConnect(string id, string ip) + private void detecModelConf() { - int result = 0; - if (!gPIBService.isOpen()) - result = -1; - else if (!tcpService.isOpen()) - result = -2; - return result; + if (textBox_detecModel.Text == "频率测量") + { + GPIB_TCPIP_OPERATIO.setFreqModel(tcpService); + } + else if (textBox_detecModel.Text == "周期测量") + { + GPIB_TCPIP_OPERATIO.setPerModel(tcpService); + } + } } -} +} \ No newline at end of file diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index c827cf3..a33d35a 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -305,212 +305,229 @@ private void InitTableChannel() { - dataGridView_Channel.Columns.Clear(); - dataGridView_Channel.Rows.Clear(); - - // 添加标题栏 - Panel tableHeader = new Panel + try { - BackColor = Color.White, - Size = new Size(984, 30), - Location = new Point(0, 0) - }; - tableHeader.BackColor = titleBackColor; - dataGridView_Channel.Controls.Add(tableHeader); + lock (obj) + { + dataGridView_Channel.Columns.Clear(); + dataGridView_Channel.Rows.Clear(); - // 通道 - Label colChannelNo = new Label + // 添加标题栏 + Panel tableHeader = new Panel + { + BackColor = Color.White, + Size = new Size(984, 30), + Location = new Point(0, 0) + }; + tableHeader.BackColor = titleBackColor; + dataGridView_Channel.Controls.Add(tableHeader); + + // 通道 + Label colChannelNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "通道", + Location = new Point(0, 0), + Size = new Size(50, 30) + }; + dataGridView_Channel.Controls.Add(colChannelNo); + colChannelNo.BringToFront(); + + // 仪器名称 + Label colDevName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器名称", + Location = new Point(50, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevName); + colDevName.BringToFront(); + + // 仪器编号 + Label colDevNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器编号", + Location = new Point(160, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevNo); + colDevNo.BringToFront(); + + // 客户名称 + Label colCustomName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "送检单位", + Location = new Point(270, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colCustomName); + colCustomName.BringToFront(); + + // 开始时间 + Label colStartTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开始时间", + Location = new Point(380, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colStartTime); + colStartTime.BringToFront(); + + // 结束时间 + Label colEndTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "结束时间", + Location = new Point(500, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colEndTime); + colEndTime.BringToFront(); + + // 状态 + Label colStatus = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "状态", + Location = new Point(620, 0), + Size = new Size(64, 30) + }; + dataGridView_Channel.Controls.Add(colStatus); + colStatus.BringToFront(); + + // 频率稳定度 + Label colStablility = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "稳定度", + + Location = new Point(684, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStablility); + colStablility.BringToFront(); + + // 频率准确度 + Label colAccuracy = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "准确度", + Location = new Point(754, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colAccuracy); + colAccuracy.BringToFront(); + + // 开机特性 + Label colStartup = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开机特性", + + Location = new Point(824, 0), + + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStartup); + colStartup.BringToFront(); + + // 日老化率 + Label colAgingRate = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "日老化率", + Location = new Point(899, 0), + Size = new Size(75, 30) + }; + + + dataGridView_Channel.Controls.Add(colAgingRate); + colAgingRate.BringToFront(); + } + } + catch (Exception ex) { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "通道", - Location = new Point(0, 0), - Size = new Size(50, 30) - }; - dataGridView_Channel.Controls.Add(colChannelNo); - colChannelNo.BringToFront(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "InitTableChannel 错误:" + ex.Message); - // 仪器名称 - Label colDevName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器名称", - Location = new Point(50, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevName); - colDevName.BringToFront(); - - // 仪器编号 - Label colDevNo = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器编号", - Location = new Point(160, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 客户名称 - Label colCustomName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "送检单位", - Location = new Point(270, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colCustomName); - colCustomName.BringToFront(); - - // 开始时间 - Label colStartTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开始时间", - Location = new Point(380, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colStartTime); - colStartTime.BringToFront(); - - // 结束时间 - Label colEndTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "结束时间", - Location = new Point(500, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colEndTime); - colEndTime.BringToFront(); - - // 状态 - Label colStatus = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "状态", - Location = new Point(620, 0), - Size = new Size(64, 30) - }; - dataGridView_Channel.Controls.Add(colStatus); - colStatus.BringToFront(); - - // 频率稳定度 - Label colStablility = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "稳定度", - - Location = new Point(684,0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStablility); - colStablility.BringToFront(); - - // 频率准确度 - Label colAccuracy = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "准确度", - Location = new Point(754, 0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colAccuracy); - colAccuracy.BringToFront(); - - // 开机特性 - Label colStartup = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开机特性", - - Location = new Point(824, 0), - - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStartup); - colStartup.BringToFront(); - - - - // 日老化率 - Label colAgingRate = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "日老化率", - Location = new Point(899, 0), - Size = new Size(75, 30) - }; - - - dataGridView_Channel.Controls.Add(colAgingRate); - colAgingRate.BringToFront(); + } } public void refreshChannelList() { - lock (obj) + try { - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - listChannelStatus = deviceService.getDeviceByChannel(); - if (listChannelStatus != null && listChannelStatus.Count > 0) + lock (obj) { - foreach (DeviceView device in listChannelStatus) + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + } } } } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "refreshChannelList 错误:" + ex.Message); + + } } public void LoadChannelStatus() { @@ -651,24 +668,39 @@ { lock (obj) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); + dataGridView_Channel.ClearSelection(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); int channelNo = e.RowIndex + 1; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); if (channelFreeList.Contains(channelNo + "")) { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); } else { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); } foreach (string no in channelFreeList.ToArray()) { dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; } + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) @@ -735,26 +767,37 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; - long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; - string startTime = ""; - string endTime = ""; - if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) - { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } - if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) - { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + try + { + long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; + string startTime = ""; + string endTime = ""; + if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) + { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } + if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) + { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + if (startTime.Equals("") && endTime.Equals("")) + { + return; + } + DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (dialogResult == DialogResult.Yes) + { - DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (dialogResult == DialogResult.Yes) - { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + } + else + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + } + LoadChannelStatus(); + LoadDevToBeTested(); } - else + catch(Exception ex) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "cellDoubleClick 错误:" + ex.Message); } - LoadChannelStatus(); - LoadDevToBeTested(); return; } else diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index f99f106..8baed4b 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -47,6 +47,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); int channel = 0; + public Action HideMaskAction { @@ -66,9 +67,7 @@ SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 跨线程访问控件 - CheckForIllegalCrossThreadCalls = false; - - + CheckForIllegalCrossThreadCalls = false; } private void btnExitChannel_Click(object sender, EventArgs e) @@ -158,6 +157,10 @@ MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1] = port; + } } catch (Exception exc) { diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 1a82d85..26e8cab 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -30,6 +30,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); DeviceService deviceService = new DeviceServiceImpl(); + #region 无边框拖动效果/最小化窗口/关闭窗口 [DllImport("user32.dll")]//拖动无窗体的控件 public static extern bool ReleaseCapture(); @@ -66,6 +67,7 @@ // 跨线程访问控件 CheckForIllegalCrossThreadCalls = false; + } // 开始检测 @@ -117,6 +119,10 @@ MessageBox.Show("无法打开串口" + portName + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..2796a25 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -19,6 +19,7 @@ int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..6b8c687 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -321,6 +321,56 @@ } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = new DetectionItem(); + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 9bfde8e..d0f942c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -43,15 +43,14 @@ try { //tcpService.write("INIT"); - //tcpService.write("*WAI"); //freqRequest++; //Thread.Sleep(2000); //tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:FREQ?"); - //tcpService.write("READ?"); + Thread.Sleep(2000); + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); //Thread.Sleep(1000); return tcpService.read(); @@ -68,17 +67,16 @@ { try { - + //tcpService.write("INIT"); + //tcpService.write("*WAI"); //tcpService.write("INIT"); //tcpService.write("*WAI"); - - //tcpService.write("INIT"); - - //tcpService.write("*WAI"); - tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:PERIOD?"); + //tcpService.write("*CLS"); + Thread.Sleep(2000); + //tcpService.write("MEAS:PERIOD?"); + + tcpService.write("READ?"); return tcpService.read(); } @@ -100,5 +98,32 @@ LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setIMP:" + ex.Message); } } + + public static void setFreqModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:FREQ"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setFreqModel:" + ex.Message); + } + } + + public static void setPerModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:PER"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setPerModel:" + ex.Message); + } + } + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index 8ad1a8a..9916a9c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -89,7 +89,7 @@ hasException = true; } - if (!hasException) _portOperatorBaseTcp.Timeout = 2000; + if (!hasException) _portOperatorBaseTcp.Timeout = 1000; return hasAddress; } @@ -134,12 +134,13 @@ string content = ""; try { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType,"TCPRead:"+DateTime.Now); content = _portOperatorBaseTcp.ReadLine(); } catch (Exception ex) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterId : " + ex.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "TCPRead: " + ex.Message); content = ""; } return content; diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 936cc37..a3daf40 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -571,7 +571,7 @@ break; case 3: // 频率计数器范围 - CounterCtrlForm counterForm = new CounterCtrlForm(); + CounterCtrlForm counterForm = CounterCtrlForm.GetInstance(); counterForm.Show(); panelMain.Controls.Add(counterForm); break; diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 876c624..b0a8196 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index 4094808..0026ae3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.btn_dropDetecModel = new System.Windows.Forms.Button(); @@ -60,9 +63,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -87,13 +87,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -106,13 +106,13 @@ this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle4.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -121,7 +121,6 @@ this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); this.dataGridView_CounterResult.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellEndEdit); - this.dataGridView_CounterResult.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellValueChanged); // // panelMedian // @@ -147,6 +146,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -158,6 +205,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -438,78 +509,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index fd7ffee..357a90c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -22,6 +22,7 @@ DeviceService deviceService = new DeviceServiceImpl(); DictService dictService = new DictServiceImpl(); CounterDetecInitService counterDetecInitService = new CounterDetecInitServiceImpl(); + CounterDataService counterDataService = new CounterDataServiceImpl(); SensitivityService sensitivityService = new SensitivityServiceImpl(); @@ -32,8 +33,7 @@ string devPort = "输入A"; long deviceId = 0; bool isAdd = false; - bool detected = false; - public static bool isDetecting = false; + //public static bool isDetecting = false; GPIBService gPIBService = new GPIBServiceImpl(); GPIBService tcpService = new TCPServiceImpl(); @@ -44,8 +44,19 @@ private readonly Color titleBackColor = Color.FromArgb(63, 132, 215); // #3F64D7 private readonly Font titleFont = new Font("微软雅黑", 14F, FontStyle.Regular, GraphicsUnit.Pixel, 134); #endregion + - public CounterCtrlForm() + private static CounterCtrlForm _counterCtrlForm = null; + + public static CounterCtrlForm GetInstance() + { + if (_counterCtrlForm == null) + _counterCtrlForm = new CounterCtrlForm(); + + return _counterCtrlForm; + } + + private CounterCtrlForm() { InitializeComponent(); @@ -56,8 +67,7 @@ comboBox_counters.ValueMember = "Id"; InitTableCounter(); LoadCounterDetecInitList(); - - + if (list != null && list.Count > 0) { string[] ids = gPIBService.getId(); @@ -111,7 +121,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(48, 0), + Location = new Point(46, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); @@ -126,12 +136,27 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(142, 0), + Location = new Point(145, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); colDevNo.BringToFront(); + // 描述/端口 + Label colDevPort = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "描述", + Location = new Point(242, 0), + Size = new Size(50, 50) + }; + dataGridView_CounterResult.Controls.Add(colDevPort); + colDevPort.BringToFront(); + // 标称值 colStdValue = new Label { @@ -141,7 +166,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(247, 0), + Location = new Point(285, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -156,7 +181,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(360, 0), + Location = new Point(377, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colValue); @@ -171,7 +196,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(465, 0), + Location = new Point(480, 0), Size = new Size(95, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); @@ -190,23 +215,11 @@ }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); - - - + } private void LoadCounterDetecInitList() { - //dataGridView_CounterResult.Columns.Add("index", ""); - //dataGridView_CounterResult.Columns.Add("devType", ""); - //dataGridView_CounterResult.Columns.Add("devNo", ""); - //dataGridView_CounterResult.Columns.Add("devPort", ""); - //dataGridView_CounterResult.Columns.Add("stdValue", ""); - //dataGridView_CounterResult.Columns.Add("value", ""); - //dataGridView_CounterResult.Columns.Add("sensitivity", ""); - //dataGridView_CounterResult.Columns.Add("logTime", ""); - //dataGridView_CounterResult.Columns.Add("id", ""); - table_counterDetecInit = new DataTable(); table_counterDetecInit.Columns.Add("index", Type.GetType("System.String")); @@ -221,8 +234,8 @@ table_counterDetecInit.Columns.Add("counterDataId", Type.GetType("System.Int64")); if (text_devName.Text != "") - { - List list =deviceService.search(text_devName.Text,"","","","",""); + { + List list = deviceService.search(text_devName.Text, "", "", "", "", ""); if (null != list && list.Count > 0) { devType = list[0].DevTypeName; @@ -237,7 +250,7 @@ int index = 1; foreach (CounterData counterData in counterDataList) { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterData.OutValue, counterData.Value,counterData.Sensitivity, counterData.LogTime, -1, counterData.Id); + table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterData.OutValue, counterData.Value, counterData.Sensitivity, counterData.LogTime, -1, counterData.Id); index++; } } @@ -260,12 +273,11 @@ } index++; } - } + } } dataGridView_CounterResult.DataSource = table_counterDetecInit; - dataGridView_CounterResult.Columns[3].Visible = false; dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; @@ -273,10 +285,11 @@ dataGridView_CounterResult.Columns[0].Width = 50; dataGridView_CounterResult.Columns[1].Width = 95; dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[4].Width = 110; - dataGridView_CounterResult.Columns[5].Width = 110; - dataGridView_CounterResult.Columns[6].Width = 90; - dataGridView_CounterResult.Columns[7].Width = 140; + dataGridView_CounterResult.Columns[3].Width = 50; + dataGridView_CounterResult.Columns[4].Width = 85; + dataGridView_CounterResult.Columns[5].Width = 105; + dataGridView_CounterResult.Columns[6].Width = 85; + dataGridView_CounterResult.Columns[7].Width = 129; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -300,12 +313,7 @@ text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); - - detected = false; - if (gPIBService.getId() != null && gPIBService.getId().Length > 0) - { - text_signal.Text = gPIBService.getId()[0]; - } + if (tcpService.getId() != null && tcpService.getId().Length > 0) { text_counterIp.Text = tcpService.getId()[0].Split(':')[2]; @@ -350,7 +358,7 @@ } } - + private void benDelete_Click(object sender, EventArgs e) { @@ -466,14 +474,7 @@ { output = cyc * 1000 * 1000 * 1000 + "ns"; } - - //if (output.Contains(".")) - //{ - // if (output.Length >= output.IndexOf('.') + 3) output = output.Substring(0, output.IndexOf('.') + 3) + output.Substring(output.Length-2); - // else output = output.Substring(0, output.IndexOf('.') + 2) + output.Substring(output.Length - 2); - - - //} + } else if (input.Contains("s")) @@ -514,10 +515,6 @@ } - private void dataGridView_CounterResult_CellValueChanged(object sender, DataGridViewCellEventArgs e) - { - - } private void btnStart_Click(object sender, EventArgs e) { @@ -532,106 +529,76 @@ return; } + + dataGridView_CounterResult.ReadOnly = true; - isDetecting = true; btn_add.Enabled = false; benDelete.Enabled = false; btn_dropDetecModel.Enabled = false; - string[] ids = gPIBService.getId(); - //string[] ips = tcpService.getId(); - /*if (ids != null && ids.Length > 0) - { - text_signal.Text = ids[0]; - } - string[] ips = tcpService.getId(); - if (ips != null && ips.Length > 0) - { - text_counterIp.Text = ips[0].Split(':')[2]; - } - else - { - //MessageBox.Show("请连接信号源!"); - return; - } - if (text_counterIp.Text.Equals("")) - { - MessageBox.Show("请输入频率计数器IP!"); - return; - } - else - {*/ string[] arr = text_counterIp.Text.Split('.'); - if (arr.Length != 4) + if (arr.Length != 4) + { + MessageBox.Show("请输入正确的频率计数器IP!"); + return; + } + else + { + foreach (string ipEle in arr) { - MessageBox.Show("请输入正确的频率计数器IP!"); - return; - } - else - { - foreach (string ipEle in arr) + string pattern = @"^[0-9]+$"; + Regex regex = new Regex(pattern); + if (!regex.IsMatch(ipEle)) { - string pattern = @"^[0-9]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(ipEle)) + MessageBox.Show("请输入正确的频率计数器IP!"); + return; + } + else + { + if (Convert.ToInt32(ipEle) < 0 || Convert.ToInt32(ipEle) > 255) { MessageBox.Show("请输入正确的频率计数器IP!"); return; } - else - { - if (Convert.ToInt32(ipEle) < 0 || Convert.ToInt32(ipEle) > 255) - { - MessageBox.Show("请输入正确的频率计数器IP!"); - return; - } - } } } - //} - //if (ips != null && ips.Length > 0) - //{ - // text_counterIp.Text = ips[0]; - //} - //else - //{ - // MessageBox.Show("请连接频率计数器!"); - // return; - //} - + } + text_devName.ReadOnly = true; btn_downCounterList.Enabled = false; btnStart.Enabled = false; btn_dropDetecModel.Enabled = false; textBox_detecModel.ReadOnly = true; - SetDevTestDlg.inDetecCounterId = deviceId; + //SetDevTestDlg.inDetecCounterId = deviceId; + string type = textBox_detecModel.Text.Equals("频率测量") ? "freq" : "period"; string typeId = type.Equals("freq") ? "1" : "2"; new Thread(() => { - // 获取数据 - List counterDetecInitList = counterDetecInitService.getAll(); - - CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); - - int gpibConnection=gPIBService.open(text_signal.Text); - int tcpConnection=tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); - + int gpibConnection = gPIBService.open(text_signal.Text); if (gpibConnection == -1) { MessageBox.Show("未连接信号源"); changeBox(); return; } - else if (tcpConnection == -1) + + int tcpConnection = tcpService.open("TCPIP0::" + text_counterIp.Text + "::INSTR"); + if (tcpConnection == -1) { MessageBox.Show("未连接计数器"); changeBox(); return; } - //tcpService.open(text_counterIp.Text); + detecModelConf(); + + // 获取数据 + List counterDetecInitList = counterDetecInitService.getAll(); + + CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); + int index = 0; foreach (DataGridViewRow row in dataGridView_CounterResult.Rows) { @@ -651,7 +618,7 @@ int re = sensitivityService.beginTest(type, gPIBService, tcpService, counterCheckParam, ref sensitivityContentParam);//0:成功;-1:失败 string value = ""; if (re == 0) - { + { value = type.Equals("freq") ? sensitivityContentParam.ReFreq : sensitivityContentParam.RePeriod; } long dataId = counterDataService.add(deviceId, row.Cells[4].Value.ToString(), value, sensitivityContentParam.VolTage, sensitivityContentParam.CheckTime.ToString("yyyy-MM-dd HH:mm:ss"), typeId); @@ -659,14 +626,18 @@ row.Cells[5].Value = value; row.Cells[6].Value = sensitivityContentParam.VolTage; row.Cells[7].Value = sensitivityContentParam.CheckTime.ToString("yyyy-MM-dd HH:mm:ss"); - + + //dataGridView_CounterResult.Refresh(); index++; } - gPIBService.close(); - tcpService.close(); changeBox(); + + gPIBService.close(); + tcpService.close(); }).Start(); + + } private void changeBox() @@ -684,8 +655,7 @@ dataGridView_CounterResult.ReadOnly = false; btn_add.Enabled = true; benDelete.Enabled = true; - detected = true; - isDetecting = false; + //isDetecting = false; } private void dataGridView_CounterResult_CellEndEdit(object sender, DataGridViewCellEventArgs e) @@ -758,30 +728,17 @@ long initId = counterDetecInitService.addOrUpdate(freq, cycle); dataGridView_CounterResult.Rows[e.RowIndex].Cells[8].Value = initId; } + else if (e.ColumnIndex == 5) { if (!String.IsNullOrEmpty(value)) { string pattern = @"^[0-9.E]+$"; Regex regex = new Regex(pattern); - if (textBox_detecModel.Text.Equals("频率测量")) + if (!regex.IsMatch(value)) { - if (!checkFreq(value)) - { - dataGridView_CounterResult.CurrentCell.Value = ""; - MessageBox.Show("请输入格式正确的、带单位的测量频率!"); - return; - } - } - else - { - if (!checkCyc(value)) - { - dataGridView_CounterResult.CurrentCell.Value = ""; - MessageBox.Show("请输入格式正确的、带单位的测量周期!"); - return; - } - + MessageBox.Show("请输入格式正确的测量值!"); + return; } } } @@ -885,15 +842,18 @@ } } - private int isConnect(string id, string ip) + private void detecModelConf() { - int result = 0; - if (!gPIBService.isOpen()) - result = -1; - else if (!tcpService.isOpen()) - result = -2; - return result; + if (textBox_detecModel.Text == "频率测量") + { + GPIB_TCPIP_OPERATIO.setFreqModel(tcpService); + } + else if (textBox_detecModel.Text == "周期测量") + { + GPIB_TCPIP_OPERATIO.setPerModel(tcpService); + } + } } -} +} \ No newline at end of file diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index c827cf3..a33d35a 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -305,212 +305,229 @@ private void InitTableChannel() { - dataGridView_Channel.Columns.Clear(); - dataGridView_Channel.Rows.Clear(); - - // 添加标题栏 - Panel tableHeader = new Panel + try { - BackColor = Color.White, - Size = new Size(984, 30), - Location = new Point(0, 0) - }; - tableHeader.BackColor = titleBackColor; - dataGridView_Channel.Controls.Add(tableHeader); + lock (obj) + { + dataGridView_Channel.Columns.Clear(); + dataGridView_Channel.Rows.Clear(); - // 通道 - Label colChannelNo = new Label + // 添加标题栏 + Panel tableHeader = new Panel + { + BackColor = Color.White, + Size = new Size(984, 30), + Location = new Point(0, 0) + }; + tableHeader.BackColor = titleBackColor; + dataGridView_Channel.Controls.Add(tableHeader); + + // 通道 + Label colChannelNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "通道", + Location = new Point(0, 0), + Size = new Size(50, 30) + }; + dataGridView_Channel.Controls.Add(colChannelNo); + colChannelNo.BringToFront(); + + // 仪器名称 + Label colDevName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器名称", + Location = new Point(50, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevName); + colDevName.BringToFront(); + + // 仪器编号 + Label colDevNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器编号", + Location = new Point(160, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevNo); + colDevNo.BringToFront(); + + // 客户名称 + Label colCustomName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "送检单位", + Location = new Point(270, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colCustomName); + colCustomName.BringToFront(); + + // 开始时间 + Label colStartTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开始时间", + Location = new Point(380, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colStartTime); + colStartTime.BringToFront(); + + // 结束时间 + Label colEndTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "结束时间", + Location = new Point(500, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colEndTime); + colEndTime.BringToFront(); + + // 状态 + Label colStatus = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "状态", + Location = new Point(620, 0), + Size = new Size(64, 30) + }; + dataGridView_Channel.Controls.Add(colStatus); + colStatus.BringToFront(); + + // 频率稳定度 + Label colStablility = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "稳定度", + + Location = new Point(684, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStablility); + colStablility.BringToFront(); + + // 频率准确度 + Label colAccuracy = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "准确度", + Location = new Point(754, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colAccuracy); + colAccuracy.BringToFront(); + + // 开机特性 + Label colStartup = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开机特性", + + Location = new Point(824, 0), + + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStartup); + colStartup.BringToFront(); + + // 日老化率 + Label colAgingRate = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "日老化率", + Location = new Point(899, 0), + Size = new Size(75, 30) + }; + + + dataGridView_Channel.Controls.Add(colAgingRate); + colAgingRate.BringToFront(); + } + } + catch (Exception ex) { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "通道", - Location = new Point(0, 0), - Size = new Size(50, 30) - }; - dataGridView_Channel.Controls.Add(colChannelNo); - colChannelNo.BringToFront(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "InitTableChannel 错误:" + ex.Message); - // 仪器名称 - Label colDevName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器名称", - Location = new Point(50, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevName); - colDevName.BringToFront(); - - // 仪器编号 - Label colDevNo = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器编号", - Location = new Point(160, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 客户名称 - Label colCustomName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "送检单位", - Location = new Point(270, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colCustomName); - colCustomName.BringToFront(); - - // 开始时间 - Label colStartTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开始时间", - Location = new Point(380, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colStartTime); - colStartTime.BringToFront(); - - // 结束时间 - Label colEndTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "结束时间", - Location = new Point(500, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colEndTime); - colEndTime.BringToFront(); - - // 状态 - Label colStatus = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "状态", - Location = new Point(620, 0), - Size = new Size(64, 30) - }; - dataGridView_Channel.Controls.Add(colStatus); - colStatus.BringToFront(); - - // 频率稳定度 - Label colStablility = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "稳定度", - - Location = new Point(684,0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStablility); - colStablility.BringToFront(); - - // 频率准确度 - Label colAccuracy = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "准确度", - Location = new Point(754, 0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colAccuracy); - colAccuracy.BringToFront(); - - // 开机特性 - Label colStartup = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开机特性", - - Location = new Point(824, 0), - - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStartup); - colStartup.BringToFront(); - - - - // 日老化率 - Label colAgingRate = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "日老化率", - Location = new Point(899, 0), - Size = new Size(75, 30) - }; - - - dataGridView_Channel.Controls.Add(colAgingRate); - colAgingRate.BringToFront(); + } } public void refreshChannelList() { - lock (obj) + try { - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - listChannelStatus = deviceService.getDeviceByChannel(); - if (listChannelStatus != null && listChannelStatus.Count > 0) + lock (obj) { - foreach (DeviceView device in listChannelStatus) + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + } } } } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "refreshChannelList 错误:" + ex.Message); + + } } public void LoadChannelStatus() { @@ -651,24 +668,39 @@ { lock (obj) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); + dataGridView_Channel.ClearSelection(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); int channelNo = e.RowIndex + 1; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); if (channelFreeList.Contains(channelNo + "")) { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); } else { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); } foreach (string no in channelFreeList.ToArray()) { dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; } + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) @@ -735,26 +767,37 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; - long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; - string startTime = ""; - string endTime = ""; - if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) - { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } - if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) - { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + try + { + long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; + string startTime = ""; + string endTime = ""; + if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) + { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } + if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) + { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + if (startTime.Equals("") && endTime.Equals("")) + { + return; + } + DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (dialogResult == DialogResult.Yes) + { - DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (dialogResult == DialogResult.Yes) - { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + } + else + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + } + LoadChannelStatus(); + LoadDevToBeTested(); } - else + catch(Exception ex) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "cellDoubleClick 错误:" + ex.Message); } - LoadChannelStatus(); - LoadDevToBeTested(); return; } else diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index f99f106..8baed4b 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -47,6 +47,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); int channel = 0; + public Action HideMaskAction { @@ -66,9 +67,7 @@ SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 跨线程访问控件 - CheckForIllegalCrossThreadCalls = false; - - + CheckForIllegalCrossThreadCalls = false; } private void btnExitChannel_Click(object sender, EventArgs e) @@ -158,6 +157,10 @@ MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1] = port; + } } catch (Exception exc) { diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 1a82d85..26e8cab 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -30,6 +30,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); DeviceService deviceService = new DeviceServiceImpl(); + #region 无边框拖动效果/最小化窗口/关闭窗口 [DllImport("user32.dll")]//拖动无窗体的控件 public static extern bool ReleaseCapture(); @@ -66,6 +67,7 @@ // 跨线程访问控件 CheckForIllegalCrossThreadCalls = false; + } // 开始检测 @@ -117,6 +119,10 @@ MessageBox.Show("无法打开串口" + portName + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index ed117e0..71a0230 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -47,7 +47,6 @@ public long deviceId = -1; public static bool isInDetection = false; - public Action HideMaskAction { get; @@ -77,7 +76,8 @@ text_channelNo.WatermarkText = "无空闲通道"; groupBox1.Enabled = false; } - + + } // 关闭对话框 @@ -208,6 +208,10 @@ MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 64253a7..2796a25 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -19,6 +19,7 @@ int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); + DetectionItem getById(long detectionItemId); int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100); } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index b849d77..6b8c687 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -321,6 +321,56 @@ } return iRetval; } + public DetectionItem getById(long detectionItemId) + { + DetectionItem detectionItem = new DetectionItem(); + try + { + + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return detectionItem; + } + } + + string sQry = "select * from r_detection_item WHERE ID = "+ detectionItemId; + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + using (MySqlDataReader aReader = cmd.ExecuteReader()) + { + while (aReader.Read()) + { + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + } + } + + cmd.Dispose(); + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + return detectionItem; + } + return detectionItem; + } public List search(long deviceId, bool isInDetection) { diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs index 9bfde8e..d0f942c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/GPIB_TCPIP_OPERATIO.cs @@ -43,15 +43,14 @@ try { //tcpService.write("INIT"); - //tcpService.write("*WAI"); //freqRequest++; //Thread.Sleep(2000); //tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:FREQ?"); - //tcpService.write("READ?"); + Thread.Sleep(2000); + //tcpService.write("MEAS:FREQ?"); + tcpService.write("READ?"); //Thread.Sleep(1000); return tcpService.read(); @@ -68,17 +67,16 @@ { try { - + //tcpService.write("INIT"); + //tcpService.write("*WAI"); //tcpService.write("INIT"); //tcpService.write("*WAI"); - - //tcpService.write("INIT"); - - //tcpService.write("*WAI"); - tcpService.write("*CLS"); - //Thread.Sleep(100); - tcpService.write("MEAS:PERIOD?"); + //tcpService.write("*CLS"); + Thread.Sleep(2000); + //tcpService.write("MEAS:PERIOD?"); + + tcpService.write("READ?"); return tcpService.read(); } @@ -100,5 +98,32 @@ LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setIMP:" + ex.Message); } } + + public static void setFreqModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:FREQ"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setFreqModel:" + ex.Message); + } + } + + public static void setPerModel(GPIBService tcpService) + { + try + { + tcpService.write("*CLS"); + tcpService.write("CONF:PER"); + } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "setPerModel:" + ex.Message); + } + } + } } \ No newline at end of file diff --git a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs index 8ad1a8a..9916a9c 100644 --- a/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs +++ b/RbFreqStandMeasure/R_DevService/Service/Impl/TCPServiceImpl.cs @@ -89,7 +89,7 @@ hasException = true; } - if (!hasException) _portOperatorBaseTcp.Timeout = 2000; + if (!hasException) _portOperatorBaseTcp.Timeout = 1000; return hasAddress; } @@ -134,12 +134,13 @@ string content = ""; try { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType,"TCPRead:"+DateTime.Now); content = _portOperatorBaseTcp.ReadLine(); } catch (Exception ex) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getCounterId : " + ex.Message); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "TCPRead: " + ex.Message); content = ""; } return content; diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 936cc37..a3daf40 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -571,7 +571,7 @@ break; case 3: // 频率计数器范围 - CounterCtrlForm counterForm = new CounterCtrlForm(); + CounterCtrlForm counterForm = CounterCtrlForm.GetInstance(); counterForm.Show(); panelMain.Controls.Add(counterForm); break; diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index 876c624..b0a8196 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index 4094808..0026ae3 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.btn_dropDetecModel = new System.Windows.Forms.Button(); @@ -60,9 +63,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -87,13 +87,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle3.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle3.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle3.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle3.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -106,13 +106,13 @@ this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle4.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle4.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle4; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; @@ -121,7 +121,6 @@ this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); this.dataGridView_CounterResult.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellEndEdit); - this.dataGridView_CounterResult.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellValueChanged); // // panelMedian // @@ -147,6 +146,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -158,6 +205,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -438,78 +509,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index fd7ffee..357a90c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -22,6 +22,7 @@ DeviceService deviceService = new DeviceServiceImpl(); DictService dictService = new DictServiceImpl(); CounterDetecInitService counterDetecInitService = new CounterDetecInitServiceImpl(); + CounterDataService counterDataService = new CounterDataServiceImpl(); SensitivityService sensitivityService = new SensitivityServiceImpl(); @@ -32,8 +33,7 @@ string devPort = "输入A"; long deviceId = 0; bool isAdd = false; - bool detected = false; - public static bool isDetecting = false; + //public static bool isDetecting = false; GPIBService gPIBService = new GPIBServiceImpl(); GPIBService tcpService = new TCPServiceImpl(); @@ -44,8 +44,19 @@ private readonly Color titleBackColor = Color.FromArgb(63, 132, 215); // #3F64D7 private readonly Font titleFont = new Font("微软雅黑", 14F, FontStyle.Regular, GraphicsUnit.Pixel, 134); #endregion + - public CounterCtrlForm() + private static CounterCtrlForm _counterCtrlForm = null; + + public static CounterCtrlForm GetInstance() + { + if (_counterCtrlForm == null) + _counterCtrlForm = new CounterCtrlForm(); + + return _counterCtrlForm; + } + + private CounterCtrlForm() { InitializeComponent(); @@ -56,8 +67,7 @@ comboBox_counters.ValueMember = "Id"; InitTableCounter(); LoadCounterDetecInitList(); - - + if (list != null && list.Count > 0) { string[] ids = gPIBService.getId(); @@ -111,7 +121,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(48, 0), + Location = new Point(46, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); @@ -126,12 +136,27 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(142, 0), + Location = new Point(145, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevNo); colDevNo.BringToFront(); + // 描述/端口 + Label colDevPort = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "描述", + Location = new Point(242, 0), + Size = new Size(50, 50) + }; + dataGridView_CounterResult.Controls.Add(colDevPort); + colDevPort.BringToFront(); + // 标称值 colStdValue = new Label { @@ -141,7 +166,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(247, 0), + Location = new Point(285, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -156,7 +181,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(360, 0), + Location = new Point(377, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colValue); @@ -171,7 +196,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(465, 0), + Location = new Point(480, 0), Size = new Size(95, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); @@ -190,23 +215,11 @@ }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); - - - + } private void LoadCounterDetecInitList() { - //dataGridView_CounterResult.Columns.Add("index", ""); - //dataGridView_CounterResult.Columns.Add("devType", ""); - //dataGridView_CounterResult.Columns.Add("devNo", ""); - //dataGridView_CounterResult.Columns.Add("devPort", ""); - //dataGridView_CounterResult.Columns.Add("stdValue", ""); - //dataGridView_CounterResult.Columns.Add("value", ""); - //dataGridView_CounterResult.Columns.Add("sensitivity", ""); - //dataGridView_CounterResult.Columns.Add("logTime", ""); - //dataGridView_CounterResult.Columns.Add("id", ""); - table_counterDetecInit = new DataTable(); table_counterDetecInit.Columns.Add("index", Type.GetType("System.String")); @@ -221,8 +234,8 @@ table_counterDetecInit.Columns.Add("counterDataId", Type.GetType("System.Int64")); if (text_devName.Text != "") - { - List list =deviceService.search(text_devName.Text,"","","","",""); + { + List list = deviceService.search(text_devName.Text, "", "", "", "", ""); if (null != list && list.Count > 0) { devType = list[0].DevTypeName; @@ -237,7 +250,7 @@ int index = 1; foreach (CounterData counterData in counterDataList) { - table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterData.OutValue, counterData.Value,counterData.Sensitivity, counterData.LogTime, -1, counterData.Id); + table_counterDetecInit.Rows.Add(index, devType, devCode, devPort, counterData.OutValue, counterData.Value, counterData.Sensitivity, counterData.LogTime, -1, counterData.Id); index++; } } @@ -260,12 +273,11 @@ } index++; } - } + } } dataGridView_CounterResult.DataSource = table_counterDetecInit; - dataGridView_CounterResult.Columns[3].Visible = false; dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; @@ -273,10 +285,11 @@ dataGridView_CounterResult.Columns[0].Width = 50; dataGridView_CounterResult.Columns[1].Width = 95; dataGridView_CounterResult.Columns[2].Width = 95; - dataGridView_CounterResult.Columns[4].Width = 110; - dataGridView_CounterResult.Columns[5].Width = 110; - dataGridView_CounterResult.Columns[6].Width = 90; - dataGridView_CounterResult.Columns[7].Width = 140; + dataGridView_CounterResult.Columns[3].Width = 50; + dataGridView_CounterResult.Columns[4].Width = 85; + dataGridView_CounterResult.Columns[5].Width = 105; + dataGridView_CounterResult.Columns[6].Width = 85; + dataGridView_CounterResult.Columns[7].Width = 129; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -300,12 +313,7 @@ text_devName.Text = ((DeviceDto)comboBox_counters.SelectedItem).DevName; deviceId = ((DeviceDto)comboBox_counters.SelectedItem).Id; LoadCounterDetecInitList(); - - detected = false; - if (gPIBService.getId() != null && gPIBService.getId().Length > 0) - { - text_signal.Text = gPIBService.getId()[0]; - } + if (tcpService.getId() != null && tcpService.getId().Length > 0) { text_counterIp.Text = tcpService.getId()[0].Split(':')[2]; @@ -350,7 +358,7 @@ } } - + private void benDelete_Click(object sender, EventArgs e) { @@ -466,14 +474,7 @@ { output = cyc * 1000 * 1000 * 1000 + "ns"; } - - //if (output.Contains(".")) - //{ - // if (output.Length >= output.IndexOf('.') + 3) output = output.Substring(0, output.IndexOf('.') + 3) + output.Substring(output.Length-2); - // else output = output.Substring(0, output.IndexOf('.') + 2) + output.Substring(output.Length - 2); - - - //} + } else if (input.Contains("s")) @@ -514,10 +515,6 @@ } - private void dataGridView_CounterResult_CellValueChanged(object sender, DataGridViewCellEventArgs e) - { - - } private void btnStart_Click(object sender, EventArgs e) { @@ -532,106 +529,76 @@ return; } + + dataGridView_CounterResult.ReadOnly = true; - isDetecting = true; btn_add.Enabled = false; benDelete.Enabled = false; btn_dropDetecModel.Enabled = false; - string[] ids = gPIBService.getId(); - //string[] ips = tcpService.getId(); - /*if (ids != null && ids.Length > 0) - { - text_signal.Text = ids[0]; - } - string[] ips = tcpService.getId(); - if (ips != null && ips.Length > 0) - { - text_counterIp.Text = ips[0].Split(':')[2]; - } - else - { - //MessageBox.Show("请连接信号源!"); - return; - } - if (text_counterIp.Text.Equals("")) - { - MessageBox.Show("请输入频率计数器IP!"); - return; - } - else - {*/ string[] arr = text_counterIp.Text.Split('.'); - if (arr.Length != 4) + if (arr.Length != 4) + { + MessageBox.Show("请输入正确的频率计数器IP!"); + return; + } + else + { + foreach (string ipEle in arr) { - MessageBox.Show("请输入正确的频率计数器IP!"); - return; - } - else - { - foreach (string ipEle in arr) + string pattern = @"^[0-9]+$"; + Regex regex = new Regex(pattern); + if (!regex.IsMatch(ipEle)) { - string pattern = @"^[0-9]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(ipEle)) + MessageBox.Show("请输入正确的频率计数器IP!"); + return; + } + else + { + if (Convert.ToInt32(ipEle) < 0 || Convert.ToInt32(ipEle) > 255) { MessageBox.Show("请输入正确的频率计数器IP!"); return; } - else - { - if (Convert.ToInt32(ipEle) < 0 || Convert.ToInt32(ipEle) > 255) - { - MessageBox.Show("请输入正确的频率计数器IP!"); - return; - } - } } } - //} - //if (ips != null && ips.Length > 0) - //{ - // text_counterIp.Text = ips[0]; - //} - //else - //{ - // MessageBox.Show("请连接频率计数器!"); - // return; - //} - + } + text_devName.ReadOnly = true; btn_downCounterList.Enabled = false; btnStart.Enabled = false; btn_dropDetecModel.Enabled = false; textBox_detecModel.ReadOnly = true; - SetDevTestDlg.inDetecCounterId = deviceId; + //SetDevTestDlg.inDetecCounterId = deviceId; + string type = textBox_detecModel.Text.Equals("频率测量") ? "freq" : "period"; string typeId = type.Equals("freq") ? "1" : "2"; new Thread(() => { - // 获取数据 - List counterDetecInitList = counterDetecInitService.getAll(); - - CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); - - int gpibConnection=gPIBService.open(text_signal.Text); - int tcpConnection=tcpService.open("TCPIP0::"+text_counterIp.Text+"::INSTR"); - + int gpibConnection = gPIBService.open(text_signal.Text); if (gpibConnection == -1) { MessageBox.Show("未连接信号源"); changeBox(); return; } - else if (tcpConnection == -1) + + int tcpConnection = tcpService.open("TCPIP0::" + text_counterIp.Text + "::INSTR"); + if (tcpConnection == -1) { MessageBox.Show("未连接计数器"); changeBox(); return; } - //tcpService.open(text_counterIp.Text); + detecModelConf(); + + // 获取数据 + List counterDetecInitList = counterDetecInitService.getAll(); + + CounterCheckParam counterCheckParam = dictService.getCounterCheckParam(); + int index = 0; foreach (DataGridViewRow row in dataGridView_CounterResult.Rows) { @@ -651,7 +618,7 @@ int re = sensitivityService.beginTest(type, gPIBService, tcpService, counterCheckParam, ref sensitivityContentParam);//0:成功;-1:失败 string value = ""; if (re == 0) - { + { value = type.Equals("freq") ? sensitivityContentParam.ReFreq : sensitivityContentParam.RePeriod; } long dataId = counterDataService.add(deviceId, row.Cells[4].Value.ToString(), value, sensitivityContentParam.VolTage, sensitivityContentParam.CheckTime.ToString("yyyy-MM-dd HH:mm:ss"), typeId); @@ -659,14 +626,18 @@ row.Cells[5].Value = value; row.Cells[6].Value = sensitivityContentParam.VolTage; row.Cells[7].Value = sensitivityContentParam.CheckTime.ToString("yyyy-MM-dd HH:mm:ss"); - + + //dataGridView_CounterResult.Refresh(); index++; } - gPIBService.close(); - tcpService.close(); changeBox(); + + gPIBService.close(); + tcpService.close(); }).Start(); + + } private void changeBox() @@ -684,8 +655,7 @@ dataGridView_CounterResult.ReadOnly = false; btn_add.Enabled = true; benDelete.Enabled = true; - detected = true; - isDetecting = false; + //isDetecting = false; } private void dataGridView_CounterResult_CellEndEdit(object sender, DataGridViewCellEventArgs e) @@ -758,30 +728,17 @@ long initId = counterDetecInitService.addOrUpdate(freq, cycle); dataGridView_CounterResult.Rows[e.RowIndex].Cells[8].Value = initId; } + else if (e.ColumnIndex == 5) { if (!String.IsNullOrEmpty(value)) { string pattern = @"^[0-9.E]+$"; Regex regex = new Regex(pattern); - if (textBox_detecModel.Text.Equals("频率测量")) + if (!regex.IsMatch(value)) { - if (!checkFreq(value)) - { - dataGridView_CounterResult.CurrentCell.Value = ""; - MessageBox.Show("请输入格式正确的、带单位的测量频率!"); - return; - } - } - else - { - if (!checkCyc(value)) - { - dataGridView_CounterResult.CurrentCell.Value = ""; - MessageBox.Show("请输入格式正确的、带单位的测量周期!"); - return; - } - + MessageBox.Show("请输入格式正确的测量值!"); + return; } } } @@ -885,15 +842,18 @@ } } - private int isConnect(string id, string ip) + private void detecModelConf() { - int result = 0; - if (!gPIBService.isOpen()) - result = -1; - else if (!tcpService.isOpen()) - result = -2; - return result; + if (textBox_detecModel.Text == "频率测量") + { + GPIB_TCPIP_OPERATIO.setFreqModel(tcpService); + } + else if (textBox_detecModel.Text == "周期测量") + { + GPIB_TCPIP_OPERATIO.setPerModel(tcpService); + } + } } -} +} \ No newline at end of file diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index c827cf3..a33d35a 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -305,212 +305,229 @@ private void InitTableChannel() { - dataGridView_Channel.Columns.Clear(); - dataGridView_Channel.Rows.Clear(); - - // 添加标题栏 - Panel tableHeader = new Panel + try { - BackColor = Color.White, - Size = new Size(984, 30), - Location = new Point(0, 0) - }; - tableHeader.BackColor = titleBackColor; - dataGridView_Channel.Controls.Add(tableHeader); + lock (obj) + { + dataGridView_Channel.Columns.Clear(); + dataGridView_Channel.Rows.Clear(); - // 通道 - Label colChannelNo = new Label + // 添加标题栏 + Panel tableHeader = new Panel + { + BackColor = Color.White, + Size = new Size(984, 30), + Location = new Point(0, 0) + }; + tableHeader.BackColor = titleBackColor; + dataGridView_Channel.Controls.Add(tableHeader); + + // 通道 + Label colChannelNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "通道", + Location = new Point(0, 0), + Size = new Size(50, 30) + }; + dataGridView_Channel.Controls.Add(colChannelNo); + colChannelNo.BringToFront(); + + // 仪器名称 + Label colDevName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器名称", + Location = new Point(50, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevName); + colDevName.BringToFront(); + + // 仪器编号 + Label colDevNo = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "仪器编号", + Location = new Point(160, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colDevNo); + colDevNo.BringToFront(); + + // 客户名称 + Label colCustomName = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "送检单位", + Location = new Point(270, 0), + Size = new Size(110, 30) + }; + dataGridView_Channel.Controls.Add(colCustomName); + colCustomName.BringToFront(); + + // 开始时间 + Label colStartTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开始时间", + Location = new Point(380, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colStartTime); + colStartTime.BringToFront(); + + // 结束时间 + Label colEndTime = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "结束时间", + Location = new Point(500, 0), + Size = new Size(120, 30) + }; + dataGridView_Channel.Controls.Add(colEndTime); + colEndTime.BringToFront(); + + // 状态 + Label colStatus = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "状态", + Location = new Point(620, 0), + Size = new Size(64, 30) + }; + dataGridView_Channel.Controls.Add(colStatus); + colStatus.BringToFront(); + + // 频率稳定度 + Label colStablility = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "稳定度", + + Location = new Point(684, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStablility); + colStablility.BringToFront(); + + // 频率准确度 + Label colAccuracy = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "准确度", + Location = new Point(754, 0), + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colAccuracy); + colAccuracy.BringToFront(); + + // 开机特性 + Label colStartup = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "开机特性", + + Location = new Point(824, 0), + + Size = new Size(75, 30) + }; + dataGridView_Channel.Controls.Add(colStartup); + colStartup.BringToFront(); + + // 日老化率 + Label colAgingRate = new Label + { + Font = titleFont, + ForeColor = Color.White, + TextAlign = ContentAlignment.MiddleCenter, + BackColor = titleBackColor, + AutoSize = false, + Text = "日老化率", + Location = new Point(899, 0), + Size = new Size(75, 30) + }; + + + dataGridView_Channel.Controls.Add(colAgingRate); + colAgingRate.BringToFront(); + } + } + catch (Exception ex) { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "通道", - Location = new Point(0, 0), - Size = new Size(50, 30) - }; - dataGridView_Channel.Controls.Add(colChannelNo); - colChannelNo.BringToFront(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "InitTableChannel 错误:" + ex.Message); - // 仪器名称 - Label colDevName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器名称", - Location = new Point(50, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevName); - colDevName.BringToFront(); - - // 仪器编号 - Label colDevNo = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "仪器编号", - Location = new Point(160, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colDevNo); - colDevNo.BringToFront(); - - // 客户名称 - Label colCustomName = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "送检单位", - Location = new Point(270, 0), - Size = new Size(110, 30) - }; - dataGridView_Channel.Controls.Add(colCustomName); - colCustomName.BringToFront(); - - // 开始时间 - Label colStartTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开始时间", - Location = new Point(380, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colStartTime); - colStartTime.BringToFront(); - - // 结束时间 - Label colEndTime = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "结束时间", - Location = new Point(500, 0), - Size = new Size(120, 30) - }; - dataGridView_Channel.Controls.Add(colEndTime); - colEndTime.BringToFront(); - - // 状态 - Label colStatus = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "状态", - Location = new Point(620, 0), - Size = new Size(64, 30) - }; - dataGridView_Channel.Controls.Add(colStatus); - colStatus.BringToFront(); - - // 频率稳定度 - Label colStablility = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "稳定度", - - Location = new Point(684,0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStablility); - colStablility.BringToFront(); - - // 频率准确度 - Label colAccuracy = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "准确度", - Location = new Point(754, 0), - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colAccuracy); - colAccuracy.BringToFront(); - - // 开机特性 - Label colStartup = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "开机特性", - - Location = new Point(824, 0), - - Size = new Size(75, 30) - }; - dataGridView_Channel.Controls.Add(colStartup); - colStartup.BringToFront(); - - - - // 日老化率 - Label colAgingRate = new Label - { - Font = titleFont, - ForeColor = Color.White, - TextAlign = ContentAlignment.MiddleCenter, - BackColor = titleBackColor, - AutoSize = false, - Text = "日老化率", - Location = new Point(899, 0), - Size = new Size(75, 30) - }; - - - dataGridView_Channel.Controls.Add(colAgingRate); - colAgingRate.BringToFront(); + } } public void refreshChannelList() { - lock (obj) + try { - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - listChannelStatus = deviceService.getDeviceByChannel(); - if (listChannelStatus != null && listChannelStatus.Count > 0) + lock (obj) { - foreach (DeviceView device in listChannelStatus) + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + + listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + } } } } + catch (Exception ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "refreshChannelList 错误:" + ex.Message); + + } } public void LoadChannelStatus() { @@ -651,24 +668,39 @@ { lock (obj) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); + dataGridView_Channel.ClearSelection(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); int channelNo = e.RowIndex + 1; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); if (channelFreeList.Contains(channelNo + "")) { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); } else { + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); } foreach (string no in channelFreeList.ToArray()) { dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; } + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) @@ -735,26 +767,37 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; - long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; - string startTime = ""; - string endTime = ""; - if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) - { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } - if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) - { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + try + { + long deviceId = (long)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + long deviceItemId = (long)dataGridView_Channel.Rows[rowIndex].Cells[12].Value; + string startTime = ""; + string endTime = ""; + if (dataGridView_Channel.Rows[rowIndex].Cells[4].Value != null) + { startTime = dataGridView_Channel.Rows[rowIndex].Cells[4].Value.ToString(); } + if (dataGridView_Channel.Rows[rowIndex].Cells[5].Value != null) + { endTime = dataGridView_Channel.Rows[rowIndex].Cells[5].Value.ToString(); } + if (startTime.Equals("") && endTime.Equals("")) + { + return; + } + DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (dialogResult == DialogResult.Yes) + { - DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (dialogResult == DialogResult.Yes) - { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); + } + else + { + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + } + LoadChannelStatus(); + LoadDevToBeTested(); } - else + catch(Exception ex) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "cellDoubleClick 错误:" + ex.Message); } - LoadChannelStatus(); - LoadDevToBeTested(); return; } else diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index f99f106..8baed4b 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -47,6 +47,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); int channel = 0; + public Action HideMaskAction { @@ -66,9 +67,7 @@ SetStyle(ControlStyles.OptimizedDoubleBuffer, true); // 跨线程访问控件 - CheckForIllegalCrossThreadCalls = false; - - + CheckForIllegalCrossThreadCalls = false; } private void btnExitChannel_Click(object sender, EventArgs e) @@ -158,6 +157,10 @@ MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1] = port; + } } catch (Exception exc) { diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 1a82d85..26e8cab 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -30,6 +30,7 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); DeviceService deviceService = new DeviceServiceImpl(); + #region 无边框拖动效果/最小化窗口/关闭窗口 [DllImport("user32.dll")]//拖动无窗体的控件 public static extern bool ReleaseCapture(); @@ -66,6 +67,7 @@ // 跨线程访问控件 CheckForIllegalCrossThreadCalls = false; + } // 开始检测 @@ -117,6 +119,10 @@ MessageBox.Show("无法打开串口" + portName + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index ed117e0..71a0230 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -47,7 +47,6 @@ public long deviceId = -1; public static bool isInDetection = false; - public Action HideMaskAction { get; @@ -77,7 +76,8 @@ text_channelNo.WatermarkText = "无空闲通道"; groupBox1.Enabled = false; } - + + } // 关闭对话框 @@ -208,6 +208,10 @@ MessageBox.Show("无法打开通道" + text_channelNo.Text + ",添加检测失败!"); return; } + else + { + RbFreqStdMeas.portList[Convert.ToInt32(text_channelNo.Text) - 1] = port; + } } catch (Exception exc) { diff --git a/RbFreqStandMeasure/tools/DetectionHelper.cs b/RbFreqStandMeasure/tools/DetectionHelper.cs index 6796778..0858c34 100644 --- a/RbFreqStandMeasure/tools/DetectionHelper.cs +++ b/RbFreqStandMeasure/tools/DetectionHelper.cs @@ -114,7 +114,14 @@ lock(resultStability1) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "isStarted:" + isStarted + ", detectionItemId =" + detectionItemId); + DetectionItem item = detectionItemService.getById(detectionItemId); + if (Convert.ToDateTime(item.EndTime) < DateTime.Now) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,稳定度1s"); + timerStability1.Dispose(); + return; + } if (!isStarted) { while (true) @@ -141,68 +148,68 @@ } string result = ""; - string fre = getFrequencyData(portStability); - if (!fre.Equals("") && resultStability1.Count<101) + string fre = getFrequencyData(portStability); + if (!fre.Equals("") && resultStability1.Count<101) + { + resultStability1.Add(fre); + if (resultStability1.Count == 101) timerStability1.Dispose(); + if (!isUpdate && count1s < 101) { - resultStability1.Add(fre); - if (resultStability1.Count == 101) timerStability1.Dispose(); - if (!isUpdate && count1s < 101) - { - detectionService.add(devIdStability, fre, "1-1",detectionItemId); - count1s++; - } - } - if (!isUpdate) - { - if (resultStability1.Count == 101) - { - result = FreMath.Stable(resultStability1) + ""; - resultStability1.Clear(); - - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "1s稳定度结果:" + result + ", devId =" + devIdStability); - - // 更新检测结果 - detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", result, "", "", ""); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "detectionId :" + detectionItemId); - - DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); - if (detectionItem != null) - { - //更新稳定度检测状态 - if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) - { - detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); - - } - detectionItem = detectionItemService.searchById(detectionItemId); - //更新整个仪器检测状态 - if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) - { - deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); - } - HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); - } - - } + detectionService.add(devIdStability, fre, "1-1",detectionItemId); + count1s++; } - else - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测稳定度1s"); - if (resultStability1.Count == 101) - { - timerStability1.Dispose(); - - string result1 = FreMath.Stable(resultStability1) + ""; - detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", result1, "", "", ""); - - updateView(resultStability1); - stability.label_result.Text = result1; - DetailDlg.detailDlg.resultStaStr1 = result1; + } + if (!isUpdate) + { + if (resultStability1.Count == 101) + { + result = FreMath.Stable(resultStability1) + ""; resultStability1.Clear(); + + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "1s稳定度结果:" + result + ", devId =" + devIdStability); + + // 更新检测结果 + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", result, "", "", ""); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "detectionId :" + detectionItemId); + + DetectionItem detectionItem = detectionItemService.searchById(detectionItemId); + if (detectionItem != null) + { + //更新稳定度检测状态 + if (!detectionItem.Stability1.Equals("-1") && !detectionItem.Stability10.Equals("-1") && !detectionItem.Stability20.Equals("-1") && !detectionItem.Stability100.Equals("-1")) + { + detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + + } + detectionItem = detectionItemService.searchById(detectionItemId); + //更新整个仪器检测状态 + if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) + { + deviceService.updateStatus(devIdStability, "3", ""); + portStability.Close(); + } + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + } + } - } - } + } + else + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测稳定度1s"); + if (resultStability1.Count == 101) + { + timerStability1.Dispose(); + + string result1 = FreMath.Stable(resultStability1) + ""; + detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", result1, "", "", ""); + + updateView(resultStability1); + stability.label_result.Text = result1; + DetailDlg.detailDlg.resultStaStr1 = result1; + resultStability1.Clear(); + } + } + } } } @@ -219,6 +226,14 @@ { lock (obj) { + DetectionItem item = detectionItemService.getById(detectionItemId); + if (Convert.ToDateTime(item.EndTime) < DateTime.Now) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,稳定度10s"); + + timerStability10.Dispose(); + return; + } if (!isStarted) { while (true) @@ -312,6 +327,14 @@ { lock (obj) { + DetectionItem item = detectionItemService.getById(detectionItemId); + if (Convert.ToDateTime(item.EndTime) < DateTime.Now) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,稳定度20s"); + + timerStability20.Dispose(); + return; + } if (!isStarted) { while (true) @@ -410,6 +433,14 @@ { lock (obj) { + DetectionItem item = detectionItemService.getById(detectionItemId); + if (Convert.ToDateTime(item.EndTime) < DateTime.Now) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,稳定度100s"); + + timerStability100.Dispose(); + return; + } if (!isStarted) { while (true) @@ -519,13 +550,19 @@ timerAccuracy = new System.Threading.Timer(exeAccuracy, null, delay + 200 ,5*60*1000); } private void exeAccuracy(Object State) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "哈哈哈哈,检测准确度了!!!!!!!"+DateTime.Now.ToLongTimeString()); - + { try { lock (obj) { + DetectionItem item = detectionItemService.getById(detectionItemId); + if (Convert.ToDateTime(item.EndTime) < DateTime.Now) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,准确度"); + + timerAccuracy.Dispose(); + return; + } if (!isStarted) { while (true) @@ -638,7 +675,14 @@ lock (obj) { LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "isStarted:"+ isStarted); + DetectionItem item = detectionItemService.getById(detectionItemId); + if (Convert.ToDateTime(item.EndTime) < DateTime.Now) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,开机特性"); + timerBootFeature.Dispose(); + return; + } if (!isStarted) { while (true) @@ -736,6 +780,14 @@ { lock (obj) { + DetectionItem item = detectionItemService.getById(detectionItemId); + if (Convert.ToDateTime(item.EndTime) < DateTime.Now) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,日老化率"); + + timerAgeRate.Dispose(); + return; + } if (!isStarted) { while (true)