/// <summary> /// 开启业务处理的线程 /// </summary> public void StartBussinessThread() { //开启页面跳转线程 String speed = BussinessFacde.GetConfigXml("Speed"); //获取配置的页面跳转速度 if (!String.IsNullOrEmpty(speed) && Convert.ToInt32(speed) > 0) //配置的速度不为空 { OverrideTimer tt = new OverrideTimer(); //将用户配置的时间转换为毫秒 int speedControl = Convert.ToInt32(speed) * 1000; tt.Interval = speedControl; tt.Elapsed += new System.Timers.ElapsedEventHandler(ChangePageBusinessProcess); tt.Enabled = true; tt.AutoReset = false; } else //如果用户没有配置,则默认10秒切换页面 { OverrideTimer tt = new OverrideTimer(); //将用户配置的时间转换为毫秒 tt.Interval = 10000; tt.Elapsed += new System.Timers.ElapsedEventHandler(ChangePageBusinessProcess); tt.Enabled = true; tt.AutoReset = false; } //开启地址监听线程,实时刷新看板数据 String stationText = BussinessFacde.GetConfigXml("Station"); if (!String.IsNullOrEmpty(stationText)) { String[] stationArray = stationText.Split(','); for (int i = 0; i < stationArray.Length; i++) { if (i < 8) //一个页面放8个工位的图片 { if (i < 4) { StationPenalControl spc = new StationPenalControl(); panel1.Controls.Add(spc); spc.Location = new Point(28 + 200 * i, 139); spc.LB_PanelStation.Text = "OP" + stationArray[i]; TimeSpan time = TimeSpan.Parse("00:00:00"); TimeHelper myTime = new TimeHelper(time, spc.LB_ErrorTimes); OverrideTimer tt = new OverrideTimer(); tt.MYTIME = myTime; tt.Spc = spc; tt.Type = "1"; tt.Station = stationArray[i]; tt.Interval = 1000; tt.Elapsed += new System.Timers.ElapsedEventHandler(ShowBusinessProcess); tt.Enabled = true; tt.AutoReset = false; } else { StationPenalControl spc = new StationPenalControl(); spc.LB_PanelStation.Text = "OP" + stationArray[i]; panel1.Controls.Add(spc); spc.Location = new Point(28 + 200 * (i - 4), 139 * 2); TimeSpan time = TimeSpan.Parse("00:00:00"); TimeHelper myTime = new TimeHelper(time, spc.LB_ErrorTimes); OverrideTimer tt = new OverrideTimer(); tt.MYTIME = myTime; tt.Spc = spc; tt.Type = "1"; tt.Station = stationArray[i]; tt.Interval = 1000; tt.Elapsed += new System.Timers.ElapsedEventHandler(ShowBusinessProcess); tt.Enabled = true; tt.AutoReset = false; } } else if (i >= 8 && i < 16) { if (i < 12) { StationPenalControl spc = new StationPenalControl(); panel16.Controls.Add(spc); spc.Location = new Point(28 + 200 * (i - 8), 139); spc.LB_PanelStation.Text = "OP" + stationArray[i]; TimeSpan time = TimeSpan.Parse("00:00:00"); TimeHelper myTime = new TimeHelper(time, spc.LB_ErrorTimes); OverrideTimer tt = new OverrideTimer(); tt.MYTIME = myTime; tt.Spc = spc; tt.Type = "1"; tt.Station = stationArray[i]; tt.Interval = 1000; tt.Elapsed += new System.Timers.ElapsedEventHandler(ShowBusinessProcess); tt.Enabled = true; tt.AutoReset = false; } else { StationPenalControl spc = new StationPenalControl(); panel16.Controls.Add(spc); spc.Location = new Point(28 + 200 * (i - 12), 139 * 2); spc.LB_PanelStation.Text = "OP" + stationArray[i]; TimeSpan time = TimeSpan.Parse("00:00:00"); TimeHelper myTime = new TimeHelper(time, spc.LB_ErrorTimes); OverrideTimer tt = new OverrideTimer(); tt.MYTIME = myTime; tt.Spc = spc; tt.Type = "1"; tt.Station = stationArray[i]; tt.Interval = 1000; tt.Elapsed += new System.Timers.ElapsedEventHandler(ShowBusinessProcess); tt.Enabled = true; tt.AutoReset = false; } } // tt.Type = BussinessFacde.GetConfigXml("ProductionType"); // tt.Plan = BussinessFacde.GetConfigXml("TodayPlan"); } } //开启产品上产状态线程 OverrideTimer t1 = new OverrideTimer(); //将用户配置的时间转换为毫秒 t1.Interval = 2000; t1.Elapsed += new System.Timers.ElapsedEventHandler(showProductionState); t1.Enabled = true; t1.AutoReset = false; }
/// <summary> /// 显示设备状态信息 /// </summary> /// <param name="source"></param> /// <param name="e"></param> public void ShowBusinessProcess(object source, System.Timers.ElapsedEventArgs e) { OverrideTimer tt = (OverrideTimer)source; tt.Stop(); try { String pruductionType = tt.Type; String todayPlan = tt.Plan; String station = tt.Station; StationPenalControl spc = tt.Spc; TimeHelper myTime = tt.MYTIME; //显示工位 // BeginInvoke((MethodInvoker)delegate() { spc.LB_PanelStation.Text = "OP "+station; }); int eqstateControl = Convert.ToInt32(BussinessFacde.GetOpcConfigXml(station, "1", "1")); String eqstate = OPC.ReadItem(eqstateControl).ToString(); //获取PLC传过来的设备状态信息 if (eqstate == "1") //表示设备正常 { BeginInvoke((MethodInvoker) delegate() { spc.panel1.BackColor = System.Drawing.Color.Lime; }); if (spc.LB_ErrorTimes.Text != "") { BeginInvoke((MethodInvoker) delegate() { spc.LB_ErrorTimes.Text = ""; }); BeginInvoke((MethodInvoker) delegate() { spc.LB_ErrorNotice.Text = ""; }); myTime.Close(); } } else if (eqstate == "2") //设备故障 { BeginInvoke((MethodInvoker) delegate() { spc.panel1.BackColor = System.Drawing.Color.Red; }); BeginInvoke((MethodInvoker) delegate() { spc.LB_ErrorNotice.Text = "停机时间:"; }); //显示停机时间 //for (int i = 1; i <= 100; i++) //{ // if (i == 100) // { // stopSecondTimes++; // } // stopMinTimers = i; // BeginInvoke((MethodInvoker)delegate() { spc.LB_ErrorTimes.Text = stopSecondTimes + "'" + stopMinTimers+"''"; }); //} if (spc.LB_ErrorTimes.Text != "") { } else { myTime.Open(); } } else if (eqstate == "3") //设备缺料 { BeginInvoke((MethodInvoker) delegate() { spc.panel1.BackColor = System.Drawing.Color.Yellow; }); BeginInvoke((MethodInvoker) delegate() { spc.LB_ErrorNotice.Text = "等待时间:"; }); //显示等待时间 //for (int i = 1; i <= 100; i++) //{ // if (i == 100) // { // stopSecondTimes++; // } // stopMinTimers = i; // BeginInvoke((MethodInvoker)delegate() { spc.LB_ErrorTimes.Text = stopSecondTimes + "'" + stopMinTimers + "''"; }); //} if (spc.LB_ErrorTimes.Text != "") { } else { myTime.Open(); } } } catch { } finally { tt.Start(); } }
/// <summary> /// 开启业务处理的线程 /// </summary> public void StartBussinessThread() { //开启页面跳转线程 String speed = BussinessFacde.GetConfigXml("Speed"); //获取配置的页面跳转速度 if (!String.IsNullOrEmpty(speed) && Convert.ToInt32(speed) > 0) //配置的速度不为空 { OverrideTimer tt = new OverrideTimer(); //将用户配置的时间转换为毫秒 int speedControl = Convert.ToInt32(speed) * 1000; tt.Interval = speedControl; tt.Elapsed += new System.Timers.ElapsedEventHandler(ChangePageBusinessProcess); tt.Enabled = true; tt.AutoReset = false; } else //如果用户没有配置,则默认10秒切换页面 { OverrideTimer tt = new OverrideTimer(); //将用户配置的时间转换为毫秒 tt.Interval = 10000; tt.Elapsed += new System.Timers.ElapsedEventHandler(ChangePageBusinessProcess); tt.Enabled = true; tt.AutoReset = false; } //开启地址监听线程,实时刷新看板数据 String stationText = BussinessFacde.GetConfigXml("Station"); if (!String.IsNullOrEmpty(stationText)) { String[] stationArray = stationText.Split(','); for (int i = 0; i < stationArray.Length; i++) { if (i < 8) //一个页面放8个工位的图片 { if (i < 4) { StationPenalControl spc = new StationPenalControl(); panel1.Controls.Add(spc); spc.Location = new Point(28 + 200 * i, 139); spc.LB_PanelStation.Text = "OP" + stationArray[i]; TimeSpan time = TimeSpan.Parse("00:00:00"); TimeHelper myTime = new TimeHelper(time, spc.LB_ErrorTimes); OverrideTimer tt = new OverrideTimer(); tt.MYTIME = myTime; tt.Spc = spc; tt.Type = "1"; tt.Station = stationArray[i]; tt.Interval = 1000; tt.Elapsed += new System.Timers.ElapsedEventHandler(ShowBusinessProcess); tt.Enabled = true; tt.AutoReset = false; } else { StationPenalControl spc = new StationPenalControl(); spc.LB_PanelStation.Text = "OP" + stationArray[i]; panel1.Controls.Add(spc); spc.Location = new Point(28 + 200 *(i-4), 139*2); TimeSpan time = TimeSpan.Parse("00:00:00"); TimeHelper myTime = new TimeHelper(time, spc.LB_ErrorTimes); OverrideTimer tt = new OverrideTimer(); tt.MYTIME = myTime; tt.Spc = spc; tt.Type = "1"; tt.Station = stationArray[i]; tt.Interval = 1000; tt.Elapsed += new System.Timers.ElapsedEventHandler(ShowBusinessProcess); tt.Enabled = true; tt.AutoReset = false; } } else if (i >= 8 && i<16) { if (i < 12) { StationPenalControl spc = new StationPenalControl(); panel16.Controls.Add(spc); spc.Location = new Point(28 + 200 * (i-8), 139); spc.LB_PanelStation.Text = "OP" + stationArray[i]; TimeSpan time = TimeSpan.Parse("00:00:00"); TimeHelper myTime = new TimeHelper(time, spc.LB_ErrorTimes); OverrideTimer tt = new OverrideTimer(); tt.MYTIME = myTime; tt.Spc = spc; tt.Type = "1"; tt.Station = stationArray[i]; tt.Interval = 1000; tt.Elapsed += new System.Timers.ElapsedEventHandler(ShowBusinessProcess); tt.Enabled = true; tt.AutoReset = false; } else { StationPenalControl spc = new StationPenalControl(); panel16.Controls.Add(spc); spc.Location = new Point(28 + 200 * (i-12), 139*2); spc.LB_PanelStation.Text = "OP" + stationArray[i]; TimeSpan time = TimeSpan.Parse("00:00:00"); TimeHelper myTime = new TimeHelper(time, spc.LB_ErrorTimes); OverrideTimer tt = new OverrideTimer(); tt.MYTIME = myTime; tt.Spc = spc; tt.Type = "1"; tt.Station = stationArray[i]; tt.Interval = 1000; tt.Elapsed += new System.Timers.ElapsedEventHandler(ShowBusinessProcess); tt.Enabled = true; tt.AutoReset = false; } } // tt.Type = BussinessFacde.GetConfigXml("ProductionType"); // tt.Plan = BussinessFacde.GetConfigXml("TodayPlan"); } } //开启产品上产状态线程 OverrideTimer t1 = new OverrideTimer(); //将用户配置的时间转换为毫秒 t1.Interval = 800; t1.Elapsed += new System.Timers.ElapsedEventHandler(showProductionState); t1.Enabled = true; t1.AutoReset = false; }