sc 1 year ago
parent
commit
b6cb301594
  1. 6
      View/EquipmentSimulationView.xaml
  2. 1
      View/WorkOrderView.xaml.cs
  3. 331
      ViewModel/MainWindowViewModel.cs
  4. 5
      Windows/ViewStep.xaml.cs

6
View/EquipmentSimulationView.xaml

@ -5,6 +5,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DyeingComputer.View"
mc:Ignorable="d"
d:DesignHeight="630" d:DesignWidth="1280" VerticalAlignment="Top">
<Grid/>
d:DesignHeight="630" d:DesignWidth="1280">
<Grid>
</Grid>
</UserControl>

1
View/WorkOrderView.xaml.cs

@ -205,6 +205,7 @@ namespace DyeingComputer.View
{
MainWindowViewModel.WorkNumder = WorkOrder_Numder;
TechnologicalProcessView.workName = Process_id;
MainWindowViewModel.SYS_REDYE = 0;
MainWindowViewModel.ViewID = 1;
var _mainWindow = Application.Current.Windows.Cast<Window>().FirstOrDefault(window => window is MainWindow) as MainWindow;//跨页面

331
ViewModel/MainWindowViewModel.cs

@ -25,6 +25,7 @@ using Microsoft.Win32;
using static DyeingComputer.Windows.ViewStep;
using System.Windows.Media;
using System.Runtime.Remoting.Channels;
using System.Diagnostics.Eventing.Reader;
namespace DyeingComputer.ViewModel
@ -61,6 +62,7 @@ namespace DyeingComputer.ViewModel
private PID pid = new PID();
public static DataTable RUN_DATATABLE = new DataTable();//缓存工作表
public static int RUN_STEPID;//当前步骤
public static int SYS_REDYE=0;//当前重燃步
public MainWindowViewModel()
{
@ -112,6 +114,7 @@ namespace DyeingComputer.ViewModel
private int MT40;//低水位
private int MT41;//安全水位
private static int MU01;//呼叫操作员
private string S01;//机台号
private int S16;//机型
public static int SM01;//副缸
public static int SM02;//副缸
@ -120,6 +123,9 @@ namespace DyeingComputer.ViewModel
private double MS01;//1缸温度偏差
private double MS02;//2缸温度偏差
private double MS03;//3缸温度偏差
public int MS17;//副缸
public int MS18;//副缸
public int MS19;//副缸
void SYS_SET()
{
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
@ -149,7 +155,11 @@ namespace DyeingComputer.ViewModel
MS01 = Convert.ToDouble(Selet_con("MS01"));
MS02 = Convert.ToDouble(Selet_con("MS02"));
MS03 = Convert.ToDouble(Selet_con("MS03"));
MS17 = Convert.ToInt16(Selet_con("MS17"));
MS18 = Convert.ToInt16(Selet_con("MS18"));
MS19 = Convert.ToInt16(Selet_con("MS19"));
S01 = Selet_sys("S01");//
S16 = Convert.ToInt16(Selet_sys("S16"));//工作信息
SM01 = Convert.ToInt16(Selet_sys("SM01"));//FG
SM02 = Convert.ToInt16(Selet_sys("SM02"));//FG
@ -412,10 +422,17 @@ namespace DyeingComputer.ViewModel
STEP_finish = false;
break;
case "050":
STEP_P1 = Convert.ToDouble(P1);
STEP_P2 = Convert.ToDouble(P2);
WORK_RUN = 2;
SETP_runtime = true;
STEP_finish = false;
break;//主缸加压
case "051":
STEP_P1 = Convert.ToDouble(P1);
STEP_P2 = Convert.ToDouble(P2);
SETP_runtime = true;
STEP_finish = false;
break;//主缸减压
case "054":
STEP_P1 = Convert.ToDouble(P1);
@ -437,28 +454,66 @@ namespace DyeingComputer.ViewModel
STEP_finish = false;
break;//主泵停止
case "064":
STEP_P1 = Convert.ToDouble(P1);
STEP_P2 = Convert.ToDouble(P2);
STEP_P3 = Convert.ToDouble(P3);
STEP_P4 = Convert.ToDouble(P4);
STEP_P5 = Convert.ToDouble(P5);
WORK_RUN = 2;
SETP_runtime = true;
STEP_finish = false;
break;//药缸备药
case "065":
STEP_P1 = Convert.ToDouble(P1);
STEP_P2 = Convert.ToDouble(P2);
STEP_P3 = Convert.ToDouble(P3);
WORK_RUN = 2;
SETP_runtime = true;
STEP_finish = false;
break;//药缸加药
case "066":
STEP_P1 = Convert.ToDouble(P1);
STEP_P2 = Convert.ToDouble(P2);
STEP_P3 = Convert.ToDouble(P3);
WORK_RUN = 2;
SETP_runtime = true;
STEP_finish = false;
break;//呼叫输送
case "067":
STEP_P1 = Convert.ToDouble(P1);
STEP_P2 = Convert.ToDouble(P2);
STEP_P3 = Convert.ToDouble(P3);
WORK_RUN = 2;
SETP_runtime = true;
STEP_finish = false;
break;//呼叫输送
case "090":
STEP_P1 = Convert.ToDouble(P1);
STEP_P2 = Convert.ToDouble(P2);
WORK_RUN = 2;
SETP_runtime = true;
STEP_finish = false;
break;//快速加酸
case "091":
STEP_P1 = Convert.ToDouble(P1);
STEP_P2 = Convert.ToDouble(P2);
STEP_P3 = Convert.ToDouble(P3);
WORK_RUN = 2;
SETP_runtime = true;
STEP_finish = false;
break;//PH温度控制
case "093":
STEP_P1 = Convert.ToDouble(P1);
WORK_RUN = 2;
SETP_runtime = true;
STEP_finish = false;
break;//PH检测
case "094":
STEP_P1 = Convert.ToDouble(P1);
STEP_P2 = Convert.ToDouble(P2);
WORK_RUN = 2;
SETP_runtime = true;
STEP_finish = false;
break;//PH控制
default:
break;
@ -467,6 +522,9 @@ namespace DyeingComputer.ViewModel
TimeSpan ts = new TimeSpan(00,00,01);//1秒间隔
private int temp_time10s = 10;//开关周期时间
private string TANK1, TANK2, TANK3;//料桶信息
public static string TANK1_DYELOT, TANK2_DYELOT, TANK3_DYELOT;//料单号
private int TANK1_REDYE,TANK1_STEP, TANK2_REDYE, TANK2_STEP, TANK3_REDYE, TANK3_STEP;
void STEP_RUN()
{
if (WORK_RUN == 2)
@ -928,19 +986,213 @@ namespace DyeingComputer.ViewModel
Updata_dtd("3011", false);//主泵
if (S16 == 1) Updata_dtd("3012", false);//风机
STEP_finish = true;
if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.PumpStops;
break;//主泵停止
case "064":
if ((STEP_P1 == 1)||(STEP_P1==0))
{
if (Selet_dtm("1017") >= STEP_P3)//水位
{
TANK1 = Resources.Ready;
Updata_dtd("3036", false);
Updata_dtd("3037", false);
Updata_dtd("3038", false);
if (Selet_dtm("1012") >= STEP_P4)//温度
{
Updata_dtd("3039",false);
if (Selet_dtd("2003"))//投料确认
{
if (STEP_TIME <= 0)//搅拌
{
TANK1 = Resources.Ready + Resources.Finish;
Updata_dtd("3040",false);
STEP_finish = true;
}
else
{
STEP_TIME--;
Updata_dtd("3040",true);
}
Alert_yellow = false;
Alert_bell = false;
}
else
{
Alert_yellow = true;
STEP_TIME = Convert.ToInt16(STEP_P5);
Alert_bell = true;
}
}
else
{
Updata_dtd("3039",true);
Updata_dtd("3040", true);
}
}
else
{
if (STEP_P2 == 0) Updata_dtd("3038", true);
else if(STEP_P2 == 1) Updata_dtd("3036", true);
else if (STEP_P2 == 2) Updata_dtd("3037", true);
}
if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Tank +" 1 :" + Resources.Ready;
} //药缸1
else if (STEP_P1 == 2)
{
if (Selet_dtm("1018") >= STEP_P3)//水位
{
TANK2 = Resources.Ready;
Updata_dtd("3046", false);
Updata_dtd("3047", false);
Updata_dtd("3048", false);
if (Selet_dtm("1013") >= STEP_P4)//温度
{
Updata_dtd("3049", false);
if (Selet_dtd("2003"))//投料确认
{
if (STEP_TIME <= 0)//搅拌
{
TANK2 = Resources.Ready + Resources.Finish;
Updata_dtd("3050", false);
STEP_finish = true;
}
else
{
STEP_TIME--;
Updata_dtd("3050", true);
}
Alert_yellow = false;
Alert_bell = false;
}
else
{
Alert_yellow = true;
STEP_TIME = Convert.ToInt16(STEP_P5);
Alert_bell = true;
}
}
else
{
Updata_dtd("3049", true);
Updata_dtd("3050", true);
}
}
else
{
if (STEP_P2 == 0) Updata_dtd("3048", true);
else if (STEP_P2 == 1) Updata_dtd("3046", true);
else if (STEP_P2 == 2) Updata_dtd("3047", true);
}
if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Tank + " 2 :" + Resources.Ready;
}//药缸2
else if (STEP_P1 == 3)
{
if (Selet_dtm("1019") >= STEP_P3)//水位
{
TANK3 = Resources.Ready;
Updata_dtd("3056", false);
Updata_dtd("3057", false);
Updata_dtd("3058", false);
if (Selet_dtm("1014") >= STEP_P4)//温度
{
Updata_dtd("3059", false);
if (Selet_dtd("2003"))//投料确认
{
if (STEP_TIME <= 0)//搅拌
{
TANK3 = Resources.Ready + Resources.Finish;
Updata_dtd("3060", false);
STEP_finish = true;
}
else
{
STEP_TIME--;
Updata_dtd("3060", true);
}
Alert_yellow = false;
Alert_bell = false;
}
else
{
Alert_yellow = true;
STEP_TIME = Convert.ToInt16(STEP_P5);
Alert_bell = true;
}
}
else
{
Updata_dtd("3059", true);
Updata_dtd("3060", true);
}
}
else
{
if (STEP_P2 == 0) Updata_dtd("3058", true);
else if (STEP_P2 == 1) Updata_dtd("3056", true);
else if (STEP_P2 == 2) Updata_dtd("3057", true);
}
if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Tank + " 3 :" + Resources.Ready;
}//药缸3
break;//药缸备药
case "065":
if ((STEP_P1 == 1) || (STEP_P1 == 0))
{
if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Tank + " 1 :" + Resources.AddTheMedicine;
} //药缸1
else if (STEP_P1 == 2)
{
if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Tank + " 2 :" + Resources.AddTheMedicine;
}//药缸2
else if (STEP_P1 == 3)
{
if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Tank + " 3 :" + Resources.AddTheMedicine;
}//药缸3
break;//药缸加药
case "066":
if (STEP_P1 == 1)
{
TANK1_REDYE = SYS_REDYE;
if(string.IsNullOrEmpty(TANK1_DYELOT)) TANK1_DYELOT = WorkNumder.ToString();
TANK1_STEP =Convert.ToInt16(STEP_P3);
FeedingRecords(work_Numder,TANK1_DYELOT,Convert.ToInt16(STEP_P1),TANK1_STEP,Convert.ToInt16(STEP_P2));//调用呼叫
if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Tank + " 1 :" + Resources.CallDistribution;
STEP_finish = true;
} //药缸1
else if (STEP_P1 == 2)
{
TANK2_REDYE = SYS_REDYE;
if (string.IsNullOrEmpty(TANK2_DYELOT)) TANK2_DYELOT = WorkNumder.ToString();
TANK2_STEP = Convert.ToInt16(STEP_P3);
FeedingRecords(work_Numder, TANK2_DYELOT, Convert.ToInt16(STEP_P1), TANK2_STEP, Convert.ToInt16(STEP_P2));//调用呼叫
if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Tank + " 2 :" + Resources.CallDistribution;
STEP_finish = true;
}//药缸2
else if (STEP_P1 == 3)
{
TANK3_REDYE = SYS_REDYE;
if (string.IsNullOrEmpty(TANK3_DYELOT)) TANK3_DYELOT = WorkNumder.ToString();
TANK3_STEP = Convert.ToInt16(STEP_P3);
FeedingRecords(work_Numder, TANK3_DYELOT, Convert.ToInt16(STEP_P1), TANK3_STEP, Convert.ToInt16(STEP_P2));//调用呼叫
if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Tank + " 3 :" + Resources.CallDistribution;
STEP_finish = true;
}//药缸3
//STEP_finish = true;
break;//呼叫输送
case "067":
break;//呼叫输送
STEP_finish = true;
break;//呼叫输送准备
case "090":
break;//快速加酸
@ -1013,6 +1265,38 @@ namespace DyeingComputer.ViewModel
}
}
void FeedingRecords(string WorkOrder,string Dyelot,int TANK,int STEP,int Type) //呼叫输送
{
DataTable data_t = new DataTable();
data_t.Columns.Add("Dyelot", typeof(string)); //添加列
data_t.Columns.Add("Machine", typeof(string));
data_t.Columns.Add("WorkOrder", typeof(string));
data_t.Columns.Add("TIME", typeof(string));
data_t.Columns.Add("Tank", typeof(int));
data_t.Columns.Add("STEP", typeof(int));
data_t.Columns.Add("Type", typeof(int));
data_t.Columns.Add("State", typeof(int));
data_t.Columns.Add("Redye", typeof(int));
DataRow dr = data_t.NewRow();
dr.BeginEdit(); //添加订单号
dr["Dyelot"] = Dyelot;
dr["Machine"] = S01;
dr["WorkOrder"] = WorkOrder;
dr["TIME"] = sys_Time;
dr["Tank"] = TANK;
dr["STEP"] = STEP;
dr["Type"] = Type;
dr["State"] = 201;
dr["Redye"] = SYS_REDYE;
dr.EndEdit();
data_t.Rows.InsertAt(dr, 0); //行转换
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
SQLiteHelpers.InsertData("FeedingRecords", SQLiteHelpers.DataTableToDictionary(data_t));//行插入
SQLiteHelpers.Close(); //关闭连接
}
public static SerialPort port = new SerialPort();//创建串口
static ModbusFactory factory = new ModbusFactory();
// Create Modbus Master
@ -1036,7 +1320,7 @@ namespace DyeingComputer.ViewModel
LogGing.LogGingDATA(e.Message);
Name_err = "800_SerialPort_Not";
}
}
}//ck
private bool LINK_OK = false;
private int LINK_RUN = 0;
private int LINK_ERR = 0;
@ -1145,21 +1429,21 @@ namespace DyeingComputer.ViewModel
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 + " : ";
}
Sys_log = Sys_log + "\n" + Resources.Dyelot + " : " + TANK1_DYELOT +"_"+ TANK1_REDYE + " => "+ TANK1_STEP;
Sys_log = Sys_log + "\n" + Resources.WorkingStatus + " : "+TANK1;
}//附缸1
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 + " : ";
}
Sys_log = Sys_log + "\n" + Resources.Dyelot + " : " + TANK2_DYELOT + "_" + TANK1_REDYE + " => " + TANK2_STEP;
Sys_log = Sys_log + "\n" + Resources.WorkingStatus + " : "+TANK2;
}//附缸2
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 + " : ";
}
Sys_log = Sys_log + "\n" + Resources.Dyelot + " : " + TANK3_DYELOT + "_" + TANK1_REDYE + " => " + TANK3_STEP;
Sys_log = Sys_log + "\n" + Resources.WorkingStatus + " : "+TANK3;
}//附缸3
}
public static DataTable dt_d = new DataTable("DIO");
public static DataTable dt_a = new DataTable("AIO");
@ -1343,7 +1627,6 @@ namespace DyeingComputer.ViewModel
LogGing.LogGingDATA("UDTA:" + ex.ToString());
}
}
public static void Upplc_dtd(string key, bool Value)//更新PLCD
{
try

5
Windows/ViewStep.xaml.cs

@ -411,15 +411,14 @@ namespace DyeingComputer.Windows
P1N.Text = Properties.Resources.Medicine + Properties.Resources.Tank;
P2N.Text = Properties.Resources.Type;
P3N.Text = Properties.Resources.Step;
P4N.Text = Properties.Resources.Advance+Properties.Resources.Time;
P1.Visibility = Visibility.Visible;
P1N.Visibility = Visibility.Visible;
P2.Visibility = Visibility.Visible;
P2N.Visibility = Visibility.Visible;
P3.Visibility = Visibility.Visible;
P3N.Visibility = Visibility.Visible;
P4.Visibility = Visibility.Visible;
P4N.Visibility = Visibility.Visible;
P4.Visibility = Visibility.Collapsed;
P4N.Visibility = Visibility.Collapsed;
P5.Visibility = Visibility.Collapsed;
P5N.Visibility = Visibility.Collapsed;
break;

Loading…
Cancel
Save