Esempio n. 1
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();
            }
        }
Esempio n. 2
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();
            }
        }