Exemple #1
0
        /// <summary>
        /// 页面切换业务处理方法
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        public void ChangePageBusinessProcess(object source, System.Timers.ElapsedEventArgs e)
        {
            OverrideTimer tt = (OverrideTimer)source;

            tt.Stop();
            int pageNo = 0;

            try
            {
                if (panel1.Visible)
                {
                    pageNo = 1;
                }
                else if (panel16.Visible)
                {
                    pageNo = 2;
                    //panel1.Visible = true;
                    //panel13.Visible = false;
                }
                else if (panel13.Visible)
                {
                    pageNo = 3;
                }
                switch (pageNo)
                {
                case 1:

                    BeginInvoke((MethodInvoker) delegate() { this.panel13.Visible = false; });
                    BeginInvoke((MethodInvoker) delegate() { this.panel1.Visible = false; });
                    BeginInvoke((MethodInvoker) delegate() { this.panel16.Visible = true; });
                    //   BeginInvoke((MethodInvoker)delegate() { this.panel13.BringToFront(); });
                    break;

                case 2:

                    BeginInvoke((MethodInvoker) delegate() { this.panel13.Visible = true; });
                    BeginInvoke((MethodInvoker) delegate() { this.panel16.Visible = false; });
                    BeginInvoke((MethodInvoker) delegate() { this.panel1.Visible = false; });
                    //    BeginInvoke((MethodInvoker)delegate() { this.panel16.BringToFront(); });
                    break;

                case 3:

                    BeginInvoke((MethodInvoker) delegate() { this.panel16.Visible = false; });
                    BeginInvoke((MethodInvoker) delegate() { this.panel13.Visible = false; });
                    BeginInvoke((MethodInvoker) delegate() { this.panel1.Visible = true; });
                    //    BeginInvoke((MethodInvoker)delegate() { this.panel1.BringToFront(); });
                    break;
                }
            }
            catch
            {
            }
            finally
            {
                tt.Start();
            }
        }
Exemple #2
0
        /// <summary>
        /// 显示产品状态的业务方法
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
        public void showProductionState(object source, System.Timers.ElapsedEventArgs e)
        {
            OverrideTimer tt = (OverrideTimer)source;

            tt.Stop();
            try
            {
                //显示产品种类
                BeginInvoke((MethodInvoker) delegate() { LB_ProductionType.Text = productionTypeconfig; });

                //显示今日计划
                BeginInvoke((MethodInvoker) delegate() { LB_TodayPlan.Text = productionTodayPlan + " ea"; });

                //显示已经完成的产量
                int fishedControl = Convert.ToInt32(BussinessFacde.GetOpcConfigXml("", "1", "2"));
                //if(Convert.ToInt32(OPC.ReadItem(fishedControl).ToString())==1)
                //{
                string    sql = "select distinct sn from OfflinePack where DT between  '" + DateTime.Now.ToString("yyyy.MM.dd") + " 00:00:00 ' and  '" + DateTime.Now.ToString("yyyy.MM.dd  HH:mm:ss") + "'";
                DataTable dt  = new DataTable();
                dt = db.ExecuteDataTable(sql);
                int finishedNumber = dt.Rows.Count;

                BeginInvoke((MethodInvoker) delegate() { LB_Fished.Text = finishedNumber + " ea"; });
                double fishedP = (double)finishedNumber / Convert.ToInt32(productionTodayPlan);

                BeginInvoke((MethodInvoker) delegate() { LB_FishenP.Text = fishedP.ToString("P"); });

                //}
                int    moduleAddr = Convert.ToInt32(BussinessFacde.GetOpcConfigXml("", "4", "2"));
                string moduleS    = OPC.ReadItem(moduleAddr).ToString();
                if (moduleS == "1")
                {
                    BeginInvoke((MethodInvoker) delegate() { moduleStatus.Text = showText; });
                    BeginInvoke((MethodInvoker) delegate() { moduleStatus.ForeColor = Color.Red; });
                }
                else
                {
                    BeginInvoke((MethodInvoker) delegate() { moduleStatus.Text = ""; });
                }
            }
            catch
            {
            }
            finally
            {
                tt.Start();
            }
        }
Exemple #3
0
        /// <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;
        }
Exemple #4
0
        /// <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();
            }
        }
Exemple #5
0
        /// <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;
        }