Browse Source

开机检查任务状态,步骤明细显示处理

master
sc 4 months ago
parent
commit
5d630c5a86
  1. 59
      View/TechnologicalProcessView.xaml.cs
  2. 48
      ViewModel/MainWindowViewModel.cs

59
View/TechnologicalProcessView.xaml.cs

@ -308,15 +308,6 @@ namespace DyeingComputer.View
{
// FocusManager.SetFocusedElement(Grid, Grid);
// Grid.DataContext = new MainWindowViewModel();
if (workName != null)
{
GridSTEP.SelectedIndex = 0;
}
else
{
if (MainWindowViewModel.WORK_RUN != 0) GridSTEP.SelectedIndex = MainWindowViewModel.RUN_STEPID - 1;//设定图表显示
}
CountDown();
}
private void UserControl_KeyDown(object sender, KeyEventArgs e) //键盘监控
@ -471,6 +462,16 @@ namespace DyeingComputer.View
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked);
viewstop.ShowDialog();
}
private void ProgramgroupView_Jump_Click(object sender, RoutedEventArgs e)
{
MainWindowViewModel.RUN_STEPID = Convert.ToInt16(ID);//插入步骤号
MainWindowViewModel.STEP_START(Numder, Convert.ToDouble(P1), Convert.ToDouble(P2), Convert.ToDouble(P3),
Convert.ToDouble(P4), Convert.ToDouble(P5));
APILog.LOGlog(MainWindowViewModel.WorkNumder.ToString(), "UserActions", "Jump", "STEP = " + ID +
";StepID=" + Numder + ";P1=" + P1 + ";P2=" + P2 + ";P3=" + P3 + ";P4=" + P4 + ";P5=" + P5);
}//跳步
string Numder = null;
string ID = null;
@ -496,18 +497,7 @@ namespace DyeingComputer.View
Parameter_set.Visibility = Visibility.Visible;
Receip.Visibility = Visibility.Collapsed;
}
private void ProgramgroupView_Jump_Click(object sender, RoutedEventArgs e)
{
MainWindowViewModel.RUN_STEPID = Convert.ToInt16(ID);//插入步骤号
MainWindowViewModel.STEP_START(Numder, Convert.ToDouble(P1),Convert.ToDouble(P2), Convert.ToDouble(P3),
Convert.ToDouble(P4), Convert.ToDouble(P5));
APILog.LOGlog(MainWindowViewModel.WorkNumder.ToString(), "UserActions", "Jump", "STEP = " + ID+
";StepID=" + Numder + ";P1=" + P1 + ";P2=" + P2 + ";P3=" + P3 + ";P4=" + P4 + ";P5=" + P5);
}//跳步
private void Grid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// if (MainWindowViewModel.WORK_RUN == 2) GridSTEP.SelectedIndex = MainWindowViewModel.RUN_STEPID - 1;//设定图表显示
@ -520,32 +510,9 @@ namespace DyeingComputer.View
P2 = (GridSTEP.Columns[7].GetCellContent(GridSTEP.Items[rownum]) as TextBlock).Text;//定位第7列,
P3 = (GridSTEP.Columns[8].GetCellContent(GridSTEP.Items[rownum]) as TextBlock).Text;//定位第8列,
P4 = (GridSTEP.Columns[9].GetCellContent(GridSTEP.Items[rownum]) as TextBlock).Text;//定位第9列,
P5 = (GridSTEP.Columns[10].GetCellContent(GridSTEP.Items[rownum]) as TextBlock).Text;//定位第10列,
P5 = (GridSTEP.Columns[10].GetCellContent(GridSTEP.Items[rownum]) as TextBlock).Text;//定位第10列,
}
}
public void CountDown()
{
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
{
Interval = TimeSpan.FromSeconds(3)//秒
};
timer1s.Tick += Tick_Event_1S;
timer1s.Start();
}
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
{
if (MainWindowViewModel.WORK_RUN == 2) GridSTEP.SelectedIndex = MainWindowViewModel.RUN_STEPID - 1;//设定图表显示
if (sql != null)
{
dt_TP = sql.Tables[0];
}
}
}
}

48
ViewModel/MainWindowViewModel.cs

@ -82,7 +82,34 @@ namespace DyeingComputer.ViewModel
WorkNumder = "----------";
SYS_SET(); //crbl
SQL_data(); //读数据库
UPort(); //启动串口
if(S04!="1") UPort(); //启动串口
if (dt_TP.Rows.Count > 0)
{
MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show(Properties.Resources.RunningProcess, "800", MessageBoxButton.YesNo);
if (messageBoxResult == MessageBoxResult.Yes)
{
DataRow drEmployee = dt_TP.Select("RUN=1").First();
RUN_STEPID = drEmployee.Field<int>("Step");
STEP_START(drEmployee.Field<string>("StepID"),
drEmployee.Field<double>("Parameter1"),
drEmployee.Field<double>("Parameter2"),
drEmployee.Field<double>("Parameter3"),
drEmployee.Field<double>("Parameter4"),
drEmployee.Field<double>("Parameter5")
);
}
else
{
SQLiteHelpers = new SQLiteHelper(DBAddress);
SQLiteHelpers.Open();
SQLiteHelpers.Delete("RUN", null, null);
SQLiteHelpers.Close();
}//清楚任务列表
}//如果有未完成的工艺
CountDown(); //启动循环任务
_ = AsyncTcpServer.Main();
@ -140,6 +167,7 @@ namespace DyeingComputer.ViewModel
private static int MU01;//呼叫操作员
public static string S01;//机台号
public static string S03;//设备组
public static string S04;//展示模式
public static string S05;//管控模式
public static string S06;//通讯编码
public static int S16;//风机联动
@ -197,6 +225,7 @@ namespace DyeingComputer.ViewModel
S01 = Selet_sys("S01");//
S03 = Selet_sys("S03");//
S04 = Selet_sys("S04");//
S05 = Selet_sys("S05");//
S06 = Selet_sys("S06");//
S16 = Convert.ToInt16(Selet_sys("S16"));//工作信息
@ -542,6 +571,7 @@ namespace DyeingComputer.ViewModel
private bool Alert_yellow = false; //警报黄灯
private bool Alert_red = false; //警报红灯
private bool Alert_bell = false; //警报铃声
static Dictionary<string, object> updata_RUN = new Dictionary<string, object>();//
public static void STEP_START(string ID, double P1, double P2, double P3, double P4, double P5) //启动模块
{
STEP_ID = ID;
@ -740,6 +770,19 @@ namespace DyeingComputer.ViewModel
default:
break;
}
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
updata_RUN.Clear();
updata_RUN.Add("RUN", 0);
SQLiteHelpers.Update("RUN", updata_RUN, "RUN ='1'", null);//更新
updata_RUN.Clear();
updata_RUN.Add("RUN", 1);
SQLiteHelpers.Update("RUN", updata_RUN, "Step ='"+ RUN_STEPID + "'", null);//更新
dt_TP = SQLiteHelpers.ExecuteDataSet("select * from RUN", null).Tables[0];
SQLiteHelpers.Close();//关闭数据库
}
TimeSpan ts = new TimeSpan(00,00,01);//1秒间隔
@ -1808,6 +1851,7 @@ namespace DyeingComputer.ViewModel
dt_m = SQLiteHelpers.ExecuteDataSet("select * from IOName where type='M' order by ID", null).Tables[0];
dt_ParameterSet = SQLiteHelpers.ExecuteDataSet("select * from Parameters order by ParameterID asc", null).Tables[0];
dt_SysSet = SQLiteHelpers.ExecuteDataSet("select * from System order by ParameterID asc", null).Tables[0];
dt_TP = SQLiteHelpers.ExecuteDataSet("select * from RUN", null).Tables[0];
SQLiteHelpers.Close();
//创建dt_d主建
@ -1818,7 +1862,7 @@ namespace DyeingComputer.ViewModel
dt_a.PrimaryKey = dt_acols;
//创建dt_m主建
DataColumn[] dt_mcols = new DataColumn[] { dt_m.Columns["ID"] };
dt_m.PrimaryKey = dt_mcols;
dt_m.PrimaryKey = dt_mcols;
}
private async void IO_data()//刷新
{

Loading…
Cancel
Save