コード例 #1
0
ファイル: PressureForm.cs プロジェクト: LIUXIAOMINGIT/FQC
        /// <summary>
        /// 双道泵测量数据统一放进m_SampleDataList中,第一道数据索引为0,第二道为1
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnChart1SamplingComplete(object sender, DoublePumpDataArgs e)
        {
            Chart chart = sender as Chart;

            if (!e.IsPass)
            {
                #region  合格
                TestAgainDialog againDlg = new TestAgainDialog(1);
                var             result   = againDlg.ShowDialog();
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    //断续测试第二道
                    m_SampleDataList.Clear();
                    m_SampleDataList.Insert(0, e.Data);
                    chart1.Close();
                    Thread.Sleep(1000);
                    chart2.Start();
                }
                else if (result == System.Windows.Forms.DialogResult.Cancel)
                {
                    //重新测试,删除所有数据
                    chart1.Close();
                    chart1.Enabled = true;
                    Thread.Sleep(2000);
                    m_SampleDataList.Clear();
                    chart1.Start();
                }
                else
                {
                    return;
                }
                return;

                #endregion
            }
            else
            {
                #region 合格
                m_SampleDataList.Clear();
                m_SampleDataList.Insert(0, e.Data);
                DualPumpAlertDialog dlg = new DualPumpAlertDialog(2);
                if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    chart1.Close();
                    Thread.Sleep(1000);
                    chart2.Start();
                }
                else
                {
                    chart1.Close();
                    chart1.Enabled = true;
                }
                #endregion
            }
        }
コード例 #2
0
ファイル: PressureForm.cs プロジェクト: LIUXIAOMINGIT/FQC
        private void OnChart2SamplingComplete(object sender, DoublePumpDataArgs e)
        {
            Chart chart = sender as Chart;

            if (!e.IsPass)
            {
                #region  合格
                TestAgainDialog againDlg = new TestAgainDialog(2);
                var             result   = againDlg.ShowDialog();
                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    //不合格结束测试
                    m_SampleDataList.Add(e.Data);
                    if (m_SampleDataList.Count == 2 && m_SampleDataList[0].Channel == 1 && m_SampleDataList[1].Channel == 2)
                    {
                        #region //结束了
                        chart1.Enabled = true;
                        chart2.Enabled = true;
                        chart1.Close();
                        chart2.Close();
                        //写入excel,调用chart类中函数
                        string path  = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\压力数据Pressure Data\\Data";
                        string path2 = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\压力数据Pressure Data\\Data Copy";
                        PumpID pid   = PumpID.None;
                        switch (m_LocalPid)
                        {
                        case PumpID.GrasebyF8:
                            pid = PumpID.GrasebyF8;
                            break;

                        case PumpID.GrasebyF8_2:
                            pid = PumpID.GrasebyF8;
                            break;

                        case PumpID.GrasebyF6:
                            pid = PumpID.GrasebyF6;
                            break;

                        case PumpID.GrasebyF6_2:
                            pid = PumpID.GrasebyF6;
                            break;

                        case PumpID.WZS50F6_2:
                            pid = PumpID.WZS50F6;
                            break;

                        default:
                            pid = m_LocalPid;
                            break;
                        }
                        string fileName = string.Format("{0}_{1}_{2}", pid.ToString(), tbPumpNo.Text, DateTime.Now.ToString("yyyy-MM-dd HH_mm_ss"));
                        if (!System.IO.Directory.Exists(path))
                        {
                            System.IO.Directory.CreateDirectory(path);
                        }
                        string saveFileName = path + "\\" + fileName + ".xlsx";

                        if (!System.IO.Directory.Exists(path2))
                        {
                            System.IO.Directory.CreateDirectory(path2);
                        }
                        string saveFileName2 = path2 + "\\" + fileName + ".xlsx";

                        //生成表格,两份
                        GenDualReport(saveFileName, saveFileName2);

                        if (m_LocalPid == PumpID.GrasebyF8_2 || m_LocalPid == PumpID.GrasebyF6_2 || m_LocalPid == PumpID.WZS50F6_2)
                        {
                            if (m_SampleDataList.Count >= 2)
                            {
                                tbPumpNo.Clear();
                            }
                        }
                        else
                        {
                            tbPumpNo.Clear();
                        }
                        //导出后就可以清空
                        m_SampleDataList.Clear();
                        string strError = "";
                        bool   ch1 = true, ch2 = true;
                        if (chart1.IsAuto())
                        {
                            ch1 = chart1.IsPassAuto(ref strError);
                        }
                        else
                        {
                            ch1 = chart1.IsPassManual(ref strError);
                        }
                        if (chart2.IsAuto())
                        {
                            ch2 = chart2.IsPassAuto(ref strError);
                        }
                        else
                        {
                            ch2 = chart2.IsPassManual(ref strError);
                        }
                        #endregion
                    }
                    else
                    {
                        Logger.Instance().ErrorFormat("OnChart2SamplingComplete()函数被调用,结果不合格,m_SampleDataList.Count={0},m_SampleDataList[0].Channel={1},m_SampleDataList[1].Channel={2}", m_SampleDataList.Count, m_SampleDataList[0].Channel, m_SampleDataList[1].Channel);
                        CompleteTestBecauseError();
                        ErrorDialog dlg = new ErrorDialog("测量结果异常,请重新测试!");
                        dlg.ShowDialog();
                    }
                }
                else if (result == System.Windows.Forms.DialogResult.Cancel)
                {
                    #region //重新测试
                    chart2.Close();
                    chart2.ClearTestData();
                    chart2.Enabled = true;
                    Thread.Sleep(1000);
                    chart2.Start();
                    #endregion
                }
                else
                {
                    return;
                }
                return;

                #endregion
            }
            else
            {
                #region 合格
                m_SampleDataList.Add(e.Data);
                if (m_SampleDataList.Count == 2 && m_SampleDataList[0].Channel == 1 && m_SampleDataList[1].Channel == 2)
                {
                    #region
                    chart1.Enabled = true;
                    chart2.Enabled = true;
                    chart1.Close();
                    chart2.Close();
                    //写入excel,调用chart类中函数
                    string path  = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\压力数据Pressure Data\\Data";
                    string path2 = Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "\\压力数据Pressure Data\\Data Copy";

                    PumpID pid = PumpID.None;
                    switch (m_LocalPid)
                    {
                    case PumpID.GrasebyF8:
                        pid = PumpID.GrasebyF8;
                        break;

                    case PumpID.GrasebyF8_2:
                        pid = PumpID.GrasebyF8;
                        break;

                    case PumpID.GrasebyF6_2:
                        pid = PumpID.GrasebyF6;
                        break;

                    case PumpID.WZS50F6_2:
                        pid = PumpID.WZS50F6;
                        break;

                    default:
                        pid = m_LocalPid;
                        break;
                    }
                    string fileName = string.Format("{0}_{1}_{2}", pid.ToString(), tbPumpNo.Text, DateTime.Now.ToString("yyyy-MM-dd HH_mm_ss"));
                    if (!System.IO.Directory.Exists(path))
                    {
                        System.IO.Directory.CreateDirectory(path);
                    }
                    string saveFileName = path + "\\" + fileName + ".xlsx";


                    if (!System.IO.Directory.Exists(path2))
                    {
                        System.IO.Directory.CreateDirectory(path2);
                    }
                    string saveFileName2 = path2 + "\\" + fileName + ".xlsx";

                    //生成表格,两份
                    GenDualReport(saveFileName, saveFileName2);

                    if (m_LocalPid == PumpID.GrasebyF8_2)
                    {
                        if (m_SampleDataList.Count >= 2)
#if DEBUG
                        {; }
#else
                        { tbPumpNo.Clear(); }
#endif
                    }
                    else

#if DEBUG
                    {; }
#else
                    { tbPumpNo.Clear(); }
#endif
                    //导出后就可以清空
                    m_SampleDataList.Clear();

                    string strError1 = "", strError2 = "";
                    bool   ch1 = true, ch2 = true;
                    if (chart1.IsAuto())
                    {
                        ch1 = chart1.IsPassAuto(ref strError1);
                    }
                    else
                    {
                        ch1 = chart1.IsPassManual(ref strError1);
                    }
                    if (chart2.IsAuto())
                    {
                        ch2 = chart2.IsPassAuto(ref strError2);
                    }
                    else
                    {
                        ch2 = chart2.IsPassManual(ref strError2);
                    }
                    if (!string.IsNullOrEmpty(strError1))
                    {
                        strError1 = "通道1失败:" + strError1;
                    }
                    if (!string.IsNullOrEmpty(strError2))
                    {
                        strError2 = "通道2失败:" + strError2;
                    }
                    //双道泵是否通过测试,弹出框
                    if (ch1 && ch2)
                    {
                        ResultDialogPass dlg = new ResultDialogPass(ch1 && ch2);
                        dlg.ShowDialog();
                    }
                    else
                    {
                        ResultDialogFail dlg = new ResultDialogFail(ch1 && ch2, strError1 + strError2);
                        dlg.ShowDialog();
                    }
                    #endregion
                }
                else
                {
                    Logger.Instance().ErrorFormat("OnChart2SamplingComplete()函数被调用,结果合格,m_SampleDataList.Count={0},m_SampleDataList[0].Channel={1},m_SampleDataList[1].Channel={2}", m_SampleDataList.Count, m_SampleDataList[0].Channel, m_SampleDataList[1].Channel);
                    CompleteTestBecauseError();
                    ErrorDialog dlg = new ErrorDialog("测量结果异常,请重新测试!");
                    dlg.ShowDialog();
                }
                #endregion
            }
        }