Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            IMeasurementSetting    setting;
            ICommunicatorConfigure config;
            var data  = GetData();
            var itype = data["Instrument_Type"];
            var ctype = data["Instrument_Communicator_Type"];
            var cdata = data["Instrument_Communicator_Setting"];

            if (!InstrumentConfig.GetConfig(ctype, cdata, out config))
            {
                AppFramework.Context.ShowError($"连接类型错误");
                return;
            }

            if (_group == "PointOpticalSource" && itype == "GeneralRouterOpticalSource01")
            {
                var router = new Incht.MeasurementSystem.Instruments.Router.UC.FSW1U1x16SMFCPCRouter();
                router.Initialize(DefaultMeasurementSetting.Create(ctype, config));

                var wlSetting = new Dictionary <double, int[]>();

                setting = new GeneralRouterSetting()
                {
                    CustomMeasurementName = "点光源",
                    Router            = router,
                    WaveLengthSetting = wlSetting
                };
            }
            else if (_group == "PolarizationController" && itype == "PCU100") //PCU100
            {
                var deviceName = (this.Parent.Controls.Find("tbDeviceName", true).FirstOrDefault() as TextBox).Text;
                setting = PCU100Setting.Create("PCU100", deviceName, config);
            }
            else
            {
                setting = DefaultMeasurementSetting.Create(ctype, config);
            }

            var measurement = MeasurementManger.CreateMeasurementInstance(
                _system, _group, itype, setting);

            if (measurement == null)
            {
                panel4.BackColor = Color.Red;
                AppFramework.Context.ShowConfirm($"初始仪器失败");
                return;
            }

            if (!measurement.Connect())
            {
                panel4.BackColor = Color.Red;
                AppFramework.Context.ShowConfirm($"连接仪器失败:{measurement.ErrorString}");
                measurement = null;
                return;
            }
            measurement.Disconnect();
            measurement      = null;
            panel4.BackColor = Color.LimeGreen;
        }
Esempio n. 2
0
        public void SetSetting(string system, string group)
        {
            _system = system;
            _group  = group;
            var ds = MeasurementManger.GetMeasurementDataSource(system, group);

            ds1.Clear();
            foreach (var item in ds)
            {
                ds1.Add(item);
            }
            if (ds.Count > 0)
            {
                comboBox1.SelectedValue = ds[0].Key;
            }
            comboBox1_SelectedValueChanged(comboBox1, EventArgs.Empty);
        }
Esempio n. 3
0
        private void comboBox1_SelectedValueChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedValue == null || string.IsNullOrEmpty(_system) || string.IsNullOrEmpty(_group))
            {
                return;
            }

            var id = comboBox1.SelectedValue.ToString();

            panel4.BackColor = this.BackColor;
            var ds = MeasurementManger.GetCommunicatorDataSource(_system, _group, id);

            ds2.Clear();
            foreach (var item in ds)
            {
                ds2.Add(item);
            }
            if (ds.Count > 0)
            {
                comboBox2.SelectedValue = ds[0].Key;
                comboBox2_SelectedValueChanged(comboBox2, EventArgs.Empty);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 注册仪器
        /// </summary>
        public static void Regisry()
        {
            //注册测试计算函数
            Incht.MeasurementSystem.Framework.Calculate.Measuring.PointTestMeasuring.Regisry();

            var systemID = Framework.MeasurementSystemSetting.AppID;

            instrumentGroup.Clear();
            instrumentGroup[InstrumentType.PointOpticalSource]     = "点光源";
            instrumentGroup[InstrumentType.PowerMeter]             = "功率计";
            instrumentGroup[InstrumentType.PolarizationController] = "偏振控制器";

            Configs.Clear();
            foreach (var item in instrumentGroup)
            {
                Configs[item.Key] = new InstrumentConfig(systemID, item.Key.ToString());
            }
            if (Framework.MeasurementSystemSetting.SystemData.Setting.Profile.EnabledSystemTypes.Contains(1000))
            {
                MeasurementManger.Regisry(
                    systemID,
                    InstrumentType.PointOpticalSource.ToString(),
                    typeof(Incht.MeasurementSystem.Instruments.Debug.DebuggerTLS),
                    new List <Type>()
                {
                    typeof(SerialPortCommunicatior)
                },
                    "DEBUG",
                    "调试");
                MeasurementManger.Regisry(
                    systemID,
                    InstrumentType.PowerMeter.ToString(),
                    typeof(Incht.MeasurementSystem.Instruments.Debug.DebuggerPM),
                    new List <Type>()
                {
                    typeof(SerialPortCommunicatior)
                },
                    "DEBUG",
                    "调试");

                MeasurementManger.Regisry(
                    systemID,
                    InstrumentType.PolarizationController.ToString(),
                    typeof(Incht.MeasurementSystem.Instruments.Debug.DebuggerPointPDL),
                    new List <Type>()
                {
                    typeof(SerialPortCommunicatior)
                },
                    "DEBUG",
                    "调试");
            }

            //注册光源
            MeasurementManger.Regisry(
                systemID,
                InstrumentType.PointOpticalSource.ToString(),
                typeof(GeneralRouterOpticalSource),
                new List <Type>()
            {
                typeof(SerialPortCommunicatior)
            },
                "GeneralRouterOpticalSource01",
                "点光源(光开关)");


            //注册GM8820B
            MeasurementManger.Regisry(
                systemID,
                InstrumentType.PowerMeter.ToString(),
                typeof(UC8822PowerMeter),
                new List <Type>()
            {
                typeof(SerialPortCommunicatior)
            },
                "UC8822PowerMeter",
                "UC UC8820");

            //注册GM8046B
            MeasurementManger.Regisry(
                systemID,
                InstrumentType.PowerMeter.ToString(),
                typeof(GM8046BPowerMeter),
                new List <Type>()
            {
                typeof(SerialPortCommunicatior)
            },
                "GM8046BPowerMeter",
                "UC GM8046B");

            MeasurementManger.Regisry(
                systemID,
                InstrumentType.PowerMeter.ToString(),
                typeof(GM8046BPowerMeter),
                new List <Type>()
            {
                typeof(SerialPortCommunicatior)
            },
                "GM8012PowerMeter",
                "UC GM8012");

            /*
             * MeasurementManger.Regisry(
             *     systemID,
             *     InstrumentType.PowerMeter.ToString(),
             *     typeof(AI9422XPowerMeter),
             *     new List<Type>() { typeof(SerialPortCommunicatior) },
             *     "AI9422XPowerMeter",
             *     "AI AI9422X");
             */
            //注册UC8202
            MeasurementManger.Regisry(
                systemID,
                InstrumentType.PowerMeter.ToString(),
                typeof(UC8202PowerMeter),
                new List <Type>()
            {
                typeof(SerialPortCommunicatior)
            },
                "UC8202PowerMeter",
                "UC UC8202");

            //注册UC8728
            MeasurementManger.Regisry(
                systemID,
                InstrumentType.PowerMeter.ToString(),
                typeof(UC8728PowerMeter),
                new List <Type>()
            {
                typeof(SerialPortCommunicatior)
            },
                "UC8728PowerMeter",
                "UC UC8728");

            MeasurementManger.Regisry(
                systemID,
                InstrumentType.PolarizationController.ToString(),
                typeof(Incht.MeasurementSystem.Instruments.Debug.DebuggerPointPDL),
                new List <Type>()
            {
                typeof(SerialPortCommunicatior)
            },
                "Debug",
                "不启用");
            //注册8015
            MeasurementManger.Regisry(
                systemID,
                InstrumentType.PolarizationController.ToString(),
                typeof(GM8015PolarizationController),
                new List <Type>()
            {
                typeof(SerialPortCommunicatior)
            },
                "GM8015PolarizationController",
                "UC GM8015");

            MeasurementManger.Regisry(
                systemID,
                InstrumentType.PolarizationController.ToString(),
                typeof(UC8340PolarizationController),
                new List <Type>()
            {
                typeof(SerialPortCommunicatior)
            },
                "UC8340PolarizationController",
                "UC UC8340");

            /*
             * MeasurementManger.Regisry(
             * systemID,
             * InstrumentType.PolarizationController.ToString(),
             * typeof(NoRespondGM8015PolarizationController),
             * new List<Type>() { typeof(SerialPortCommunicatior) },
             * "NoRespondGM8015PolarizationController",
             * "UC GM8015(无反馈)");
             */
            //AI9901A
            MeasurementManger.Regisry(
                systemID,
                InstrumentType.PolarizationController.ToString(),
                typeof(AI9901APolarizationController),
                new List <Type>()
            {
                typeof(SerialPortCommunicatior)
            },
                "AI9901APolarizationController",
                "AI AI9901A");
        }
Esempio n. 5
0
        /// <summary>
        /// 初始仪器
        /// </summary>
        /// <returns></returns>
        public bool Initialize()
        {
            if (instrumentGroup.Count < 1 || instrumentGroup.Count != Configs.Count)
            {
                ErrorString = "系统未注册仪器";
                return(false);
            }
            foreach (var item in Configs)
            {
                var type = item.Key;
                var data = item.Value;
                if (data.Instrument_Type == "None")
                {
                    instrument[type] = null;
                    continue;
                }

                var groupName = instrumentGroup[type];
                ICommunicatorConfigure config = data.Instrument_Communicator_Config;
                IMeasurementSetting    setting;
                if (item.Key == InstrumentType.PointOpticalSource && item.Value.Instrument_Type == "GeneralRouterOpticalSource01")
                {
                    var router = new Incht.MeasurementSystem.Instruments.Router.UC.FSW1U1x16SMFCPCRouter();
                    router.Initialize(DefaultMeasurementSetting.Create(groupName, config));
                    //1525nm,1270nm,1550nm
                    var wlSetting = new Dictionary <double, int[]>()
                    {
                        { 1525D, new int[] { 1, 1 } },
                        { 1270D, new int[] { 1, 2 } },
                        { 1550D, new int[] { 1, 3 } },
                    };
                    if (!string.IsNullOrEmpty(item.Value["Instrument_WaveLengthSetting"]))
                    {
                        wlSetting = item.Value["Instrument_WaveLengthSetting"].FromJsonString <Dictionary <double, int[]> >();
                    }

                    setting = new GeneralRouterSetting()
                    {
                        CustomMeasurementName = "点光源",
                        Router            = router,
                        WaveLengthSetting = wlSetting
                    };
                }
                else
                {
                    setting = DefaultMeasurementSetting.Create(groupName, config);
                }

                instrument[type] = MeasurementManger.CreateMeasurementInstance(data.SystemID, data.GroupID, data.Instrument_Type, setting);

                if (instrument[type] == null)
                {
                    ErrorString = $"初始仪器{groupName}失败";
                    return(false);
                }

                if (item.Key == InstrumentType.PointOpticalSource)
                {
                    if (!string.IsNullOrEmpty(item.Value["Instrument_WaitTime"]))
                    {
                        waitTime = item.Value["Instrument_WaitTime"].CastTo(1000);
                    }
                }
                else if (item.Key == InstrumentType.PolarizationController)
                {
                    if (!string.IsNullOrEmpty(item.Value["Instrument_Rate"]))
                    {
                        pdlRate = item.Value["Instrument_Rate"].CastTo(1);
                    }
                    if (!string.IsNullOrEmpty(item.Value["Instrument_TestTime"]))
                    {
                        PDLTestTime = item.Value["Instrument_TestTime"].CastTo(3D);
                    }
                }
            }

            return(true);
        }