using SlMesDbIterface; using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace MesWork { /// /// /// public partial class Temp { } /// /// 延时刷新 /// public partial class MesWorkForm { /// /// 刷新 /// /// /// private void timer_OnLine_Show_Tick(object sender, EventArgs e) { timer_OnLine_Show.Enabled = false; Show_OnLineState(); label_RunSort.Text = $"{RunSort}"; timer_OnLine_Show.Enabled = true; } /// /// 获取数据库连接状态 /// private void CommunicationCheckOnLine() { //源数据库 new Thread(new ThreadStart(delegate () { while (true) { try { MesWorkForm.OnLine_Sql = SqlOperation.ExecuteSql("select getdate()", out DataTable dt,out string error); } catch (Exception) { } Thread.Sleep(5000); } })) { IsBackground = true }.Start(); } /// /// 显示通讯状态 /// /// /// private void OnLineState_C(PictureBox pb, bool onLine) { pb.Image = onLine ? global::CentralControl.Properties.Resources.连接状态 : global::CentralControl.Properties.Resources.断开状态; } /// /// 显示通讯状态 /// private void Show_OnLineState() { //状态显示 OnLineState_C(pb_OnLine_Sql, MesWorkForm.OnLine_Sql); } /// /// 刷新 /// /// /// private void timer_ShowStation_Tick(object sender, EventArgs e) { timer_ShowStation.Enabled = false; RefreshShowStation(); timer_ShowStation.Enabled = true; } /// /// 显示工位状态 /// public static void RefreshShowStation() { try { foreach (DictionaryEntry item in ht_Station_Content) { var stationName = item.Key.ToString(); var control = (Panel)item.Value; var auto = ht_Signal__Station_Auto[stationName].ToString().ToLower(); var running = ht_Signal__Station_Running[stationName].ToString().ToLower(); var manual = ht_Signal__Station_Manual[stationName].ToString().ToLower(); var alarm = ht_Signal__Station_Alarm[stationName].ToString().ToLower(); var offLine = ht_Signal__Station_OffLine[stationName].ToString().ToLower(); if (ValueT(offLine)) { if (ValueT(auto)) { control.BackColor = color_Yellow; } if (ValueT(running)) { control.BackColor = color_Green; } if (ValueT(manual)) { control.BackColor = color_Faw; } if (ValueT(alarm)) { control.BackColor = color_Red; } } else { control.BackColor = color_Bad; } } } catch (Exception err) { } } /// /// 值处理函数 /// /// /// public static bool ValueT(string value) { bool success = false; if (value == "true" | value == "1") { success = true; } return success; } /// /// 显示报警信息 /// 临时!!!! /// /// /// private void timer_ShowAlarm_Tick(object sender, EventArgs e) { timer_ShowAlarm.Enabled = false; //try //{ // var sql = // $" SELECT [StationName],[AlarmCode],[AlarmTime],[SureTime] FROM [SP_Curr_Alarm]" + // $" ORDER BY [ID] DESC"; // SqlOperation.ExecuteSql(sql, out DataTable dt_Alarm, out string error); // dgv_Alarm.DataSource = dt_Alarm; //} //catch (Exception err) { } //try //{ // var sql = // $" SELECT [StationName],[AlarmCode],[AlarmTime],[SureTime] FROM [SP_Curr_Alarm_Andon]" + // $" ORDER BY [ID] DESC"; // SqlOperation.ExecuteSql(sql, out DataTable dt_Alarm_Andon, out string error); // dgv_Alarm_Andon.DataSource = dt_Alarm_Andon; //} //catch (Exception err) { } timer_ShowAlarm.Enabled = true; } /// /// 布局按钮显示 /// /// public void Visible_SaveLyoutBtn(bool visible) { btn_SaveLyout.Visible = visible; } } }