change - PlcCommunication代码优化

master
wangsr 1 year ago
parent 4c853034dd
commit 6ee566826c

@ -24,25 +24,6 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach
StateMonitor_FOR_MOTOR_VFD(DmName_FOR_MOTOR_VFD); StateMonitor_FOR_MOTOR_VFD(DmName_FOR_MOTOR_VFD);
} }
/// <summary>
/// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用
/// </summary>
/// <param name="dmValue">数据块属性名</param>
/// <returns></returns>
private DataKeyValue GetDataNameValue(string dmName, string dmValue)
{
return new DataKeyValue(dmName + dmValue);
}
/// <summary>
/// 从PLC中读取值
/// </summary>
/// <param name="dmValue">要读取的属性</param>
/// <returns></returns>
private string GetDataToString(string dmName, string dmValue)
{
return GetDataNameValue(dmName, dmValue).NowValue.ToString();
}
private void DmChange_FOR_MOTOR_SelectedIndexChanged(object sender, EventArgs e) 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) private void StateMonitor_FOR_MOTOR(String dmName)
{ {
ManualMode.Text = GetDataToString(dmName, "_ManualMode"); ManualMode.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManualMode");
AutoMode.Text = GetDataToString(dmName, "_AutoMode"); AutoMode.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoMode");
StartManual.Text = GetDataToString(dmName, "_StartManual"); StartManual.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StartManual");
StopManual.Text = GetDataToString(dmName, "_StopManual"); StopManual.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StopManual");
StartAuto.Text = GetDataToString(dmName, "_StartAuto"); StartAuto.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StartAuto");
StopAuto.Text = GetDataToString(dmName, "_StopAuto"); StopAuto.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StopAuto");
AlarmReset.Text = GetDataToString(dmName, "_AlarmReset"); AlarmReset.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmReset");
Running.Text = GetDataToString(dmName, "_Running"); Running.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Running");
Run.Text = GetDataToString(dmName, "_Run"); Run.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Run");
Alarm.Text = GetDataToString(dmName, "_Alarm"); Alarm.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm");
} }
private void DmChange_FOR_MOTOR_S_SelectedIndexChanged(object sender, EventArgs e) 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) private void StateMonitor_FOR_MOTOR_S(String dmName)
{ {
ManualMode_S.Text = GetDataToString(dmName, "_ManualMode"); ManualMode_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManualMode");
AutoMode_S.Text = GetDataToString(dmName, "_AutoMode"); AutoMode_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoMode");
StartManual_S.Text = GetDataToString(dmName, "_StartManual"); StartManual_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StartManual");
StopManual_S.Text = GetDataToString(dmName, "_StopManual"); StopManual_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StopManual");
StartAuto_S.Text = GetDataToString(dmName, "_StartAuto"); StartAuto_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StartAuto");
StopAuto_S.Text = GetDataToString(dmName, "_StopAuto"); StopAuto_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StopAuto");
AlarmReset_S.Text = GetDataToString(dmName, "_AlarmReset"); AlarmReset_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmReset");
Running_M_S.Text = GetDataToString(dmName, "_RunningM"); Running_M_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_RunningM");
Running_S_S.Text = GetDataToString(dmName, "_RunningS"); Running_S_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_RunningS");
Running_T_S.Text = GetDataToString(dmName, "_RunningT"); Running_T_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_RunningT");
Run_M_S.Text = GetDataToString(dmName, "_RunM"); Run_M_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_RunM");
Run_S_S.Text = GetDataToString(dmName, "_RunS"); Run_S_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_RunS");
Run_T_S.Text = GetDataToString(dmName, "_RunT"); Run_T_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_RunT");
Alarm_S.Text = GetDataToString(dmName, "_Alarm"); Alarm_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm");
Alarm_M_S.Text = GetDataToString(dmName, "_AlarmM"); Alarm_M_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmM");
Alarm_S_S.Text = GetDataToString(dmName, "_AlarmS"); Alarm_S_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmS");
Alarm_T_S.Text = GetDataToString(dmName, "_AlarmT"); Alarm_T_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmT");
} }
private void DmChange_FOR_MOTOR_VFD_SelectedIndexChanged(object sender, EventArgs e) 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) private void StateMonitor_FOR_MOTOR_VFD(string dmName)
{ {
Auto_BT_VFD.Text = GetDataToString(dmName, "_AutoBT"); Auto_BT_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoBT");
Man_BT_VFD.Text = GetDataToString(dmName, "_ManBT"); Man_BT_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManBT");
Start_A_VFD.Text = GetDataToString(dmName, "_StartA"); Start_A_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StartA");
Stop_A_VFD.Text = GetDataToString(dmName, "_StopA"); Stop_A_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StopA");
Start_M_VFD.Text = GetDataToString(dmName, "_StartM"); Start_M_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StartM");
Stop_M_VFD.Text = GetDataToString(dmName, "_StopM"); Stop_M_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StopM");
AlarmReset_VFD.Text = GetDataToString(dmName, "_AlarmReset"); AlarmReset_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmReset");
EXT_Estop_VFD.Text = GetDataToString(dmName, "_EXTEstop"); EXT_Estop_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_EXTEstop");
AutoMode_VFD.Text = GetDataToString(dmName, "_AutoMode"); AutoMode_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoMode");
ManMode_VFD.Text = GetDataToString(dmName, "_ManMode"); ManMode_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManMode");
VVVF_OK_VFD.Text = GetDataToString(dmName, "_VVVFOK"); VVVF_OK_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_VVVFOK");
Running_VFD.Text = GetDataToString(dmName, "_Running"); Running_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Running");
Alarm_VFD.Text = GetDataToString(dmName, "_Alarm"); Alarm_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm");
Error_VFD.Text = GetDataToString(dmName, "_Error"); Error_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Error");
Enable_VFD.Text = GetDataToString(dmName, "_Enable"); Enable_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Enable");
Polarity_VFD.Text = GetDataToString(dmName, "_Polarity"); Polarity_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Polarity");
SetSpeed_A_VFD.Text = GetDataToString(dmName, "_SetSpeedA"); SetSpeed_A_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetSpeedA");
SetSpeed_M_VFD.Text = GetDataToString(dmName, "_SetSpeedM"); SetSpeed_M_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetSpeedM");
ACT_Speed_VFD.Text = GetDataToString(dmName, "_ACTSpeed"); ACT_Speed_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ACTSpeed");
} }
private void Refresh_Click(object sender, EventArgs e) private void Refresh_Click(object sender, EventArgs e)

@ -9,6 +9,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.InstrumentDataStateMonitor namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.InstrumentDataStateMonitor
{ {
public partial class InstrumentDataStateMonitor : Form public partial class InstrumentDataStateMonitor : Form
@ -24,25 +25,7 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.InstrumentData
} }
/// <summary>
/// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用
/// </summary>
/// <param name="dmValue">数据块属性名</param>
/// <returns></returns>
private DataKeyValue GetDataNameValue(string dmName, string dmValue)
{
return new DataKeyValue(dmName + dmValue);
}
/// <summary>
/// 从PLC中读取值
/// </summary>
/// <param name="dmValue">要读取的属性</param>
/// <returns></returns>
private string GetDataToString(string dmName, string dmValue)
{
return GetDataNameValue(dmName, dmValue).NowValue.ToString();
}
private void DmChange_3005_SelectedIndexChanged(object sender, EventArgs e) 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) private void StateMonitor_3005(string dmName)
{ {
Min_3005.Text = GetDataToString(dmName, "_Min"); Min_3005.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Min");
Max_3005.Text = GetDataToString(dmName, "_Max"); Max_3005.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Max");
Value_3005.Text = GetDataToString(dmName, "_Value"); Value_3005.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Value");
Alarm_3005.Text = GetDataToString(dmName, "_Alarm"); Alarm_3005.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm");
} }
private void StateMonitor_3006(string dmName) private void StateMonitor_3006(string dmName)
{ {
Mlin_3006.Text = GetDataToString(dmName, "_Mlin"); Mlin_3006.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Mlin");
Max_3006.Text = GetDataToString(dmName, "_Max"); Max_3006.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Max");
SetValue_3006.Text = GetDataToString(dmName, "_SetValue"); SetValue_3006.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetValue");
Alarm_3006.Text = GetDataToString(dmName, "_Alarm"); Alarm_3006.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm");
} }
private IDictionary<string, string> dmNameValue = new Dictionary<string, string>() private IDictionary<string, string> dmNameValue = new Dictionary<string, string>()

@ -42,58 +42,40 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.MotorInitState
StateMonitor_FOR_MOTOR_VFD(DmName_FOR_MOTOR_VFD); StateMonitor_FOR_MOTOR_VFD(DmName_FOR_MOTOR_VFD);
} }
/// <summary>
/// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用
/// </summary>
/// <param name="dmValue">数据块属性名</param>
/// <returns></returns>
private DataKeyValue GetDataNameValue(string dmName, string dmValue)
{
return new DataKeyValue(dmName + dmValue);
}
/// <summary>
/// 从PLC中读取值
/// </summary>
/// <param name="dmValue">要读取的属性</param>
/// <returns></returns>
private string GetDataToString(string dmName, string dmValue)
{
return GetDataNameValue(dmName, dmValue).NowValue.ToString();
}
private void StateMonitor_FOR_MOTOR(String dmName) private void StateMonitor_FOR_MOTOR(String dmName)
{ {
ManualMode.Text = GetDataToString(dmName, "_ManualMode"); ManualMode.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManualMode");
AutoMode.Text = GetDataToString(dmName, "_AutoMode"); AutoMode.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoMode");
AlarmReset.Text = GetDataToString(dmName, "_AlarmReset"); AlarmReset.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmReset");
StartManual.Text = GetDataToString(dmName, "_StartManual"); StartManual.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StartManual");
StopManual.Text = GetDataToString(dmName, "_StopManual"); StopManual.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StopManual");
StartAuto.Text = GetDataToString(dmName, "_StartAuto"); StartAuto.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StartAuto");
StopAuto.Text = GetDataToString(dmName, "_StopAuto"); StopAuto.Text = PlcCommunicationUtil.GetDataToString(dmName, "_StopAuto");
Running.Text = GetDataToString(dmName, "_Running"); Running.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Running");
Run.Text = GetDataToString(dmName, "_Run"); Run.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Run");
Alarm.Text = GetDataToString(dmName, "_Alarm"); Alarm.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm");
} }
private void StateMonitor_FOR_MOTOR_VFD(string dmName) private void StateMonitor_FOR_MOTOR_VFD(string dmName)
{ {
AutoMode_VFD.Text = GetDataToString(dmName, "_AutoMode"); AutoMode_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoMode");
ManMode_VFD.Text = GetDataToString(dmName, "_ManualMode"); ManMode_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManualMode");
Start_A_VFD.Text = GetDataToString(dmName, "_Start_A"); Start_A_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Start_A");
Stop_A_VFD.Text = GetDataToString(dmName, "_Stop_A"); Stop_A_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Stop_A");
Start_M_VFD.Text = GetDataToString(dmName, "_Start_M"); Start_M_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Start_M");
Stop_M_VFD.Text = GetDataToString(dmName, "_Stop_M"); Stop_M_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Stop_M");
AlarmReset_VFD.Text = GetDataToString(dmName, "_AlarmReset"); AlarmReset_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmReset");
EXT_Estop_VFD.Text = GetDataToString(dmName, "_EXT_Estop"); EXT_Estop_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_EXT_Estop");
Running_VFD.Text = GetDataToString(dmName, "_Running"); Running_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Running");
Alarm_VFD.Text = GetDataToString(dmName, "_Alarm"); Alarm_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm");
Error_VFD.Text = GetDataToString(dmName, "_Error"); Error_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Error");
Enable_VFD.Text = GetDataToString(dmName, "_Enable"); Enable_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Enable");
Polarity_VFD.Text = GetDataToString(dmName, "_Polarity"); Polarity_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Polarity");
SetSpeed_A_VFD.Text = GetDataToString(dmName, "_SetSpeed_A"); SetSpeed_A_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetSpeed_A");
SetSpeed_M_VFD.Text = GetDataToString(dmName, "_SetSpeed_M"); SetSpeed_M_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetSpeed_M");
ACT_Speed_VFD.Text = GetDataToString(dmName, "_ACT_Speed"); ACT_Speed_VFD.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ACT_Speed");
} }
private IDictionary<string, string> dmNameValue = new Dictionary<string, string>() private IDictionary<string, string> dmNameValue = new Dictionary<string, string>()

@ -26,25 +26,25 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ParametersWith
private void StateMonitor_Pressure(string dmName) private void StateMonitor_Pressure(string dmName)
{ {
ActualValue.Text = GetDataToString(dmName, "_ActualValue"); ActualValue.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ActualValue");
LowLimit.Text = GetDataToString(dmName, "_LowLimit"); LowLimit.Text = PlcCommunicationUtil.GetDataToString(dmName, "_LowLimit");
HighLimit.Text = GetDataToString(dmName, "_HighLimit"); HighLimit.Text = PlcCommunicationUtil.GetDataToString(dmName, "_HighLimit");
Alarm.Text = GetDataToString(dmName, "_Alarm"); Alarm.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm");
} }
private void StateMonitor_PID(string dmName) private void StateMonitor_PID(string dmName)
{ {
PV.Text = GetDataToString(dmName, "_PV"); PV.Text = PlcCommunicationUtil.GetDataToString(dmName, "_PV");
SV.Text = GetDataToString(dmName, "_SV"); SV.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SV");
} }
private void StateMonitor_Weight(string dmName) private void StateMonitor_Weight(string dmName)
{ {
ActWeight.Text = GetDataToString(dmName, "_ActWeight"); ActWeight.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ActWeight");
HighWeight.Text = GetDataToString(dmName, "_HighWeight"); HighWeight.Text = PlcCommunicationUtil.GetDataToString(dmName, "_HighWeight");
LowWeight.Text = GetDataToString(dmName, "_LowWeight"); LowWeight.Text = PlcCommunicationUtil.GetDataToString(dmName, "_LowWeight");
HighLevel.Text = GetDataToString(dmName, "_HighLevel"); HighLevel.Text = PlcCommunicationUtil.GetDataToString(dmName, "_HighLevel");
LowLevel.Text = GetDataToString(dmName, "_LowLevel"); LowLevel.Text = PlcCommunicationUtil.GetDataToString(dmName, "_LowLevel");
} }
private void ListBox_DmChange_Pressure_SelectedIndexChanged(object sender, EventArgs e) private void ListBox_DmChange_Pressure_SelectedIndexChanged(object sender, EventArgs e)
@ -125,25 +125,6 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ParametersWith
}; };
/// <summary>
/// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用
/// </summary>
/// <param name="dmValue">数据块属性名</param>
/// <returns></returns>
private DataKeyValue GetDataNameValue(string dmName, string dmValue)
{
return new DataKeyValue(dmName + dmValue);
}
/// <summary>
/// 从PLC中读取值
/// </summary>
/// <param name="dmValue">要读取的属性</param>
/// <returns></returns>
private string GetDataToString(string dmName, string dmValue)
{
return GetDataNameValue(dmName, dmValue).NowValue.ToString();
}
private void ListBox_DmChange_PID_SelectedIndexChanged(object sender, EventArgs e) private void ListBox_DmChange_PID_SelectedIndexChanged(object sender, EventArgs e)
{ {

@ -21,76 +21,57 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.NewFolder1
StateMonitor_ControlSign(); StateMonitor_ControlSign();
} }
/// <summary>
/// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用
/// </summary>
/// <param name="dmValue">数据块属性名</param>
/// <returns></returns>
private DataKeyValue GetDataNameValue(string dmValue)
{
return new DataKeyValue( dmValue);
}
/// <summary>
/// 从PLC中读取值
/// </summary>
/// <param name="dmValue">要读取的属性</param>
/// <returns></returns>
private string GetDataToString(string dmValue)
{
return GetDataNameValue(dmValue).NowValue.ToString();
}
private void StateMonitor_NormalStatus() private void StateMonitor_NormalStatus()
{ {
WatchDog.Text = GetDataToString("WatchDog"); WatchDog.Text = PlcCommunicationUtil.GetDataToString("WatchDog");
RecipeRun.Text = GetDataToString("RecipeRun"); RecipeRun.Text = PlcCommunicationUtil.GetDataToString("RecipeRun");
RecipePause.Text = GetDataToString("RecipePause"); RecipePause.Text = PlcCommunicationUtil.GetDataToString("RecipePause");
Ready.Text = GetDataToString("Ready"); Ready.Text = PlcCommunicationUtil.GetDataToString("Ready");
Alarm.Text = GetDataToString("Alarm"); Alarm.Text = PlcCommunicationUtil.GetDataToString("Alarm");
EMStop.Text = GetDataToString("EMStop"); EMStop.Text = PlcCommunicationUtil.GetDataToString("EMStop");
RdyRpt_V1.Text = GetDataToString("RdyRpt_V1"); RdyRpt_V1.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_V1");
RdyRpt_V2.Text = GetDataToString("RdyRpt_V2"); RdyRpt_V2.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_V2");
RdyRpt_V3.Text = GetDataToString("RdyRpt_V3"); RdyRpt_V3.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_V3");
RdyRpt_V4.Text = GetDataToString("RdyRpt_V4"); RdyRpt_V4.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_V4");
RdyRpt_V5.Text = GetDataToString("RdyRpt_V5"); RdyRpt_V5.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_V5");
RdyRpt_W1.Text = GetDataToString("RdyRpt_W1"); RdyRpt_W1.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_W1");
RdyRpt_W2.Text = GetDataToString("RdyRpt_W2"); RdyRpt_W2.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_W2");
RdyRpt_W3.Text = GetDataToString("RdyRpt_W3"); RdyRpt_W3.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_W3");
RdyRpt_W4.Text = GetDataToString("RdyRpt_W4"); RdyRpt_W4.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_W4");
RdyRpt_D1.Text = GetDataToString("RdyRpt_D1"); RdyRpt_D1.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_D1");
RdyRpt_D2.Text = GetDataToString("RdyRpt_D2"); RdyRpt_D2.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_D2");
RdyRpt_D3.Text = GetDataToString("RdyRpt_D3"); RdyRpt_D3.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_D3");
RdyRpt_D4.Text = GetDataToString("RdyRpt_D4"); RdyRpt_D4.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_D4");
RdyRpt_G1.Text = GetDataToString("RdyRpt_G1"); RdyRpt_G1.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_G1");
RdyRpt_G2.Text = GetDataToString("RdyRpt_G2"); RdyRpt_G2.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_G2");
RdyRpt_G3.Text = GetDataToString("RdyRpt_G3"); RdyRpt_G3.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_G3");
RdyRpt_G4.Text = GetDataToString("RdyRpt_G4"); RdyRpt_G4.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_G4");
RdyRpt_G5.Text = GetDataToString("RdyRpt_G5"); RdyRpt_G5.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_G5");
RdyRpt_G6.Text = GetDataToString("RdyRpt_G6"); RdyRpt_G6.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_G6");
RdyRpt_G7.Text = GetDataToString("RdyRpt_G7"); RdyRpt_G7.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_G7");
RdyRpt_G8.Text = GetDataToString("RdyRpt_G8"); RdyRpt_G8.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_G8");
RdyRpt_M1.Text = GetDataToString("RdyRpt_M1"); RdyRpt_M1.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_M1");
RdyRpt_M2.Text = GetDataToString("RdyRpt_M2"); RdyRpt_M2.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_M2");
RdyRpt_M3.Text = GetDataToString("RdyRpt_M3"); RdyRpt_M3.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_M3");
RdyRpt_M4.Text = GetDataToString("RdyRpt_M4"); RdyRpt_M4.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_M4");
RdyRpt_M5.Text = GetDataToString("RdyRpt_M5"); RdyRpt_M5.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_M5");
RdyRpt_M6.Text = GetDataToString("RdyRpt_M6"); RdyRpt_M6.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_M6");
RdyRpt_M7.Text = GetDataToString("RdyRpt_M7"); RdyRpt_M7.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_M7");
RdyRpt_M8.Text = GetDataToString("RdyRpt_M8"); RdyRpt_M8.Text = PlcCommunicationUtil.GetDataToString("RdyRpt_M8");
} }
private void StateMonitor_ControlSign() private void StateMonitor_ControlSign()
{ {
AutoMode.Text = GetDataToString("AutoMode"); AutoMode.Text = PlcCommunicationUtil.GetDataToString("AutoMode");
LocMode.Text = GetDataToString("LocMode"); LocMode.Text = PlcCommunicationUtil.GetDataToString("LocMode");
TestMode.Text = GetDataToString("TestMode"); TestMode.Text = PlcCommunicationUtil.GetDataToString("TestMode");
Start.Text = GetDataToString("Start"); Start.Text = PlcCommunicationUtil.GetDataToString("Start");
Pause.Text = GetDataToString("Pause"); Pause.Text = PlcCommunicationUtil.GetDataToString("Pause");
Stop.Text = GetDataToString("Stop"); Stop.Text = PlcCommunicationUtil.GetDataToString("Stop");
Reset.Text = GetDataToString("Reset"); Reset.Text = PlcCommunicationUtil.GetDataToString("Reset");
AlarmAck.Text = GetDataToString("AlarmAck"); AlarmAck.Text = PlcCommunicationUtil.GetDataToString("AlarmAck");
LampTest.Text = GetDataToString("LampTest"); LampTest.Text = PlcCommunicationUtil.GetDataToString("LampTest");
} }
private void Refresh_Click(object sender, EventArgs e) private void Refresh_Click(object sender, EventArgs e)

@ -498,7 +498,7 @@
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 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.Refresh);
this.Controls.Add(this.ListBox_UntiStatus_HMI); this.Controls.Add(this.ListBox_UntiStatus_HMI);
this.Controls.Add(this.ListBox_WeightPara); this.Controls.Add(this.ListBox_WeightPara);

@ -10,6 +10,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ParametersWithPCStateMonitor namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ParametersWithPCStateMonitor
{ {
public partial class ParametersWithPCStateMonitor_Para : Form public partial class ParametersWithPCStateMonitor_Para : Form
@ -25,26 +26,26 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ParametersWith
private void StateMonitor_Weight(string dmName) private void StateMonitor_Weight(string dmName)
{ {
HighSpeed.Text = GetDataToString(dmName, "_HighSpeed"); HighSpeed.Text = PlcCommunicationUtil.GetDataToString(dmName, "_HighSpeed");
LowSpeed.Text = GetDataToString(dmName, "_LowSpeed"); LowSpeed.Text = PlcCommunicationUtil.GetDataToString(dmName, "_LowSpeed");
WeightSlow.Text = GetDataToString(dmName, "_WeightSlow"); WeightSlow.Text = PlcCommunicationUtil.GetDataToString(dmName, "_WeightSlow");
Precut.Text = GetDataToString(dmName, "_Precut"); Precut.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Precut");
JogTime.Text = GetDataToString(dmName, "_JogTime"); JogTime.Text = PlcCommunicationUtil.GetDataToString(dmName, "_JogTime");
} }
private void StateMonitor_UntiStatus_HMI(string dmName) private void StateMonitor_UntiStatus_HMI(string dmName)
{ {
mode.Text = GetDataToString(dmName, "_mode"); mode.Text = PlcCommunicationUtil.GetDataToString(dmName, "_mode");
status.Text = GetDataToString(dmName, "_status"); status.Text = PlcCommunicationUtil.GetDataToString(dmName, "_status");
batch.Text = GetDataToString(dmName, "_batch"); batch.Text = PlcCommunicationUtil.GetDataToString(dmName, "_batch");
step.Text = GetDataToString(dmName, "_step"); step.Text = PlcCommunicationUtil.GetDataToString(dmName, "_step");
stepCode.Text = GetDataToString(dmName, "_stepCode"); stepCode.Text = PlcCommunicationUtil.GetDataToString(dmName, "_stepCode");
totalTime.Text = GetDataToString(dmName, "_totalTime"); totalTime.Text = PlcCommunicationUtil.GetDataToString(dmName, "_totalTime");
stepTime.Text = GetDataToString(dmName, "_stepTime"); stepTime.Text = PlcCommunicationUtil.GetDataToString(dmName, "_stepTime");
temperature.Text = GetDataToString(dmName, "_temperature"); temperature.Text = PlcCommunicationUtil.GetDataToString(dmName, "_temperature");
speed.Text = GetDataToString(dmName, "_speed"); speed.Text = PlcCommunicationUtil.GetDataToString(dmName, "_speed");
currnet.Text = GetDataToString(dmName, "_currnet"); currnet.Text = PlcCommunicationUtil.GetDataToString(dmName, "_currnet");
pressure.Text = GetDataToString(dmName, "_pressure"); pressure.Text = PlcCommunicationUtil.GetDataToString(dmName, "_pressure");
} }
@ -60,25 +61,7 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ParametersWith
StateMonitor_UntiStatus_HMI(DmName_UntiStatus_HMI); StateMonitor_UntiStatus_HMI(DmName_UntiStatus_HMI);
} }
/// <summary>
/// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用
/// </summary>
/// <param name="dmValue">数据块属性名</param>
/// <returns></returns>
private DataKeyValue GetDataNameValue(string dmName, string dmValue)
{
return new DataKeyValue(dmName + dmValue);
}
/// <summary>
/// 从PLC中读取值
/// </summary>
/// <param name="dmValue">要读取的属性</param>
/// <returns></returns>
private string GetDataToString(string dmName, string dmValue)
{
return GetDataNameValue(dmName, dmValue).NowValue.ToString();
}
private IDictionary<string, string> dmNameValue = new Dictionary<string, string>() private IDictionary<string, string> dmNameValue = new Dictionary<string, string>()
{ {

@ -13,60 +13,27 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode
public class PlcCommunicationUtil public class PlcCommunicationUtil
{ {
string DmName;
BasePlcHelper Plc = BasePlcHelper.Instance;
/// <summary>
/// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用
/// </summary>
/// <param name="dmValue">数据块属性名</param>
/// <returns></returns>
private DataKeyValue GetDataNameValue(string dmValue)
{
return new DataKeyValue(dmValue);
}
/// <summary> /// <summary>
/// 从PLC中读取值 /// 从PLC中读取值
/// </summary> /// </summary>
/// <param name="dmValue">要读取的属性</param> /// <param name="dmValue">要读取的属性</param>
/// <returns></returns> /// <returns></returns>
private int GetDataToInt(String dmValue) public static string GetDataToString(string dmValue)
{ {
return GetDataNameValue(dmValue).NowValue.ToInt(); return new DataKeyValue(dmValue).NowValue.ToString();
} }
/// <summary>
/// 向PLC中写入值
/// </summary>
/// <param name="dmValue">要写入的属性</param>
/// <param name="value">写入的值</param>
private void SetDataValue(String dmValue, int value)
{
Plc.PlcWriteByDataKey(GetDataNameValue(dmValue), new Object[] { value });
}
/// <summary> /// <summary>
/// 从PLC中读取值 /// 从PLC中读取值
/// </summary> /// </summary>
/// <param name="dmValue">要读取的属性</param> /// <param name="dmValue">要读取的属性</param>
/// <returns></returns> /// <returns></returns>
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);
} }
/// <summary>
/// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用
/// </summary>
/// <param name="dmValue">数据块属性名</param>
/// <returns></returns>
private DataKeyValue GetDataNameValue(string dmName, string dmValue)
{
return new DataKeyValue(dmName + dmValue);
}
} }
} }

@ -35,19 +35,18 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ValveStateMoni
private void StateMonitor_S(string dmName) private void StateMonitor_S(string dmName)
{ {
ManualMode_S.Text = GetDataToString(dmName, "_ManualMode"); ManualMode_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManualMode");
AutoMode_S.Text = GetDataToString(dmName, "_AutoMode"); AutoMode_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoMode");
SetManual_S.Text = GetDataToString(dmName, "_SetManual"); SetManual_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetManual");
SetAuto_S.Text = GetDataToString(dmName, "_SetAuto"); SetAuto_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetAuto");
AlarmReset_S.Text = GetDataToString(dmName, "_AlarmReset"); AlarmReset_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmReset");
SetPosition_S.Text = GetDataToString(dmName, "_SetPosition"); SetPosition_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetPosition");
UnSetPosition_S.Text = GetDataToString(dmName, "_UnSetPosition"); UnSetPosition_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_UnSetPosition");
Set_S.Text = GetDataToString(dmName, "_Set"); Set_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Set");
AlarmSetPos_S.Text = GetDataToString(dmName, "_AlarmSetPos"); AlarmSetPos_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmSetPos");
AlarmUnSetPos_S.Text = GetDataToString(dmName, "_AlarmUnSetPos"); AlarmUnSetPos_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmUnSetPos");
AlarmPosition_S.Text = GetDataToString(dmName, "_AlarmPosition"); AlarmPosition_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmPosition");
Alarm_S.Text = GetDataToString(dmName, "_Alarm"); Alarm_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm");
} }
private void DmChange_D_SelectedIndexChanged(object sender, EventArgs e) 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) private void StateMonitor_D(string dmName)
{ {
ManualMode_D.Text = GetDataToString(dmName, "_ManualMode"); ManualMode_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManualMode");
AutoMode_D.Text = GetDataToString(dmName, "_AutoMode"); AutoMode_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoMode");
SetLeftManual_D.Text = GetDataToString(dmName, "_SetLeftManual"); SetLeftManual_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetLeftManual");
SetRightManual_D.Text = GetDataToString(dmName, "_SetRightManual"); SetRightManual_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetRightManual");
SetLeftAuto_D.Text = GetDataToString(dmName, "_SetLeftAuto"); SetLeftAuto_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetLeftAuto");
SetRightAuto_D.Text = GetDataToString(dmName, "_SetRightAuto"); SetRightAuto_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetRightAuto");
AlarmReset_D.Text = GetDataToString(dmName, "_AlarmReset"); AlarmReset_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmReset");
LeftPosition_D.Text = GetDataToString(dmName, "_LeftPosition"); LeftPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_LeftPosition");
RightPosition_D.Text = GetDataToString(dmName, "_RightPosition"); RightPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_RightPosition");
SetLeft_D.Text = GetDataToString(dmName, "_SetLeft"); SetLeft_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetLeft");
SetRight_D.Text = GetDataToString(dmName, "_SetRight"); SetRight_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetRight");
AlarmLeftPosition_D.Text = GetDataToString(dmName, "_AlarmLeftPosition"); AlarmLeftPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmLeftPosition");
AlarmRightPosition_D.Text = GetDataToString(dmName, "_AlarmRightPosition"); AlarmRightPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmRightPosition");
AlarmPosition_D.Text = GetDataToString(dmName, "_AlarmPosition"); AlarmPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmPosition");
Alarm_D.Text = GetDataToString(dmName, "_Alarm"); Alarm_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm");
} }
@ -158,27 +157,6 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ValveStateMoni
}; };
/// <summary>
/// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用
/// </summary>
/// <param name="dmValue">数据块属性名</param>
/// <returns></returns>
private DataKeyValue GetDataNameValue(string dmName, string dmValue)
{
return new DataKeyValue(dmName + dmValue);
}
/// <summary>
/// 从PLC中读取值
/// </summary>
/// <param name="dmValue">要读取的属性</param>
/// <returns></returns>
private string GetDataToString(string dmName, string dmValue)
{
return GetDataNameValue(dmName, dmValue).NowValue.ToString();
}
private void Refresh_Click(object sender, EventArgs e) private void Refresh_Click(object sender, EventArgs e)
{ {
StateMonitor_D(DmName_D); StateMonitor_D(DmName_D);

@ -31,19 +31,19 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.NewFolder1
private void StateMonitor_S(string dmName) private void StateMonitor_S(string dmName)
{ {
ManualMode_S.Text = GetDataToString(dmName, "_ManualMode"); ManualMode_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManualMode");
AutoMode_S.Text = GetDataToString(dmName, "_AutoMode"); AutoMode_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoMode");
AlarmReset_S.Text = GetDataToString(dmName, "_AlarmReset"); AlarmReset_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmReset");
SetManual_S.Text = GetDataToString(dmName, "_SetManual"); SetManual_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetManual");
SetAuto_S.Text = GetDataToString(dmName, "_SetAuto"); SetAuto_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetAuto");
SetPosition_S.Text = GetDataToString(dmName, "_SetPosition"); SetPosition_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetPosition");
UnSetPosition_S.Text = GetDataToString(dmName, "_UnSetPosition"); UnSetPosition_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_UnSetPosition");
Set_S.Text = GetDataToString(dmName, "_Set"); Set_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Set");
AlarmSetPos_S.Text = GetDataToString(dmName, "_AlarmSetPos"); AlarmSetPos_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmSetPos");
AlarmUnSetPos_S.Text = GetDataToString(dmName, "_AlarmUnSetPos"); AlarmUnSetPos_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmUnSetPos");
AlarmPosition_S.Text = GetDataToString(dmName, "_AlarmPosition"); AlarmPosition_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmPosition");
Alarm_S.Text = GetDataToString(dmName, "_Alarm"); Alarm_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm");
P_S.Text = GetDataToString(dmName, "_P"); P_S.Text = PlcCommunicationUtil.GetDataToString(dmName, "_P");
} }
private void DmChange_D_SelectedIndexChanged(object sender, EventArgs e) 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) private void StateMonitor_D(string dmName)
{ {
ManualMode_D.Text = GetDataToString(dmName, "_ManualMode"); ManualMode_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_ManualMode");
AutoMode_D.Text = GetDataToString(dmName, "_AutoMode"); AutoMode_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AutoMode");
SetLeftManual_D.Text = GetDataToString(dmName, "_SetLeftManual"); SetLeftManual_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetLeftManual");
SetRightManual_D.Text = GetDataToString(dmName, "_SetRightManual"); SetRightManual_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetRightManual");
SetLeftAuto_D.Text = GetDataToString(dmName, "_SetLeftAuto"); SetLeftAuto_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetLeftAuto");
SetRightAuto_D.Text = GetDataToString(dmName, "_SetRightAuto"); SetRightAuto_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetRightAuto");
AlarmReset_D.Text = GetDataToString(dmName, "_AlarmReset"); AlarmReset_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmReset");
LeftPosition_D.Text = GetDataToString(dmName, "_LeftPosition"); LeftPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_LeftPosition");
RightPosition_D.Text = GetDataToString(dmName, "_RightPosition"); RightPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_RightPosition");
SetLeft_D.Text = GetDataToString(dmName, "_SetLeft"); SetLeft_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetLeft");
SetRight_D.Text = GetDataToString(dmName, "_SetRight"); SetRight_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_SetRight");
AlarmLeftPosition_D.Text = GetDataToString(dmName, "_AlarmLeftPosition"); AlarmLeftPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmLeftPosition");
AlarmRightPosition_D.Text = GetDataToString(dmName, "_AlarmRightPosition"); AlarmRightPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmRightPosition");
AlarmPosition_D.Text = GetDataToString(dmName, "_AlarmPosition"); AlarmPosition_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_AlarmPosition");
Alarm_D.Text = GetDataToString(dmName, "_Alarm"); Alarm_D.Text = PlcCommunicationUtil.GetDataToString(dmName, "_Alarm");
} }
@ -78,25 +78,7 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.NewFolder1
StateMonitor_S(DmName_S); StateMonitor_S(DmName_S);
} }
/// <summary>
/// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用
/// </summary>
/// <param name="dmValue">数据块属性名</param>
/// <returns></returns>
private DataKeyValue GetDataNameValue(string dmName, string dmValue)
{
return new DataKeyValue(dmName + dmValue);
}
/// <summary>
/// 从PLC中读取值
/// </summary>
/// <param name="dmValue">要读取的属性</param>
/// <returns></returns>
private string GetDataToString(string dmName, string dmValue)
{
return GetDataNameValue(dmName, dmValue).NowValue.ToString();
}
private IDictionary<string, string> dmNameValue = new Dictionary<string, string>() private IDictionary<string, string> dmNameValue = new Dictionary<string, string>()
{ {

@ -46,7 +46,7 @@ namespace Mesnac.Action.ChemicalWeighing.Test
// dbHelper.CommandText = sql; // dbHelper.CommandText = sql;
ParametersWithPCStateMonitor_Para Form = new ParametersWithPCStateMonitor_Para(); ValveInitStateMonitor Form = new ValveInitStateMonitor();
Form.Show(); Form.Show();

Loading…
Cancel
Save