sc 1 year ago
parent
commit
af14a59c01
  1. 18
      Properties/Resources.Designer.cs
  2. 6
      Properties/Resources.en-US.resx
  3. 6
      Properties/Resources.resx
  4. 6
      Properties/Resources.zh-CN.resx
  5. 6
      Properties/Resources.zh-TW.resx
  6. 2
      View/InOutView.xaml
  7. 2
      View/TechnologicalProcessView.xaml
  8. 2
      View/TechnologicalProcessView.xaml.cs
  9. 120
      ViewModel/MainWindowViewModel.cs

18
Properties/Resources.Designer.cs

@ -321,6 +321,15 @@ namespace DyeingComputer.Properties {
}
}
/// <summary>
/// 查找类似 Dyelot 的本地化字符串。
/// </summary>
public static string Dyelot {
get {
return ResourceManager.GetString("Dyelot", resourceCulture);
}
}
/// <summary>
/// 查找类似 edit 的本地化字符串。
/// </summary>
@ -1104,6 +1113,15 @@ namespace DyeingComputer.Properties {
}
}
/// <summary>
/// 查找类似 WorkingStatus 的本地化字符串。
/// </summary>
public static string WorkingStatus {
get {
return ResourceManager.GetString("WorkingStatus", resourceCulture);
}
}
/// <summary>
/// 查找类似 Worklist 的本地化字符串。
/// </summary>

6
Properties/Resources.en-US.resx

@ -474,4 +474,10 @@
<data name="LnsufficientPower" xml:space="preserve">
<value>Lnsufficient Power</value>
</data>
<data name="WorkingStatus" xml:space="preserve">
<value>Working Status</value>
</data>
<data name="Dyelot" xml:space="preserve">
<value>Dyelot</value>
</data>
</root>

6
Properties/Resources.resx

@ -474,4 +474,10 @@
<data name="LnsufficientPower" xml:space="preserve">
<value>LnsufficientPower</value>
</data>
<data name="WorkingStatus" xml:space="preserve">
<value>WorkingStatus</value>
</data>
<data name="Dyelot" xml:space="preserve">
<value>Dyelot</value>
</data>
</root>

6
Properties/Resources.zh-CN.resx

@ -474,4 +474,10 @@
<data name="LnsufficientPower" xml:space="preserve">
<value>功率不足</value>
</data>
<data name="WorkingStatus" xml:space="preserve">
<value>工作状态</value>
</data>
<data name="Dyelot" xml:space="preserve">
<value>领料单</value>
</data>
</root>

6
Properties/Resources.zh-TW.resx

@ -474,4 +474,10 @@
<data name="LnsufficientPower" xml:space="preserve">
<value>功率不足</value>
</data>
<data name="WorkingStatus" xml:space="preserve">
<value>工作狀態</value>
</data>
<data name="Dyelot" xml:space="preserve">
<value>領料單</value>
</data>
</root>

2
View/InOutView.xaml

@ -19,7 +19,7 @@
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<DataGrid x:Name="Grid_D" AlternationCount="2" IsReadOnly="True" SelectionChanged="Grid_D_SelectionChanged" d:ItemsSource="{d:SampleData ItemCount=256}"
<DataGrid x:Name="Grid_D" AlternationCount="2" IsReadOnly="True" SelectionChanged="Grid_D_SelectionChanged" d:ItemsSource="{d:SampleData ItemCount=512}"
Margin="0,0,0,0" ItemsSource="{Binding Path=SYSData_D,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" AutoGenerateColumns="False" MinColumnWidth="30"
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="#CCCCCC"
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" AllowDrop="False"

2
View/TechnologicalProcessView.xaml

@ -16,7 +16,7 @@
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="{x:Null}"
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2" AllowDrop="False"
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
CanUserAddRows="True" CanUserDeleteRows="False" HeadersVisibility ="Column" SelectedIndex="{Binding Sys_workSTEPID}"
CanUserAddRows="True" CanUserDeleteRows="False" HeadersVisibility ="Column"
Background="White" SelectionMode="Single" FontSize="15" MinHeight="632" TabIndex="1" Focusable="True">
<DataGrid.RowStyle >
<Style TargetType="{x:Type DataGridRow}">

2
View/TechnologicalProcessView.xaml.cs

@ -31,7 +31,7 @@ namespace DyeingComputer.View
public TechnologicalProcessView()
{
InitializeComponent();
DataContext = new MainWindowViewModel();
//Grid.DataContext = new MainWindowViewModel();
FocusManager.SetFocusedElement(Grid, Grid);
if (workName != null)
{

120
ViewModel/MainWindowViewModel.cs

@ -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()
{

Loading…
Cancel
Save