Beispiel #1
0
        public ActionResult <string> SetData(TestSystemGroupModifyModel data)
        {
            var newData = new TestSystemGroup()
            {
                TestGroupID       = data.TestGroupID,
                TestGroupName     = data.TestGroupName,
                TestGroupText     = data.TestGroupText,
                TestGroupSetting  = data.TestGroupSetting,
                TestGroupTestType = data.TestGroupTestType,
                ProductClassID    = data.ProductClassID,
                OrderID           = data.OrderID
            };

            try
            {
                if (repository.SaveData(newData))
                {
                    return(ActionResult <string> .SetSuccess($"保存 {ItemName} 成功", "保存成功"));
                }
                else
                {
                    return(ActionResult <string> .SetError($"{ItemName} 已经被删除", "保存失败"));
                }
            }
            catch (Exception ex)
            {
                return(ActionResult <string> .SetError(ex.Message, "保存失败"));
            }
        }
Beispiel #2
0
        private int ShowFailMessage(IMeasurementTask testTask, string temp, TestSystemGroup systemGroup, WorkInfoSpecItem item,
                                    string tipMsg, string showMsg)
        {
            tipCallback?.Invoke(testTask.TestOrderID, 2, tipMsg, 0);
            var msg = ShowMessage(2, $"{showMsg}\r\n按[重新测试]对项目重新测试,按[继续测试]进行下一测试。", "测试失败");

            if (msg == 3)
            {
                TestSpecItem(testTask, temp, systemGroup, item, true);
            }

            return(msg);
        }
Beispiel #3
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;
        }
Beispiel #4
0
 public void SetUp()
 {
     World     = new World("Test");
     TestGroup = World.CreateSystem <TestSystemGroup>();
     TestGroup.AddSystemToUpdateList(World.CreateSystem <TestSystem2>());
 }
Beispiel #5
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);
            }
        }
Beispiel #6
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);
            }
        }
Beispiel #7
0
        private void TestSpecItem(IMeasurementTask testTask, string temp, TestSystemGroup systemGroup, WorkInfoSpecItem item, bool testAgain = false)
        {
            if (IsStop)
            {
                return;
            }

            testCallback?.Invoke(testTask.StartTime, testTask.TestOrderID, -1, "", item.SpecItemID, "正在测试", "", 3);

            try
            {
                switch (systemGroup.TestGroupTestType)
                {
                case "None":     //计算

                    break;

                case "Swept":     //扫描
                    throw new Exception("系统禁用了扫描功能");

                case "PDLSwept":     //扫描
                    throw new Exception("系统禁用了扫描功能");

                case "RL":     //回损
                    GetPointRLTestData(testTask, temp, systemGroup, item, testAgain);
                    break;

                case "Point":     //点测
                    GetPointTestData(testTask, temp, systemGroup, item, testAgain);
                    break;

                case "PointPDL":
                    GetPointPDLTestData(testTask, temp, systemGroup, item, testAgain);
                    break;

                case "ManualPointPDL":
                    GetManualPointPDLPointPDLTestData(testTask, temp, systemGroup, item, testAgain);
                    break;
                }
            }
            catch (Exception ex)
            {
                lastGroupResult = -1;
                testCallback?.Invoke(testTask.StartTime, testTask.TestOrderID, -1, "", item.SpecItemID, ex.Message, "", 2);
                IsStop = true;
                return;
            }

            if (IsStop)
            {
                testCallback?.Invoke(testTask.StartTime, testTask.TestOrderID, -1, "", item.SpecItemID, "停止测试", "", 2);
                return;
            }

            var value1     = "";
            var value2     = "";
            var result     = testTask.MeasurementTest(item.SpecItemID);
            var failString = new List <string>();

            lastGroupResult = Math.Min(lastGroupResult, result.Result);
            if (result.Result < 1)
            {
                failString.Add(item.ItemName);
                value1 = result.Result < 0 ? "-" : result.Data.ToString("F2");
            }
            else
            {
                value1 = result.Data.ToString("F2");
            }

            testCallback?.Invoke(testTask.StartTime, testTask.TestOrderID, item.PortSetting, item.SystemTypeID, item.SpecItemID, value1, value2, result.Result > 0 ? 1 : 2);
            if (failString.Count > 0 && Framework.MeasurementSystemSetting.SystemData.Setting.Profile.TestFailTreatmentType > 0)
            {
                if (Framework.MeasurementSystemSetting.SystemData.Setting.Profile.TestFailTreatmentType == 2)
                {
                    IsStop = true;
                    return;
                }
                ShowFailMessage(testTask, temp, systemGroup, item, result.Message, $"项目测试结果失败: \r\n{string.Join("\r\n", failString)}");
            }
        }
Beispiel #8
0
        /// <summary>
        /// 测试项
        /// </summary>
        /// <param name="tempIndex"></param>
        /// <param name="tempString"></param>
        /// <param name="systemGroup"></param>
        /// <param name="specItems"></param>
        private void EachSpecItems(int tempIndex, string tempString, TestSystemGroup systemGroup, List <Guid> specItems)
        {
            if (IsStop)
            {
                return;
            }
            lastGroupResult = int.MaxValue;
            foreach (var specItemID in specItems)
            {
                if (IsStop)
                {
                    return;
                }
                var item = MeasurementJob.SpecData.GetWorkInfoSpecItem(specItemID);
                foreach (var task in MeasurementTasks)
                {
                    tipCallback?.Invoke(task.TestOrderID, 3, $"准备测试{item.ItemName}", 0);
                }

                if (currentSystemGroup != systemGroup.TestGroupID)
                {
                    currentSystemGroup = systemGroup.TestGroupID;

                    if (systemGroup.TestGroupSetting == "1")
                    {
                        for (int i = 0; i < MeasurementTasks.Count; i++)
                        {
                            var testTask = MeasurementTasks[i];
                            testCallback?.Invoke(testTask.StartTime, testTask.TestOrderID, -1, "", item.SpecItemID, "正在测试", "", 3);
                        }

                        if (item.PortSetting != 0)
                        {
                            currentChannel = item.PortSetting;
                        }
                        currentWavelength = item.TestSetting.CastTo(1550D);

                        var text   = systemGroup.TestGroupText.ExtendReplace("<t>", tempString, false);
                        var result = ShowMessage(0, text, "正在测试");
                        for (int i = 0; i < MeasurementTasks.Count; i++)
                        {
                            var testTask = MeasurementTasks[i];
                            if (IsStop)
                            {
                                testCallback?.Invoke(testTask.StartTime, testTask.TestOrderID, -1, "", item.SpecItemID, "停止测试", "", 2);
                            }
                        }
                        if (result != 1)
                        {
                            return;
                        }
                    }
                }
                else if (systemGroup.TestGroupTestType != "RL" &&
                         systemGroup.TestGroupTestType != "Manual" &&
                         systemGroup.TestGroupTestType != "None" &&
                         currentTempOrder != -1 && currentTempOrder != tempIndex)
                {
                    for (int i = 0; i < MeasurementTasks.Count; i++)
                    {
                        var testTask = MeasurementTasks[i];
                        testCallback?.Invoke(testTask.StartTime, testTask.TestOrderID, -1, "", item.SpecItemID, "正在测试", "", 3);
                    }

                    var result = ShowMessage(0, $"正在切换到温度{tempString}℃,\r\n确认无误后点击[确定按钮]继续测试", "正在测试");
                    for (int i = 0; i < MeasurementTasks.Count; i++)
                    {
                        var testTask = MeasurementTasks[i];
                        if (IsStop)
                        {
                            testCallback?.Invoke(testTask.StartTime, testTask.TestOrderID, -1, "", item.SpecItemID, "停止测试", "", 2);
                        }
                    }
                    if (result != 1)
                    {
                        return;
                    }
                }

                if (currentTempOrder != tempIndex)
                {
                    if (systemGroup.TestGroupTestType != "RL" &&
                        systemGroup.TestGroupTestType != "Manual" &&
                        systemGroup.TestGroupTestType != "None" && currentTempOrder != -1)
                    {
                        var result = ChangeTemp(tempIndex, tempString);
                        if (result != 1)
                        {
                            return;
                        }
                    }
                    currentTempOrder = tempIndex;
                }
                foreach (var task in MeasurementTasks)
                {
                    tipCallback?.Invoke(task.TestOrderID, 3, $"正在测试{item.ItemName}", 0);
                }
                for (int i = 0; i < MeasurementTasks.Count; i++)
                {
                    var testTask = MeasurementTasks[i];
                    TestSpecItem(testTask, tempString, systemGroup, item);
                }
            }
        }