From 6ee566826cbef0ff7dd4db15d78ee0b04f7752a6 Mon Sep 17 00:00:00 2001 From: wangsr Date: Fri, 25 Aug 2023 17:36:07 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20PlcCommunication=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ElectronicMachineryDataStateMonitor.cs | 111 ++++++++---------- .../InstrumentDataStateMonitor.cs | 37 ++---- .../MotorInitStateMonitor.cs | 72 +++++------- .../ParametersWithPCStateMonitor.cs | 41 ++----- ...ParametersWithPCStateMonitor_Normal_HMI.cs | 109 +++++++---------- ...ametersWithPCStateMonitor_Para.Designer.cs | 2 +- .../ParametersWithPCStateMonitor_Para.cs | 53 +++------ .../PlcCommunicationUtil.cs | 43 +------ .../ValveStateMonitor.cs | 76 +++++------- .../ValveInitStateMonitor.cs | 76 +++++------- .../Test/TestAction.cs | 2 +- 11 files changed, 220 insertions(+), 402 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ElectronicMachineryDataStateMonitor/ElectronicMachineryDataStateMonitor.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ElectronicMachineryDataStateMonitor/ElectronicMachineryDataStateMonitor.cs index c24e3be..008d8f6 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ElectronicMachineryDataStateMonitor/ElectronicMachineryDataStateMonitor.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ElectronicMachineryDataStateMonitor/ElectronicMachineryDataStateMonitor.cs @@ -24,25 +24,6 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach StateMonitor_FOR_MOTOR_VFD(DmName_FOR_MOTOR_VFD); } - /// - /// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用 - /// - /// 数据块属性名 - /// - private DataKeyValue GetDataNameValue(string dmName, string dmValue) - { - return new DataKeyValue(dmName + dmValue); - } - - /// - /// 从PLC中读取值 - /// - /// 要读取的属性 - /// - private string GetDataToString(string dmName, string dmValue) - { - return GetDataNameValue(dmName, dmValue).NowValue.ToString(); - } private void DmChange_FOR_MOTOR_SelectedIndexChanged(object sender, EventArgs e) { @@ -84,16 +65,16 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach private void StateMonitor_FOR_MOTOR(String dmName) { - ManualMode.Text = GetDataToString(dmName, "_ManualMode"); - AutoMode.Text = GetDataToString(dmName, "_AutoMode"); - StartManual.Text = GetDataToString(dmName, "_StartManual"); - StopManual.Text = GetDataToString(dmName, "_StopManual"); - StartAuto.Text = GetDataToString(dmName, "_StartAuto"); - StopAuto.Text = GetDataToString(dmName, "_StopAuto"); - AlarmReset.Text = GetDataToString(dmName, "_AlarmReset"); - Running.Text = GetDataToString(dmName, "_Running"); - Run.Text = GetDataToString(dmName, "_Run"); - Alarm.Text = GetDataToString(dmName, "_Alarm"); + ManualMode.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManualMode"); + AutoMode.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoMode"); + StartManual.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StartManual"); + StopManual.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StopManual"); + StartAuto.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StartAuto"); + StopAuto.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StopAuto"); + AlarmReset.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmReset"); + Running.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Running"); + Run.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Run"); + Alarm.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm"); } private void DmChange_FOR_MOTOR_S_SelectedIndexChanged(object sender, EventArgs e) @@ -112,23 +93,23 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach private void StateMonitor_FOR_MOTOR_S(String dmName) { - ManualMode_S.Text = GetDataToString(dmName, "_ManualMode"); - AutoMode_S.Text = GetDataToString(dmName, "_AutoMode"); - StartManual_S.Text = GetDataToString(dmName, "_StartManual"); - StopManual_S.Text = GetDataToString(dmName, "_StopManual"); - StartAuto_S.Text = GetDataToString(dmName, "_StartAuto"); - StopAuto_S.Text = GetDataToString(dmName, "_StopAuto"); - AlarmReset_S.Text = GetDataToString(dmName, "_AlarmReset"); - Running_M_S.Text = GetDataToString(dmName, "_RunningM"); - Running_S_S.Text = GetDataToString(dmName, "_RunningS"); - Running_T_S.Text = GetDataToString(dmName, "_RunningT"); - Run_M_S.Text = GetDataToString(dmName, "_RunM"); - Run_S_S.Text = GetDataToString(dmName, "_RunS"); - Run_T_S.Text = GetDataToString(dmName, "_RunT"); - Alarm_S.Text = GetDataToString(dmName, "_Alarm"); - Alarm_M_S.Text = GetDataToString(dmName, "_AlarmM"); - Alarm_S_S.Text = GetDataToString(dmName, "_AlarmS"); - Alarm_T_S.Text = GetDataToString(dmName, "_AlarmT"); + ManualMode_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManualMode"); + AutoMode_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoMode"); + StartManual_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StartManual"); + StopManual_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StopManual"); + StartAuto_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StartAuto"); + StopAuto_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StopAuto"); + AlarmReset_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmReset"); + Running_M_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_RunningM"); + Running_S_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_RunningS"); + Running_T_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_RunningT"); + Run_M_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_RunM"); + Run_S_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_RunS"); + Run_T_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_RunT"); + Alarm_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm"); + Alarm_M_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmM"); + Alarm_S_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmS"); + Alarm_T_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmT"); } private void DmChange_FOR_MOTOR_VFD_SelectedIndexChanged(object sender, EventArgs e) @@ -153,25 +134,25 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach private void StateMonitor_FOR_MOTOR_VFD(string dmName) { - Auto_BT_VFD.Text = GetDataToString(dmName, "_AutoBT"); - Man_BT_VFD.Text = GetDataToString(dmName, "_ManBT"); - Start_A_VFD.Text = GetDataToString(dmName, "_StartA"); - Stop_A_VFD.Text = GetDataToString(dmName, "_StopA"); - Start_M_VFD.Text = GetDataToString(dmName, "_StartM"); - Stop_M_VFD.Text = GetDataToString(dmName, "_StopM"); - AlarmReset_VFD.Text = GetDataToString(dmName, "_AlarmReset"); - EXT_Estop_VFD.Text = GetDataToString(dmName, "_EXTEstop"); - AutoMode_VFD.Text = GetDataToString(dmName, "_AutoMode"); - ManMode_VFD.Text = GetDataToString(dmName, "_ManMode"); - VVVF_OK_VFD.Text = GetDataToString(dmName, "_VVVFOK"); - Running_VFD.Text = GetDataToString(dmName, "_Running"); - Alarm_VFD.Text = GetDataToString(dmName, "_Alarm"); - Error_VFD.Text = GetDataToString(dmName, "_Error"); - Enable_VFD.Text = GetDataToString(dmName, "_Enable"); - Polarity_VFD.Text = GetDataToString(dmName, "_Polarity"); - SetSpeed_A_VFD.Text = GetDataToString(dmName, "_SetSpeedA"); - SetSpeed_M_VFD.Text = GetDataToString(dmName, "_SetSpeedM"); - ACT_Speed_VFD.Text = GetDataToString(dmName, "_ACTSpeed"); + Auto_BT_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoBT"); + Man_BT_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManBT"); + Start_A_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StartA"); + Stop_A_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StopA"); + Start_M_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StartM"); + Stop_M_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StopM"); + AlarmReset_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmReset"); + EXT_Estop_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_EXTEstop"); + AutoMode_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoMode"); + ManMode_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManMode"); + VVVF_OK_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_VVVFOK"); + Running_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Running"); + Alarm_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm"); + Error_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Error"); + Enable_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Enable"); + Polarity_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Polarity"); + SetSpeed_A_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetSpeedA"); + SetSpeed_M_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetSpeedM"); + ACT_Speed_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ACTSpeed"); } private void Refresh_Click(object sender, EventArgs e) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/InstrumentDataStateMonitor/InstrumentDataStateMonitor.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/InstrumentDataStateMonitor/InstrumentDataStateMonitor.cs index 90b888f..1110d06 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/InstrumentDataStateMonitor/InstrumentDataStateMonitor.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/InstrumentDataStateMonitor/InstrumentDataStateMonitor.cs @@ -9,6 +9,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; + namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.InstrumentDataStateMonitor { public partial class InstrumentDataStateMonitor : Form @@ -24,25 +25,7 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.InstrumentData } - /// - /// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用 - /// - /// 数据块属性名 - /// - private DataKeyValue GetDataNameValue(string dmName, string dmValue) - { - return new DataKeyValue(dmName + dmValue); - } - - /// - /// 从PLC中读取值 - /// - /// 要读取的属性 - /// - private string GetDataToString(string dmName, string dmValue) - { - return GetDataNameValue(dmName, dmValue).NowValue.ToString(); - } + private void DmChange_3005_SelectedIndexChanged(object sender, EventArgs e) { @@ -64,18 +47,18 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.InstrumentData private void StateMonitor_3005(string dmName) { - Min_3005.Text = GetDataToString(dmName, "_Min"); - Max_3005.Text = GetDataToString(dmName, "_Max"); - Value_3005.Text = GetDataToString(dmName, "_Value"); - Alarm_3005.Text = GetDataToString(dmName, "_Alarm"); + Min_3005.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Min"); + Max_3005.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Max"); + Value_3005.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Value"); + Alarm_3005.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm"); } private void StateMonitor_3006(string dmName) { - Mlin_3006.Text = GetDataToString(dmName, "_Mlin"); - Max_3006.Text = GetDataToString(dmName, "_Max"); - SetValue_3006.Text = GetDataToString(dmName, "_SetValue"); - Alarm_3006.Text = GetDataToString(dmName, "_Alarm"); + Mlin_3006.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Mlin"); + Max_3006.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Max"); + SetValue_3006.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetValue"); + Alarm_3006.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm"); } private IDictionary dmNameValue = new Dictionary() diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/MotorInitStateMonitor/MotorInitStateMonitor.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/MotorInitStateMonitor/MotorInitStateMonitor.cs index 6b80104..3e65548 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/MotorInitStateMonitor/MotorInitStateMonitor.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/MotorInitStateMonitor/MotorInitStateMonitor.cs @@ -42,58 +42,40 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.MotorInitState StateMonitor_FOR_MOTOR_VFD(DmName_FOR_MOTOR_VFD); } - /// - /// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用 - /// - /// 数据块属性名 - /// - private DataKeyValue GetDataNameValue(string dmName, string dmValue) - { - return new DataKeyValue(dmName + dmValue); - } - - /// - /// 从PLC中读取值 - /// - /// 要读取的属性 - /// - private string GetDataToString(string dmName, string dmValue) - { - return GetDataNameValue(dmName, dmValue).NowValue.ToString(); - } + private void StateMonitor_FOR_MOTOR(String dmName) { - ManualMode.Text = GetDataToString(dmName, "_ManualMode"); - AutoMode.Text = GetDataToString(dmName, "_AutoMode"); - AlarmReset.Text = GetDataToString(dmName, "_AlarmReset"); - StartManual.Text = GetDataToString(dmName, "_StartManual"); - StopManual.Text = GetDataToString(dmName, "_StopManual"); - StartAuto.Text = GetDataToString(dmName, "_StartAuto"); - StopAuto.Text = GetDataToString(dmName, "_StopAuto"); - Running.Text = GetDataToString(dmName, "_Running"); - Run.Text = GetDataToString(dmName, "_Run"); - Alarm.Text = GetDataToString(dmName, "_Alarm"); + ManualMode.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManualMode"); + AutoMode.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoMode"); + AlarmReset.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmReset"); + StartManual.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StartManual"); + StopManual.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StopManual"); + StartAuto.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StartAuto"); + StopAuto.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StopAuto"); + Running.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Running"); + Run.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Run"); + Alarm.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm"); } private void StateMonitor_FOR_MOTOR_VFD(string dmName) { - AutoMode_VFD.Text = GetDataToString(dmName, "_AutoMode"); - ManMode_VFD.Text = GetDataToString(dmName, "_ManualMode"); - Start_A_VFD.Text = GetDataToString(dmName, "_Start_A"); - Stop_A_VFD.Text = GetDataToString(dmName, "_Stop_A"); - Start_M_VFD.Text = GetDataToString(dmName, "_Start_M"); - Stop_M_VFD.Text = GetDataToString(dmName, "_Stop_M"); - AlarmReset_VFD.Text = GetDataToString(dmName, "_AlarmReset"); - EXT_Estop_VFD.Text = GetDataToString(dmName, "_EXT_Estop"); - Running_VFD.Text = GetDataToString(dmName, "_Running"); - Alarm_VFD.Text = GetDataToString(dmName, "_Alarm"); - Error_VFD.Text = GetDataToString(dmName, "_Error"); - Enable_VFD.Text = GetDataToString(dmName, "_Enable"); - Polarity_VFD.Text = GetDataToString(dmName, "_Polarity"); - SetSpeed_A_VFD.Text = GetDataToString(dmName, "_SetSpeed_A"); - SetSpeed_M_VFD.Text = GetDataToString(dmName, "_SetSpeed_M"); - ACT_Speed_VFD.Text = GetDataToString(dmName, "_ACT_Speed"); + AutoMode_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoMode"); + ManMode_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManualMode"); + Start_A_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Start_A"); + Stop_A_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Stop_A"); + Start_M_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Start_M"); + Stop_M_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Stop_M"); + AlarmReset_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmReset"); + EXT_Estop_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_EXT_Estop"); + Running_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Running"); + Alarm_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm"); + Error_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Error"); + Enable_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Enable"); + Polarity_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Polarity"); + SetSpeed_A_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetSpeed_A"); + SetSpeed_M_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetSpeed_M"); + ACT_Speed_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ACT_Speed"); } private IDictionary dmNameValue = new Dictionary() diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ParametersWithPCStateMonitor/ParametersWithPCStateMonitor.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ParametersWithPCStateMonitor/ParametersWithPCStateMonitor.cs index 38df551..201fa73 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ParametersWithPCStateMonitor/ParametersWithPCStateMonitor.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ParametersWithPCStateMonitor/ParametersWithPCStateMonitor.cs @@ -26,25 +26,25 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ParametersWith private void StateMonitor_Pressure(string dmName) { - ActualValue.Text = GetDataToString(dmName, "_ActualValue"); - LowLimit.Text = GetDataToString(dmName, "_LowLimit"); - HighLimit.Text = GetDataToString(dmName, "_HighLimit"); - Alarm.Text = GetDataToString(dmName, "_Alarm"); + ActualValue.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ActualValue"); + LowLimit.Text = PlcCommunicationUtil.GetDataToString(dmName, "_LowLimit"); + HighLimit.Text = PlcCommunicationUtil.GetDataToString(dmName, "_HighLimit"); + Alarm.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm"); } private void StateMonitor_PID(string dmName) { - PV.Text = GetDataToString(dmName, "_PV"); - SV.Text = GetDataToString(dmName, "_SV"); + PV.Text = PlcCommunicationUtil.GetDataToString(dmName, "_PV"); + SV.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SV"); } private void StateMonitor_Weight(string dmName) { - ActWeight.Text = GetDataToString(dmName, "_ActWeight"); - HighWeight.Text = GetDataToString(dmName, "_HighWeight"); - LowWeight.Text = GetDataToString(dmName, "_LowWeight"); - HighLevel.Text = GetDataToString(dmName, "_HighLevel"); - LowLevel.Text = GetDataToString(dmName, "_LowLevel"); + ActWeight.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ActWeight"); + HighWeight.Text = PlcCommunicationUtil.GetDataToString(dmName, "_HighWeight"); + LowWeight.Text = PlcCommunicationUtil.GetDataToString(dmName, "_LowWeight"); + HighLevel.Text = PlcCommunicationUtil.GetDataToString(dmName, "_HighLevel"); + LowLevel.Text = PlcCommunicationUtil.GetDataToString(dmName, "_LowLevel"); } private void ListBox_DmChange_Pressure_SelectedIndexChanged(object sender, EventArgs e) @@ -125,25 +125,6 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ParametersWith }; - /// - /// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用 - /// - /// 数据块属性名 - /// - private DataKeyValue GetDataNameValue(string dmName, string dmValue) - { - return new DataKeyValue(dmName + dmValue); - } - - /// - /// 从PLC中读取值 - /// - /// 要读取的属性 - /// - private string GetDataToString(string dmName, string dmValue) - { - return GetDataNameValue(dmName, dmValue).NowValue.ToString(); - } private void ListBox_DmChange_PID_SelectedIndexChanged(object sender, EventArgs e) { diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ParametersWithPCStateMonitor/ParametersWithPCStateMonitor_Normal_HMI.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ParametersWithPCStateMonitor/ParametersWithPCStateMonitor_Normal_HMI.cs index 7249e4c..f79d7bb 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ParametersWithPCStateMonitor/ParametersWithPCStateMonitor_Normal_HMI.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ParametersWithPCStateMonitor/ParametersWithPCStateMonitor_Normal_HMI.cs @@ -21,76 +21,57 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.NewFolder1 StateMonitor_ControlSign(); } - /// - /// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用 - /// - /// 数据块属性名 - /// - private DataKeyValue GetDataNameValue(string dmValue) - { - return new DataKeyValue( dmValue); - } - - /// - /// 从PLC中读取值 - /// - /// 要读取的属性 - /// - private string GetDataToString(string dmValue) - { - return GetDataNameValue(dmValue).NowValue.ToString(); - } - + private void StateMonitor_NormalStatus() { - WatchDog.Text = GetDataToString("WatchDog"); - RecipeRun.Text = GetDataToString("RecipeRun"); - RecipePause.Text = GetDataToString("RecipePause"); - Ready.Text = GetDataToString("Ready"); - Alarm.Text = GetDataToString("Alarm"); - EMStop.Text = GetDataToString("EMStop"); - RdyRpt_V1.Text = GetDataToString("RdyRpt_V1"); - RdyRpt_V2.Text = GetDataToString("RdyRpt_V2"); - RdyRpt_V3.Text = GetDataToString("RdyRpt_V3"); - RdyRpt_V4.Text = GetDataToString("RdyRpt_V4"); - RdyRpt_V5.Text = GetDataToString("RdyRpt_V5"); - RdyRpt_W1.Text = GetDataToString("RdyRpt_W1"); - RdyRpt_W2.Text = GetDataToString("RdyRpt_W2"); - RdyRpt_W3.Text = GetDataToString("RdyRpt_W3"); - RdyRpt_W4.Text = GetDataToString("RdyRpt_W4"); - RdyRpt_D1.Text = GetDataToString("RdyRpt_D1"); - RdyRpt_D2.Text = GetDataToString("RdyRpt_D2"); - RdyRpt_D3.Text = GetDataToString("RdyRpt_D3"); - RdyRpt_D4.Text = GetDataToString("RdyRpt_D4"); - RdyRpt_G1.Text = GetDataToString("RdyRpt_G1"); - RdyRpt_G2.Text = GetDataToString("RdyRpt_G2"); - RdyRpt_G3.Text = GetDataToString("RdyRpt_G3"); - RdyRpt_G4.Text = GetDataToString("RdyRpt_G4"); - RdyRpt_G5.Text = GetDataToString("RdyRpt_G5"); - RdyRpt_G6.Text = GetDataToString("RdyRpt_G6"); - RdyRpt_G7.Text = GetDataToString("RdyRpt_G7"); - RdyRpt_G8.Text = GetDataToString("RdyRpt_G8"); - RdyRpt_M1.Text = GetDataToString("RdyRpt_M1"); - RdyRpt_M2.Text = GetDataToString("RdyRpt_M2"); - RdyRpt_M3.Text = GetDataToString("RdyRpt_M3"); - RdyRpt_M4.Text = GetDataToString("RdyRpt_M4"); - RdyRpt_M5.Text = GetDataToString("RdyRpt_M5"); - RdyRpt_M6.Text = GetDataToString("RdyRpt_M6"); - RdyRpt_M7.Text = GetDataToString("RdyRpt_M7"); - RdyRpt_M8.Text = GetDataToString("RdyRpt_M8"); + WatchDog.Text = PlcCommunicationUtil.GetDataToString("WatchDog"); + RecipeRun.Text = PlcCommunicationUtil.GetDataToString("RecipeRun"); + RecipePause.Text = PlcCommunicationUtil.GetDataToString("RecipePause"); + Ready.Text = PlcCommunicationUtil.GetDataToString("Ready"); + Alarm.Text = PlcCommunicationUtil.GetDataToString("Alarm"); + EMStop.Text = PlcCommunicationUtil.GetDataToString("EMStop"); + RdyRpt_V1.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_V1"); + RdyRpt_V2.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_V2"); + RdyRpt_V3.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_V3"); + RdyRpt_V4.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_V4"); + RdyRpt_V5.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_V5"); + RdyRpt_W1.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_W1"); + RdyRpt_W2.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_W2"); + RdyRpt_W3.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_W3"); + RdyRpt_W4.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_W4"); + RdyRpt_D1.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_D1"); + RdyRpt_D2.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_D2"); + RdyRpt_D3.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_D3"); + RdyRpt_D4.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_D4"); + RdyRpt_G1.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_G1"); + RdyRpt_G2.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_G2"); + RdyRpt_G3.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_G3"); + RdyRpt_G4.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_G4"); + RdyRpt_G5.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_G5"); + RdyRpt_G6.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_G6"); + RdyRpt_G7.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_G7"); + RdyRpt_G8.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_G8"); + RdyRpt_M1.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_M1"); + RdyRpt_M2.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_M2"); + RdyRpt_M3.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_M3"); + RdyRpt_M4.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_M4"); + RdyRpt_M5.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_M5"); + RdyRpt_M6.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_M6"); + RdyRpt_M7.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_M7"); + RdyRpt_M8.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_M8"); } private void StateMonitor_ControlSign() { - AutoMode.Text = GetDataToString("AutoMode"); - LocMode.Text = GetDataToString("LocMode"); - TestMode.Text = GetDataToString("TestMode"); - Start.Text = GetDataToString("Start"); - Pause.Text = GetDataToString("Pause"); - Stop.Text = GetDataToString("Stop"); - Reset.Text = GetDataToString("Reset"); - AlarmAck.Text = GetDataToString("AlarmAck"); - LampTest.Text = GetDataToString("LampTest"); + AutoMode.Text = PlcCommunicationUtil.GetDataToString("AutoMode"); + LocMode.Text = PlcCommunicationUtil.GetDataToString("LocMode"); + TestMode.Text = PlcCommunicationUtil.GetDataToString("TestMode"); + Start.Text = PlcCommunicationUtil.GetDataToString("Start"); + Pause.Text = PlcCommunicationUtil.GetDataToString("Pause"); + Stop.Text = PlcCommunicationUtil.GetDataToString("Stop"); + Reset.Text = PlcCommunicationUtil.GetDataToString("Reset"); + AlarmAck.Text = PlcCommunicationUtil.GetDataToString("AlarmAck"); + LampTest.Text = PlcCommunicationUtil.GetDataToString("LampTest"); } private void Refresh_Click(object sender, EventArgs e) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ParametersWithPCStateMonitor/ParametersWithPCStateMonitor_Para.Designer.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ParametersWithPCStateMonitor/ParametersWithPCStateMonitor_Para.Designer.cs index a0f75a6..9387c25 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ParametersWithPCStateMonitor/ParametersWithPCStateMonitor_Para.Designer.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ParametersWithPCStateMonitor/ParametersWithPCStateMonitor_Para.Designer.cs @@ -498,7 +498,7 @@ // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(310, 405); + this.ClientSize = new System.Drawing.Size(309, 405); this.Controls.Add(this.Refresh); this.Controls.Add(this.ListBox_UntiStatus_HMI); this.Controls.Add(this.ListBox_WeightPara); diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ParametersWithPCStateMonitor/ParametersWithPCStateMonitor_Para.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ParametersWithPCStateMonitor/ParametersWithPCStateMonitor_Para.cs index 39ca5d5..af8e2cc 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ParametersWithPCStateMonitor/ParametersWithPCStateMonitor_Para.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ParametersWithPCStateMonitor/ParametersWithPCStateMonitor_Para.cs @@ -10,6 +10,7 @@ using System.Text; using System.Threading.Tasks; using System.Windows.Forms; + namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ParametersWithPCStateMonitor { public partial class ParametersWithPCStateMonitor_Para : Form @@ -25,26 +26,26 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ParametersWith private void StateMonitor_Weight(string dmName) { - HighSpeed.Text = GetDataToString(dmName, "_HighSpeed"); - LowSpeed.Text = GetDataToString(dmName, "_LowSpeed"); - WeightSlow.Text = GetDataToString(dmName, "_WeightSlow"); - Precut.Text = GetDataToString(dmName, "_Precut"); - JogTime.Text = GetDataToString(dmName, "_JogTime"); + HighSpeed.Text = PlcCommunicationUtil.GetDataToString(dmName, "_HighSpeed"); + LowSpeed.Text = PlcCommunicationUtil.GetDataToString(dmName, "_LowSpeed"); + WeightSlow.Text = PlcCommunicationUtil.GetDataToString(dmName, "_WeightSlow"); + Precut.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Precut"); + JogTime.Text = PlcCommunicationUtil.GetDataToString(dmName, "_JogTime"); } private void StateMonitor_UntiStatus_HMI(string dmName) { - mode.Text = GetDataToString(dmName, "_mode"); - status.Text = GetDataToString(dmName, "_status"); - batch.Text = GetDataToString(dmName, "_batch"); - step.Text = GetDataToString(dmName, "_step"); - stepCode.Text = GetDataToString(dmName, "_stepCode"); - totalTime.Text = GetDataToString(dmName, "_totalTime"); - stepTime.Text = GetDataToString(dmName, "_stepTime"); - temperature.Text = GetDataToString(dmName, "_temperature"); - speed.Text = GetDataToString(dmName, "_speed"); - currnet.Text = GetDataToString(dmName, "_currnet"); - pressure.Text = GetDataToString(dmName, "_pressure"); + mode.Text = PlcCommunicationUtil.GetDataToString(dmName, "_mode"); + status.Text = PlcCommunicationUtil.GetDataToString(dmName, "_status"); + batch.Text = PlcCommunicationUtil.GetDataToString(dmName, "_batch"); + step.Text = PlcCommunicationUtil.GetDataToString(dmName, "_step"); + stepCode.Text = PlcCommunicationUtil.GetDataToString(dmName, "_stepCode"); + totalTime.Text = PlcCommunicationUtil.GetDataToString(dmName, "_totalTime"); + stepTime.Text = PlcCommunicationUtil.GetDataToString(dmName, "_stepTime"); + temperature.Text = PlcCommunicationUtil.GetDataToString(dmName, "_temperature"); + speed.Text = PlcCommunicationUtil.GetDataToString(dmName, "_speed"); + currnet.Text = PlcCommunicationUtil.GetDataToString(dmName, "_currnet"); + pressure.Text = PlcCommunicationUtil.GetDataToString(dmName, "_pressure"); } @@ -60,25 +61,7 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ParametersWith StateMonitor_UntiStatus_HMI(DmName_UntiStatus_HMI); } - /// - /// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用 - /// - /// 数据块属性名 - /// - private DataKeyValue GetDataNameValue(string dmName, string dmValue) - { - return new DataKeyValue(dmName + dmValue); - } - - /// - /// 从PLC中读取值 - /// - /// 要读取的属性 - /// - private string GetDataToString(string dmName, string dmValue) - { - return GetDataNameValue(dmName, dmValue).NowValue.ToString(); - } + private IDictionary dmNameValue = new Dictionary() { diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/PlcCommunicationUtil.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/PlcCommunicationUtil.cs index 84b1eaf..3e8c13e 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/PlcCommunicationUtil.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/PlcCommunicationUtil.cs @@ -13,60 +13,27 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode public class PlcCommunicationUtil { - string DmName; - BasePlcHelper Plc = BasePlcHelper.Instance; - - - - - /// - /// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用 - /// - /// 数据块属性名 - /// - private DataKeyValue GetDataNameValue(string dmValue) - { - return new DataKeyValue(dmValue); - } - /// /// 从PLC中读取值 /// /// 要读取的属性 /// - private int GetDataToInt(String dmValue) + public static string GetDataToString(string dmValue) { - return GetDataNameValue(dmValue).NowValue.ToInt(); + return new DataKeyValue(dmValue).NowValue.ToString(); } - /// - /// 向PLC中写入值 - /// - /// 要写入的属性 - /// 写入的值 - private void SetDataValue(String dmValue, int value) - { - Plc.PlcWriteByDataKey(GetDataNameValue(dmValue), new Object[] { value }); - } /// /// 从PLC中读取值 /// /// 要读取的属性 /// - private string GetDataToString(string dmName, string dmValue) + public static string GetDataToString(string dmName, string dmValue) { - return GetDataNameValue(dmName, dmValue).NowValue.ToString(); + return GetDataToString(dmName + dmValue); } - /// - /// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用 - /// - /// 数据块属性名 - /// - private DataKeyValue GetDataNameValue(string dmName, string dmValue) - { - return new DataKeyValue(dmName + dmValue); - } + } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ValveDataStateMonitor/ValveStateMonitor.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ValveDataStateMonitor/ValveStateMonitor.cs index 0794731..63ed2b1 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ValveDataStateMonitor/ValveStateMonitor.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ValveDataStateMonitor/ValveStateMonitor.cs @@ -35,19 +35,18 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ValveStateMoni private void StateMonitor_S(string dmName) { - ManualMode_S.Text = GetDataToString(dmName, "_ManualMode"); - AutoMode_S.Text = GetDataToString(dmName, "_AutoMode"); - SetManual_S.Text = GetDataToString(dmName, "_SetManual"); - SetAuto_S.Text = GetDataToString(dmName, "_SetAuto"); - AlarmReset_S.Text = GetDataToString(dmName, "_AlarmReset"); - SetPosition_S.Text = GetDataToString(dmName, "_SetPosition"); - UnSetPosition_S.Text = GetDataToString(dmName, "_UnSetPosition"); - Set_S.Text = GetDataToString(dmName, "_Set"); - AlarmSetPos_S.Text = GetDataToString(dmName, "_AlarmSetPos"); - AlarmUnSetPos_S.Text = GetDataToString(dmName, "_AlarmUnSetPos"); - AlarmPosition_S.Text = GetDataToString(dmName, "_AlarmPosition"); - Alarm_S.Text = GetDataToString(dmName, "_Alarm"); - + ManualMode_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManualMode"); + AutoMode_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoMode"); + SetManual_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetManual"); + SetAuto_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetAuto"); + AlarmReset_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmReset"); + SetPosition_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetPosition"); + UnSetPosition_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_UnSetPosition"); + Set_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Set"); + AlarmSetPos_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmSetPos"); + AlarmUnSetPos_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmUnSetPos"); + AlarmPosition_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmPosition"); + Alarm_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm"); } private void DmChange_D_SelectedIndexChanged(object sender, EventArgs e) @@ -58,21 +57,21 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ValveStateMoni private void StateMonitor_D(string dmName) { - ManualMode_D.Text = GetDataToString(dmName, "_ManualMode"); - AutoMode_D.Text = GetDataToString(dmName, "_AutoMode"); - SetLeftManual_D.Text = GetDataToString(dmName, "_SetLeftManual"); - SetRightManual_D.Text = GetDataToString(dmName, "_SetRightManual"); - SetLeftAuto_D.Text = GetDataToString(dmName, "_SetLeftAuto"); - SetRightAuto_D.Text = GetDataToString(dmName, "_SetRightAuto"); - AlarmReset_D.Text = GetDataToString(dmName, "_AlarmReset"); - LeftPosition_D.Text = GetDataToString(dmName, "_LeftPosition"); - RightPosition_D.Text = GetDataToString(dmName, "_RightPosition"); - SetLeft_D.Text = GetDataToString(dmName, "_SetLeft"); - SetRight_D.Text = GetDataToString(dmName, "_SetRight"); - AlarmLeftPosition_D.Text = GetDataToString(dmName, "_AlarmLeftPosition"); - AlarmRightPosition_D.Text = GetDataToString(dmName, "_AlarmRightPosition"); - AlarmPosition_D.Text = GetDataToString(dmName, "_AlarmPosition"); - Alarm_D.Text = GetDataToString(dmName, "_Alarm"); + ManualMode_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManualMode"); + AutoMode_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoMode"); + SetLeftManual_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetLeftManual"); + SetRightManual_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetRightManual"); + SetLeftAuto_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetLeftAuto"); + SetRightAuto_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetRightAuto"); + AlarmReset_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmReset"); + LeftPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_LeftPosition"); + RightPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_RightPosition"); + SetLeft_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetLeft"); + SetRight_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetRight"); + AlarmLeftPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmLeftPosition"); + AlarmRightPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmRightPosition"); + AlarmPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmPosition"); + Alarm_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm"); } @@ -157,27 +156,6 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ValveStateMoni ["磨粉系统旋转阀气密封电磁阀"] = "SV1GDS01" }; - - /// - /// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用 - /// - /// 数据块属性名 - /// - private DataKeyValue GetDataNameValue(string dmName, string dmValue) - { - return new DataKeyValue(dmName + dmValue); - } - - /// - /// 从PLC中读取值 - /// - /// 要读取的属性 - /// - private string GetDataToString(string dmName, string dmValue) - { - return GetDataNameValue(dmName, dmValue).NowValue.ToString(); - } - private void Refresh_Click(object sender, EventArgs e) { diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ValveInitStateMonitor/ValveInitStateMonitor.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ValveInitStateMonitor/ValveInitStateMonitor.cs index 449a7db..1c5f69e 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ValveInitStateMonitor/ValveInitStateMonitor.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/EngineeringDebuggingMode/ValveInitStateMonitor/ValveInitStateMonitor.cs @@ -31,19 +31,19 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.NewFolder1 private void StateMonitor_S(string dmName) { - ManualMode_S.Text = GetDataToString(dmName, "_ManualMode"); - AutoMode_S.Text = GetDataToString(dmName, "_AutoMode"); - AlarmReset_S.Text = GetDataToString(dmName, "_AlarmReset"); - SetManual_S.Text = GetDataToString(dmName, "_SetManual"); - SetAuto_S.Text = GetDataToString(dmName, "_SetAuto"); - SetPosition_S.Text = GetDataToString(dmName, "_SetPosition"); - UnSetPosition_S.Text = GetDataToString(dmName, "_UnSetPosition"); - Set_S.Text = GetDataToString(dmName, "_Set"); - AlarmSetPos_S.Text = GetDataToString(dmName, "_AlarmSetPos"); - AlarmUnSetPos_S.Text = GetDataToString(dmName, "_AlarmUnSetPos"); - AlarmPosition_S.Text = GetDataToString(dmName, "_AlarmPosition"); - Alarm_S.Text = GetDataToString(dmName, "_Alarm"); - P_S.Text = GetDataToString(dmName, "_P"); + ManualMode_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManualMode"); + AutoMode_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoMode"); + AlarmReset_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmReset"); + SetManual_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetManual"); + SetAuto_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetAuto"); + SetPosition_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetPosition"); + UnSetPosition_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_UnSetPosition"); + Set_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Set"); + AlarmSetPos_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmSetPos"); + AlarmUnSetPos_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmUnSetPos"); + AlarmPosition_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmPosition"); + Alarm_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm"); + P_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_P"); } private void DmChange_D_SelectedIndexChanged(object sender, EventArgs e) @@ -54,21 +54,21 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.NewFolder1 private void StateMonitor_D(string dmName) { - ManualMode_D.Text = GetDataToString(dmName, "_ManualMode"); - AutoMode_D.Text = GetDataToString(dmName, "_AutoMode"); - SetLeftManual_D.Text = GetDataToString(dmName, "_SetLeftManual"); - SetRightManual_D.Text = GetDataToString(dmName, "_SetRightManual"); - SetLeftAuto_D.Text = GetDataToString(dmName, "_SetLeftAuto"); - SetRightAuto_D.Text = GetDataToString(dmName, "_SetRightAuto"); - AlarmReset_D.Text = GetDataToString(dmName, "_AlarmReset"); - LeftPosition_D.Text = GetDataToString(dmName, "_LeftPosition"); - RightPosition_D.Text = GetDataToString(dmName, "_RightPosition"); - SetLeft_D.Text = GetDataToString(dmName, "_SetLeft"); - SetRight_D.Text = GetDataToString(dmName, "_SetRight"); - AlarmLeftPosition_D.Text = GetDataToString(dmName, "_AlarmLeftPosition"); - AlarmRightPosition_D.Text = GetDataToString(dmName, "_AlarmRightPosition"); - AlarmPosition_D.Text = GetDataToString(dmName, "_AlarmPosition"); - Alarm_D.Text = GetDataToString(dmName, "_Alarm"); + ManualMode_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManualMode"); + AutoMode_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoMode"); + SetLeftManual_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetLeftManual"); + SetRightManual_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetRightManual"); + SetLeftAuto_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetLeftAuto"); + SetRightAuto_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetRightAuto"); + AlarmReset_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmReset"); + LeftPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_LeftPosition"); + RightPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_RightPosition"); + SetLeft_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetLeft"); + SetRight_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetRight"); + AlarmLeftPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmLeftPosition"); + AlarmRightPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmRightPosition"); + AlarmPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmPosition"); + Alarm_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm"); } @@ -78,25 +78,7 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.NewFolder1 StateMonitor_S(DmName_S); } - /// - /// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用 - /// - /// 数据块属性名 - /// - private DataKeyValue GetDataNameValue(string dmName, string dmValue) - { - return new DataKeyValue(dmName + dmValue); - } - - /// - /// 从PLC中读取值 - /// - /// 要读取的属性 - /// - private string GetDataToString(string dmName, string dmValue) - { - return GetDataNameValue(dmName, dmValue).NowValue.ToString(); - } + private IDictionary dmNameValue = new Dictionary() { diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs index eb965e4..88fa10d 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs @@ -46,7 +46,7 @@ namespace Mesnac.Action.ChemicalWeighing.Test // dbHelper.CommandText = sql; - ParametersWithPCStateMonitor_Para Form = new ParametersWithPCStateMonitor_Para(); + ValveInitStateMonitor Form = new ValveInitStateMonitor(); Form.Show();