Exemple #1
0
        private void TestAcq()
        {
            int ems = 29;


            for (int i = 0; i < 20; i++)
            {
                Thread.Sleep(100);

                if (i == 10)
                {
                    ems += 1;
                    Thread.Sleep(500);
                }

                if (i == 15)
                {
                    ems += 1;
                    Thread.Sleep(500);
                }

                AcqLineItemMDL acqlineMDL = new AcqLineItemMDL();

                EMSUnit unit = null;

                acqlineMDL.PLID = "01";
                //  TimeRange range = plineCaculator.GetTimeRangByAcqTime(DateTime.Now);

                ///采集数据创建并设置唯一编号


                acqlineMDL.TGNAME = "01";
                acqlineMDL.SetTID(DateTime.Now, acqlineMDL.PLID, "01", "01");
                acqlineMDL.PR_COUNT    = 1;
                acqlineMDL.EMS         = ems;
                acqlineMDL.UPDATE_TIME = DateTime.Now;
                //AddTraceInfo(acqlineMDL, "ST440", 11);

                //判断计算器时间
                if (plineCaculator == null)
                {
                    plineCaculator = new ProductLineCaculator();
                    plineCaculator.ReloadPlanUnits();
                    ///初始化EMS编号
                    // ems = ReadEMS();

                    unit = new EMSUnit(ems, DateTime.Now);

                    plineCaculator.ems = unit;
                }



                unit = new EMSUnit(ems, DateTime.Now);



                //检查是否需要重新加载计算区间
                plineCaculator.CheckReload(DateTime.Now, unit);

                DateTime acqTime = DateTime.Now;

                //获取当前数据输入的采集区间
                TimeRange range = plineCaculator.GetTimeRangByAcqTime(DateTime.Now);

                ///采集数据创建并设置唯一编号
                acqlineMDL.TGNAME = range.SEQ;
                acqlineMDL.SetTID(DateTime.Now, acqlineMDL.PLID, range.SEQ, "01");
                acqlineMDL.PR_COUNT    = 1;
                acqlineMDL.EMS         = ems;
                acqlineMDL.UPDATE_TIME = DateTime.Now;



                //更新采集数据
                // plineCaculator.UpdateAcqData(ref acqlineMDL, index, curCount);
                plineCaculator.UpdateAcqUnitData(ref acqlineMDL);

                CLog.WriteStationLog("ST400", string.Format("更新数据完成:{0}的计算数量已提交", acqlineMDL.PR_COUNT));


                if (plineCaculator.IsChangedEMS(ems))
                {
                    //处理换型记录
                    plineCaculator.ProcessAcqLineData(acqlineMDL.PLID, acqlineMDL.UNITID, unit);

                    CLog.WriteStationLog("ST400", string.Format("换型:{0}", acqlineMDL.PLID));
                    ////更改换型时间
                    //AcqLineDAL updateDal = new AcqLineDAL();
                    //updateDal.UpdateAclineUnitByLastUnit(DateTime.Now, acqlineMDL.PLID);
                }
                else
                {
                    //plineCaculator.LoadEMSTime(unit.SetTime);
                    plineCaculator.LoadEMSTime(DateTime.Now);
                }
            }
        }
Exemple #2
0
        private void IntialPalnData()
        {
            ProductLineCaculator plc = new ProductLineCaculator();

            plc.ReLoad();

            int line = Convert.ToInt32(BaseVariable.LineID);

            string plainid = DateTime.Now.ToString("yyyyMMdd") + string.Format("{0:D2}", line);

            this.planMDL = ReloadNewPlan(plainid);

            this.planMDL.PLINE = string.Format("{0:D2}", line);


            GraphPane myPane = zg1.GraphPane;

            myPane.Fill = new Fill(Color.Black);

            myPane.XAxis.Title.Text = "Section of plan";
            myPane.XAxis.Title.FontSpec.FontColor = Color.White;
            myPane.XAxis.Type         = AxisType.Date;
            myPane.XAxis.Scale.Format = "HH:mm";



            myPane.YAxis.Title.Text = "Changeover Time";
            myPane.YAxis.Title.FontSpec.FontColor = Color.White;


            int type = 1;

            List <OPMDL> opItems = null;

            if (!planMDL.GetTimeRange(1).IsInRange(DateTime.Now))
            {
                opItems = this.planMDL.OP2_ITEMS;
                type    = 2;
            }
            else
            {
                opItems = this.planMDL.OP1_ITEMS;
            }

            LineDTDAL dtDal = new LineDTDAL();

            ChangeTimeDAL ctDal = new ChangeTimeDAL();

            TimeRange tRange = new TimeRange(opItems[0].IIME_RANGE.StartTime, opItems[opItems.Count - 1].IIME_RANGE.EndTime);

            List <TimeRange> dtrangs = dtDal.GetTimeRangeByRange(this.planMDL.PLINE, tRange);



            PointPairList list       = new PointPairList();
            PointPairList changelist = new PointPairList();



            Color changeColor = Color.White;



            for (int i = 0; i < opItems.Count; i++)
            {
                int haveDt = 0;

                if (dtrangs != null && dtrangs.Count > 0)
                {
                    foreach (TimeRange item in dtrangs)
                    {
                        if (item.IsInFullRange(opItems[i].IIME_RANGE.StartTime, opItems[i].IIME_RANGE.EndTime))
                        {
                            haveDt = 1;
                            continue;
                        }
                    }
                }


                // double x = (double)i * 5.0;
                double x = (double)new XDate(opItems[i].IIME_RANGE.StartTime);

                int count = 0;

                if (haveDt <= 0)
                {
                    count = ctDal.GetChangeTime(opItems[i].LINEID.Substring(opItems[i].LINEID.Length - 2, 2), opItems[i].IIME_RANGE);
                }


                double changeOver = 0;

                if (count > 0)
                {
                    //除以分钟
                    changeOver = Math.Round((double)count / (double)60, 2);

                    if (changeOver > 18)
                    {
                        changeOver = 18;
                    }

                    if (changeOver > 10)
                    {
                        changeColor = Color.Red;
                    }
                }

                double y = 5;

                changelist.Add(x, changeOver);
                list.Add(x, y);
            }

            LineItem defualtCurve = myPane.AddCurve("Standard",
                                                    list, Color.Yellow, SymbolType.None);

            LineItem changeOverCurve = myPane.AddCurve("ChangeOver",
                                                       changelist, changeColor, SymbolType.Circle);

            // changeOverCurve.Symbol.Fill.Color = Color.White;
            changeOverCurve.Line.Width  = 2;
            changeOverCurve.Symbol.Fill = new Fill(changeColor);


            defualtCurve.Label.IsVisible    = false;
            changeOverCurve.Label.IsVisible = false;

            myPane.XAxis.Scale.FontSpec.FontColor = Color.White;
            myPane.XAxis.Title.FontSpec.FontColor = Color.White;

            myPane.XAxis.MajorGrid.IsVisible      = true;
            myPane.YAxis.Scale.FontSpec.FontColor = Color.White;
            myPane.YAxis.Title.FontSpec.FontColor = Color.White;
            myPane.YAxis.Scale.Max = 18;
            myPane.YAxis.Scale.Min = -1;



            //// Fill the axis background with a gradient
            myPane.Chart.Fill = new Fill(Color.Black, Color.Black, 45.0f);


            //// Enable scrollbars if needed
            zg1.IsShowHScrollBar  = false;
            zg1.IsShowVScrollBar  = false;
            zg1.IsAutoScrollRange = true;
            zg1.IsScrollY2        = true;

            //// OPTIONAL: Show tooltips when the mouse hovers over a point
            zg1.IsShowPointValues = true;
            zg1.PointValueEvent  += new ZedGraphControl.PointValueHandler(MyPointValueHandler);


            SetSize();

            //// Tell ZedGraph to calculate the axis ranges
            //// Note that you MUST call this after enabling IsAutoScrollRange, since AxisChange() sets
            //// up the proper scrolling parameters
            zg1.AxisChange();
            zg1.IsEnableHZoom     = false;
            zg1.IsEnableVZoom     = false;
            zg1.IsEnableWheelZoom = false;
            //// Make sure the Graph gets redrawn
            zg1.Invalidate();
        }