|
|
@ -73,6 +73,7 @@ namespace DyeingComputer.ViewModel |
|
|
|
|
|
|
|
private static int MT05;//主缸排水延时
|
|
|
|
private static int MT06;//主缸排水延时
|
|
|
|
private int MT12; |
|
|
|
private static double MT16;//流量计数系数
|
|
|
|
private int MT18;//主缸管数
|
|
|
|
private static double MT33;//主缸温度偏差
|
|
|
@ -103,6 +104,7 @@ namespace DyeingComputer.ViewModel |
|
|
|
|
|
|
|
MT05 = Convert.ToInt16(Selet_con("MT05"));//主缸排水延时
|
|
|
|
MT06 = Convert.ToInt16(Selet_con("MT06"));//动力排水延时
|
|
|
|
MT12 = Convert.ToInt16(Selet_con("MT12"));//
|
|
|
|
MT16 = Convert.ToDouble(Selet_con("MT16"));//流量计数系数
|
|
|
|
MT18 = Convert.ToInt16(Selet_con("MT18"));//
|
|
|
|
MT33 = Convert.ToDouble(Selet_con("MT33"));//温度偏差参数
|
|
|
@ -220,25 +222,25 @@ namespace DyeingComputer.ViewModel |
|
|
|
Work_Temp = Selet_dtm("1010") + " ℃"; |
|
|
|
Work_Numder = WorkNumder.ToString(); |
|
|
|
|
|
|
|
// if (LINK_OK) Modbus_link();
|
|
|
|
if (!SETP_runtime) DIDETime++; |
|
|
|
|
|
|
|
STEP_RUN(); |
|
|
|
IO_view(); |
|
|
|
STEP_RUN(); |
|
|
|
LOG_view(); |
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Name_err.ToString(); |
|
|
|
} |
|
|
|
void Tick_Event_5S(object sender, EventArgs e)//Tick_Event周期执行事件5S
|
|
|
|
{ |
|
|
|
Name_err = ""; |
|
|
|
if (!LINK_OK) Modbus_link(); |
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(Name_err.ToString()) && ((Selet_dtm("1010") < 10) || (Selet_dtm("1010") > 160))) |
|
|
|
{ Status_Str = Resources.Temperature + Resources.Sensor + Resources.Malfunction; } //温度故障提示
|
|
|
|
{ Name_err = Resources.Temperature + Resources.Sensor + Resources.Malfunction; } //温度故障提示
|
|
|
|
} |
|
|
|
void DisTimer_500MS(object sender, EventArgs e)//Tick_Event周期执行事件100MS
|
|
|
|
void DisTimer_500MS(object sender, EventArgs e)//Tick_Event周期执行事件500MS
|
|
|
|
{ |
|
|
|
if (LINK_OK) Modbus_link(); |
|
|
|
IO_view(); |
|
|
|
if (LINK_OK) IO_data(); |
|
|
|
if (!string.IsNullOrEmpty(Name_err.ToString()) && (!ERR_JOG)) //有故障信息,无故障保持
|
|
|
|
{ |
|
|
@ -415,6 +417,7 @@ namespace DyeingComputer.ViewModel |
|
|
|
} |
|
|
|
|
|
|
|
TimeSpan ts = new TimeSpan(1);//1秒间隔
|
|
|
|
private int temp_time10s = 10; |
|
|
|
void STEP_RUN() |
|
|
|
{ |
|
|
|
if (WORK_RUN == 2) |
|
|
@ -504,6 +507,33 @@ namespace DyeingComputer.ViewModel |
|
|
|
} |
|
|
|
updata_dtm("1004", TO); |
|
|
|
updata_dtm("1005", TEMP_co); |
|
|
|
if (MT12 == 1)//输出类型0开关1模拟
|
|
|
|
{ |
|
|
|
if (THL_mode == 2) |
|
|
|
{ |
|
|
|
updata_dta("5002", Convert.ToInt16(TO)); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
updata_dta("5001", Convert.ToInt16(TO)); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (temp_time10s <= 0) { temp_time10s = 10; } else { temp_time10s--; } |
|
|
|
if (THL_mode == 2) |
|
|
|
{ |
|
|
|
if ((temp_time10s <= Convert.ToInt16(TO)/100)) |
|
|
|
{ updata_dtd("3010", true); } |
|
|
|
else { updata_dtd("3010", false); }//降温
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if ((temp_time10s <= Convert.ToInt16(TO)/100)) |
|
|
|
{ updata_dtd("3009", true); } |
|
|
|
else { updata_dtd("3009", false); }//升温
|
|
|
|
} |
|
|
|
} |
|
|
|
break;//功能模块001温度控制
|
|
|
|
case "007": |
|
|
|
if (STEP_P1.ToString() == "1") |
|
|
@ -947,8 +977,7 @@ namespace DyeingComputer.ViewModel |
|
|
|
master.WriteMultipleRegisters(slaveId, 07000, DW); //写入寄存器
|
|
|
|
DO = master.ReadCoils(slaveId, 01000, DO_L); //读取线圈
|
|
|
|
RW = master.ReadHoldingRegisters(slaveId, 06000, RW_L); //读取寄存器
|
|
|
|
LINK_OK = true; |
|
|
|
Name_err = ""; |
|
|
|
LINK_OK = true; |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
@ -958,13 +987,12 @@ namespace DyeingComputer.ViewModel |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
void LOG_view()//细节页面
|
|
|
|
{ |
|
|
|
Sys_log = Resources.Target + Resources.Temperature + " : " + string.Format(" {0:###.#}", TEMP_tar) + "°C";//显示目标温度
|
|
|
|
Sys_log = Sys_log + " | " + Resources.MasterCylinder + Resources.Temperature + " : " + string.Format(" {0:###.#}", Convert.ToDouble(Selet_dtm("1010"))) + "°C";//显示实际温度
|
|
|
|
Sys_log = Sys_log + "\n" + Resources.Compute + Resources.Temperature + " : " + string.Format(" {0:###.#}", Convert.ToDouble(Selet_dtm("1005"))) + "°C";//显示计算温度
|
|
|
|
Sys_log = Sys_log + " | " + Resources.ProportionalValves + " : " + string.Format("{0:###.#}", Convert.ToDouble(Selet_dtm("1004"))/10) + "%";//显示比例
|
|
|
|
Sys_log = Sys_log + " | " + Resources.ProportionalValves + " : " + string.Format("{0:###.#}", Convert.ToDouble(Selet_dtm("1004")) / 10) + "%";//显示比例
|
|
|
|
int IO1015 = Convert.ToInt16(Selet_dtm("1015")); |
|
|
|
if (IO1015 < MT39) |
|
|
|
{ |
|
|
@ -986,12 +1014,12 @@ namespace DyeingComputer.ViewModel |
|
|
|
{ |
|
|
|
Sys_log = Sys_log + "\n" + Resources.PumpSpeed + " : " + string.Format("{0:D3}", Convert.ToInt16(Selet_dtm("1020"))) + "% => [" + Resources.PumpStops + "]";//主泵状态
|
|
|
|
} |
|
|
|
Sys_log = Sys_log + "\n" + Resources.MasterCylinder + Resources.Pressure + " : " + string.Format("{0:###.#}", Convert.ToDouble(Selet_dtm("1042")))+ "Bar"; |
|
|
|
Sys_log = Sys_log + "\n" + Resources.MasterCylinder + Resources.Pressure + " : " + string.Format("{0:###.#}", Convert.ToDouble(Selet_dtm("1042"))) + "Bar"; |
|
|
|
Sys_log = Sys_log + " | " + Resources.Nozzle + Resources.Pressure + " : " + string.Format("{0:###.#}", Convert.ToDouble(Selet_dtm("1043"))) + "Bar"; |
|
|
|
Sys_log = Sys_log + "\n-------------------------------------------------------"; |
|
|
|
if (S16 == 0) |
|
|
|
{ |
|
|
|
Sys_log = Sys_log + "\n" + Resources.ClothWheel +"M/min"; |
|
|
|
Sys_log = Sys_log + "\n" + Resources.ClothWheel + "M/min"; |
|
|
|
Sys_log = Sys_log + "\n" + "1 : " + string.Format("{0:D3}", Convert.ToInt16(Selet_dtm("1022"))); |
|
|
|
if (MT18 >= 2) Sys_log = Sys_log + " | " + "2 : " + string.Format("{0:D3}", Convert.ToInt16(Selet_dtm("1023"))); |
|
|
|
if (MT18 >= 3) Sys_log = Sys_log + " | " + "3 : " + string.Format("{0:D3}", Convert.ToInt16(Selet_dtm("1024"))); |
|
|
@ -1016,7 +1044,7 @@ namespace DyeingComputer.ViewModel |
|
|
|
}//溢流/o型
|
|
|
|
else if (S16 == 1) //气流
|
|
|
|
{ |
|
|
|
Sys_log = Sys_log + "\n" + Resources.DifferentialPressure + " : "+ string.Format("{0:D3}", Convert.ToInt16(Selet_dtm("1021"))) + "%"; |
|
|
|
Sys_log = Sys_log + "\n" + Resources.DifferentialPressure + " : " + string.Format("{0:D3}", Convert.ToInt16(Selet_dtm("1021"))) + "%"; |
|
|
|
Sys_log = Sys_log + "\n" + Resources.Blower + " : " + string.Format("{0:D3}", Convert.ToInt16(Selet_dtm("1044"))) + "%"; |
|
|
|
Sys_log = Sys_log + "\n" + Resources.GuidingWheel + " : " + string.Format("{0:D3}", Convert.ToInt16(Selet_dtm("1046"))) + "M/min"; |
|
|
|
Sys_log = Sys_log + "\n" + Resources.Nozzle + Resources.Flowmeter + " : " + string.Format("{0:D3}", Convert.ToInt16(Selet_dtm("1045"))) + "L/min"; |
|
|
@ -1025,11 +1053,25 @@ namespace DyeingComputer.ViewModel |
|
|
|
{ } |
|
|
|
|
|
|
|
Sys_log = Sys_log + "\n-------------------------------------------------------"; |
|
|
|
if (SM01 == 1) Sys_log = Sys_log + "\n" + Resources.Medicine + Resources.Tank + "1 => [" + Resources.WaterLevel + ":" + string.Format("{0:D4}", Convert.ToInt16(Selet_dtm("1017"))) + "L][" + Resources.Temperature + ":" + string.Format(" {0:###.#}", Convert.ToInt16(Selet_dtm("1012"))) + "°C]"; |
|
|
|
if (SM02 == 1) Sys_log = Sys_log + "\n" + Resources.Medicine + Resources.Tank + "2 => [" + Resources.WaterLevel + ":" + string.Format("{0:D4}", Convert.ToInt16(Selet_dtm("1018"))) + "L][" + Resources.Temperature + ":" + string.Format(" {0:###.#}", Convert.ToInt16(Selet_dtm("1013"))) + "°C]"; |
|
|
|
if (SM03 == 1) Sys_log = Sys_log + "\n" + Resources.Medicine + Resources.Tank + "3 => [" + Resources.WaterLevel + ":" + string.Format("{0:D4}", Convert.ToInt16(Selet_dtm("1019"))) + "L][" + Resources.Temperature + ":" + string.Format(" {0:###.#}", Convert.ToInt16(Selet_dtm("1014"))) + "°C]"; |
|
|
|
if (SM01 == 1) |
|
|
|
{ |
|
|
|
Sys_log = Sys_log + "\n" + Resources.Medicine + Resources.Tank + "1 => [" + Resources.WaterLevel + ":" + string.Format("{0:D4}", Convert.ToInt16(Selet_dtm("1017"))) + "L][" + Resources.Temperature + ":" + string.Format(" {0:###.#}", Convert.ToInt16(Selet_dtm("1012"))) + "°C]"; |
|
|
|
Sys_log = Sys_log + "\n" + Resources.Dyelot + " : " + " => "; |
|
|
|
Sys_log = Sys_log + "\n" + Resources.WorkingStatus + " : "; |
|
|
|
} |
|
|
|
if (SM02 == 1) |
|
|
|
{ |
|
|
|
Sys_log = Sys_log + "\n" + Resources.Medicine + Resources.Tank + "2 => [" + Resources.WaterLevel + ":" + string.Format("{0:D4}", Convert.ToInt16(Selet_dtm("1018"))) + "L][" + Resources.Temperature + ":" + string.Format(" {0:###.#}", Convert.ToInt16(Selet_dtm("1013"))) + "°C]"; |
|
|
|
Sys_log = Sys_log + "\n" + Resources.Dyelot + " : " + " => "; |
|
|
|
Sys_log = Sys_log + "\n" + Resources.WorkingStatus + " : "; |
|
|
|
} |
|
|
|
if (SM03 == 1) |
|
|
|
{ |
|
|
|
Sys_log = Sys_log + "\n" + Resources.Medicine + Resources.Tank + "3 => [" + Resources.WaterLevel + ":" + string.Format("{0:D4}", Convert.ToInt16(Selet_dtm("1019"))) + "L][" + Resources.Temperature + ":" + string.Format(" {0:###.#}", Convert.ToInt16(Selet_dtm("1014"))) + "°C]"; |
|
|
|
Sys_log = Sys_log + "\n" + Resources.Dyelot + " : " + " => "; |
|
|
|
Sys_log = Sys_log + "\n" + Resources.WorkingStatus + " : "; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static DataTable dt_d = new DataTable("DIO"); |
|
|
|
public static DataTable dt_a = new DataTable("AIO"); |
|
|
|
public static DataTable dt_m = new DataTable("M"); |
|
|
@ -1074,14 +1116,21 @@ namespace DyeingComputer.ViewModel |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
SYSData_A = ToObservableCollection<DATA_A>(dt_a); |
|
|
|
SYSData_A = ToObservableCollection<DATA_A>(dt_a); |
|
|
|
} |
|
|
|
catch (Exception ex) { Name_err = "IO_SYSData_A" + "(" + ex.Message + ")"; } |
|
|
|
try |
|
|
|
{ |
|
|
|
SYSData_D = ToObservableCollection<DATA_D>(dt_d); |
|
|
|
} |
|
|
|
catch (Exception ex) { Name_err = "IO_SYSData_D" + "(" + ex.Message + ")"; } |
|
|
|
try |
|
|
|
{ |
|
|
|
SYSData_M = ToObservableCollection<DATA_M>(dt_m); |
|
|
|
} |
|
|
|
catch (Exception ex) { Name_err = "IO" + "(" + ex.Message + ")"; } |
|
|
|
catch (Exception ex) { Name_err = "IO_SYSData_M" + "(" + ex.Message + ")"; } |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
public static double Selet_dtm(string key)//M寄存器
|
|
|
|
{ |
|
|
|
try |
|
|
@ -1097,7 +1146,7 @@ namespace DyeingComputer.ViewModel |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
LogGing.LogGingDATA(ex.ToString()); |
|
|
|
LogGing.LogGingDATA("SDTM:"+ex.ToString()); |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
@ -1116,7 +1165,7 @@ namespace DyeingComputer.ViewModel |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
LogGing.LogGingDATA(ex.ToString()); |
|
|
|
LogGing.LogGingDATA("SDTD:" + ex.ToString()); |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
@ -1135,7 +1184,7 @@ namespace DyeingComputer.ViewModel |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
LogGing.LogGingDATA(ex.ToString()); |
|
|
|
LogGing.LogGingDATA("SDTA:" + ex.ToString()); |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
@ -1164,7 +1213,7 @@ namespace DyeingComputer.ViewModel |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
LogGing.LogGingDATA(ex.ToString()); |
|
|
|
LogGing.LogGingDATA("UDTM:" + ex.ToString()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
@ -1174,17 +1223,6 @@ namespace DyeingComputer.ViewModel |
|
|
|
{ |
|
|
|
lock (dt_d)//锁
|
|
|
|
{ |
|
|
|
/* DataRow[] arrRows = dt_d.Rows.Find(key); //dt_d.Select("ID='" + key + "'");
|
|
|
|
int index = dt_d.Rows.IndexOf(arrRows[0]); |
|
|
|
if (index != -1) |
|
|
|
{ |
|
|
|
DataRow drEmployee = dt_d.Rows[index]; |
|
|
|
drEmployee.BeginEdit(); |
|
|
|
drEmployee["DIO"] = Value; |
|
|
|
drEmployee.EndEdit(); |
|
|
|
drEmployee.AcceptChanges(); |
|
|
|
drEmployee.ClearErrors(); |
|
|
|
}*/ |
|
|
|
DataRow drEmployee = dt_d.Rows.Find(key); |
|
|
|
drEmployee.BeginEdit(); |
|
|
|
drEmployee["DIO"] = Value; |
|
|
@ -1195,7 +1233,7 @@ namespace DyeingComputer.ViewModel |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
LogGing.LogGingDATA(ex.ToString()); |
|
|
|
LogGing.LogGingDATA("UDTD:" + ex.ToString()); |
|
|
|
} |
|
|
|
} |
|
|
|
public static void updata_dta(string key, int Value)//更新A寄存器
|
|
|
@ -1204,15 +1242,6 @@ namespace DyeingComputer.ViewModel |
|
|
|
{ |
|
|
|
lock (dt_a) |
|
|
|
{ |
|
|
|
/* DataRow[] arrRows = dt_a.Select("ID='" + key + "'"); |
|
|
|
int index = dt_a.Rows.IndexOf(arrRows[0]); |
|
|
|
if (index != -1) |
|
|
|
{ |
|
|
|
DataRow drEmployee = dt_a.Rows[index]; |
|
|
|
drEmployee.BeginEdit(); |
|
|
|
drEmployee["AIO"] = Value; |
|
|
|
drEmployee.EndEdit(); |
|
|
|
}*/ |
|
|
|
DataRow drEmployee = dt_a.Rows.Find(key); |
|
|
|
drEmployee.BeginEdit(); |
|
|
|
drEmployee["AIO"] = Value; |
|
|
@ -1223,7 +1252,7 @@ namespace DyeingComputer.ViewModel |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
LogGing.LogGingDATA(ex.ToString()); |
|
|
|
LogGing.LogGingDATA("UDTA:" + ex.ToString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -1280,6 +1309,7 @@ namespace DyeingComputer.ViewModel |
|
|
|
public double Value { get; set; } |
|
|
|
public String ID { get; set; } |
|
|
|
public string Info { get; set; } |
|
|
|
public string type { get; set; } |
|
|
|
} |
|
|
|
public ObservableCollection<T> ToObservableCollection<T>(DataTable dt) where T : class, new() |
|
|
|
{ |
|
|
|