using Mesnac.Action.ChemicalWeighing.Entity; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace Mesnac.Action.ChemicalWeighing.EngineeringDebuggingMode.ElectronicMachinaryStateMonitor { public partial class ElectronicMachineryDataStateMonitor : Form { string DmName_FOR_MOTOR = "DM1GDP01"; string DmName_FOR_MOTOR_S = "DM1GDS06"; string DmName_FOR_MOTOR_VFD = "DM1DSM01"; public ElectronicMachineryDataStateMonitor() { InitializeComponent(); StateMonitor_FOR_MOTOR(DmName_FOR_MOTOR); StateMonitor_FOR_MOTOR_S(DmName_FOR_MOTOR_S); 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) { switch (DmChange_FOR_MOTOR.Text) { case "二级除尘器除尘风机": DmName_FOR_MOTOR = "DM1GDP01"; break; case "大A组除尘风机": DmName_FOR_MOTOR = "DM1ASIG01"; break; case "大仓B组除尘风机": DmName_FOR_MOTOR = "DM1BSIG01"; break; case "大仓C组除尘风机": DmName_FOR_MOTOR = "DM1CSIG01"; break; case "大仓D组除尘风机": DmName_FOR_MOTOR = "DM1DSIG01"; break; case "磨粉分析机电机": DmName_FOR_MOTOR = "DM1GDS01"; break; case "磨粉除尘风机电机": DmName_FOR_MOTOR = "DM1GDS02"; break; case "磨粉罗茨风机电机": DmName_FOR_MOTOR = "DM1GDS03"; break; case "磨粉皮带正转电机": DmName_FOR_MOTOR = "DM1GDS04"; break; case "磨粉皮带反转电机": DmName_FOR_MOTOR = "DM1GDS05"; break; } StateMonitor_FOR_MOTOR(DmName_FOR_MOTOR); } 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"); } 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"); } private void DmChange_FOR_MOTOR_VFD_SelectedIndexChanged(object sender, EventArgs e) { 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); } 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"); } private void Refresh_Click(object sender, EventArgs e) { StateMonitor_FOR_MOTOR(DmName_FOR_MOTOR); StateMonitor_FOR_MOTOR_S(DmName_FOR_MOTOR_S); StateMonitor_FOR_MOTOR_VFD(DmName_FOR_MOTOR_VFD); } } }