sc 1 year ago
parent
commit
001b2ff686
  1. 18
      Properties/Resources.Designer.cs
  2. 6
      Properties/Resources.resx
  3. 3
      View/TechnologicalProcessView.xaml.cs
  4. 87
      ViewModel/MainWindowViewModel.cs

18
Properties/Resources.Designer.cs

@ -465,6 +465,15 @@ namespace DyeingComputer.Properties {
} }
} }
/// <summary>
/// 查找类似 Malfunction 的本地化字符串。
/// </summary>
public static string Malfunction {
get {
return ResourceManager.GetString("Malfunction", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 Measure 的本地化字符串。 /// 查找类似 Measure 的本地化字符串。
/// </summary> /// </summary>
@ -834,6 +843,15 @@ namespace DyeingComputer.Properties {
} }
} }
/// <summary>
/// 查找类似 Sensor 的本地化字符串。
/// </summary>
public static string Sensor {
get {
return ResourceManager.GetString("Sensor", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 StartTime 的本地化字符串。 /// 查找类似 StartTime 的本地化字符串。
/// </summary> /// </summary>

6
Properties/Resources.resx

@ -429,4 +429,10 @@
<data name="Heat insulating" xml:space="preserve"> <data name="Heat insulating" xml:space="preserve">
<value>Heat insulating</value> <value>Heat insulating</value>
</data> </data>
<data name="Malfunction" xml:space="preserve">
<value>Malfunction</value>
</data>
<data name="Sensor" xml:space="preserve">
<value>Sensor</value>
</data>
</root> </root>

3
View/TechnologicalProcessView.xaml.cs

@ -99,6 +99,8 @@ namespace DyeingComputer.View
} }
private void UserControl_KeyDown(object sender, KeyEventArgs e) //键盘监控 private void UserControl_KeyDown(object sender, KeyEventArgs e) //键盘监控
{
if (string.IsNullOrEmpty(MainWindowViewModel.Name_err.ToString()))//无错误信息
{ {
if ((MainWindowViewModel.WORK_RUN == 1) || (MainWindowViewModel.WORK_RUN == 0))//停止暂停时可以启用开始 if ((MainWindowViewModel.WORK_RUN == 1) || (MainWindowViewModel.WORK_RUN == 0))//停止暂停时可以启用开始
{ {
@ -110,6 +112,7 @@ namespace DyeingComputer.View
} }
} }
} }
}
private void ProgramgroupView_edit_Click(object sender, RoutedEventArgs e)//编辑按钮 private void ProgramgroupView_edit_Click(object sender, RoutedEventArgs e)//编辑按钮
{ {

87
ViewModel/MainWindowViewModel.cs

@ -152,7 +152,7 @@ namespace DyeingComputer.ViewModel
disTimer.Start();//计时开始 disTimer.Start();//计时开始
}//时间周期初始化 }//时间周期初始化
public static object Name_err; public static object Name_err = "";
public static object WorkNumder; public static object WorkNumder;
public static object Process_step; public static object Process_step;
public static Int32 DIDETime; //空闲计时器 public static Int32 DIDETime; //空闲计时器
@ -163,23 +163,25 @@ namespace DyeingComputer.ViewModel
Work_Numder = WorkNumder.ToString(); Work_Numder = WorkNumder.ToString();
if (LINK_OK) Modbus_link(); if (LINK_OK) Modbus_link();
DIDETime++; DIDETime++;
STEP_RUN(); STEP_RUN();
IO_data(); IO_data();
if (!string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Name_err.ToString();
} }
void Tick_Event_5S(object sender, EventArgs e)//Tick_Event周期执行事件5S void Tick_Event_5S(object sender, EventArgs e)//Tick_Event周期执行事件5S
{ {
if (!LINK_OK) Modbus_link(); if (!LINK_OK) Modbus_link();
if (Name_err != null) Status_Str = Name_err.ToString();
if (string.IsNullOrEmpty(Name_err.ToString()) && ((Selet_dtm("1010") < 10) || (Selet_dtm("1010") > 160)))
{ Status_Str = Resources.Temperature + Resources.Sensor + Resources.Malfunction; } //温度故障提示
} }
void DisTimer_100MS(object sender, EventArgs e)//Tick_Event周期执行事件100MS void DisTimer_100MS(object sender, EventArgs e)//Tick_Event周期执行事件100MS
{ {
} }
public static int WORK_RUN = 0; //运行状态0停止1暂停2运行 public static int WORK_RUN = 0; //运行状态0停止1暂停2运行
private static string STEP_ID = "0"; private static string STEP_ID = "0";
private static double STEP_P1 = 0; private static double STEP_P1 = 0;
@ -195,8 +197,9 @@ namespace DyeingComputer.ViewModel
public static void STEP_START(string ID,double P1,double P2,double P3,double P4,double P5) public static void STEP_START(string ID,double P1,double P2,double P3,double P4,double P5)
{ {
if (ID == "001") switch (STEP_ID)
{ {
case "001":
STEP_ID = "001"; STEP_ID = "001";
STEP_P1 = Convert.ToDouble(P1); STEP_P1 = Convert.ToDouble(P1);
STEP_P2 = Convert.ToDouble(P2); STEP_P2 = Convert.ToDouble(P2);
@ -211,19 +214,43 @@ namespace DyeingComputer.ViewModel
STEP_TIME = Convert.ToInt16(STEP_P3) * 60; STEP_TIME = Convert.ToInt16(STEP_P3) * 60;
WORK_RUN = 2; WORK_RUN = 2;
SETP_runtime = true; SETP_runtime = true;
break;
case "007":
break;
case "009":
break;
case "013":
break;
case "015":
break;
case "017":
break;
case "020":
break;
case "022":
break;
default:
break;
} }
} }
TimeSpan ts=new TimeSpan(1);//1秒间隔 TimeSpan ts=new TimeSpan(1);//1秒间隔
void STEP_RUN() void STEP_RUN()
{ {
if (WORK_RUN == 2) if (WORK_RUN == 2)
{ {
if (SETP_runtime) if (SETP_runtime)
{ {
if (STEP_ID == "001") switch (STEP_ID)
{ {
case "001": //功能模块001温度控制
int TIME_H; int TIME_H;
int TIME_M; int TIME_M;
int TIME_S; int TIME_S;
@ -239,7 +266,7 @@ namespace DyeingComputer.ViewModel
TIME_H = STEP_TIME / 3600; TIME_H = STEP_TIME / 3600;
TIME_M = (STEP_TIME - TIME_H * 3600) / 60; TIME_M = (STEP_TIME - TIME_H * 3600) / 60;
TIME_S = STEP_TIME - TIME_H * 3600 - TIME_M * 60; TIME_S = STEP_TIME - TIME_H * 3600 - TIME_M * 60;
Status_Str = Resources.Heat_insulating+":" + Resources.Time + string.Format(" {0:D2}", TIME_H) + ":" + string.Format(" {0:D2}", TIME_M) + ":" + string.Format(" {0:D2}", TIME_S); Status_Str = Resources.Heat_insulating + ":" + Resources.Time + string.Format(" {0:D2}", TIME_H) + ":" + string.Format(" {0:D2}", TIME_M) + ":" + string.Format(" {0:D2}", TIME_S);
} }
else if (THL_mode == 1)//升温 else if (THL_mode == 1)//升温
{ {
@ -253,9 +280,9 @@ namespace DyeingComputer.ViewModel
} }
else else
{ {
TIME_M = Convert.ToInt16( (STEP_P1 - T) / (STEP_P2/10)); TIME_M = Convert.ToInt16((STEP_P1 - T) / (STEP_P2 / 10));
} }
Status_Str = Resources.Heats + ":" + Resources.Target + Resources.Temperature + string.Format(" {0:###.#}", STEP_P1) + "°C" + Resources.Expected+ string.Format(" {0:D2}", TIME_M) + Resources.Min; Status_Str = Resources.Heats + ":" + Resources.Target + Resources.Temperature + string.Format(" {0:###.#}", STEP_P1) + "°C" + Resources.Expected + string.Format(" {0:D2}", TIME_M) + Resources.Min;
} }
else if (THL_mode == 2)//降温 else if (THL_mode == 2)//降温
{ {
@ -272,18 +299,39 @@ namespace DyeingComputer.ViewModel
{ {
TIME_M = Convert.ToInt16((T - STEP_P1) / (STEP_P2 / 10)); TIME_M = Convert.ToInt16((T - STEP_P1) / (STEP_P2 / 10));
} }
Status_Str = Resources.Cooling +":" + Resources.Target + Resources.Temperature + string.Format(" {0:###.#}", STEP_P1) +"°C" + Resources.Expected + string.Format(" {0:D2}", TIME_M )+ Resources.Min; Status_Str = Resources.Cooling + ":" + Resources.Target + Resources.Temperature + string.Format(" {0:###.#}", STEP_P1) + "°C" + Resources.Expected + string.Format(" {0:D2}", TIME_M) + Resources.Min;
} }
updata_dtm("1004", TO); updata_dtm("1004", TO);
updata_dtm("1005", TEMP_co); updata_dtm("1005", TEMP_co);
break;
case "007":
} break;
case "009":
break;
case "013":
break;
case "015":
break;
case "017":
break;
case "020":
break;
case "022":
break;
default:
break;
}
} }
else else
{ {
if (Name_err == null) if (string.IsNullOrEmpty(Name_err.ToString()))
{ {
Status_Str = Resources.Await; Status_Str = Resources.Await;
} }
@ -296,7 +344,7 @@ namespace DyeingComputer.ViewModel
else else
if (WORK_RUN == 0) if (WORK_RUN == 0)
{ {
if (Name_err == null) if (string.IsNullOrEmpty(Name_err.ToString()))
{ {
int TIMEH = DIDETime / 3600; int TIMEH = DIDETime / 3600;
int TIMEM = (DIDETime - TIMEH * 3600) / 60; int TIMEM = (DIDETime - TIMEH * 3600) / 60;
@ -304,13 +352,8 @@ namespace DyeingComputer.ViewModel
Status_Str = Resources.Dide + string.Format(" {0:D4}", TIMEH) + ":" + string.Format(" {0:D2}", TIMEM) + ":" + string.Format(" {0:D2}", TIMES); Status_Str = Resources.Dide + string.Format(" {0:D4}", TIMEH) + ":" + string.Format(" {0:D2}", TIMEM) + ":" + string.Format(" {0:D2}", TIMES);
} }
} }
} }
public static SerialPort port = new SerialPort();//创建串口 public static SerialPort port = new SerialPort();//创建串口
static ModbusFactory factory = new ModbusFactory(); static ModbusFactory factory = new ModbusFactory();
// Create Modbus Master // Create Modbus Master
@ -360,18 +403,14 @@ namespace DyeingComputer.ViewModel
{ {
master.WriteMultipleCoils(slaveId, 00000, DQ); //写入线圈 master.WriteMultipleCoils(slaveId, 00000, DQ); //写入线圈
master.WriteMultipleRegisters(slaveId,07000,DW); //写入寄存器 master.WriteMultipleRegisters(slaveId,07000,DW); //写入寄存器
DO = master.ReadCoils(slaveId, 01000, DO_L); //读取线圈 DO = master.ReadCoils(slaveId, 01000, DO_L); //读取线圈
// DQ = master.ReadCoils(slaveId, 00000, DQ_L);
RW = master.ReadHoldingRegisters(slaveId,06000, RW_L); //读取寄存器 RW = master.ReadHoldingRegisters(slaveId,06000, RW_L); //读取寄存器
// RW = master.ReadHoldingRegisters(slaveId, 07000, RW_L);
LINK_OK =true; LINK_OK =true;
} }
catch (Exception ex) catch (Exception ex)
{ {
LINK_OK=false; LINK_OK=false;
LINK_ERR++; LINK_ERR++;
// LogGing.LogGingDATA(ex.Message);
Name_err = "PLC"+Properties.Resources.Connectionlost+"("+ ex.Message + ")"; Name_err = "PLC"+Properties.Resources.Connectionlost+"("+ ex.Message + ")";
} }
}); });

Loading…
Cancel
Save