add - 电机数据块状态检测 - 待添加Timer

master
wangsr 1 year ago
parent c298569b3f
commit fa6c6e84bc

@ -156,7 +156,7 @@
this.DmChange.SelectedIndexChanged += new System.EventHandler(this.DmChange_SelectedIndexChanged);
this.DmChange.Items.AddRange(new object[] {
"磨粉主机电机",
"磨粉风机电机",
"磨粉风机电机"
});
//
// ElectronicMachinery_2

@ -13,13 +13,36 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach
{
public partial class ElectronicMachineryStateMonitor : Form
{
string DmName_FOR_MOTOR = "DM1GDP01";
string DmName_FOR_MOTOR = "DM1GDP01";
string DmName_FOR_MOTOR_S = "DM1GDS06";
string DmName_FOR_MOTOR_VFD = "DM1DSM01";
public ElectronicMachineryStateMonitor()
{
InitializeComponent();
StateMonitor_FOR_MOTOR(DmName_FOR_MOTOR);
StateMonitor_FOR_MOTOR_S(DmName_FOR_MOTOR_S);
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)
{
switch (DmChange_FOR_MOTOR.Text)
@ -72,54 +95,82 @@ namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMach
Alarm.Text = GetDataToString(dmName, "_Alarm");
}
private void DmChange_FOR_MOTOR_S_SelectedIndexChanged(object sender, EventArgs e)
{
switch (DmChange_FOR_MOTOR_S.Text)
{
case "磨粉主机电机":
DmName_FOR_MOTOR_S = "DM1GDS06";
break;
case "磨粉风机电机":
DmName_FOR_MOTOR_S = "DM1GDS07";
break;
}
StateMonitor_FOR_MOTOR_S(DmName_FOR_MOTOR_S);
}
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");
}
/// <summary>
/// 根据属性名和现在选择的数据块名得到PLC数据块的具体引用
/// </summary>
/// <param name="dmValue">数据块属性名</param>
/// <returns></returns>
private DataKeyValue GetDataNameValue(string dmName, string dmValue)
private void DmChange_FOR_MOTOR_VFD_SelectedIndexChanged(object sender, EventArgs e)
{
return new DataKeyValue(dmName + dmValue);
switch (DmChange_FOR_MOTOR_VFD.Text)
{
case "筛分机A电机":
DmName_FOR_MOTOR_VFD = "DM1DSM01";
break;
case "筛分机B电机":
DmName_FOR_MOTOR_VFD = "DM2DSM01";
break;
case "筛分机C电机":
DmName_FOR_MOTOR_VFD = "DM3DSM01";
break;
case "磨粉旋转阀电机":
DmName_FOR_MOTOR_VFD = "DM1GDS12";
break;
}
StateMonitor_FOR_MOTOR_VFD(DmName_FOR_MOTOR_VFD);
}
/// <summary>
/// 从PLC中读取值
/// </summary>
/// <param name="dmValue">要读取的属性</param>
/// <returns></returns>
private string GetDataToString(string dmName, string dmValue)
private void StateMonitor_FOR_MOTOR_VFD(string dmName)
{
return GetDataNameValue(dmName ,dmValue).NowValue.ToString();
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");
}
}
}

Loading…
Cancel
Save