diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 2796a25..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,7 +15,7 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 2796a25..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,7 +15,7 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 7478161..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -293,7 +293,6 @@ 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 + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -428,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 2796a25..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,7 +15,7 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 7478161..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -293,7 +293,6 @@ 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 + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -428,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2e91e63..b2213e4 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,7 +481,13 @@ 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); + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) + { + } using (MySqlDataReader aReader = aCommand.ExecuteReader()) { while (aReader.Read()) @@ -500,7 +506,7 @@ if (!aReader.IsDBNull(5)) { DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + deviceView.RegTime = reg.ToString("yyyy-MM-dd"); } if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev @@ -516,6 +522,7 @@ DateTime reg = aReader.GetDateTime(11); // regTime deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); } + if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 2796a25..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,7 +15,7 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 7478161..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -293,7 +293,6 @@ 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 + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -428,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2e91e63..b2213e4 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,7 +481,13 @@ 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); + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) + { + } using (MySqlDataReader aReader = aCommand.ExecuteReader()) { while (aReader.Read()) @@ -500,7 +506,7 @@ if (!aReader.IsDBNull(5)) { DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + deviceView.RegTime = reg.ToString("yyyy-MM-dd"); } if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev @@ -516,6 +522,7 @@ DateTime reg = aReader.GetDateTime(11); // regTime deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); } + if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 4abd70a..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -363,7 +364,24 @@ } } deviceService.clearChannel(); - } + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 2796a25..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,7 +15,7 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 7478161..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -293,7 +293,6 @@ 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 + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -428,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2e91e63..b2213e4 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,7 +481,13 @@ 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); + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) + { + } using (MySqlDataReader aReader = aCommand.ExecuteReader()) { while (aReader.Read()) @@ -500,7 +506,7 @@ if (!aReader.IsDBNull(5)) { DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + deviceView.RegTime = reg.ToString("yyyy-MM-dd"); } if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev @@ -516,6 +522,7 @@ DateTime reg = aReader.GetDateTime(11); // regTime deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); } + if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 4abd70a..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -363,7 +364,24 @@ } } deviceService.clearChannel(); - } + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index bce03f9..ad92b91 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 2796a25..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,7 +15,7 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 7478161..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -293,7 +293,6 @@ 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 + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -428,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2e91e63..b2213e4 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,7 +481,13 @@ 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); + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) + { + } using (MySqlDataReader aReader = aCommand.ExecuteReader()) { while (aReader.Read()) @@ -500,7 +506,7 @@ if (!aReader.IsDBNull(5)) { DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + deviceView.RegTime = reg.ToString("yyyy-MM-dd"); } if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev @@ -516,6 +522,7 @@ DateTime reg = aReader.GetDateTime(11); // regTime deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); } + if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 4abd70a..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -363,7 +364,24 @@ } } deviceService.clearChannel(); - } + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index bce03f9..ad92b91 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 2796a25..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,7 +15,7 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 7478161..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -293,7 +293,6 @@ 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 + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -428,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2e91e63..b2213e4 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,7 +481,13 @@ 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); + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) + { + } using (MySqlDataReader aReader = aCommand.ExecuteReader()) { while (aReader.Read()) @@ -500,7 +506,7 @@ if (!aReader.IsDBNull(5)) { DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + deviceView.RegTime = reg.ToString("yyyy-MM-dd"); } if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev @@ -516,6 +522,7 @@ DateTime reg = aReader.GetDateTime(11); // regTime deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); } + if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 4abd70a..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -363,7 +364,24 @@ } } deviceService.clearChannel(); - } + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index bce03f9..ad92b91 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 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(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px 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[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 2796a25..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,7 +15,7 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 7478161..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -293,7 +293,6 @@ 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 + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -428,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2e91e63..b2213e4 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,7 +481,13 @@ 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); + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) + { + } using (MySqlDataReader aReader = aCommand.ExecuteReader()) { while (aReader.Read()) @@ -500,7 +506,7 @@ if (!aReader.IsDBNull(5)) { DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + deviceView.RegTime = reg.ToString("yyyy-MM-dd"); } if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev @@ -516,6 +522,7 @@ DateTime reg = aReader.GetDateTime(11); // regTime deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); } + if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 4abd70a..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -363,7 +364,24 @@ } } deviceService.clearChannel(); - } + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index bce03f9..ad92b91 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 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(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px 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[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index 5a5771a..b2568f7 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -567,8 +567,7 @@ channelFreeList.Add("3"); channelFreeList.Add("4"); channelFreeList.Add("5"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); - + if (listChannelStatus != null && listChannelStatus.Count > 0) { foreach (DeviceView device in listChannelStatus) @@ -784,13 +783,26 @@ DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); } else { detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); } + DetectionItem detectionItem0 = detectionItemService.getById(deviceItemId); + if (detectionItem0 != null) + { + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "0", "", "", "", "", ""); + + } + LoadChannelStatus(); LoadDevToBeTested(); } @@ -832,32 +844,26 @@ try { lock (obj) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); - + { dataGridView_Channel.ClearSelection(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); int channelNo = e.RowIndex + 1; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); if (channelFreeList.Contains(channelNo + "")) { - - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); } else { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); } foreach (string no in channelFreeList.ToArray()) { @@ -865,7 +871,7 @@ panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; } - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 2796a25..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,7 +15,7 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 7478161..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -293,7 +293,6 @@ 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 + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -428,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2e91e63..b2213e4 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,7 +481,13 @@ 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); + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) + { + } using (MySqlDataReader aReader = aCommand.ExecuteReader()) { while (aReader.Read()) @@ -500,7 +506,7 @@ if (!aReader.IsDBNull(5)) { DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + deviceView.RegTime = reg.ToString("yyyy-MM-dd"); } if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev @@ -516,6 +522,7 @@ DateTime reg = aReader.GetDateTime(11); // regTime deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); } + if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 4abd70a..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -363,7 +364,24 @@ } } deviceService.clearChannel(); - } + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index bce03f9..ad92b91 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 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(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px 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[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index 5a5771a..b2568f7 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -567,8 +567,7 @@ channelFreeList.Add("3"); channelFreeList.Add("4"); channelFreeList.Add("5"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); - + if (listChannelStatus != null && listChannelStatus.Count > 0) { foreach (DeviceView device in listChannelStatus) @@ -784,13 +783,26 @@ DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); } else { detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); } + DetectionItem detectionItem0 = detectionItemService.getById(deviceItemId); + if (detectionItem0 != null) + { + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "0", "", "", "", "", ""); + + } + LoadChannelStatus(); LoadDevToBeTested(); } @@ -832,32 +844,26 @@ try { lock (obj) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); - + { dataGridView_Channel.ClearSelection(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); int channelNo = e.RowIndex + 1; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); if (channelFreeList.Contains(channelNo + "")) { - - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); } else { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); } foreach (string no in channelFreeList.ToArray()) { @@ -865,7 +871,7 @@ panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; } - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 8baed4b..fe3bcdd 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -168,7 +168,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 2796a25..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,7 +15,7 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 7478161..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -293,7 +293,6 @@ 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 + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -428,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2e91e63..b2213e4 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,7 +481,13 @@ 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); + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) + { + } using (MySqlDataReader aReader = aCommand.ExecuteReader()) { while (aReader.Read()) @@ -500,7 +506,7 @@ if (!aReader.IsDBNull(5)) { DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + deviceView.RegTime = reg.ToString("yyyy-MM-dd"); } if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev @@ -516,6 +522,7 @@ DateTime reg = aReader.GetDateTime(11); // regTime deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); } + if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 4abd70a..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -363,7 +364,24 @@ } } deviceService.clearChannel(); - } + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index bce03f9..ad92b91 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 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(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px 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[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index 5a5771a..b2568f7 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -567,8 +567,7 @@ channelFreeList.Add("3"); channelFreeList.Add("4"); channelFreeList.Add("5"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); - + if (listChannelStatus != null && listChannelStatus.Count > 0) { foreach (DeviceView device in listChannelStatus) @@ -784,13 +783,26 @@ DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); } else { detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); } + DetectionItem detectionItem0 = detectionItemService.getById(deviceItemId); + if (detectionItem0 != null) + { + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "0", "", "", "", "", ""); + + } + LoadChannelStatus(); LoadDevToBeTested(); } @@ -832,32 +844,26 @@ try { lock (obj) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); - + { dataGridView_Channel.ClearSelection(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); int channelNo = e.RowIndex + 1; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); if (channelFreeList.Contains(channelNo + "")) { - - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); } else { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); } foreach (string no in channelFreeList.ToArray()) { @@ -865,7 +871,7 @@ panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; } - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 8baed4b..fe3bcdd 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -168,7 +168,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 26e8cab..f1027ba 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -130,7 +130,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + text_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 2796a25..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,7 +15,7 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 7478161..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -293,7 +293,6 @@ 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 + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -428,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2e91e63..b2213e4 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,7 +481,13 @@ 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); + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) + { + } using (MySqlDataReader aReader = aCommand.ExecuteReader()) { while (aReader.Read()) @@ -500,7 +506,7 @@ if (!aReader.IsDBNull(5)) { DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + deviceView.RegTime = reg.ToString("yyyy-MM-dd"); } if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev @@ -516,6 +522,7 @@ DateTime reg = aReader.GetDateTime(11); // regTime deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); } + if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 4abd70a..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -363,7 +364,24 @@ } } deviceService.clearChannel(); - } + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index bce03f9..ad92b91 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 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(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px 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[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index 5a5771a..b2568f7 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -567,8 +567,7 @@ channelFreeList.Add("3"); channelFreeList.Add("4"); channelFreeList.Add("5"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); - + if (listChannelStatus != null && listChannelStatus.Count > 0) { foreach (DeviceView device in listChannelStatus) @@ -784,13 +783,26 @@ DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); } else { detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); } + DetectionItem detectionItem0 = detectionItemService.getById(deviceItemId); + if (detectionItem0 != null) + { + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "0", "", "", "", "", ""); + + } + LoadChannelStatus(); LoadDevToBeTested(); } @@ -832,32 +844,26 @@ try { lock (obj) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); - + { dataGridView_Channel.ClearSelection(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); int channelNo = e.RowIndex + 1; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); if (channelFreeList.Contains(channelNo + "")) { - - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); } else { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); } foreach (string no in channelFreeList.ToArray()) { @@ -865,7 +871,7 @@ panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; } - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 8baed4b..fe3bcdd 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -168,7 +168,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 26e8cab..f1027ba 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -130,7 +130,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + text_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 71a0230..46d4778 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -221,7 +221,7 @@ try { - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); return; diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 2796a25..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,7 +15,7 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 7478161..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -293,7 +293,6 @@ 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 + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -428,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2e91e63..b2213e4 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,7 +481,13 @@ 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); + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) + { + } using (MySqlDataReader aReader = aCommand.ExecuteReader()) { while (aReader.Read()) @@ -500,7 +506,7 @@ if (!aReader.IsDBNull(5)) { DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + deviceView.RegTime = reg.ToString("yyyy-MM-dd"); } if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev @@ -516,6 +522,7 @@ DateTime reg = aReader.GetDateTime(11); // regTime deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); } + if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 4abd70a..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -363,7 +364,24 @@ } } deviceService.clearChannel(); - } + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index bce03f9..ad92b91 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 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(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px 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[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index 5a5771a..b2568f7 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -567,8 +567,7 @@ channelFreeList.Add("3"); channelFreeList.Add("4"); channelFreeList.Add("5"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); - + if (listChannelStatus != null && listChannelStatus.Count > 0) { foreach (DeviceView device in listChannelStatus) @@ -784,13 +783,26 @@ DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); } else { detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); } + DetectionItem detectionItem0 = detectionItemService.getById(deviceItemId); + if (detectionItem0 != null) + { + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "0", "", "", "", "", ""); + + } + LoadChannelStatus(); LoadDevToBeTested(); } @@ -832,32 +844,26 @@ try { lock (obj) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); - + { dataGridView_Channel.ClearSelection(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); int channelNo = e.RowIndex + 1; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); if (channelFreeList.Contains(channelNo + "")) { - - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); } else { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); } foreach (string no in channelFreeList.ToArray()) { @@ -865,7 +871,7 @@ panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; } - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 8baed4b..fe3bcdd 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -168,7 +168,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 26e8cab..f1027ba 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -130,7 +130,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + text_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 71a0230..46d4778 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -221,7 +221,7 @@ try { - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); return; diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index e0c40b6..ad05a32 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -337,7 +337,12 @@ groupBox3.Text = "1s频率稳定度"; stability result = new stability(); result.label_stability.Text = ""; - if (!resultStaStr1.Equals("-1")&& !resultStaStr1.Equals("-2")&&!resultStaStr1.Equals("-3")) result.label_stability.Text = resultStaStr1; + result.label_count.Text = ""; + if (!resultStaStr1.Equals("-1") && !resultStaStr1.Equals("-2") && !resultStaStr1.Equals("-3")) + { + result.label_stability.Text = resultStaStr1; + result.label_count.Text = "101"; + } result.Show(); panel_result.Controls.Add(result); diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 2796a25..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,7 +15,7 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 7478161..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -293,7 +293,6 @@ 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 + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -428,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2e91e63..b2213e4 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,7 +481,13 @@ 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); + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) + { + } using (MySqlDataReader aReader = aCommand.ExecuteReader()) { while (aReader.Read()) @@ -500,7 +506,7 @@ if (!aReader.IsDBNull(5)) { DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + deviceView.RegTime = reg.ToString("yyyy-MM-dd"); } if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev @@ -516,6 +522,7 @@ DateTime reg = aReader.GetDateTime(11); // regTime deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); } + if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 4abd70a..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -363,7 +364,24 @@ } } deviceService.clearChannel(); - } + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index bce03f9..ad92b91 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 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(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px 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[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index 5a5771a..b2568f7 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -567,8 +567,7 @@ channelFreeList.Add("3"); channelFreeList.Add("4"); channelFreeList.Add("5"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); - + if (listChannelStatus != null && listChannelStatus.Count > 0) { foreach (DeviceView device in listChannelStatus) @@ -784,13 +783,26 @@ DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); } else { detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); } + DetectionItem detectionItem0 = detectionItemService.getById(deviceItemId); + if (detectionItem0 != null) + { + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "0", "", "", "", "", ""); + + } + LoadChannelStatus(); LoadDevToBeTested(); } @@ -832,32 +844,26 @@ try { lock (obj) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); - + { dataGridView_Channel.ClearSelection(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); int channelNo = e.RowIndex + 1; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); if (channelFreeList.Contains(channelNo + "")) { - - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); } else { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); } foreach (string no in channelFreeList.ToArray()) { @@ -865,7 +871,7 @@ panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; } - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 8baed4b..fe3bcdd 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -168,7 +168,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 26e8cab..f1027ba 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -130,7 +130,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + text_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 71a0230..46d4778 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -221,7 +221,7 @@ try { - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); return; diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index e0c40b6..ad05a32 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -337,7 +337,12 @@ groupBox3.Text = "1s频率稳定度"; stability result = new stability(); result.label_stability.Text = ""; - if (!resultStaStr1.Equals("-1")&& !resultStaStr1.Equals("-2")&&!resultStaStr1.Equals("-3")) result.label_stability.Text = resultStaStr1; + result.label_count.Text = ""; + if (!resultStaStr1.Equals("-1") && !resultStaStr1.Equals("-2") && !resultStaStr1.Equals("-3")) + { + result.label_stability.Text = resultStaStr1; + result.label_count.Text = "101"; + } result.Show(); panel_result.Controls.Add(result); diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index 19e2f83..cfb23dd 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -133,7 +133,7 @@ } DetectionHelper detectionHelper = new DetectionHelper(); - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNoReDetec + "]!"); btn_reDetec.Enabled = true; diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 2796a25..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,7 +15,7 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 7478161..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -293,7 +293,6 @@ 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 + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -428,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2e91e63..b2213e4 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,7 +481,13 @@ 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); + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) + { + } using (MySqlDataReader aReader = aCommand.ExecuteReader()) { while (aReader.Read()) @@ -500,7 +506,7 @@ if (!aReader.IsDBNull(5)) { DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + deviceView.RegTime = reg.ToString("yyyy-MM-dd"); } if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev @@ -516,6 +522,7 @@ DateTime reg = aReader.GetDateTime(11); // regTime deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); } + if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 4abd70a..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -363,7 +364,24 @@ } } deviceService.clearChannel(); - } + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index bce03f9..ad92b91 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 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(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px 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[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index 5a5771a..b2568f7 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -567,8 +567,7 @@ channelFreeList.Add("3"); channelFreeList.Add("4"); channelFreeList.Add("5"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); - + if (listChannelStatus != null && listChannelStatus.Count > 0) { foreach (DeviceView device in listChannelStatus) @@ -784,13 +783,26 @@ DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); } else { detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); } + DetectionItem detectionItem0 = detectionItemService.getById(deviceItemId); + if (detectionItem0 != null) + { + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "0", "", "", "", "", ""); + + } + LoadChannelStatus(); LoadDevToBeTested(); } @@ -832,32 +844,26 @@ try { lock (obj) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); - + { dataGridView_Channel.ClearSelection(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); int channelNo = e.RowIndex + 1; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); if (channelFreeList.Contains(channelNo + "")) { - - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); } else { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); } foreach (string no in channelFreeList.ToArray()) { @@ -865,7 +871,7 @@ panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; } - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 8baed4b..fe3bcdd 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -168,7 +168,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 26e8cab..f1027ba 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -130,7 +130,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + text_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 71a0230..46d4778 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -221,7 +221,7 @@ try { - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); return; diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index e0c40b6..ad05a32 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -337,7 +337,12 @@ groupBox3.Text = "1s频率稳定度"; stability result = new stability(); result.label_stability.Text = ""; - if (!resultStaStr1.Equals("-1")&& !resultStaStr1.Equals("-2")&&!resultStaStr1.Equals("-3")) result.label_stability.Text = resultStaStr1; + result.label_count.Text = ""; + if (!resultStaStr1.Equals("-1") && !resultStaStr1.Equals("-2") && !resultStaStr1.Equals("-3")) + { + result.label_stability.Text = resultStaStr1; + result.label_count.Text = "101"; + } result.Show(); panel_result.Controls.Add(result); diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index 19e2f83..cfb23dd 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -133,7 +133,7 @@ } DetectionHelper detectionHelper = new DetectionHelper(); - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNoReDetec + "]!"); btn_reDetec.Enabled = true; diff --git a/RbFreqStandMeasure/info/stability.designer.cs b/RbFreqStandMeasure/info/stability.designer.cs index e9dc1c9..40caec5 100644 --- a/RbFreqStandMeasure/info/stability.designer.cs +++ b/RbFreqStandMeasure/info/stability.designer.cs @@ -44,7 +44,6 @@ this.label_count.Name = "label_count"; this.label_count.Size = new System.Drawing.Size(83, 27); this.label_count.TabIndex = 82; - this.label_count.Text = "101"; this.label_count.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // label_stability @@ -98,9 +97,9 @@ } #endregion - private System.Windows.Forms.Label label_count; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label9; public System.Windows.Forms.Label label_stability; + public System.Windows.Forms.Label label_count; } } diff --git a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs index 2796a25..e338811 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/DetectionItemService.cs @@ -15,7 +15,7 @@ string accuracy, string bootFeature, string ageRate, String interval, string counterDetec); List search(long deviceId, bool isInDetection); - + List getAll(); int stopDetection(long deviceId, long detectionItemId, string startTime, string endTime, bool isDeleteData); DetectionItem searchById(long detectionId); int updateChannelNo(long detectionItemId, string channelNo); diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs index 7478161..974b3b7 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DetectionItemServiceImpl.cs @@ -293,7 +293,6 @@ 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 + "'"; cmd = new MySqlCommand(sQry, DbConnectService.mySqlConnect); cmd.ExecuteNonQuery(); @@ -428,6 +427,58 @@ } return detectionItemList; } + public List getAll() + { + List detectionItemList = new List(); + try + { + if (DbConnectService.mySqlConnect.State == ConnectionState.Closed) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll : 数据库链接断开"); + int iRetval = DbConnectService.openDb(); + if (iRetval != 0) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "重连失败!"); + return null; + } + } + + string sQry = "SELECT * FROM r_detection_item "; + + MySqlCommand aCommand = new MySqlCommand(sQry, DbConnectService.mySqlConnect); + + using (MySqlDataReader aReader = aCommand.ExecuteReader()) + { + while (aReader.Read()) + { + DetectionItem detectionItem = new DetectionItem(); + //姓名 + if (!aReader.IsDBNull(0)) detectionItem.Id = Convert.ToInt32(aReader.GetString(0)); + if (!aReader.IsDBNull(1)) detectionItem.DeviceId = Convert.ToInt64(aReader.GetString(1)); + if (!aReader.IsDBNull(2)) detectionItem.StartTime = aReader.GetString(2); + if (!aReader.IsDBNull(3)) detectionItem.EndTime = aReader.GetString(3); + if (!aReader.IsDBNull(4)) detectionItem.Stability = aReader.GetString(4); + if (!aReader.IsDBNull(5)) detectionItem.Accuracy = aReader.GetString(5); + if (!aReader.IsDBNull(6)) detectionItem.BootFeature = aReader.GetString(6); + if (!aReader.IsDBNull(7)) detectionItem.AgeRate = aReader.GetString(7); + if (!aReader.IsDBNull(8)) detectionItem.Interval = aReader.GetString(8); + if (!aReader.IsDBNull(10)) detectionItem.Channel = aReader.GetString(10); + if (!aReader.IsDBNull(11)) detectionItem.Stability1 = aReader.GetString(11); + if (!aReader.IsDBNull(12)) detectionItem.Stability10 = aReader.GetString(12); + if (!aReader.IsDBNull(13)) detectionItem.Stability20 = aReader.GetString(13); + if (!aReader.IsDBNull(14)) detectionItem.Stability100 = aReader.GetString(14); + detectionItemList.Add(detectionItem); + } + + aCommand.Dispose(); + } + } + catch (MySqlException ex) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "getAll: " + ex.Message); + } + return detectionItemList; + } public DetectionItem searchById(long detectionId) { diff --git a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs index 2e91e63..b2213e4 100644 --- a/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs +++ b/RbFreqStandMeasure/R_DataBase/Service/Impl/DeviceServiceImpl.cs @@ -481,7 +481,13 @@ 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); + MySqlDataAdapter adap = new MySqlDataAdapter(aCommand); + DataTable dt = new DataTable(); + adap.Fill(dt); + if (dt != null && dt.Rows.Count > 0) + { + } using (MySqlDataReader aReader = aCommand.ExecuteReader()) { while (aReader.Read()) @@ -500,7 +506,7 @@ if (!aReader.IsDBNull(5)) { DateTime reg = aReader.GetDateTime(5); // regTime - deviceView.RegTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); + deviceView.RegTime = reg.ToString("yyyy-MM-dd"); } if (!aReader.IsDBNull(6)) deviceView.CustomerName = aReader.GetString(6); // customName if (!aReader.IsDBNull(7)) deviceView.CustomerDev = aReader.GetString(7); // customDev @@ -516,6 +522,7 @@ DateTime reg = aReader.GetDateTime(11); // regTime deviceView.EndTime = reg.ToString("yyyy-MM-dd HH:mm:ss"); } + if (!aReader.IsDBNull(12)) deviceView.StatusId = aReader.GetString(12); if (!aReader.IsDBNull(13)) deviceView.Stability = aReader.GetString(13); if (!aReader.IsDBNull(14)) deviceView.Accuracy = aReader.GetString(14); if (!aReader.IsDBNull(15)) deviceView.BootFeature = aReader.GetString(15); diff --git a/RbFreqStandMeasure/RbFreqStdMeas.cs b/RbFreqStandMeasure/RbFreqStdMeas.cs index 4abd70a..beae3dc 100644 --- a/RbFreqStandMeasure/RbFreqStdMeas.cs +++ b/RbFreqStandMeasure/RbFreqStdMeas.cs @@ -3,6 +3,7 @@ using Casic.Birmm.RbFreqStandMeasure.Properties; using Casic.Birmm.RbFreqStandMeasure.R_DataBase; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Dto; +using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Model; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service; using Casic.Birmm.RbFreqStandMeasure.R_DataBase.Service.Impl; using Casic.Birmm.RbFreqStandMeasure.setting; @@ -363,7 +364,24 @@ } } deviceService.clearChannel(); - } + List detectionItemList = detectionItemService.getAll(); + if (detectionItemList != null && detectionItemList.Count > 0) + { + foreach (DetectionItem detectionItem in detectionItemList) + { + long detectionItemId = detectionItem.Id; + if (detectionItem.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + } + } + + } else { MessageBox.Show("启动失败,无法连接数据库!", null, MessageBoxButtons.OK, MessageBoxIcon.Error); diff --git a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe index bce03f9..ad92b91 100644 --- a/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe +++ b/RbFreqStandMeasure/bin/Debug/RbFreqStandMeasure.exe Binary files differ diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs index f01e221..4800a1b 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.Designer.cs @@ -30,13 +30,16 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CounterCtrlForm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); this.panel1 = new System.Windows.Forms.Panel(); this.dataGridView_CounterResult = new System.Windows.Forms.DataGridView(); this.panelMedian = new System.Windows.Forms.Panel(); this.labelMedian = new System.Windows.Forms.Label(); + this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); + this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panelControl = new System.Windows.Forms.Panel(); + this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.labelControl = new System.Windows.Forms.Label(); this.panelSource = new System.Windows.Forms.Panel(); this.text_signal = new DevComponents.DotNetBar.Controls.TextBoxX(); @@ -56,9 +59,6 @@ this.label1 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label(); this.labelCounter = new System.Windows.Forms.Label(); - this.btn_add = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.benDelete = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); - this.btnStart = new Casic.Birmm.RbFreqStandMeasure.RoundButton(); this.panel1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView_CounterResult)).BeginInit(); this.panelMedian.SuspendLayout(); @@ -83,13 +83,13 @@ this.dataGridView_CounterResult.AllowUserToDeleteRows = false; this.dataGridView_CounterResult.AllowUserToResizeColumns = false; this.dataGridView_CounterResult.AllowUserToResizeRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle5.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); - dataGridViewCellStyle5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(234)))), ((int)(((byte)(238))))); + dataGridViewCellStyle1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle1; this.dataGridView_CounterResult.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; this.dataGridView_CounterResult.BackgroundColor = System.Drawing.Color.White; this.dataGridView_CounterResult.BorderStyle = System.Windows.Forms.BorderStyle.None; @@ -97,22 +97,22 @@ this.dataGridView_CounterResult.ColumnHeadersHeight = 50; this.dataGridView_CounterResult.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing; this.dataGridView_CounterResult.GridColor = System.Drawing.Color.WhiteSmoke; - this.dataGridView_CounterResult.Location = new System.Drawing.Point(10, 10); + this.dataGridView_CounterResult.Location = new System.Drawing.Point(9, 10); this.dataGridView_CounterResult.MultiSelect = false; this.dataGridView_CounterResult.Name = "dataGridView_CounterResult"; this.dataGridView_CounterResult.RowHeadersVisible = false; this.dataGridView_CounterResult.RowHeadersWidth = 50; - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; - dataGridViewCellStyle6.BackColor = System.Drawing.Color.White; - dataGridViewCellStyle6.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.Color.White; - this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; + dataGridViewCellStyle2.BackColor = System.Drawing.Color.White; + dataGridViewCellStyle2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(51)))), ((int)(((byte)(51)))), ((int)(((byte)(51))))); + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.Color.White; + this.dataGridView_CounterResult.RowsDefaultCellStyle = dataGridViewCellStyle2; this.dataGridView_CounterResult.RowTemplate.DefaultCellStyle.NullValue = "-"; this.dataGridView_CounterResult.RowTemplate.Height = 50; this.dataGridView_CounterResult.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; - this.dataGridView_CounterResult.Size = new System.Drawing.Size(698, 627); + this.dataGridView_CounterResult.Size = new System.Drawing.Size(700, 627); this.dataGridView_CounterResult.TabIndex = 1; this.dataGridView_CounterResult.VirtualMode = true; this.dataGridView_CounterResult.CellDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_CounterResult_CellDoubleClick); @@ -142,6 +142,54 @@ this.labelMedian.Text = "结果编辑"; this.labelMedian.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // + // btn_add + // + this.btn_add.EnterBackColor = System.Drawing.Color.Blue; + this.btn_add.EnterForeColor = System.Drawing.Color.White; + this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btn_add.FlatAppearance.BorderSize = 0; + this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btn_add.HoverForeColor = System.Drawing.Color.White; + this.btn_add.Location = new System.Drawing.Point(155, 65); + this.btn_add.Margin = new System.Windows.Forms.Padding(0); + this.btn_add.Name = "btn_add"; + this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; + this.btn_add.PressForeColor = System.Drawing.Color.White; + this.btn_add.Radius = 5; + this.btn_add.Size = new System.Drawing.Size(111, 26); + this.btn_add.TabIndex = 14; + this.btn_add.Text = "添加"; + this.btn_add.UseVisualStyleBackColor = true; + this.btn_add.Click += new System.EventHandler(this.btn_add_Click); + // + // benDelete + // + this.benDelete.EnterBackColor = System.Drawing.Color.Blue; + this.benDelete.EnterForeColor = System.Drawing.Color.White; + this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.benDelete.FlatAppearance.BorderSize = 0; + this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); + this.benDelete.HoverForeColor = System.Drawing.Color.White; + this.benDelete.Location = new System.Drawing.Point(27, 65); + this.benDelete.Margin = new System.Windows.Forms.Padding(0); + this.benDelete.Name = "benDelete"; + this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; + this.benDelete.PressForeColor = System.Drawing.Color.White; + this.benDelete.Radius = 5; + this.benDelete.Size = new System.Drawing.Size(111, 26); + this.benDelete.TabIndex = 13; + this.benDelete.Text = "删除"; + this.benDelete.UseVisualStyleBackColor = true; + this.benDelete.Click += new System.EventHandler(this.benDelete_Click); + // // panelControl // this.panelControl.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("panelControl.BackgroundImage"))); @@ -153,6 +201,30 @@ this.panelControl.Size = new System.Drawing.Size(288, 136); this.panelControl.TabIndex = 3; // + // btnStart + // + this.btnStart.EnterBackColor = System.Drawing.Color.Blue; + this.btnStart.EnterForeColor = System.Drawing.Color.White; + this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); + this.btnStart.FlatAppearance.BorderSize = 0; + this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; + this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; + this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); + this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); + this.btnStart.HoverForeColor = System.Drawing.Color.White; + this.btnStart.Location = new System.Drawing.Point(88, 65); + this.btnStart.Margin = new System.Windows.Forms.Padding(0); + this.btnStart.Name = "btnStart"; + this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; + this.btnStart.PressForeColor = System.Drawing.Color.White; + this.btnStart.Radius = 5; + this.btnStart.Size = new System.Drawing.Size(111, 26); + this.btnStart.TabIndex = 11; + this.btnStart.Text = "启动连续检定"; + this.btnStart.UseVisualStyleBackColor = true; + this.btnStart.Click += new System.EventHandler(this.btnStart_Click); + // // labelControl // this.labelControl.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(63)))), ((int)(((byte)(132)))), ((int)(((byte)(215))))); @@ -362,78 +434,6 @@ this.labelCounter.Text = "计数器参数设置"; this.labelCounter.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // btn_add - // - this.btn_add.EnterBackColor = System.Drawing.Color.Blue; - this.btn_add.EnterForeColor = System.Drawing.Color.White; - this.btn_add.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btn_add.FlatAppearance.BorderSize = 0; - this.btn_add.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btn_add.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btn_add.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btn_add.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btn_add.HoverForeColor = System.Drawing.Color.White; - this.btn_add.Location = new System.Drawing.Point(155, 65); - this.btn_add.Margin = new System.Windows.Forms.Padding(0); - this.btn_add.Name = "btn_add"; - this.btn_add.PressBackColor = System.Drawing.Color.DarkBlue; - this.btn_add.PressForeColor = System.Drawing.Color.White; - this.btn_add.Radius = 5; - this.btn_add.Size = new System.Drawing.Size(111, 26); - this.btn_add.TabIndex = 14; - this.btn_add.Text = "添加"; - this.btn_add.UseVisualStyleBackColor = true; - this.btn_add.Click += new System.EventHandler(this.btn_add_Click); - // - // benDelete - // - this.benDelete.EnterBackColor = System.Drawing.Color.Blue; - this.benDelete.EnterForeColor = System.Drawing.Color.White; - this.benDelete.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.benDelete.FlatAppearance.BorderSize = 0; - this.benDelete.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.benDelete.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.benDelete.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.benDelete.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(230)))), ((int)(((byte)(0)))), ((int)(((byte)(18))))); - this.benDelete.HoverForeColor = System.Drawing.Color.White; - this.benDelete.Location = new System.Drawing.Point(27, 65); - this.benDelete.Margin = new System.Windows.Forms.Padding(0); - this.benDelete.Name = "benDelete"; - this.benDelete.PressBackColor = System.Drawing.Color.DarkBlue; - this.benDelete.PressForeColor = System.Drawing.Color.White; - this.benDelete.Radius = 5; - this.benDelete.Size = new System.Drawing.Size(111, 26); - this.benDelete.TabIndex = 13; - this.benDelete.Text = "删除"; - this.benDelete.UseVisualStyleBackColor = true; - this.benDelete.Click += new System.EventHandler(this.benDelete_Click); - // - // btnStart - // - this.btnStart.EnterBackColor = System.Drawing.Color.Blue; - this.btnStart.EnterForeColor = System.Drawing.Color.White; - this.btnStart.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(0))))); - this.btnStart.FlatAppearance.BorderSize = 0; - this.btnStart.FlatAppearance.MouseDownBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatAppearance.MouseOverBackColor = System.Drawing.Color.Transparent; - this.btnStart.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.btnStart.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134))); - this.btnStart.HoverBackColor = System.Drawing.Color.FromArgb(((int)(((byte)(86)))), ((int)(((byte)(163)))), ((int)(((byte)(242))))); - this.btnStart.HoverForeColor = System.Drawing.Color.White; - this.btnStart.Location = new System.Drawing.Point(88, 65); - this.btnStart.Margin = new System.Windows.Forms.Padding(0); - this.btnStart.Name = "btnStart"; - this.btnStart.PressBackColor = System.Drawing.Color.DarkBlue; - this.btnStart.PressForeColor = System.Drawing.Color.White; - this.btnStart.Radius = 5; - this.btnStart.Size = new System.Drawing.Size(111, 26); - this.btnStart.TabIndex = 11; - this.btnStart.Text = "启动连续检定"; - this.btnStart.UseVisualStyleBackColor = true; - this.btnStart.Click += new System.EventHandler(this.btnStart_Click); - // // CounterCtrlForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); diff --git a/RbFreqStandMeasure/counter/CounterCtrlForm.cs b/RbFreqStandMeasure/counter/CounterCtrlForm.cs index f21874a..951a19c 100644 --- a/RbFreqStandMeasure/counter/CounterCtrlForm.cs +++ b/RbFreqStandMeasure/counter/CounterCtrlForm.cs @@ -124,8 +124,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器型号", - Location = new Point(46, 0), - Size = new Size(100, 50) + Location = new Point(48, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colDevType); colDevType.BringToFront(); @@ -139,26 +139,11 @@ BackColor = titleBackColor, AutoSize = false, Text = "仪器编号", - Location = new Point(145, 0), - Size = new Size(100, 50) + Location = new Point(140, 0), + Size = new Size(90, 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(); + colDevNo.BringToFront(); // 标称值 colStdValue = new Label @@ -169,7 +154,7 @@ BackColor = titleBackColor, AutoSize = false, Text = "输出频率", - Location = new Point(285, 0), + Location = new Point(230, 0), Size = new Size(100, 50) }; dataGridView_CounterResult.Controls.Add(colStdValue); @@ -184,8 +169,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量频率", - Location = new Point(377, 0), - Size = new Size(100, 50) + Location = new Point(327, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colValue); colValue.BringToFront(); @@ -199,8 +184,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "灵敏度(Vpp)", - Location = new Point(480, 0), - Size = new Size(95, 50) + Location = new Point(470, 0), + Size = new Size(90, 50) }; dataGridView_CounterResult.Controls.Add(colSensitivity); colSensitivity.BringToFront(); @@ -213,8 +198,8 @@ BackColor = titleBackColor, AutoSize = false, Text = "测量时间", - Location = new Point(580, 0), - Size = new Size(94, 50) + Location = new Point(558, 0), + Size = new Size(140, 50) }; dataGridView_CounterResult.Controls.Add(colTime); colTime.BringToFront(); @@ -283,16 +268,16 @@ dataGridView_CounterResult.Columns[8].Visible = false; dataGridView_CounterResult.Columns[9].Visible = false; + dataGridView_CounterResult.Columns[3].Visible = false; // width=714px 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[1].Width = 90; + dataGridView_CounterResult.Columns[2].Width = 90; + dataGridView_CounterResult.Columns[4].Width = 100; + dataGridView_CounterResult.Columns[5].Width = 140; + dataGridView_CounterResult.Columns[6].Width = 90; + dataGridView_CounterResult.Columns[7].Width = 140; dataGridView_CounterResult.Columns[0].ReadOnly = true; dataGridView_CounterResult.Columns[1].ReadOnly = true; @@ -746,12 +731,21 @@ { if (!String.IsNullOrEmpty(value)) { - string pattern = @"^[0-9.E]+$"; - Regex regex = new Regex(pattern); - if (!regex.IsMatch(value)) + if (comboBox_detecModel.Text.Equals("频率测量")) { - MessageBox.Show("请输入格式正确的测量值!"); - return; + if (!checkFreq(value)) + { + MessageBox.Show("请输入格式正确的测量频率值!"); + return; + } + } + else + { + if (!checkCyc(value)) + { + MessageBox.Show("请输入格式正确的测量周期值!"); + return; + } } } } @@ -803,14 +797,18 @@ private bool checkFreq(string val) { string value = val; - string pattern = @"^[0-9.]+$"; + string pattern = @"^[0-9.]+$"; //@"/^((([^0][0-9]+|0)\.([0-9]{1,20}))$)|^(([1-9]+)\.([0-9]{1,20})$)/"; //@"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.'))|| val.IndexOf('.')==0 || val.LastIndexOf('.')==val.Length)) return false; + if (val.Contains("E") && ((val.IndexOf('E') != val.LastIndexOf('E')) || val.IndexOf('E') == 0 || val.LastIndexOf('E') == val.Length)) return false; + if (!value.Contains("Hz") && !value.Contains("kHz") && !value.Contains("MHz") && !value.Contains("GHz")) { return false; } else { + if (value.Contains("E")) value = value.Replace("E", ""); if (value.Contains("kHz")) value = value.Replace("kHz", ""); else if (value.Contains("MHz")) value = value.Replace("MHz", ""); else if (value.Contains("GHz")) value = value.Replace("GHz", ""); @@ -826,6 +824,7 @@ string value = val; string pattern = @"^[0-9.]+$"; Regex regex = new Regex(pattern); + if (val.Contains(".") && ((val.IndexOf('.') != val.LastIndexOf('.')) || val.IndexOf('.') == 0 || val.LastIndexOf('.') == val.Length)) return false; if (!value.Contains("s") && !value.Contains("ms") && !value.Contains("us") && !value.Contains("ns")) { return false; diff --git a/RbFreqStandMeasure/home/HomeCtrlForm.cs b/RbFreqStandMeasure/home/HomeCtrlForm.cs index 5a5771a..b2568f7 100644 --- a/RbFreqStandMeasure/home/HomeCtrlForm.cs +++ b/RbFreqStandMeasure/home/HomeCtrlForm.cs @@ -567,8 +567,7 @@ channelFreeList.Add("3"); channelFreeList.Add("4"); channelFreeList.Add("5"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "listChannelStatus.count :" + listChannelStatus.Count); - + if (listChannelStatus != null && listChannelStatus.Count > 0) { foreach (DeviceView device in listChannelStatus) @@ -784,13 +783,26 @@ DialogResult dialogResult = MessageBox.Show("是否保存此次检测的数据?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { - detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, false); } else { detectionItemService.stopDetection(deviceId, deviceItemId, startTime, endTime, true); } + DetectionItem detectionItem0 = detectionItemService.getById(deviceItemId); + if (detectionItem0 != null) + { + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "0", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "0", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "0", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "", "", "", "", "", "0"); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "0", "", "", "", "", "", "", ""); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "0", "", "", "", "", "", ""); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(deviceItemId, "", "", "", "0", "", "", "", "", ""); + + } + LoadChannelStatus(); LoadDevToBeTested(); } @@ -832,32 +844,26 @@ try { lock (obj) - { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "11111111"); - + { dataGridView_Channel.ClearSelection(); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "222222"); int channelNo = e.RowIndex + 1; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "333333"); if (channelFreeList.Contains(channelNo + "")) { - - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "44444"); - dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); + dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(232, 234, 238); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = false; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "5555555555"); } else { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "66666666666"); dataGridView_Channel.Rows[e.RowIndex].DefaultCellStyle.BackColor = Color.FromArgb(201, 203, 208); panel_channelList.Controls.Find("panel" + channelNo, true)[0].Visible = true; - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "777777777"); } foreach (string no in channelFreeList.ToArray()) { @@ -865,7 +871,7 @@ panel_channelList.Controls.Find("panel" + no, true)[0].Visible = false; } - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); + //LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "88888888"); } } catch (Exception ex) diff --git a/RbFreqStandMeasure/home/SetDevChannelDlg.cs b/RbFreqStandMeasure/home/SetDevChannelDlg.cs index 8baed4b..fe3bcdd 100644 --- a/RbFreqStandMeasure/home/SetDevChannelDlg.cs +++ b/RbFreqStandMeasure/home/SetDevChannelDlg.cs @@ -168,7 +168,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + textBox_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/home/SetDevTestDlg.cs b/RbFreqStandMeasure/home/SetDevTestDlg.cs index 26e8cab..f1027ba 100644 --- a/RbFreqStandMeasure/home/SetDevTestDlg.cs +++ b/RbFreqStandMeasure/home/SetDevTestDlg.cs @@ -130,7 +130,7 @@ return; } - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + text_channelNo.Text + "]!"); return; diff --git a/RbFreqStandMeasure/info/AddDevDlg.cs b/RbFreqStandMeasure/info/AddDevDlg.cs index 71a0230..46d4778 100644 --- a/RbFreqStandMeasure/info/AddDevDlg.cs +++ b/RbFreqStandMeasure/info/AddDevDlg.cs @@ -221,7 +221,7 @@ try { - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNo + "]!"); return; diff --git a/RbFreqStandMeasure/info/DetailDlg.cs b/RbFreqStandMeasure/info/DetailDlg.cs index e0c40b6..ad05a32 100644 --- a/RbFreqStandMeasure/info/DetailDlg.cs +++ b/RbFreqStandMeasure/info/DetailDlg.cs @@ -337,7 +337,12 @@ groupBox3.Text = "1s频率稳定度"; stability result = new stability(); result.label_stability.Text = ""; - if (!resultStaStr1.Equals("-1")&& !resultStaStr1.Equals("-2")&&!resultStaStr1.Equals("-3")) result.label_stability.Text = resultStaStr1; + result.label_count.Text = ""; + if (!resultStaStr1.Equals("-1") && !resultStaStr1.Equals("-2") && !resultStaStr1.Equals("-3")) + { + result.label_stability.Text = resultStaStr1; + result.label_count.Text = "101"; + } result.Show(); panel_result.Controls.Add(result); diff --git a/RbFreqStandMeasure/info/ReDetecDlg.cs b/RbFreqStandMeasure/info/ReDetecDlg.cs index 19e2f83..cfb23dd 100644 --- a/RbFreqStandMeasure/info/ReDetecDlg.cs +++ b/RbFreqStandMeasure/info/ReDetecDlg.cs @@ -133,7 +133,7 @@ } DetectionHelper detectionHelper = new DetectionHelper(); - if (DetectionHelper.detectionHelper.getFrequencyData(port).Equals("")) + if (DetectionHelper.detectionHelper.getFrequencyData(port, true).Equals("")) { MessageBox.Show("请连接仪器到通道[" + channelNoReDetec + "]!"); btn_reDetec.Enabled = true; diff --git a/RbFreqStandMeasure/info/stability.designer.cs b/RbFreqStandMeasure/info/stability.designer.cs index e9dc1c9..40caec5 100644 --- a/RbFreqStandMeasure/info/stability.designer.cs +++ b/RbFreqStandMeasure/info/stability.designer.cs @@ -44,7 +44,6 @@ this.label_count.Name = "label_count"; this.label_count.Size = new System.Drawing.Size(83, 27); this.label_count.TabIndex = 82; - this.label_count.Text = "101"; this.label_count.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; // // label_stability @@ -98,9 +97,9 @@ } #endregion - private System.Windows.Forms.Label label_count; private System.Windows.Forms.Label label2; private System.Windows.Forms.Label label9; public System.Windows.Forms.Label label_stability; + public System.Windows.Forms.Label label_count; } } diff --git a/RbFreqStandMeasure/tools/DetectionHelper.cs b/RbFreqStandMeasure/tools/DetectionHelper.cs index 05f74fb..2070bac 100644 --- a/RbFreqStandMeasure/tools/DetectionHelper.cs +++ b/RbFreqStandMeasure/tools/DetectionHelper.cs @@ -121,9 +121,9 @@ DetectionItem item = detectionItemService.getById(detectionItemId); if (item==null||(item!=null&&Convert.ToDateTime(item.EndTime) < DateTime.Now)) { - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,稳定度1s,devId="+ devIdStability+";detectionItemId="+ detectionItemId); - timerStability1.Dispose(); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "已停止检测,稳定度1s,devId="+ devIdStability+";detectionItemId="+ detectionItemId); + return; } if (!isStarted) @@ -131,8 +131,7 @@ isStarted = true; DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); - detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); - + 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"); @@ -148,7 +147,20 @@ } string result = ""; - string fre = getFrequencyData(portStability); + string fre = getFrequencyData(portStability,false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,稳定度1s,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerStability1.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability1.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "0", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } if (!fre.Equals("") && resultStability1.Count<101) { resultStability1.Add(fre); @@ -158,7 +170,6 @@ detectionService.add(devIdStability, fre, "1-1",detectionItemId); count1s++; LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "获取到频率值,1s稳定度,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); - } } if (!isUpdate) @@ -188,7 +199,6 @@ if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); } @@ -261,7 +271,21 @@ string result = ""; - string fre = getFrequencyData(portStability); + string fre = getFrequencyData(portStability, false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,稳定度10s,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerStability10.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability10.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "0", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } + if (!fre.Equals("") && resultStability10.Count < 101) { resultStability10.Add(fre); @@ -300,7 +324,6 @@ if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); @@ -345,8 +368,7 @@ return; } if (!isStarted) - { - + { isStarted = true; DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); if (detectionItem0.Stability1.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-1", "", "", "", "", "-1", "", "", ""); @@ -366,7 +388,20 @@ } string result = ""; - string fre = getFrequencyData(portStability); + string fre = getFrequencyData(portStability, false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,稳定度20s,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerStability20.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability20.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "0", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } if (!fre.Equals("") && resultStability20.Count < 101) { resultStability20.Add(fre); @@ -406,7 +441,6 @@ if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); @@ -477,7 +511,20 @@ } string result = ""; - string fre = getFrequencyData(portStability); + string fre = getFrequencyData(portStability, false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,稳定度100s,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerStability100.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Stability.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", ""); + if (detectionItem0.Stability100.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "0", "", "", "", "", "", "", "", "0"); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } if (!fre.Equals("") && resultStability100.Count < 101) { resultStability100.Add(fre); @@ -516,7 +563,6 @@ if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdStability, "3", ""); - portStability.Close(); } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); } @@ -589,11 +635,11 @@ 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.Stability.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-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", "", "", "", "", ""); @@ -612,7 +658,19 @@ for (int i = 0; i < 500; i++) { - string fre = getFrequencyData(portAccuracy); + string fre = getFrequencyData(portAccuracy, false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,准确度,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerAccuracy.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.Accuracy.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "0", "", "", "", "", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } if (fre.Equals("")) continue; resultList.Add(fre); if (!isUpdate) @@ -649,7 +707,6 @@ if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdAccuracy, "3", ""); - portAccuracy.Close(); } } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); @@ -715,11 +772,11 @@ { 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.Stability.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-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", "", "", "", "", ""); @@ -736,7 +793,19 @@ int count = 0; for (int i = 0; i < 50; i++) { - string fre = getFrequencyData(portBootFeature); + string fre = getFrequencyData(portBootFeature, false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,开机特性,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerBootFeature.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.BootFeature.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "0", "", "", "", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } if (!fre.Equals("")) { count++; @@ -771,7 +840,6 @@ if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdBootFeature, "3", ""); - portBootFeature.Close(); } } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); @@ -822,11 +890,11 @@ 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.Stability.Equals("-2")) detectionItemService.updateDetecStatus(detectionItemId, "-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", "", "", "", "", ""); @@ -845,7 +913,19 @@ int count = 0; for (int i = 0; i < 50; i++) { - string fre = getFrequencyData(portAgeRate); + string fre = getFrequencyData(portAgeRate, false); + if (fre.Equals("close")) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "端口异常关闭,日老化率,devId=" + devIdStability + ";detectionItemId=" + detectionItemId); + + timerAgeRate.Dispose(); + DetectionItem detectionItem0 = detectionItemService.searchById(detectionItemId); + if (detectionItem0.AgeRate.Equals("-1")) detectionItemService.updateDetecStatus(detectionItemId, "", "", "", "0", "", "", "", "", ""); + + HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); + deviceService.updateStatus(devIdStability, "1", ""); + return; + } if (!fre.Equals("")) { count++; @@ -875,7 +955,6 @@ if (!detectionItem.Stability.Equals("-1") && !detectionItem.Accuracy.Equals("-1") && !detectionItem.AgeRate.Equals("-1") && !detectionItem.BootFeature.Equals("-1")) { deviceService.updateStatus(devIdAgeRate, "3", ""); - portAgeRate.Close(); } } HomeCtrlForm.homeCtrlForm.LoadChannelStatus(); @@ -890,7 +969,7 @@ // 获取检测数据 - public string getFrequencyData(SerialPort port) + public string getFrequencyData(SerialPort port, bool isTest) { string received = ""; try @@ -900,15 +979,20 @@ if (!isUsing) { isUsing = true; - if (port.IsOpen) LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, "portname:" + port.PortName); - else LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, port.PortName + " port closed"); + if (!port.IsOpen) + { + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, port.PortName + " closed!!!!!!"); + string name = ConfigHelper.getKeyByValue(port.PortName + " 115200").Replace("channel", "通道"); + MessageBox.Show(name+"的端口异常关闭,该通道上的检测将终止!"); + return "close"; + } if (ConfigHelper.GetAppConfig("deviceType").ToString().Equals("1")) { int count = 0; while (count < 600) { - Thread.Sleep(100); + int readLen = port.BytesToRead; if (readLen > 0) { @@ -937,6 +1021,7 @@ } } count++; + Thread.Sleep(100); } } else @@ -945,7 +1030,7 @@ while (count < 600) { - Thread.Sleep(100); + int readLen = port.BytesToRead; if (readLen > 0) { @@ -971,6 +1056,8 @@ } } count++; + + Thread.Sleep(100); } } @@ -978,7 +1065,14 @@ if (received.Equals("")) { string name = ConfigHelper.getKeyByValue(port.PortName + " 115200").Replace("channel", "通道"); - LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, name + "获取数据失败!" + DateTime.Now.ToLongTimeString()); + LogHelper.WriteErrorLog(MethodBase.GetCurrentMethod().DeclaringType, name + "获取数据失败!!!!!!!!!!!!!!" + DateTime.Now.ToLongTimeString()); + if (!isTest) + { + MessageBox.Show("从[" + name + "]获取数据失败,该通道上的检测将终止!"); + return "close"; + } + + return received; } break; }