예제 #1
0
        private List <double> GetMeterPowers(int channel, double time)
        {
            var powers = new List <double>();

            var sw = System.Diagnostics.Stopwatch.StartNew();

            while (!IsStop)
            {
                var power = MeasurementController.GetMeterPower(channel);
                if (power == double.MinValue)
                {
                    continue;
                }

                powers.Add(power);

                readingCallback?.Invoke(
                    "-",
                    powers.Max().ToString("F3"),
                    powers.Min().ToString("F3")
                    );

                if (sw.ElapsedMilliseconds > time * 1000D)
                {
                    sw.Stop();
                    break;
                }
            }
            readingCallback?.Invoke(
                "-",
                powers.Max().ToString("F3"),
                powers.Min().ToString("F3")
                );
            return(powers);
        }
예제 #2
0
        /// <summary>
        /// 弹框
        /// </summary>
        /// <param name="type"></param>
        /// <param name="msg"></param>
        /// <param name="title"></param>
        /// <returns></returns>
        private int ShowMessage(int type, string msg, string title = "归零测试")
        {
            if (currentChannel == int.MinValue)
            {
                currentChannel = Channels.FirstOrDefault();
            }
            if (currentWavelength == double.MinValue)
            {
                currentWavelength = Wavelengths.FirstOrDefault();
            }

            testInfoCallback?.Invoke(currentWavelength, currentChannel);

            FormMessageBox.SetShow(refForm, title, msg, type);

            while (FormMessageBox.MessageBoxResult == 0)
            {
                if (IsStop)
                {
                    FormMessageBox.SetClose(2);
                    break;
                }
                var p = MeasurementController.GetMeterAllChannelPower(1, 1);
                readingCallback?.Invoke(string.Join(", ", p.Values.Select(q => q == double.MinValue ? "-" : q.ToString("F2")).ToArray()));
                System.Threading.Thread.Sleep(50);
            }
            readingCallback?.Invoke("-");
            if (FormMessageBox.MessageBoxResult == 2)
            {
                IsStop = true;
            }
            return(FormMessageBox.MessageBoxResult);
        }
예제 #3
0
        private void GetPower()
        {
            var pws = MeasurementController.GetMeterAllChannelPower(0, 0);
            var str = "";

            if (pws.Count < 1)
            {
                str = "-";
            }
            foreach (var pw in pws)
            {
                var ch = pw.Key;
                var p  = pw.Value;
                if (p == double.MinValue)
                {
                    str = "-";
                    break;
                }
                if (currentUnit == "dB")
                {
                    var rf = MeasurementJob.ReferenceData.GetReference(1, currentChannel, currentWavelength);
                    if (rf == null)
                    {
                        currentUnit = "dBm";
                    }
                    else
                    {
                        p = Math.Abs(rf.Power - p);
                    }
                }
                str += $"{p:F2}{currentUnit}\r\n";
            }

            readingCallback?.Invoke(str, "-", "-");
        }
예제 #4
0
        public FormMeasurementTest()
        {
            InitializeComponent();

            this.Text = MeasurementSystemSetting.SystemData.Setting.Profile.AppTitle + " - 测试作业";

            btReferencecs.Image = StaticImage.Referencecs;

            measurementJob                  = new MeasurementJobInformation();
            measurementController           = new MeasurementController();
            referencesProcess               = new ReferencesProcess();
            measurementProcess              = new MeasurementProcess();
            referencesProcess.ProcessError += (o, e) =>
            {
                AppFramework.Context.Execute(
                    new Action(() =>
                {
                    AppFramework.Context.ShowError(e.ExceptionObject.ToString(), "归零错误");
                }));
            };
            measurementProcess.ProcessError += (o, e) =>
            {
                AppFramework.Context.Execute(
                    new Action(() =>
                {
                    AppFramework.Context.ShowError(e.ExceptionObject.ToString(), "测试错误");
                }));
            };
            measurementProcess.ProcessStart += (o, e) =>
            {
                btReferencecs.Enabled = false;
                btStart.Image         = Properties.Resources.stop_64;
                btStart.Text          = "       停止测试";
                tslMsg.Text           = "正在测试产品...";
            };
            measurementProcess.ProcessStop += (o, e) =>
            {
                btReferencecs.Enabled = true;
                btStart.Image         = Properties.Resources.Start_64;
                btStart.Text          = "       开始测试";
                tslMsg.Text           = "就绪";

                if (testSystemControls == null)
                {
                    return;
                }
                foreach (var testSystemControl in testSystemControls)
                {
                    testSystemControl.SetStop();
                }
            };
        }
예제 #5
0
        private void ConnectAction()
        {
            if (MeasurementTasks.Count < 1)
            {
                FormMessageBox.SetShow(null, "测试错误", "请至少选择一个产品测试", 4);
                while (!IsStop && FormMessageBox.MessageBoxResult == 0)
                {
                    System.Threading.Thread.Sleep(500);
                }

                IsStop = true;
                return;
            }

            if (Framework.MeasurementSystemSetting.SystemData.Setting.Profile.DuplicationCheckType > 0)
            {
                var c = new ModifyTestInfo();
                foreach (var task in MeasurementTasks)
                {
                    var temp = c.GetLastTestInfo(MeasurementJob.ProductInfo.ProductID, MeasurementJob.StationInfo.StationID, task.TestSN, true);
                    if (temp.Status)
                    {
                        if (temp.Data != null && temp.Data != Guid.Empty)
                        {
                            tipCallback?.Invoke(task.TestOrderID, 2, $"{task.TestSN}重复测试", 0);
                            FormMessageBox.SetShow(null, "重复测试", $"系统检查到 {task.TestSN} 已经测试\r\n请确认SN号码是否重号或者产品多次测试。", 3);
                            while (!IsStop && FormMessageBox.MessageBoxResult == 0)
                            {
                                System.Threading.Thread.Sleep(500);
                            }
                            if (FormMessageBox.MessageBoxResult != 1)
                            {
                                IsStop = true;
                                return;
                            }
                        }
                    }
                }
            }

            if (!MeasurementController.Connect())
            {
                FormMessageBox.SetShow(null, "仪器错误", $"连接仪器失败\r\n{MeasurementController.ErrorString}", 4);
                while (!IsStop && FormMessageBox.MessageBoxResult == 0)
                {
                    System.Threading.Thread.Sleep(500);
                }

                IsStop = true;
                return;
            }
        }
예제 #6
0
        private Dictionary <int, List <double> > GetAllChannelMeterPowers(int id, int sww, double time)
        {
            var result = new Dictionary <int, List <double> >();
            var sw     = System.Diagnostics.Stopwatch.StartNew();

            while (!IsStop)
            {
                var powers = MeasurementController.GetMeterAllChannelPower(id, sww);
                if (powers.Count < 1)
                {
                    continue;
                }
                var max = new StringBuilder();
                var min = new StringBuilder();
                foreach (var pw in powers)
                {
                    if (!result.ContainsKey(pw.Key))
                    {
                        result[pw.Key] = new List <double>();
                    }
                    if (pw.Value != double.MinValue)
                    {
                        result[pw.Key].Add(pw.Value);
                    }

                    var maxP = result[pw.Key].Max();
                    var minP = result[pw.Key].Min();
                    if (maxP == double.MinValue || minP == double.MinValue)
                    {
                        max.Append($"{pw.Key}: -\r\n");
                        min.Append("-\r\n");
                    }
                    else
                    {
                        max.Append($"{pw.Key}: {maxP:F3}\r\n");
                        min.Append($"{minP:F3}\r\n");
                    }
                }
                readingCallback?.Invoke(
                    "-",
                    max.ToString(),
                    min.ToString()
                    );

                if (sw.ElapsedMilliseconds > time * 1000D)
                {
                    sw.Stop();
                    break;
                }
            }
            return(result);
        }
예제 #7
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (referencesProcess == null || measurementProcess == null)
            {
                return;
            }

            referencesProcess.Register(
                measurementProcess.MeasurementController,
                measurementProcess.MeasurementJob,
                enableTestChannel);


            foreach (var item in referencesProcess.TestItems)
            {
                AddTestInfoRow(item.ItemID, item.ItemName, item.LastValueString);
            }

            comboBox1.Items.AddRange(referencesProcess.Wavelengths.Select(q => q.ToString("F3")).ToArray());
            var source = new List <KeyValuePair <int, string> >();

            foreach (var channel in referencesProcess.Channels)
            {
                source.Add(new KeyValuePair <int, string>(channel, MeasurementController.GetPortName(channel)));
            }
            comboBox2.BindingDataSource(source);
            if (comboBox1.Items.Count > 0)
            {
                comboBox1.SelectedIndex = 0;
            }
            if (comboBox2.Items.Count > 0)
            {
                comboBox2.SelectedIndex = 0;
            }
            comboBox1.Enabled = false;
            comboBox2.Enabled = false;


            referencesProcess.RegisterCallback(
                this,
                TestCallback,
                SetTestInfo,
                ReadingCallbck);
            referencesProcess.ProcessStart += ReferencesProcess_ProcessStart;
            referencesProcess.ProcessStop  += ReferencesProcess_ProcessStop;
            btStart.Enabled = true;
        }
예제 #8
0
        private void GetPointRLTestData(IMeasurementTask testTask, string temp, TestSystemGroup systemGroup, WorkInfoSpecItem item, bool testAgain)
        {
            if (!item.TestSetting.IsDouble())
            {
                return;
            }
            var wl = item.TestSetting.CastTo(1550D);

            var type = "RL";

            if (!testAgain && testTask.ContainsTestData(type, temp, item.PortSetting, wl))
            {
                return;
            }
            currentChannel    = 1;
            currentWavelength = wl;
            testInfoCallback?.Invoke(currentWavelength, currentChannel, currentUnit);

            var pw = new List <double>();

            if (!MeasurementController.RunPointTest(
                    false,
                    currentWavelength,
                    () =>
            {
                return(!IsStop);
            },
                    () =>
            {
                var readTime = Framework.MeasurementSystemSetting.SystemData.Setting.Profile.RetrunLosssTime;
                pw = GetMeterPowers(1, readTime);
            }))
            {
                throw new Exception(MeasurementController.ErrorString);
            }
            if (pw.Count < 1)
            {
                throw new Exception("读取功率失败");
            }
            AddPointRLTestData(testTask, type, temp, item.PortSetting, currentWavelength, pw);
            return;
        }
예제 #9
0
        /// <summary>
        /// 仪器连接
        /// </summary>
        private void ConnectAction()
        {
            //清空测试内容
            foreach (var testItem in TestItems)
            {
                testItem.ValueString = "";
                testResultCallback(testItem.ItemID, "", testItem.LastValueString, 0);
            }
            var item = TestItems.FirstOrDefault(q => q.TestTypeID == TestTypes[0]);

            testResultCallback(item.ItemID, "正在连接", "", 3);
            if (!MeasurementController.Connect())
            {
                testResultCallback(item.ItemID, MeasurementController.ErrorString, "", 2);
                ShowMessage(4, MeasurementController.ErrorString);
                IsStop = true;
            }
            else
            {
                item.LastValueString = "已连接";
                item.ValueString     = "OK";
                testResultCallback(item.ItemID, "通过", "", 1);
            }
        }
예제 #10
0
        /// <summary>
        /// 注册测试信息
        /// </summary>
        /// <param name="controller"></param>
        /// <param name="job"></param>
        /// <param name="testChannel"></param>
        public void Register(MeasurementController controller, MeasurementJobInformation job, bool[] testChannel)
        {
            MeasurementController = controller;
            MeasurementJob        = job;

            //点测测试组
            var ILgroups = job.SpecData.TestSystemGroups.Where(q => q.TestGroupTestType == "Point" || q.TestGroupTestType == "PointPDL").Select(q => q.TestGroupID).ToList();
            //回损测试组
            var RLgroups = job.SpecData.TestSystemGroups.Where(q => q.TestGroupTestType == "RL").Select(q => q.TestGroupID).ToList();

            //点测测试项
            var ilTestItems = job.SpecData.WorkInfoSpecItems.Where(q => ILgroups.Any(g => g == q.TestGroupID) || RLgroups.Any(g => g == q.TestGroupID)).ToList(); //插损
            //回损测试项
            var rl1TestItems = job.SpecData.WorkInfoSpecItems.Where(q => RLgroups.Any(g => g == q.TestGroupID)).ToList();

            //按端口归组
            var portILGroup = ilTestItems.GroupBy(q => q.PortSetting % TestPortSetting.DataDivide).ToList();

            TestItems.Clear();
            TestItems.Add(new ReferenceTestItem()
            {
                ItemID          = Guid.NewGuid(),
                TestTypeID      = TestTypes[0],
                ItemName        = "连接仪器",
                Wavelenght      = 0D,
                Channel         = 0,
                ReferenceType   = -1,
                ReferenceData   = default(List <TPointTestItem>),
                LastValueString = "",
                ValueString     = "",
                ReferenceResult = -1,
                OrderID         = TestItems.Count + 1
            });
            Wavelengths.Clear();
            Channels.Clear();
            for (int i = 0; i < Framework.MeasurementSystemSetting.SystemData.Setting.Profile.SimultaneousNumber; i++)
            {
                if (testChannel.Length > i && !testChannel[i])
                {
                    continue;
                }

                foreach (var port in portILGroup)
                {
                    if (port.Key == 0)
                    {
                        continue;
                    }

                    var list = port.ToList();
                    if (list.Count < 1)
                    {
                        continue;
                    }

                    var    channel = MeasurementController.GetSimultaneityPort(i, port.Key);
                    string name    = MeasurementController.GetPortName(channel);

                    var wlGroup = list.Where(q => q.TestSetting.IsDouble()).GroupBy(q => q.TestSetting.CastTo <double>());
                    foreach (var wlItem in wlGroup)
                    {
                        var wl = wlItem.Key;

                        var refData = "";
                        var oldRef  = job.ReferenceData.GetReference(1, channel, wl);
                        if (oldRef != null)
                        {
                            refData = oldRef.Power.ToString("F3");
                        }

                        TestItems.Add(new ReferenceTestItem()
                        {
                            ItemID          = Guid.NewGuid(),
                            TestTypeID      = TestTypes[1],
                            ItemName        = $"获取 IL (功率计 {name}, 波长 {wl}) 归零值",
                            Wavelenght      = wl,
                            Channel         = channel,
                            ReferenceType   = 1,
                            ReferenceData   = new List <TPointTestItem>(),
                            LastValueString = refData,
                            ValueString     = "",
                            ReferenceResult = -1,
                            OrderID         = TestItems.Count + 1
                        });

                        if (!Wavelengths.Contains(wl))
                        {
                            Wavelengths.Add(wl);
                        }

                        if (!Channels.Contains(channel))
                        {
                            Channels.Add(channel);
                        }
                    }
                }
            }

            //按端口归组
            var portRLGroup = rl1TestItems.GroupBy(q => q.PortSetting % TestPortSetting.DataDivide).ToList();

            for (int i = 0; i < Framework.MeasurementSystemSetting.SystemData.Setting.Profile.SimultaneousNumber; i++)
            {
                if (testChannel.Length > i && !testChannel[i])
                {
                    continue;
                }

                foreach (var port in portRLGroup)
                {
                    if (port.Key == 0)
                    {
                        continue;
                    }

                    var list = port.ToList();
                    if (list.Count < 1)
                    {
                        continue;
                    }

                    var    channel = MeasurementController.GetSimultaneityPort(i, port.Key);
                    string name    = MeasurementController.GetPortName(channel);

                    var wlGroup = list.Where(q => q.TestSetting.IsDouble()).GroupBy(q => q.TestSetting.CastTo <double>());

                    foreach (var wlItem in wlGroup)
                    {
                        var wl = wlItem.Key;


                        var refData = "";
                        var oldRef  = job.ReferenceData.GetReference(2, channel, wl);
                        if (oldRef != null)
                        {
                            refData = oldRef.Power.ToString("F3");
                        }

                        TestItems.Add(new ReferenceTestItem()
                        {
                            ItemID          = Guid.NewGuid(),
                            TestTypeID      = TestTypes[2],
                            ItemName        = $"获取 ({name},波长 {wl}) 的系统回损",
                            Wavelenght      = wl,
                            Channel         = channel,
                            ReferenceType   = 2,
                            ReferenceData   = new List <TPointTestItem>(),
                            LastValueString = refData,
                            ValueString     = "",
                            ReferenceResult = -1,
                            OrderID         = TestItems.Count + 1
                        });

                        if (!Wavelengths.Contains(wl))
                        {
                            Wavelengths.Add(wl);
                        }

                        if (!Channels.Contains(channel))
                        {
                            Channels.Add(channel);
                        }
                    }
                }
            }

            TestItems.Add(new ReferenceTestItem()
            {
                ItemID          = Guid.NewGuid(),
                TestTypeID      = TestTypes[TestTypes.Length - 1],
                ItemName        = "保存数据",
                Wavelenght      = 0D,
                Channel         = 0,
                ReferenceType   = -1,
                ReferenceData   = new List <TPointTestItem>(),
                LastValueString = "",
                ValueString     = "",
                ReferenceResult = -1,
                OrderID         = TestItems.Count + 1
            });
        }
예제 #11
0
 public void Register(MeasurementController measurement, MeasurementJobInformation task)
 {
     MeasurementController = measurement;
     MeasurementJob        = task;
 }
예제 #12
0
        private List <double> GetMeterPowers(int channel, double time)
        {
            var powers = new List <double>();

            var setting = TestPortSetting.Get(channel);
            var pm      = MeasurementController.GetMeterIsMaxMin(setting.DeviceID);

            if (pm != null)
            {
                System.Threading.Thread.Sleep(10);
                TryAction(() => {
                    return(pm.SetPowerMaxMin(0, setting.ChannelID, 1));
                }, 10);
                var sw = System.Diagnostics.Stopwatch.StartNew();
                while (!IsStop)
                {
                    if (sw.ElapsedMilliseconds > time * 1000D)
                    {
                        sw.Stop();
                        break;
                    }
                    System.Threading.Thread.Sleep(10);
                }

                TryAction(() => {
                    return(pm.SetPowerMaxMin(0, setting.ChannelID, 0));
                }, 10);

                var pw = double.MinValue;
                TryAction(() => {
                    return(pm.GetMaxPower(0, setting.ChannelID, out pw) && pw != double.MinValue);
                }, 10);

                if (pw == 0D)
                {
                    return(new List <double>());
                }

                if (pw != double.MinValue)
                {
                    powers.Add(pw);
                }

                TryAction(() => {
                    return(pm.GetMinPower(0, setting.ChannelID, out pw) && pw != double.MinValue);
                }, 10);

                if (pw != double.MinValue)
                {
                    powers.Add(pw);
                }
            }
            else
            {
                var sw = System.Diagnostics.Stopwatch.StartNew();
                while (!IsStop)
                {
                    var power = MeasurementController.GetMeterPower(channel);
                    if (power == double.MinValue)
                    {
                        continue;
                    }

                    powers.Add(power);
                    if (sw.ElapsedMilliseconds > time * 1000D)
                    {
                        sw.Stop();
                        break;
                    }
                }
            }


            return(powers);
        }
예제 #13
0
        /// <summary>
        /// 测试项目
        /// </summary>
        /// <param name="item"></param>
        private void TestItem(ReferenceTestItem item)
        {
            var wl = item.Wavelenght;
            var ch = item.Channel;


            UpdateTestInfo(wl, ch);

            var value1 = double.MinValue;

            if (!MeasurementController.RunPointTest(
                    pdlReferces,
                    wl,
                    () => {
                return(!IsStop);
            },
                    () => {
                if (item.TestTypeID == TestTypes[1])     //IL
                {
                    if (pdlReferces)
                    {
                        TryAction(() => {
                            if (IsStop)
                            {
                                return(false);
                            }

                            var pws = GetMeterPowers(ch, MeasurementController.PDLTestTime);
                            if (pws.Count < 1)
                            {
                                return(false);
                            }
                            else
                            {
                                var max = Math.Round(pws.Max(), 3);
                                var min = Math.Round(pws.Min(), 3);
                                var avg = Math.Round(pws.Average(), 3);
                                var p = max;
                                if (Framework.MeasurementSystemSetting.SystemData.Setting.Profile.CalculateILType > 0)
                                {
                                    switch (Framework.MeasurementSystemSetting.SystemData.Setting.Profile.CalculateILType)
                                    {
                                    case 1:
                                        p = max;
                                        break;

                                    case 2:
                                        p = min;
                                        break;

                                    case 3:
                                        p = avg;
                                        break;
                                    }
                                }
                                value1 = p;
                            }
                            return(true);
                        }, 10);
                    }
                    else
                    {
                        value1 = MeasurementController.GetMeterPower(ch);
                    }
                }
                else     //RL
                {
                    value1 = MeasurementController.GetMeterMinPower(ch, Framework.MeasurementSystemSetting.SystemData.Setting.Profile.RetrunLosssTime);
                }
            }))
            {
                testResultCallback(item.ItemID, MeasurementController.ErrorString, item.LastValueString, 2);
                IsStop = true;
                return;
            }

            if (Framework.MeasurementSystemSetting.SystemData.Setting.Profile.CheckOpticalSource &&
                value1 < Framework.MeasurementSystemSetting.SystemData.Setting.Profile.OpticalSourceThreshold)
            {
                testResultCallback(item.ItemID, value1.ToString(), "", 2);
                ShowMessage(4, "光源太弱,请检查接线后再测试");
                return;
            }

            if (value1 == double.MinValue)
            {
                testResultCallback(item.ItemID, "读取失败", item.LastValueString, 2);
                ShowMessage(4, MeasurementController.ErrorString);
                return;
            }
            item.ReferenceData.Clear();
            item.ReferenceData.Add(new TPointTestItem()
            {
                WaveLength   = wl,
                MonitorPower = 0D,
                Power        = value1,
                IL           = 0D,
                PDL          = 0D,
                MaxPower     = 0D,
                MinPower     = 0D,
                AvgPower     = 0D,
                ExtendData   = new double[0]
            });

            var oldTemp = item.LastValueString;

            item.LastValueString = value1.ToString("F3");
            item.ValueString     = $"{value1}";

            testResultCallback(item.ItemID, value1.ToString("F3"), oldTemp, 1);
        }
예제 #14
0
        public void AddTestInfoRow(WorkInfoSpecItem specItem)
        {
            var row = testItem.NewRow();

            row["TestItemID"]   = specItem.SpecItemID;
            row["TestItemName"] = specItem.ItemName;

            foreach (var resultItem in BaseSettingsManager.Get <ResultSettings>().NeedSettingResult)
            {
                if (!specItem.ComputeSetting.ContainsKey(resultItem.ResultID))
                {
                    row[string.Format("TestItemCompute{0}", resultItem.ResultID)] = "N/A";
                }
                else
                {
                    var computeItem = specItem.ComputeSetting[resultItem.ResultID];
                    row[string.Format("TestItemCompute{0}", resultItem.ResultID)] = string.IsNullOrEmpty(computeItem.ComputeValue) ? "未设置" : OperatorManager.GetOperator(computeItem.ComputeSign).GetDisplayString(computeItem.ComputeValue);
                }
            }
            row["TestItemPortSetting"] = MeasurementController.GetPortName(specItem.PortSetting);
            if (string.IsNullOrEmpty("specItem.TestTemp") || !specItem.TestTemp.IsNumeric())
            {
                row["TestItemTemp"] = "";
            }
            else
            {
                row["TestItemTemp"] = $"{specItem.TestTemp}℃";
            }
            row["TestItemValue"]     = "";
            row["TestItemMaxValue"]  = "";
            row["TestItemMinValue"]  = "";
            row["TestItemLastValue"] = "-999";
            row["TestItemStatus"]    = -10;
            testItem.Rows.Add(row);

            var resultInfo = new ResultInfo()
            {
                TestInfoDataRow = row
            };

            testReslut[specItem.SpecItemID] = resultInfo;

            var dgvResult = default(DataGridView);

            if (!dgvResults.TryGetValue(specItem.TestTemp, out dgvResult))
            {
                return;
            }
            if (!specItem.TestSetting.IsDouble())
            {
                return;
            }

            var wl    = specItem.TestSetting.CastTo(1550D);
            var names = specItem.ItemName.Split(":");
            var name  = names.Length > 1 ? names[1] : names[0];

            names = name.Split("@");
            name  = names[0];

            var setting = TestPortSetting.Get(specItem.PortSetting);

            if (setting.ChannelID < 1 && name == "UL")
            {
                name = "IL";
            }

            if (!dgvResult.Columns.Contains(name))
            {
                dgvResult.Columns.Add(name, name);
                dgvResult.Columns[name].SortMode = DataGridViewColumnSortMode.NotSortable;
            }

            foreach (DataGridViewRow dataRow in dgvResult.Rows)
            {
                if (dataRow.Cells["Wavelength"].Value.ToString() == wl.ToString("F3") &&
                    dataRow.Cells["Port"].Value.ToString() == specItem.PortSetting.ToString())
                {
                    resultInfo.ResultViewCell = dataRow.Cells[name];
                }
            }
        }
예제 #15
0
        public void SetSetting(string[] temps, List <double> wls, List <int> chs)
        {
            for (int i = 0; i < temps.Length; i++)
            {
                var temp = temps[i];

                if (string.IsNullOrEmpty(temp))
                {
                    continue;
                }

                var text    = $"{temp}℃";
                var tagPage = new TabPage()
                {
                    Name = Guid.NewGuid().ToString(),
                    Text = text
                };

                var dgvResult = new DataGridViewEx();
                dgvResults[temp]                      = dgvResult;
                dgvResult.AllowUserToAddRows          = false;
                dgvResult.AllowUserToDeleteRows       = false;
                dgvResult.AutoSizeColumnsMode         = DataGridViewAutoSizeColumnsMode.Fill;
                dgvResult.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
                var dataGridViewCellStyle = new DataGridViewCellStyle();
                dataGridViewCellStyle.Alignment          = DataGridViewContentAlignment.MiddleLeft;
                dataGridViewCellStyle.BackColor          = SystemColors.Window;
                dataGridViewCellStyle.Font               = new Font("微软雅黑", 10.5F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(134)));
                dataGridViewCellStyle.ForeColor          = SystemColors.ControlText;
                dataGridViewCellStyle.SelectionBackColor = SystemColors.Highlight;
                dataGridViewCellStyle.SelectionForeColor = SystemColors.HighlightText;
                dataGridViewCellStyle.WrapMode           = DataGridViewTriState.False;
                dgvResult.DefaultCellStyle               = dataGridViewCellStyle;
                dgvResult.Location           = new Point(322, 14);
                dgvResult.Name               = Guid.NewGuid().ToString();
                dgvResult.ReadOnly           = true;
                dgvResult.RowHeadersWidth    = 21;
                dgvResult.RowTemplate.Height = 27;
                dgvResult.SelectionMode      = DataGridViewSelectionMode.CellSelect;
                dgvResult.Size               = new Size(586, 161);
                dgvResult.Dock               = DockStyle.Fill;
                tagPage.Controls.Add(dgvResult);

                dgvResult.Columns.Add("Wavelength", "波长");
                dgvResult.Columns.Add("Port", "Port");
                dgvResult.Columns.Add("PortName", "端口");
                dgvResult.Columns[1].Visible  = false;
                dgvResult.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
                dgvResult.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
                dgvResult.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;

                var multPort = chs.Any(q => TestPortSetting.Get(q).DataID > 0);
                foreach (var wl in wls)
                {
                    foreach (var ch in chs)
                    {
                        var setting = TestPortSetting.Get(ch);
                        var port    = setting.ChannelID;
                        if (port < 1)
                        {
                            continue;
                        }

                        var name = $"Ch{port}";
                        if (multPort)
                        {
                            name = $"{setting.DataID + 1}-{setting.ChannelID}";
                        }

                        dgvResult.Rows.Add(wl.ToString("F3"), ch, name);
                    }
                    if (multPort)
                    {
                        dgvResult.Rows.Add(wl.ToString("F3"), 0, "1均一性");
                        dgvResult.Rows.Add(wl.ToString("F3"), 1000000, "2均一性");
                    }
                    else
                    {
                        dgvResult.Rows.Add(wl.ToString("F3"), 0, "均一性");
                    }
                }
                dgvResult.MergeColumnNames.Add("Wavelength");
                tabControl3.TabPages.Add(tagPage);
            }

            cbWavelength.Items.AddRange(wls.Select(q => q.ToString("F3")).ToArray());
            var source = new List <KeyValuePair <int, string> >();

            foreach (var channel in chs)
            {
                source.Add(new KeyValuePair <int, string>(channel, MeasurementController.GetPortName(channel)));
            }

            cbChannel.BindingDataSource(source);

            if (cbWavelength.Items.Count > 0)
            {
                cbWavelength.SelectedIndex = 0;
            }
            if (cbChannel.Items.Count > 0)
            {
                cbChannel.SelectedIndex = 0;
            }

            cbUnit.Text = "dBm";
        }
예제 #16
0
        private void GetPointTestData(IMeasurementTask testTask, string temp, TestSystemGroup systemGroup, WorkInfoSpecItem item, bool testAgain)
        {
            if (!item.TestSetting.IsDouble())
            {
                return;
            }
            var wl = item.TestSetting.CastTo(1550D);

            if (item.PortSetting == 0)
            {
                return;
            }

            var type = "Point";

            if (!testAgain && testTask.ContainsTestData(type, temp, item.PortSetting, wl))
            {
                return;
            }

            currentChannel    = MeasurementController.GetSimultaneityPort(testTask.TestOrderID, item.PortSetting);
            currentWavelength = wl;
            testInfoCallback?.Invoke(currentWavelength, currentChannel, currentUnit);

            var pws = default(Dictionary <int, double>);

            if (!MeasurementController.RunPointTest(
                    false,
                    currentWavelength,
                    () =>
            {
                return(!IsStop);
            },
                    () =>
            {
                var setting = TestPortSetting.Get(currentChannel);
                pws = MeasurementController.GetMeterAllChannelPower(setting.DeviceID, setting.SwitchID);
            }))
            {
                throw new Exception(MeasurementController.ErrorString);
            }

            if (pws == null || pws.Count < 1)
            {
                throw new Exception($"读取功率失败,{MeasurementController.ErrorString}");
            }

            var items = MeasurementJob.SpecData.GetTestGroupWorkInfoSpecItems(systemGroup.TestGroupID);

            foreach (var testItem in items)
            {
                var pw = 0D;
                var c  = TestPortSetting.Get(testItem.PortSetting).ChannelID;
                if (!pws.TryGetValue(c, out pw))
                {
                    continue;
                }
                if (pw == double.MinValue)
                {
                    throw new Exception($"读取功率失败,{MeasurementController.ErrorString}");
                }
                AddPointTestData(testTask, type, temp, testItem.PortSetting, currentWavelength, pw);
            }
        }
예제 #17
0
        private void GetManualPointPDLPointPDLTestData(IMeasurementTask testTask, string temp, TestSystemGroup systemGroup, WorkInfoSpecItem item, bool testAgain)
        {
            if (!item.TestSetting.IsDouble())
            {
                return;
            }
            var wl = item.TestSetting.CastTo(1550D);

            if (item.PortSetting == 0)
            {
                return;
            }

            var type = "PointPDL";

            if (!testAgain && testTask.ContainsTestData(type, temp, item.PortSetting, wl))
            {
                return;
            }

            currentChannel    = MeasurementController.GetSimultaneityPort(testTask.TestOrderID, item.PortSetting);
            currentWavelength = wl;
            testInfoCallback?.Invoke(currentWavelength, currentChannel, currentUnit);

            var pws = new Dictionary <int, List <double> >();

            if (!MeasurementController.ChangeWaveLength(currentWavelength))
            {
                throw new Exception($"切换波长失败,{MeasurementController.ErrorString}");
            }


            FormMessageBox.SetShow(null, "正在测试", "请摇动手摇偏振控制器,完成后点击[继续测试]进行测试", 0);

            var setting = TestPortSetting.Get(currentChannel);

            while (FormMessageBox.MessageBoxResult == 0)
            {
                if (IsStop)
                {
                    FormMessageBox.SetClose(2);
                    break;
                }
                var powers = MeasurementController.GetMeterAllChannelPower(setting.DeviceID, setting.SwitchID);
                if (powers.Count < 1)
                {
                    continue;
                }
                var max = new StringBuilder();
                var min = new StringBuilder();
                foreach (var pw in powers)
                {
                    if (!pws.ContainsKey(pw.Key))
                    {
                        pws[pw.Key] = new List <double>();
                    }
                    if (pw.Value != double.MinValue)
                    {
                        pws[pw.Key].Add(pw.Value);
                    }

                    var maxP = pws[pw.Key].Max();
                    var minP = pws[pw.Key].Min();
                    if (maxP == double.MinValue || minP == double.MinValue)
                    {
                        max.Append($"{pw.Key}: -\r\n");
                        min.Append("-\r\n");
                    }
                    else
                    {
                        max.Append($"{pw.Key}: {maxP:F3}\r\n");
                        min.Append($"{minP:F3}\r\n");
                    }
                }
                readingCallback?.Invoke(
                    "-",
                    max.ToString(),
                    min.ToString()
                    );
            }
            readingCallback?.Invoke("-", "-", "-");
            if (FormMessageBox.MessageBoxResult != 1)
            {
                IsStop = true;
                return;
            }

            if (pws == null || pws.Count < 1)
            {
                throw new Exception($"读取功率失败,{MeasurementController.ErrorString}");
            }
            var items = MeasurementJob.SpecData.GetTestGroupWorkInfoSpecItems(systemGroup.TestGroupID);

            foreach (var testItem in items)
            {
                var pw = default(List <double>);
                var c  = TestPortSetting.Get(testItem.PortSetting).ChannelID;
                if (!pws.TryGetValue(c, out pw))
                {
                    continue;
                }
                if (pw.Count < 2)
                {
                    throw new Exception($"读取功率失败,{MeasurementController.ErrorString}");
                }
                AddPointPDLTestData(testTask, type, temp, testItem.PortSetting, currentWavelength, pw);
            }
        }