コード例 #1
0
ファイル: HtmLightTrig.cs プロジェクト: xhyangxianjun/ASMZZZ
        bool _InitParamEqualExisted() //内外参数设置一样一样的
        {
            if (null == config_file || null == use_aps_card || use_htnet_card == null ||
                offline_mode == null || max_axis_num == null || max_io_num == null ||
                max_dev_num == null || max_module_num == null)
            {
                return(false);
            }
            HTM.INIT_PARA currParam = new HTM.INIT_PARA();
            currParam.para_file      = config_file;
            currParam.use_aps_card   = (byte)(use_aps_card == yesnoRange[0] as string?1 : 0);
            currParam.use_htnet_card = (byte)(use_htnet_card == yesnoRange[0] as string? 1 : 0);


            currParam.offline_mode = (byte)Array.IndexOf(openModeRange, offline_mode);

            currParam.max_axis_num = (ushort)max_axis_num;
            currParam.max_io_num   = (ushort)max_io_num;

            currParam.max_dev_num = (ushort)max_dev_num;

            currParam.max_module_num = (ushort)max_module_num;
            return(HtmDllManager.InitParamEqualExisted(currParam));
        }
コード例 #2
0
ファイル: HtmLightTrig.cs プロジェクト: xhyangxianjun/ASMZZZ
        /// <summary>
        /// 对象初始化
        /// </summary>
        /// <returns>操作成功返回True,失败返回false,可通过GetInitErrorInfo()获取错误信息</returns>
        public bool Initialize()
        {
            bool ret = false;

            //string errorInfo = "Unknown-Error!";
            lock (HtmDllManager.AsynLocker)
            {
                if (IsDeviceOpen)
                {
                    CloseDevice();
                }
                do
                {
                    if (null == config_file)
                    {
                        _initErrorInfo = "初始化参数:\"配置文件\"未设置!";
                        break;
                    }
                    if (use_aps_card == null)
                    {
                        _initErrorInfo = "初始化参数:\"使用凌华控制卡\"未设置!";;
                        break;
                    }
                    if (use_htnet_card == null)
                    {
                        _initErrorInfo = "初始化参数:\"使用HTM控制卡\"未设置!";
                        break;
                    }
                    if (offline_mode == null)
                    {
                        _initErrorInfo = "初始化参数:\"板卡打开模式\"未设置!";
                        break;
                    }
                    if (max_axis_num == null)
                    {
                        _initErrorInfo = "初始化参数:\"最大轴数\"未设置!";
                        break;
                    }
                    if (max_io_num == null)
                    {
                        _initErrorInfo = "初始化参数:\"最大IO数量\"未设置!";
                        break;
                    }
                    if (max_dev_num == null)
                    {
                        _initErrorInfo = "初始化参数:\"其他设备数量\"未设置!";
                        break;
                    }
                    if (max_module_num == null)
                    {
                        _initErrorInfo = "初始化参数:\"模块数量\"未设置!";
                        break;
                    }

                    if (null == devIndex)
                    {
                        _initErrorInfo = "初始化参数:\"设备序号\"未设置!";
                        break;
                    }
                    lock (HtmDllManager.AsynLocker)
                    {
                        if (HtmDllManager.IsHtmParamInited()) //HTM控制卡已打开
                        {
                            if (!_InitParamEqualExisted())    //当前预设参数和已打开的控制卡参数不同
                            {
                                _initErrorInfo = "HtmLightTrig初始化参数和已打开的HTM库中的初始化参数不同!";
                                break;
                            }
                        }
                        if (HtmDllManager.LightTrigInited.Contains((int)devIndex))
                        {
                            _initErrorInfo = "系统中已存在DevIndex = " + devIndex + " 的光源触发板对象!";
                            break;
                        }

                        HTM.INIT_PARA currParam = new HTM.INIT_PARA();
                        currParam.para_file      = config_file;
                        currParam.use_aps_card   = (byte)(use_aps_card == yesnoRange[0] as string? 1 : 0);
                        currParam.use_htnet_card = (byte)(use_htnet_card == yesnoRange[0] as string? 1 : 0);


                        currParam.offline_mode = (byte)Array.IndexOf(openModeRange, offline_mode);

                        currParam.max_axis_num = (ushort)max_axis_num;
                        currParam.max_io_num   = (ushort)max_io_num;

                        currParam.max_dev_num = (ushort)max_dev_num;

                        currParam.max_module_num = (ushort)max_module_num;
                        HtmDllManager.SetInitParam(currParam);

                        HtmDllManager.LightTrigInited.Add((int)devIndex);
                    }
                    ret            = true;
                    _initErrorInfo = "Success";
                } while (false);
            }
            IsInitOK = ret;
            return(ret);
        }
コード例 #3
0
ファイル: HTMMotionDaq.cs プロジェクト: xhyangxianjun/ASMZZZ
        /// <summary>
        /// 初始化动作,并不打开卡,只是检查参数的合法性,打开卡的动作在Open()函数中
        /// </summary>
        /// <returns></returns>
        public bool Initialize()
        {
            bool ret = false;

            //string errorInfo = "Unknown-Error!";
            lock (HtmDllManager.AsynLocker)
            {
                //if (IsDeviceOpen)
                //    CloseDevice();
                do
                {
                    //if (HtmDllManager.MotionDaqCount > 0)
                    //{
                    //    _initErrorInfo = "系统中已存在HTM类型的MDD_Htm设备实例对象,不能初始化多个MDD_Htm设备对象!";
                    //    break;
                    //}
                    if (null == config_file)
                    {
                        _initErrorInfo = "初始化参数:\"配置文件\"未设置!";
                        break;
                    }
                    if (use_aps_card == null)
                    {
                        _initErrorInfo = "初始化参数:\"使用凌华控制卡\"未设置!";;
                        break;
                    }
                    if (use_htnet_card == null)
                    {
                        _initErrorInfo = "初始化参数:\"使用HTM控制卡\"未设置!";
                        break;
                    }
                    if (offline_mode == null)
                    {
                        _initErrorInfo = "初始化参数:\"板卡打开模式\"未设置!";
                        break;
                    }
                    if (max_axis_num == null)
                    {
                        _initErrorInfo = "初始化参数:\"最大轴数\"未设置!";
                        break;
                    }
                    if (max_io_num == null)
                    {
                        _initErrorInfo = "初始化参数:\"最大IO数量\"未设置!";
                        break;
                    }
                    if (max_dev_num == null)
                    {
                        _initErrorInfo = "初始化参数:\"其他设备数量\"未设置!";
                        break;
                    }
                    if (max_module_num == null)
                    {
                        _initErrorInfo = "初始化参数:\"模块数量\"未设置!";
                        break;
                    }
                    lock (HtmDllManager.AsynLocker)
                    {
                        if (HtmDllManager.IsHtmParamInited()) //HTM控制卡参数已设置
                        {
                            if (!_InitParamEqualExisted())    //当前预设参数和已打开的控制卡参数不同
                            {
                                _initErrorInfo = "MDD_Htm初始化参数和已打开的HTM库中的初始化参数不同!";
                                break;
                            }
                        }
                        //else
                        if (HtmDllManager.OpendDevCount > 0)
                        {
                            IsDeviceOpen = true;
                            HtmDllManager.OpendDevCount++;
                        }
                        else
                        {
                            HTM.INIT_PARA currParam = new HTM.INIT_PARA();
                            currParam.para_file      = config_file;
                            currParam.use_aps_card   = (byte)(use_aps_card == yesnoRange[0] as string? 1 : 0);
                            currParam.use_htnet_card = (byte)(use_htnet_card == yesnoRange[0] as string? 1 : 0);


                            currParam.offline_mode = (byte)Array.IndexOf(openModeRange, offline_mode);

                            currParam.max_axis_num = (ushort)max_axis_num;
                            currParam.max_io_num   = (ushort)max_io_num;

                            currParam.max_dev_num = (ushort)max_dev_num;

                            currParam.max_module_num = (ushort)max_module_num;
                            HtmDllManager.SetInitParam(currParam);
                        }

                        //HtmDllManager.MotionDaqCount++;
                    }
                    ret            = true;
                    _initErrorInfo = "Success";
                    //errorInfo = "Success";
                } while (false);
            }
            //_initErrorInfo = errorInfo;
            IsInitOK = ret;
            return(ret);
        }