Exemplo n.º 1
0
        /// <summary>
        /// 移动转轮
        /// </summary>
        /// <param name="position">0 = 打开, 1 = NG4滤光玻璃, 2 = 聚苯乙烯, 3 = 过滤网</param>
        /// <returns></returns>
        public override bool?MoveWheel(int position, string iniFilePath)
        {
            //lock (thisLock)
            //{
            if (!System.IO.File.Exists(iniFilePath))
            {
                ErrorString = "file: \r\n" + iniFilePath + "\r\n is not exist!";
                return(null);
            }
            if (!LoadXPM(iniFilePath))
            {
                return(null);
            }
            OpusCMD334.OpusCommand    command   = new OpusCMD334.OpusCommand();
            OpusCMD334.WriteParameter writePara = new OpusCMD334.WriteParameter();

            bool result = false;

            // string para = "apt", value = "3";

            switch (position)
            {
            //APT= 1(BRM2065) 2(Filter NG9) 3(Filter NG4) 4(Filter NG11) 5(Reference Spectralon) 10(Open)
            case 0:
                //result=command.Command("SendCommand (0, {UNI='apt=10'}");
                result = writePara.WriteParm("APT", "Open", iniFilePath, false);
                //result = command.Command("SendCommand (0, {UNI='apt=10'}");
                break;        //OPEN

            case 1:
                //result = command.Command("SendCommand (0, {UNI='apt=3'}");
                result = writePara.WriteParm("APT", "Filter NG4", iniFilePath, false);
                //result = command.Command("SendCommand (0, {UNI='apt=3'}");
                break;        //Filter NG4

            case 2:
                //result = command.Command("SendCommand (0, {UNI='apt=1'}");
                result = writePara.WriteParm("APT", "Filter BRM2065", iniFilePath, false);
                //result = command.Command("SendCommand (0, {UNI='apt=1'}");
                break;        //BRM2065

            default: result = true; break;
            }
            if (!result)
            {
                ErrorString = writePara.ErrorDesc;
            }
            if (!LoadXPM(iniFilePath))
            {
                return(null);
            }
            return(result);
            //}
        }
Exemplo n.º 2
0
        /// <summary>
        /// 移动转轮
        /// </summary>
        /// <param name="position">0 = 打开, 1 = NG4滤光玻璃, 2 = 聚苯乙烯, 3 = 过滤网</param>
        /// <returns></returns>
        public override bool?MoveWheel(int position, string iniFilePath)
        {
            lock (thisLock)
            {
                if (!System.IO.File.Exists(iniFilePath))
                {
                    ErrorString = "file: \r\n" + iniFilePath + "\r\n is not exist!";
                    return(null);
                }
                if (!LoadXPM(iniFilePath))
                {
                    return(null);
                }

                OpusCMD334.WriteParameter writePara = new OpusCMD334.WriteParameter();
                //writePara.WriteParm("OPF", "Open", iniFilePath, false);
                bool result = false;
                switch (position)
                {
                case 0: result = writePara.WriteParm("OPF", "Open", iniFilePath, false); break;

                case 1: result = writePara.WriteParm("OPF", "Filter NG9", iniFilePath, false); break;

                case 2: result = writePara.WriteParm("OPF", "Filter BRM2065", iniFilePath, false); break;

                default: result = true; break;
                }
                if (!result)
                {
                    ErrorString = writePara.ErrorDesc;
                }
                if (!LoadXPM(iniFilePath))
                {
                    return(null);
                }
                return(result);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 修改配置文件
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="scPara"></param>
        /// <param name="iniFilePath"></param>
        /// <returns></returns>
        public override bool?ModifyIniFile <T>(T scPara, string iniFilePath)
        {
            Type type = scPara.GetType();

            if (type == null || !System.IO.File.Exists(iniFilePath))
            {
                return(false);
            }
            //OpusCMD334.ReadParameter read = new OpusCMD334.ReadParameter();
            //read.ReadParm("FXV");
            //read.ReadParm("LXV");
            //加载XPM扫描参数文件
            if (LoadXPM(iniFilePath) == false)
            {
                return(false);
            }
            OpusCMD334.WriteParameter writePara = new OpusCMD334.WriteParameter();
            foreach (var p in type.GetProperties())
            {
                if (string.Equals(p.Name, "xRegion"))
                {
                    ModifyIniFile(p.GetValue(scPara, null), iniFilePath);
                }
                switch (p.Name)
                {
                case "resolution":
                    if (!writePara.WriteParm("RES", p.GetValue(scPara, null).ToString(), iniFilePath, false))
                    {
                        ErrorString = writePara.ErrorDesc;
                        return(false);
                    }
                    break;

                case "count":
                    if (!writePara.WriteParm("NSS", p.GetValue(scPara, null).ToString(), iniFilePath, false))
                    {
                        ErrorString = writePara.ErrorDesc;
                        return(false);
                    }
                    if (!writePara.WriteParm("NSR", p.GetValue(scPara, null).ToString(), iniFilePath, false))
                    {
                        ErrorString = writePara.ErrorDesc;
                        return(false);
                    }
                    break;

                case "minumum":
                    if (!writePara.WriteParm("HFQ", p.GetValue(scPara, null).ToString(), iniFilePath, false))
                    {
                        ErrorString = writePara.ErrorDesc;
                        return(false);
                    }
                    break;

                case "maxumum":
                    if (!writePara.WriteParm("LFQ", p.GetValue(scPara, null).ToString(), iniFilePath, false))
                    {
                        ErrorString = writePara.ErrorDesc;
                        return(false);
                    }
                    break;

                default: break;
                }
            }
            return(true);
        }