Exemple #1
0
        private void GenerateTileButtons(List <WIPStationProductionStatus> workUnits)
        {
            if (buttons.Count == 0)
            {
                int intButtonWidth = 0;
                int intButtonTop   = 0;
                int intButtonLeft  = 0;

                for (int i = 0; i < workUnits.Count; i++)
                {
                    WIPStationProductionStatus station = workUnits[i].Clone();
                    ucWorkUnit button = new ucWorkUnit();

                    if (intButtonWidth == 0)
                    {
                        intButtonWidth =
                            button.Width *
                            workUnits.Count +
                            widthButtonSplitter *
                            (workUnits.Count - 1);
                        intButtonTop =
                            (xtraScrollableControl.Height - button.Height) / 2;
                        intButtonLeft =
                            (xtraScrollableControl.Width - intButtonWidth) / 2;
                        if (intButtonLeft < 0)
                        {
                            intButtonLeft = 0;
                        }
                    }

                    button.Top  = intButtonTop;
                    button.Left = intButtonLeft + (button.Width + widthButtonSplitter) * i;

                    button.Station         = station;
                    button.Parent          = xtraScrollableControl;
                    button.MouseLeftClick += new EventHandler(ItemClick);

                    buttons.Add(button);
                }
            }
            else
            {
                for (int i = 0; i < workUnits.Count; i++)
                {
                    if (i >= buttons.Count)
                    {
                        break;
                    }
                    buttons[i].Station = workUnits[i].Clone();
                }
            }
        }
Exemple #2
0
        private void RedrawingSPCChart(
            XtraTabControl tabControl,
            string t107Code,
            string pwoNo,
            int t47LeafID,
            int t216LeafID,
            int t133LeafID,
            int t20LeafID)
        {
            foreach (XtraTabPage page in tabControl.TabPages)
            {
                if (page.Tag == null)
                {
                    continue;
                }

                WIPStationProductionStatus workUnit = page.Tag as WIPStationProductionStatus;
                if (workUnit.T107Code == t107Code)
                {
                    if (tabControl.SelectedTabPage != page)
                    {
                        tabControl.SelectedTabPage = page;
                    }
                    else
                    {
                        tcMain_SelectedPageChanged(
                            tcMain,
                            new TabPageChangedEventArgs(
                                tabControl.SelectedTabPage,
                                page));
                    }
                    //foreach (Control control in page.Controls)
                    //{
                    //    if (control is ucRainBowChart)
                    //    {
                    //        ucRainBowChart chart = control as ucRainBowChart;
                    //        chart.DrawChart(stationUser, workUnit, pwoNo, t216LeafID, t133LeafID, t20LeafID);
                    //        return;
                    //    }
                    //    if (control is ucXBarRChart)
                    //    {
                    //        ucXBarRChart chart = control as ucXBarRChart;
                    //        chart.DrawChart(stationUser, workUnit, pwoNo, t20LeafID);
                    //        return;
                    //    }
                    //}
                }
            }
        }
Exemple #3
0
        private void tcMain_SelectedPageChanged(object sender, TabPageChangedEventArgs e)
        {
            if (e.Page != null && e.Page.Tag != null && e.Page.Tag is WIPStationProductionStatus)
            {
                string strProcedureName =
                    string.Format(
                        "{0}.{1}",
                        className,
                        MethodBase.GetCurrentMethod().Name);

                WIPStationProductionStatus workUnit = e.Page.Tag as WIPStationProductionStatus;
                int pageIndex = tcMain.TabPages.IndexOf(e.Page);

                int    errCode = 0;
                string errText = "";
                List <WIPStationSPCMonitor> datas = new List <WIPStationSPCMonitor>();

//#if DEBUG
//                datas.Add(
//                    new WIPStationSPCMonitor()
//                    {
//                        T47LeafID = 373564,
//                        PWONo_InExecution = "34PFF1CCQY60628003",
//                        T216LeafID = 5258697,
//                        T133LeafID = 2155684,
//                        T20LeafID = 352942,
//                    });
//#else

                WriteLog.Instance.WriteBeginSplitter(strProcedureName);
                try
                {
                    IRAPMDMClient.Instance.ufn_GetList_WIPStationSPCMonitor(
                        stationUser.CommunityID,
                        stationUser.SysLogID,
                        workUnit.T107Code,
                        ref datas,
                        out errCode,
                        out errText);
                    WriteLog.Instance.Write(
                        string.Format("({0}){1}", errCode, errText),
                        strProcedureName);
                    if (errCode != 0)
                    {
                        XtraMessageBox.Show(
                            errText,
                            "系统信息",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                        return;
                    }
                }
                finally
                {
                    WriteLog.Instance.WriteEndSplitter(strProcedureName);
                }
//#endif

                int t47LeafID = 0;
                if (datas.Count > 0)
                {
                    t47LeafID = datas[0].T47LeafID;
                }

                if (t47LeafID == 0)
                {
                    if (!(ucCharts[pageIndex] is ucUncontrolChart))
                    {
                        tcMain.TabPages[pageIndex].Controls.Remove(ucCharts[pageIndex]);
                        ucCharts[pageIndex] = null;

                        ucCharts[pageIndex] =
                            new ucUncontrolChart()
                        {
                            Dock   = DockStyle.Fill,
                            Parent = e.Page,
                        };
                    }
                }
                else
                {
                    switch (t47LeafID)
                    {
                    case 373564:
                        if (!(ucCharts[pageIndex] is ucRainBowChart))
                        {
                            tcMain.TabPages[pageIndex].Controls.Remove(ucCharts[pageIndex]);
                            ucCharts[pageIndex] = null;

                            ucRainBowChart chartRainBow =
                                new ucRainBowChart()
                            {
                                Dock   = DockStyle.Fill,
                                Parent = e.Page,
                            };
                            if (datas[0].TimeOutThreshold == 0)
                            {
                                chartRainBow.TimeOutThreshold = 60 * 1000;
                            }
                            else
                            {
                                chartRainBow.TimeOutThreshold = Convert.ToInt32(datas[0].TimeOutThreshold);
                            }

                            ucCharts[pageIndex] = chartRainBow;
                        }

                        (ucCharts[pageIndex] as ucRainBowChart).DrawChart(
                            stationUser,
                            workUnit,
                            datas[0].PWONo_InExecution,
                            t47LeafID,
                            datas[0].T216LeafID,
                            datas[0].T133LeafID,
                            datas[0].T20LeafID);

                        break;

                    case 373565:
                        if (!(ucCharts[pageIndex] is ucXBarRChart))
                        {
                            tcMain.TabPages[pageIndex].Controls.Remove(ucCharts[pageIndex]);
                            ucCharts[pageIndex] = null;

                            ucXBarRChart chartXbarR =
                                new ucXBarRChart()
                            {
                                Dock    = DockStyle.Fill,
                                Parent  = e.Page,
                                SPCRule = datas[0].SPCRule,
                            };

                            ucCharts[pageIndex] = chartXbarR;
                        }

                        (ucCharts[pageIndex] as ucXBarRChart).DrawChart(
                            stationUser,
                            workUnit,
                            datas[0],
                            datas[0].PWONo_InExecution,
                            datas[0].LCL,
                            datas[0].UCL,
                            datas[0].RLCL,
                            datas[0].RUCL,
                            datas[0].T20LeafID,
                            datas[0].PerQtyOfGroup);
                        break;
                    }
                }
            }
        }
Exemple #4
0
        public void DrawChart(
            StationLogin stationUser,
            WIPStationProductionStatus workUnit,
            string pwoNo,
            int t47LeafID,
            int t216LeafID,
            int t133LeafID,
            int t20LeafID)
        {
            string strProcedureName =
                string.Format(
                    "{0}.{1}",
                    className,
                    MethodBase.GetCurrentMethod().Name);

            int    errCode = 0;
            string errText = "";


            #region 获取Xbar-R图数据
            EntitySPCChart data = new EntitySPCChart();
            WriteLog.Instance.WriteBeginSplitter(strProcedureName);
            try
            {
                IRAPMESClient.Instance.ufn_GetInfo_SPCChart(
                    stationUser.CommunityID, // 60010,
                    pwoNo,                   // "1C3PK1A7BA50422003",
                    t47LeafID,               // 373564,
                    t216LeafID,              // 2155621,
                    t133LeafID,              //2155684,
                    t20LeafID,               //352942,
                    stationUser.SysLogID,    //101,
                    ref data,
                    out errCode,
                    out errText);
                WriteLog.Instance.Write(
                    string.Format("({0}){1}", errCode, errText),
                    strProcedureName);
                if (errCode != 0)
                {
                    return;
                }
            }
            finally
            {
                WriteLog.Instance.WriteEndSplitter(strProcedureName);
            }
            #endregion

            if (data.UCL != 0 || data.LCL != 0)
            {
                chartType = XbarRChartType.Control;
            }

            Font font = new Font("新宋体", 12f);

            #region 填写表头
            picLogo.Image     = data.CompanyLogoImage;
            lblTitle.Text     = data.ChartTitle;
            lblChartCode.Text = data.FormCode;
            edtT1002Name.Text = data.T1002Name;
            edtT1Name.Text    = data.T1Name;
            edtT216Name.Text  = data.T216Name;
            edtT133Code.Text  = data.T133Code;
            edtOperator.Text  =
                string.Format(
                    "{0}[{1}]",
                    data.OperatorCode,
                    data.OperatorName);
            edtT102Name.Text         = data.T102Name;
            edtT102Code.Text         = data.T102Code;
            edtT20Name.Text          = data.T20Name;
            edtEngineeringSpec.Text  = data.EngineeringSpec;
            edtSamplingInterval.Text = data.SamplingInterval;
            edtMeasuredDate.Text     = data.MeasuredDate;
            #endregion

            #region 绘制彩虹图
            chartRainBow.Series.Clear();

            Series pointMeasureData = new Series("测量值", ViewType.Point)
            {
                ArgumentScaleType = ScaleType.Qualitative,
                LabelsVisibility  = DefaultBoolean.True,
            };
            PointSeriesView view = new PointSeriesView();
            view.Color = Color.Blue;
            view.PointMarkerOptions.BorderColor = Color.Blue;
            pointMeasureData.View = view;

            PointSeriesLabel label = pointMeasureData.Label as PointSeriesLabel;
            label.Font      = font;
            label.TextColor = Color.Black;

            double maxValue = 0;
            double minValue = 0;

            List <RainbowChartMeasureData> datas       = data.XMLToRainbowChartDataList();
            List <ConstantLine>            clineAxisXs = new List <ConstantLine>();
            int opType  = -1;
            int ocCount = 0;

            foreach (RainbowChartMeasureData pointData in datas)
            {
                if (maxValue == 0 || maxValue < pointData.Metric01.DoubleValue)
                {
                    maxValue = pointData.Metric01.DoubleValue;
                }
                if (minValue == 0 || minValue > pointData.Metric01.DoubleValue)
                {
                    minValue = pointData.Metric01.DoubleValue;
                }

                SeriesPoint point =
                    new SeriesPoint(
                        string.Format(
                            "{0}\n{1}",
                            pointData.Ordinal,
                            pointData.MeasureTime),
                        pointData.Metric01.DoubleValue);

                pointMeasureData.Points.Add(point);

                if (opType != pointData.OpType)
                {
                    ocCount = 0;
                    opType  = pointData.OpType;

                    if (opType == 4 || opType == 5 || opType == 6)
                    {
                        ConstantLine clineX = new ConstantLine();
                        clineX.ShowInLegend          = false;
                        clineX.AxisValueSerializable = point.Argument;
                        switch (opType)
                        {
                        case 4:
                            clineX.Title.Text = "首检开始";
                            break;

                        case 5:
                            clineX.Title.Text = "过程检开始";
                            break;

                        case 6:
                            clineX.Title.Text = "末检开始";
                            break;
                        }
                        clineX.Title.Alignment = ConstantLineTitleAlignment.Far;
                        clineX.Title.TextColor = Color.Black;
                        clineX.Title.Font      = font;

                        clineAxisXs.Add(clineX);
                    }
                }

                if (pointData.OpType == 5)
                {
                    if (ocCount >= 2)
                    {
                        if (ocCount % 2 == 0)
                        {
                            clineAxisXs.Add(
                                new ConstantLine()
                            {
                                ShowInLegend          = false,
                                AxisValueSerializable = point.Argument,
                            });
                        }
                    }

                    ocCount++;
                }
            }

            chartRainBow.Series.Add(pointMeasureData);

            XYDiagram xyDiagram = chartRainBow.Diagram as XYDiagram;
            if (xyDiagram != null)
            {
                double midValue =
                    (data.LCLData.DoubleValue +
                     data.UCLData.DoubleValue) / 2;
                double splitData =
                    (data.USLData.DoubleValue -
                     data.LSLData.DoubleValue) / 4;
                double ucl = data.USLData.DoubleValue - splitData;
                double lcl = data.LSLData.DoubleValue + splitData;

                xyDiagram.DefaultPane.BackColor = Color.Red;

                xyDiagram.AxisX.Label.Font = font;
                xyDiagram.AxisY.Label.Font = font;
                xyDiagram.AxisX.Title.Font = font;

                xyDiagram.AxisX.Title.Visibility = DefaultBoolean.True;
                xyDiagram.AxisX.Title.Text       = "时间点";

                xyDiagram.AxisY.Strips.Clear();
                xyDiagram.AxisY.ConstantLines.Clear();
                xyDiagram.AxisX.ConstantLines.Clear();

                #region 画中值线
                ConstantLine constantLine = new ConstantLine();
                constantLine.ShowInLegend          = false;
                constantLine.AxisValueSerializable = midValue.ToString();
                constantLine.Color = Color.Black;
                constantLine.LineStyle.Thickness = 3;
                constantLine.Title.Text          = "M";
                constantLine.Title.Font          = font;
                xyDiagram.AxisY.ConstantLines.Add(constantLine);
                #endregion

                constantLine = new ConstantLine();
                constantLine.ShowInLegend          = false;
                constantLine.AxisValueSerializable = data.UCLData.DoubleValue.ToString();// ucl.ToString();
                constantLine.Color = Color.Black;
                constantLine.LineStyle.Thickness = 2;
                constantLine.Title.Text          = "P-C";
                constantLine.Title.Font          = font;
                xyDiagram.AxisY.ConstantLines.Add(constantLine);

                constantLine = new ConstantLine();
                constantLine.ShowInLegend          = false;
                constantLine.AxisValueSerializable = data.LCLData.DoubleValue.ToString();// lcl.ToString();
                constantLine.Color = Color.Black;
                constantLine.LineStyle.Thickness = 2;
                constantLine.Title.Text          = "P-C";
                constantLine.Title.Font          = font;
                xyDiagram.AxisY.ConstantLines.Add(constantLine);

                constantLine = new ConstantLine();
                constantLine.ShowInLegend          = false;
                constantLine.AxisValueSerializable = data.USLData.DoubleValue.ToString();
                constantLine.Color = Color.Black;
                constantLine.LineStyle.Thickness = 2;
                constantLine.Title.Text          = "Tu";
                constantLine.Title.Font          = font;
                xyDiagram.AxisY.ConstantLines.Add(constantLine);

                constantLine = new ConstantLine();
                constantLine.ShowInLegend          = false;
                constantLine.AxisValueSerializable = data.LSLData.DoubleValue.ToString();
                constantLine.Color = Color.Black;
                constantLine.LineStyle.Thickness = 2;
                constantLine.Title.Text          = "Tl";
                constantLine.Title.Font          = font;
                xyDiagram.AxisY.ConstantLines.Add(constantLine);

                foreach (ConstantLine lineX in clineAxisXs)
                {
                    xyDiagram.AxisX.ConstantLines.Add(lineX);
                }

                WholeRange wholeRange = xyDiagram.AxisY.WholeRange;
                wholeRange.AlwaysShowZeroLevel = false;
                wholeRange.Auto = false;
                //if (minValue > data.LSLData.DoubleValue)
                //    wholeRange.MinValue = data.LSLData.DoubleValue;
                //else
                //    wholeRange.MinValue = minValue;
                //if (maxValue < data.USLData.DoubleValue)
                //    wholeRange.MaxValue = data.USLData.DoubleValue;
                //else
                //    wholeRange.MaxValue = maxValue;
                wholeRange.MinValue         = data.LSLData.DoubleValue;
                wholeRange.MaxValue         = data.USLData.DoubleValue;
                wholeRange.SideMarginsValue = splitData;
                wholeRange.AutoSideMargins  = false;

                //VisualRange visualRange = xyDiagram.AxisY.VisualRange;
                //visualRange.Auto = false;
                //visualRange.MinValue = data.LSLData.DoubleValue;
                //visualRange.MaxValue = data.USLData.DoubleValue;
                //visualRange.SideMarginsValue = 1;
                //visualRange.AutoSideMargins = true;

                Strip strip = new Strip();
                strip.Color = Color.Yellow;
                strip.MinLimit.AxisValue = data.LSLData.DoubleValue;
                strip.MaxLimit.AxisValue = data.USLData.DoubleValue;
                strip.ShowInLegend       = false;
                xyDiagram.AxisY.Strips.Add(strip);

                strip       = new Strip();
                strip.Color = Color.Lime;
                strip.MinLimit.AxisValue = data.LCLData.DoubleValue;
                strip.MaxLimit.AxisValue = data.UCLData.DoubleValue;
                strip.ShowInLegend       = false;
                xyDiagram.AxisY.Strips.Add(strip);

                //strip = new Strip();
                //strip.Color = Color.Yellow;
                //strip.MinLimit.AxisValue = data.UCLData.DoubleValue;
                //strip.MaxLimit.AxisValue = data.USLData.DoubleValue;
                //strip.ShowInLegend = false;
                //xyDiagram.AxisY.Strips.Add(strip);
            }

            chartRainBow.Legend.Font = font;
            #endregion

            #region 如果有需要报警的消息,则弹出报警对话框
            switch (data.AnomalyType)
            {
            case 0:
                #region 如果是正常,则根据首检5片及过程检2片之后启动超时报警
                if (datas.Count > 0)
                {
                    bool startCountdown = false;
                    int  lastOpType     = 0;
                    int  numCheckPoint  = 0;
                    for (int i = 0; i < datas.Count; i++)
                    {
                        if (lastOpType != datas[i].OpType)
                        {
                            lastOpType     = datas[i].OpType;
                            numCheckPoint  = 1;
                            startCountdown = false;
                            continue;
                        }
                        else
                        {
                            numCheckPoint++;
                        }

                        if (lastOpType == 4 && numCheckPoint % 5 == 0)
                        {
                            startCountdown = true;
                        }
                        else if (lastOpType == 5 && numCheckPoint % 2 == 0)
                        {
                            startCountdown = true;
                        }
                        else
                        {
                            startCountdown = false;
                        }
                    }

                    IRAPMessageBox.Instance.Hide();

                    if (startCountdown)
                    {
                        timerWarning.Enabled = false;
                        Thread.Sleep(100);
                        timerWarning.Enabled = true;
                    }
                }
                else
                {
                    IRAPMessageBox.Instance.Hide();
                    timerWarning.Enabled = false;
                }
                #endregion
                break;

            case 1:
            case 2:
            case 3:
            case 4:
                IRAPMessageBox.Instance.Hide();
                timerWarning.Enabled = false;

                IRAPMessageBox.Instance.Show(
                    //XtraMessageBox.Show(
                    data.AnomalyDesc,
                    "测量数据异常",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation);

#if !DEBUG
                #region 重置统计过程
                if (data.C1ID != 0)
                {
                    WriteLog.Instance.WriteBeginSplitter(strProcedureName);
                    try
                    {
                        IRAPMESClient.Instance.usp_WriteLog_SPCReset(
                            stationUser.CommunityID,
                            data.C1ID,
                            373564,
                            stationUser.SysLogID,
                            out errCode,
                            out errText);
                        WriteLog.Instance.Write(
                            string.Format("({0}){1}", errCode, errText),
                            strProcedureName);
                    }
                    finally
                    {
                        WriteLog.Instance.WriteEndSplitter(strProcedureName);
                    }

                    //DrawChart(stationUser, workUnit, pwoNo, t47LeafID, t216LeafID, t133LeafID, t20LeafID);
                }
                #endregion
#endif

                break;
            }
            #endregion
        }