diff --git a/DB/Service/UpdateLogService.cs b/DB/Service/UpdateLogService.cs index dfeb421..cc2b1dd 100644 --- a/DB/Service/UpdateLogService.cs +++ b/DB/Service/UpdateLogService.cs @@ -16,7 +16,7 @@ namespace DB.Service /// public class UpdateLogService { - public bool AddOrUpdateLog(UserDto user,string address,uint value) + public bool AddOrUpdateLog(UserDto user,string address,int value) { UpdateLog log = new UpdateLog { diff --git a/RfidWeb/FormLogin.cs b/RfidWeb/FormLogin.cs index 8fef9c9..c5f4483 100644 --- a/RfidWeb/FormLogin.cs +++ b/RfidWeb/FormLogin.cs @@ -88,6 +88,7 @@ namespace RfidWeb } UserManager.Add(one); + var info= PlcConnect.Instance.Write(HmiPointInfo.Safety_level, int.Parse(one.RoleLevel.ToString())); this.DialogResult = DialogResult.No; this.Close(); diff --git a/RfidWeb/FormMain.cs b/RfidWeb/FormMain.cs index 64831a8..3d5c0a9 100644 --- a/RfidWeb/FormMain.cs +++ b/RfidWeb/FormMain.cs @@ -14,6 +14,7 @@ using RfidWeb.Frm; using System; using System.Collections.Generic; using System.Drawing; +using System.Security.Policy; using System.Windows.Forms; using Tool; @@ -90,13 +91,12 @@ namespace RfidWeb this.Invoke(() => { - - //不存在 if (!isExit) { labUser.ForeColor= System.Drawing.SystemColors.Window; labUser.Text = "未登录(未授权)"; + PlcConnect.Instance.Write(HmiPointInfo.Safety_level, int.Parse("0")); } else { @@ -142,7 +142,7 @@ namespace RfidWeb var strings = dic.Keys; foreach (var se in strings) { - var res = plc.ReadUInt32(se); + var res = plc.ReadInt32(se); if (res.IsSuccess) { string name = dic[se]; @@ -262,10 +262,15 @@ namespace RfidWeb if (FrmDialog.ShowDialog(this, "退出登录", "提示窗体", true) == System.Windows.Forms.DialogResult.OK) { - cache.Remove(CacheKeyManager.User); + cache.Remove(CacheKeyManager.HmiUser); + PlcConnect.Instance.Write(HmiPointInfo.Safety_level, int.Parse("0")); btnShow_Click(new object(), EventArgs.Empty); } } + else + { + CheckLogin(); + } } private void buttonUpdateLog_Click(object sender, EventArgs e) diff --git a/RfidWeb/Frm/FormPar.cs b/RfidWeb/Frm/FormPar.cs index 9cf92e7..59aff98 100644 --- a/RfidWeb/Frm/FormPar.cs +++ b/RfidWeb/Frm/FormPar.cs @@ -45,17 +45,17 @@ namespace RfidWeb.Frm { dicA.Clear(); - textBoxExFeedingMotorSpeed.Text=HmiPoint.GetFeedingMotorSpeed.ToString(); - textBoxExLaminatedMotorSpeed.Text= HmiPoint.GetLaminatedMotorSpeed.ToString(); - double result = HmiPoint.GetSWSS / 10.0; + textBoxExFeedingMotorSpeed.Text=HmiPointInfo.GetFeedingMotorSpeed.ToString(); + textBoxExLaminatedMotorSpeed.Text= HmiPointInfo.GetLaminatedMotorSpeed.ToString(); + double result = HmiPointInfo.GetSWSS / 10.0; textBoxExSWSD.Text = result.ToString(); - textBoxExFelt.Text = HmiPoint.GetFeltBeltMotorSpeed.ToString(); - textBoxReceiving.Text = HmiPoint.GeReceivingMotorSpeed.ToString(); + textBoxExFelt.Text = HmiPointInfo.GetFeltBeltMotorSpeed.ToString(); + textBoxReceiving.Text = HmiPointInfo.GeReceivingMotorSpeed.ToString(); dicA["A"] = textBoxExFeedingMotorSpeed.Text; dicA["B"] = textBoxExLaminatedMotorSpeed.Text; - dicA["C"] = HmiPoint.GetSWSS.ToString(); + dicA["C"] = HmiPointInfo.GetSWSS.ToString(); dicA["D"] = textBoxExFelt.Text; dicA["E"] = textBoxReceiving.Text; @@ -69,31 +69,31 @@ namespace RfidWeb.Frm var a = textBoxExFeedingMotorSpeed.Text; if (a != dicA["A"]) { - plc.Write(HmiPoint.feeding_motor_speed, uint.Parse(a)); + plc.Write(HmiPointInfo.feeding_motor_speed, int.Parse(a)); } var b = textBoxExLaminatedMotorSpeed.Text; if (b != dicA["B"]) { - plc.Write(HmiPoint.Laminated_motor_speed, uint.Parse(b)); + plc.Write(HmiPointInfo.Laminated_motor_speed, int.Parse(b)); } var c = UInt32.Parse((Convert.ToDouble(textBoxExSWSD.Text) * 10).ToString()).ToString(); if (c != dicA["C"]) { - plc.Write(HmiPoint.SWSS, uint.Parse(c)); + plc.Write(HmiPointInfo.SWSS, int.Parse(c)); } var d = textBoxExFelt.Text; if (d != dicA["D"]) { - plc.Write(HmiPoint.Felt_belt_motor_speed, uint.Parse(d)); + plc.Write(HmiPointInfo.Felt_belt_motor_speed, int.Parse(d)); } var ee = textBoxExFelt.Text; if (ee != dicA["E"]) { - plc.Write(HmiPoint.Receiving_Electric_motor_speed, uint.Parse(ee)); + plc.Write(HmiPointInfo.Receiving_Electric_motor_speed, int.Parse(ee)); } MessageBox.Show("保存成功"); @@ -105,172 +105,172 @@ namespace RfidWeb.Frm { dicB.Clear(); - txtCUTTING_SET_TEMPERATURE1_1.Text = HmiPoint.GetCUTTING_SET_TEMPERATURE1_1.ToString(); + txtCUTTING_SET_TEMPERATURE1_1.Text = HmiPointInfo.GetCUTTING_SET_TEMPERATURE1_1.ToString(); dicB["CUTTING_SET_TEMPERATURE1_1"] = txtCUTTING_SET_TEMPERATURE1_1.Text; - txtCUTTING_SET_TEMPERATURE1_2.Text = HmiPoint.GetCUTTING_SET_TEMPERATURE1_2.ToString(); + txtCUTTING_SET_TEMPERATURE1_2.Text = HmiPointInfo.GetCUTTING_SET_TEMPERATURE1_2.ToString(); dicB["CUTTING_SET_TEMPERATURE1_2"] = txtCUTTING_SET_TEMPERATURE1_2.Text; - txtCUTTING_SET_TEMPERATURE1_3.Text = HmiPoint.GetCUTTING_SET_TEMPERATURE1_3.ToString(); + txtCUTTING_SET_TEMPERATURE1_3.Text = HmiPointInfo.GetCUTTING_SET_TEMPERATURE1_3.ToString(); dicB["CUTTING_SET_TEMPERATURE1_3"] = txtCUTTING_SET_TEMPERATURE1_3.Text; - txtCUTTING_SET_TEMPERATURE1_4.Text = HmiPoint.GetCUTTING_SET_TEMPERATURE1_4.ToString(); + txtCUTTING_SET_TEMPERATURE1_4.Text = HmiPointInfo.GetCUTTING_SET_TEMPERATURE1_4.ToString(); dicB["CUTTING_SET_TEMPERATURE1_4"] = txtCUTTING_SET_TEMPERATURE1_4.Text; - txtCUTTING_SET_TEMPERATURE2_1.Text = HmiPoint.GetCUTTING_SET_TEMPERATURE2_1.ToString(); + txtCUTTING_SET_TEMPERATURE2_1.Text = HmiPointInfo.GetCUTTING_SET_TEMPERATURE2_1.ToString(); dicB["CUTTING_SET_TEMPERATURE2_1"] = txtCUTTING_SET_TEMPERATURE2_1.Text; - txtCUTTING_SET_TEMPERATURE2_2.Text = HmiPoint.GetCUTTING_SET_TEMPERATURE2_2.ToString(); + txtCUTTING_SET_TEMPERATURE2_2.Text = HmiPointInfo.GetCUTTING_SET_TEMPERATURE2_2.ToString(); dicB["CUTTING_SET_TEMPERATURE2_2"] = txtCUTTING_SET_TEMPERATURE2_2.Text; - txtCUTTING_SET_TEMPERATURE2_3.Text = HmiPoint.GetCUTTING_SET_TEMPERATURE2_3.ToString(); + txtCUTTING_SET_TEMPERATURE2_3.Text = HmiPointInfo.GetCUTTING_SET_TEMPERATURE2_3.ToString(); dicB["CUTTING_SET_TEMPERATURE2_3"] = txtCUTTING_SET_TEMPERATURE2_3.Text; - txtCUTTING_SET_TEMPERATURE2_4.Text = HmiPoint.GetCUTTING_SET_TEMPERATURE2_4.ToString(); + txtCUTTING_SET_TEMPERATURE2_4.Text = HmiPointInfo.GetCUTTING_SET_TEMPERATURE2_4.ToString(); dicB["CUTTING_SET_TEMPERATURE2_4"] = txtCUTTING_SET_TEMPERATURE2_4.Text; - txtCUTTING_SET_TIME1_1.Text = HmiPoint.GetCUTTING_SET_TIME1_1.ToString(); + txtCUTTING_SET_TIME1_1.Text = HmiPointInfo.GetCUTTING_SET_TIME1_1.ToString(); dicB["CUTTING_SET_TIME1_1"] = txtCUTTING_SET_TIME1_1.Text; - txtCUTTING_SET_TIME1_2.Text = HmiPoint.GetCUTTING_SET_TIME1_2.ToString(); + txtCUTTING_SET_TIME1_2.Text = HmiPointInfo.GetCUTTING_SET_TIME1_2.ToString(); dicB["CUTTING_SET_TIME1_2"] = txtCUTTING_SET_TIME1_2.Text; - txtCUTTING_SET_TIME1_3.Text = HmiPoint.GetCUTTING_SET_TIME1_3.ToString(); + txtCUTTING_SET_TIME1_3.Text = HmiPointInfo.GetCUTTING_SET_TIME1_3.ToString(); dicB["CUTTING_SET_TIME1_3"] = txtCUTTING_SET_TIME1_3.Text; - txtCUTTING_SET_TIME1_4.Text = HmiPoint.GetCUTTING_SET_TIME1_4.ToString(); + txtCUTTING_SET_TIME1_4.Text = HmiPointInfo.GetCUTTING_SET_TIME1_4.ToString(); dicB["CUTTING_SET_TIME1_4"] = txtCUTTING_SET_TIME1_4.Text; - txtCUTTING_SET_TIME2_1.Text = HmiPoint.GetCUTTING_SET_TIME2_1.ToString(); + txtCUTTING_SET_TIME2_1.Text = HmiPointInfo.GetCUTTING_SET_TIME2_1.ToString(); dicB["CUTTING_SET_TIME2_1"] = txtCUTTING_SET_TIME2_1.Text; - txtCUTTING_SET_TIME2_2.Text = HmiPoint.GetCUTTING_SET_TIME2_2.ToString(); + txtCUTTING_SET_TIME2_2.Text = HmiPointInfo.GetCUTTING_SET_TIME2_2.ToString(); dicB["CUTTING_SET_TIME2_2"] = txtCUTTING_SET_TIME2_2.Text; - txtCUTTING_SET_TIME2_3.Text = HmiPoint.GetCUTTING_SET_TIME2_3.ToString(); + txtCUTTING_SET_TIME2_3.Text = HmiPointInfo.GetCUTTING_SET_TIME2_3.ToString(); dicB["CUTTING_SET_TIME2_3"] = txtCUTTING_SET_TIME2_3.Text; - txtCUTTING_SET_TIME2_4.Text = HmiPoint.GetCUTTING_SET_TIME2_4.ToString(); + txtCUTTING_SET_TIME2_4.Text = HmiPointInfo.GetCUTTING_SET_TIME2_4.ToString(); dicB["CUTTING_SET_TIME2_4"] = txtCUTTING_SET_TIME2_4.Text; } private void button7_Click(object sender, EventArgs e) { var plc = PlcConnect.Instance; - var CUTTING_SET_TEMPERATURE1_1= HmiPoint.GetCUTTING_SET_TEMPERATURE1_1.ToString(); + var CUTTING_SET_TEMPERATURE1_1= HmiPointInfo.GetCUTTING_SET_TEMPERATURE1_1.ToString(); if (CUTTING_SET_TEMPERATURE1_1 != dicB["CUTTING_SET_TEMPERATURE1_1"]) { - plc.Write(HmiPoint.CUTTING_SET_TEMPERATURE1_1, uint.Parse(CUTTING_SET_TEMPERATURE1_1)); + plc.Write(HmiPointInfo.CUTTING_SET_TEMPERATURE1_1, int.Parse(CUTTING_SET_TEMPERATURE1_1)); } - var CUTTING_SET_TEMPERATURE1_2 = HmiPoint.GetCUTTING_SET_TEMPERATURE1_2.ToString(); + var CUTTING_SET_TEMPERATURE1_2 = HmiPointInfo.GetCUTTING_SET_TEMPERATURE1_2.ToString(); if (CUTTING_SET_TEMPERATURE1_2 != dicB["CUTTING_SET_TEMPERATURE1_2"]) { - plc.Write(HmiPoint.CUTTING_SET_TEMPERATURE1_2, uint.Parse(CUTTING_SET_TEMPERATURE1_2)); + plc.Write(HmiPointInfo.CUTTING_SET_TEMPERATURE1_2, int.Parse(CUTTING_SET_TEMPERATURE1_2)); } - var CUTTING_SET_TEMPERATURE1_3 = HmiPoint.GetCUTTING_SET_TEMPERATURE1_3.ToString(); + var CUTTING_SET_TEMPERATURE1_3 = HmiPointInfo.GetCUTTING_SET_TEMPERATURE1_3.ToString(); if (CUTTING_SET_TEMPERATURE1_3 != dicB["CUTTING_SET_TEMPERATURE1_3"]) { - plc.Write(HmiPoint.CUTTING_SET_TEMPERATURE1_3, uint.Parse(CUTTING_SET_TEMPERATURE1_3)); + plc.Write(HmiPointInfo.CUTTING_SET_TEMPERATURE1_3, int.Parse(CUTTING_SET_TEMPERATURE1_3)); } - var CUTTING_SET_TEMPERATURE1_4 = HmiPoint.GetCUTTING_SET_TEMPERATURE1_4.ToString(); + var CUTTING_SET_TEMPERATURE1_4 = HmiPointInfo.GetCUTTING_SET_TEMPERATURE1_4.ToString(); if (CUTTING_SET_TEMPERATURE1_4 != dicB["CUTTING_SET_TEMPERATURE1_4"]) { - plc.Write(HmiPoint.CUTTING_SET_TEMPERATURE1_4, uint.Parse(CUTTING_SET_TEMPERATURE1_4)); + plc.Write(HmiPointInfo.CUTTING_SET_TEMPERATURE1_4, int.Parse(CUTTING_SET_TEMPERATURE1_4)); } - var CUTTING_SET_TEMPERATURE2_1 = HmiPoint.GetCUTTING_SET_TEMPERATURE2_1.ToString(); + var CUTTING_SET_TEMPERATURE2_1 = HmiPointInfo.GetCUTTING_SET_TEMPERATURE2_1.ToString(); if (CUTTING_SET_TEMPERATURE2_1 != dicB["CUTTING_SET_TEMPERATURE2_1"]) { - plc.Write(HmiPoint.CUTTING_SET_TEMPERATURE2_1, uint.Parse(CUTTING_SET_TEMPERATURE2_1)); + plc.Write(HmiPointInfo.CUTTING_SET_TEMPERATURE2_1, int.Parse(CUTTING_SET_TEMPERATURE2_1)); } - var CUTTING_SET_TEMPERATURE2_2 = HmiPoint.GetCUTTING_SET_TEMPERATURE2_2.ToString(); + var CUTTING_SET_TEMPERATURE2_2 = HmiPointInfo.GetCUTTING_SET_TEMPERATURE2_2.ToString(); if (CUTTING_SET_TEMPERATURE2_2 != dicB["CUTTING_SET_TEMPERATURE2_2"]) { - plc.Write(HmiPoint.CUTTING_SET_TEMPERATURE2_2, uint.Parse(CUTTING_SET_TEMPERATURE2_2)); + plc.Write(HmiPointInfo.CUTTING_SET_TEMPERATURE2_2, int.Parse(CUTTING_SET_TEMPERATURE2_2)); } - var CUTTING_SET_TEMPERATURE2_3 = HmiPoint.GetCUTTING_SET_TEMPERATURE2_3.ToString(); + var CUTTING_SET_TEMPERATURE2_3 = HmiPointInfo.GetCUTTING_SET_TEMPERATURE2_3.ToString(); if (CUTTING_SET_TEMPERATURE2_3 != dicB["CUTTING_SET_TEMPERATURE2_3"]) { - plc.Write(HmiPoint.CUTTING_SET_TEMPERATURE2_3, uint.Parse(CUTTING_SET_TEMPERATURE2_3)); + plc.Write(HmiPointInfo.CUTTING_SET_TEMPERATURE2_3, int.Parse(CUTTING_SET_TEMPERATURE2_3)); } - var CUTTING_SET_TEMPERATURE2_4 = HmiPoint.GetCUTTING_SET_TEMPERATURE2_4.ToString(); + var CUTTING_SET_TEMPERATURE2_4 = HmiPointInfo.GetCUTTING_SET_TEMPERATURE2_4.ToString(); if (CUTTING_SET_TEMPERATURE2_4 != dicB["CUTTING_SET_TEMPERATURE2_4"]) { - plc.Write(HmiPoint.CUTTING_SET_TEMPERATURE2_4, uint.Parse(CUTTING_SET_TEMPERATURE2_4)); + plc.Write(HmiPointInfo.CUTTING_SET_TEMPERATURE2_4, int.Parse(CUTTING_SET_TEMPERATURE2_4)); } - var CUTTING_SET_TIME1_1 = HmiPoint.GetCUTTING_SET_TIME1_1.ToString(); + var CUTTING_SET_TIME1_1 = HmiPointInfo.GetCUTTING_SET_TIME1_1.ToString(); if (CUTTING_SET_TIME1_1 != dicB["CUTTING_SET_TIME1_1"]) { - plc.Write(HmiPoint.CUTTING_SET_TIME1_1, uint.Parse(CUTTING_SET_TIME1_1)); + plc.Write(HmiPointInfo.CUTTING_SET_TIME1_1, int.Parse(CUTTING_SET_TIME1_1)); } - var CUTTING_SET_TIME1_2 = HmiPoint.GetCUTTING_SET_TIME1_2.ToString(); + var CUTTING_SET_TIME1_2 = HmiPointInfo.GetCUTTING_SET_TIME1_2.ToString(); if (CUTTING_SET_TIME1_2 != dicB["CUTTING_SET_TIME1_2"]) { - plc.Write(HmiPoint.CUTTING_SET_TIME1_2, uint.Parse(CUTTING_SET_TIME1_2)); + plc.Write(HmiPointInfo.CUTTING_SET_TIME1_2, int.Parse(CUTTING_SET_TIME1_2)); } - var CUTTING_SET_TIME1_3 = HmiPoint.GetCUTTING_SET_TIME1_3.ToString(); + var CUTTING_SET_TIME1_3 = HmiPointInfo.GetCUTTING_SET_TIME1_3.ToString(); if (CUTTING_SET_TIME1_3 != dicB["CUTTING_SET_TIME1_3"]) { - plc.Write(HmiPoint.CUTTING_SET_TIME1_3, uint.Parse(CUTTING_SET_TIME1_3)); + plc.Write(HmiPointInfo.CUTTING_SET_TIME1_3, int.Parse(CUTTING_SET_TIME1_3)); } - var CUTTING_SET_TIME1_4 = HmiPoint.GetCUTTING_SET_TIME1_4.ToString(); + var CUTTING_SET_TIME1_4 = HmiPointInfo.GetCUTTING_SET_TIME1_4.ToString(); if (CUTTING_SET_TIME1_4 != dicB["CUTTING_SET_TIME1_4"]) { - plc.Write(HmiPoint.CUTTING_SET_TIME1_4, uint.Parse(CUTTING_SET_TIME1_4)); + plc.Write(HmiPointInfo.CUTTING_SET_TIME1_4, int.Parse(CUTTING_SET_TIME1_4)); } - var CUTTING_SET_TIME2_1 = HmiPoint.GetCUTTING_SET_TIME2_1.ToString(); + var CUTTING_SET_TIME2_1 = HmiPointInfo.GetCUTTING_SET_TIME2_1.ToString(); if (CUTTING_SET_TIME2_1 != dicB["CUTTING_SET_TIME2_1"]) { - plc.Write(HmiPoint.CUTTING_SET_TIME2_1, uint.Parse(CUTTING_SET_TIME2_1)); + plc.Write(HmiPointInfo.CUTTING_SET_TIME2_1, int.Parse(CUTTING_SET_TIME2_1)); } - var CUTTING_SET_TIME2_2 = HmiPoint.GetCUTTING_SET_TIME2_2.ToString(); + var CUTTING_SET_TIME2_2 = HmiPointInfo.GetCUTTING_SET_TIME2_2.ToString(); if (CUTTING_SET_TIME2_2 != dicB["CUTTING_SET_TIME2_2"]) { - plc.Write(HmiPoint.CUTTING_SET_TIME2_2, uint.Parse(CUTTING_SET_TIME2_2)); + plc.Write(HmiPointInfo.CUTTING_SET_TIME2_2, int.Parse(CUTTING_SET_TIME2_2)); } - var CUTTING_SET_TIME2_3 = HmiPoint.GetCUTTING_SET_TIME2_3.ToString(); + var CUTTING_SET_TIME2_3 = HmiPointInfo.GetCUTTING_SET_TIME2_3.ToString(); if (CUTTING_SET_TIME2_3 != dicB["CUTTING_SET_TIME2_3"]) { - plc.Write(HmiPoint.CUTTING_SET_TIME2_3, uint.Parse(CUTTING_SET_TIME2_3)); + plc.Write(HmiPointInfo.CUTTING_SET_TIME2_3, int.Parse(CUTTING_SET_TIME2_3)); } - var CUTTING_SET_TIME2_4 = HmiPoint.GetCUTTING_SET_TIME2_4.ToString(); + var CUTTING_SET_TIME2_4 = HmiPointInfo.GetCUTTING_SET_TIME2_4.ToString(); if (CUTTING_SET_TIME2_4 != dicB["CUTTING_SET_TIME2_4"]) { - plc.Write(HmiPoint.CUTTING_SET_TIME2_4, uint.Parse(CUTTING_SET_TIME2_4)); + plc.Write(HmiPointInfo.CUTTING_SET_TIME2_4, int.Parse(CUTTING_SET_TIME2_4)); } MessageBox.Show("保存成功"); diff --git a/RfidWeb/Frm/FormPlanAdd.cs b/RfidWeb/Frm/FormPlanAdd.cs index cf8c49c..5bbb34c 100644 --- a/RfidWeb/Frm/FormPlanAdd.cs +++ b/RfidWeb/Frm/FormPlanAdd.cs @@ -11,6 +11,7 @@ using System.Windows.Forms; using DB.Entity; using DB.Service; using Tool; +using Tool.Model; namespace RfidWeb.Frm { @@ -44,12 +45,31 @@ namespace RfidWeb.Frm this.Close(); } - private void btnOK_BtnClick(object sender, EventArgs e) + bool IsValidNumber(string input) { + // 检查是否是纯数字 + if (int.TryParse(input, out int number)) + { + // 检查范围是否符合 + return number > 0 && number < 2000; + } + return false; + } + - fromPlan.Num = ucNo.InputText.ToInt(); + private void btnOK_BtnClick(object sender, EventArgs e) + { + var code = ucNo.InputText.ToInt(); + fromPlan.Num = code; fromPlan.Code=ucCode.InputText.ToString(); + if (IsValidNumber(ucNo.InputText)) + { + MessageBox.Show("请输入0-2000 有效范围"); + return; + } + + if (id == 0) { @@ -60,6 +80,8 @@ namespace RfidWeb.Frm fromPlanService.Update(fromPlan); } + PlcConnect.Instance.Write(HmiPointInfo.Product_counter_CH, int.Parse(code.ToString())); + this.Close(); } } diff --git a/RfidWeb/Frm/UserAlarmShow.cs b/RfidWeb/Frm/UserAlarmShow.cs index cc11731..edccce5 100644 --- a/RfidWeb/Frm/UserAlarmShow.cs +++ b/RfidWeb/Frm/UserAlarmShow.cs @@ -49,7 +49,7 @@ namespace RfidWeb.Frm stopwatc.Restart(); this.Invoke(() => { - btnStatus.Text = HmiPoint.GetStateText(); + btnStatus.Text = HmiPointInfo.GetStateText(); }); FillAlarmGrid(); FillPromptGrid(); @@ -288,20 +288,20 @@ namespace RfidWeb.Frm { //HmiPoint - hslLabelCombofeedingMotorSpeed.TextValue = HmiPoint.GetFeedingMotorSpeed.ToString(); - hslLabelComboLaminated.TextValue = HmiPoint.GetLaminatedMotorSpeed.ToString(); - hslLabelComboFelt.TextValue = HmiPoint.GetFeltBeltMotorSpeed.ToString(); - hslLabelComboReceiving.TextValue = HmiPoint.GeReceivingMotorSpeed.ToString(); + hslLabelCombofeedingMotorSpeed.TextValue = HmiPointInfo.GetFeedingMotorSpeed.ToString(); + hslLabelComboLaminated.TextValue = HmiPointInfo.GetLaminatedMotorSpeed.ToString(); + hslLabelComboFelt.TextValue = HmiPointInfo.GetFeltBeltMotorSpeed.ToString(); + hslLabelComboReceiving.TextValue = HmiPointInfo.GeReceivingMotorSpeed.ToString(); - hslLabelComboProduct_counter2.TextValue = HmiPoint.GetProduct_counter2.ToString(); + hslLabelComboProduct_counter2.TextValue = HmiPointInfo.GetProduct_counter2.ToString(); - hslLabelComboCQ_Chip1_counter.TextValue = HmiPoint.GetCQ_Chip1_counter.ToString(); - hslLabelComboCQ_Chip2_counter.TextValue = HmiPoint.GetCQ_Chip2_counter.ToString(); + hslLabelComboCQ_Chip1_counter.TextValue = HmiPointInfo.GetCQ_Chip1_counter.ToString(); + hslLabelComboCQ_Chip2_counter.TextValue = HmiPointInfo.GetCQ_Chip2_counter.ToString(); - hslLabelComboQDWD1SS.TextValue = HmiPoint.GetQDWD1SS.ToString(); - hslLabelComboQDWD2SS.TextValue = HmiPoint.GetQDWD2SS.ToString(); + hslLabelComboQDWD1SS.TextValue = HmiPointInfo.GetQDWD1SS.ToString(); + hslLabelComboQDWD2SS.TextValue = HmiPointInfo.GetQDWD2SS.ToString(); - double result = HmiPoint.GetSWSS / 10.0; + double result = HmiPointInfo.GetSWSS / 10.0; hslLabelComboSWSS.TextValue = result.ToString(); diff --git a/RfidWeb/Tool/UserManager.cs b/RfidWeb/Tool/UserManager.cs index c9d50b9..fe481b7 100644 --- a/RfidWeb/Tool/UserManager.cs +++ b/RfidWeb/Tool/UserManager.cs @@ -15,12 +15,13 @@ namespace RfidWeb /// public static class UserManager { - private static string key => CacheKeyManager.User; + private static string key => CacheKeyManager.HmiUser; private static ICache cache = Cache.Default; public static void Add(UserDto dto) { - cache.Set(key, dto, TimeSpan.FromMinutes(5)); + cache.Set(key, dto, TimeSpan.FromDays(2)); + } public static UserDto GetUser() @@ -37,7 +38,7 @@ namespace RfidWeb { if (IsExit()) { - cache.SetExpire(key, TimeSpan.FromMinutes(5)); + cache.SetExpire(key, TimeSpan.FromDays(2)); } } } diff --git a/Tool/Model/BoolModelFactory.cs b/Tool/Model/BoolModelFactory.cs index 54a5474..26c1d56 100644 --- a/Tool/Model/BoolModelFactory.cs +++ b/Tool/Model/BoolModelFactory.cs @@ -58,7 +58,7 @@ namespace Tool.Model { PlcBoolModel BoolModel = new PlcBoolModel(); - var readUInt32 = PlcConnect.Instance.ReadUInt32(a); + var readUInt32 = PlcConnect.Instance.ReadInt32(a); var bo = readUInt32.IsSuccess; var context = readUInt32.Content; if (bo) @@ -72,7 +72,7 @@ namespace Tool.Model } - readUInt32 = PlcConnect.Instance.ReadUInt32(b); + readUInt32 = PlcConnect.Instance.ReadInt32(b); bo = readUInt32.IsSuccess; context = readUInt32.Content; if (bo) diff --git a/Tool/Model/CacheKeyManager.cs b/Tool/Model/CacheKeyManager.cs index 6283d44..d015717 100644 --- a/Tool/Model/CacheKeyManager.cs +++ b/Tool/Model/CacheKeyManager.cs @@ -4,7 +4,7 @@ { public static readonly string UpdateLog = "UpdateLog"; - public static readonly string User = "HmiUser"; + public static readonly string HmiUser = "HmiUser"; public static readonly string AesPwd = "nodyang"; diff --git a/Tool/Model/EsStop.cs b/Tool/Model/EsStop.cs index 98104b7..20f315d 100644 --- a/Tool/Model/EsStop.cs +++ b/Tool/Model/EsStop.cs @@ -10,7 +10,7 @@ namespace Tool.Model public List GetDb() { bool[] bitArray = new bool[32]; - var readUInt32 = PlcConnect.Instance.ReadUInt32("estop_temporary_storage"); + var readUInt32 = PlcConnect.Instance.ReadInt32("estop_temporary_storage"); var bo = readUInt32.IsSuccess; var context = readUInt32.Content; if (bo) diff --git a/Tool/Model/HmiPoint.cs b/Tool/Model/HmiPoint.cs index 02a65eb..62dba83 100644 --- a/Tool/Model/HmiPoint.cs +++ b/Tool/Model/HmiPoint.cs @@ -8,14 +8,14 @@ using HslCommunication; namespace Tool.Model { - public class HmiPoint + public class HmiPointInfo { /// /// DInt 供料电机速度 /// public static readonly string feeding_motor_speed = "feeding_motor_speed"; - public static UInt32 GetFeedingMotorSpeed => GetValue(feeding_motor_speed); + public static Int32 GetFeedingMotorSpeed => GetValue(feeding_motor_speed); /// @@ -24,7 +24,7 @@ namespace Tool.Model public static readonly string Laminated_motor_speed = "Laminated_motor_speed"; - public static UInt32 GetLaminatedMotorSpeed => GetValue(Laminated_motor_speed); + public static Int32 GetLaminatedMotorSpeed => GetValue(Laminated_motor_speed); /// @@ -33,7 +33,7 @@ namespace Tool.Model public static readonly string Felt_belt_motor_speed = "Felt_belt_motor_speed"; - public static UInt32 GetFeltBeltMotorSpeed => GetValue(Felt_belt_motor_speed); + public static Int32 GetFeltBeltMotorSpeed => GetValue(Felt_belt_motor_speed); /// @@ -41,7 +41,7 @@ namespace Tool.Model /// public static readonly string Receiving_Electric_motor_speed = "Receiving_Electric_motor_speed"; - public static UInt32 GeReceivingMotorSpeed => GetValue(Receiving_Electric_motor_speed); + public static Int32 GeReceivingMotorSpeed => GetValue(Receiving_Electric_motor_speed); /// @@ -49,20 +49,20 @@ namespace Tool.Model /// public static readonly string Product_counter2 = "Product_counter2"; - public static UInt32 GetProduct_counter2 => GetValue(Product_counter2); + public static Int32 GetProduct_counter2 => GetValue(Product_counter2); /// /// 裁切1生产数量 /// public static readonly string CQ_Chip1_counter = "CQ_Chip1_counter"; - public static UInt32 GetCQ_Chip1_counter => GetValue(CQ_Chip1_counter); + public static Int32 GetCQ_Chip1_counter => GetValue(CQ_Chip1_counter); /// /// 裁切2生产数量 /// public static readonly string CQ_Chip2_counter = "CQ_Chip2_counter"; - public static UInt32 GetCQ_Chip2_counter => GetValue(CQ_Chip2_counter); + public static Int32 GetCQ_Chip2_counter => GetValue(CQ_Chip2_counter); /// @@ -70,109 +70,121 @@ namespace Tool.Model /// public static readonly string QDWD1SS = "QDWD1SS"; - public static UInt32 GetQDWD1SS => GetValue(QDWD1SS); + public static Int32 GetQDWD1SS => GetValue(QDWD1SS); /// /// 裁刀1温度 /// public static readonly string QDWD2SS = "QDWD2SS"; - public static UInt32 GetQDWD2SS => GetValue(QDWD2SS); + public static Int32 GetQDWD2SS => GetValue(QDWD2SS); /// /// 设备内部温度 /// public static readonly string SWSS = "SWSS"; - public static UInt32 GetSWSS => GetValue(SWSS); + public static Int32 GetSWSS => GetValue(SWSS); - private static UInt32 GetValue(string key) + private static Int32 GetValue(string key) { var plc = PlcConnect.Instance; - var result = plc.ReadUInt32(key); + var result = plc.ReadInt32(key); - return result.IsSuccess ? result.Content : (uint)0; + return result.IsSuccess ? result.Content : 0; } public static readonly string CUTTING_SET_TEMPERATURE1_1 = "CUTTING_SET_TEMPERATURE1_1"; - public static UInt32 GetCUTTING_SET_TEMPERATURE1_1 => GetValue(CUTTING_SET_TEMPERATURE1_1); + public static Int32 GetCUTTING_SET_TEMPERATURE1_1 => GetValue(CUTTING_SET_TEMPERATURE1_1); public static readonly string CUTTING_SET_TEMPERATURE1_2 = "CUTTING_SET_TEMPERATURE1_2"; - public static UInt32 GetCUTTING_SET_TEMPERATURE1_2 => GetValue(CUTTING_SET_TEMPERATURE1_2); + public static Int32 GetCUTTING_SET_TEMPERATURE1_2 => GetValue(CUTTING_SET_TEMPERATURE1_2); public static readonly string CUTTING_SET_TEMPERATURE1_3 = "CUTTING_SET_TEMPERATURE1_3"; - public static UInt32 GetCUTTING_SET_TEMPERATURE1_3 => GetValue(CUTTING_SET_TEMPERATURE1_3); + public static Int32 GetCUTTING_SET_TEMPERATURE1_3 => GetValue(CUTTING_SET_TEMPERATURE1_3); public static readonly string CUTTING_SET_TEMPERATURE1_4 = "CUTTING_SET_TEMPERATURE1_4"; - public static UInt32 GetCUTTING_SET_TEMPERATURE1_4 => GetValue(CUTTING_SET_TEMPERATURE1_4); + public static Int32 GetCUTTING_SET_TEMPERATURE1_4 => GetValue(CUTTING_SET_TEMPERATURE1_4); public static readonly string CUTTING_SET_TEMPERATURE2_1 = "CUTTING_SET_TEMPERATURE2_1"; - public static UInt32 GetCUTTING_SET_TEMPERATURE2_1 => GetValue(CUTTING_SET_TEMPERATURE2_1); + public static Int32 GetCUTTING_SET_TEMPERATURE2_1 => GetValue(CUTTING_SET_TEMPERATURE2_1); public static readonly string CUTTING_SET_TEMPERATURE2_2 = "CUTTING_SET_TEMPERATURE2_2"; - public static UInt32 GetCUTTING_SET_TEMPERATURE2_2 => GetValue(CUTTING_SET_TEMPERATURE2_2); + public static Int32 GetCUTTING_SET_TEMPERATURE2_2 => GetValue(CUTTING_SET_TEMPERATURE2_2); public static readonly string CUTTING_SET_TEMPERATURE2_3 = "CUTTING_SET_TEMPERATURE2_3"; - public static UInt32 GetCUTTING_SET_TEMPERATURE2_3 => GetValue(CUTTING_SET_TEMPERATURE2_3); + public static Int32 GetCUTTING_SET_TEMPERATURE2_3 => GetValue(CUTTING_SET_TEMPERATURE2_3); public static readonly string CUTTING_SET_TEMPERATURE2_4 = "CUTTING_SET_TEMPERATURE2_4"; - public static UInt32 GetCUTTING_SET_TEMPERATURE2_4 => GetValue(CUTTING_SET_TEMPERATURE2_4); + public static Int32 GetCUTTING_SET_TEMPERATURE2_4 => GetValue(CUTTING_SET_TEMPERATURE2_4); public static readonly string CUTTING_SET_TIME1_1 = "CUTTING_SET_TIME1_1"; - public static UInt32 GetCUTTING_SET_TIME1_1 => GetValue(CUTTING_SET_TIME1_1); + public static Int32 GetCUTTING_SET_TIME1_1 => GetValue(CUTTING_SET_TIME1_1); public static readonly string CUTTING_SET_TIME1_2 = "CUTTING_SET_TIME1_2"; - public static UInt32 GetCUTTING_SET_TIME1_2 => GetValue(CUTTING_SET_TIME1_2); + public static Int32 GetCUTTING_SET_TIME1_2 => GetValue(CUTTING_SET_TIME1_2); public static readonly string CUTTING_SET_TIME1_3 = "CUTTING_SET_TIME1_3"; - public static UInt32 GetCUTTING_SET_TIME1_3 => GetValue(CUTTING_SET_TIME1_3); + public static Int32 GetCUTTING_SET_TIME1_3 => GetValue(CUTTING_SET_TIME1_3); public static readonly string CUTTING_SET_TIME1_4 = "CUTTING_SET_TIME1_4"; - public static UInt32 GetCUTTING_SET_TIME1_4 => GetValue(CUTTING_SET_TIME1_4); + public static Int32 GetCUTTING_SET_TIME1_4 => GetValue(CUTTING_SET_TIME1_4); public static readonly string CUTTING_SET_TIME2_1 = "CUTTING_SET_TIME2_1"; - public static UInt32 GetCUTTING_SET_TIME2_1 => GetValue(CUTTING_SET_TIME2_1); + public static Int32 GetCUTTING_SET_TIME2_1 => GetValue(CUTTING_SET_TIME2_1); public static readonly string CUTTING_SET_TIME2_2 = "CUTTING_SET_TIME2_2"; - public static UInt32 GetCUTTING_SET_TIME2_2 => GetValue(CUTTING_SET_TIME2_2); + public static Int32 GetCUTTING_SET_TIME2_2 => GetValue(CUTTING_SET_TIME2_2); public static readonly string CUTTING_SET_TIME2_3 = "CUTTING_SET_TIME2_3"; - public static UInt32 GetCUTTING_SET_TIME2_3 => GetValue(CUTTING_SET_TIME2_3); + public static Int32 GetCUTTING_SET_TIME2_3 => GetValue(CUTTING_SET_TIME2_3); public static readonly string CUTTING_SET_TIME2_4 = "CUTTING_SET_TIME2_4"; - public static UInt32 GetCUTTING_SET_TIME2_4 => GetValue(CUTTING_SET_TIME2_4); + public static Int32 GetCUTTING_SET_TIME2_4 => GetValue(CUTTING_SET_TIME2_4); + /// + /// 计划的数量 + /// + public static readonly string Product_counter_CH = "Product_counter_CH"; + + + /// + /// 安全级别 + /// + public static readonly string Safety_level = "Safety_level"; + + public static String GetStateText() { string text = ""; var plc = PlcConnect.Instance; - var result = plc.ReadUInt32("status_indicator"); + var result = plc.ReadInt32("status_indicator"); if (result.IsSuccess) { var context = result.Content; diff --git a/Tool/Model/PromptAlarm.cs b/Tool/Model/PromptAlarm.cs index fb4101c..042f4ac 100644 --- a/Tool/Model/PromptAlarm.cs +++ b/Tool/Model/PromptAlarm.cs @@ -13,7 +13,7 @@ namespace Tool.Model public List GetDb() { bool[] bitArray = new bool[32]; - var readUInt32 = PlcConnect.Instance.ReadUInt32("Prompt_alarm"); + var readUInt32 = PlcConnect.Instance.ReadInt32("Prompt_alarm"); var bo = readUInt32.IsSuccess; var context = readUInt32.Content; if (bo)