|
|
@ -22,6 +22,8 @@ using static System.Windows.Forms.VisualStyles.VisualStyleElement; |
|
|
|
using Newtonsoft.Json; |
|
|
|
using static DyeingComputer.UserClass.SqliteHelper; |
|
|
|
using DyeingComputer.View; |
|
|
|
using System.Windows; |
|
|
|
using System.Windows.Controls; |
|
|
|
|
|
|
|
namespace DyeingComputer.UserClass |
|
|
|
{/// <summary>
|
|
|
@ -165,30 +167,141 @@ namespace DyeingComputer.UserClass |
|
|
|
{ |
|
|
|
Dictionary<string, object> dat_821; |
|
|
|
dat_821 = SerializeConvert.JsonDeserializeFromString<Dictionary<string, object>>(SYSDAT); |
|
|
|
if (dat_821.GetValue("INSTRUCTION").ToString() == "START") |
|
|
|
if (dat_821.GetValue("INSTRUCTION").ToString() == "START") |
|
|
|
{ |
|
|
|
SQLDATA.TechnologicalProcess_START(dat_821.GetValue("ProgramID").ToString()); |
|
|
|
} |
|
|
|
else if (dat_821.GetValue("INSTRUCTION").ToString() == "STOP") |
|
|
|
else if (dat_821.GetValue("INSTRUCTION").ToString() == "STOP") |
|
|
|
{ |
|
|
|
MainWindowViewModel.WORK_RUN = 0;//停止
|
|
|
|
MainWindowViewModel.DIDETime = 0; |
|
|
|
} |
|
|
|
else if (dat_821.GetValue("INSTRUCTION").ToString() == "PAUSE") |
|
|
|
else if (dat_821.GetValue("INSTRUCTION").ToString() == "PAUSE") |
|
|
|
{ |
|
|
|
MainWindowViewModel.WORK_RUN = 1;//暂停
|
|
|
|
} |
|
|
|
else if (dat_821.GetValue("INSTRUCTION").ToString() == "CONTINUE") |
|
|
|
else if (dat_821.GetValue("INSTRUCTION").ToString() == "CONTINUE") |
|
|
|
{ |
|
|
|
MainWindowViewModel.WORK_RUN = 2;//暂停
|
|
|
|
} |
|
|
|
MainWindowViewModel.WORK_RUN = 2;//暂停
|
|
|
|
} |
|
|
|
else if (dat_821.GetValue("INSTRUCTION").ToString() == "JUMP") |
|
|
|
{ |
|
|
|
MainWindowViewModel.RUN_DATATABLE = TechnologicalProcessView.sql.Tables[0];//缓存表
|
|
|
|
MainWindowViewModel.RUN_STEPID = Convert.ToInt16(dat_821.GetValue("ID").ToString());//插入步骤号
|
|
|
|
MainWindowViewModel.STEP_START(dat_821.GetValue("Numder").ToString(), Convert.ToDouble(dat_821.GetValue("P1")), |
|
|
|
Convert.ToDouble(dat_821.GetValue("P2")), Convert.ToDouble(dat_821.GetValue("P3")), |
|
|
|
Convert.ToDouble(dat_821.GetValue("P4")), Convert.ToDouble(dat_821.GetValue("P5"))); |
|
|
|
MainWindowViewModel.STEP_START(dat_821.GetValue("Numder").ToString(), Convert.ToDouble(dat_821.GetValue("P1")), |
|
|
|
Convert.ToDouble(dat_821.GetValue("P2")), Convert.ToDouble(dat_821.GetValue("P3")), |
|
|
|
Convert.ToDouble(dat_821.GetValue("P4")), Convert.ToDouble(dat_821.GetValue("P5"))); |
|
|
|
} |
|
|
|
else if (dat_821.GetValue("INSTRUCTION").ToString() == "INSERT") |
|
|
|
{ |
|
|
|
int d = Convert.ToInt16( dat_821.GetValue("ID")); |
|
|
|
TechnologicalProcessView.SQLiteHelpers = new SQLiteHelper(TechnologicalProcessView.DBAddress); //数据库连接路径
|
|
|
|
TechnologicalProcessView.SQLiteHelpers.Open(); //打开数据库
|
|
|
|
|
|
|
|
string ProgramID = TechnologicalProcessView.SQLiteHelpers.ExecuteScalar("select ProgramID from RUN where Step = '1'", null).ToString(); |
|
|
|
string ProgramNAME = TechnologicalProcessView.SQLiteHelpers.ExecuteScalar("select Program from RUN where Step = '1'", null).ToString(); |
|
|
|
TechnologicalProcessView.SQLiteHelpers.Close(); |
|
|
|
DataRow dr = TechnologicalProcessView.sql.Tables[0].NewRow();//添加表数据
|
|
|
|
dr["ProgramID"] = ProgramID; |
|
|
|
dr["Program"] = ProgramNAME; |
|
|
|
|
|
|
|
TechnologicalProcessView.sql.Tables[0].Rows.InsertAt(dr, d - 1); |
|
|
|
int a = TechnologicalProcessView.sql.Tables[0].Rows.Count; |
|
|
|
for (int i = 0; i < a; i++) |
|
|
|
{ |
|
|
|
DataRow drt = TechnologicalProcessView.sql.Tables[0].Rows[i]; |
|
|
|
drt.BeginEdit(); |
|
|
|
drt["Step"] = i + 1; |
|
|
|
drt.EndEdit(); |
|
|
|
} |
|
|
|
|
|
|
|
DataRow drtt = TechnologicalProcessView.sql.Tables[0].Rows[d - 1]; |
|
|
|
drtt.BeginEdit(); |
|
|
|
drtt["StepID"] = dat_821.GetValue("STEPID").ToString(); |
|
|
|
drtt["StepName"] = dat_821.GetValue("STEPNAME").ToString(); |
|
|
|
drtt["ParameterName"] = dat_821.GetValue("PNAME").ToString(); |
|
|
|
drtt["Parameter1"] = dat_821.GetValue("P1").ToString(); |
|
|
|
drtt["Parameter2"] = dat_821.GetValue("P2").ToString(); |
|
|
|
drtt["Parameter3"] = dat_821.GetValue("P3").ToString(); |
|
|
|
drtt["Parameter4"] = dat_821.GetValue("P4").ToString(); |
|
|
|
drtt["Parameter5"] = dat_821.GetValue("P5").ToString(); |
|
|
|
drtt.EndEdit(); |
|
|
|
|
|
|
|
var _TechnologicalProcessView = Application.Current.Windows.Cast<UserControl>().FirstOrDefault(window => window is TechnologicalProcessView) as TechnologicalProcessView;//跨页面
|
|
|
|
_TechnologicalProcessView.Grid.ItemsSource = TechnologicalProcessView.sql.Tables[0].DefaultView; |
|
|
|
_TechnologicalProcessView.Grid.SelectedIndex = -1; |
|
|
|
|
|
|
|
TechnologicalProcessView.SQLiteHelpers = new SQLiteHelper(TechnologicalProcessView.DBAddress); //数据库连接路径
|
|
|
|
TechnologicalProcessView.SQLiteHelpers.Open(); //打开数据库
|
|
|
|
TechnologicalProcessView.SQLiteHelpers.Delete("RUN", null, null); |
|
|
|
DataTable data_t = new DataTable(); |
|
|
|
data_t.Columns.Add("DYELOT", typeof(string)); //添加列
|
|
|
|
data_t = TechnologicalProcessView.sql.Tables[0].Clone(); |
|
|
|
int a = TechnologicalProcessView.sql.Tables[0].Rows.Count; |
|
|
|
for (int i = 0; i < a; i++) |
|
|
|
{ |
|
|
|
data_t.Clear();//清空
|
|
|
|
|
|
|
|
DataRow dt = TechnologicalProcessView.sql.Tables[0].Rows[i];//行转换
|
|
|
|
DataRow drT = data_t.NewRow(); |
|
|
|
drT.ItemArray = dt.ItemArray; |
|
|
|
data_t.Rows.InsertAt(drT, 0); |
|
|
|
dr.BeginEdit(); //添加订单号
|
|
|
|
dr["DYELOT"] = MainWindowViewModel.WorkNumder; |
|
|
|
dr.EndEdit(); |
|
|
|
|
|
|
|
TechnologicalProcessView.SQLiteHelpers.InsertData("RUN", TechnologicalProcessView.SQLiteHelpers.DataTableToDictionary(data_t));//行插入
|
|
|
|
} |
|
|
|
|
|
|
|
TechnologicalProcessView.SQLiteHelpers.Close(); //关闭连接
|
|
|
|
}//插入
|
|
|
|
else if (dat_821.GetValue("INSTRUCTION").ToString() == "EDIT") |
|
|
|
{ |
|
|
|
int n = Convert.ToInt16(dat_821.GetValue("ID").ToString()); |
|
|
|
|
|
|
|
DataRow dr = TechnologicalProcessView.sql.Tables[0].Rows[n - 1]; |
|
|
|
dr.BeginEdit(); |
|
|
|
dr["StepID"] = dat_821.GetValue("STEPID").ToString(); |
|
|
|
dr["StepName"] = dat_821.GetValue("STEPNAME").ToString(); |
|
|
|
dr["ParameterName"] = dat_821.GetValue("PNAME").ToString(); |
|
|
|
dr["Parameter1"] = dat_821.GetValue("P1").ToString(); |
|
|
|
dr["Parameter2"] = dat_821.GetValue("P2").ToString(); |
|
|
|
dr["Parameter3"] = dat_821.GetValue("P3").ToString(); |
|
|
|
dr["Parameter4"] = dat_821.GetValue("P4").ToString(); |
|
|
|
dr["Parameter5"] = dat_821.GetValue("P5").ToString(); |
|
|
|
dr.EndEdit(); |
|
|
|
|
|
|
|
var _TechnologicalProcessView = Application.Current.Windows.Cast<UserControl>().FirstOrDefault(window => window is TechnologicalProcessView) as TechnologicalProcessView;//跨页面
|
|
|
|
_TechnologicalProcessView.Grid.ItemsSource = TechnologicalProcessView.sql.Tables[0].DefaultView; |
|
|
|
_TechnologicalProcessView.Grid.SelectedIndex = -1; |
|
|
|
|
|
|
|
TechnologicalProcessView.SQLiteHelpers = new SQLiteHelper(TechnologicalProcessView.DBAddress); //数据库连接路径
|
|
|
|
TechnologicalProcessView.SQLiteHelpers.Open(); //打开数据库
|
|
|
|
TechnologicalProcessView.SQLiteHelpers.Delete("RUN", null, null); |
|
|
|
DataTable data_t = new DataTable(); |
|
|
|
data_t.Columns.Add("DYELOT", typeof(string)); //添加列
|
|
|
|
data_t = TechnologicalProcessView.sql.Tables[0].Clone(); |
|
|
|
int a = TechnologicalProcessView.sql.Tables[0].Rows.Count; |
|
|
|
for (int i = 0; i < a; i++) |
|
|
|
{ |
|
|
|
data_t.Clear();//清空
|
|
|
|
|
|
|
|
DataRow dt = TechnologicalProcessView.sql.Tables[0].Rows[i];//行转换
|
|
|
|
DataRow drT = data_t.NewRow(); |
|
|
|
drT.ItemArray = dt.ItemArray; |
|
|
|
data_t.Rows.InsertAt(drT, 0); |
|
|
|
dr.BeginEdit(); //添加订单号
|
|
|
|
dr["DYELOT"] = MainWindowViewModel.WorkNumder; |
|
|
|
dr.EndEdit(); |
|
|
|
|
|
|
|
TechnologicalProcessView.SQLiteHelpers.InsertData("RUN", TechnologicalProcessView.SQLiteHelpers.DataTableToDictionary(data_t));//行插入
|
|
|
|
} |
|
|
|
|
|
|
|
TechnologicalProcessView.SQLiteHelpers.Close(); //关闭连接
|
|
|
|
} |
|
|
|
else if (dat_821.GetValue("INSTRUCTION").ToString() == "DELETE") |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
client.SendAsync("SC821" + SYSKEY + SYSDAT); |
|
|
|
} |
|
|
|