Browse Source

异常显示添加错误信息轮询显示

master
sc 3 months ago
parent
commit
bf161904a9
  1. 10
      UserClass/APILog.cs
  2. 6
      UserClass/ERRinf.cs
  3. 2
      View/TechnologicalProcessView.xaml
  4. 7
      View/TechnologicalProcessView.xaml.cs
  5. 27
      ViewModel/MainWindowViewModel.cs

10
UserClass/APILog.cs

@ -70,6 +70,16 @@ namespace DyeingComputer.UserClass
LOGDB("IOLog", API_LOG);//行插入
API_LOG.Clear();
}
public static void ERRlog(string WorkOrder, string ERRID, string MESSAGE, string Time)
{
Dictionary<string, object> API_LOG = new Dictionary<string, object>();//缓存函数
API_LOG.Add("NAME", WorkOrder);
API_LOG.Add("ERRID", ERRID);
API_LOG.Add("MESSAGE", MESSAGE);
API_LOG.Add("TIME", Time);
LOGDB("ERRLog", API_LOG);//行插入
API_LOG.Clear();
}
public static void LOGDB(string NAME, Dictionary<string, object> dat)//添加信息到队列
{

6
UserClass/ERRinf.cs

@ -23,6 +23,7 @@ namespace DyeingComputer.UserClass
if (i == 0)
{
dataTable.Rows.Add(ID,dat, DateTime.Now.ToString("yyMMddHHmmss"));
APILog.ERRlog(MainWindowViewModel.WorkNumder.ToString(),ID,dat, DateTime.Now.ToString("yy_MM_dd_HH:mm:ss"));
}
}
public static void ERRinf_d(DataTable dataTable, string dat)//删除
@ -33,9 +34,12 @@ namespace DyeingComputer.UserClass
dataTable.Rows.Remove(dataTable.Select("ID='" + dat + "'").First());
}
}
public static int i=0;
public static string ERRinf_r(DataTable dataTable)//读取
{
string index = dataTable.Rows[0].Field<string>("INF");
if (i >= dataTable.Rows.Count) { i = 0; } else { i++; }
string index = dataTable.Rows[i].Field<string>("INF");
return index;
}
}

2
View/TechnologicalProcessView.xaml

@ -90,7 +90,7 @@
</DataGrid>
<Grid Width="600" Margin="0,40,0,0" HorizontalAlignment="Left" >
<ScrollViewer VerticalScrollBarVisibility="Auto" PanningMode="VerticalOnly">
<TextBlock x:Name="log" TextWrapping="Wrap" FontSize="25" Background="White"
<TextBlock x:Name="log" FontSize="25" Background="White"
Text="{Binding Sys_log}" />
</ScrollViewer>
<DataGrid x:Name="Receip" IsHitTestVisible="False" Visibility="Collapsed"

7
View/TechnologicalProcessView.xaml.cs

@ -199,7 +199,6 @@ namespace DyeingComputer.View
Parameter_set.ItemsSource = tblDatas.DefaultView;
}
private void Parameter_set_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e)
{
string VID;
@ -247,7 +246,6 @@ namespace DyeingComputer.View
}
}//参数设置
DataTable tblDatas = new DataTable("Datas");
public static object workName;
public static SQLiteHelper SQLiteHelpers = null; //定义数据库
@ -284,7 +282,6 @@ namespace DyeingComputer.View
}
SQLiteHelpers.Close(); //关闭连接
}
private void TechnologicalProcess_sql()
{
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
@ -309,7 +306,6 @@ namespace DyeingComputer.View
// FocusManager.SetFocusedElement(Grid, Grid);
// Grid.DataContext = new MainWindowViewModel();
}
private void UserControl_KeyDown(object sender, KeyEventArgs e) //键盘监控
{
if (errTabler.Rows.Count == 0)//无错误信息
@ -384,8 +380,7 @@ namespace DyeingComputer.View
APILog.LOGlog(MainWindowViewModel.WorkNumder.ToString(), "UserActions", "STEP = " + n,
"StepID="+ e.StepID + ";StepName="+ e.StepNAME+";P1="+ e.P1+
";P2="+ e.P2+";P3="+ e.P3+";P4="+ e.P4+";P5="+ e.P5);
User_Button = true;
User_Button = true;
}
public static void Dat()//行号刷新
{

27
ViewModel/MainWindowViewModel.cs

@ -219,8 +219,6 @@ namespace DyeingComputer.ViewModel
execute:ProgramgroupView_run_ );//开始/暂停事件
ProgramgroupView_stop = new RelayCommand(
execute: ProgramgroupView_stop_);//结束事件
}
DataTable dt_con = new DataTable();
@ -357,7 +355,6 @@ namespace DyeingComputer.ViewModel
WORK_RUN = 2;//
SETP_runtime = true;
APILog.LOGlog(WorkNumder.ToString(), "UserActions", "WORK_RUN = RUN", WORK_RUN.ToString());
}
else
{
@ -420,6 +417,7 @@ namespace DyeingComputer.ViewModel
if (errTabler.Rows.Count!=0)
{
Status_Str = ERRinf.ERRinf_r(errTabler);
Alert_red = true;
Alert_bell = true;
}
@ -445,11 +443,11 @@ namespace DyeingComputer.ViewModel
if (Selet_dtd("2013")) { ERRinf.ERRinf_w(errTabler, Resources.Fault + ":" + Resources.OtherCircuits, "ERR108"); } //其它电器故障
else { ERRinf.ERRinf_d(errTabler, "ERR108"); }
if (Selet_dtd("2014")) { ERRinf.ERRinf_w(errTabler, Resources.Fault + ":" + Resources.Pump + "-1", "ERR104-1"); } //加料泵
else { ERRinf.ERRinf_d(errTabler, "ERR100"); }
else { ERRinf.ERRinf_d(errTabler, "ERR104-1"); }
if (Selet_dtd("2015")) { ERRinf.ERRinf_w(errTabler, Resources.Fault + ":" + Resources.Pump + "-2", "ERR104-2"); } //加料泵
else { ERRinf.ERRinf_d(errTabler, "ERR100"); }
else { ERRinf.ERRinf_d(errTabler, "ERR104-2"); }
if (Selet_dtd("2016")) { ERRinf.ERRinf_w(errTabler, Resources.Fault + ":" + Resources.Pump + "-3", "ERR104-3"); } //加料泵
else { ERRinf.ERRinf_d(errTabler, "ERR100"); }
else { ERRinf.ERRinf_d(errTabler, "ERR104-3"); }
}
uint TX_t;
@ -565,7 +563,6 @@ namespace DyeingComputer.ViewModel
if (timer5s_ >=10) { timer5s_ = 0; Tick_Event_5S(); }
if (LINK_OK) IO_data();
}
void Chart()
@ -841,7 +838,7 @@ namespace DyeingComputer.ViewModel
}
else if (THL_mode == 1)//升温
{
if (STEP_P1 > TEMP_co) TEMP_co = TEMP_co + (STEP_P2 / 600);
if (STEP_P1 > TEMP_co) TEMP_co = TEMP_co + (STEP_P2 / 60);
TO = pid.PID_iterate(TEMP_co, T, ts);
if (TO < 0) TO = 0;
if ((TEMP_co < T) || (T - TEMP_co > 3)) TO = 0;
@ -852,24 +849,25 @@ namespace DyeingComputer.ViewModel
}
else
{
TIME_M = Convert.ToInt16((STEP_P1 - T) / (STEP_P2 / 10));
TIME_M = Convert.ToInt16((STEP_P1 - T) / STEP_P2 );
}
if (errTabler.Rows.Count == 0)
{
Status_Str = Resources.Heats + ":" + Resources.Target + Resources.Temperature + string.Format(" {0:###.#}", STEP_P1) + "°C";
if ((TEMP_co - T) > 5)
{
Status_Str = Status_Str + "[" + Resources.Heats + Resources.LnsufficientPower + "]";
ERRinf.ERRinf_w(errTabler, Status_Str + "[" + Resources.Heats + Resources.LnsufficientPower + "]", "201-1");//写入
}
else
{
ERRinf.ERRinf_d(errTabler, "201-1");//
Status_Str = Status_Str + Resources.Expected + string.Format(" {0:D2}", TIME_M) + Resources.Min;
}
}
}
else if (THL_mode == 2)//降温
{
if (STEP_P1 < TEMP_co) TEMP_co = TEMP_co - (STEP_P2 / 600);
if (STEP_P1 < TEMP_co) TEMP_co = TEMP_co - (STEP_P2 / 60);
TO = pid.PID_iterate(TEMP_co, T, ts);
if (TO > 0) TO = 0;
TO = Math.Abs(TO);
@ -880,17 +878,18 @@ namespace DyeingComputer.ViewModel
}
else
{
TIME_M = Convert.ToInt16((T - STEP_P1) / (STEP_P2 / 10));
TIME_M = Convert.ToInt16((T - STEP_P1) / STEP_P2 );
}
if (errTabler.Rows.Count == 0)
{
Status_Str = Resources.Cooling + ":" + Resources.Target + Resources.Temperature + string.Format(" {0:###.#}", STEP_P1) + "°C";
if ((T - TEMP_co) > 5)
{
Status_Str = Status_Str + "[" + Resources.Cooling + Resources.LnsufficientPower + "]";
ERRinf.ERRinf_w(errTabler, Status_Str + "[" + Resources.Cooling + Resources.LnsufficientPower + "]", "201-2");//写入
}
else
{
ERRinf.ERRinf_d(errTabler, "201-2");//
Status_Str = Status_Str + Resources.Expected + string.Format(" {0:D2}", TIME_M) + Resources.Min;
}
}
@ -1571,8 +1570,6 @@ namespace DyeingComputer.ViewModel
}
else if (WORK_RUN == 1)
{
SETP_runtime = false;
STEP_finish = false;
Status_Str = Resources.Paused;
Updata_dtm("1004", 0);
Updata_dtd("3009", false);

Loading…
Cancel
Save