diff --git a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs index ec02ee3..ba3c1cf 100644 --- a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs +++ b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs @@ -51,6 +51,7 @@ private String accuracy; private String bootFeature; private String ageRate; + private long detectionItemId; public long Id { @@ -251,5 +252,6 @@ public string Accuracy { get => accuracy; set => accuracy = value; } public string BootFeature { get => bootFeature; set => bootFeature = value; } public string AgeRate { get => ageRate; set => ageRate = value; } + public long DetectionItemId { get => detectionItemId; set => detectionItemId = value; } } } diff --git a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs index ec02ee3..ba3c1cf 100644 --- a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs +++ b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs @@ -51,6 +51,7 @@ private String accuracy; private String bootFeature; private String ageRate; + private long detectionItemId; public long Id { @@ -251,5 +252,6 @@ public string Accuracy { get => accuracy; set => accuracy = value; } public string BootFeature { get => bootFeature; set => bootFeature = value; } public string AgeRate { get => ageRate; set => ageRate = value; } + public long DetectionItemId { get => detectionItemId; set => detectionItemId = value; } } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 3fe0773..64253a7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -16,7 +16,7 @@ List search(long deviceId, bool isInDetection); - int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData); + int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); 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/Dto/DeviceView.cs b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs index ec02ee3..ba3c1cf 100644 --- a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs +++ b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs @@ -51,6 +51,7 @@ private String accuracy; private String bootFeature; private String ageRate; + private long detectionItemId; public long Id { @@ -251,5 +252,6 @@ public string Accuracy { get => accuracy; set => accuracy = value; } public string BootFeature { get => bootFeature; set => bootFeature = value; } public string AgeRate { get => ageRate; set => ageRate = value; } + public long DetectionItemId { get => detectionItemId; set => detectionItemId = value; } } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 3fe0773..64253a7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -16,7 +16,7 @@ List search(long deviceId, bool isInDetection); - int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData); + int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); 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 5c4cda2..b849d77 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -115,6 +115,56 @@ } return iRetval; } + public int startDetect(long detectionItemId, string stability, string accuracy, string bootFeature, string ageRate) + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + if (stability.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + + string sQry = "UPDATE r_detection_item SET"; + if (!stability.Equals("")) + sQry = sQry + " STABILITY=@STABILITY"; + if (!accuracy.Equals("")) + sQry = sQry + " ACCURACY=@ACCURACY"; + if (!bootFeature.Equals("")) + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + if (!ageRate.Equals("")) + sQry = sQry + " AGE_RATE=@AGE_RATE"; + sQry = sQry + " where ID = " + detectionItemId; + + + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; + cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; + cmd.Parameters.Add("@BOOT_FEATURE", MySqlDbType.String, 10).Value = bootFeature; + cmd.Parameters.Add("@AGE_RATE", MySqlDbType.String, 10).Value = ageRate; + + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + iRetval = 0; + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + iRetval = -1; + } + + return iRetval; + } public int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100) { @@ -134,28 +184,28 @@ } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stability : "+ stability); string sQry = "UPDATE r_detection_item SET"; if(!stability.Equals("")) - sQry = sQry + " STABILITY=@STABILITY"; + sQry = sQry + " STABILITY=@STABILITY,"; if (!accuracy.Equals("")) - sQry = sQry + " ACCURACY=@ACCURACY"; + sQry = sQry + " ACCURACY=@ACCURACY,"; if (!bootFeature.Equals("")) - sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE,"; if (!ageRate.Equals("")) - sQry = sQry + " AGE_RATE=@AGE_RATE"; - if (!counterDetec.Equals("")) - sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC"; + sQry = sQry + " AGE_RATE=@AGE_RATE,"; if (!stability1.Equals("")) - sQry = sQry + " STABILITY_1=@STABILITY_1"; + sQry = sQry + " STABILITY_1=@STABILITY_1,"; if (!stability10.Equals("")) - sQry = sQry + " STABILITY_10=@STABILITY_10"; + sQry = sQry + " STABILITY_10=@STABILITY_10,"; if (!stability20.Equals("")) - sQry = sQry + " STABILITY_20=@STABILITY_20"; + sQry = sQry + " STABILITY_20=@STABILITY_20,"; if (!stability100.Equals("")) - sQry = sQry + " STABILITY_100=@STABILITY_100"; - sQry = sQry + " where ID = " + detectionId; + sQry = sQry + " STABILITY_100=@STABILITY_100,"; + sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; @@ -220,7 +270,7 @@ return iRetval; } - public int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData) + public int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData) { int iRetval = -1; try @@ -241,17 +291,25 @@ cmd.Parameters.Add("@CHANNEL", MySqlDbType.String, 20).Value = ""; cmd.ExecuteNonQuery(); + if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime + "' and '" + endTime + "')"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } + else + { + sQry = "UPDATE r_detection_item SET END_TIME=@END_TIME WHERE ID="+ detectionItemId; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@END_TIME", MySqlDbType.DateTime, 20).Value = DateTime.Now; + cmd.ExecuteNonQuery(); + } cmd.Dispose(); iRetval = 0; diff --git a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs index ec02ee3..ba3c1cf 100644 --- a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs +++ b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs @@ -51,6 +51,7 @@ private String accuracy; private String bootFeature; private String ageRate; + private long detectionItemId; public long Id { @@ -251,5 +252,6 @@ public string Accuracy { get => accuracy; set => accuracy = value; } public string BootFeature { get => bootFeature; set => bootFeature = value; } public string AgeRate { get => ageRate; set => ageRate = value; } + public long DetectionItemId { get => detectionItemId; set => detectionItemId = value; } } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 3fe0773..64253a7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -16,7 +16,7 @@ List search(long deviceId, bool isInDetection); - int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData); + int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); 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 5c4cda2..b849d77 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -115,6 +115,56 @@ } return iRetval; } + public int startDetect(long detectionItemId, string stability, string accuracy, string bootFeature, string ageRate) + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + if (stability.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + + string sQry = "UPDATE r_detection_item SET"; + if (!stability.Equals("")) + sQry = sQry + " STABILITY=@STABILITY"; + if (!accuracy.Equals("")) + sQry = sQry + " ACCURACY=@ACCURACY"; + if (!bootFeature.Equals("")) + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + if (!ageRate.Equals("")) + sQry = sQry + " AGE_RATE=@AGE_RATE"; + sQry = sQry + " where ID = " + detectionItemId; + + + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; + cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; + cmd.Parameters.Add("@BOOT_FEATURE", MySqlDbType.String, 10).Value = bootFeature; + cmd.Parameters.Add("@AGE_RATE", MySqlDbType.String, 10).Value = ageRate; + + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + iRetval = 0; + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + iRetval = -1; + } + + return iRetval; + } public int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100) { @@ -134,28 +184,28 @@ } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stability : "+ stability); string sQry = "UPDATE r_detection_item SET"; if(!stability.Equals("")) - sQry = sQry + " STABILITY=@STABILITY"; + sQry = sQry + " STABILITY=@STABILITY,"; if (!accuracy.Equals("")) - sQry = sQry + " ACCURACY=@ACCURACY"; + sQry = sQry + " ACCURACY=@ACCURACY,"; if (!bootFeature.Equals("")) - sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE,"; if (!ageRate.Equals("")) - sQry = sQry + " AGE_RATE=@AGE_RATE"; - if (!counterDetec.Equals("")) - sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC"; + sQry = sQry + " AGE_RATE=@AGE_RATE,"; if (!stability1.Equals("")) - sQry = sQry + " STABILITY_1=@STABILITY_1"; + sQry = sQry + " STABILITY_1=@STABILITY_1,"; if (!stability10.Equals("")) - sQry = sQry + " STABILITY_10=@STABILITY_10"; + sQry = sQry + " STABILITY_10=@STABILITY_10,"; if (!stability20.Equals("")) - sQry = sQry + " STABILITY_20=@STABILITY_20"; + sQry = sQry + " STABILITY_20=@STABILITY_20,"; if (!stability100.Equals("")) - sQry = sQry + " STABILITY_100=@STABILITY_100"; - sQry = sQry + " where ID = " + detectionId; + sQry = sQry + " STABILITY_100=@STABILITY_100,"; + sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; @@ -220,7 +270,7 @@ return iRetval; } - public int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData) + public int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData) { int iRetval = -1; try @@ -241,17 +291,25 @@ cmd.Parameters.Add("@CHANNEL", MySqlDbType.String, 20).Value = ""; cmd.ExecuteNonQuery(); + if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime + "' and '" + endTime + "')"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } + else + { + sQry = "UPDATE r_detection_item SET END_TIME=@END_TIME WHERE ID="+ detectionItemId; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@END_TIME", MySqlDbType.DateTime, 20).Value = DateTime.Now; + cmd.ExecuteNonQuery(); + } cmd.Dispose(); iRetval = 0; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 8773cb6..2de0df9 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -87,7 +87,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry + "; statusId="+ statusId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -101,9 +101,6 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); - - iRetval = 0; } catch (MySqlException ex) @@ -205,7 +202,7 @@ if (!aReader.IsDBNull(7)) deviceDto.CustomerDev = aReader.GetString(7); if (!aReader.IsDBNull(8)) { - deviceDto.StatusId = aReader.GetString(7); + deviceDto.StatusId = aReader.GetString(8); } if (!aReader.IsDBNull(9)) deviceDto.Channel = aReader.GetString(9); @@ -481,7 +478,7 @@ } } - string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 "; + string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -523,7 +520,7 @@ if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - + if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); deviceViewList.Add(deviceView); diff --git a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs index ec02ee3..ba3c1cf 100644 --- a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs +++ b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs @@ -51,6 +51,7 @@ private String accuracy; private String bootFeature; private String ageRate; + private long detectionItemId; public long Id { @@ -251,5 +252,6 @@ public string Accuracy { get => accuracy; set => accuracy = value; } public string BootFeature { get => bootFeature; set => bootFeature = value; } public string AgeRate { get => ageRate; set => ageRate = value; } + public long DetectionItemId { get => detectionItemId; set => detectionItemId = value; } } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 3fe0773..64253a7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -16,7 +16,7 @@ List search(long deviceId, bool isInDetection); - int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData); + int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); 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 5c4cda2..b849d77 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -115,6 +115,56 @@ } return iRetval; } + public int startDetect(long detectionItemId, string stability, string accuracy, string bootFeature, string ageRate) + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + if (stability.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + + string sQry = "UPDATE r_detection_item SET"; + if (!stability.Equals("")) + sQry = sQry + " STABILITY=@STABILITY"; + if (!accuracy.Equals("")) + sQry = sQry + " ACCURACY=@ACCURACY"; + if (!bootFeature.Equals("")) + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + if (!ageRate.Equals("")) + sQry = sQry + " AGE_RATE=@AGE_RATE"; + sQry = sQry + " where ID = " + detectionItemId; + + + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; + cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; + cmd.Parameters.Add("@BOOT_FEATURE", MySqlDbType.String, 10).Value = bootFeature; + cmd.Parameters.Add("@AGE_RATE", MySqlDbType.String, 10).Value = ageRate; + + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + iRetval = 0; + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + iRetval = -1; + } + + return iRetval; + } public int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100) { @@ -134,28 +184,28 @@ } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stability : "+ stability); string sQry = "UPDATE r_detection_item SET"; if(!stability.Equals("")) - sQry = sQry + " STABILITY=@STABILITY"; + sQry = sQry + " STABILITY=@STABILITY,"; if (!accuracy.Equals("")) - sQry = sQry + " ACCURACY=@ACCURACY"; + sQry = sQry + " ACCURACY=@ACCURACY,"; if (!bootFeature.Equals("")) - sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE,"; if (!ageRate.Equals("")) - sQry = sQry + " AGE_RATE=@AGE_RATE"; - if (!counterDetec.Equals("")) - sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC"; + sQry = sQry + " AGE_RATE=@AGE_RATE,"; if (!stability1.Equals("")) - sQry = sQry + " STABILITY_1=@STABILITY_1"; + sQry = sQry + " STABILITY_1=@STABILITY_1,"; if (!stability10.Equals("")) - sQry = sQry + " STABILITY_10=@STABILITY_10"; + sQry = sQry + " STABILITY_10=@STABILITY_10,"; if (!stability20.Equals("")) - sQry = sQry + " STABILITY_20=@STABILITY_20"; + sQry = sQry + " STABILITY_20=@STABILITY_20,"; if (!stability100.Equals("")) - sQry = sQry + " STABILITY_100=@STABILITY_100"; - sQry = sQry + " where ID = " + detectionId; + sQry = sQry + " STABILITY_100=@STABILITY_100,"; + sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; @@ -220,7 +270,7 @@ return iRetval; } - public int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData) + public int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData) { int iRetval = -1; try @@ -241,17 +291,25 @@ cmd.Parameters.Add("@CHANNEL", MySqlDbType.String, 20).Value = ""; cmd.ExecuteNonQuery(); + if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime + "' and '" + endTime + "')"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } + else + { + sQry = "UPDATE r_detection_item SET END_TIME=@END_TIME WHERE ID="+ detectionItemId; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@END_TIME", MySqlDbType.DateTime, 20).Value = DateTime.Now; + cmd.ExecuteNonQuery(); + } cmd.Dispose(); iRetval = 0; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 8773cb6..2de0df9 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -87,7 +87,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry + "; statusId="+ statusId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -101,9 +101,6 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); - - iRetval = 0; } catch (MySqlException ex) @@ -205,7 +202,7 @@ if (!aReader.IsDBNull(7)) deviceDto.CustomerDev = aReader.GetString(7); if (!aReader.IsDBNull(8)) { - deviceDto.StatusId = aReader.GetString(7); + deviceDto.StatusId = aReader.GetString(8); } if (!aReader.IsDBNull(9)) deviceDto.Channel = aReader.GetString(9); @@ -481,7 +478,7 @@ } } - string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 "; + string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -523,7 +520,7 @@ if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - + if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); deviceViewList.Add(deviceView); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index ff6a679..1626aa5 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -27,7 +27,7 @@ } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); diff --git a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs index ec02ee3..ba3c1cf 100644 --- a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs +++ b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs @@ -51,6 +51,7 @@ private String accuracy; private String bootFeature; private String ageRate; + private long detectionItemId; public long Id { @@ -251,5 +252,6 @@ public string Accuracy { get => accuracy; set => accuracy = value; } public string BootFeature { get => bootFeature; set => bootFeature = value; } public string AgeRate { get => ageRate; set => ageRate = value; } + public long DetectionItemId { get => detectionItemId; set => detectionItemId = value; } } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 3fe0773..64253a7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -16,7 +16,7 @@ List search(long deviceId, bool isInDetection); - int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData); + int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); 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 5c4cda2..b849d77 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -115,6 +115,56 @@ } return iRetval; } + public int startDetect(long detectionItemId, string stability, string accuracy, string bootFeature, string ageRate) + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + if (stability.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + + string sQry = "UPDATE r_detection_item SET"; + if (!stability.Equals("")) + sQry = sQry + " STABILITY=@STABILITY"; + if (!accuracy.Equals("")) + sQry = sQry + " ACCURACY=@ACCURACY"; + if (!bootFeature.Equals("")) + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + if (!ageRate.Equals("")) + sQry = sQry + " AGE_RATE=@AGE_RATE"; + sQry = sQry + " where ID = " + detectionItemId; + + + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; + cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; + cmd.Parameters.Add("@BOOT_FEATURE", MySqlDbType.String, 10).Value = bootFeature; + cmd.Parameters.Add("@AGE_RATE", MySqlDbType.String, 10).Value = ageRate; + + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + iRetval = 0; + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + iRetval = -1; + } + + return iRetval; + } public int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100) { @@ -134,28 +184,28 @@ } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stability : "+ stability); string sQry = "UPDATE r_detection_item SET"; if(!stability.Equals("")) - sQry = sQry + " STABILITY=@STABILITY"; + sQry = sQry + " STABILITY=@STABILITY,"; if (!accuracy.Equals("")) - sQry = sQry + " ACCURACY=@ACCURACY"; + sQry = sQry + " ACCURACY=@ACCURACY,"; if (!bootFeature.Equals("")) - sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE,"; if (!ageRate.Equals("")) - sQry = sQry + " AGE_RATE=@AGE_RATE"; - if (!counterDetec.Equals("")) - sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC"; + sQry = sQry + " AGE_RATE=@AGE_RATE,"; if (!stability1.Equals("")) - sQry = sQry + " STABILITY_1=@STABILITY_1"; + sQry = sQry + " STABILITY_1=@STABILITY_1,"; if (!stability10.Equals("")) - sQry = sQry + " STABILITY_10=@STABILITY_10"; + sQry = sQry + " STABILITY_10=@STABILITY_10,"; if (!stability20.Equals("")) - sQry = sQry + " STABILITY_20=@STABILITY_20"; + sQry = sQry + " STABILITY_20=@STABILITY_20,"; if (!stability100.Equals("")) - sQry = sQry + " STABILITY_100=@STABILITY_100"; - sQry = sQry + " where ID = " + detectionId; + sQry = sQry + " STABILITY_100=@STABILITY_100,"; + sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; @@ -220,7 +270,7 @@ return iRetval; } - public int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData) + public int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData) { int iRetval = -1; try @@ -241,17 +291,25 @@ cmd.Parameters.Add("@CHANNEL", MySqlDbType.String, 20).Value = ""; cmd.ExecuteNonQuery(); + if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime + "' and '" + endTime + "')"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } + else + { + sQry = "UPDATE r_detection_item SET END_TIME=@END_TIME WHERE ID="+ detectionItemId; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@END_TIME", MySqlDbType.DateTime, 20).Value = DateTime.Now; + cmd.ExecuteNonQuery(); + } cmd.Dispose(); iRetval = 0; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 8773cb6..2de0df9 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -87,7 +87,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry + "; statusId="+ statusId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -101,9 +101,6 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); - - iRetval = 0; } catch (MySqlException ex) @@ -205,7 +202,7 @@ if (!aReader.IsDBNull(7)) deviceDto.CustomerDev = aReader.GetString(7); if (!aReader.IsDBNull(8)) { - deviceDto.StatusId = aReader.GetString(7); + deviceDto.StatusId = aReader.GetString(8); } if (!aReader.IsDBNull(9)) deviceDto.Channel = aReader.GetString(9); @@ -481,7 +478,7 @@ } } - string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 "; + string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -523,7 +520,7 @@ if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - + if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); deviceViewList.Add(deviceView); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index ff6a679..1626aa5 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -27,7 +27,7 @@ } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index e1b99b2..936cc37 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -224,7 +224,19 @@ } private void SelectCounter() { - + // 移除所有按钮的选中样式 + ClearAllMenuSelected(); + + // 鼠标移入效果去掉 + LeaveCounter(); + + // 重新设置所有按钮的状态 + menuSelected = new bool[] { false, false, false, true, false, false }; + + // 将新选中的按钮设置为选中 + picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + labCounterText.ForeColor = menuSelectedColor; + labCounterSelected.BackColor = menuSelectedColor; // 切换到频率计数器的界面 switchMainPanel(3); @@ -242,10 +254,16 @@ } private void SelectData() { + //if (CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // return; + //} // 移除所有按钮的选中样式 ClearAllMenuSelected(); // 鼠标移入效果去掉 + LeaveData(); // 重新设置所有按钮的状态 @@ -331,6 +349,19 @@ portList.Add(new SerialPort()); portList.Add(new SerialPort()); portList.Add(new SerialPort()); + DeviceService deviceService = new DeviceServiceImpl(); + DetectionItemService detectionItemService = new DetectionItemServiceImpl(); + List listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + long deviceId = device.Id; + string startTime = device.StartTime; + string endTime = device.EndTime; + detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); + } + } } else { @@ -500,24 +531,24 @@ private void switchMainPanel(int index) { - if (index != 3 && CounterCtrlForm.isDetecting) - { - MessageBox.Show("正在检测计数器,无法离开当前界面!"); - // 移除所有按钮的选中样式 - ClearAllMenuSelected(); + //if (index != 3 && CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // // 移除所有按钮的选中样式 + // ClearAllMenuSelected(); - // 鼠标移入效果去掉 - LeaveCounter(); + // // 鼠标移入效果去掉 + // LeaveCounter(); - // 重新设置所有按钮的状态 - menuSelected = new bool[] { false, false, false, true, false, false }; + // // 重新设置所有按钮的状态 + // menuSelected = new bool[] { false, false, false, true, false, false }; - // 将新选中的按钮设置为选中 - picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); - labCounterText.ForeColor = menuSelectedColor; - labCounterSelected.BackColor = menuSelectedColor; - return; - } + // // 将新选中的按钮设置为选中 + // picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + // labCounterText.ForeColor = menuSelectedColor; + // labCounterSelected.BackColor = menuSelectedColor; + // return; + //} panelMain.Controls.Clear(); switch (index) { diff --git a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs index ec02ee3..ba3c1cf 100644 --- a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs +++ b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs @@ -51,6 +51,7 @@ private String accuracy; private String bootFeature; private String ageRate; + private long detectionItemId; public long Id { @@ -251,5 +252,6 @@ public string Accuracy { get => accuracy; set => accuracy = value; } public string BootFeature { get => bootFeature; set => bootFeature = value; } public string AgeRate { get => ageRate; set => ageRate = value; } + public long DetectionItemId { get => detectionItemId; set => detectionItemId = value; } } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 3fe0773..64253a7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -16,7 +16,7 @@ List search(long deviceId, bool isInDetection); - int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData); + int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); 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 5c4cda2..b849d77 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -115,6 +115,56 @@ } return iRetval; } + public int startDetect(long detectionItemId, string stability, string accuracy, string bootFeature, string ageRate) + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + if (stability.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + + string sQry = "UPDATE r_detection_item SET"; + if (!stability.Equals("")) + sQry = sQry + " STABILITY=@STABILITY"; + if (!accuracy.Equals("")) + sQry = sQry + " ACCURACY=@ACCURACY"; + if (!bootFeature.Equals("")) + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + if (!ageRate.Equals("")) + sQry = sQry + " AGE_RATE=@AGE_RATE"; + sQry = sQry + " where ID = " + detectionItemId; + + + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; + cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; + cmd.Parameters.Add("@BOOT_FEATURE", MySqlDbType.String, 10).Value = bootFeature; + cmd.Parameters.Add("@AGE_RATE", MySqlDbType.String, 10).Value = ageRate; + + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + iRetval = 0; + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + iRetval = -1; + } + + return iRetval; + } public int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100) { @@ -134,28 +184,28 @@ } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stability : "+ stability); string sQry = "UPDATE r_detection_item SET"; if(!stability.Equals("")) - sQry = sQry + " STABILITY=@STABILITY"; + sQry = sQry + " STABILITY=@STABILITY,"; if (!accuracy.Equals("")) - sQry = sQry + " ACCURACY=@ACCURACY"; + sQry = sQry + " ACCURACY=@ACCURACY,"; if (!bootFeature.Equals("")) - sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE,"; if (!ageRate.Equals("")) - sQry = sQry + " AGE_RATE=@AGE_RATE"; - if (!counterDetec.Equals("")) - sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC"; + sQry = sQry + " AGE_RATE=@AGE_RATE,"; if (!stability1.Equals("")) - sQry = sQry + " STABILITY_1=@STABILITY_1"; + sQry = sQry + " STABILITY_1=@STABILITY_1,"; if (!stability10.Equals("")) - sQry = sQry + " STABILITY_10=@STABILITY_10"; + sQry = sQry + " STABILITY_10=@STABILITY_10,"; if (!stability20.Equals("")) - sQry = sQry + " STABILITY_20=@STABILITY_20"; + sQry = sQry + " STABILITY_20=@STABILITY_20,"; if (!stability100.Equals("")) - sQry = sQry + " STABILITY_100=@STABILITY_100"; - sQry = sQry + " where ID = " + detectionId; + sQry = sQry + " STABILITY_100=@STABILITY_100,"; + sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; @@ -220,7 +270,7 @@ return iRetval; } - public int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData) + public int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData) { int iRetval = -1; try @@ -241,17 +291,25 @@ cmd.Parameters.Add("@CHANNEL", MySqlDbType.String, 20).Value = ""; cmd.ExecuteNonQuery(); + if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime + "' and '" + endTime + "')"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } + else + { + sQry = "UPDATE r_detection_item SET END_TIME=@END_TIME WHERE ID="+ detectionItemId; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@END_TIME", MySqlDbType.DateTime, 20).Value = DateTime.Now; + cmd.ExecuteNonQuery(); + } cmd.Dispose(); iRetval = 0; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 8773cb6..2de0df9 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -87,7 +87,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry + "; statusId="+ statusId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -101,9 +101,6 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); - - iRetval = 0; } catch (MySqlException ex) @@ -205,7 +202,7 @@ if (!aReader.IsDBNull(7)) deviceDto.CustomerDev = aReader.GetString(7); if (!aReader.IsDBNull(8)) { - deviceDto.StatusId = aReader.GetString(7); + deviceDto.StatusId = aReader.GetString(8); } if (!aReader.IsDBNull(9)) deviceDto.Channel = aReader.GetString(9); @@ -481,7 +478,7 @@ } } - string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 "; + string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -523,7 +520,7 @@ if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - + if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); deviceViewList.Add(deviceView); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index ff6a679..1626aa5 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -27,7 +27,7 @@ } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index e1b99b2..936cc37 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -224,7 +224,19 @@ } private void SelectCounter() { - + // 移除所有按钮的选中样式 + ClearAllMenuSelected(); + + // 鼠标移入效果去掉 + LeaveCounter(); + + // 重新设置所有按钮的状态 + menuSelected = new bool[] { false, false, false, true, false, false }; + + // 将新选中的按钮设置为选中 + picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + labCounterText.ForeColor = menuSelectedColor; + labCounterSelected.BackColor = menuSelectedColor; // 切换到频率计数器的界面 switchMainPanel(3); @@ -242,10 +254,16 @@ } private void SelectData() { + //if (CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // return; + //} // 移除所有按钮的选中样式 ClearAllMenuSelected(); // 鼠标移入效果去掉 + LeaveData(); // 重新设置所有按钮的状态 @@ -331,6 +349,19 @@ portList.Add(new SerialPort()); portList.Add(new SerialPort()); portList.Add(new SerialPort()); + DeviceService deviceService = new DeviceServiceImpl(); + DetectionItemService detectionItemService = new DetectionItemServiceImpl(); + List listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + long deviceId = device.Id; + string startTime = device.StartTime; + string endTime = device.EndTime; + detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); + } + } } else { @@ -500,24 +531,24 @@ private void switchMainPanel(int index) { - if (index != 3 && CounterCtrlForm.isDetecting) - { - MessageBox.Show("正在检测计数器,无法离开当前界面!"); - // 移除所有按钮的选中样式 - ClearAllMenuSelected(); + //if (index != 3 && CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // // 移除所有按钮的选中样式 + // ClearAllMenuSelected(); - // 鼠标移入效果去掉 - LeaveCounter(); + // // 鼠标移入效果去掉 + // LeaveCounter(); - // 重新设置所有按钮的状态 - menuSelected = new bool[] { false, false, false, true, false, false }; + // // 重新设置所有按钮的状态 + // menuSelected = new bool[] { false, false, false, true, false, false }; - // 将新选中的按钮设置为选中 - picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); - labCounterText.ForeColor = menuSelectedColor; - labCounterSelected.BackColor = menuSelectedColor; - return; - } + // // 将新选中的按钮设置为选中 + // picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + // labCounterText.ForeColor = menuSelectedColor; + // labCounterSelected.BackColor = menuSelectedColor; + // return; + //} panelMain.Controls.Clear(); switch (index) { diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index ecbb7e2..4405d66 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs index ec02ee3..ba3c1cf 100644 --- a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs +++ b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs @@ -51,6 +51,7 @@ private String accuracy; private String bootFeature; private String ageRate; + private long detectionItemId; public long Id { @@ -251,5 +252,6 @@ public string Accuracy { get => accuracy; set => accuracy = value; } public string BootFeature { get => bootFeature; set => bootFeature = value; } public string AgeRate { get => ageRate; set => ageRate = value; } + public long DetectionItemId { get => detectionItemId; set => detectionItemId = value; } } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 3fe0773..64253a7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -16,7 +16,7 @@ List search(long deviceId, bool isInDetection); - int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData); + int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); 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 5c4cda2..b849d77 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -115,6 +115,56 @@ } return iRetval; } + public int startDetect(long detectionItemId, string stability, string accuracy, string bootFeature, string ageRate) + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + if (stability.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + + string sQry = "UPDATE r_detection_item SET"; + if (!stability.Equals("")) + sQry = sQry + " STABILITY=@STABILITY"; + if (!accuracy.Equals("")) + sQry = sQry + " ACCURACY=@ACCURACY"; + if (!bootFeature.Equals("")) + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + if (!ageRate.Equals("")) + sQry = sQry + " AGE_RATE=@AGE_RATE"; + sQry = sQry + " where ID = " + detectionItemId; + + + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; + cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; + cmd.Parameters.Add("@BOOT_FEATURE", MySqlDbType.String, 10).Value = bootFeature; + cmd.Parameters.Add("@AGE_RATE", MySqlDbType.String, 10).Value = ageRate; + + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + iRetval = 0; + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + iRetval = -1; + } + + return iRetval; + } public int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100) { @@ -134,28 +184,28 @@ } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stability : "+ stability); string sQry = "UPDATE r_detection_item SET"; if(!stability.Equals("")) - sQry = sQry + " STABILITY=@STABILITY"; + sQry = sQry + " STABILITY=@STABILITY,"; if (!accuracy.Equals("")) - sQry = sQry + " ACCURACY=@ACCURACY"; + sQry = sQry + " ACCURACY=@ACCURACY,"; if (!bootFeature.Equals("")) - sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE,"; if (!ageRate.Equals("")) - sQry = sQry + " AGE_RATE=@AGE_RATE"; - if (!counterDetec.Equals("")) - sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC"; + sQry = sQry + " AGE_RATE=@AGE_RATE,"; if (!stability1.Equals("")) - sQry = sQry + " STABILITY_1=@STABILITY_1"; + sQry = sQry + " STABILITY_1=@STABILITY_1,"; if (!stability10.Equals("")) - sQry = sQry + " STABILITY_10=@STABILITY_10"; + sQry = sQry + " STABILITY_10=@STABILITY_10,"; if (!stability20.Equals("")) - sQry = sQry + " STABILITY_20=@STABILITY_20"; + sQry = sQry + " STABILITY_20=@STABILITY_20,"; if (!stability100.Equals("")) - sQry = sQry + " STABILITY_100=@STABILITY_100"; - sQry = sQry + " where ID = " + detectionId; + sQry = sQry + " STABILITY_100=@STABILITY_100,"; + sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; @@ -220,7 +270,7 @@ return iRetval; } - public int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData) + public int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData) { int iRetval = -1; try @@ -241,17 +291,25 @@ cmd.Parameters.Add("@CHANNEL", MySqlDbType.String, 20).Value = ""; cmd.ExecuteNonQuery(); + if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime + "' and '" + endTime + "')"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } + else + { + sQry = "UPDATE r_detection_item SET END_TIME=@END_TIME WHERE ID="+ detectionItemId; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@END_TIME", MySqlDbType.DateTime, 20).Value = DateTime.Now; + cmd.ExecuteNonQuery(); + } cmd.Dispose(); iRetval = 0; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 8773cb6..2de0df9 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -87,7 +87,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry + "; statusId="+ statusId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -101,9 +101,6 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); - - iRetval = 0; } catch (MySqlException ex) @@ -205,7 +202,7 @@ if (!aReader.IsDBNull(7)) deviceDto.CustomerDev = aReader.GetString(7); if (!aReader.IsDBNull(8)) { - deviceDto.StatusId = aReader.GetString(7); + deviceDto.StatusId = aReader.GetString(8); } if (!aReader.IsDBNull(9)) deviceDto.Channel = aReader.GetString(9); @@ -481,7 +478,7 @@ } } - string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 "; + string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -523,7 +520,7 @@ if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - + if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); deviceViewList.Add(deviceView); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index ff6a679..1626aa5 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -27,7 +27,7 @@ } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index e1b99b2..936cc37 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -224,7 +224,19 @@ } private void SelectCounter() { - + // 移除所有按钮的选中样式 + ClearAllMenuSelected(); + + // 鼠标移入效果去掉 + LeaveCounter(); + + // 重新设置所有按钮的状态 + menuSelected = new bool[] { false, false, false, true, false, false }; + + // 将新选中的按钮设置为选中 + picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + labCounterText.ForeColor = menuSelectedColor; + labCounterSelected.BackColor = menuSelectedColor; // 切换到频率计数器的界面 switchMainPanel(3); @@ -242,10 +254,16 @@ } private void SelectData() { + //if (CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // return; + //} // 移除所有按钮的选中样式 ClearAllMenuSelected(); // 鼠标移入效果去掉 + LeaveData(); // 重新设置所有按钮的状态 @@ -331,6 +349,19 @@ portList.Add(new SerialPort()); portList.Add(new SerialPort()); portList.Add(new SerialPort()); + DeviceService deviceService = new DeviceServiceImpl(); + DetectionItemService detectionItemService = new DetectionItemServiceImpl(); + List listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + long deviceId = device.Id; + string startTime = device.StartTime; + string endTime = device.EndTime; + detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); + } + } } else { @@ -500,24 +531,24 @@ private void switchMainPanel(int index) { - if (index != 3 && CounterCtrlForm.isDetecting) - { - MessageBox.Show("正在检测计数器,无法离开当前界面!"); - // 移除所有按钮的选中样式 - ClearAllMenuSelected(); + //if (index != 3 && CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // // 移除所有按钮的选中样式 + // ClearAllMenuSelected(); - // 鼠标移入效果去掉 - LeaveCounter(); + // // 鼠标移入效果去掉 + // LeaveCounter(); - // 重新设置所有按钮的状态 - menuSelected = new bool[] { false, false, false, true, false, false }; + // // 重新设置所有按钮的状态 + // menuSelected = new bool[] { false, false, false, true, false, false }; - // 将新选中的按钮设置为选中 - picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); - labCounterText.ForeColor = menuSelectedColor; - labCounterSelected.BackColor = menuSelectedColor; - return; - } + // // 将新选中的按钮设置为选中 + // picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + // labCounterText.ForeColor = menuSelectedColor; + // labCounterSelected.BackColor = menuSelectedColor; + // return; + //} panelMain.Controls.Clear(); switch (index) { diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index ecbb7e2..4405d66 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index 36ae30d..fd7ffee 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -111,7 +111,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), + Location = new Point(48, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); @@ -126,27 +126,12 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), + Location = new Point(142, 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 { @@ -156,7 +141,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(247, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -171,7 +156,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), + Location = new Point(360, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colValue); @@ -186,7 +171,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), + Location = new Point(465, 0), Size = new Size(95, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); @@ -280,6 +265,7 @@ dataGridView_CounterResult.DataSource = table_counterDetecInit; + dataGridView_CounterResult.Columns[3].Visible = false; dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; @@ -287,11 +273,10 @@ dataGridView_CounterResult.Columns[0].Width = 50; dataGridView_CounterResult.Columns[1].Width = 95; dataGridView_CounterResult.Columns[2].Width = 95; - 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[4].Width = 110; + dataGridView_CounterResult.Columns[5].Width = 110; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -773,17 +758,30 @@ 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 (!regex.IsMatch(value)) + if (textBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + dataGridView_CounterResult.CurrentCell.Value = ""; + MessageBox.Show("请输入格式正确的、带单位的测量频率!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + dataGridView_CounterResult.CurrentCell.Value = ""; + MessageBox.Show("请输入格式正确的、带单位的测量周期!"); + return; + } + } } } diff --git a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs index ec02ee3..ba3c1cf 100644 --- a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs +++ b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs @@ -51,6 +51,7 @@ private String accuracy; private String bootFeature; private String ageRate; + private long detectionItemId; public long Id { @@ -251,5 +252,6 @@ public string Accuracy { get => accuracy; set => accuracy = value; } public string BootFeature { get => bootFeature; set => bootFeature = value; } public string AgeRate { get => ageRate; set => ageRate = value; } + public long DetectionItemId { get => detectionItemId; set => detectionItemId = value; } } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 3fe0773..64253a7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -16,7 +16,7 @@ List search(long deviceId, bool isInDetection); - int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData); + int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); 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 5c4cda2..b849d77 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -115,6 +115,56 @@ } return iRetval; } + public int startDetect(long detectionItemId, string stability, string accuracy, string bootFeature, string ageRate) + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + if (stability.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + + string sQry = "UPDATE r_detection_item SET"; + if (!stability.Equals("")) + sQry = sQry + " STABILITY=@STABILITY"; + if (!accuracy.Equals("")) + sQry = sQry + " ACCURACY=@ACCURACY"; + if (!bootFeature.Equals("")) + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + if (!ageRate.Equals("")) + sQry = sQry + " AGE_RATE=@AGE_RATE"; + sQry = sQry + " where ID = " + detectionItemId; + + + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; + cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; + cmd.Parameters.Add("@BOOT_FEATURE", MySqlDbType.String, 10).Value = bootFeature; + cmd.Parameters.Add("@AGE_RATE", MySqlDbType.String, 10).Value = ageRate; + + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + iRetval = 0; + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + iRetval = -1; + } + + return iRetval; + } public int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100) { @@ -134,28 +184,28 @@ } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stability : "+ stability); string sQry = "UPDATE r_detection_item SET"; if(!stability.Equals("")) - sQry = sQry + " STABILITY=@STABILITY"; + sQry = sQry + " STABILITY=@STABILITY,"; if (!accuracy.Equals("")) - sQry = sQry + " ACCURACY=@ACCURACY"; + sQry = sQry + " ACCURACY=@ACCURACY,"; if (!bootFeature.Equals("")) - sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE,"; if (!ageRate.Equals("")) - sQry = sQry + " AGE_RATE=@AGE_RATE"; - if (!counterDetec.Equals("")) - sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC"; + sQry = sQry + " AGE_RATE=@AGE_RATE,"; if (!stability1.Equals("")) - sQry = sQry + " STABILITY_1=@STABILITY_1"; + sQry = sQry + " STABILITY_1=@STABILITY_1,"; if (!stability10.Equals("")) - sQry = sQry + " STABILITY_10=@STABILITY_10"; + sQry = sQry + " STABILITY_10=@STABILITY_10,"; if (!stability20.Equals("")) - sQry = sQry + " STABILITY_20=@STABILITY_20"; + sQry = sQry + " STABILITY_20=@STABILITY_20,"; if (!stability100.Equals("")) - sQry = sQry + " STABILITY_100=@STABILITY_100"; - sQry = sQry + " where ID = " + detectionId; + sQry = sQry + " STABILITY_100=@STABILITY_100,"; + sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; @@ -220,7 +270,7 @@ return iRetval; } - public int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData) + public int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData) { int iRetval = -1; try @@ -241,17 +291,25 @@ cmd.Parameters.Add("@CHANNEL", MySqlDbType.String, 20).Value = ""; cmd.ExecuteNonQuery(); + if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime + "' and '" + endTime + "')"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } + else + { + sQry = "UPDATE r_detection_item SET END_TIME=@END_TIME WHERE ID="+ detectionItemId; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@END_TIME", MySqlDbType.DateTime, 20).Value = DateTime.Now; + cmd.ExecuteNonQuery(); + } cmd.Dispose(); iRetval = 0; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 8773cb6..2de0df9 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -87,7 +87,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry + "; statusId="+ statusId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -101,9 +101,6 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); - - iRetval = 0; } catch (MySqlException ex) @@ -205,7 +202,7 @@ if (!aReader.IsDBNull(7)) deviceDto.CustomerDev = aReader.GetString(7); if (!aReader.IsDBNull(8)) { - deviceDto.StatusId = aReader.GetString(7); + deviceDto.StatusId = aReader.GetString(8); } if (!aReader.IsDBNull(9)) deviceDto.Channel = aReader.GetString(9); @@ -481,7 +478,7 @@ } } - string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 "; + string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -523,7 +520,7 @@ if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - + if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); deviceViewList.Add(deviceView); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index ff6a679..1626aa5 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -27,7 +27,7 @@ } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index e1b99b2..936cc37 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -224,7 +224,19 @@ } private void SelectCounter() { - + // 移除所有按钮的选中样式 + ClearAllMenuSelected(); + + // 鼠标移入效果去掉 + LeaveCounter(); + + // 重新设置所有按钮的状态 + menuSelected = new bool[] { false, false, false, true, false, false }; + + // 将新选中的按钮设置为选中 + picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + labCounterText.ForeColor = menuSelectedColor; + labCounterSelected.BackColor = menuSelectedColor; // 切换到频率计数器的界面 switchMainPanel(3); @@ -242,10 +254,16 @@ } private void SelectData() { + //if (CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // return; + //} // 移除所有按钮的选中样式 ClearAllMenuSelected(); // 鼠标移入效果去掉 + LeaveData(); // 重新设置所有按钮的状态 @@ -331,6 +349,19 @@ portList.Add(new SerialPort()); portList.Add(new SerialPort()); portList.Add(new SerialPort()); + DeviceService deviceService = new DeviceServiceImpl(); + DetectionItemService detectionItemService = new DetectionItemServiceImpl(); + List listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + long deviceId = device.Id; + string startTime = device.StartTime; + string endTime = device.EndTime; + detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); + } + } } else { @@ -500,24 +531,24 @@ private void switchMainPanel(int index) { - if (index != 3 && CounterCtrlForm.isDetecting) - { - MessageBox.Show("正在检测计数器,无法离开当前界面!"); - // 移除所有按钮的选中样式 - ClearAllMenuSelected(); + //if (index != 3 && CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // // 移除所有按钮的选中样式 + // ClearAllMenuSelected(); - // 鼠标移入效果去掉 - LeaveCounter(); + // // 鼠标移入效果去掉 + // LeaveCounter(); - // 重新设置所有按钮的状态 - menuSelected = new bool[] { false, false, false, true, false, false }; + // // 重新设置所有按钮的状态 + // menuSelected = new bool[] { false, false, false, true, false, false }; - // 将新选中的按钮设置为选中 - picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); - labCounterText.ForeColor = menuSelectedColor; - labCounterSelected.BackColor = menuSelectedColor; - return; - } + // // 将新选中的按钮设置为选中 + // picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + // labCounterText.ForeColor = menuSelectedColor; + // labCounterSelected.BackColor = menuSelectedColor; + // return; + //} panelMain.Controls.Clear(); switch (index) { diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index ecbb7e2..4405d66 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index 36ae30d..fd7ffee 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -111,7 +111,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), + Location = new Point(48, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); @@ -126,27 +126,12 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), + Location = new Point(142, 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 { @@ -156,7 +141,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(247, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -171,7 +156,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), + Location = new Point(360, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colValue); @@ -186,7 +171,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), + Location = new Point(465, 0), Size = new Size(95, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); @@ -280,6 +265,7 @@ dataGridView_CounterResult.DataSource = table_counterDetecInit; + dataGridView_CounterResult.Columns[3].Visible = false; dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; @@ -287,11 +273,10 @@ dataGridView_CounterResult.Columns[0].Width = 50; dataGridView_CounterResult.Columns[1].Width = 95; dataGridView_CounterResult.Columns[2].Width = 95; - 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[4].Width = 110; + dataGridView_CounterResult.Columns[5].Width = 110; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -773,17 +758,30 @@ 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 (!regex.IsMatch(value)) + if (textBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + dataGridView_CounterResult.CurrentCell.Value = ""; + MessageBox.Show("请输入格式正确的、带单位的测量频率!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + dataGridView_CounterResult.CurrentCell.Value = ""; + MessageBox.Show("请输入格式正确的、带单位的测量周期!"); + return; + } + } } } diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index fcefb48..09d1e4a 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -321,7 +321,7 @@ // this.pic_ageRate_5.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_5.Location = new System.Drawing.Point(151, 9); + this.pic_ageRate_5.Location = new System.Drawing.Point(224, 9); this.pic_ageRate_5.Name = "pic_ageRate_5"; this.pic_ageRate_5.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_5.TabIndex = 336; @@ -331,7 +331,7 @@ // this.pic_stability_5.BackColor = System.Drawing.Color.Transparent; this.pic_stability_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_5.Location = new System.Drawing.Point(85, 9); + this.pic_stability_5.Location = new System.Drawing.Point(12, 9); this.pic_stability_5.Name = "pic_stability_5"; this.pic_stability_5.Size = new System.Drawing.Size(16, 16); this.pic_stability_5.TabIndex = 333; @@ -341,7 +341,7 @@ // this.pic_accuracy_5.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_5.Location = new System.Drawing.Point(224, 9); + this.pic_accuracy_5.Location = new System.Drawing.Point(78, 9); this.pic_accuracy_5.Name = "pic_accuracy_5"; this.pic_accuracy_5.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_5.TabIndex = 334; @@ -351,7 +351,7 @@ // this.pic_bootFeature_5.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_5.Location = new System.Drawing.Point(9, 9); + this.pic_bootFeature_5.Location = new System.Drawing.Point(152, 9); this.pic_bootFeature_5.Name = "pic_bootFeature_5"; this.pic_bootFeature_5.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_5.TabIndex = 335; @@ -374,7 +374,7 @@ // this.pic_ageRate_4.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_4.Location = new System.Drawing.Point(151, 10); + this.pic_ageRate_4.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_4.Name = "pic_ageRate_4"; this.pic_ageRate_4.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_4.TabIndex = 332; @@ -384,7 +384,7 @@ // this.pic_stability_4.BackColor = System.Drawing.Color.Transparent; this.pic_stability_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_stability_4.Location = new System.Drawing.Point(85, 10); + this.pic_stability_4.Location = new System.Drawing.Point(12, 8); this.pic_stability_4.Name = "pic_stability_4"; this.pic_stability_4.Size = new System.Drawing.Size(16, 16); this.pic_stability_4.TabIndex = 329; @@ -394,7 +394,7 @@ // this.pic_accuracy_4.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_4.Location = new System.Drawing.Point(224, 10); + this.pic_accuracy_4.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_4.Name = "pic_accuracy_4"; this.pic_accuracy_4.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_4.TabIndex = 330; @@ -404,7 +404,7 @@ // this.pic_bootFeature_4.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_4.Location = new System.Drawing.Point(9, 10); + this.pic_bootFeature_4.Location = new System.Drawing.Point(152, 8); this.pic_bootFeature_4.Name = "pic_bootFeature_4"; this.pic_bootFeature_4.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_4.TabIndex = 331; @@ -427,7 +427,7 @@ // this.pic_ageRate_3.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_3.Location = new System.Drawing.Point(151, 8); + this.pic_ageRate_3.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_3.Name = "pic_ageRate_3"; this.pic_ageRate_3.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_3.TabIndex = 328; @@ -437,7 +437,7 @@ // this.pic_stability_3.BackColor = System.Drawing.Color.Transparent; this.pic_stability_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_3.Location = new System.Drawing.Point(85, 8); + this.pic_stability_3.Location = new System.Drawing.Point(12, 8); this.pic_stability_3.Name = "pic_stability_3"; this.pic_stability_3.Size = new System.Drawing.Size(16, 16); this.pic_stability_3.TabIndex = 325; @@ -447,7 +447,7 @@ // this.pic_accuracy_3.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_3.Location = new System.Drawing.Point(224, 8); + this.pic_accuracy_3.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_3.Name = "pic_accuracy_3"; this.pic_accuracy_3.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_3.TabIndex = 326; @@ -457,7 +457,7 @@ // this.pic_bootFeature_3.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_3.Location = new System.Drawing.Point(8, 8); + this.pic_bootFeature_3.Location = new System.Drawing.Point(151, 8); this.pic_bootFeature_3.Name = "pic_bootFeature_3"; this.pic_bootFeature_3.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_3.TabIndex = 327; @@ -480,7 +480,7 @@ // this.pic_ageRate_2.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_2.Location = new System.Drawing.Point(151, 7); + this.pic_ageRate_2.Location = new System.Drawing.Point(224, 7); this.pic_ageRate_2.Name = "pic_ageRate_2"; this.pic_ageRate_2.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_2.TabIndex = 324; @@ -490,7 +490,7 @@ // this.pic_stability_2.BackColor = System.Drawing.Color.Transparent; this.pic_stability_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_2.Location = new System.Drawing.Point(85, 7); + this.pic_stability_2.Location = new System.Drawing.Point(12, 7); this.pic_stability_2.Name = "pic_stability_2"; this.pic_stability_2.Size = new System.Drawing.Size(16, 16); this.pic_stability_2.TabIndex = 321; @@ -500,7 +500,7 @@ // this.pic_accuracy_2.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_2.Location = new System.Drawing.Point(224, 7); + this.pic_accuracy_2.Location = new System.Drawing.Point(78, 7); this.pic_accuracy_2.Name = "pic_accuracy_2"; this.pic_accuracy_2.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_2.TabIndex = 322; @@ -510,7 +510,7 @@ // this.pic_bootFeature_2.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_2.Location = new System.Drawing.Point(8, 7); + this.pic_bootFeature_2.Location = new System.Drawing.Point(151, 7); this.pic_bootFeature_2.Name = "pic_bootFeature_2"; this.pic_bootFeature_2.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_2.TabIndex = 323; @@ -533,7 +533,7 @@ // this.pic_ageRate_1.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_1.Location = new System.Drawing.Point(151, 8); + this.pic_ageRate_1.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_1.Name = "pic_ageRate_1"; this.pic_ageRate_1.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_1.TabIndex = 320; @@ -543,7 +543,7 @@ // this.pic_stability_1.BackColor = System.Drawing.Color.Transparent; this.pic_stability_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_1.Location = new System.Drawing.Point(85, 8); + this.pic_stability_1.Location = new System.Drawing.Point(12, 8); this.pic_stability_1.Name = "pic_stability_1"; this.pic_stability_1.Size = new System.Drawing.Size(16, 16); this.pic_stability_1.TabIndex = 317; @@ -553,7 +553,7 @@ // this.pic_accuracy_1.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_1.Location = new System.Drawing.Point(224, 8); + this.pic_accuracy_1.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_1.Name = "pic_accuracy_1"; this.pic_accuracy_1.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_1.TabIndex = 318; @@ -563,7 +563,7 @@ // this.pic_bootFeature_1.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_1.Location = new System.Drawing.Point(7, 8); + this.pic_bootFeature_1.Location = new System.Drawing.Point(150, 8); this.pic_bootFeature_1.Name = "pic_bootFeature_1"; this.pic_bootFeature_1.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_1.TabIndex = 319; @@ -598,7 +598,7 @@ dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.dataGridView_Channel.DefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_Channel.GridColor = System.Drawing.Color.DarkGray; - this.dataGridView_Channel.Location = new System.Drawing.Point(10, 10); + this.dataGridView_Channel.Location = new System.Drawing.Point(11, 10); this.dataGridView_Channel.Margin = new System.Windows.Forms.Padding(0); this.dataGridView_Channel.MultiSelect = false; this.dataGridView_Channel.Name = "dataGridView_Channel"; diff --git a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs index ec02ee3..ba3c1cf 100644 --- a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs +++ b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs @@ -51,6 +51,7 @@ private String accuracy; private String bootFeature; private String ageRate; + private long detectionItemId; public long Id { @@ -251,5 +252,6 @@ public string Accuracy { get => accuracy; set => accuracy = value; } public string BootFeature { get => bootFeature; set => bootFeature = value; } public string AgeRate { get => ageRate; set => ageRate = value; } + public long DetectionItemId { get => detectionItemId; set => detectionItemId = value; } } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 3fe0773..64253a7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -16,7 +16,7 @@ List search(long deviceId, bool isInDetection); - int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData); + int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); 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 5c4cda2..b849d77 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -115,6 +115,56 @@ } return iRetval; } + public int startDetect(long detectionItemId, string stability, string accuracy, string bootFeature, string ageRate) + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + if (stability.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + + string sQry = "UPDATE r_detection_item SET"; + if (!stability.Equals("")) + sQry = sQry + " STABILITY=@STABILITY"; + if (!accuracy.Equals("")) + sQry = sQry + " ACCURACY=@ACCURACY"; + if (!bootFeature.Equals("")) + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + if (!ageRate.Equals("")) + sQry = sQry + " AGE_RATE=@AGE_RATE"; + sQry = sQry + " where ID = " + detectionItemId; + + + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; + cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; + cmd.Parameters.Add("@BOOT_FEATURE", MySqlDbType.String, 10).Value = bootFeature; + cmd.Parameters.Add("@AGE_RATE", MySqlDbType.String, 10).Value = ageRate; + + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + iRetval = 0; + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + iRetval = -1; + } + + return iRetval; + } public int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100) { @@ -134,28 +184,28 @@ } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stability : "+ stability); string sQry = "UPDATE r_detection_item SET"; if(!stability.Equals("")) - sQry = sQry + " STABILITY=@STABILITY"; + sQry = sQry + " STABILITY=@STABILITY,"; if (!accuracy.Equals("")) - sQry = sQry + " ACCURACY=@ACCURACY"; + sQry = sQry + " ACCURACY=@ACCURACY,"; if (!bootFeature.Equals("")) - sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE,"; if (!ageRate.Equals("")) - sQry = sQry + " AGE_RATE=@AGE_RATE"; - if (!counterDetec.Equals("")) - sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC"; + sQry = sQry + " AGE_RATE=@AGE_RATE,"; if (!stability1.Equals("")) - sQry = sQry + " STABILITY_1=@STABILITY_1"; + sQry = sQry + " STABILITY_1=@STABILITY_1,"; if (!stability10.Equals("")) - sQry = sQry + " STABILITY_10=@STABILITY_10"; + sQry = sQry + " STABILITY_10=@STABILITY_10,"; if (!stability20.Equals("")) - sQry = sQry + " STABILITY_20=@STABILITY_20"; + sQry = sQry + " STABILITY_20=@STABILITY_20,"; if (!stability100.Equals("")) - sQry = sQry + " STABILITY_100=@STABILITY_100"; - sQry = sQry + " where ID = " + detectionId; + sQry = sQry + " STABILITY_100=@STABILITY_100,"; + sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; @@ -220,7 +270,7 @@ return iRetval; } - public int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData) + public int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData) { int iRetval = -1; try @@ -241,17 +291,25 @@ cmd.Parameters.Add("@CHANNEL", MySqlDbType.String, 20).Value = ""; cmd.ExecuteNonQuery(); + if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime + "' and '" + endTime + "')"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } + else + { + sQry = "UPDATE r_detection_item SET END_TIME=@END_TIME WHERE ID="+ detectionItemId; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@END_TIME", MySqlDbType.DateTime, 20).Value = DateTime.Now; + cmd.ExecuteNonQuery(); + } cmd.Dispose(); iRetval = 0; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 8773cb6..2de0df9 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -87,7 +87,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry + "; statusId="+ statusId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -101,9 +101,6 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); - - iRetval = 0; } catch (MySqlException ex) @@ -205,7 +202,7 @@ if (!aReader.IsDBNull(7)) deviceDto.CustomerDev = aReader.GetString(7); if (!aReader.IsDBNull(8)) { - deviceDto.StatusId = aReader.GetString(7); + deviceDto.StatusId = aReader.GetString(8); } if (!aReader.IsDBNull(9)) deviceDto.Channel = aReader.GetString(9); @@ -481,7 +478,7 @@ } } - string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 "; + string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -523,7 +520,7 @@ if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - + if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); deviceViewList.Add(deviceView); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index ff6a679..1626aa5 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -27,7 +27,7 @@ } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index e1b99b2..936cc37 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -224,7 +224,19 @@ } private void SelectCounter() { - + // 移除所有按钮的选中样式 + ClearAllMenuSelected(); + + // 鼠标移入效果去掉 + LeaveCounter(); + + // 重新设置所有按钮的状态 + menuSelected = new bool[] { false, false, false, true, false, false }; + + // 将新选中的按钮设置为选中 + picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + labCounterText.ForeColor = menuSelectedColor; + labCounterSelected.BackColor = menuSelectedColor; // 切换到频率计数器的界面 switchMainPanel(3); @@ -242,10 +254,16 @@ } private void SelectData() { + //if (CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // return; + //} // 移除所有按钮的选中样式 ClearAllMenuSelected(); // 鼠标移入效果去掉 + LeaveData(); // 重新设置所有按钮的状态 @@ -331,6 +349,19 @@ portList.Add(new SerialPort()); portList.Add(new SerialPort()); portList.Add(new SerialPort()); + DeviceService deviceService = new DeviceServiceImpl(); + DetectionItemService detectionItemService = new DetectionItemServiceImpl(); + List listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + long deviceId = device.Id; + string startTime = device.StartTime; + string endTime = device.EndTime; + detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); + } + } } else { @@ -500,24 +531,24 @@ private void switchMainPanel(int index) { - if (index != 3 && CounterCtrlForm.isDetecting) - { - MessageBox.Show("正在检测计数器,无法离开当前界面!"); - // 移除所有按钮的选中样式 - ClearAllMenuSelected(); + //if (index != 3 && CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // // 移除所有按钮的选中样式 + // ClearAllMenuSelected(); - // 鼠标移入效果去掉 - LeaveCounter(); + // // 鼠标移入效果去掉 + // LeaveCounter(); - // 重新设置所有按钮的状态 - menuSelected = new bool[] { false, false, false, true, false, false }; + // // 重新设置所有按钮的状态 + // menuSelected = new bool[] { false, false, false, true, false, false }; - // 将新选中的按钮设置为选中 - picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); - labCounterText.ForeColor = menuSelectedColor; - labCounterSelected.BackColor = menuSelectedColor; - return; - } + // // 将新选中的按钮设置为选中 + // picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + // labCounterText.ForeColor = menuSelectedColor; + // labCounterSelected.BackColor = menuSelectedColor; + // return; + //} panelMain.Controls.Clear(); switch (index) { diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index ecbb7e2..4405d66 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index 36ae30d..fd7ffee 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -111,7 +111,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), + Location = new Point(48, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); @@ -126,27 +126,12 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), + Location = new Point(142, 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 { @@ -156,7 +141,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(247, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -171,7 +156,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), + Location = new Point(360, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colValue); @@ -186,7 +171,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), + Location = new Point(465, 0), Size = new Size(95, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); @@ -280,6 +265,7 @@ dataGridView_CounterResult.DataSource = table_counterDetecInit; + dataGridView_CounterResult.Columns[3].Visible = false; dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; @@ -287,11 +273,10 @@ dataGridView_CounterResult.Columns[0].Width = 50; dataGridView_CounterResult.Columns[1].Width = 95; dataGridView_CounterResult.Columns[2].Width = 95; - 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[4].Width = 110; + dataGridView_CounterResult.Columns[5].Width = 110; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -773,17 +758,30 @@ 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 (!regex.IsMatch(value)) + if (textBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + dataGridView_CounterResult.CurrentCell.Value = ""; + MessageBox.Show("请输入格式正确的、带单位的测量频率!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + dataGridView_CounterResult.CurrentCell.Value = ""; + MessageBox.Show("请输入格式正确的、带单位的测量周期!"); + return; + } + } } } diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index fcefb48..09d1e4a 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -321,7 +321,7 @@ // this.pic_ageRate_5.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_5.Location = new System.Drawing.Point(151, 9); + this.pic_ageRate_5.Location = new System.Drawing.Point(224, 9); this.pic_ageRate_5.Name = "pic_ageRate_5"; this.pic_ageRate_5.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_5.TabIndex = 336; @@ -331,7 +331,7 @@ // this.pic_stability_5.BackColor = System.Drawing.Color.Transparent; this.pic_stability_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_5.Location = new System.Drawing.Point(85, 9); + this.pic_stability_5.Location = new System.Drawing.Point(12, 9); this.pic_stability_5.Name = "pic_stability_5"; this.pic_stability_5.Size = new System.Drawing.Size(16, 16); this.pic_stability_5.TabIndex = 333; @@ -341,7 +341,7 @@ // this.pic_accuracy_5.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_5.Location = new System.Drawing.Point(224, 9); + this.pic_accuracy_5.Location = new System.Drawing.Point(78, 9); this.pic_accuracy_5.Name = "pic_accuracy_5"; this.pic_accuracy_5.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_5.TabIndex = 334; @@ -351,7 +351,7 @@ // this.pic_bootFeature_5.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_5.Location = new System.Drawing.Point(9, 9); + this.pic_bootFeature_5.Location = new System.Drawing.Point(152, 9); this.pic_bootFeature_5.Name = "pic_bootFeature_5"; this.pic_bootFeature_5.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_5.TabIndex = 335; @@ -374,7 +374,7 @@ // this.pic_ageRate_4.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_4.Location = new System.Drawing.Point(151, 10); + this.pic_ageRate_4.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_4.Name = "pic_ageRate_4"; this.pic_ageRate_4.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_4.TabIndex = 332; @@ -384,7 +384,7 @@ // this.pic_stability_4.BackColor = System.Drawing.Color.Transparent; this.pic_stability_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_stability_4.Location = new System.Drawing.Point(85, 10); + this.pic_stability_4.Location = new System.Drawing.Point(12, 8); this.pic_stability_4.Name = "pic_stability_4"; this.pic_stability_4.Size = new System.Drawing.Size(16, 16); this.pic_stability_4.TabIndex = 329; @@ -394,7 +394,7 @@ // this.pic_accuracy_4.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_4.Location = new System.Drawing.Point(224, 10); + this.pic_accuracy_4.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_4.Name = "pic_accuracy_4"; this.pic_accuracy_4.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_4.TabIndex = 330; @@ -404,7 +404,7 @@ // this.pic_bootFeature_4.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_4.Location = new System.Drawing.Point(9, 10); + this.pic_bootFeature_4.Location = new System.Drawing.Point(152, 8); this.pic_bootFeature_4.Name = "pic_bootFeature_4"; this.pic_bootFeature_4.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_4.TabIndex = 331; @@ -427,7 +427,7 @@ // this.pic_ageRate_3.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_3.Location = new System.Drawing.Point(151, 8); + this.pic_ageRate_3.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_3.Name = "pic_ageRate_3"; this.pic_ageRate_3.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_3.TabIndex = 328; @@ -437,7 +437,7 @@ // this.pic_stability_3.BackColor = System.Drawing.Color.Transparent; this.pic_stability_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_3.Location = new System.Drawing.Point(85, 8); + this.pic_stability_3.Location = new System.Drawing.Point(12, 8); this.pic_stability_3.Name = "pic_stability_3"; this.pic_stability_3.Size = new System.Drawing.Size(16, 16); this.pic_stability_3.TabIndex = 325; @@ -447,7 +447,7 @@ // this.pic_accuracy_3.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_3.Location = new System.Drawing.Point(224, 8); + this.pic_accuracy_3.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_3.Name = "pic_accuracy_3"; this.pic_accuracy_3.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_3.TabIndex = 326; @@ -457,7 +457,7 @@ // this.pic_bootFeature_3.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_3.Location = new System.Drawing.Point(8, 8); + this.pic_bootFeature_3.Location = new System.Drawing.Point(151, 8); this.pic_bootFeature_3.Name = "pic_bootFeature_3"; this.pic_bootFeature_3.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_3.TabIndex = 327; @@ -480,7 +480,7 @@ // this.pic_ageRate_2.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_2.Location = new System.Drawing.Point(151, 7); + this.pic_ageRate_2.Location = new System.Drawing.Point(224, 7); this.pic_ageRate_2.Name = "pic_ageRate_2"; this.pic_ageRate_2.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_2.TabIndex = 324; @@ -490,7 +490,7 @@ // this.pic_stability_2.BackColor = System.Drawing.Color.Transparent; this.pic_stability_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_2.Location = new System.Drawing.Point(85, 7); + this.pic_stability_2.Location = new System.Drawing.Point(12, 7); this.pic_stability_2.Name = "pic_stability_2"; this.pic_stability_2.Size = new System.Drawing.Size(16, 16); this.pic_stability_2.TabIndex = 321; @@ -500,7 +500,7 @@ // this.pic_accuracy_2.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_2.Location = new System.Drawing.Point(224, 7); + this.pic_accuracy_2.Location = new System.Drawing.Point(78, 7); this.pic_accuracy_2.Name = "pic_accuracy_2"; this.pic_accuracy_2.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_2.TabIndex = 322; @@ -510,7 +510,7 @@ // this.pic_bootFeature_2.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_2.Location = new System.Drawing.Point(8, 7); + this.pic_bootFeature_2.Location = new System.Drawing.Point(151, 7); this.pic_bootFeature_2.Name = "pic_bootFeature_2"; this.pic_bootFeature_2.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_2.TabIndex = 323; @@ -533,7 +533,7 @@ // this.pic_ageRate_1.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_1.Location = new System.Drawing.Point(151, 8); + this.pic_ageRate_1.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_1.Name = "pic_ageRate_1"; this.pic_ageRate_1.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_1.TabIndex = 320; @@ -543,7 +543,7 @@ // this.pic_stability_1.BackColor = System.Drawing.Color.Transparent; this.pic_stability_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_1.Location = new System.Drawing.Point(85, 8); + this.pic_stability_1.Location = new System.Drawing.Point(12, 8); this.pic_stability_1.Name = "pic_stability_1"; this.pic_stability_1.Size = new System.Drawing.Size(16, 16); this.pic_stability_1.TabIndex = 317; @@ -553,7 +553,7 @@ // this.pic_accuracy_1.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_1.Location = new System.Drawing.Point(224, 8); + this.pic_accuracy_1.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_1.Name = "pic_accuracy_1"; this.pic_accuracy_1.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_1.TabIndex = 318; @@ -563,7 +563,7 @@ // this.pic_bootFeature_1.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_1.Location = new System.Drawing.Point(7, 8); + this.pic_bootFeature_1.Location = new System.Drawing.Point(150, 8); this.pic_bootFeature_1.Name = "pic_bootFeature_1"; this.pic_bootFeature_1.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_1.TabIndex = 319; @@ -598,7 +598,7 @@ dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.dataGridView_Channel.DefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_Channel.GridColor = System.Drawing.Color.DarkGray; - this.dataGridView_Channel.Location = new System.Drawing.Point(10, 10); + this.dataGridView_Channel.Location = new System.Drawing.Point(11, 10); this.dataGridView_Channel.Margin = new System.Windows.Forms.Padding(0); this.dataGridView_Channel.MultiSelect = false; this.dataGridView_Channel.Name = "dataGridView_Channel"; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index 5d75f74..ca3181d 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -60,6 +60,8 @@ label_clockStatus.Text = FreshStatus.clockStatus; label_receiverStatus.Text = StatusCtrlForm.receiverStatus; } + + } private void HomeCtrlForm_Load(object sender, EventArgs e) @@ -421,22 +423,6 @@ dataGridView_Channel.Controls.Add(colStatus); colStatus.BringToFront(); - // 开机特性 - Label colStartup = 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(colStartup); - colStartup.BringToFront(); - // 频率稳定度 Label colStablility = new Label { @@ -446,25 +432,13 @@ BackColor = titleBackColor, AutoSize = false, Text = "稳定度", - Location = new Point(759, 0), + + Location = new Point(684,0), Size = new Size(75, 30) }; dataGridView_Channel.Controls.Add(colStablility); colStablility.BringToFront(); - // 日老化率 - Label colAgingRate = 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) - }; - // 频率准确度 Label colAccuracy = new Label { @@ -474,11 +448,45 @@ BackColor = titleBackColor, AutoSize = false, Text = "准确度", - Location = new Point(899, 0), + 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) + }; + + @@ -506,142 +514,162 @@ } public void LoadChannelStatus() { - channelsTable = new DataTable(); - - channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); - channelsTable.Columns.Add("devName", Type.GetType("System.String")); - channelsTable.Columns.Add("devCode", Type.GetType("System.String")); - channelsTable.Columns.Add("customComp", Type.GetType("System.String")); - channelsTable.Columns.Add("startTime", Type.GetType("System.String")); - channelsTable.Columns.Add("endTime", Type.GetType("System.String")); - channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); - channelsTable.Columns.Add("startup", Type.GetType("System.String")); - channelsTable.Columns.Add("stablility", Type.GetType("System.String")); - channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); - channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); - channelsTable.Columns.Add("deviceId", Type.GetType("System.Int32")); - //channelsTable.Columns.Add("devType", Type.GetType("System.String")); - //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); - //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); - - listChannelStatus = deviceService.getDeviceByChannel(); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - if (listChannelStatus != null && listChannelStatus.Count > 0) + try { - foreach (DeviceView device in listChannelStatus) + channelsTable = new DataTable(); + + channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); + channelsTable.Columns.Add("devName", Type.GetType("System.String")); + channelsTable.Columns.Add("devCode", Type.GetType("System.String")); + channelsTable.Columns.Add("customComp", Type.GetType("System.String")); + channelsTable.Columns.Add("startTime", Type.GetType("System.String")); + channelsTable.Columns.Add("endTime", Type.GetType("System.String")); + channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); + channelsTable.Columns.Add("stablility", Type.GetType("System.String")); + channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); + channelsTable.Columns.Add("startup", Type.GetType("System.String")); + channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); + channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); + channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); + //channelsTable.Columns.Add("devType", Type.GetType("System.String")); + //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); + //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); + + listChannelStatus = deviceService.getDeviceByChannel(); + + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); + + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); - int index = Convert.ToInt32(device.Channel) - 1; - channelsTable.Rows[index]["channelNo"] = device.Channel; - channelsTable.Rows[index]["devName"] = device.DevName; - channelsTable.Rows[index]["devCode"] = device.DevCode; - channelsTable.Rows[index]["customComp"] = device.CustomerDev; - channelsTable.Rows[index]["startTime"] = device.StartTime; - channelsTable.Rows[index]["endTime"] = device.EndTime; - channelsTable.Rows[index]["channelStatus"] = "占用"; - channelsTable.Rows[index]["deviceId"] = device.Id; - if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + int index = Convert.ToInt32(device.Channel) - 1; + channelsTable.Rows[index]["channelNo"] = device.Channel; + channelsTable.Rows[index]["devName"] = device.DevName; + channelsTable.Rows[index]["devCode"] = device.DevCode; + channelsTable.Rows[index]["customComp"] = device.CustomerDev; + channelsTable.Rows[index]["startTime"] = device.StartTime; + channelsTable.Rows[index]["endTime"] = device.EndTime; + channelsTable.Rows[index]["channelStatus"] = "占用"; + channelsTable.Rows[index]["deviceId"] = device.Id; + channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; + + if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + } } + else + { + channelsTable.Rows.Clear(); + channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); + } + + foreach (string no in channelFreeList) + { + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; + } + + + dataGridView_Channel.DataSource = channelsTable; + + // width=764px + dataGridView_Channel.Columns[11].Visible = false; + dataGridView_Channel.Columns[12].Visible = false; + dataGridView_Channel.Columns[0].Width = 50; + dataGridView_Channel.Columns[1].Width = 110; + dataGridView_Channel.Columns[2].Width = 110; + dataGridView_Channel.Columns[3].Width = 110; + dataGridView_Channel.Columns[4].Width = 120; + dataGridView_Channel.Columns[5].Width = 120; + dataGridView_Channel.Columns[6].Width = 64; + dataGridView_Channel.Columns[7].Width = 75; + dataGridView_Channel.Columns[8].Width = 75; + dataGridView_Channel.Columns[9].Width = 75; + dataGridView_Channel.Columns[10].Width = 75; + + dataGridView_Channel.Columns[0].ReadOnly = true; + dataGridView_Channel.Columns[1].ReadOnly = true; + dataGridView_Channel.Columns[2].ReadOnly = true; + dataGridView_Channel.Columns[3].ReadOnly = true; + dataGridView_Channel.Columns[4].ReadOnly = true; + dataGridView_Channel.Columns[5].ReadOnly = true; + dataGridView_Channel.Columns[6].ReadOnly = true; + dataGridView_Channel.Columns[7].ReadOnly = true; + dataGridView_Channel.Columns[8].ReadOnly = true; + dataGridView_Channel.Columns[9].ReadOnly = true; + dataGridView_Channel.Columns[10].ReadOnly = true; } - else + catch (Exception ex) { - channelsTable.Rows.Clear(); - channelsTable.Rows.Add("1","","","","","","空闲",""); - channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", ""); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "LoadChannelStatus 错误:" + ex.Message); + } - - foreach (string no in channelFreeList) - { - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; - } - - - dataGridView_Channel.DataSource = channelsTable; - - // width=764px - dataGridView_Channel.Columns[11].Visible = false; - dataGridView_Channel.Columns[0].Width = 50; - dataGridView_Channel.Columns[1].Width = 110; - dataGridView_Channel.Columns[2].Width = 110; - dataGridView_Channel.Columns[3].Width = 110; - dataGridView_Channel.Columns[4].Width = 120; - dataGridView_Channel.Columns[5].Width = 120; - dataGridView_Channel.Columns[6].Width = 64; - dataGridView_Channel.Columns[7].Width = 75; - dataGridView_Channel.Columns[8].Width = 75; - dataGridView_Channel.Columns[9].Width = 75; - dataGridView_Channel.Columns[10].Width = 75; - - dataGridView_Channel.Columns[0].ReadOnly = true; - dataGridView_Channel.Columns[1].ReadOnly = true; - dataGridView_Channel.Columns[2].ReadOnly = true; - dataGridView_Channel.Columns[3].ReadOnly = true; - dataGridView_Channel.Columns[4].ReadOnly = true; - dataGridView_Channel.Columns[5].ReadOnly = true; - dataGridView_Channel.Columns[6].ReadOnly = true; - dataGridView_Channel.Columns[7].ReadOnly = true; - dataGridView_Channel.Columns[8].ReadOnly = true; - dataGridView_Channel.Columns[9].ReadOnly = true; - dataGridView_Channel.Columns[10].ReadOnly = true; - } private void dataGridView_Channel_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) - { - dataGridView_Channel.ClearSelection(); + { + try + { + dataGridView_Channel.ClearSelection(); - int channelNo = e.RowIndex + 1; - if (channelFreeList.Contains(channelNo + "")) - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + int channelNo = e.RowIndex + 1; + if (channelFreeList.Contains(channelNo + "")) + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + } + else + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + } + foreach (string no in channelFreeList) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } } - else + catch (Exception ex) { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - } - foreach (string no in channelFreeList) - { - 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, "dataGridView_Channel_RowPostPaint 错误:" + ex.Message); + } } @@ -701,7 +729,8 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - int deviceId = (int)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + 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) @@ -712,11 +741,11 @@ DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { - detectionItemService.stopDetection(deviceId, startTime, endTime, false); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); } else { - detectionItemService.stopDetection(deviceId, startTime, endTime, true); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); } LoadChannelStatus(); LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs index ec02ee3..ba3c1cf 100644 --- a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs +++ b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs @@ -51,6 +51,7 @@ private String accuracy; private String bootFeature; private String ageRate; + private long detectionItemId; public long Id { @@ -251,5 +252,6 @@ public string Accuracy { get => accuracy; set => accuracy = value; } public string BootFeature { get => bootFeature; set => bootFeature = value; } public string AgeRate { get => ageRate; set => ageRate = value; } + public long DetectionItemId { get => detectionItemId; set => detectionItemId = value; } } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 3fe0773..64253a7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -16,7 +16,7 @@ List search(long deviceId, bool isInDetection); - int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData); + int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); 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 5c4cda2..b849d77 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -115,6 +115,56 @@ } return iRetval; } + public int startDetect(long detectionItemId, string stability, string accuracy, string bootFeature, string ageRate) + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + if (stability.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + + string sQry = "UPDATE r_detection_item SET"; + if (!stability.Equals("")) + sQry = sQry + " STABILITY=@STABILITY"; + if (!accuracy.Equals("")) + sQry = sQry + " ACCURACY=@ACCURACY"; + if (!bootFeature.Equals("")) + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + if (!ageRate.Equals("")) + sQry = sQry + " AGE_RATE=@AGE_RATE"; + sQry = sQry + " where ID = " + detectionItemId; + + + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; + cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; + cmd.Parameters.Add("@BOOT_FEATURE", MySqlDbType.String, 10).Value = bootFeature; + cmd.Parameters.Add("@AGE_RATE", MySqlDbType.String, 10).Value = ageRate; + + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + iRetval = 0; + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + iRetval = -1; + } + + return iRetval; + } public int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100) { @@ -134,28 +184,28 @@ } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stability : "+ stability); string sQry = "UPDATE r_detection_item SET"; if(!stability.Equals("")) - sQry = sQry + " STABILITY=@STABILITY"; + sQry = sQry + " STABILITY=@STABILITY,"; if (!accuracy.Equals("")) - sQry = sQry + " ACCURACY=@ACCURACY"; + sQry = sQry + " ACCURACY=@ACCURACY,"; if (!bootFeature.Equals("")) - sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE,"; if (!ageRate.Equals("")) - sQry = sQry + " AGE_RATE=@AGE_RATE"; - if (!counterDetec.Equals("")) - sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC"; + sQry = sQry + " AGE_RATE=@AGE_RATE,"; if (!stability1.Equals("")) - sQry = sQry + " STABILITY_1=@STABILITY_1"; + sQry = sQry + " STABILITY_1=@STABILITY_1,"; if (!stability10.Equals("")) - sQry = sQry + " STABILITY_10=@STABILITY_10"; + sQry = sQry + " STABILITY_10=@STABILITY_10,"; if (!stability20.Equals("")) - sQry = sQry + " STABILITY_20=@STABILITY_20"; + sQry = sQry + " STABILITY_20=@STABILITY_20,"; if (!stability100.Equals("")) - sQry = sQry + " STABILITY_100=@STABILITY_100"; - sQry = sQry + " where ID = " + detectionId; + sQry = sQry + " STABILITY_100=@STABILITY_100,"; + sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; @@ -220,7 +270,7 @@ return iRetval; } - public int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData) + public int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData) { int iRetval = -1; try @@ -241,17 +291,25 @@ cmd.Parameters.Add("@CHANNEL", MySqlDbType.String, 20).Value = ""; cmd.ExecuteNonQuery(); + if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime + "' and '" + endTime + "')"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } + else + { + sQry = "UPDATE r_detection_item SET END_TIME=@END_TIME WHERE ID="+ detectionItemId; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@END_TIME", MySqlDbType.DateTime, 20).Value = DateTime.Now; + cmd.ExecuteNonQuery(); + } cmd.Dispose(); iRetval = 0; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 8773cb6..2de0df9 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -87,7 +87,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry + "; statusId="+ statusId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -101,9 +101,6 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); - - iRetval = 0; } catch (MySqlException ex) @@ -205,7 +202,7 @@ if (!aReader.IsDBNull(7)) deviceDto.CustomerDev = aReader.GetString(7); if (!aReader.IsDBNull(8)) { - deviceDto.StatusId = aReader.GetString(7); + deviceDto.StatusId = aReader.GetString(8); } if (!aReader.IsDBNull(9)) deviceDto.Channel = aReader.GetString(9); @@ -481,7 +478,7 @@ } } - string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 "; + string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -523,7 +520,7 @@ if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - + if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); deviceViewList.Add(deviceView); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index ff6a679..1626aa5 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -27,7 +27,7 @@ } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index e1b99b2..936cc37 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -224,7 +224,19 @@ } private void SelectCounter() { - + // 移除所有按钮的选中样式 + ClearAllMenuSelected(); + + // 鼠标移入效果去掉 + LeaveCounter(); + + // 重新设置所有按钮的状态 + menuSelected = new bool[] { false, false, false, true, false, false }; + + // 将新选中的按钮设置为选中 + picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + labCounterText.ForeColor = menuSelectedColor; + labCounterSelected.BackColor = menuSelectedColor; // 切换到频率计数器的界面 switchMainPanel(3); @@ -242,10 +254,16 @@ } private void SelectData() { + //if (CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // return; + //} // 移除所有按钮的选中样式 ClearAllMenuSelected(); // 鼠标移入效果去掉 + LeaveData(); // 重新设置所有按钮的状态 @@ -331,6 +349,19 @@ portList.Add(new SerialPort()); portList.Add(new SerialPort()); portList.Add(new SerialPort()); + DeviceService deviceService = new DeviceServiceImpl(); + DetectionItemService detectionItemService = new DetectionItemServiceImpl(); + List listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + long deviceId = device.Id; + string startTime = device.StartTime; + string endTime = device.EndTime; + detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); + } + } } else { @@ -500,24 +531,24 @@ private void switchMainPanel(int index) { - if (index != 3 && CounterCtrlForm.isDetecting) - { - MessageBox.Show("正在检测计数器,无法离开当前界面!"); - // 移除所有按钮的选中样式 - ClearAllMenuSelected(); + //if (index != 3 && CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // // 移除所有按钮的选中样式 + // ClearAllMenuSelected(); - // 鼠标移入效果去掉 - LeaveCounter(); + // // 鼠标移入效果去掉 + // LeaveCounter(); - // 重新设置所有按钮的状态 - menuSelected = new bool[] { false, false, false, true, false, false }; + // // 重新设置所有按钮的状态 + // menuSelected = new bool[] { false, false, false, true, false, false }; - // 将新选中的按钮设置为选中 - picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); - labCounterText.ForeColor = menuSelectedColor; - labCounterSelected.BackColor = menuSelectedColor; - return; - } + // // 将新选中的按钮设置为选中 + // picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + // labCounterText.ForeColor = menuSelectedColor; + // labCounterSelected.BackColor = menuSelectedColor; + // return; + //} panelMain.Controls.Clear(); switch (index) { diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index ecbb7e2..4405d66 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index 36ae30d..fd7ffee 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -111,7 +111,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), + Location = new Point(48, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); @@ -126,27 +126,12 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), + Location = new Point(142, 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 { @@ -156,7 +141,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(247, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -171,7 +156,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), + Location = new Point(360, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colValue); @@ -186,7 +171,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), + Location = new Point(465, 0), Size = new Size(95, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); @@ -280,6 +265,7 @@ dataGridView_CounterResult.DataSource = table_counterDetecInit; + dataGridView_CounterResult.Columns[3].Visible = false; dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; @@ -287,11 +273,10 @@ dataGridView_CounterResult.Columns[0].Width = 50; dataGridView_CounterResult.Columns[1].Width = 95; dataGridView_CounterResult.Columns[2].Width = 95; - 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[4].Width = 110; + dataGridView_CounterResult.Columns[5].Width = 110; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -773,17 +758,30 @@ 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 (!regex.IsMatch(value)) + if (textBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + dataGridView_CounterResult.CurrentCell.Value = ""; + MessageBox.Show("请输入格式正确的、带单位的测量频率!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + dataGridView_CounterResult.CurrentCell.Value = ""; + MessageBox.Show("请输入格式正确的、带单位的测量周期!"); + return; + } + } } } diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index fcefb48..09d1e4a 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -321,7 +321,7 @@ // this.pic_ageRate_5.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_5.Location = new System.Drawing.Point(151, 9); + this.pic_ageRate_5.Location = new System.Drawing.Point(224, 9); this.pic_ageRate_5.Name = "pic_ageRate_5"; this.pic_ageRate_5.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_5.TabIndex = 336; @@ -331,7 +331,7 @@ // this.pic_stability_5.BackColor = System.Drawing.Color.Transparent; this.pic_stability_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_5.Location = new System.Drawing.Point(85, 9); + this.pic_stability_5.Location = new System.Drawing.Point(12, 9); this.pic_stability_5.Name = "pic_stability_5"; this.pic_stability_5.Size = new System.Drawing.Size(16, 16); this.pic_stability_5.TabIndex = 333; @@ -341,7 +341,7 @@ // this.pic_accuracy_5.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_5.Location = new System.Drawing.Point(224, 9); + this.pic_accuracy_5.Location = new System.Drawing.Point(78, 9); this.pic_accuracy_5.Name = "pic_accuracy_5"; this.pic_accuracy_5.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_5.TabIndex = 334; @@ -351,7 +351,7 @@ // this.pic_bootFeature_5.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_5.Location = new System.Drawing.Point(9, 9); + this.pic_bootFeature_5.Location = new System.Drawing.Point(152, 9); this.pic_bootFeature_5.Name = "pic_bootFeature_5"; this.pic_bootFeature_5.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_5.TabIndex = 335; @@ -374,7 +374,7 @@ // this.pic_ageRate_4.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_4.Location = new System.Drawing.Point(151, 10); + this.pic_ageRate_4.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_4.Name = "pic_ageRate_4"; this.pic_ageRate_4.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_4.TabIndex = 332; @@ -384,7 +384,7 @@ // this.pic_stability_4.BackColor = System.Drawing.Color.Transparent; this.pic_stability_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_stability_4.Location = new System.Drawing.Point(85, 10); + this.pic_stability_4.Location = new System.Drawing.Point(12, 8); this.pic_stability_4.Name = "pic_stability_4"; this.pic_stability_4.Size = new System.Drawing.Size(16, 16); this.pic_stability_4.TabIndex = 329; @@ -394,7 +394,7 @@ // this.pic_accuracy_4.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_4.Location = new System.Drawing.Point(224, 10); + this.pic_accuracy_4.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_4.Name = "pic_accuracy_4"; this.pic_accuracy_4.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_4.TabIndex = 330; @@ -404,7 +404,7 @@ // this.pic_bootFeature_4.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_4.Location = new System.Drawing.Point(9, 10); + this.pic_bootFeature_4.Location = new System.Drawing.Point(152, 8); this.pic_bootFeature_4.Name = "pic_bootFeature_4"; this.pic_bootFeature_4.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_4.TabIndex = 331; @@ -427,7 +427,7 @@ // this.pic_ageRate_3.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_3.Location = new System.Drawing.Point(151, 8); + this.pic_ageRate_3.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_3.Name = "pic_ageRate_3"; this.pic_ageRate_3.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_3.TabIndex = 328; @@ -437,7 +437,7 @@ // this.pic_stability_3.BackColor = System.Drawing.Color.Transparent; this.pic_stability_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_3.Location = new System.Drawing.Point(85, 8); + this.pic_stability_3.Location = new System.Drawing.Point(12, 8); this.pic_stability_3.Name = "pic_stability_3"; this.pic_stability_3.Size = new System.Drawing.Size(16, 16); this.pic_stability_3.TabIndex = 325; @@ -447,7 +447,7 @@ // this.pic_accuracy_3.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_3.Location = new System.Drawing.Point(224, 8); + this.pic_accuracy_3.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_3.Name = "pic_accuracy_3"; this.pic_accuracy_3.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_3.TabIndex = 326; @@ -457,7 +457,7 @@ // this.pic_bootFeature_3.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_3.Location = new System.Drawing.Point(8, 8); + this.pic_bootFeature_3.Location = new System.Drawing.Point(151, 8); this.pic_bootFeature_3.Name = "pic_bootFeature_3"; this.pic_bootFeature_3.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_3.TabIndex = 327; @@ -480,7 +480,7 @@ // this.pic_ageRate_2.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_2.Location = new System.Drawing.Point(151, 7); + this.pic_ageRate_2.Location = new System.Drawing.Point(224, 7); this.pic_ageRate_2.Name = "pic_ageRate_2"; this.pic_ageRate_2.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_2.TabIndex = 324; @@ -490,7 +490,7 @@ // this.pic_stability_2.BackColor = System.Drawing.Color.Transparent; this.pic_stability_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_2.Location = new System.Drawing.Point(85, 7); + this.pic_stability_2.Location = new System.Drawing.Point(12, 7); this.pic_stability_2.Name = "pic_stability_2"; this.pic_stability_2.Size = new System.Drawing.Size(16, 16); this.pic_stability_2.TabIndex = 321; @@ -500,7 +500,7 @@ // this.pic_accuracy_2.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_2.Location = new System.Drawing.Point(224, 7); + this.pic_accuracy_2.Location = new System.Drawing.Point(78, 7); this.pic_accuracy_2.Name = "pic_accuracy_2"; this.pic_accuracy_2.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_2.TabIndex = 322; @@ -510,7 +510,7 @@ // this.pic_bootFeature_2.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_2.Location = new System.Drawing.Point(8, 7); + this.pic_bootFeature_2.Location = new System.Drawing.Point(151, 7); this.pic_bootFeature_2.Name = "pic_bootFeature_2"; this.pic_bootFeature_2.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_2.TabIndex = 323; @@ -533,7 +533,7 @@ // this.pic_ageRate_1.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_1.Location = new System.Drawing.Point(151, 8); + this.pic_ageRate_1.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_1.Name = "pic_ageRate_1"; this.pic_ageRate_1.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_1.TabIndex = 320; @@ -543,7 +543,7 @@ // this.pic_stability_1.BackColor = System.Drawing.Color.Transparent; this.pic_stability_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_1.Location = new System.Drawing.Point(85, 8); + this.pic_stability_1.Location = new System.Drawing.Point(12, 8); this.pic_stability_1.Name = "pic_stability_1"; this.pic_stability_1.Size = new System.Drawing.Size(16, 16); this.pic_stability_1.TabIndex = 317; @@ -553,7 +553,7 @@ // this.pic_accuracy_1.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_1.Location = new System.Drawing.Point(224, 8); + this.pic_accuracy_1.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_1.Name = "pic_accuracy_1"; this.pic_accuracy_1.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_1.TabIndex = 318; @@ -563,7 +563,7 @@ // this.pic_bootFeature_1.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_1.Location = new System.Drawing.Point(7, 8); + this.pic_bootFeature_1.Location = new System.Drawing.Point(150, 8); this.pic_bootFeature_1.Name = "pic_bootFeature_1"; this.pic_bootFeature_1.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_1.TabIndex = 319; @@ -598,7 +598,7 @@ dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.dataGridView_Channel.DefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_Channel.GridColor = System.Drawing.Color.DarkGray; - this.dataGridView_Channel.Location = new System.Drawing.Point(10, 10); + this.dataGridView_Channel.Location = new System.Drawing.Point(11, 10); this.dataGridView_Channel.Margin = new System.Windows.Forms.Padding(0); this.dataGridView_Channel.MultiSelect = false; this.dataGridView_Channel.Name = "dataGridView_Channel"; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index 5d75f74..ca3181d 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -60,6 +60,8 @@ label_clockStatus.Text = FreshStatus.clockStatus; label_receiverStatus.Text = StatusCtrlForm.receiverStatus; } + + } private void HomeCtrlForm_Load(object sender, EventArgs e) @@ -421,22 +423,6 @@ dataGridView_Channel.Controls.Add(colStatus); colStatus.BringToFront(); - // 开机特性 - Label colStartup = 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(colStartup); - colStartup.BringToFront(); - // 频率稳定度 Label colStablility = new Label { @@ -446,25 +432,13 @@ BackColor = titleBackColor, AutoSize = false, Text = "稳定度", - Location = new Point(759, 0), + + Location = new Point(684,0), Size = new Size(75, 30) }; dataGridView_Channel.Controls.Add(colStablility); colStablility.BringToFront(); - // 日老化率 - Label colAgingRate = 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) - }; - // 频率准确度 Label colAccuracy = new Label { @@ -474,11 +448,45 @@ BackColor = titleBackColor, AutoSize = false, Text = "准确度", - Location = new Point(899, 0), + 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) + }; + + @@ -506,142 +514,162 @@ } public void LoadChannelStatus() { - channelsTable = new DataTable(); - - channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); - channelsTable.Columns.Add("devName", Type.GetType("System.String")); - channelsTable.Columns.Add("devCode", Type.GetType("System.String")); - channelsTable.Columns.Add("customComp", Type.GetType("System.String")); - channelsTable.Columns.Add("startTime", Type.GetType("System.String")); - channelsTable.Columns.Add("endTime", Type.GetType("System.String")); - channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); - channelsTable.Columns.Add("startup", Type.GetType("System.String")); - channelsTable.Columns.Add("stablility", Type.GetType("System.String")); - channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); - channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); - channelsTable.Columns.Add("deviceId", Type.GetType("System.Int32")); - //channelsTable.Columns.Add("devType", Type.GetType("System.String")); - //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); - //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); - - listChannelStatus = deviceService.getDeviceByChannel(); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - if (listChannelStatus != null && listChannelStatus.Count > 0) + try { - foreach (DeviceView device in listChannelStatus) + channelsTable = new DataTable(); + + channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); + channelsTable.Columns.Add("devName", Type.GetType("System.String")); + channelsTable.Columns.Add("devCode", Type.GetType("System.String")); + channelsTable.Columns.Add("customComp", Type.GetType("System.String")); + channelsTable.Columns.Add("startTime", Type.GetType("System.String")); + channelsTable.Columns.Add("endTime", Type.GetType("System.String")); + channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); + channelsTable.Columns.Add("stablility", Type.GetType("System.String")); + channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); + channelsTable.Columns.Add("startup", Type.GetType("System.String")); + channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); + channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); + channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); + //channelsTable.Columns.Add("devType", Type.GetType("System.String")); + //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); + //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); + + listChannelStatus = deviceService.getDeviceByChannel(); + + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); + + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); - int index = Convert.ToInt32(device.Channel) - 1; - channelsTable.Rows[index]["channelNo"] = device.Channel; - channelsTable.Rows[index]["devName"] = device.DevName; - channelsTable.Rows[index]["devCode"] = device.DevCode; - channelsTable.Rows[index]["customComp"] = device.CustomerDev; - channelsTable.Rows[index]["startTime"] = device.StartTime; - channelsTable.Rows[index]["endTime"] = device.EndTime; - channelsTable.Rows[index]["channelStatus"] = "占用"; - channelsTable.Rows[index]["deviceId"] = device.Id; - if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + int index = Convert.ToInt32(device.Channel) - 1; + channelsTable.Rows[index]["channelNo"] = device.Channel; + channelsTable.Rows[index]["devName"] = device.DevName; + channelsTable.Rows[index]["devCode"] = device.DevCode; + channelsTable.Rows[index]["customComp"] = device.CustomerDev; + channelsTable.Rows[index]["startTime"] = device.StartTime; + channelsTable.Rows[index]["endTime"] = device.EndTime; + channelsTable.Rows[index]["channelStatus"] = "占用"; + channelsTable.Rows[index]["deviceId"] = device.Id; + channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; + + if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + } } + else + { + channelsTable.Rows.Clear(); + channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); + } + + foreach (string no in channelFreeList) + { + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; + } + + + dataGridView_Channel.DataSource = channelsTable; + + // width=764px + dataGridView_Channel.Columns[11].Visible = false; + dataGridView_Channel.Columns[12].Visible = false; + dataGridView_Channel.Columns[0].Width = 50; + dataGridView_Channel.Columns[1].Width = 110; + dataGridView_Channel.Columns[2].Width = 110; + dataGridView_Channel.Columns[3].Width = 110; + dataGridView_Channel.Columns[4].Width = 120; + dataGridView_Channel.Columns[5].Width = 120; + dataGridView_Channel.Columns[6].Width = 64; + dataGridView_Channel.Columns[7].Width = 75; + dataGridView_Channel.Columns[8].Width = 75; + dataGridView_Channel.Columns[9].Width = 75; + dataGridView_Channel.Columns[10].Width = 75; + + dataGridView_Channel.Columns[0].ReadOnly = true; + dataGridView_Channel.Columns[1].ReadOnly = true; + dataGridView_Channel.Columns[2].ReadOnly = true; + dataGridView_Channel.Columns[3].ReadOnly = true; + dataGridView_Channel.Columns[4].ReadOnly = true; + dataGridView_Channel.Columns[5].ReadOnly = true; + dataGridView_Channel.Columns[6].ReadOnly = true; + dataGridView_Channel.Columns[7].ReadOnly = true; + dataGridView_Channel.Columns[8].ReadOnly = true; + dataGridView_Channel.Columns[9].ReadOnly = true; + dataGridView_Channel.Columns[10].ReadOnly = true; } - else + catch (Exception ex) { - channelsTable.Rows.Clear(); - channelsTable.Rows.Add("1","","","","","","空闲",""); - channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", ""); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "LoadChannelStatus 错误:" + ex.Message); + } - - foreach (string no in channelFreeList) - { - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; - } - - - dataGridView_Channel.DataSource = channelsTable; - - // width=764px - dataGridView_Channel.Columns[11].Visible = false; - dataGridView_Channel.Columns[0].Width = 50; - dataGridView_Channel.Columns[1].Width = 110; - dataGridView_Channel.Columns[2].Width = 110; - dataGridView_Channel.Columns[3].Width = 110; - dataGridView_Channel.Columns[4].Width = 120; - dataGridView_Channel.Columns[5].Width = 120; - dataGridView_Channel.Columns[6].Width = 64; - dataGridView_Channel.Columns[7].Width = 75; - dataGridView_Channel.Columns[8].Width = 75; - dataGridView_Channel.Columns[9].Width = 75; - dataGridView_Channel.Columns[10].Width = 75; - - dataGridView_Channel.Columns[0].ReadOnly = true; - dataGridView_Channel.Columns[1].ReadOnly = true; - dataGridView_Channel.Columns[2].ReadOnly = true; - dataGridView_Channel.Columns[3].ReadOnly = true; - dataGridView_Channel.Columns[4].ReadOnly = true; - dataGridView_Channel.Columns[5].ReadOnly = true; - dataGridView_Channel.Columns[6].ReadOnly = true; - dataGridView_Channel.Columns[7].ReadOnly = true; - dataGridView_Channel.Columns[8].ReadOnly = true; - dataGridView_Channel.Columns[9].ReadOnly = true; - dataGridView_Channel.Columns[10].ReadOnly = true; - } private void dataGridView_Channel_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) - { - dataGridView_Channel.ClearSelection(); + { + try + { + dataGridView_Channel.ClearSelection(); - int channelNo = e.RowIndex + 1; - if (channelFreeList.Contains(channelNo + "")) - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + int channelNo = e.RowIndex + 1; + if (channelFreeList.Contains(channelNo + "")) + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + } + else + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + } + foreach (string no in channelFreeList) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } } - else + catch (Exception ex) { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - } - foreach (string no in channelFreeList) - { - 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, "dataGridView_Channel_RowPostPaint 错误:" + ex.Message); + } } @@ -701,7 +729,8 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - int deviceId = (int)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + 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) @@ -712,11 +741,11 @@ DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { - detectionItemService.stopDetection(deviceId, startTime, endTime, false); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); } else { - detectionItemService.stopDetection(deviceId, startTime, endTime, true); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); } LoadChannelStatus(); LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 6aaa532..f99f106 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -132,16 +132,16 @@ return; } timePicker_endTime.Value = endTimeBySystem; - + // 打开串口 DetectionHelper detectionHelper = new DetectionHelper(); - + SerialPort port = RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1]; string portName = ConfigHelper.GetAppConfig("channel" + textBox_channelNo.Text).Split(' ')[0]; int band = Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + textBox_channelNo.Text).Split(' ')[1]); if (port.IsOpen) port.Close(); - + port.PortName = portName; port.BaudRate = band; port.Parity = Parity.None; @@ -159,12 +159,12 @@ return; } } - catch(Exception exc) + catch (Exception exc) { MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } - + if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); @@ -321,7 +321,7 @@ else if (checkBox10s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101 * 10).AddSeconds(40); else if (checkBox1s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101).AddSeconds(40); } - else endTimeBySystem = DateTime.Now.AddMinutes(1).AddSeconds(30); + else endTimeBySystem = timePicker_startTime.Value.AddMinutes(1).AddSeconds(30); } } diff --git a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs index ec02ee3..ba3c1cf 100644 --- a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs +++ b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs @@ -51,6 +51,7 @@ private String accuracy; private String bootFeature; private String ageRate; + private long detectionItemId; public long Id { @@ -251,5 +252,6 @@ public string Accuracy { get => accuracy; set => accuracy = value; } public string BootFeature { get => bootFeature; set => bootFeature = value; } public string AgeRate { get => ageRate; set => ageRate = value; } + public long DetectionItemId { get => detectionItemId; set => detectionItemId = value; } } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 3fe0773..64253a7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -16,7 +16,7 @@ List search(long deviceId, bool isInDetection); - int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData); + int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); 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 5c4cda2..b849d77 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -115,6 +115,56 @@ } return iRetval; } + public int startDetect(long detectionItemId, string stability, string accuracy, string bootFeature, string ageRate) + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + if (stability.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + + string sQry = "UPDATE r_detection_item SET"; + if (!stability.Equals("")) + sQry = sQry + " STABILITY=@STABILITY"; + if (!accuracy.Equals("")) + sQry = sQry + " ACCURACY=@ACCURACY"; + if (!bootFeature.Equals("")) + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + if (!ageRate.Equals("")) + sQry = sQry + " AGE_RATE=@AGE_RATE"; + sQry = sQry + " where ID = " + detectionItemId; + + + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; + cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; + cmd.Parameters.Add("@BOOT_FEATURE", MySqlDbType.String, 10).Value = bootFeature; + cmd.Parameters.Add("@AGE_RATE", MySqlDbType.String, 10).Value = ageRate; + + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + iRetval = 0; + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + iRetval = -1; + } + + return iRetval; + } public int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100) { @@ -134,28 +184,28 @@ } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stability : "+ stability); string sQry = "UPDATE r_detection_item SET"; if(!stability.Equals("")) - sQry = sQry + " STABILITY=@STABILITY"; + sQry = sQry + " STABILITY=@STABILITY,"; if (!accuracy.Equals("")) - sQry = sQry + " ACCURACY=@ACCURACY"; + sQry = sQry + " ACCURACY=@ACCURACY,"; if (!bootFeature.Equals("")) - sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE,"; if (!ageRate.Equals("")) - sQry = sQry + " AGE_RATE=@AGE_RATE"; - if (!counterDetec.Equals("")) - sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC"; + sQry = sQry + " AGE_RATE=@AGE_RATE,"; if (!stability1.Equals("")) - sQry = sQry + " STABILITY_1=@STABILITY_1"; + sQry = sQry + " STABILITY_1=@STABILITY_1,"; if (!stability10.Equals("")) - sQry = sQry + " STABILITY_10=@STABILITY_10"; + sQry = sQry + " STABILITY_10=@STABILITY_10,"; if (!stability20.Equals("")) - sQry = sQry + " STABILITY_20=@STABILITY_20"; + sQry = sQry + " STABILITY_20=@STABILITY_20,"; if (!stability100.Equals("")) - sQry = sQry + " STABILITY_100=@STABILITY_100"; - sQry = sQry + " where ID = " + detectionId; + sQry = sQry + " STABILITY_100=@STABILITY_100,"; + sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; @@ -220,7 +270,7 @@ return iRetval; } - public int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData) + public int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData) { int iRetval = -1; try @@ -241,17 +291,25 @@ cmd.Parameters.Add("@CHANNEL", MySqlDbType.String, 20).Value = ""; cmd.ExecuteNonQuery(); + if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime + "' and '" + endTime + "')"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } + else + { + sQry = "UPDATE r_detection_item SET END_TIME=@END_TIME WHERE ID="+ detectionItemId; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@END_TIME", MySqlDbType.DateTime, 20).Value = DateTime.Now; + cmd.ExecuteNonQuery(); + } cmd.Dispose(); iRetval = 0; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 8773cb6..2de0df9 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -87,7 +87,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry + "; statusId="+ statusId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -101,9 +101,6 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); - - iRetval = 0; } catch (MySqlException ex) @@ -205,7 +202,7 @@ if (!aReader.IsDBNull(7)) deviceDto.CustomerDev = aReader.GetString(7); if (!aReader.IsDBNull(8)) { - deviceDto.StatusId = aReader.GetString(7); + deviceDto.StatusId = aReader.GetString(8); } if (!aReader.IsDBNull(9)) deviceDto.Channel = aReader.GetString(9); @@ -481,7 +478,7 @@ } } - string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 "; + string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -523,7 +520,7 @@ if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - + if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); deviceViewList.Add(deviceView); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index ff6a679..1626aa5 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -27,7 +27,7 @@ } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index e1b99b2..936cc37 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -224,7 +224,19 @@ } private void SelectCounter() { - + // 移除所有按钮的选中样式 + ClearAllMenuSelected(); + + // 鼠标移入效果去掉 + LeaveCounter(); + + // 重新设置所有按钮的状态 + menuSelected = new bool[] { false, false, false, true, false, false }; + + // 将新选中的按钮设置为选中 + picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + labCounterText.ForeColor = menuSelectedColor; + labCounterSelected.BackColor = menuSelectedColor; // 切换到频率计数器的界面 switchMainPanel(3); @@ -242,10 +254,16 @@ } private void SelectData() { + //if (CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // return; + //} // 移除所有按钮的选中样式 ClearAllMenuSelected(); // 鼠标移入效果去掉 + LeaveData(); // 重新设置所有按钮的状态 @@ -331,6 +349,19 @@ portList.Add(new SerialPort()); portList.Add(new SerialPort()); portList.Add(new SerialPort()); + DeviceService deviceService = new DeviceServiceImpl(); + DetectionItemService detectionItemService = new DetectionItemServiceImpl(); + List listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + long deviceId = device.Id; + string startTime = device.StartTime; + string endTime = device.EndTime; + detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); + } + } } else { @@ -500,24 +531,24 @@ private void switchMainPanel(int index) { - if (index != 3 && CounterCtrlForm.isDetecting) - { - MessageBox.Show("正在检测计数器,无法离开当前界面!"); - // 移除所有按钮的选中样式 - ClearAllMenuSelected(); + //if (index != 3 && CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // // 移除所有按钮的选中样式 + // ClearAllMenuSelected(); - // 鼠标移入效果去掉 - LeaveCounter(); + // // 鼠标移入效果去掉 + // LeaveCounter(); - // 重新设置所有按钮的状态 - menuSelected = new bool[] { false, false, false, true, false, false }; + // // 重新设置所有按钮的状态 + // menuSelected = new bool[] { false, false, false, true, false, false }; - // 将新选中的按钮设置为选中 - picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); - labCounterText.ForeColor = menuSelectedColor; - labCounterSelected.BackColor = menuSelectedColor; - return; - } + // // 将新选中的按钮设置为选中 + // picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + // labCounterText.ForeColor = menuSelectedColor; + // labCounterSelected.BackColor = menuSelectedColor; + // return; + //} panelMain.Controls.Clear(); switch (index) { diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index ecbb7e2..4405d66 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index 36ae30d..fd7ffee 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -111,7 +111,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), + Location = new Point(48, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); @@ -126,27 +126,12 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), + Location = new Point(142, 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 { @@ -156,7 +141,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(247, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -171,7 +156,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), + Location = new Point(360, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colValue); @@ -186,7 +171,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), + Location = new Point(465, 0), Size = new Size(95, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); @@ -280,6 +265,7 @@ dataGridView_CounterResult.DataSource = table_counterDetecInit; + dataGridView_CounterResult.Columns[3].Visible = false; dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; @@ -287,11 +273,10 @@ dataGridView_CounterResult.Columns[0].Width = 50; dataGridView_CounterResult.Columns[1].Width = 95; dataGridView_CounterResult.Columns[2].Width = 95; - 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[4].Width = 110; + dataGridView_CounterResult.Columns[5].Width = 110; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -773,17 +758,30 @@ 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 (!regex.IsMatch(value)) + if (textBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + dataGridView_CounterResult.CurrentCell.Value = ""; + MessageBox.Show("请输入格式正确的、带单位的测量频率!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + dataGridView_CounterResult.CurrentCell.Value = ""; + MessageBox.Show("请输入格式正确的、带单位的测量周期!"); + return; + } + } } } diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index fcefb48..09d1e4a 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -321,7 +321,7 @@ // this.pic_ageRate_5.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_5.Location = new System.Drawing.Point(151, 9); + this.pic_ageRate_5.Location = new System.Drawing.Point(224, 9); this.pic_ageRate_5.Name = "pic_ageRate_5"; this.pic_ageRate_5.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_5.TabIndex = 336; @@ -331,7 +331,7 @@ // this.pic_stability_5.BackColor = System.Drawing.Color.Transparent; this.pic_stability_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_5.Location = new System.Drawing.Point(85, 9); + this.pic_stability_5.Location = new System.Drawing.Point(12, 9); this.pic_stability_5.Name = "pic_stability_5"; this.pic_stability_5.Size = new System.Drawing.Size(16, 16); this.pic_stability_5.TabIndex = 333; @@ -341,7 +341,7 @@ // this.pic_accuracy_5.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_5.Location = new System.Drawing.Point(224, 9); + this.pic_accuracy_5.Location = new System.Drawing.Point(78, 9); this.pic_accuracy_5.Name = "pic_accuracy_5"; this.pic_accuracy_5.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_5.TabIndex = 334; @@ -351,7 +351,7 @@ // this.pic_bootFeature_5.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_5.Location = new System.Drawing.Point(9, 9); + this.pic_bootFeature_5.Location = new System.Drawing.Point(152, 9); this.pic_bootFeature_5.Name = "pic_bootFeature_5"; this.pic_bootFeature_5.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_5.TabIndex = 335; @@ -374,7 +374,7 @@ // this.pic_ageRate_4.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_4.Location = new System.Drawing.Point(151, 10); + this.pic_ageRate_4.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_4.Name = "pic_ageRate_4"; this.pic_ageRate_4.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_4.TabIndex = 332; @@ -384,7 +384,7 @@ // this.pic_stability_4.BackColor = System.Drawing.Color.Transparent; this.pic_stability_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_stability_4.Location = new System.Drawing.Point(85, 10); + this.pic_stability_4.Location = new System.Drawing.Point(12, 8); this.pic_stability_4.Name = "pic_stability_4"; this.pic_stability_4.Size = new System.Drawing.Size(16, 16); this.pic_stability_4.TabIndex = 329; @@ -394,7 +394,7 @@ // this.pic_accuracy_4.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_4.Location = new System.Drawing.Point(224, 10); + this.pic_accuracy_4.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_4.Name = "pic_accuracy_4"; this.pic_accuracy_4.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_4.TabIndex = 330; @@ -404,7 +404,7 @@ // this.pic_bootFeature_4.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_4.Location = new System.Drawing.Point(9, 10); + this.pic_bootFeature_4.Location = new System.Drawing.Point(152, 8); this.pic_bootFeature_4.Name = "pic_bootFeature_4"; this.pic_bootFeature_4.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_4.TabIndex = 331; @@ -427,7 +427,7 @@ // this.pic_ageRate_3.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_3.Location = new System.Drawing.Point(151, 8); + this.pic_ageRate_3.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_3.Name = "pic_ageRate_3"; this.pic_ageRate_3.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_3.TabIndex = 328; @@ -437,7 +437,7 @@ // this.pic_stability_3.BackColor = System.Drawing.Color.Transparent; this.pic_stability_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_3.Location = new System.Drawing.Point(85, 8); + this.pic_stability_3.Location = new System.Drawing.Point(12, 8); this.pic_stability_3.Name = "pic_stability_3"; this.pic_stability_3.Size = new System.Drawing.Size(16, 16); this.pic_stability_3.TabIndex = 325; @@ -447,7 +447,7 @@ // this.pic_accuracy_3.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_3.Location = new System.Drawing.Point(224, 8); + this.pic_accuracy_3.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_3.Name = "pic_accuracy_3"; this.pic_accuracy_3.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_3.TabIndex = 326; @@ -457,7 +457,7 @@ // this.pic_bootFeature_3.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_3.Location = new System.Drawing.Point(8, 8); + this.pic_bootFeature_3.Location = new System.Drawing.Point(151, 8); this.pic_bootFeature_3.Name = "pic_bootFeature_3"; this.pic_bootFeature_3.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_3.TabIndex = 327; @@ -480,7 +480,7 @@ // this.pic_ageRate_2.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_2.Location = new System.Drawing.Point(151, 7); + this.pic_ageRate_2.Location = new System.Drawing.Point(224, 7); this.pic_ageRate_2.Name = "pic_ageRate_2"; this.pic_ageRate_2.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_2.TabIndex = 324; @@ -490,7 +490,7 @@ // this.pic_stability_2.BackColor = System.Drawing.Color.Transparent; this.pic_stability_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_2.Location = new System.Drawing.Point(85, 7); + this.pic_stability_2.Location = new System.Drawing.Point(12, 7); this.pic_stability_2.Name = "pic_stability_2"; this.pic_stability_2.Size = new System.Drawing.Size(16, 16); this.pic_stability_2.TabIndex = 321; @@ -500,7 +500,7 @@ // this.pic_accuracy_2.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_2.Location = new System.Drawing.Point(224, 7); + this.pic_accuracy_2.Location = new System.Drawing.Point(78, 7); this.pic_accuracy_2.Name = "pic_accuracy_2"; this.pic_accuracy_2.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_2.TabIndex = 322; @@ -510,7 +510,7 @@ // this.pic_bootFeature_2.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_2.Location = new System.Drawing.Point(8, 7); + this.pic_bootFeature_2.Location = new System.Drawing.Point(151, 7); this.pic_bootFeature_2.Name = "pic_bootFeature_2"; this.pic_bootFeature_2.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_2.TabIndex = 323; @@ -533,7 +533,7 @@ // this.pic_ageRate_1.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_1.Location = new System.Drawing.Point(151, 8); + this.pic_ageRate_1.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_1.Name = "pic_ageRate_1"; this.pic_ageRate_1.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_1.TabIndex = 320; @@ -543,7 +543,7 @@ // this.pic_stability_1.BackColor = System.Drawing.Color.Transparent; this.pic_stability_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_1.Location = new System.Drawing.Point(85, 8); + this.pic_stability_1.Location = new System.Drawing.Point(12, 8); this.pic_stability_1.Name = "pic_stability_1"; this.pic_stability_1.Size = new System.Drawing.Size(16, 16); this.pic_stability_1.TabIndex = 317; @@ -553,7 +553,7 @@ // this.pic_accuracy_1.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_1.Location = new System.Drawing.Point(224, 8); + this.pic_accuracy_1.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_1.Name = "pic_accuracy_1"; this.pic_accuracy_1.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_1.TabIndex = 318; @@ -563,7 +563,7 @@ // this.pic_bootFeature_1.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_1.Location = new System.Drawing.Point(7, 8); + this.pic_bootFeature_1.Location = new System.Drawing.Point(150, 8); this.pic_bootFeature_1.Name = "pic_bootFeature_1"; this.pic_bootFeature_1.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_1.TabIndex = 319; @@ -598,7 +598,7 @@ dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.dataGridView_Channel.DefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_Channel.GridColor = System.Drawing.Color.DarkGray; - this.dataGridView_Channel.Location = new System.Drawing.Point(10, 10); + this.dataGridView_Channel.Location = new System.Drawing.Point(11, 10); this.dataGridView_Channel.Margin = new System.Windows.Forms.Padding(0); this.dataGridView_Channel.MultiSelect = false; this.dataGridView_Channel.Name = "dataGridView_Channel"; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index 5d75f74..ca3181d 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -60,6 +60,8 @@ label_clockStatus.Text = FreshStatus.clockStatus; label_receiverStatus.Text = StatusCtrlForm.receiverStatus; } + + } private void HomeCtrlForm_Load(object sender, EventArgs e) @@ -421,22 +423,6 @@ dataGridView_Channel.Controls.Add(colStatus); colStatus.BringToFront(); - // 开机特性 - Label colStartup = 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(colStartup); - colStartup.BringToFront(); - // 频率稳定度 Label colStablility = new Label { @@ -446,25 +432,13 @@ BackColor = titleBackColor, AutoSize = false, Text = "稳定度", - Location = new Point(759, 0), + + Location = new Point(684,0), Size = new Size(75, 30) }; dataGridView_Channel.Controls.Add(colStablility); colStablility.BringToFront(); - // 日老化率 - Label colAgingRate = 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) - }; - // 频率准确度 Label colAccuracy = new Label { @@ -474,11 +448,45 @@ BackColor = titleBackColor, AutoSize = false, Text = "准确度", - Location = new Point(899, 0), + 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) + }; + + @@ -506,142 +514,162 @@ } public void LoadChannelStatus() { - channelsTable = new DataTable(); - - channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); - channelsTable.Columns.Add("devName", Type.GetType("System.String")); - channelsTable.Columns.Add("devCode", Type.GetType("System.String")); - channelsTable.Columns.Add("customComp", Type.GetType("System.String")); - channelsTable.Columns.Add("startTime", Type.GetType("System.String")); - channelsTable.Columns.Add("endTime", Type.GetType("System.String")); - channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); - channelsTable.Columns.Add("startup", Type.GetType("System.String")); - channelsTable.Columns.Add("stablility", Type.GetType("System.String")); - channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); - channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); - channelsTable.Columns.Add("deviceId", Type.GetType("System.Int32")); - //channelsTable.Columns.Add("devType", Type.GetType("System.String")); - //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); - //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); - - listChannelStatus = deviceService.getDeviceByChannel(); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - if (listChannelStatus != null && listChannelStatus.Count > 0) + try { - foreach (DeviceView device in listChannelStatus) + channelsTable = new DataTable(); + + channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); + channelsTable.Columns.Add("devName", Type.GetType("System.String")); + channelsTable.Columns.Add("devCode", Type.GetType("System.String")); + channelsTable.Columns.Add("customComp", Type.GetType("System.String")); + channelsTable.Columns.Add("startTime", Type.GetType("System.String")); + channelsTable.Columns.Add("endTime", Type.GetType("System.String")); + channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); + channelsTable.Columns.Add("stablility", Type.GetType("System.String")); + channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); + channelsTable.Columns.Add("startup", Type.GetType("System.String")); + channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); + channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); + channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); + //channelsTable.Columns.Add("devType", Type.GetType("System.String")); + //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); + //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); + + listChannelStatus = deviceService.getDeviceByChannel(); + + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); + + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); - int index = Convert.ToInt32(device.Channel) - 1; - channelsTable.Rows[index]["channelNo"] = device.Channel; - channelsTable.Rows[index]["devName"] = device.DevName; - channelsTable.Rows[index]["devCode"] = device.DevCode; - channelsTable.Rows[index]["customComp"] = device.CustomerDev; - channelsTable.Rows[index]["startTime"] = device.StartTime; - channelsTable.Rows[index]["endTime"] = device.EndTime; - channelsTable.Rows[index]["channelStatus"] = "占用"; - channelsTable.Rows[index]["deviceId"] = device.Id; - if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + int index = Convert.ToInt32(device.Channel) - 1; + channelsTable.Rows[index]["channelNo"] = device.Channel; + channelsTable.Rows[index]["devName"] = device.DevName; + channelsTable.Rows[index]["devCode"] = device.DevCode; + channelsTable.Rows[index]["customComp"] = device.CustomerDev; + channelsTable.Rows[index]["startTime"] = device.StartTime; + channelsTable.Rows[index]["endTime"] = device.EndTime; + channelsTable.Rows[index]["channelStatus"] = "占用"; + channelsTable.Rows[index]["deviceId"] = device.Id; + channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; + + if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + } } + else + { + channelsTable.Rows.Clear(); + channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); + } + + foreach (string no in channelFreeList) + { + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; + } + + + dataGridView_Channel.DataSource = channelsTable; + + // width=764px + dataGridView_Channel.Columns[11].Visible = false; + dataGridView_Channel.Columns[12].Visible = false; + dataGridView_Channel.Columns[0].Width = 50; + dataGridView_Channel.Columns[1].Width = 110; + dataGridView_Channel.Columns[2].Width = 110; + dataGridView_Channel.Columns[3].Width = 110; + dataGridView_Channel.Columns[4].Width = 120; + dataGridView_Channel.Columns[5].Width = 120; + dataGridView_Channel.Columns[6].Width = 64; + dataGridView_Channel.Columns[7].Width = 75; + dataGridView_Channel.Columns[8].Width = 75; + dataGridView_Channel.Columns[9].Width = 75; + dataGridView_Channel.Columns[10].Width = 75; + + dataGridView_Channel.Columns[0].ReadOnly = true; + dataGridView_Channel.Columns[1].ReadOnly = true; + dataGridView_Channel.Columns[2].ReadOnly = true; + dataGridView_Channel.Columns[3].ReadOnly = true; + dataGridView_Channel.Columns[4].ReadOnly = true; + dataGridView_Channel.Columns[5].ReadOnly = true; + dataGridView_Channel.Columns[6].ReadOnly = true; + dataGridView_Channel.Columns[7].ReadOnly = true; + dataGridView_Channel.Columns[8].ReadOnly = true; + dataGridView_Channel.Columns[9].ReadOnly = true; + dataGridView_Channel.Columns[10].ReadOnly = true; } - else + catch (Exception ex) { - channelsTable.Rows.Clear(); - channelsTable.Rows.Add("1","","","","","","空闲",""); - channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", ""); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "LoadChannelStatus 错误:" + ex.Message); + } - - foreach (string no in channelFreeList) - { - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; - } - - - dataGridView_Channel.DataSource = channelsTable; - - // width=764px - dataGridView_Channel.Columns[11].Visible = false; - dataGridView_Channel.Columns[0].Width = 50; - dataGridView_Channel.Columns[1].Width = 110; - dataGridView_Channel.Columns[2].Width = 110; - dataGridView_Channel.Columns[3].Width = 110; - dataGridView_Channel.Columns[4].Width = 120; - dataGridView_Channel.Columns[5].Width = 120; - dataGridView_Channel.Columns[6].Width = 64; - dataGridView_Channel.Columns[7].Width = 75; - dataGridView_Channel.Columns[8].Width = 75; - dataGridView_Channel.Columns[9].Width = 75; - dataGridView_Channel.Columns[10].Width = 75; - - dataGridView_Channel.Columns[0].ReadOnly = true; - dataGridView_Channel.Columns[1].ReadOnly = true; - dataGridView_Channel.Columns[2].ReadOnly = true; - dataGridView_Channel.Columns[3].ReadOnly = true; - dataGridView_Channel.Columns[4].ReadOnly = true; - dataGridView_Channel.Columns[5].ReadOnly = true; - dataGridView_Channel.Columns[6].ReadOnly = true; - dataGridView_Channel.Columns[7].ReadOnly = true; - dataGridView_Channel.Columns[8].ReadOnly = true; - dataGridView_Channel.Columns[9].ReadOnly = true; - dataGridView_Channel.Columns[10].ReadOnly = true; - } private void dataGridView_Channel_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) - { - dataGridView_Channel.ClearSelection(); + { + try + { + dataGridView_Channel.ClearSelection(); - int channelNo = e.RowIndex + 1; - if (channelFreeList.Contains(channelNo + "")) - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + int channelNo = e.RowIndex + 1; + if (channelFreeList.Contains(channelNo + "")) + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + } + else + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + } + foreach (string no in channelFreeList) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } } - else + catch (Exception ex) { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - } - foreach (string no in channelFreeList) - { - 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, "dataGridView_Channel_RowPostPaint 错误:" + ex.Message); + } } @@ -701,7 +729,8 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - int deviceId = (int)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + 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) @@ -712,11 +741,11 @@ DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { - detectionItemService.stopDetection(deviceId, startTime, endTime, false); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); } else { - detectionItemService.stopDetection(deviceId, startTime, endTime, true); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); } LoadChannelStatus(); LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 6aaa532..f99f106 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -132,16 +132,16 @@ return; } timePicker_endTime.Value = endTimeBySystem; - + // 打开串口 DetectionHelper detectionHelper = new DetectionHelper(); - + SerialPort port = RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1]; string portName = ConfigHelper.GetAppConfig("channel" + textBox_channelNo.Text).Split(' ')[0]; int band = Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + textBox_channelNo.Text).Split(' ')[1]); if (port.IsOpen) port.Close(); - + port.PortName = portName; port.BaudRate = band; port.Parity = Parity.None; @@ -159,12 +159,12 @@ return; } } - catch(Exception exc) + catch (Exception exc) { MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } - + if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); @@ -321,7 +321,7 @@ else if (checkBox10s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101 * 10).AddSeconds(40); else if (checkBox1s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101).AddSeconds(40); } - else endTimeBySystem = DateTime.Now.AddMinutes(1).AddSeconds(30); + else endTimeBySystem = timePicker_startTime.Value.AddMinutes(1).AddSeconds(30); } } diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 1bb08ca..1a82d85 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -287,7 +287,7 @@ else if (checkBox10s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101 * 10).AddSeconds(40); else if (checkBox1s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101).AddSeconds(40); } - else endTimeBySystem = DateTime.Now.AddMinutes(1).AddSeconds(30); + else endTimeBySystem = timePicker_startTime.Value.AddMinutes(1).AddSeconds(30); } } timePicker_endTime.Value = endTimeBySystem; diff --git a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs index ec02ee3..ba3c1cf 100644 --- a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs +++ b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs @@ -51,6 +51,7 @@ private String accuracy; private String bootFeature; private String ageRate; + private long detectionItemId; public long Id { @@ -251,5 +252,6 @@ public string Accuracy { get => accuracy; set => accuracy = value; } public string BootFeature { get => bootFeature; set => bootFeature = value; } public string AgeRate { get => ageRate; set => ageRate = value; } + public long DetectionItemId { get => detectionItemId; set => detectionItemId = value; } } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 3fe0773..64253a7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -16,7 +16,7 @@ List search(long deviceId, bool isInDetection); - int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData); + int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); 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 5c4cda2..b849d77 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -115,6 +115,56 @@ } return iRetval; } + public int startDetect(long detectionItemId, string stability, string accuracy, string bootFeature, string ageRate) + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + if (stability.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + + string sQry = "UPDATE r_detection_item SET"; + if (!stability.Equals("")) + sQry = sQry + " STABILITY=@STABILITY"; + if (!accuracy.Equals("")) + sQry = sQry + " ACCURACY=@ACCURACY"; + if (!bootFeature.Equals("")) + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + if (!ageRate.Equals("")) + sQry = sQry + " AGE_RATE=@AGE_RATE"; + sQry = sQry + " where ID = " + detectionItemId; + + + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; + cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; + cmd.Parameters.Add("@BOOT_FEATURE", MySqlDbType.String, 10).Value = bootFeature; + cmd.Parameters.Add("@AGE_RATE", MySqlDbType.String, 10).Value = ageRate; + + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + iRetval = 0; + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + iRetval = -1; + } + + return iRetval; + } public int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100) { @@ -134,28 +184,28 @@ } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stability : "+ stability); string sQry = "UPDATE r_detection_item SET"; if(!stability.Equals("")) - sQry = sQry + " STABILITY=@STABILITY"; + sQry = sQry + " STABILITY=@STABILITY,"; if (!accuracy.Equals("")) - sQry = sQry + " ACCURACY=@ACCURACY"; + sQry = sQry + " ACCURACY=@ACCURACY,"; if (!bootFeature.Equals("")) - sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE,"; if (!ageRate.Equals("")) - sQry = sQry + " AGE_RATE=@AGE_RATE"; - if (!counterDetec.Equals("")) - sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC"; + sQry = sQry + " AGE_RATE=@AGE_RATE,"; if (!stability1.Equals("")) - sQry = sQry + " STABILITY_1=@STABILITY_1"; + sQry = sQry + " STABILITY_1=@STABILITY_1,"; if (!stability10.Equals("")) - sQry = sQry + " STABILITY_10=@STABILITY_10"; + sQry = sQry + " STABILITY_10=@STABILITY_10,"; if (!stability20.Equals("")) - sQry = sQry + " STABILITY_20=@STABILITY_20"; + sQry = sQry + " STABILITY_20=@STABILITY_20,"; if (!stability100.Equals("")) - sQry = sQry + " STABILITY_100=@STABILITY_100"; - sQry = sQry + " where ID = " + detectionId; + sQry = sQry + " STABILITY_100=@STABILITY_100,"; + sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; @@ -220,7 +270,7 @@ return iRetval; } - public int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData) + public int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData) { int iRetval = -1; try @@ -241,17 +291,25 @@ cmd.Parameters.Add("@CHANNEL", MySqlDbType.String, 20).Value = ""; cmd.ExecuteNonQuery(); + if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime + "' and '" + endTime + "')"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } + else + { + sQry = "UPDATE r_detection_item SET END_TIME=@END_TIME WHERE ID="+ detectionItemId; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@END_TIME", MySqlDbType.DateTime, 20).Value = DateTime.Now; + cmd.ExecuteNonQuery(); + } cmd.Dispose(); iRetval = 0; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 8773cb6..2de0df9 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -87,7 +87,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry + "; statusId="+ statusId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -101,9 +101,6 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); - - iRetval = 0; } catch (MySqlException ex) @@ -205,7 +202,7 @@ if (!aReader.IsDBNull(7)) deviceDto.CustomerDev = aReader.GetString(7); if (!aReader.IsDBNull(8)) { - deviceDto.StatusId = aReader.GetString(7); + deviceDto.StatusId = aReader.GetString(8); } if (!aReader.IsDBNull(9)) deviceDto.Channel = aReader.GetString(9); @@ -481,7 +478,7 @@ } } - string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 "; + string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -523,7 +520,7 @@ if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - + if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); deviceViewList.Add(deviceView); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index ff6a679..1626aa5 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -27,7 +27,7 @@ } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index e1b99b2..936cc37 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -224,7 +224,19 @@ } private void SelectCounter() { - + // 移除所有按钮的选中样式 + ClearAllMenuSelected(); + + // 鼠标移入效果去掉 + LeaveCounter(); + + // 重新设置所有按钮的状态 + menuSelected = new bool[] { false, false, false, true, false, false }; + + // 将新选中的按钮设置为选中 + picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + labCounterText.ForeColor = menuSelectedColor; + labCounterSelected.BackColor = menuSelectedColor; // 切换到频率计数器的界面 switchMainPanel(3); @@ -242,10 +254,16 @@ } private void SelectData() { + //if (CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // return; + //} // 移除所有按钮的选中样式 ClearAllMenuSelected(); // 鼠标移入效果去掉 + LeaveData(); // 重新设置所有按钮的状态 @@ -331,6 +349,19 @@ portList.Add(new SerialPort()); portList.Add(new SerialPort()); portList.Add(new SerialPort()); + DeviceService deviceService = new DeviceServiceImpl(); + DetectionItemService detectionItemService = new DetectionItemServiceImpl(); + List listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + long deviceId = device.Id; + string startTime = device.StartTime; + string endTime = device.EndTime; + detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); + } + } } else { @@ -500,24 +531,24 @@ private void switchMainPanel(int index) { - if (index != 3 && CounterCtrlForm.isDetecting) - { - MessageBox.Show("正在检测计数器,无法离开当前界面!"); - // 移除所有按钮的选中样式 - ClearAllMenuSelected(); + //if (index != 3 && CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // // 移除所有按钮的选中样式 + // ClearAllMenuSelected(); - // 鼠标移入效果去掉 - LeaveCounter(); + // // 鼠标移入效果去掉 + // LeaveCounter(); - // 重新设置所有按钮的状态 - menuSelected = new bool[] { false, false, false, true, false, false }; + // // 重新设置所有按钮的状态 + // menuSelected = new bool[] { false, false, false, true, false, false }; - // 将新选中的按钮设置为选中 - picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); - labCounterText.ForeColor = menuSelectedColor; - labCounterSelected.BackColor = menuSelectedColor; - return; - } + // // 将新选中的按钮设置为选中 + // picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + // labCounterText.ForeColor = menuSelectedColor; + // labCounterSelected.BackColor = menuSelectedColor; + // return; + //} panelMain.Controls.Clear(); switch (index) { diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index ecbb7e2..4405d66 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index 36ae30d..fd7ffee 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -111,7 +111,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), + Location = new Point(48, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); @@ -126,27 +126,12 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), + Location = new Point(142, 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 { @@ -156,7 +141,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(247, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -171,7 +156,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), + Location = new Point(360, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colValue); @@ -186,7 +171,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), + Location = new Point(465, 0), Size = new Size(95, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); @@ -280,6 +265,7 @@ dataGridView_CounterResult.DataSource = table_counterDetecInit; + dataGridView_CounterResult.Columns[3].Visible = false; dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; @@ -287,11 +273,10 @@ dataGridView_CounterResult.Columns[0].Width = 50; dataGridView_CounterResult.Columns[1].Width = 95; dataGridView_CounterResult.Columns[2].Width = 95; - 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[4].Width = 110; + dataGridView_CounterResult.Columns[5].Width = 110; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -773,17 +758,30 @@ 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 (!regex.IsMatch(value)) + if (textBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + dataGridView_CounterResult.CurrentCell.Value = ""; + MessageBox.Show("请输入格式正确的、带单位的测量频率!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + dataGridView_CounterResult.CurrentCell.Value = ""; + MessageBox.Show("请输入格式正确的、带单位的测量周期!"); + return; + } + } } } diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index fcefb48..09d1e4a 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -321,7 +321,7 @@ // this.pic_ageRate_5.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_5.Location = new System.Drawing.Point(151, 9); + this.pic_ageRate_5.Location = new System.Drawing.Point(224, 9); this.pic_ageRate_5.Name = "pic_ageRate_5"; this.pic_ageRate_5.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_5.TabIndex = 336; @@ -331,7 +331,7 @@ // this.pic_stability_5.BackColor = System.Drawing.Color.Transparent; this.pic_stability_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_5.Location = new System.Drawing.Point(85, 9); + this.pic_stability_5.Location = new System.Drawing.Point(12, 9); this.pic_stability_5.Name = "pic_stability_5"; this.pic_stability_5.Size = new System.Drawing.Size(16, 16); this.pic_stability_5.TabIndex = 333; @@ -341,7 +341,7 @@ // this.pic_accuracy_5.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_5.Location = new System.Drawing.Point(224, 9); + this.pic_accuracy_5.Location = new System.Drawing.Point(78, 9); this.pic_accuracy_5.Name = "pic_accuracy_5"; this.pic_accuracy_5.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_5.TabIndex = 334; @@ -351,7 +351,7 @@ // this.pic_bootFeature_5.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_5.Location = new System.Drawing.Point(9, 9); + this.pic_bootFeature_5.Location = new System.Drawing.Point(152, 9); this.pic_bootFeature_5.Name = "pic_bootFeature_5"; this.pic_bootFeature_5.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_5.TabIndex = 335; @@ -374,7 +374,7 @@ // this.pic_ageRate_4.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_4.Location = new System.Drawing.Point(151, 10); + this.pic_ageRate_4.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_4.Name = "pic_ageRate_4"; this.pic_ageRate_4.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_4.TabIndex = 332; @@ -384,7 +384,7 @@ // this.pic_stability_4.BackColor = System.Drawing.Color.Transparent; this.pic_stability_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_stability_4.Location = new System.Drawing.Point(85, 10); + this.pic_stability_4.Location = new System.Drawing.Point(12, 8); this.pic_stability_4.Name = "pic_stability_4"; this.pic_stability_4.Size = new System.Drawing.Size(16, 16); this.pic_stability_4.TabIndex = 329; @@ -394,7 +394,7 @@ // this.pic_accuracy_4.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_4.Location = new System.Drawing.Point(224, 10); + this.pic_accuracy_4.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_4.Name = "pic_accuracy_4"; this.pic_accuracy_4.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_4.TabIndex = 330; @@ -404,7 +404,7 @@ // this.pic_bootFeature_4.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_4.Location = new System.Drawing.Point(9, 10); + this.pic_bootFeature_4.Location = new System.Drawing.Point(152, 8); this.pic_bootFeature_4.Name = "pic_bootFeature_4"; this.pic_bootFeature_4.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_4.TabIndex = 331; @@ -427,7 +427,7 @@ // this.pic_ageRate_3.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_3.Location = new System.Drawing.Point(151, 8); + this.pic_ageRate_3.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_3.Name = "pic_ageRate_3"; this.pic_ageRate_3.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_3.TabIndex = 328; @@ -437,7 +437,7 @@ // this.pic_stability_3.BackColor = System.Drawing.Color.Transparent; this.pic_stability_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_3.Location = new System.Drawing.Point(85, 8); + this.pic_stability_3.Location = new System.Drawing.Point(12, 8); this.pic_stability_3.Name = "pic_stability_3"; this.pic_stability_3.Size = new System.Drawing.Size(16, 16); this.pic_stability_3.TabIndex = 325; @@ -447,7 +447,7 @@ // this.pic_accuracy_3.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_3.Location = new System.Drawing.Point(224, 8); + this.pic_accuracy_3.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_3.Name = "pic_accuracy_3"; this.pic_accuracy_3.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_3.TabIndex = 326; @@ -457,7 +457,7 @@ // this.pic_bootFeature_3.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_3.Location = new System.Drawing.Point(8, 8); + this.pic_bootFeature_3.Location = new System.Drawing.Point(151, 8); this.pic_bootFeature_3.Name = "pic_bootFeature_3"; this.pic_bootFeature_3.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_3.TabIndex = 327; @@ -480,7 +480,7 @@ // this.pic_ageRate_2.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_2.Location = new System.Drawing.Point(151, 7); + this.pic_ageRate_2.Location = new System.Drawing.Point(224, 7); this.pic_ageRate_2.Name = "pic_ageRate_2"; this.pic_ageRate_2.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_2.TabIndex = 324; @@ -490,7 +490,7 @@ // this.pic_stability_2.BackColor = System.Drawing.Color.Transparent; this.pic_stability_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_2.Location = new System.Drawing.Point(85, 7); + this.pic_stability_2.Location = new System.Drawing.Point(12, 7); this.pic_stability_2.Name = "pic_stability_2"; this.pic_stability_2.Size = new System.Drawing.Size(16, 16); this.pic_stability_2.TabIndex = 321; @@ -500,7 +500,7 @@ // this.pic_accuracy_2.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_2.Location = new System.Drawing.Point(224, 7); + this.pic_accuracy_2.Location = new System.Drawing.Point(78, 7); this.pic_accuracy_2.Name = "pic_accuracy_2"; this.pic_accuracy_2.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_2.TabIndex = 322; @@ -510,7 +510,7 @@ // this.pic_bootFeature_2.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_2.Location = new System.Drawing.Point(8, 7); + this.pic_bootFeature_2.Location = new System.Drawing.Point(151, 7); this.pic_bootFeature_2.Name = "pic_bootFeature_2"; this.pic_bootFeature_2.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_2.TabIndex = 323; @@ -533,7 +533,7 @@ // this.pic_ageRate_1.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_1.Location = new System.Drawing.Point(151, 8); + this.pic_ageRate_1.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_1.Name = "pic_ageRate_1"; this.pic_ageRate_1.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_1.TabIndex = 320; @@ -543,7 +543,7 @@ // this.pic_stability_1.BackColor = System.Drawing.Color.Transparent; this.pic_stability_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_1.Location = new System.Drawing.Point(85, 8); + this.pic_stability_1.Location = new System.Drawing.Point(12, 8); this.pic_stability_1.Name = "pic_stability_1"; this.pic_stability_1.Size = new System.Drawing.Size(16, 16); this.pic_stability_1.TabIndex = 317; @@ -553,7 +553,7 @@ // this.pic_accuracy_1.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_1.Location = new System.Drawing.Point(224, 8); + this.pic_accuracy_1.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_1.Name = "pic_accuracy_1"; this.pic_accuracy_1.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_1.TabIndex = 318; @@ -563,7 +563,7 @@ // this.pic_bootFeature_1.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_1.Location = new System.Drawing.Point(7, 8); + this.pic_bootFeature_1.Location = new System.Drawing.Point(150, 8); this.pic_bootFeature_1.Name = "pic_bootFeature_1"; this.pic_bootFeature_1.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_1.TabIndex = 319; @@ -598,7 +598,7 @@ dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.dataGridView_Channel.DefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_Channel.GridColor = System.Drawing.Color.DarkGray; - this.dataGridView_Channel.Location = new System.Drawing.Point(10, 10); + this.dataGridView_Channel.Location = new System.Drawing.Point(11, 10); this.dataGridView_Channel.Margin = new System.Windows.Forms.Padding(0); this.dataGridView_Channel.MultiSelect = false; this.dataGridView_Channel.Name = "dataGridView_Channel"; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index 5d75f74..ca3181d 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -60,6 +60,8 @@ label_clockStatus.Text = FreshStatus.clockStatus; label_receiverStatus.Text = StatusCtrlForm.receiverStatus; } + + } private void HomeCtrlForm_Load(object sender, EventArgs e) @@ -421,22 +423,6 @@ dataGridView_Channel.Controls.Add(colStatus); colStatus.BringToFront(); - // 开机特性 - Label colStartup = 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(colStartup); - colStartup.BringToFront(); - // 频率稳定度 Label colStablility = new Label { @@ -446,25 +432,13 @@ BackColor = titleBackColor, AutoSize = false, Text = "稳定度", - Location = new Point(759, 0), + + Location = new Point(684,0), Size = new Size(75, 30) }; dataGridView_Channel.Controls.Add(colStablility); colStablility.BringToFront(); - // 日老化率 - Label colAgingRate = 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) - }; - // 频率准确度 Label colAccuracy = new Label { @@ -474,11 +448,45 @@ BackColor = titleBackColor, AutoSize = false, Text = "准确度", - Location = new Point(899, 0), + 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) + }; + + @@ -506,142 +514,162 @@ } public void LoadChannelStatus() { - channelsTable = new DataTable(); - - channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); - channelsTable.Columns.Add("devName", Type.GetType("System.String")); - channelsTable.Columns.Add("devCode", Type.GetType("System.String")); - channelsTable.Columns.Add("customComp", Type.GetType("System.String")); - channelsTable.Columns.Add("startTime", Type.GetType("System.String")); - channelsTable.Columns.Add("endTime", Type.GetType("System.String")); - channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); - channelsTable.Columns.Add("startup", Type.GetType("System.String")); - channelsTable.Columns.Add("stablility", Type.GetType("System.String")); - channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); - channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); - channelsTable.Columns.Add("deviceId", Type.GetType("System.Int32")); - //channelsTable.Columns.Add("devType", Type.GetType("System.String")); - //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); - //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); - - listChannelStatus = deviceService.getDeviceByChannel(); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - if (listChannelStatus != null && listChannelStatus.Count > 0) + try { - foreach (DeviceView device in listChannelStatus) + channelsTable = new DataTable(); + + channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); + channelsTable.Columns.Add("devName", Type.GetType("System.String")); + channelsTable.Columns.Add("devCode", Type.GetType("System.String")); + channelsTable.Columns.Add("customComp", Type.GetType("System.String")); + channelsTable.Columns.Add("startTime", Type.GetType("System.String")); + channelsTable.Columns.Add("endTime", Type.GetType("System.String")); + channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); + channelsTable.Columns.Add("stablility", Type.GetType("System.String")); + channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); + channelsTable.Columns.Add("startup", Type.GetType("System.String")); + channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); + channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); + channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); + //channelsTable.Columns.Add("devType", Type.GetType("System.String")); + //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); + //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); + + listChannelStatus = deviceService.getDeviceByChannel(); + + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); + + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); - int index = Convert.ToInt32(device.Channel) - 1; - channelsTable.Rows[index]["channelNo"] = device.Channel; - channelsTable.Rows[index]["devName"] = device.DevName; - channelsTable.Rows[index]["devCode"] = device.DevCode; - channelsTable.Rows[index]["customComp"] = device.CustomerDev; - channelsTable.Rows[index]["startTime"] = device.StartTime; - channelsTable.Rows[index]["endTime"] = device.EndTime; - channelsTable.Rows[index]["channelStatus"] = "占用"; - channelsTable.Rows[index]["deviceId"] = device.Id; - if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + int index = Convert.ToInt32(device.Channel) - 1; + channelsTable.Rows[index]["channelNo"] = device.Channel; + channelsTable.Rows[index]["devName"] = device.DevName; + channelsTable.Rows[index]["devCode"] = device.DevCode; + channelsTable.Rows[index]["customComp"] = device.CustomerDev; + channelsTable.Rows[index]["startTime"] = device.StartTime; + channelsTable.Rows[index]["endTime"] = device.EndTime; + channelsTable.Rows[index]["channelStatus"] = "占用"; + channelsTable.Rows[index]["deviceId"] = device.Id; + channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; + + if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + } } + else + { + channelsTable.Rows.Clear(); + channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); + } + + foreach (string no in channelFreeList) + { + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; + } + + + dataGridView_Channel.DataSource = channelsTable; + + // width=764px + dataGridView_Channel.Columns[11].Visible = false; + dataGridView_Channel.Columns[12].Visible = false; + dataGridView_Channel.Columns[0].Width = 50; + dataGridView_Channel.Columns[1].Width = 110; + dataGridView_Channel.Columns[2].Width = 110; + dataGridView_Channel.Columns[3].Width = 110; + dataGridView_Channel.Columns[4].Width = 120; + dataGridView_Channel.Columns[5].Width = 120; + dataGridView_Channel.Columns[6].Width = 64; + dataGridView_Channel.Columns[7].Width = 75; + dataGridView_Channel.Columns[8].Width = 75; + dataGridView_Channel.Columns[9].Width = 75; + dataGridView_Channel.Columns[10].Width = 75; + + dataGridView_Channel.Columns[0].ReadOnly = true; + dataGridView_Channel.Columns[1].ReadOnly = true; + dataGridView_Channel.Columns[2].ReadOnly = true; + dataGridView_Channel.Columns[3].ReadOnly = true; + dataGridView_Channel.Columns[4].ReadOnly = true; + dataGridView_Channel.Columns[5].ReadOnly = true; + dataGridView_Channel.Columns[6].ReadOnly = true; + dataGridView_Channel.Columns[7].ReadOnly = true; + dataGridView_Channel.Columns[8].ReadOnly = true; + dataGridView_Channel.Columns[9].ReadOnly = true; + dataGridView_Channel.Columns[10].ReadOnly = true; } - else + catch (Exception ex) { - channelsTable.Rows.Clear(); - channelsTable.Rows.Add("1","","","","","","空闲",""); - channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", ""); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "LoadChannelStatus 错误:" + ex.Message); + } - - foreach (string no in channelFreeList) - { - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; - } - - - dataGridView_Channel.DataSource = channelsTable; - - // width=764px - dataGridView_Channel.Columns[11].Visible = false; - dataGridView_Channel.Columns[0].Width = 50; - dataGridView_Channel.Columns[1].Width = 110; - dataGridView_Channel.Columns[2].Width = 110; - dataGridView_Channel.Columns[3].Width = 110; - dataGridView_Channel.Columns[4].Width = 120; - dataGridView_Channel.Columns[5].Width = 120; - dataGridView_Channel.Columns[6].Width = 64; - dataGridView_Channel.Columns[7].Width = 75; - dataGridView_Channel.Columns[8].Width = 75; - dataGridView_Channel.Columns[9].Width = 75; - dataGridView_Channel.Columns[10].Width = 75; - - dataGridView_Channel.Columns[0].ReadOnly = true; - dataGridView_Channel.Columns[1].ReadOnly = true; - dataGridView_Channel.Columns[2].ReadOnly = true; - dataGridView_Channel.Columns[3].ReadOnly = true; - dataGridView_Channel.Columns[4].ReadOnly = true; - dataGridView_Channel.Columns[5].ReadOnly = true; - dataGridView_Channel.Columns[6].ReadOnly = true; - dataGridView_Channel.Columns[7].ReadOnly = true; - dataGridView_Channel.Columns[8].ReadOnly = true; - dataGridView_Channel.Columns[9].ReadOnly = true; - dataGridView_Channel.Columns[10].ReadOnly = true; - } private void dataGridView_Channel_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) - { - dataGridView_Channel.ClearSelection(); + { + try + { + dataGridView_Channel.ClearSelection(); - int channelNo = e.RowIndex + 1; - if (channelFreeList.Contains(channelNo + "")) - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + int channelNo = e.RowIndex + 1; + if (channelFreeList.Contains(channelNo + "")) + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + } + else + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + } + foreach (string no in channelFreeList) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } } - else + catch (Exception ex) { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - } - foreach (string no in channelFreeList) - { - 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, "dataGridView_Channel_RowPostPaint 错误:" + ex.Message); + } } @@ -701,7 +729,8 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - int deviceId = (int)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + 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) @@ -712,11 +741,11 @@ DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { - detectionItemService.stopDetection(deviceId, startTime, endTime, false); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); } else { - detectionItemService.stopDetection(deviceId, startTime, endTime, true); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); } LoadChannelStatus(); LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 6aaa532..f99f106 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -132,16 +132,16 @@ return; } timePicker_endTime.Value = endTimeBySystem; - + // 打开串口 DetectionHelper detectionHelper = new DetectionHelper(); - + SerialPort port = RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1]; string portName = ConfigHelper.GetAppConfig("channel" + textBox_channelNo.Text).Split(' ')[0]; int band = Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + textBox_channelNo.Text).Split(' ')[1]); if (port.IsOpen) port.Close(); - + port.PortName = portName; port.BaudRate = band; port.Parity = Parity.None; @@ -159,12 +159,12 @@ return; } } - catch(Exception exc) + catch (Exception exc) { MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } - + if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); @@ -321,7 +321,7 @@ else if (checkBox10s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101 * 10).AddSeconds(40); else if (checkBox1s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101).AddSeconds(40); } - else endTimeBySystem = DateTime.Now.AddMinutes(1).AddSeconds(30); + else endTimeBySystem = timePicker_startTime.Value.AddMinutes(1).AddSeconds(30); } } diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 1bb08ca..1a82d85 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -287,7 +287,7 @@ else if (checkBox10s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101 * 10).AddSeconds(40); else if (checkBox1s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101).AddSeconds(40); } - else endTimeBySystem = DateTime.Now.AddMinutes(1).AddSeconds(30); + else endTimeBySystem = timePicker_startTime.Value.AddMinutes(1).AddSeconds(30); } } timePicker_endTime.Value = endTimeBySystem; diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 5d7de27..ed117e0 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -173,7 +173,7 @@ string portName = ""; SerialPort port = new SerialPort(); - DetectionHelper detectionHelper = new DetectionHelper(); + DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) { port.Dispose(); @@ -181,7 +181,7 @@ picker_endTime.Value = endTimeBySystem; startTime = picker_startTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); endTime = picker_endTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); - + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "结束时间: " + endTime); needDetec = true; portName = ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[0]; int band =Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[1]); @@ -247,9 +247,7 @@ } } else if (labelTitle.Text.Equals("修改")) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "修改" + deviceId); - + { if (needDetec) statusId = "2"; devService.update(deviceId, devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo,statusId); LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update 完成"); @@ -450,7 +448,7 @@ else if (checkBox10s.Checked) endTimeBySystem = picker_startTime.Value.AddSeconds(101 * 10).AddSeconds(40); else if (checkBox1s.Checked) endTimeBySystem = picker_startTime.Value.AddSeconds(101).AddSeconds(40); } - else endTimeBySystem = DateTime.Now.AddMinutes(1).AddSeconds(30); + else endTimeBySystem = picker_startTime.Value.AddMinutes(1).AddSeconds(30); } } diff --git a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs index ec02ee3..ba3c1cf 100644 --- a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs +++ b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs @@ -51,6 +51,7 @@ private String accuracy; private String bootFeature; private String ageRate; + private long detectionItemId; public long Id { @@ -251,5 +252,6 @@ public string Accuracy { get => accuracy; set => accuracy = value; } public string BootFeature { get => bootFeature; set => bootFeature = value; } public string AgeRate { get => ageRate; set => ageRate = value; } + public long DetectionItemId { get => detectionItemId; set => detectionItemId = value; } } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 3fe0773..64253a7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -16,7 +16,7 @@ List search(long deviceId, bool isInDetection); - int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData); + int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); 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 5c4cda2..b849d77 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -115,6 +115,56 @@ } return iRetval; } + public int startDetect(long detectionItemId, string stability, string accuracy, string bootFeature, string ageRate) + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + if (stability.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + + string sQry = "UPDATE r_detection_item SET"; + if (!stability.Equals("")) + sQry = sQry + " STABILITY=@STABILITY"; + if (!accuracy.Equals("")) + sQry = sQry + " ACCURACY=@ACCURACY"; + if (!bootFeature.Equals("")) + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + if (!ageRate.Equals("")) + sQry = sQry + " AGE_RATE=@AGE_RATE"; + sQry = sQry + " where ID = " + detectionItemId; + + + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; + cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; + cmd.Parameters.Add("@BOOT_FEATURE", MySqlDbType.String, 10).Value = bootFeature; + cmd.Parameters.Add("@AGE_RATE", MySqlDbType.String, 10).Value = ageRate; + + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + iRetval = 0; + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + iRetval = -1; + } + + return iRetval; + } public int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100) { @@ -134,28 +184,28 @@ } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stability : "+ stability); string sQry = "UPDATE r_detection_item SET"; if(!stability.Equals("")) - sQry = sQry + " STABILITY=@STABILITY"; + sQry = sQry + " STABILITY=@STABILITY,"; if (!accuracy.Equals("")) - sQry = sQry + " ACCURACY=@ACCURACY"; + sQry = sQry + " ACCURACY=@ACCURACY,"; if (!bootFeature.Equals("")) - sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE,"; if (!ageRate.Equals("")) - sQry = sQry + " AGE_RATE=@AGE_RATE"; - if (!counterDetec.Equals("")) - sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC"; + sQry = sQry + " AGE_RATE=@AGE_RATE,"; if (!stability1.Equals("")) - sQry = sQry + " STABILITY_1=@STABILITY_1"; + sQry = sQry + " STABILITY_1=@STABILITY_1,"; if (!stability10.Equals("")) - sQry = sQry + " STABILITY_10=@STABILITY_10"; + sQry = sQry + " STABILITY_10=@STABILITY_10,"; if (!stability20.Equals("")) - sQry = sQry + " STABILITY_20=@STABILITY_20"; + sQry = sQry + " STABILITY_20=@STABILITY_20,"; if (!stability100.Equals("")) - sQry = sQry + " STABILITY_100=@STABILITY_100"; - sQry = sQry + " where ID = " + detectionId; + sQry = sQry + " STABILITY_100=@STABILITY_100,"; + sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; @@ -220,7 +270,7 @@ return iRetval; } - public int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData) + public int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData) { int iRetval = -1; try @@ -241,17 +291,25 @@ cmd.Parameters.Add("@CHANNEL", MySqlDbType.String, 20).Value = ""; cmd.ExecuteNonQuery(); + if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime + "' and '" + endTime + "')"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } + else + { + sQry = "UPDATE r_detection_item SET END_TIME=@END_TIME WHERE ID="+ detectionItemId; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@END_TIME", MySqlDbType.DateTime, 20).Value = DateTime.Now; + cmd.ExecuteNonQuery(); + } cmd.Dispose(); iRetval = 0; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 8773cb6..2de0df9 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -87,7 +87,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry + "; statusId="+ statusId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -101,9 +101,6 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); - - iRetval = 0; } catch (MySqlException ex) @@ -205,7 +202,7 @@ if (!aReader.IsDBNull(7)) deviceDto.CustomerDev = aReader.GetString(7); if (!aReader.IsDBNull(8)) { - deviceDto.StatusId = aReader.GetString(7); + deviceDto.StatusId = aReader.GetString(8); } if (!aReader.IsDBNull(9)) deviceDto.Channel = aReader.GetString(9); @@ -481,7 +478,7 @@ } } - string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 "; + string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -523,7 +520,7 @@ if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - + if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); deviceViewList.Add(deviceView); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index ff6a679..1626aa5 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -27,7 +27,7 @@ } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index e1b99b2..936cc37 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -224,7 +224,19 @@ } private void SelectCounter() { - + // 移除所有按钮的选中样式 + ClearAllMenuSelected(); + + // 鼠标移入效果去掉 + LeaveCounter(); + + // 重新设置所有按钮的状态 + menuSelected = new bool[] { false, false, false, true, false, false }; + + // 将新选中的按钮设置为选中 + picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + labCounterText.ForeColor = menuSelectedColor; + labCounterSelected.BackColor = menuSelectedColor; // 切换到频率计数器的界面 switchMainPanel(3); @@ -242,10 +254,16 @@ } private void SelectData() { + //if (CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // return; + //} // 移除所有按钮的选中样式 ClearAllMenuSelected(); // 鼠标移入效果去掉 + LeaveData(); // 重新设置所有按钮的状态 @@ -331,6 +349,19 @@ portList.Add(new SerialPort()); portList.Add(new SerialPort()); portList.Add(new SerialPort()); + DeviceService deviceService = new DeviceServiceImpl(); + DetectionItemService detectionItemService = new DetectionItemServiceImpl(); + List listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + long deviceId = device.Id; + string startTime = device.StartTime; + string endTime = device.EndTime; + detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); + } + } } else { @@ -500,24 +531,24 @@ private void switchMainPanel(int index) { - if (index != 3 && CounterCtrlForm.isDetecting) - { - MessageBox.Show("正在检测计数器,无法离开当前界面!"); - // 移除所有按钮的选中样式 - ClearAllMenuSelected(); + //if (index != 3 && CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // // 移除所有按钮的选中样式 + // ClearAllMenuSelected(); - // 鼠标移入效果去掉 - LeaveCounter(); + // // 鼠标移入效果去掉 + // LeaveCounter(); - // 重新设置所有按钮的状态 - menuSelected = new bool[] { false, false, false, true, false, false }; + // // 重新设置所有按钮的状态 + // menuSelected = new bool[] { false, false, false, true, false, false }; - // 将新选中的按钮设置为选中 - picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); - labCounterText.ForeColor = menuSelectedColor; - labCounterSelected.BackColor = menuSelectedColor; - return; - } + // // 将新选中的按钮设置为选中 + // picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + // labCounterText.ForeColor = menuSelectedColor; + // labCounterSelected.BackColor = menuSelectedColor; + // return; + //} panelMain.Controls.Clear(); switch (index) { diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index ecbb7e2..4405d66 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index 36ae30d..fd7ffee 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -111,7 +111,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), + Location = new Point(48, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); @@ -126,27 +126,12 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), + Location = new Point(142, 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 { @@ -156,7 +141,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(247, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -171,7 +156,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), + Location = new Point(360, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colValue); @@ -186,7 +171,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), + Location = new Point(465, 0), Size = new Size(95, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); @@ -280,6 +265,7 @@ dataGridView_CounterResult.DataSource = table_counterDetecInit; + dataGridView_CounterResult.Columns[3].Visible = false; dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; @@ -287,11 +273,10 @@ dataGridView_CounterResult.Columns[0].Width = 50; dataGridView_CounterResult.Columns[1].Width = 95; dataGridView_CounterResult.Columns[2].Width = 95; - 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[4].Width = 110; + dataGridView_CounterResult.Columns[5].Width = 110; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -773,17 +758,30 @@ 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 (!regex.IsMatch(value)) + if (textBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + dataGridView_CounterResult.CurrentCell.Value = ""; + MessageBox.Show("请输入格式正确的、带单位的测量频率!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + dataGridView_CounterResult.CurrentCell.Value = ""; + MessageBox.Show("请输入格式正确的、带单位的测量周期!"); + return; + } + } } } diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index fcefb48..09d1e4a 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -321,7 +321,7 @@ // this.pic_ageRate_5.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_5.Location = new System.Drawing.Point(151, 9); + this.pic_ageRate_5.Location = new System.Drawing.Point(224, 9); this.pic_ageRate_5.Name = "pic_ageRate_5"; this.pic_ageRate_5.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_5.TabIndex = 336; @@ -331,7 +331,7 @@ // this.pic_stability_5.BackColor = System.Drawing.Color.Transparent; this.pic_stability_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_5.Location = new System.Drawing.Point(85, 9); + this.pic_stability_5.Location = new System.Drawing.Point(12, 9); this.pic_stability_5.Name = "pic_stability_5"; this.pic_stability_5.Size = new System.Drawing.Size(16, 16); this.pic_stability_5.TabIndex = 333; @@ -341,7 +341,7 @@ // this.pic_accuracy_5.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_5.Location = new System.Drawing.Point(224, 9); + this.pic_accuracy_5.Location = new System.Drawing.Point(78, 9); this.pic_accuracy_5.Name = "pic_accuracy_5"; this.pic_accuracy_5.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_5.TabIndex = 334; @@ -351,7 +351,7 @@ // this.pic_bootFeature_5.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_5.Location = new System.Drawing.Point(9, 9); + this.pic_bootFeature_5.Location = new System.Drawing.Point(152, 9); this.pic_bootFeature_5.Name = "pic_bootFeature_5"; this.pic_bootFeature_5.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_5.TabIndex = 335; @@ -374,7 +374,7 @@ // this.pic_ageRate_4.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_4.Location = new System.Drawing.Point(151, 10); + this.pic_ageRate_4.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_4.Name = "pic_ageRate_4"; this.pic_ageRate_4.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_4.TabIndex = 332; @@ -384,7 +384,7 @@ // this.pic_stability_4.BackColor = System.Drawing.Color.Transparent; this.pic_stability_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_stability_4.Location = new System.Drawing.Point(85, 10); + this.pic_stability_4.Location = new System.Drawing.Point(12, 8); this.pic_stability_4.Name = "pic_stability_4"; this.pic_stability_4.Size = new System.Drawing.Size(16, 16); this.pic_stability_4.TabIndex = 329; @@ -394,7 +394,7 @@ // this.pic_accuracy_4.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_4.Location = new System.Drawing.Point(224, 10); + this.pic_accuracy_4.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_4.Name = "pic_accuracy_4"; this.pic_accuracy_4.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_4.TabIndex = 330; @@ -404,7 +404,7 @@ // this.pic_bootFeature_4.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_4.Location = new System.Drawing.Point(9, 10); + this.pic_bootFeature_4.Location = new System.Drawing.Point(152, 8); this.pic_bootFeature_4.Name = "pic_bootFeature_4"; this.pic_bootFeature_4.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_4.TabIndex = 331; @@ -427,7 +427,7 @@ // this.pic_ageRate_3.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_3.Location = new System.Drawing.Point(151, 8); + this.pic_ageRate_3.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_3.Name = "pic_ageRate_3"; this.pic_ageRate_3.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_3.TabIndex = 328; @@ -437,7 +437,7 @@ // this.pic_stability_3.BackColor = System.Drawing.Color.Transparent; this.pic_stability_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_3.Location = new System.Drawing.Point(85, 8); + this.pic_stability_3.Location = new System.Drawing.Point(12, 8); this.pic_stability_3.Name = "pic_stability_3"; this.pic_stability_3.Size = new System.Drawing.Size(16, 16); this.pic_stability_3.TabIndex = 325; @@ -447,7 +447,7 @@ // this.pic_accuracy_3.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_3.Location = new System.Drawing.Point(224, 8); + this.pic_accuracy_3.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_3.Name = "pic_accuracy_3"; this.pic_accuracy_3.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_3.TabIndex = 326; @@ -457,7 +457,7 @@ // this.pic_bootFeature_3.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_3.Location = new System.Drawing.Point(8, 8); + this.pic_bootFeature_3.Location = new System.Drawing.Point(151, 8); this.pic_bootFeature_3.Name = "pic_bootFeature_3"; this.pic_bootFeature_3.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_3.TabIndex = 327; @@ -480,7 +480,7 @@ // this.pic_ageRate_2.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_2.Location = new System.Drawing.Point(151, 7); + this.pic_ageRate_2.Location = new System.Drawing.Point(224, 7); this.pic_ageRate_2.Name = "pic_ageRate_2"; this.pic_ageRate_2.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_2.TabIndex = 324; @@ -490,7 +490,7 @@ // this.pic_stability_2.BackColor = System.Drawing.Color.Transparent; this.pic_stability_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_2.Location = new System.Drawing.Point(85, 7); + this.pic_stability_2.Location = new System.Drawing.Point(12, 7); this.pic_stability_2.Name = "pic_stability_2"; this.pic_stability_2.Size = new System.Drawing.Size(16, 16); this.pic_stability_2.TabIndex = 321; @@ -500,7 +500,7 @@ // this.pic_accuracy_2.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_2.Location = new System.Drawing.Point(224, 7); + this.pic_accuracy_2.Location = new System.Drawing.Point(78, 7); this.pic_accuracy_2.Name = "pic_accuracy_2"; this.pic_accuracy_2.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_2.TabIndex = 322; @@ -510,7 +510,7 @@ // this.pic_bootFeature_2.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_2.Location = new System.Drawing.Point(8, 7); + this.pic_bootFeature_2.Location = new System.Drawing.Point(151, 7); this.pic_bootFeature_2.Name = "pic_bootFeature_2"; this.pic_bootFeature_2.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_2.TabIndex = 323; @@ -533,7 +533,7 @@ // this.pic_ageRate_1.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_1.Location = new System.Drawing.Point(151, 8); + this.pic_ageRate_1.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_1.Name = "pic_ageRate_1"; this.pic_ageRate_1.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_1.TabIndex = 320; @@ -543,7 +543,7 @@ // this.pic_stability_1.BackColor = System.Drawing.Color.Transparent; this.pic_stability_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_1.Location = new System.Drawing.Point(85, 8); + this.pic_stability_1.Location = new System.Drawing.Point(12, 8); this.pic_stability_1.Name = "pic_stability_1"; this.pic_stability_1.Size = new System.Drawing.Size(16, 16); this.pic_stability_1.TabIndex = 317; @@ -553,7 +553,7 @@ // this.pic_accuracy_1.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_1.Location = new System.Drawing.Point(224, 8); + this.pic_accuracy_1.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_1.Name = "pic_accuracy_1"; this.pic_accuracy_1.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_1.TabIndex = 318; @@ -563,7 +563,7 @@ // this.pic_bootFeature_1.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_1.Location = new System.Drawing.Point(7, 8); + this.pic_bootFeature_1.Location = new System.Drawing.Point(150, 8); this.pic_bootFeature_1.Name = "pic_bootFeature_1"; this.pic_bootFeature_1.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_1.TabIndex = 319; @@ -598,7 +598,7 @@ dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.dataGridView_Channel.DefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_Channel.GridColor = System.Drawing.Color.DarkGray; - this.dataGridView_Channel.Location = new System.Drawing.Point(10, 10); + this.dataGridView_Channel.Location = new System.Drawing.Point(11, 10); this.dataGridView_Channel.Margin = new System.Windows.Forms.Padding(0); this.dataGridView_Channel.MultiSelect = false; this.dataGridView_Channel.Name = "dataGridView_Channel"; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index 5d75f74..ca3181d 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -60,6 +60,8 @@ label_clockStatus.Text = FreshStatus.clockStatus; label_receiverStatus.Text = StatusCtrlForm.receiverStatus; } + + } private void HomeCtrlForm_Load(object sender, EventArgs e) @@ -421,22 +423,6 @@ dataGridView_Channel.Controls.Add(colStatus); colStatus.BringToFront(); - // 开机特性 - Label colStartup = 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(colStartup); - colStartup.BringToFront(); - // 频率稳定度 Label colStablility = new Label { @@ -446,25 +432,13 @@ BackColor = titleBackColor, AutoSize = false, Text = "稳定度", - Location = new Point(759, 0), + + Location = new Point(684,0), Size = new Size(75, 30) }; dataGridView_Channel.Controls.Add(colStablility); colStablility.BringToFront(); - // 日老化率 - Label colAgingRate = 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) - }; - // 频率准确度 Label colAccuracy = new Label { @@ -474,11 +448,45 @@ BackColor = titleBackColor, AutoSize = false, Text = "准确度", - Location = new Point(899, 0), + 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) + }; + + @@ -506,142 +514,162 @@ } public void LoadChannelStatus() { - channelsTable = new DataTable(); - - channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); - channelsTable.Columns.Add("devName", Type.GetType("System.String")); - channelsTable.Columns.Add("devCode", Type.GetType("System.String")); - channelsTable.Columns.Add("customComp", Type.GetType("System.String")); - channelsTable.Columns.Add("startTime", Type.GetType("System.String")); - channelsTable.Columns.Add("endTime", Type.GetType("System.String")); - channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); - channelsTable.Columns.Add("startup", Type.GetType("System.String")); - channelsTable.Columns.Add("stablility", Type.GetType("System.String")); - channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); - channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); - channelsTable.Columns.Add("deviceId", Type.GetType("System.Int32")); - //channelsTable.Columns.Add("devType", Type.GetType("System.String")); - //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); - //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); - - listChannelStatus = deviceService.getDeviceByChannel(); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - if (listChannelStatus != null && listChannelStatus.Count > 0) + try { - foreach (DeviceView device in listChannelStatus) + channelsTable = new DataTable(); + + channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); + channelsTable.Columns.Add("devName", Type.GetType("System.String")); + channelsTable.Columns.Add("devCode", Type.GetType("System.String")); + channelsTable.Columns.Add("customComp", Type.GetType("System.String")); + channelsTable.Columns.Add("startTime", Type.GetType("System.String")); + channelsTable.Columns.Add("endTime", Type.GetType("System.String")); + channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); + channelsTable.Columns.Add("stablility", Type.GetType("System.String")); + channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); + channelsTable.Columns.Add("startup", Type.GetType("System.String")); + channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); + channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); + channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); + //channelsTable.Columns.Add("devType", Type.GetType("System.String")); + //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); + //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); + + listChannelStatus = deviceService.getDeviceByChannel(); + + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); + + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); - int index = Convert.ToInt32(device.Channel) - 1; - channelsTable.Rows[index]["channelNo"] = device.Channel; - channelsTable.Rows[index]["devName"] = device.DevName; - channelsTable.Rows[index]["devCode"] = device.DevCode; - channelsTable.Rows[index]["customComp"] = device.CustomerDev; - channelsTable.Rows[index]["startTime"] = device.StartTime; - channelsTable.Rows[index]["endTime"] = device.EndTime; - channelsTable.Rows[index]["channelStatus"] = "占用"; - channelsTable.Rows[index]["deviceId"] = device.Id; - if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + int index = Convert.ToInt32(device.Channel) - 1; + channelsTable.Rows[index]["channelNo"] = device.Channel; + channelsTable.Rows[index]["devName"] = device.DevName; + channelsTable.Rows[index]["devCode"] = device.DevCode; + channelsTable.Rows[index]["customComp"] = device.CustomerDev; + channelsTable.Rows[index]["startTime"] = device.StartTime; + channelsTable.Rows[index]["endTime"] = device.EndTime; + channelsTable.Rows[index]["channelStatus"] = "占用"; + channelsTable.Rows[index]["deviceId"] = device.Id; + channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; + + if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + } } + else + { + channelsTable.Rows.Clear(); + channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); + } + + foreach (string no in channelFreeList) + { + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; + } + + + dataGridView_Channel.DataSource = channelsTable; + + // width=764px + dataGridView_Channel.Columns[11].Visible = false; + dataGridView_Channel.Columns[12].Visible = false; + dataGridView_Channel.Columns[0].Width = 50; + dataGridView_Channel.Columns[1].Width = 110; + dataGridView_Channel.Columns[2].Width = 110; + dataGridView_Channel.Columns[3].Width = 110; + dataGridView_Channel.Columns[4].Width = 120; + dataGridView_Channel.Columns[5].Width = 120; + dataGridView_Channel.Columns[6].Width = 64; + dataGridView_Channel.Columns[7].Width = 75; + dataGridView_Channel.Columns[8].Width = 75; + dataGridView_Channel.Columns[9].Width = 75; + dataGridView_Channel.Columns[10].Width = 75; + + dataGridView_Channel.Columns[0].ReadOnly = true; + dataGridView_Channel.Columns[1].ReadOnly = true; + dataGridView_Channel.Columns[2].ReadOnly = true; + dataGridView_Channel.Columns[3].ReadOnly = true; + dataGridView_Channel.Columns[4].ReadOnly = true; + dataGridView_Channel.Columns[5].ReadOnly = true; + dataGridView_Channel.Columns[6].ReadOnly = true; + dataGridView_Channel.Columns[7].ReadOnly = true; + dataGridView_Channel.Columns[8].ReadOnly = true; + dataGridView_Channel.Columns[9].ReadOnly = true; + dataGridView_Channel.Columns[10].ReadOnly = true; } - else + catch (Exception ex) { - channelsTable.Rows.Clear(); - channelsTable.Rows.Add("1","","","","","","空闲",""); - channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", ""); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "LoadChannelStatus 错误:" + ex.Message); + } - - foreach (string no in channelFreeList) - { - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; - } - - - dataGridView_Channel.DataSource = channelsTable; - - // width=764px - dataGridView_Channel.Columns[11].Visible = false; - dataGridView_Channel.Columns[0].Width = 50; - dataGridView_Channel.Columns[1].Width = 110; - dataGridView_Channel.Columns[2].Width = 110; - dataGridView_Channel.Columns[3].Width = 110; - dataGridView_Channel.Columns[4].Width = 120; - dataGridView_Channel.Columns[5].Width = 120; - dataGridView_Channel.Columns[6].Width = 64; - dataGridView_Channel.Columns[7].Width = 75; - dataGridView_Channel.Columns[8].Width = 75; - dataGridView_Channel.Columns[9].Width = 75; - dataGridView_Channel.Columns[10].Width = 75; - - dataGridView_Channel.Columns[0].ReadOnly = true; - dataGridView_Channel.Columns[1].ReadOnly = true; - dataGridView_Channel.Columns[2].ReadOnly = true; - dataGridView_Channel.Columns[3].ReadOnly = true; - dataGridView_Channel.Columns[4].ReadOnly = true; - dataGridView_Channel.Columns[5].ReadOnly = true; - dataGridView_Channel.Columns[6].ReadOnly = true; - dataGridView_Channel.Columns[7].ReadOnly = true; - dataGridView_Channel.Columns[8].ReadOnly = true; - dataGridView_Channel.Columns[9].ReadOnly = true; - dataGridView_Channel.Columns[10].ReadOnly = true; - } private void dataGridView_Channel_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) - { - dataGridView_Channel.ClearSelection(); + { + try + { + dataGridView_Channel.ClearSelection(); - int channelNo = e.RowIndex + 1; - if (channelFreeList.Contains(channelNo + "")) - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + int channelNo = e.RowIndex + 1; + if (channelFreeList.Contains(channelNo + "")) + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + } + else + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + } + foreach (string no in channelFreeList) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } } - else + catch (Exception ex) { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - } - foreach (string no in channelFreeList) - { - 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, "dataGridView_Channel_RowPostPaint 错误:" + ex.Message); + } } @@ -701,7 +729,8 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - int deviceId = (int)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + 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) @@ -712,11 +741,11 @@ DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { - detectionItemService.stopDetection(deviceId, startTime, endTime, false); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); } else { - detectionItemService.stopDetection(deviceId, startTime, endTime, true); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); } LoadChannelStatus(); LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 6aaa532..f99f106 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -132,16 +132,16 @@ return; } timePicker_endTime.Value = endTimeBySystem; - + // 打开串口 DetectionHelper detectionHelper = new DetectionHelper(); - + SerialPort port = RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1]; string portName = ConfigHelper.GetAppConfig("channel" + textBox_channelNo.Text).Split(' ')[0]; int band = Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + textBox_channelNo.Text).Split(' ')[1]); if (port.IsOpen) port.Close(); - + port.PortName = portName; port.BaudRate = band; port.Parity = Parity.None; @@ -159,12 +159,12 @@ return; } } - catch(Exception exc) + catch (Exception exc) { MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } - + if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); @@ -321,7 +321,7 @@ else if (checkBox10s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101 * 10).AddSeconds(40); else if (checkBox1s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101).AddSeconds(40); } - else endTimeBySystem = DateTime.Now.AddMinutes(1).AddSeconds(30); + else endTimeBySystem = timePicker_startTime.Value.AddMinutes(1).AddSeconds(30); } } diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 1bb08ca..1a82d85 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -287,7 +287,7 @@ else if (checkBox10s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101 * 10).AddSeconds(40); else if (checkBox1s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101).AddSeconds(40); } - else endTimeBySystem = DateTime.Now.AddMinutes(1).AddSeconds(30); + else endTimeBySystem = timePicker_startTime.Value.AddMinutes(1).AddSeconds(30); } } timePicker_endTime.Value = endTimeBySystem; diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 5d7de27..ed117e0 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -173,7 +173,7 @@ string portName = ""; SerialPort port = new SerialPort(); - DetectionHelper detectionHelper = new DetectionHelper(); + DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) { port.Dispose(); @@ -181,7 +181,7 @@ picker_endTime.Value = endTimeBySystem; startTime = picker_startTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); endTime = picker_endTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); - + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "结束时间: " + endTime); needDetec = true; portName = ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[0]; int band =Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[1]); @@ -247,9 +247,7 @@ } } else if (labelTitle.Text.Equals("修改")) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "修改" + deviceId); - + { if (needDetec) statusId = "2"; devService.update(deviceId, devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo,statusId); LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update 完成"); @@ -450,7 +448,7 @@ else if (checkBox10s.Checked) endTimeBySystem = picker_startTime.Value.AddSeconds(101 * 10).AddSeconds(40); else if (checkBox1s.Checked) endTimeBySystem = picker_startTime.Value.AddSeconds(101).AddSeconds(40); } - else endTimeBySystem = DateTime.Now.AddMinutes(1).AddSeconds(30); + else endTimeBySystem = picker_startTime.Value.AddMinutes(1).AddSeconds(30); } } diff --git a/RbFreqStandMeasure/info/ExportDlg.cs b/RbFreqStandMeasure/info/ExportDlg.cs index 6b1b03a..edecd98 100644 --- a/RbFreqStandMeasure/info/ExportDlg.cs +++ b/RbFreqStandMeasure/info/ExportDlg.cs @@ -11,6 +11,7 @@ using System.Drawing; using System.IO; using System.IO.Ports; +using System.Reflection; using System.Runtime.InteropServices; using System.Windows.Forms; @@ -106,11 +107,11 @@ List queryList = detectionItemService.search(deviceId, false); if (null != queryList && queryList.Count > 0) { - int index = 1; foreach (DetectionItem detection in queryList) { tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime, detection.Accuracy, detection.Stability, detection.BootFeature, detection.AgeRate, detection.Channel, detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100,detection.Id); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "detection.Id :" + detection.Id); index++; } @@ -130,8 +131,8 @@ dataGridView_times.Columns[10].Visible = false; dataGridView_times.Columns[11].Visible = false; dataGridView_times.Columns[12].Visible = false; + dataGridView_times.Columns[13].Visible = false; - dataGridView_times.Columns[1].ReadOnly = true; dataGridView_times.Columns[2].ReadOnly = true; dataGridView_times.Columns[3].ReadOnly = true; @@ -142,6 +143,8 @@ dataGridView_times.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable; dataGridView_times.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable; dataGridView_times.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable; + dataGridView_times.Columns[7].SortMode = DataGridViewColumnSortMode.NotSortable; + dataGridView_times.Columns[8].SortMode = DataGridViewColumnSortMode.NotSortable; } else { @@ -214,7 +217,6 @@ StreamWriter strmWriterObj = new StreamWriter(strFilePath, false, System.Text.Encoding.UTF8); strmWriterObj.WriteLine(label_devName.Text + " - " + label_devType.Text + "-" + "测试数据及结果"); - strmWriterObj.WriteLine("序号,时间,相对频率偏差"); foreach (DataGridViewRow row in dataGridView_times.Rows) { DataGridViewCheckBoxCell checkBox = (DataGridViewCheckBoxCell)row.Cells[0]; @@ -230,12 +232,17 @@ { string typeStr = type + ""; if (type == 1) typeStr = "1-1"; - else if(type == 2) typeStr = "1-10"; - else if (type == 3) typeStr = "1-20"; - else if (type == 4) typeStr = "1-100"; + if(type == 2) typeStr = "1-10"; + if (type == 3) typeStr = "1-20"; + if (type == 4) typeStr = "1-100"; + if(type == 5) typeStr = "2"; + if (type == 6) typeStr = "3"; + if (type == 7) typeStr = "4"; // 获取数据 - List List = detectionService.search(deviceId, typeStr, startTime, endTime,Convert.ToInt64(row.Cells[12].Value)); + List List = detectionService.search(deviceId, typeStr, startTime, endTime,Convert.ToInt64(row.Cells[13].Value)); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "List.count :" + List.Count +";itemid="+ Convert.ToInt64(row.Cells[13].Value)+ ";typeStr"+ typeStr+";devid="+ deviceId); + if (null != List && List.Count > 0) { string detecItemName = ""; @@ -270,14 +277,17 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); List query = counterDataService.getHistory(deviceId, "", ""); - strmWriterObj.WriteLine("计数器范围及灵敏度"); - strmWriterObj.WriteLine("序号,输出值,测量值,灵敏度,时间"); - int index2 = 1; - foreach (CounterData counterData in query) + if (null != query && query.Count > 0) { - string strBufferLine = index2 + "," + counterData.OutValue + "," + counterData.Value + "," + counterData.Sensitivity + "," + counterData.LogTime; - strmWriterObj.WriteLine(strBufferLine); - index2++; + strmWriterObj.WriteLine("计数器范围及灵敏度"); + strmWriterObj.WriteLine("序号,输出值,测量值,灵敏度,时间"); + int index2 = 1; + foreach (CounterData counterData in query) + { + string strBufferLine = index2 + "," + counterData.OutValue + "," + counterData.Value + "," + counterData.Sensitivity + "," + counterData.LogTime; + strmWriterObj.WriteLine(strBufferLine); + index2++; + } } strmWriterObj.Close(); MessageBox.Show("导出成功,存放位置:" + strFilePath); diff --git a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs index ec02ee3..ba3c1cf 100644 --- a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs +++ b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs @@ -51,6 +51,7 @@ private String accuracy; private String bootFeature; private String ageRate; + private long detectionItemId; public long Id { @@ -251,5 +252,6 @@ public string Accuracy { get => accuracy; set => accuracy = value; } public string BootFeature { get => bootFeature; set => bootFeature = value; } public string AgeRate { get => ageRate; set => ageRate = value; } + public long DetectionItemId { get => detectionItemId; set => detectionItemId = value; } } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 3fe0773..64253a7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -16,7 +16,7 @@ List search(long deviceId, bool isInDetection); - int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData); + int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); 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 5c4cda2..b849d77 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -115,6 +115,56 @@ } return iRetval; } + public int startDetect(long detectionItemId, string stability, string accuracy, string bootFeature, string ageRate) + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + if (stability.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + + string sQry = "UPDATE r_detection_item SET"; + if (!stability.Equals("")) + sQry = sQry + " STABILITY=@STABILITY"; + if (!accuracy.Equals("")) + sQry = sQry + " ACCURACY=@ACCURACY"; + if (!bootFeature.Equals("")) + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + if (!ageRate.Equals("")) + sQry = sQry + " AGE_RATE=@AGE_RATE"; + sQry = sQry + " where ID = " + detectionItemId; + + + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; + cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; + cmd.Parameters.Add("@BOOT_FEATURE", MySqlDbType.String, 10).Value = bootFeature; + cmd.Parameters.Add("@AGE_RATE", MySqlDbType.String, 10).Value = ageRate; + + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + iRetval = 0; + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + iRetval = -1; + } + + return iRetval; + } public int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100) { @@ -134,28 +184,28 @@ } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stability : "+ stability); string sQry = "UPDATE r_detection_item SET"; if(!stability.Equals("")) - sQry = sQry + " STABILITY=@STABILITY"; + sQry = sQry + " STABILITY=@STABILITY,"; if (!accuracy.Equals("")) - sQry = sQry + " ACCURACY=@ACCURACY"; + sQry = sQry + " ACCURACY=@ACCURACY,"; if (!bootFeature.Equals("")) - sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE,"; if (!ageRate.Equals("")) - sQry = sQry + " AGE_RATE=@AGE_RATE"; - if (!counterDetec.Equals("")) - sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC"; + sQry = sQry + " AGE_RATE=@AGE_RATE,"; if (!stability1.Equals("")) - sQry = sQry + " STABILITY_1=@STABILITY_1"; + sQry = sQry + " STABILITY_1=@STABILITY_1,"; if (!stability10.Equals("")) - sQry = sQry + " STABILITY_10=@STABILITY_10"; + sQry = sQry + " STABILITY_10=@STABILITY_10,"; if (!stability20.Equals("")) - sQry = sQry + " STABILITY_20=@STABILITY_20"; + sQry = sQry + " STABILITY_20=@STABILITY_20,"; if (!stability100.Equals("")) - sQry = sQry + " STABILITY_100=@STABILITY_100"; - sQry = sQry + " where ID = " + detectionId; + sQry = sQry + " STABILITY_100=@STABILITY_100,"; + sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; @@ -220,7 +270,7 @@ return iRetval; } - public int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData) + public int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData) { int iRetval = -1; try @@ -241,17 +291,25 @@ cmd.Parameters.Add("@CHANNEL", MySqlDbType.String, 20).Value = ""; cmd.ExecuteNonQuery(); + if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime + "' and '" + endTime + "')"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } + else + { + sQry = "UPDATE r_detection_item SET END_TIME=@END_TIME WHERE ID="+ detectionItemId; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@END_TIME", MySqlDbType.DateTime, 20).Value = DateTime.Now; + cmd.ExecuteNonQuery(); + } cmd.Dispose(); iRetval = 0; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 8773cb6..2de0df9 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -87,7 +87,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry + "; statusId="+ statusId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -101,9 +101,6 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); - - iRetval = 0; } catch (MySqlException ex) @@ -205,7 +202,7 @@ if (!aReader.IsDBNull(7)) deviceDto.CustomerDev = aReader.GetString(7); if (!aReader.IsDBNull(8)) { - deviceDto.StatusId = aReader.GetString(7); + deviceDto.StatusId = aReader.GetString(8); } if (!aReader.IsDBNull(9)) deviceDto.Channel = aReader.GetString(9); @@ -481,7 +478,7 @@ } } - string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 "; + string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -523,7 +520,7 @@ if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - + if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); deviceViewList.Add(deviceView); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index ff6a679..1626aa5 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -27,7 +27,7 @@ } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index e1b99b2..936cc37 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -224,7 +224,19 @@ } private void SelectCounter() { - + // 移除所有按钮的选中样式 + ClearAllMenuSelected(); + + // 鼠标移入效果去掉 + LeaveCounter(); + + // 重新设置所有按钮的状态 + menuSelected = new bool[] { false, false, false, true, false, false }; + + // 将新选中的按钮设置为选中 + picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + labCounterText.ForeColor = menuSelectedColor; + labCounterSelected.BackColor = menuSelectedColor; // 切换到频率计数器的界面 switchMainPanel(3); @@ -242,10 +254,16 @@ } private void SelectData() { + //if (CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // return; + //} // 移除所有按钮的选中样式 ClearAllMenuSelected(); // 鼠标移入效果去掉 + LeaveData(); // 重新设置所有按钮的状态 @@ -331,6 +349,19 @@ portList.Add(new SerialPort()); portList.Add(new SerialPort()); portList.Add(new SerialPort()); + DeviceService deviceService = new DeviceServiceImpl(); + DetectionItemService detectionItemService = new DetectionItemServiceImpl(); + List listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + long deviceId = device.Id; + string startTime = device.StartTime; + string endTime = device.EndTime; + detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); + } + } } else { @@ -500,24 +531,24 @@ private void switchMainPanel(int index) { - if (index != 3 && CounterCtrlForm.isDetecting) - { - MessageBox.Show("正在检测计数器,无法离开当前界面!"); - // 移除所有按钮的选中样式 - ClearAllMenuSelected(); + //if (index != 3 && CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // // 移除所有按钮的选中样式 + // ClearAllMenuSelected(); - // 鼠标移入效果去掉 - LeaveCounter(); + // // 鼠标移入效果去掉 + // LeaveCounter(); - // 重新设置所有按钮的状态 - menuSelected = new bool[] { false, false, false, true, false, false }; + // // 重新设置所有按钮的状态 + // menuSelected = new bool[] { false, false, false, true, false, false }; - // 将新选中的按钮设置为选中 - picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); - labCounterText.ForeColor = menuSelectedColor; - labCounterSelected.BackColor = menuSelectedColor; - return; - } + // // 将新选中的按钮设置为选中 + // picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + // labCounterText.ForeColor = menuSelectedColor; + // labCounterSelected.BackColor = menuSelectedColor; + // return; + //} panelMain.Controls.Clear(); switch (index) { diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index ecbb7e2..4405d66 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index 36ae30d..fd7ffee 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -111,7 +111,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), + Location = new Point(48, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); @@ -126,27 +126,12 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), + Location = new Point(142, 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 { @@ -156,7 +141,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(247, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -171,7 +156,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), + Location = new Point(360, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colValue); @@ -186,7 +171,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), + Location = new Point(465, 0), Size = new Size(95, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); @@ -280,6 +265,7 @@ dataGridView_CounterResult.DataSource = table_counterDetecInit; + dataGridView_CounterResult.Columns[3].Visible = false; dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; @@ -287,11 +273,10 @@ dataGridView_CounterResult.Columns[0].Width = 50; dataGridView_CounterResult.Columns[1].Width = 95; dataGridView_CounterResult.Columns[2].Width = 95; - 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[4].Width = 110; + dataGridView_CounterResult.Columns[5].Width = 110; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -773,17 +758,30 @@ 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 (!regex.IsMatch(value)) + if (textBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + dataGridView_CounterResult.CurrentCell.Value = ""; + MessageBox.Show("请输入格式正确的、带单位的测量频率!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + dataGridView_CounterResult.CurrentCell.Value = ""; + MessageBox.Show("请输入格式正确的、带单位的测量周期!"); + return; + } + } } } diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index fcefb48..09d1e4a 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -321,7 +321,7 @@ // this.pic_ageRate_5.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_5.Location = new System.Drawing.Point(151, 9); + this.pic_ageRate_5.Location = new System.Drawing.Point(224, 9); this.pic_ageRate_5.Name = "pic_ageRate_5"; this.pic_ageRate_5.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_5.TabIndex = 336; @@ -331,7 +331,7 @@ // this.pic_stability_5.BackColor = System.Drawing.Color.Transparent; this.pic_stability_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_5.Location = new System.Drawing.Point(85, 9); + this.pic_stability_5.Location = new System.Drawing.Point(12, 9); this.pic_stability_5.Name = "pic_stability_5"; this.pic_stability_5.Size = new System.Drawing.Size(16, 16); this.pic_stability_5.TabIndex = 333; @@ -341,7 +341,7 @@ // this.pic_accuracy_5.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_5.Location = new System.Drawing.Point(224, 9); + this.pic_accuracy_5.Location = new System.Drawing.Point(78, 9); this.pic_accuracy_5.Name = "pic_accuracy_5"; this.pic_accuracy_5.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_5.TabIndex = 334; @@ -351,7 +351,7 @@ // this.pic_bootFeature_5.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_5.Location = new System.Drawing.Point(9, 9); + this.pic_bootFeature_5.Location = new System.Drawing.Point(152, 9); this.pic_bootFeature_5.Name = "pic_bootFeature_5"; this.pic_bootFeature_5.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_5.TabIndex = 335; @@ -374,7 +374,7 @@ // this.pic_ageRate_4.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_4.Location = new System.Drawing.Point(151, 10); + this.pic_ageRate_4.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_4.Name = "pic_ageRate_4"; this.pic_ageRate_4.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_4.TabIndex = 332; @@ -384,7 +384,7 @@ // this.pic_stability_4.BackColor = System.Drawing.Color.Transparent; this.pic_stability_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_stability_4.Location = new System.Drawing.Point(85, 10); + this.pic_stability_4.Location = new System.Drawing.Point(12, 8); this.pic_stability_4.Name = "pic_stability_4"; this.pic_stability_4.Size = new System.Drawing.Size(16, 16); this.pic_stability_4.TabIndex = 329; @@ -394,7 +394,7 @@ // this.pic_accuracy_4.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_4.Location = new System.Drawing.Point(224, 10); + this.pic_accuracy_4.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_4.Name = "pic_accuracy_4"; this.pic_accuracy_4.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_4.TabIndex = 330; @@ -404,7 +404,7 @@ // this.pic_bootFeature_4.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_4.Location = new System.Drawing.Point(9, 10); + this.pic_bootFeature_4.Location = new System.Drawing.Point(152, 8); this.pic_bootFeature_4.Name = "pic_bootFeature_4"; this.pic_bootFeature_4.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_4.TabIndex = 331; @@ -427,7 +427,7 @@ // this.pic_ageRate_3.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_3.Location = new System.Drawing.Point(151, 8); + this.pic_ageRate_3.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_3.Name = "pic_ageRate_3"; this.pic_ageRate_3.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_3.TabIndex = 328; @@ -437,7 +437,7 @@ // this.pic_stability_3.BackColor = System.Drawing.Color.Transparent; this.pic_stability_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_3.Location = new System.Drawing.Point(85, 8); + this.pic_stability_3.Location = new System.Drawing.Point(12, 8); this.pic_stability_3.Name = "pic_stability_3"; this.pic_stability_3.Size = new System.Drawing.Size(16, 16); this.pic_stability_3.TabIndex = 325; @@ -447,7 +447,7 @@ // this.pic_accuracy_3.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_3.Location = new System.Drawing.Point(224, 8); + this.pic_accuracy_3.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_3.Name = "pic_accuracy_3"; this.pic_accuracy_3.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_3.TabIndex = 326; @@ -457,7 +457,7 @@ // this.pic_bootFeature_3.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_3.Location = new System.Drawing.Point(8, 8); + this.pic_bootFeature_3.Location = new System.Drawing.Point(151, 8); this.pic_bootFeature_3.Name = "pic_bootFeature_3"; this.pic_bootFeature_3.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_3.TabIndex = 327; @@ -480,7 +480,7 @@ // this.pic_ageRate_2.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_2.Location = new System.Drawing.Point(151, 7); + this.pic_ageRate_2.Location = new System.Drawing.Point(224, 7); this.pic_ageRate_2.Name = "pic_ageRate_2"; this.pic_ageRate_2.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_2.TabIndex = 324; @@ -490,7 +490,7 @@ // this.pic_stability_2.BackColor = System.Drawing.Color.Transparent; this.pic_stability_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_2.Location = new System.Drawing.Point(85, 7); + this.pic_stability_2.Location = new System.Drawing.Point(12, 7); this.pic_stability_2.Name = "pic_stability_2"; this.pic_stability_2.Size = new System.Drawing.Size(16, 16); this.pic_stability_2.TabIndex = 321; @@ -500,7 +500,7 @@ // this.pic_accuracy_2.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_2.Location = new System.Drawing.Point(224, 7); + this.pic_accuracy_2.Location = new System.Drawing.Point(78, 7); this.pic_accuracy_2.Name = "pic_accuracy_2"; this.pic_accuracy_2.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_2.TabIndex = 322; @@ -510,7 +510,7 @@ // this.pic_bootFeature_2.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_2.Location = new System.Drawing.Point(8, 7); + this.pic_bootFeature_2.Location = new System.Drawing.Point(151, 7); this.pic_bootFeature_2.Name = "pic_bootFeature_2"; this.pic_bootFeature_2.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_2.TabIndex = 323; @@ -533,7 +533,7 @@ // this.pic_ageRate_1.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_1.Location = new System.Drawing.Point(151, 8); + this.pic_ageRate_1.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_1.Name = "pic_ageRate_1"; this.pic_ageRate_1.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_1.TabIndex = 320; @@ -543,7 +543,7 @@ // this.pic_stability_1.BackColor = System.Drawing.Color.Transparent; this.pic_stability_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_1.Location = new System.Drawing.Point(85, 8); + this.pic_stability_1.Location = new System.Drawing.Point(12, 8); this.pic_stability_1.Name = "pic_stability_1"; this.pic_stability_1.Size = new System.Drawing.Size(16, 16); this.pic_stability_1.TabIndex = 317; @@ -553,7 +553,7 @@ // this.pic_accuracy_1.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_1.Location = new System.Drawing.Point(224, 8); + this.pic_accuracy_1.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_1.Name = "pic_accuracy_1"; this.pic_accuracy_1.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_1.TabIndex = 318; @@ -563,7 +563,7 @@ // this.pic_bootFeature_1.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_1.Location = new System.Drawing.Point(7, 8); + this.pic_bootFeature_1.Location = new System.Drawing.Point(150, 8); this.pic_bootFeature_1.Name = "pic_bootFeature_1"; this.pic_bootFeature_1.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_1.TabIndex = 319; @@ -598,7 +598,7 @@ dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.dataGridView_Channel.DefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_Channel.GridColor = System.Drawing.Color.DarkGray; - this.dataGridView_Channel.Location = new System.Drawing.Point(10, 10); + this.dataGridView_Channel.Location = new System.Drawing.Point(11, 10); this.dataGridView_Channel.Margin = new System.Windows.Forms.Padding(0); this.dataGridView_Channel.MultiSelect = false; this.dataGridView_Channel.Name = "dataGridView_Channel"; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index 5d75f74..ca3181d 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -60,6 +60,8 @@ label_clockStatus.Text = FreshStatus.clockStatus; label_receiverStatus.Text = StatusCtrlForm.receiverStatus; } + + } private void HomeCtrlForm_Load(object sender, EventArgs e) @@ -421,22 +423,6 @@ dataGridView_Channel.Controls.Add(colStatus); colStatus.BringToFront(); - // 开机特性 - Label colStartup = 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(colStartup); - colStartup.BringToFront(); - // 频率稳定度 Label colStablility = new Label { @@ -446,25 +432,13 @@ BackColor = titleBackColor, AutoSize = false, Text = "稳定度", - Location = new Point(759, 0), + + Location = new Point(684,0), Size = new Size(75, 30) }; dataGridView_Channel.Controls.Add(colStablility); colStablility.BringToFront(); - // 日老化率 - Label colAgingRate = 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) - }; - // 频率准确度 Label colAccuracy = new Label { @@ -474,11 +448,45 @@ BackColor = titleBackColor, AutoSize = false, Text = "准确度", - Location = new Point(899, 0), + 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) + }; + + @@ -506,142 +514,162 @@ } public void LoadChannelStatus() { - channelsTable = new DataTable(); - - channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); - channelsTable.Columns.Add("devName", Type.GetType("System.String")); - channelsTable.Columns.Add("devCode", Type.GetType("System.String")); - channelsTable.Columns.Add("customComp", Type.GetType("System.String")); - channelsTable.Columns.Add("startTime", Type.GetType("System.String")); - channelsTable.Columns.Add("endTime", Type.GetType("System.String")); - channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); - channelsTable.Columns.Add("startup", Type.GetType("System.String")); - channelsTable.Columns.Add("stablility", Type.GetType("System.String")); - channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); - channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); - channelsTable.Columns.Add("deviceId", Type.GetType("System.Int32")); - //channelsTable.Columns.Add("devType", Type.GetType("System.String")); - //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); - //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); - - listChannelStatus = deviceService.getDeviceByChannel(); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - if (listChannelStatus != null && listChannelStatus.Count > 0) + try { - foreach (DeviceView device in listChannelStatus) + channelsTable = new DataTable(); + + channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); + channelsTable.Columns.Add("devName", Type.GetType("System.String")); + channelsTable.Columns.Add("devCode", Type.GetType("System.String")); + channelsTable.Columns.Add("customComp", Type.GetType("System.String")); + channelsTable.Columns.Add("startTime", Type.GetType("System.String")); + channelsTable.Columns.Add("endTime", Type.GetType("System.String")); + channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); + channelsTable.Columns.Add("stablility", Type.GetType("System.String")); + channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); + channelsTable.Columns.Add("startup", Type.GetType("System.String")); + channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); + channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); + channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); + //channelsTable.Columns.Add("devType", Type.GetType("System.String")); + //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); + //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); + + listChannelStatus = deviceService.getDeviceByChannel(); + + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); + + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); - int index = Convert.ToInt32(device.Channel) - 1; - channelsTable.Rows[index]["channelNo"] = device.Channel; - channelsTable.Rows[index]["devName"] = device.DevName; - channelsTable.Rows[index]["devCode"] = device.DevCode; - channelsTable.Rows[index]["customComp"] = device.CustomerDev; - channelsTable.Rows[index]["startTime"] = device.StartTime; - channelsTable.Rows[index]["endTime"] = device.EndTime; - channelsTable.Rows[index]["channelStatus"] = "占用"; - channelsTable.Rows[index]["deviceId"] = device.Id; - if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + int index = Convert.ToInt32(device.Channel) - 1; + channelsTable.Rows[index]["channelNo"] = device.Channel; + channelsTable.Rows[index]["devName"] = device.DevName; + channelsTable.Rows[index]["devCode"] = device.DevCode; + channelsTable.Rows[index]["customComp"] = device.CustomerDev; + channelsTable.Rows[index]["startTime"] = device.StartTime; + channelsTable.Rows[index]["endTime"] = device.EndTime; + channelsTable.Rows[index]["channelStatus"] = "占用"; + channelsTable.Rows[index]["deviceId"] = device.Id; + channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; + + if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + } } + else + { + channelsTable.Rows.Clear(); + channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); + } + + foreach (string no in channelFreeList) + { + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; + } + + + dataGridView_Channel.DataSource = channelsTable; + + // width=764px + dataGridView_Channel.Columns[11].Visible = false; + dataGridView_Channel.Columns[12].Visible = false; + dataGridView_Channel.Columns[0].Width = 50; + dataGridView_Channel.Columns[1].Width = 110; + dataGridView_Channel.Columns[2].Width = 110; + dataGridView_Channel.Columns[3].Width = 110; + dataGridView_Channel.Columns[4].Width = 120; + dataGridView_Channel.Columns[5].Width = 120; + dataGridView_Channel.Columns[6].Width = 64; + dataGridView_Channel.Columns[7].Width = 75; + dataGridView_Channel.Columns[8].Width = 75; + dataGridView_Channel.Columns[9].Width = 75; + dataGridView_Channel.Columns[10].Width = 75; + + dataGridView_Channel.Columns[0].ReadOnly = true; + dataGridView_Channel.Columns[1].ReadOnly = true; + dataGridView_Channel.Columns[2].ReadOnly = true; + dataGridView_Channel.Columns[3].ReadOnly = true; + dataGridView_Channel.Columns[4].ReadOnly = true; + dataGridView_Channel.Columns[5].ReadOnly = true; + dataGridView_Channel.Columns[6].ReadOnly = true; + dataGridView_Channel.Columns[7].ReadOnly = true; + dataGridView_Channel.Columns[8].ReadOnly = true; + dataGridView_Channel.Columns[9].ReadOnly = true; + dataGridView_Channel.Columns[10].ReadOnly = true; } - else + catch (Exception ex) { - channelsTable.Rows.Clear(); - channelsTable.Rows.Add("1","","","","","","空闲",""); - channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", ""); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "LoadChannelStatus 错误:" + ex.Message); + } - - foreach (string no in channelFreeList) - { - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; - } - - - dataGridView_Channel.DataSource = channelsTable; - - // width=764px - dataGridView_Channel.Columns[11].Visible = false; - dataGridView_Channel.Columns[0].Width = 50; - dataGridView_Channel.Columns[1].Width = 110; - dataGridView_Channel.Columns[2].Width = 110; - dataGridView_Channel.Columns[3].Width = 110; - dataGridView_Channel.Columns[4].Width = 120; - dataGridView_Channel.Columns[5].Width = 120; - dataGridView_Channel.Columns[6].Width = 64; - dataGridView_Channel.Columns[7].Width = 75; - dataGridView_Channel.Columns[8].Width = 75; - dataGridView_Channel.Columns[9].Width = 75; - dataGridView_Channel.Columns[10].Width = 75; - - dataGridView_Channel.Columns[0].ReadOnly = true; - dataGridView_Channel.Columns[1].ReadOnly = true; - dataGridView_Channel.Columns[2].ReadOnly = true; - dataGridView_Channel.Columns[3].ReadOnly = true; - dataGridView_Channel.Columns[4].ReadOnly = true; - dataGridView_Channel.Columns[5].ReadOnly = true; - dataGridView_Channel.Columns[6].ReadOnly = true; - dataGridView_Channel.Columns[7].ReadOnly = true; - dataGridView_Channel.Columns[8].ReadOnly = true; - dataGridView_Channel.Columns[9].ReadOnly = true; - dataGridView_Channel.Columns[10].ReadOnly = true; - } private void dataGridView_Channel_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) - { - dataGridView_Channel.ClearSelection(); + { + try + { + dataGridView_Channel.ClearSelection(); - int channelNo = e.RowIndex + 1; - if (channelFreeList.Contains(channelNo + "")) - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + int channelNo = e.RowIndex + 1; + if (channelFreeList.Contains(channelNo + "")) + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + } + else + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + } + foreach (string no in channelFreeList) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } } - else + catch (Exception ex) { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - } - foreach (string no in channelFreeList) - { - 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, "dataGridView_Channel_RowPostPaint 错误:" + ex.Message); + } } @@ -701,7 +729,8 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - int deviceId = (int)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + 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) @@ -712,11 +741,11 @@ DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { - detectionItemService.stopDetection(deviceId, startTime, endTime, false); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); } else { - detectionItemService.stopDetection(deviceId, startTime, endTime, true); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); } LoadChannelStatus(); LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 6aaa532..f99f106 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -132,16 +132,16 @@ return; } timePicker_endTime.Value = endTimeBySystem; - + // 打开串口 DetectionHelper detectionHelper = new DetectionHelper(); - + SerialPort port = RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1]; string portName = ConfigHelper.GetAppConfig("channel" + textBox_channelNo.Text).Split(' ')[0]; int band = Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + textBox_channelNo.Text).Split(' ')[1]); if (port.IsOpen) port.Close(); - + port.PortName = portName; port.BaudRate = band; port.Parity = Parity.None; @@ -159,12 +159,12 @@ return; } } - catch(Exception exc) + catch (Exception exc) { MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } - + if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); @@ -321,7 +321,7 @@ else if (checkBox10s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101 * 10).AddSeconds(40); else if (checkBox1s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101).AddSeconds(40); } - else endTimeBySystem = DateTime.Now.AddMinutes(1).AddSeconds(30); + else endTimeBySystem = timePicker_startTime.Value.AddMinutes(1).AddSeconds(30); } } diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 1bb08ca..1a82d85 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -287,7 +287,7 @@ else if (checkBox10s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101 * 10).AddSeconds(40); else if (checkBox1s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101).AddSeconds(40); } - else endTimeBySystem = DateTime.Now.AddMinutes(1).AddSeconds(30); + else endTimeBySystem = timePicker_startTime.Value.AddMinutes(1).AddSeconds(30); } } timePicker_endTime.Value = endTimeBySystem; diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 5d7de27..ed117e0 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -173,7 +173,7 @@ string portName = ""; SerialPort port = new SerialPort(); - DetectionHelper detectionHelper = new DetectionHelper(); + DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) { port.Dispose(); @@ -181,7 +181,7 @@ picker_endTime.Value = endTimeBySystem; startTime = picker_startTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); endTime = picker_endTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); - + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "结束时间: " + endTime); needDetec = true; portName = ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[0]; int band =Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[1]); @@ -247,9 +247,7 @@ } } else if (labelTitle.Text.Equals("修改")) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "修改" + deviceId); - + { if (needDetec) statusId = "2"; devService.update(deviceId, devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo,statusId); LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update 完成"); @@ -450,7 +448,7 @@ else if (checkBox10s.Checked) endTimeBySystem = picker_startTime.Value.AddSeconds(101 * 10).AddSeconds(40); else if (checkBox1s.Checked) endTimeBySystem = picker_startTime.Value.AddSeconds(101).AddSeconds(40); } - else endTimeBySystem = DateTime.Now.AddMinutes(1).AddSeconds(30); + else endTimeBySystem = picker_startTime.Value.AddMinutes(1).AddSeconds(30); } } diff --git a/RbFreqStandMeasure/info/ExportDlg.cs b/RbFreqStandMeasure/info/ExportDlg.cs index 6b1b03a..edecd98 100644 --- a/RbFreqStandMeasure/info/ExportDlg.cs +++ b/RbFreqStandMeasure/info/ExportDlg.cs @@ -11,6 +11,7 @@ using System.Drawing; using System.IO; using System.IO.Ports; +using System.Reflection; using System.Runtime.InteropServices; using System.Windows.Forms; @@ -106,11 +107,11 @@ List queryList = detectionItemService.search(deviceId, false); if (null != queryList && queryList.Count > 0) { - int index = 1; foreach (DetectionItem detection in queryList) { tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime, detection.Accuracy, detection.Stability, detection.BootFeature, detection.AgeRate, detection.Channel, detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100,detection.Id); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "detection.Id :" + detection.Id); index++; } @@ -130,8 +131,8 @@ dataGridView_times.Columns[10].Visible = false; dataGridView_times.Columns[11].Visible = false; dataGridView_times.Columns[12].Visible = false; + dataGridView_times.Columns[13].Visible = false; - dataGridView_times.Columns[1].ReadOnly = true; dataGridView_times.Columns[2].ReadOnly = true; dataGridView_times.Columns[3].ReadOnly = true; @@ -142,6 +143,8 @@ dataGridView_times.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable; dataGridView_times.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable; dataGridView_times.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable; + dataGridView_times.Columns[7].SortMode = DataGridViewColumnSortMode.NotSortable; + dataGridView_times.Columns[8].SortMode = DataGridViewColumnSortMode.NotSortable; } else { @@ -214,7 +217,6 @@ StreamWriter strmWriterObj = new StreamWriter(strFilePath, false, System.Text.Encoding.UTF8); strmWriterObj.WriteLine(label_devName.Text + " - " + label_devType.Text + "-" + "测试数据及结果"); - strmWriterObj.WriteLine("序号,时间,相对频率偏差"); foreach (DataGridViewRow row in dataGridView_times.Rows) { DataGridViewCheckBoxCell checkBox = (DataGridViewCheckBoxCell)row.Cells[0]; @@ -230,12 +232,17 @@ { string typeStr = type + ""; if (type == 1) typeStr = "1-1"; - else if(type == 2) typeStr = "1-10"; - else if (type == 3) typeStr = "1-20"; - else if (type == 4) typeStr = "1-100"; + if(type == 2) typeStr = "1-10"; + if (type == 3) typeStr = "1-20"; + if (type == 4) typeStr = "1-100"; + if(type == 5) typeStr = "2"; + if (type == 6) typeStr = "3"; + if (type == 7) typeStr = "4"; // 获取数据 - List List = detectionService.search(deviceId, typeStr, startTime, endTime,Convert.ToInt64(row.Cells[12].Value)); + List List = detectionService.search(deviceId, typeStr, startTime, endTime,Convert.ToInt64(row.Cells[13].Value)); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "List.count :" + List.Count +";itemid="+ Convert.ToInt64(row.Cells[13].Value)+ ";typeStr"+ typeStr+";devid="+ deviceId); + if (null != List && List.Count > 0) { string detecItemName = ""; @@ -270,14 +277,17 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); List query = counterDataService.getHistory(deviceId, "", ""); - strmWriterObj.WriteLine("计数器范围及灵敏度"); - strmWriterObj.WriteLine("序号,输出值,测量值,灵敏度,时间"); - int index2 = 1; - foreach (CounterData counterData in query) + if (null != query && query.Count > 0) { - string strBufferLine = index2 + "," + counterData.OutValue + "," + counterData.Value + "," + counterData.Sensitivity + "," + counterData.LogTime; - strmWriterObj.WriteLine(strBufferLine); - index2++; + strmWriterObj.WriteLine("计数器范围及灵敏度"); + strmWriterObj.WriteLine("序号,输出值,测量值,灵敏度,时间"); + int index2 = 1; + foreach (CounterData counterData in query) + { + string strBufferLine = index2 + "," + counterData.OutValue + "," + counterData.Value + "," + counterData.Sensitivity + "," + counterData.LogTime; + strmWriterObj.WriteLine(strBufferLine); + index2++; + } } strmWriterObj.Close(); MessageBox.Show("导出成功,存放位置:" + strFilePath); diff --git a/RbFreqStandMeasure/info/InfoCtrlForm.Designer.cs b/RbFreqStandMeasure/info/InfoCtrlForm.Designer.cs index a151c85..adc57a4 100644 --- a/RbFreqStandMeasure/info/InfoCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/info/InfoCtrlForm.Designer.cs @@ -29,8 +29,8 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.panelNodata = new System.Windows.Forms.Panel(); this.labelNodata = new System.Windows.Forms.Label(); @@ -170,14 +170,14 @@ this.dataGridView_DevList.AllowUserToDeleteRows = false; this.dataGridView_DevList.AllowUserToResizeColumns = false; this.dataGridView_DevList.AllowUserToResizeRows = false; - 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.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_DevList.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; + 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.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_DevList.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; this.dataGridView_DevList.BackgroundColor = System.Drawing.Color.White; this.dataGridView_DevList.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_DevList.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; @@ -189,15 +189,15 @@ this.dataGridView_DevList.ReadOnly = true; this.dataGridView_DevList.RowHeadersVisible = false; this.dataGridView_DevList.RowHeadersWidth = 30; - 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.NullValue = "-"; - dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_DevList.RowsDefaultCellStyle = dataGridViewCellStyle2; + 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.NullValue = "-"; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_DevList.RowsDefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_DevList.RowTemplate.Height = 44; this.dataGridView_DevList.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView_DevList.Size = new System.Drawing.Size(964, 480); @@ -251,6 +251,7 @@ // // inputDevStatus // + this.inputDevStatus.BackColor = System.Drawing.Color.White; // // // @@ -264,6 +265,7 @@ this.inputDevStatus.MaximumSize = new System.Drawing.Size(150, 28); this.inputDevStatus.Name = "inputDevStatus"; this.inputDevStatus.PreventEnterBeep = true; + this.inputDevStatus.ReadOnly = true; this.inputDevStatus.Size = new System.Drawing.Size(150, 28); this.inputDevStatus.TabIndex = 15; this.inputDevStatus.WatermarkColor = System.Drawing.Color.Silver; diff --git a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs index ec02ee3..ba3c1cf 100644 --- a/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs +++ b/RbFreqStandMeasure/R_DataBase/Dto/DeviceView.cs @@ -51,6 +51,7 @@ private String accuracy; private String bootFeature; private String ageRate; + private long detectionItemId; public long Id { @@ -251,5 +252,6 @@ public string Accuracy { get => accuracy; set => accuracy = value; } public string BootFeature { get => bootFeature; set => bootFeature = value; } public string AgeRate { get => ageRate; set => ageRate = value; } + public long DetectionItemId { get => detectionItemId; set => detectionItemId = value; } } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 3fe0773..64253a7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -16,7 +16,7 @@ List search(long deviceId, bool isInDetection); - int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData); + int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); 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 5c4cda2..b849d77 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -115,6 +115,56 @@ } return iRetval; } + public int startDetect(long detectionItemId, string stability, string accuracy, string bootFeature, string ageRate) + { + int iRetval = -1; + + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem : 数据库链接断开"); + iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return iRetval; + } + } + + if (stability.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + + string sQry = "UPDATE r_detection_item SET"; + if (!stability.Equals("")) + sQry = sQry + " STABILITY=@STABILITY"; + if (!accuracy.Equals("")) + sQry = sQry + " ACCURACY=@ACCURACY"; + if (!bootFeature.Equals("")) + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + if (!ageRate.Equals("")) + sQry = sQry + " AGE_RATE=@AGE_RATE"; + sQry = sQry + " where ID = " + detectionItemId; + + + MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; + cmd.Parameters.Add("@ACCURACY", MySqlDbType.String, 10).Value = accuracy; + cmd.Parameters.Add("@BOOT_FEATURE", MySqlDbType.String, 10).Value = bootFeature; + cmd.Parameters.Add("@AGE_RATE", MySqlDbType.String, 10).Value = ageRate; + + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + iRetval = 0; + } + catch (MySqlException e) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "updateDetectionItem: " + e.Message); + iRetval = -1; + } + + return iRetval; + } public int updateDetecStatus(long detectionId, string stability, string accuracy, string bootFeature, string ageRate, string counterDetec, string stability1, string stability10, string stability20, string stability100) { @@ -134,28 +184,28 @@ } if (stability.Equals("")&&stability10.Equals("") && stability20.Equals("") && stability100.Equals("") && stability1.Equals("") && accuracy.Equals("") && bootFeature.Equals("") && ageRate.Equals("")) return -1; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "stability : "+ stability); string sQry = "UPDATE r_detection_item SET"; if(!stability.Equals("")) - sQry = sQry + " STABILITY=@STABILITY"; + sQry = sQry + " STABILITY=@STABILITY,"; if (!accuracy.Equals("")) - sQry = sQry + " ACCURACY=@ACCURACY"; + sQry = sQry + " ACCURACY=@ACCURACY,"; if (!bootFeature.Equals("")) - sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE"; + sQry = sQry + " BOOT_FEATURE=@BOOT_FEATURE,"; if (!ageRate.Equals("")) - sQry = sQry + " AGE_RATE=@AGE_RATE"; - if (!counterDetec.Equals("")) - sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC"; + sQry = sQry + " AGE_RATE=@AGE_RATE,"; if (!stability1.Equals("")) - sQry = sQry + " STABILITY_1=@STABILITY_1"; + sQry = sQry + " STABILITY_1=@STABILITY_1,"; if (!stability10.Equals("")) - sQry = sQry + " STABILITY_10=@STABILITY_10"; + sQry = sQry + " STABILITY_10=@STABILITY_10,"; if (!stability20.Equals("")) - sQry = sQry + " STABILITY_20=@STABILITY_20"; + sQry = sQry + " STABILITY_20=@STABILITY_20,"; if (!stability100.Equals("")) - sQry = sQry + " STABILITY_100=@STABILITY_100"; - sQry = sQry + " where ID = " + detectionId; + sQry = sQry + " STABILITY_100=@STABILITY_100,"; + sQry = sQry + " COUNTER_DETEC=@COUNTER_DETEC where ID = " + detectionId; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQrys!Qrys!="+ sQry+ ";stability="+ stability+";DETECTION_ITEM_ID="+ detectionId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@STABILITY", MySqlDbType.String, 10).Value = stability; @@ -220,7 +270,7 @@ return iRetval; } - public int stopDetection(long deviceId, string startTime, string endTime, bool isDeleteData) + public int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData) { int iRetval = -1; try @@ -241,17 +291,25 @@ cmd.Parameters.Add("@CHANNEL", MySqlDbType.String, 20).Value = ""; cmd.ExecuteNonQuery(); + if (isDeleteData) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : "+ startTime + " endtime:"+endTime); - sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime+"'"; + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "starttime : " + startTime + " endtime:" + endTime); + sQry = "DELETE FROM r_detection_item WHERE DEVICE_ID = " + deviceId + " AND START_TIME='" + startTime + "' AND END_TIME='" + endTime + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); - sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime+"' and '" + endTime + "')" ; + sQry = "DELETE FROM r_detection WHERE DEVICE_ID = " + deviceId + " AND (LOG_TIME between'" + startTime + "' and '" + endTime + "')"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); } + else + { + sQry = "UPDATE r_detection_item SET END_TIME=@END_TIME WHERE ID="+ detectionItemId; + cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + cmd.Parameters.Add("@END_TIME", MySqlDbType.DateTime, 20).Value = DateTime.Now; + cmd.ExecuteNonQuery(); + } cmd.Dispose(); iRetval = 0; diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 8773cb6..2de0df9 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -87,7 +87,7 @@ string sQry = "UPDATE r_device SET DEV_NAME=@DEV_NAME, DEV_CODE=@DEV_CODE ,DEV_TYPEID=@DEV_TYPEID ,DEV_MODEL=@DEV_MODEL ,CUSTOMER_NAME=@CUSTOMER_NAME ,CUSTOMER_DEV=@CUSTOMER_DEV ,CHANNEL=@CHANNEL "; if (!statusId.Equals("")) sQry = sQry + ", STATUSID=@STATUSID"; sQry = sQry+ " WHERE ID = " + id; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "sQry : "+ sQry + "; statusId="+ statusId); MySqlCommand cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.Parameters.Add("@DEV_NAME", MySqlDbType.String, 30).Value = devName; @@ -101,9 +101,6 @@ cmd.ExecuteNonQuery(); cmd.Dispose(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "iRetval : " + 0); - - iRetval = 0; } catch (MySqlException ex) @@ -205,7 +202,7 @@ if (!aReader.IsDBNull(7)) deviceDto.CustomerDev = aReader.GetString(7); if (!aReader.IsDBNull(8)) { - deviceDto.StatusId = aReader.GetString(7); + deviceDto.StatusId = aReader.GetString(8); } if (!aReader.IsDBNull(9)) deviceDto.Channel = aReader.GetString(9); @@ -481,7 +478,7 @@ } } - string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 "; + string sQry = "SELECT * FROM r_deviceview where ACTIVE = 0 and STATUSID = 2 " + "and ('" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "' <= END_TIME)"; MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); @@ -523,7 +520,7 @@ if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); if (!aReader.IsDBNull(16)) deviceView.AgeRate = aReader.GetString(16); - + if (!aReader.IsDBNull(17)) deviceView.DetectionItemId = Convert.ToInt64(aReader.GetString(17)); deviceViewList.Add(deviceView); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs index ff6a679..1626aa5 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DictServiceImpl.cs @@ -27,7 +27,7 @@ } string sql = "SELECT name FROM r_dict where pid = (select id from r_dict where code = '" + codeType + "') and code = " + code; - + MySqlCommand cmd = new MySqlCommand(sql, DbConnectService.mySqlConnect); MySqlDataReader aReader = cmd.ExecuteReader(CommandBehavior.Default); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index e1b99b2..936cc37 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -224,7 +224,19 @@ } private void SelectCounter() { - + // 移除所有按钮的选中样式 + ClearAllMenuSelected(); + + // 鼠标移入效果去掉 + LeaveCounter(); + + // 重新设置所有按钮的状态 + menuSelected = new bool[] { false, false, false, true, false, false }; + + // 将新选中的按钮设置为选中 + picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + labCounterText.ForeColor = menuSelectedColor; + labCounterSelected.BackColor = menuSelectedColor; // 切换到频率计数器的界面 switchMainPanel(3); @@ -242,10 +254,16 @@ } private void SelectData() { + //if (CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // return; + //} // 移除所有按钮的选中样式 ClearAllMenuSelected(); // 鼠标移入效果去掉 + LeaveData(); // 重新设置所有按钮的状态 @@ -331,6 +349,19 @@ portList.Add(new SerialPort()); portList.Add(new SerialPort()); portList.Add(new SerialPort()); + DeviceService deviceService = new DeviceServiceImpl(); + DetectionItemService detectionItemService = new DetectionItemServiceImpl(); + List listChannelStatus = deviceService.getDeviceByChannel(); + if (listChannelStatus != null && listChannelStatus.Count > 0) + { + foreach (DeviceView device in listChannelStatus) + { + long deviceId = device.Id; + string startTime = device.StartTime; + string endTime = device.EndTime; + detectionItemService.stopDetection(deviceId, device.DetectionItemId, startTime, endTime, true); + } + } } else { @@ -500,24 +531,24 @@ private void switchMainPanel(int index) { - if (index != 3 && CounterCtrlForm.isDetecting) - { - MessageBox.Show("正在检测计数器,无法离开当前界面!"); - // 移除所有按钮的选中样式 - ClearAllMenuSelected(); + //if (index != 3 && CounterCtrlForm.isDetecting) + //{ + // MessageBox.Show("正在检测计数器,无法离开当前界面!"); + // // 移除所有按钮的选中样式 + // ClearAllMenuSelected(); - // 鼠标移入效果去掉 - LeaveCounter(); + // // 鼠标移入效果去掉 + // LeaveCounter(); - // 重新设置所有按钮的状态 - menuSelected = new bool[] { false, false, false, true, false, false }; + // // 重新设置所有按钮的状态 + // menuSelected = new bool[] { false, false, false, true, false, false }; - // 将新选中的按钮设置为选中 - picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); - labCounterText.ForeColor = menuSelectedColor; - labCounterSelected.BackColor = menuSelectedColor; - return; - } + // // 将新选中的按钮设置为选中 + // picIconCounter.BackgroundImage = (Bitmap)Resources.ResourceManager.GetObject("icon_counter_selected", null); + // labCounterText.ForeColor = menuSelectedColor; + // labCounterSelected.BackColor = menuSelectedColor; + // return; + //} panelMain.Controls.Clear(); switch (index) { diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index ecbb7e2..4405d66 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index 36ae30d..fd7ffee 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -111,7 +111,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), + Location = new Point(48, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); @@ -126,27 +126,12 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), + Location = new Point(142, 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 { @@ -156,7 +141,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(247, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -171,7 +156,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), + Location = new Point(360, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colValue); @@ -186,7 +171,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), + Location = new Point(465, 0), Size = new Size(95, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); @@ -280,6 +265,7 @@ dataGridView_CounterResult.DataSource = table_counterDetecInit; + dataGridView_CounterResult.Columns[3].Visible = false; dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; @@ -287,11 +273,10 @@ dataGridView_CounterResult.Columns[0].Width = 50; dataGridView_CounterResult.Columns[1].Width = 95; dataGridView_CounterResult.Columns[2].Width = 95; - 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[4].Width = 110; + dataGridView_CounterResult.Columns[5].Width = 110; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -773,17 +758,30 @@ 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 (!regex.IsMatch(value)) + if (textBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + dataGridView_CounterResult.CurrentCell.Value = ""; + MessageBox.Show("请输入格式正确的、带单位的测量频率!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + dataGridView_CounterResult.CurrentCell.Value = ""; + MessageBox.Show("请输入格式正确的、带单位的测量周期!"); + return; + } + } } } diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs index fcefb48..09d1e4a 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.Designer.cs @@ -321,7 +321,7 @@ // this.pic_ageRate_5.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_5.Location = new System.Drawing.Point(151, 9); + this.pic_ageRate_5.Location = new System.Drawing.Point(224, 9); this.pic_ageRate_5.Name = "pic_ageRate_5"; this.pic_ageRate_5.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_5.TabIndex = 336; @@ -331,7 +331,7 @@ // this.pic_stability_5.BackColor = System.Drawing.Color.Transparent; this.pic_stability_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_5.Location = new System.Drawing.Point(85, 9); + this.pic_stability_5.Location = new System.Drawing.Point(12, 9); this.pic_stability_5.Name = "pic_stability_5"; this.pic_stability_5.Size = new System.Drawing.Size(16, 16); this.pic_stability_5.TabIndex = 333; @@ -341,7 +341,7 @@ // this.pic_accuracy_5.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_5.Location = new System.Drawing.Point(224, 9); + this.pic_accuracy_5.Location = new System.Drawing.Point(78, 9); this.pic_accuracy_5.Name = "pic_accuracy_5"; this.pic_accuracy_5.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_5.TabIndex = 334; @@ -351,7 +351,7 @@ // this.pic_bootFeature_5.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_5.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_5.Location = new System.Drawing.Point(9, 9); + this.pic_bootFeature_5.Location = new System.Drawing.Point(152, 9); this.pic_bootFeature_5.Name = "pic_bootFeature_5"; this.pic_bootFeature_5.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_5.TabIndex = 335; @@ -374,7 +374,7 @@ // this.pic_ageRate_4.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_4.Location = new System.Drawing.Point(151, 10); + this.pic_ageRate_4.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_4.Name = "pic_ageRate_4"; this.pic_ageRate_4.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_4.TabIndex = 332; @@ -384,7 +384,7 @@ // this.pic_stability_4.BackColor = System.Drawing.Color.Transparent; this.pic_stability_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_stability_4.Location = new System.Drawing.Point(85, 10); + this.pic_stability_4.Location = new System.Drawing.Point(12, 8); this.pic_stability_4.Name = "pic_stability_4"; this.pic_stability_4.Size = new System.Drawing.Size(16, 16); this.pic_stability_4.TabIndex = 329; @@ -394,7 +394,7 @@ // this.pic_accuracy_4.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_4.Location = new System.Drawing.Point(224, 10); + this.pic_accuracy_4.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_4.Name = "pic_accuracy_4"; this.pic_accuracy_4.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_4.TabIndex = 330; @@ -404,7 +404,7 @@ // this.pic_bootFeature_4.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_4.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_4.Location = new System.Drawing.Point(9, 10); + this.pic_bootFeature_4.Location = new System.Drawing.Point(152, 8); this.pic_bootFeature_4.Name = "pic_bootFeature_4"; this.pic_bootFeature_4.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_4.TabIndex = 331; @@ -427,7 +427,7 @@ // this.pic_ageRate_3.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_3.Location = new System.Drawing.Point(151, 8); + this.pic_ageRate_3.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_3.Name = "pic_ageRate_3"; this.pic_ageRate_3.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_3.TabIndex = 328; @@ -437,7 +437,7 @@ // this.pic_stability_3.BackColor = System.Drawing.Color.Transparent; this.pic_stability_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_3.Location = new System.Drawing.Point(85, 8); + this.pic_stability_3.Location = new System.Drawing.Point(12, 8); this.pic_stability_3.Name = "pic_stability_3"; this.pic_stability_3.Size = new System.Drawing.Size(16, 16); this.pic_stability_3.TabIndex = 325; @@ -447,7 +447,7 @@ // this.pic_accuracy_3.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_3.Location = new System.Drawing.Point(224, 8); + this.pic_accuracy_3.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_3.Name = "pic_accuracy_3"; this.pic_accuracy_3.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_3.TabIndex = 326; @@ -457,7 +457,7 @@ // this.pic_bootFeature_3.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_3.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_3.Location = new System.Drawing.Point(8, 8); + this.pic_bootFeature_3.Location = new System.Drawing.Point(151, 8); this.pic_bootFeature_3.Name = "pic_bootFeature_3"; this.pic_bootFeature_3.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_3.TabIndex = 327; @@ -480,7 +480,7 @@ // this.pic_ageRate_2.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_2.Location = new System.Drawing.Point(151, 7); + this.pic_ageRate_2.Location = new System.Drawing.Point(224, 7); this.pic_ageRate_2.Name = "pic_ageRate_2"; this.pic_ageRate_2.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_2.TabIndex = 324; @@ -490,7 +490,7 @@ // this.pic_stability_2.BackColor = System.Drawing.Color.Transparent; this.pic_stability_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_2.Location = new System.Drawing.Point(85, 7); + this.pic_stability_2.Location = new System.Drawing.Point(12, 7); this.pic_stability_2.Name = "pic_stability_2"; this.pic_stability_2.Size = new System.Drawing.Size(16, 16); this.pic_stability_2.TabIndex = 321; @@ -500,7 +500,7 @@ // this.pic_accuracy_2.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_2.Location = new System.Drawing.Point(224, 7); + this.pic_accuracy_2.Location = new System.Drawing.Point(78, 7); this.pic_accuracy_2.Name = "pic_accuracy_2"; this.pic_accuracy_2.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_2.TabIndex = 322; @@ -510,7 +510,7 @@ // this.pic_bootFeature_2.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_2.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_2.Location = new System.Drawing.Point(8, 7); + this.pic_bootFeature_2.Location = new System.Drawing.Point(151, 7); this.pic_bootFeature_2.Name = "pic_bootFeature_2"; this.pic_bootFeature_2.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_2.TabIndex = 323; @@ -533,7 +533,7 @@ // this.pic_ageRate_1.BackColor = System.Drawing.Color.Transparent; this.pic_ageRate_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center; - this.pic_ageRate_1.Location = new System.Drawing.Point(151, 8); + this.pic_ageRate_1.Location = new System.Drawing.Point(224, 8); this.pic_ageRate_1.Name = "pic_ageRate_1"; this.pic_ageRate_1.Size = new System.Drawing.Size(16, 16); this.pic_ageRate_1.TabIndex = 320; @@ -543,7 +543,7 @@ // this.pic_stability_1.BackColor = System.Drawing.Color.Transparent; this.pic_stability_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_stability_1.Location = new System.Drawing.Point(85, 8); + this.pic_stability_1.Location = new System.Drawing.Point(12, 8); this.pic_stability_1.Name = "pic_stability_1"; this.pic_stability_1.Size = new System.Drawing.Size(16, 16); this.pic_stability_1.TabIndex = 317; @@ -553,7 +553,7 @@ // this.pic_accuracy_1.BackColor = System.Drawing.Color.Transparent; this.pic_accuracy_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_accuracy_1.Location = new System.Drawing.Point(224, 8); + this.pic_accuracy_1.Location = new System.Drawing.Point(78, 8); this.pic_accuracy_1.Name = "pic_accuracy_1"; this.pic_accuracy_1.Size = new System.Drawing.Size(16, 16); this.pic_accuracy_1.TabIndex = 318; @@ -563,7 +563,7 @@ // this.pic_bootFeature_1.BackColor = System.Drawing.Color.Transparent; this.pic_bootFeature_1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None; - this.pic_bootFeature_1.Location = new System.Drawing.Point(7, 8); + this.pic_bootFeature_1.Location = new System.Drawing.Point(150, 8); this.pic_bootFeature_1.Name = "pic_bootFeature_1"; this.pic_bootFeature_1.Size = new System.Drawing.Size(16, 16); this.pic_bootFeature_1.TabIndex = 319; @@ -598,7 +598,7 @@ dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; this.dataGridView_Channel.DefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_Channel.GridColor = System.Drawing.Color.DarkGray; - this.dataGridView_Channel.Location = new System.Drawing.Point(10, 10); + this.dataGridView_Channel.Location = new System.Drawing.Point(11, 10); this.dataGridView_Channel.Margin = new System.Windows.Forms.Padding(0); this.dataGridView_Channel.MultiSelect = false; this.dataGridView_Channel.Name = "dataGridView_Channel"; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index 5d75f74..ca3181d 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -60,6 +60,8 @@ label_clockStatus.Text = FreshStatus.clockStatus; label_receiverStatus.Text = StatusCtrlForm.receiverStatus; } + + } private void HomeCtrlForm_Load(object sender, EventArgs e) @@ -421,22 +423,6 @@ dataGridView_Channel.Controls.Add(colStatus); colStatus.BringToFront(); - // 开机特性 - Label colStartup = 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(colStartup); - colStartup.BringToFront(); - // 频率稳定度 Label colStablility = new Label { @@ -446,25 +432,13 @@ BackColor = titleBackColor, AutoSize = false, Text = "稳定度", - Location = new Point(759, 0), + + Location = new Point(684,0), Size = new Size(75, 30) }; dataGridView_Channel.Controls.Add(colStablility); colStablility.BringToFront(); - // 日老化率 - Label colAgingRate = 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) - }; - // 频率准确度 Label colAccuracy = new Label { @@ -474,11 +448,45 @@ BackColor = titleBackColor, AutoSize = false, Text = "准确度", - Location = new Point(899, 0), + 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) + }; + + @@ -506,142 +514,162 @@ } public void LoadChannelStatus() { - channelsTable = new DataTable(); - - channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); - channelsTable.Columns.Add("devName", Type.GetType("System.String")); - channelsTable.Columns.Add("devCode", Type.GetType("System.String")); - channelsTable.Columns.Add("customComp", Type.GetType("System.String")); - channelsTable.Columns.Add("startTime", Type.GetType("System.String")); - channelsTable.Columns.Add("endTime", Type.GetType("System.String")); - channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); - channelsTable.Columns.Add("startup", Type.GetType("System.String")); - channelsTable.Columns.Add("stablility", Type.GetType("System.String")); - channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); - channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); - channelsTable.Columns.Add("deviceId", Type.GetType("System.Int32")); - //channelsTable.Columns.Add("devType", Type.GetType("System.String")); - //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); - //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); - - listChannelStatus = deviceService.getDeviceByChannel(); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelsTable.Rows.Add(channelsTable.NewRow()); - channelFreeList.Clear(); - channelFreeList.Add("1"); - channelFreeList.Add("2"); - channelFreeList.Add("3"); - channelFreeList.Add("4"); - channelFreeList.Add("5"); - - if (listChannelStatus != null && listChannelStatus.Count > 0) + try { - foreach (DeviceView device in listChannelStatus) + channelsTable = new DataTable(); + + channelsTable.Columns.Add("channelNo", Type.GetType("System.String")); + channelsTable.Columns.Add("devName", Type.GetType("System.String")); + channelsTable.Columns.Add("devCode", Type.GetType("System.String")); + channelsTable.Columns.Add("customComp", Type.GetType("System.String")); + channelsTable.Columns.Add("startTime", Type.GetType("System.String")); + channelsTable.Columns.Add("endTime", Type.GetType("System.String")); + channelsTable.Columns.Add("channelStatus", Type.GetType("System.String")); + channelsTable.Columns.Add("stablility", Type.GetType("System.String")); + channelsTable.Columns.Add("accuracy", Type.GetType("System.String")); + channelsTable.Columns.Add("startup", Type.GetType("System.String")); + channelsTable.Columns.Add("agingRate", Type.GetType("System.String")); + channelsTable.Columns.Add("deviceId", Type.GetType("System.Int64")); + channelsTable.Columns.Add("deviceItemId", Type.GetType("System.Int64")); + //channelsTable.Columns.Add("devType", Type.GetType("System.String")); + //channelsTable.Columns.Add("devModel", Type.GetType("System.String")); + //channelsTable.Columns.Add("customCom", Type.GetType("System.String")); + + listChannelStatus = deviceService.getDeviceByChannel(); + + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelsTable.Rows.Add(channelsTable.NewRow()); + channelFreeList.Clear(); + channelFreeList.Add("1"); + channelFreeList.Add("2"); + channelFreeList.Add("3"); + channelFreeList.Add("4"); + channelFreeList.Add("5"); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); + + if (listChannelStatus != null && listChannelStatus.Count > 0) { - channelFreeList.Remove(device.Channel); - int index = Convert.ToInt32(device.Channel) - 1; - channelsTable.Rows[index]["channelNo"] = device.Channel; - channelsTable.Rows[index]["devName"] = device.DevName; - channelsTable.Rows[index]["devCode"] = device.DevCode; - channelsTable.Rows[index]["customComp"] = device.CustomerDev; - channelsTable.Rows[index]["startTime"] = device.StartTime; - channelsTable.Rows[index]["endTime"] = device.EndTime; - channelsTable.Rows[index]["channelStatus"] = "占用"; - channelsTable.Rows[index]["deviceId"] = device.Id; - if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + foreach (DeviceView device in listChannelStatus) + { + channelFreeList.Remove(device.Channel); + int index = Convert.ToInt32(device.Channel) - 1; + channelsTable.Rows[index]["channelNo"] = device.Channel; + channelsTable.Rows[index]["devName"] = device.DevName; + channelsTable.Rows[index]["devCode"] = device.DevCode; + channelsTable.Rows[index]["customComp"] = device.CustomerDev; + channelsTable.Rows[index]["startTime"] = device.StartTime; + channelsTable.Rows[index]["endTime"] = device.EndTime; + channelsTable.Rows[index]["channelStatus"] = "占用"; + channelsTable.Rows[index]["deviceId"] = device.Id; + channelsTable.Rows[index]["deviceItemId"] = device.DetectionItemId; + + if (device.Stability.Equals("-3")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Stability.Equals("-2")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Stability.Equals("-1")) this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_stability_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.Accuracy.Equals("-3")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.Accuracy.Equals("-2")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.Accuracy.Equals("-1")) this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_accuracy_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.AgeRate.Equals("-3")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.AgeRate.Equals("-2")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.AgeRate.Equals("-1")) this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_ageRate_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; - if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; - else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; - else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; - else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + if (device.BootFeature.Equals("-3")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.line; + else if (device.BootFeature.Equals("-2")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_gray; + else if (device.BootFeature.Equals("-1")) this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_orange; + else this.Controls.Find("pic_bootFeature_" + device.Channel, true)[0].BackgroundImage = Properties.Resources.dot_green; + } } + else + { + channelsTable.Rows.Clear(); + channelsTable.Rows.Add("1", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", "", ""); + channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", "", ""); + } + + foreach (string no in channelFreeList) + { + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; + channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; + } + + + dataGridView_Channel.DataSource = channelsTable; + + // width=764px + dataGridView_Channel.Columns[11].Visible = false; + dataGridView_Channel.Columns[12].Visible = false; + dataGridView_Channel.Columns[0].Width = 50; + dataGridView_Channel.Columns[1].Width = 110; + dataGridView_Channel.Columns[2].Width = 110; + dataGridView_Channel.Columns[3].Width = 110; + dataGridView_Channel.Columns[4].Width = 120; + dataGridView_Channel.Columns[5].Width = 120; + dataGridView_Channel.Columns[6].Width = 64; + dataGridView_Channel.Columns[7].Width = 75; + dataGridView_Channel.Columns[8].Width = 75; + dataGridView_Channel.Columns[9].Width = 75; + dataGridView_Channel.Columns[10].Width = 75; + + dataGridView_Channel.Columns[0].ReadOnly = true; + dataGridView_Channel.Columns[1].ReadOnly = true; + dataGridView_Channel.Columns[2].ReadOnly = true; + dataGridView_Channel.Columns[3].ReadOnly = true; + dataGridView_Channel.Columns[4].ReadOnly = true; + dataGridView_Channel.Columns[5].ReadOnly = true; + dataGridView_Channel.Columns[6].ReadOnly = true; + dataGridView_Channel.Columns[7].ReadOnly = true; + dataGridView_Channel.Columns[8].ReadOnly = true; + dataGridView_Channel.Columns[9].ReadOnly = true; + dataGridView_Channel.Columns[10].ReadOnly = true; } - else + catch (Exception ex) { - channelsTable.Rows.Clear(); - channelsTable.Rows.Add("1","","","","","","空闲",""); - channelsTable.Rows.Add("2", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("3", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("4", "", "", "", "", "", "空闲", ""); - channelsTable.Rows.Add("5", "", "", "", "", "", "空闲", ""); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "LoadChannelStatus 错误:" + ex.Message); + } - - foreach (string no in channelFreeList) - { - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelNo"] = no; - channelsTable.Rows[Convert.ToInt32(no) - 1]["channelStatus"] = "空闲"; - } - - - dataGridView_Channel.DataSource = channelsTable; - - // width=764px - dataGridView_Channel.Columns[11].Visible = false; - dataGridView_Channel.Columns[0].Width = 50; - dataGridView_Channel.Columns[1].Width = 110; - dataGridView_Channel.Columns[2].Width = 110; - dataGridView_Channel.Columns[3].Width = 110; - dataGridView_Channel.Columns[4].Width = 120; - dataGridView_Channel.Columns[5].Width = 120; - dataGridView_Channel.Columns[6].Width = 64; - dataGridView_Channel.Columns[7].Width = 75; - dataGridView_Channel.Columns[8].Width = 75; - dataGridView_Channel.Columns[9].Width = 75; - dataGridView_Channel.Columns[10].Width = 75; - - dataGridView_Channel.Columns[0].ReadOnly = true; - dataGridView_Channel.Columns[1].ReadOnly = true; - dataGridView_Channel.Columns[2].ReadOnly = true; - dataGridView_Channel.Columns[3].ReadOnly = true; - dataGridView_Channel.Columns[4].ReadOnly = true; - dataGridView_Channel.Columns[5].ReadOnly = true; - dataGridView_Channel.Columns[6].ReadOnly = true; - dataGridView_Channel.Columns[7].ReadOnly = true; - dataGridView_Channel.Columns[8].ReadOnly = true; - dataGridView_Channel.Columns[9].ReadOnly = true; - dataGridView_Channel.Columns[10].ReadOnly = true; - } private void dataGridView_Channel_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e) - { - dataGridView_Channel.ClearSelection(); + { + try + { + dataGridView_Channel.ClearSelection(); - int channelNo = e.RowIndex + 1; - if (channelFreeList.Contains(channelNo + "")) - { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + int channelNo = e.RowIndex + 1; + if (channelFreeList.Contains(channelNo + "")) + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; + } + else + { + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); + panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; + } + foreach (string no in channelFreeList) + { + dataGridView_Channel.Rows[Convert.ToInt32(no) - 1].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; + } } - else + catch (Exception ex) { - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); - panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - } - foreach (string no in channelFreeList) - { - 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, "dataGridView_Channel_RowPostPaint 错误:" + ex.Message); + } } @@ -701,7 +729,8 @@ if (MessageBox.Show("该通道有正在检测的仪器,确定要停止检测?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { - int deviceId = (int)dataGridView_Channel.Rows[rowIndex].Cells[11].Value; + 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) @@ -712,11 +741,11 @@ DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { - detectionItemService.stopDetection(deviceId, startTime, endTime, false); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); } else { - detectionItemService.stopDetection(deviceId, startTime, endTime, true); + detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); } LoadChannelStatus(); LoadDevToBeTested(); diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 6aaa532..f99f106 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -132,16 +132,16 @@ return; } timePicker_endTime.Value = endTimeBySystem; - + // 打开串口 DetectionHelper detectionHelper = new DetectionHelper(); - + SerialPort port = RbFreqStdMeas.portList[Convert.ToInt32(textBox_channelNo.Text) - 1]; string portName = ConfigHelper.GetAppConfig("channel" + textBox_channelNo.Text).Split(' ')[0]; int band = Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + textBox_channelNo.Text).Split(' ')[1]); if (port.IsOpen) port.Close(); - + port.PortName = portName; port.BaudRate = band; port.Parity = Parity.None; @@ -159,12 +159,12 @@ return; } } - catch(Exception exc) + catch (Exception exc) { MessageBox.Show("无法打开通道" + textBox_channelNo.Text + ",添加检测失败!"); return; } - + if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); @@ -321,7 +321,7 @@ else if (checkBox10s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101 * 10).AddSeconds(40); else if (checkBox1s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101).AddSeconds(40); } - else endTimeBySystem = DateTime.Now.AddMinutes(1).AddSeconds(30); + else endTimeBySystem = timePicker_startTime.Value.AddMinutes(1).AddSeconds(30); } } diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 1bb08ca..1a82d85 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -287,7 +287,7 @@ else if (checkBox10s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101 * 10).AddSeconds(40); else if (checkBox1s.Checked) endTimeBySystem = timePicker_startTime.Value.AddSeconds(101).AddSeconds(40); } - else endTimeBySystem = DateTime.Now.AddMinutes(1).AddSeconds(30); + else endTimeBySystem = timePicker_startTime.Value.AddMinutes(1).AddSeconds(30); } } timePicker_endTime.Value = endTimeBySystem; diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 5d7de27..ed117e0 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -173,7 +173,7 @@ string portName = ""; SerialPort port = new SerialPort(); - DetectionHelper detectionHelper = new DetectionHelper(); + DetectionHelper detectionHelper = new DetectionHelper(); if (!isInDetection && !channelNo.Equals("")) { port.Dispose(); @@ -181,7 +181,7 @@ picker_endTime.Value = endTimeBySystem; startTime = picker_startTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); endTime = picker_endTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); - + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "结束时间: " + endTime); needDetec = true; portName = ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[0]; int band =Convert.ToInt32(ConfigHelper.GetAppConfig("channel" + text_channelNo.Text).Split(' ')[1]); @@ -247,9 +247,7 @@ } } else if (labelTitle.Text.Equals("修改")) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "修改" + deviceId); - + { if (needDetec) statusId = "2"; devService.update(deviceId, devName, devCode, devTypeCode, devModel, devCustomComp, devCustomName, channelNo,statusId); LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "update 完成"); @@ -450,7 +448,7 @@ else if (checkBox10s.Checked) endTimeBySystem = picker_startTime.Value.AddSeconds(101 * 10).AddSeconds(40); else if (checkBox1s.Checked) endTimeBySystem = picker_startTime.Value.AddSeconds(101).AddSeconds(40); } - else endTimeBySystem = DateTime.Now.AddMinutes(1).AddSeconds(30); + else endTimeBySystem = picker_startTime.Value.AddMinutes(1).AddSeconds(30); } } diff --git a/RbFreqStandMeasure/info/ExportDlg.cs b/RbFreqStandMeasure/info/ExportDlg.cs index 6b1b03a..edecd98 100644 --- a/RbFreqStandMeasure/info/ExportDlg.cs +++ b/RbFreqStandMeasure/info/ExportDlg.cs @@ -11,6 +11,7 @@ using System.Drawing; using System.IO; using System.IO.Ports; +using System.Reflection; using System.Runtime.InteropServices; using System.Windows.Forms; @@ -106,11 +107,11 @@ List queryList = detectionItemService.search(deviceId, false); if (null != queryList && queryList.Count > 0) { - int index = 1; foreach (DetectionItem detection in queryList) { tableTimes.Rows.Add(index, detection.StartTime, detection.EndTime, detection.Accuracy, detection.Stability, detection.BootFeature, detection.AgeRate, detection.Channel, detection.Stability1, detection.Stability10, detection.Stability20, detection.Stability100,detection.Id); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "detection.Id :" + detection.Id); index++; } @@ -130,8 +131,8 @@ dataGridView_times.Columns[10].Visible = false; dataGridView_times.Columns[11].Visible = false; dataGridView_times.Columns[12].Visible = false; + dataGridView_times.Columns[13].Visible = false; - dataGridView_times.Columns[1].ReadOnly = true; dataGridView_times.Columns[2].ReadOnly = true; dataGridView_times.Columns[3].ReadOnly = true; @@ -142,6 +143,8 @@ dataGridView_times.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable; dataGridView_times.Columns[3].SortMode = DataGridViewColumnSortMode.NotSortable; dataGridView_times.Columns[4].SortMode = DataGridViewColumnSortMode.NotSortable; + dataGridView_times.Columns[7].SortMode = DataGridViewColumnSortMode.NotSortable; + dataGridView_times.Columns[8].SortMode = DataGridViewColumnSortMode.NotSortable; } else { @@ -214,7 +217,6 @@ StreamWriter strmWriterObj = new StreamWriter(strFilePath, false, System.Text.Encoding.UTF8); strmWriterObj.WriteLine(label_devName.Text + " - " + label_devType.Text + "-" + "测试数据及结果"); - strmWriterObj.WriteLine("序号,时间,相对频率偏差"); foreach (DataGridViewRow row in dataGridView_times.Rows) { DataGridViewCheckBoxCell checkBox = (DataGridViewCheckBoxCell)row.Cells[0]; @@ -230,12 +232,17 @@ { string typeStr = type + ""; if (type == 1) typeStr = "1-1"; - else if(type == 2) typeStr = "1-10"; - else if (type == 3) typeStr = "1-20"; - else if (type == 4) typeStr = "1-100"; + if(type == 2) typeStr = "1-10"; + if (type == 3) typeStr = "1-20"; + if (type == 4) typeStr = "1-100"; + if(type == 5) typeStr = "2"; + if (type == 6) typeStr = "3"; + if (type == 7) typeStr = "4"; // 获取数据 - List List = detectionService.search(deviceId, typeStr, startTime, endTime,Convert.ToInt64(row.Cells[12].Value)); + List List = detectionService.search(deviceId, typeStr, startTime, endTime,Convert.ToInt64(row.Cells[13].Value)); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "List.count :" + List.Count +";itemid="+ Convert.ToInt64(row.Cells[13].Value)+ ";typeStr"+ typeStr+";devid="+ deviceId); + if (null != List && List.Count > 0) { string detecItemName = ""; @@ -270,14 +277,17 @@ CounterDataService counterDataService = new CounterDataServiceImpl(); List query = counterDataService.getHistory(deviceId, "", ""); - strmWriterObj.WriteLine("计数器范围及灵敏度"); - strmWriterObj.WriteLine("序号,输出值,测量值,灵敏度,时间"); - int index2 = 1; - foreach (CounterData counterData in query) + if (null != query && query.Count > 0) { - string strBufferLine = index2 + "," + counterData.OutValue + "," + counterData.Value + "," + counterData.Sensitivity + "," + counterData.LogTime; - strmWriterObj.WriteLine(strBufferLine); - index2++; + strmWriterObj.WriteLine("计数器范围及灵敏度"); + strmWriterObj.WriteLine("序号,输出值,测量值,灵敏度,时间"); + int index2 = 1; + foreach (CounterData counterData in query) + { + string strBufferLine = index2 + "," + counterData.OutValue + "," + counterData.Value + "," + counterData.Sensitivity + "," + counterData.LogTime; + strmWriterObj.WriteLine(strBufferLine); + index2++; + } } strmWriterObj.Close(); MessageBox.Show("导出成功,存放位置:" + strFilePath); diff --git a/RbFreqStandMeasure/info/InfoCtrlForm.Designer.cs b/RbFreqStandMeasure/info/InfoCtrlForm.Designer.cs index a151c85..adc57a4 100644 --- a/RbFreqStandMeasure/info/InfoCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/info/InfoCtrlForm.Designer.cs @@ -29,8 +29,8 @@ /// private void InitializeComponent() { - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.panelNodata = new System.Windows.Forms.Panel(); this.labelNodata = new System.Windows.Forms.Label(); @@ -170,14 +170,14 @@ this.dataGridView_DevList.AllowUserToDeleteRows = false; this.dataGridView_DevList.AllowUserToResizeColumns = false; this.dataGridView_DevList.AllowUserToResizeRows = false; - 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.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_DevList.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; + 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.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_DevList.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle3; this.dataGridView_DevList.BackgroundColor = System.Drawing.Color.White; this.dataGridView_DevList.BorderStyle = System.Windows.Forms.BorderStyle.None; this.dataGridView_DevList.CellBorderStyle = System.Windows.Forms.DataGridViewCellBorderStyle.None; @@ -189,15 +189,15 @@ this.dataGridView_DevList.ReadOnly = true; this.dataGridView_DevList.RowHeadersVisible = false; this.dataGridView_DevList.RowHeadersWidth = 30; - 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.NullValue = "-"; - dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dataGridView_DevList.RowsDefaultCellStyle = dataGridViewCellStyle2; + 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.NullValue = "-"; + dataGridViewCellStyle4.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle4.SelectionForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle4.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dataGridView_DevList.RowsDefaultCellStyle = dataGridViewCellStyle4; this.dataGridView_DevList.RowTemplate.Height = 44; this.dataGridView_DevList.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dataGridView_DevList.Size = new System.Drawing.Size(964, 480); @@ -251,6 +251,7 @@ // // inputDevStatus // + this.inputDevStatus.BackColor = System.Drawing.Color.White; // // // @@ -264,6 +265,7 @@ this.inputDevStatus.MaximumSize = new System.Drawing.Size(150, 28); this.inputDevStatus.Name = "inputDevStatus"; this.inputDevStatus.PreventEnterBeep = true; + this.inputDevStatus.ReadOnly = true; this.inputDevStatus.Size = new System.Drawing.Size(150, 28); this.inputDevStatus.TabIndex = 15; this.inputDevStatus.WatermarkColor = System.Drawing.Color.Silver; diff --git a/RbFreqStandMeasure/tools/DetectionHelper.cs b/RbFreqStandMeasure/tools/DetectionHelper.cs index 242f3fa..6796778 100644 --- a/RbFreqStandMeasure/tools/DetectionHelper.cs +++ b/RbFreqStandMeasure/tools/DetectionHelper.cs @@ -60,6 +60,7 @@ private int count1s = 0; private int count10s = 0; private int count20s = 0; + private bool isStarted = true; //1-STABILITY,2-ACCURACY,3-BOOT_FEATURE,4-AGE_RATE @@ -89,6 +90,7 @@ int delay = 0; if (Convert.ToDateTime(startTime) > DateTime.Now) { + isStarted = false; TimeSpan secondSpan = new TimeSpan(Convert.ToDateTime(startTime).Ticks - DateTime.Now.Ticks); delay = (int)secondSpan.TotalMilliseconds; } @@ -110,8 +112,34 @@ lock (obj) { lock(resultStability1) - { - string result = ""; + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "isStarted:" + isStarted + ", detectionItemId =" + detectionItemId); + + if (!isStarted) + { + while (true) + { + if (detectionItemId != -1) + { + isStarted = true; + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + + detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + + if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); + if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); + if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); + if (detectionItem0.Accuracy.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "-1", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "-1", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + break; + } + } + + } + string result = ""; string fre = getFrequencyData(portStability); if (!fre.Equals("") && resultStability1.Count<101) @@ -172,7 +200,7 @@ stability.label_result.Text = result1; DetailDlg.detailDlg.resultStaStr1 = result1; resultStability1.Clear(); - } + } } } } @@ -191,6 +219,29 @@ { lock (obj) { + if (!isStarted) + { + while (true) + { + if (detectionItemId != -1) + { + isStarted = true; + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); + if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); + if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); + if (detectionItem0.Accuracy.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "-1", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "-1", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + break; + } + } + + } + string result = ""; string fre = getFrequencyData(portStability); @@ -260,7 +311,29 @@ private void exeStability20(Object State) { lock (obj) - { + { + if (!isStarted) + { + while (true) + { + if (detectionItemId != -1) + { + isStarted = true; + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); + detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); + if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); + if (detectionItem0.Accuracy.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "-1", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "-1", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + break; + } + } + + } string result = ""; string fre = getFrequencyData(portStability); @@ -336,7 +409,29 @@ private void exeStability100(Object State) { lock (obj) - { + { + if (!isStarted) + { + while (true) + { + if (detectionItemId != -1) + { + isStarted = true; + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); + if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); + detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); + if (detectionItem0.Accuracy.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "-1", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "-1", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + break; + } + } + + } string result = ""; string fre = getFrequencyData(portStability); @@ -413,8 +508,9 @@ } int delay = 0; - if (Convert.ToDateTime(endTime)>=DateTime.Now) + if (Convert.ToDateTime(endTime)>DateTime.Now) { + isStarted = false; TimeSpan secondSpan = new TimeSpan(Convert.ToDateTime(endTime).Ticks - DateTime.Now.Ticks); delay = (int)secondSpan.TotalMilliseconds - 20*1000; } @@ -424,11 +520,37 @@ } private void exeAccuracy(Object State) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "哈哈哈哈,检测准确度了!!!!!!!"+DateTime.Now.ToLongTimeString()); + try { lock (obj) { - if(isUpdate) LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测准确度!!!!!!!开始"); + if (!isStarted) + { + while (true) + { + if (detectionItemId != -1) + { + isStarted = true; + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Stability.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); + if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); + if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); + if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Accuracy.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "-1", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "-1", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + break; + } + } + + } + + if (isUpdate) LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重新检测准确度!!!!!!!开始"); string result = ""; double sum = 0.0; List resultList = new List(); @@ -503,17 +625,45 @@ portBootFeature = port; devIdBootFeature = deviceId; int delay = 0; - if (!isStartNow && Convert.ToDateTime(startTime) >= DateTime.Now) + if (!isStartNow && Convert.ToDateTime(startTime) > DateTime.Now) { + isStarted = false; TimeSpan secondSpan = new TimeSpan(Convert.ToDateTime(startTime).Ticks - DateTime.Now.Ticks); delay = (int)secondSpan.TotalMilliseconds; } - timerBootFeature = new System.Threading.Timer(exeBootFeature, null, delay + 100, 60*60*1000); + timerBootFeature = new System.Threading.Timer(exeBootFeature, null, delay + 100, 60 * 60 * 1000); } private void exeBootFeature(Object State) { lock (obj) { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "isStarted:"+ isStarted); + + if (!isStarted) + { + while (true) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "detectionItemId:" + detectionItemId); + + if (detectionItemId != -1) + { + isStarted = true; + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Stability.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); + if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); + if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); + if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Accuracy.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "-1", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "-1", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + break; + } + } + + } LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测开机特性"); string result = ""; @@ -576,6 +726,7 @@ int delay = 0; if (!isStartNow && Convert.ToDateTime(startTime) > DateTime.Now) { + isStarted = false; TimeSpan secondSpan = new TimeSpan(Convert.ToDateTime(startTime).Ticks - DateTime.Now.Ticks); delay = (int)secondSpan.TotalMilliseconds; } @@ -584,7 +735,30 @@ private void exeAgeRate(Object State) { lock (obj) - { + { + if (!isStarted) + { + while (true) + { + if (detectionItemId != -1) + { + isStarted = true; + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Stability.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "-1", "", ""); + if (detectionItem0.Stability10.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "-1", ""); + if (detectionItem0.Stability20.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "", "", "", "-1"); + if (detectionItem0.Stability100.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); + if (detectionItem0.Accuracy.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "-1", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "-1", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "-1", "", "", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + break; + } + } + + } LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "开始检测日老化率"); string result = "";