Exemplo n.º 1
0
 public void SetModuleInfo(IJFDevice_LightController module, string[] chnIDs = null)
 {
     _module = module;
     _chnIDs = chnIDs;
     if (_isFormLoaded)
     {
         AdjustUI();
     }
 }
Exemplo n.º 2
0
        void _UpdateLight()
        {
            string[] allLightDevs = JFHubCenter.Instance.InitorManager.GetIDs(typeof(IJFDevice_LightController));
            if (null == allLightDevs || 0 == allLightDevs.Length) //系统中不存在已命名的AI通道
            {
                ShowTips("设备列表中不存在开关光源通道!");
                btAdd.Enabled = false;
            }
            else
            {
                btAdd.Enabled = true;
            }

            string[] chnNames = _station.LightChannelNames;
            if (null == chnNames || 0 == chnNames.Length)
            {
                btDel.Enabled = false;
                return;
            }
            else//if(null != chnNames)
            {
                btDel.Enabled = true;
                foreach (string chnName in chnNames)
                {
                    DataGridViewRow         row      = new DataGridViewRow();
                    DataGridViewTextBoxCell cellName = new DataGridViewTextBoxCell();
                    cellName.Value = chnName;
                    DataGridViewTextBoxCell cellInfo    = new DataGridViewTextBoxCell();
                    JFDevCellInfo           chnCellInfo = JFHubCenter.Instance.MDCellNameMgr.GetLightCtrlChannelInfo(chnName);
                    if (null == chnCellInfo)
                    {
                        cellName.Style.ForeColor = Color.Red;
                        cellInfo.Value           = "无效的通道名称,在名称配置表中不存在!";
                        cellInfo.Style.ForeColor = Color.Red;
                    }
                    else
                    {
                        IJFDevice_LightController lightDev = JFHubCenter.Instance.InitorManager.GetInitor(chnCellInfo.DeviceID) as IJFDevice_LightController;
                        if (null == lightDev)
                        {
                            cellName.Style.ForeColor = Color.Red;
                            cellInfo.Value           = "控制器在设备列表中不存在!";
                            cellInfo.Style.ForeColor = Color.Red;
                        }
                        else
                        {
                            cellInfo.Value = string.Format("控制器:{0} - 通道:{1}", chnCellInfo.DeviceID, chnCellInfo.ChannelIndex);
                        }
                        //cellInfo.Value = string.Format("控制器:{0} - 模块:{1} - 通道:{2}", devInfo.DeviceID, devInfo.ModuleIndex, devInfo.ChannelIndex);
                    }
                    row.Cells.Add(cellName);
                    row.Cells.Add(cellInfo);
                    dgvNameInfos.Rows.Add(row);
                }
            }
        }
Exemplo n.º 3
0
 public void SetChannelInfo(IJFDevice_LightController module, int chn, string chnID = null)
 {
     _module   = module;
     _chn      = chn;
     _chnID    = chnID == null ? "通道_" + chn.ToString() : chnID;
     tbID.Text = _chnID;
     if (_isFormLoaded)
     {
         UpdateChannelStatus();
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// 保存当前视觉配置
        /// </summary>
        /// <param name="filePath"></param>
        public bool SaveProgram(string programName, out string errorInfo)
        {
            errorInfo = "UnknownError";
            bool ret = false;

            do
            {
                if (string.IsNullOrEmpty(programName))
                {
                    errorInfo = "配置名称为空字串";
                    break;
                }

                JFVisionManager        vm = JFHubCenter.Instance.VisionMgr;
                JFSingleVisionCfgParam vc = null;
                if (vm.ContainSingleVisionCfgByName(programName))
                {
                    vc = vm.GetSingleVisionCfgByName(programName);
                }
                else
                {
                    vc = new JFSingleVisionCfgParam();
                }
                string ei;
                if (!OpenEnableDevices(out ei))
                {
                    errorInfo = "设备未全部打开并使能:" + ei;
                    break;
                }
                ///相机参数
                double exposure = 0; //相机曝光值
                double gain     = 0;
                bool   isRevsX  = false;
                bool   isRevsY  = false;

                int errCode = _cmr.GetExposure(out exposure);
                if (errCode != 0)
                {
                    errorInfo = "获取相机曝光值失败:" + _cmr.GetErrorInfo(errCode);
                    break;
                }

                errCode = _cmr.GetGain(out gain);
                if (errCode != 0)
                {
                    errorInfo = "获取相机增益值失败:" + _cmr.GetErrorInfo(errCode);
                    break;
                }

                errCode = _cmr.GetReverseX(out isRevsX);
                if (errCode != 0)
                {
                    errorInfo = "获取相机X镜像参数失败:" + _cmr.GetErrorInfo(errCode);
                    break;
                }

                errCode = _cmr.GetReverseY(out isRevsY);
                if (errCode != 0)
                {
                    errorInfo = "获取相机Y镜像参数失败:" + _cmr.GetErrorInfo(errCode);
                    break;
                }

                ///光源通道参数
                int[] intensities = null;
                if (_lightNames != null && _lightNames.Length > 0)
                {
                    intensities = new int[_lightNames.Length];
                    for (int i = 0; i < _lightNames.Length; i++)
                    {
                        int nVal = 0;
                        IJFDevice_LightController dev = _lightChns[i].Device() as IJFDevice_LightController;
                        errCode = dev.GetLightIntensity(_lightChns[i].CellInfo().ChannelIndex, out nVal);
                        if (errCode != 0)
                        {
                            errorInfo = "获取光源:\"" + _lightNames[i] + "\"亮度值失败:" + dev.GetErrorInfo(errCode);
                            goto LoopExit;
                        }
                        intensities[i] = nVal;
                    }
                }


                double[] axisPos = null;
                ///配置轴参数
                if (_cfgAxisNames != null && _cfgAxisNames.Length > 0)
                {
                    double dVal = 0;
                    axisPos = new double[_cfgAxisNames.Length];
                    for (int i = 0; i < _cfgAxisNames.Length; i++)
                    {
                        IJFDevice_MotionDaq md = _cfgAxes[i].Device() as IJFDevice_MotionDaq;
                        JFDevCellInfo       ci = _cfgAxes[i].CellInfo();
                        errCode = md.GetMc(ci.ModuleIndex).GetFbkPos(ci.ChannelIndex, out dVal);
                        if (errCode != 0)
                        {
                            errorInfo = "获取轴:\"" + _cfgAxisNames[i] + "\"位置失败:" + md.GetMc(ci.ModuleIndex).GetErrorInfo(errCode);
                            goto LoopExit;
                        }
                        axisPos[i] = dVal;
                    }
                }

                vc.CmrReverseX      = isRevsX;
                vc.CmrReverseY      = isRevsY;
                vc.CmrExposure      = exposure;
                vc.CmrGain          = gain;
                vc.LightChnNames    = _lightNames == null ? new string[] { } : _lightNames;
                vc.LightIntensities = intensities == null ? new int[] { } : intensities;
                vc.AxisNames        = _cfgAxisNames == null ? new string[] { } : _cfgAxisNames;
                vc.AxisPositions    = axisPos == null ? new double[] { } : axisPos;
                if (!vm.ContainSingleVisionCfgByName(programName))
                {
                    vc.Name        = programName;
                    vc.OwnerAssist = Name;
                    vm.AddSingleVisionCfg(programName, vc);
                }
                else
                {
                    vm.Save();
                }

                errorInfo = "Success";
                ret       = true;
            } while (false);
LoopExit:
            return(ret);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 检查设备通道是否存在并且可用
        /// </summary>
        /// <param name="category"></param>
        /// <param name="cellName"></param>
        /// <param name="initor"></param>
        /// <param name="cellInfo"></param>
        /// <param name="errorInfo"></param>
        /// <returns></returns>
        public static bool CheckDevCellName(string category, string cellName, out IJFInitializable initor, out JFDevCellInfo ci, out string errorInfo)
        {
            initor    = null;
            ci        = null;
            errorInfo = null;

            if (string.IsNullOrEmpty(cellName))
            {
                errorInfo = "参数项\"cellName\"为空";
                return(false);
            }
            JFDevCellNameManeger nameMgr   = JFHubCenter.Instance.MDCellNameMgr;
            JFInitorManager      initorMgr = JFHubCenter.Instance.InitorManager;
            JFDevCellInfo        cellInfo  = null;

            if (category == DO) //获取数字量输出通道信息
            {
                cellInfo = nameMgr.GetDoCellInfo(cellName);
                if (null == cellInfo)
                {
                    errorInfo = "设备命名表中不存在DO:" + cellName;
                    return(false);
                }

                IJFInitializable dev = initorMgr.GetInitor(cellInfo.DeviceID);
                if (null == dev)
                {
                    errorInfo = "DO:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"在设备列表中不存在";
                    return(false);
                }

                if (!typeof(IJFDevice_MotionDaq).IsAssignableFrom(dev.GetType()))
                {
                    errorInfo = "DO:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"类型不是Device_MotionDaq ";
                    return(false);
                }

                IJFDevice_MotionDaq md = dev as IJFDevice_MotionDaq;
                if (!md.IsInitOK)
                {
                    errorInfo = "DO:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"未完成初始化动作 ";
                    return(false);
                }

                if (!md.IsDeviceOpen)
                {
                    errorInfo = "DO:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"未打开 ";
                    return(false);
                }

                if (cellInfo.ModuleIndex >= md.DioCount)
                {
                    errorInfo = "DO:\"" + cellName + "\" ModuleIndex = :" + cellInfo.ModuleIndex + "超出设备DIO模块数量: " + md.DioCount;
                    return(false);
                }

                if (cellInfo.ChannelIndex >= md.GetDio(cellInfo.ModuleIndex).DOCount)
                {
                    errorInfo = "DO:\"" + cellName + "\" Channel = :" + cellInfo.ChannelIndex + "超出模块DO通道数量: " + md.GetDio(cellInfo.ModuleIndex).DOCount;
                    return(false);
                }
                initor    = dev;
                ci        = cellInfo;
                errorInfo = "Success";
                return(true);
            }
            else if (category == DI) //获取数字量输入
            {
                cellInfo = nameMgr.GetDiCellInfo(cellName);
                if (null == cellInfo)
                {
                    errorInfo = "设备命名表中不存在DI:" + cellName;
                    return(false);
                }

                IJFInitializable dev = initorMgr.GetInitor(cellInfo.DeviceID);
                if (null == dev)
                {
                    errorInfo = "DI:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"在设备列表中不存在";
                    return(false);
                }

                if (!typeof(IJFDevice_MotionDaq).IsAssignableFrom(dev.GetType()))
                {
                    errorInfo = "DI:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"类型不是Device_MotionDaq ";
                    return(false);
                }

                IJFDevice_MotionDaq md = dev as IJFDevice_MotionDaq;
                if (!md.IsInitOK)
                {
                    errorInfo = "DI:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"未完成初始化动作 ";
                    return(false);
                }

                if (!md.IsDeviceOpen)
                {
                    errorInfo = "DI:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"未打开 ";
                    return(false);
                }

                if (cellInfo.ModuleIndex >= md.DioCount)
                {
                    errorInfo = "DI:\"" + cellName + "\" ModuleIndex = :" + cellInfo.ModuleIndex + "超出设备DIO模块数量: " + md.DioCount;
                    return(false);
                }

                if (cellInfo.ChannelIndex >= md.GetDio(cellInfo.ModuleIndex).DICount)
                {
                    errorInfo = "DI:\"" + cellName + "\" Channel = :" + cellInfo.ChannelIndex + "超出模块DI通道数量: " + md.GetDio(cellInfo.ModuleIndex).DOCount;
                    return(false);
                }
                initor    = dev;
                ci        = cellInfo;
                errorInfo = "Success";
                return(true);
            }
            else if (category == AI)
            {
            }
            else if (category == AO)
            {
            }
            else if (category == Axis)
            {
                cellInfo = nameMgr.GetAxisCellInfo(cellName);
                if (null == cellInfo)
                {
                    errorInfo = "设备命名表中不存在Axis:" + cellName;
                    return(false);
                }

                IJFInitializable dev = initorMgr.GetInitor(cellInfo.DeviceID);
                if (null == dev)
                {
                    errorInfo = "Axis:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"在设备列表中不存在";
                    return(false);
                }

                if (!typeof(IJFDevice_MotionDaq).IsAssignableFrom(dev.GetType()))
                {
                    errorInfo = "Axis:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"类型不是Device_MotionDaq ";
                    return(false);
                }

                IJFDevice_MotionDaq md = dev as IJFDevice_MotionDaq;
                if (!md.IsInitOK)
                {
                    errorInfo = "Axis:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"未完成初始化动作 ";
                    return(false);
                }

                if (!md.IsDeviceOpen)
                {
                    errorInfo = "Axis:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"未打开 ";
                    return(false);
                }

                if (cellInfo.ModuleIndex >= md.McCount)
                {
                    errorInfo = "Axis:\"" + cellName + "\" ModuleIndex = :" + cellInfo.ModuleIndex + "超出设备轴模块数量: " + md.McCount;
                    return(false);
                }

                if (cellInfo.ChannelIndex >= md.GetMc(cellInfo.ModuleIndex).AxisCount)
                {
                    errorInfo = "Axis:\"" + cellName + "\" Channel = :" + cellInfo.ModuleIndex + "超出模块轴通道数量: " + md.GetMc(cellInfo.ModuleIndex).AxisCount;
                    return(false);
                }
                initor    = dev;
                ci        = cellInfo;
                errorInfo = "Success";
                return(true);
            }
            else if (category == CmpTrig)
            {
                cellInfo = nameMgr.GetCmpTrigCellInfo(cellName);
                if (null == cellInfo)
                {
                    errorInfo = "设备命名表中不存在CmpTrig:" + cellName;
                    return(false);
                }

                IJFInitializable dev = initorMgr.GetInitor(cellInfo.DeviceID);
                if (null == dev)
                {
                    errorInfo = "CmpTrig:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"在设备列表中不存在";
                    return(false);
                }

                if (!typeof(IJFDevice_MotionDaq).IsAssignableFrom(dev.GetType()))
                {
                    errorInfo = "CmpTrig:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"类型不是Device_MotionDaq ";
                    return(false);
                }

                IJFDevice_MotionDaq md = dev as IJFDevice_MotionDaq;
                if (!md.IsInitOK)
                {
                    errorInfo = "CmpTrig:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"未完成初始化动作 ";
                    return(false);
                }

                if (!md.IsDeviceOpen)
                {
                    errorInfo = "CmpTrig:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"未打开 ";
                    return(false);
                }

                if (cellInfo.ModuleIndex >= md.CompareTriggerCount)
                {
                    errorInfo = "CmpTrig:\"" + cellName + "\" ModuleIndex = :" + cellInfo.ModuleIndex + "超出设备比较触发模块数量: " + md.CompareTriggerCount;
                    return(false);
                }

                if (cellInfo.ChannelIndex >= md.GetCompareTrigger(cellInfo.ModuleIndex).EncoderChannels)
                {
                    errorInfo = "CmpTrig:\"" + cellName + "\" Channel = :" + cellInfo.ModuleIndex + "超出模块比较触发通道数量: " + md.GetCompareTrigger(cellInfo.ModuleIndex).EncoderChannels;
                    return(false);
                }
                initor    = dev;
                ci        = cellInfo;
                errorInfo = "Success";
                return(true);
            }
            else if (category == LightCtrl)
            {
                cellInfo = nameMgr.GetLightCtrlChannelInfo(cellName);
                if (null == cellInfo)
                {
                    errorInfo = "设备命名表中不存在LightCtrl:" + cellName;
                    return(false);
                }

                IJFInitializable dev = initorMgr.GetInitor(cellInfo.DeviceID);
                if (null == dev)
                {
                    errorInfo = "LightCtrl:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"在设备列表中不存在";
                    return(false);
                }

                if (!typeof(IJFDevice_LightController).IsAssignableFrom(dev.GetType()))
                {
                    errorInfo = "LightCtrl:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"类型不是IJFDevice_LightController ";
                    return(false);
                }

                IJFDevice_LightController md = dev as IJFDevice_LightController;
                if (!md.IsInitOK)
                {
                    errorInfo = "LightCtrl:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"未完成初始化动作 ";
                    return(false);
                }

                if (!md.IsDeviceOpen)
                {
                    errorInfo = "LightCtrl:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"未打开 ";
                    return(false);
                }

                if (cellInfo.ChannelIndex >= md.LightChannelCount)
                {
                    errorInfo = "LightCtrl:\"" + cellName + "\" Channel = :" + cellInfo.ChannelIndex + "超出设备光源通道数量: " + md.LightChannelCount;
                    return(false);
                }
                initor    = dev;
                ci        = cellInfo;
                errorInfo = "Success";
                return(true);
            }
            else if (category == LightTrig)
            {
                cellInfo = nameMgr.GetTrigCtrlChannelInfo(cellName);
                if (null == cellInfo)
                {
                    errorInfo = "设备命名表中不存在LightTrig:" + cellName;
                    return(false);
                }

                IJFInitializable dev = initorMgr.GetInitor(cellInfo.DeviceID);
                if (null == dev)
                {
                    errorInfo = "LightTrig:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"在设备列表中不存在";
                    return(false);
                }

                if (!typeof(IJFDevice_TrigController).IsAssignableFrom(dev.GetType()))
                {
                    errorInfo = "LightTrig:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"类型不是IJFDevice_TrigController ";
                    return(false);
                }

                IJFDevice_TrigController md = dev as IJFDevice_TrigController;
                if (!md.IsInitOK)
                {
                    errorInfo = "LightTrig:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"未完成初始化动作 ";
                    return(false);
                }

                if (!md.IsDeviceOpen)
                {
                    errorInfo = "LightTrig:\"" + cellName + "\" 所属设备:\"" + cellInfo.DeviceID + "\"未打开 ";
                    return(false);
                }

                if (cellInfo.ChannelIndex >= md.TrigChannelCount)
                {
                    errorInfo = "LightTrig:\"" + cellName + "\" Channel = :" + cellInfo.ChannelIndex + "超出设备触发通道数量: " + md.TrigChannelCount;
                    return(false);
                }
                initor    = dev;
                ci        = cellInfo;
                errorInfo = "Success";
                return(true);
            }
            else if (category == Cmr)
            {
                IJFInitializable dev = initorMgr.GetInitor(cellName);
                if (null == dev)
                {
                    errorInfo = "Camera:\"" + cellName + "\" 在设备列表中不存在";
                    return(false);
                }

                if (!typeof(IJFDevice_Camera).IsAssignableFrom(dev.GetType()))
                {
                    errorInfo = "Camera:\"" + cellName + "\" 设备类型不是IJFDevice_Camera ";
                    return(false);
                }
                initor    = dev;
                errorInfo = "Success";
                return(true);
            }
            else
            {
                errorInfo = "不支持的参数项\"category\" = " + category;
            }
            return(false);
        }
Exemplo n.º 6
0
        protected override bool ActionGenuine(out string errorInfo)
        {
            string chnID     = GetMethodInputValue("光源通道ID") as string;
            int    intensity = (int)GetMethodInputValue("光照强度");

            if (string.IsNullOrEmpty(chnID))
            {
                errorInfo = "输入参数项:\"光源通道ID\" 为空字串";
                return(false);
            }
            if (!JFHubCenter.Instance.MDCellNameMgr.ContainLightChannelName(chnID))
            {
                errorInfo = "输入参数项:\"光源通道ID\"  = " + chnID + " 在设备名称表中不存在";
                return(false);
            }

            if (intensity < 0)
            {
                errorInfo = "输入参数项:\"光照强度\"  = " + intensity + " 为无效值(参数值必须>=0)";
                return(false);
            }

            bool isAutoSwitchMode = (bool)GetInitParamValue("自动切换到开关模式");
            bool isAutoEnable     = (bool)GetInitParamValue("自动使能");


            IJFInitializable dev     = null;
            JFDevCellInfo    ci      = null;
            string           errInfo = null;

            if (!JFCMFunction.CheckDevCellName(JFCMFunction.LightCtrl, chnID, out dev, out ci, out errInfo))
            {
                errorInfo = errInfo;
                return(false);
            }

            int errCode = 0;
            IJFDevice_LightController devLight = dev as IJFDevice_LightController;

            if (typeof(IJFDevice_LightControllerWithTrig).IsAssignableFrom(devLight.GetType())) //如果当前设备带有触发功能
            {
                IJFDevice_LightControllerWithTrig devLT = devLight as IJFDevice_LightControllerWithTrig;
                JFLightWithTrigWorkMode           wm;
                errCode = devLT.GetWorkMode(out wm);
                if (errCode != 0)
                {
                    errorInfo = "获取光源控制器工作模式失败:" + devLT.GetErrorInfo(errCode);
                    return(false);
                }

                if (wm == JFLightWithTrigWorkMode.Trigger) //当前处于触发模式
                {
                    if (!isAutoSwitchMode)
                    {
                        errorInfo = "控制器当前为触发模式";
                        return(false);
                    }

                    errCode = devLT.SetWorkMode(JFLightWithTrigWorkMode.TurnOnOff);
                    if (errCode != 0)
                    {
                        errorInfo = "控制器切换工作模式失败:" + devLT.GetErrorInfo(errCode);
                        return(false);
                    }
                }
            }

            bool isLightChnEnabled = false;

            errCode = devLight.GetLightChannelEnable(ci.ChannelIndex, out isLightChnEnabled);
            if (0 != errCode)
            {
                errorInfo = "获取通道使能状态失败:" + devLight.GetErrorInfo(errCode);
                return(false);
            }
            if (!isLightChnEnabled)
            {
                if (!isAutoEnable)
                {
                    errorInfo = "光源通道未使能";
                    return(false);
                }
                errCode = devLight.SetLightChannelEnable(ci.ChannelIndex, true);
                if (errCode != 0)
                {
                    errorInfo = "光源通道使能失败:" + devLight.GetErrorInfo(errCode);
                    return(false);
                }
            }

            errCode = devLight.SetLightIntensity(ci.ChannelIndex, intensity);
            if (errCode != 0)
            {
                errorInfo = "设置光照强度失败:" + devLight.GetErrorInfo(errCode);
                return(false);
            }
            errorInfo = "Success";
            return(true);
        }
Exemplo n.º 7
0
        ///// <summary>
        ///// 使通道可用(如伺服上电,光源/触发可用)
        ///// 建议在 打开设备->检查通道可用性 之后调用
        ///// </summary>
        ///// <param name="errorInfo"></param>
        ///// <returns></returns>
        public bool EnabledChannel(out string errorInfo)
        {
            errorInfo = "Unknown-Error";
            bool isOK = false;

            if (!CheckAvalid(out errorInfo))
            {
                return(false);
            }
            int       errorCode = 0;
            IJFDevice dev       = Device();

            switch (CellType)
            {
            case JFDevCellType.DI:
                isOK      = true;
                errorInfo = "Success";
                break;

            case JFDevCellType.DO:
                errorInfo = "Success";
                isOK      = true;
                break;

            case JFDevCellType.Axis:
            {
                IJFDevice_MotionDaq devMD = Device() as IJFDevice_MotionDaq;
                JFDevCellInfo       ci    = CellInfo();
                IJFModule_Motion    mm    = devMD.GetMc(ci.ModuleIndex);
                errorCode = mm.ServoOn(ci.ChannelIndex);
                if (errorCode != 0)
                {
                    errorInfo = mm.GetErrorInfo(errorCode);
                }
                else
                {
                    isOK      = true;
                    errorInfo = "Success";
                }
            }
            break;

            case JFDevCellType.AI:
                errorInfo = "Success";
                isOK      = true;
                break;

            case JFDevCellType.AO:
                errorInfo = "Success";
                isOK      = true;
                break;

            case JFDevCellType.CmpTrig:
                errorInfo = "Success";
                isOK      = true;
                break;

            case JFDevCellType.Light:
                dev = Device();
                if (dev is IJFDevice_LightControllerWithTrig)    //光源控制器
                {
                    IJFDevice_LightControllerWithTrig devLT = dev as IJFDevice_LightControllerWithTrig;
                    errorCode = devLT.SetWorkMode(JFLightWithTrigWorkMode.TurnOnOff);     //切换为开关模式
                    if (errorCode != 0)
                    {
                        errorInfo = "切换为开关模式失败:" + devLT.GetErrorInfo(errorCode);
                        break;
                    }
                }
                IJFDevice_LightController devl = dev as IJFDevice_LightController;
                errorCode = devl.SetLightChannelEnable(CellInfo().ChannelIndex, true);
                if (errorCode != 0)
                {
                    errorInfo = "通道使能失败:" + devl.GetErrorInfo(errorCode);
                    break;
                }
                isOK      = true;
                errorInfo = "Success";
                break;

            case JFDevCellType.Trig:
                dev = Device();
                if (dev is IJFDevice_LightControllerWithTrig)     //光源控制器
                {
                    IJFDevice_LightControllerWithTrig devLT = dev as IJFDevice_LightControllerWithTrig;
                    errorCode = devLT.SetWorkMode(JFLightWithTrigWorkMode.Trigger);     //切换为触发模式
                    if (errorCode != 0)
                    {
                        errorInfo = "切换为触发模式失败:" + devLT.GetErrorInfo(errorCode);
                        break;
                    }
                }
                IJFDevice_TrigController devt = dev as IJFDevice_TrigController;
                errorCode = devt.SetTrigChannelEnable(CellInfo().ChannelIndex, true);
                if (errorCode != 0)
                {
                    errorInfo = "通道使能失败:" + devt.GetErrorInfo(errorCode);
                    break;
                }
                isOK      = true;
                errorInfo = "Success";
                break;

            default:
                errorInfo = "未定义的通道类型";
                break;
            }
            return(isOK);
        }
Exemplo n.º 8
0
        public void UpdateChannelsInfo(string devID) //必须从名称表中的触发控制器和光源控制器提取信息
        {
            _devID = devID;
            panelLight.Controls.Clear();
            panelTrig.Controls.Clear();
            if (string.IsNullOrEmpty(_devID))
            {
                ShowTips("设备名称为空!");
                return;
            }

            if (!JFHubCenter.Instance.MDCellNameMgr.ContainLightCtrlDev(devID))
            {
                ShowTips("设备名称列表中未包含光源控制器设备:" + _devID);
                return;
            }

            IJFDevice_LightController dev = JFHubCenter.Instance.InitorManager.GetInitor(_devID) as IJFDevice_LightController;

            if (dev == null)
            {
                ShowTips("设备列表中不存在设备Name = " + _devID);
                //return;
            }
            else
            {
                if (!dev.IsDeviceOpen)
                {
                    ShowTips("设备当前处于关闭状态");
                }
            }

            int top = 3;

            string[] lightChnNames = JFHubCenter.Instance.MDCellNameMgr.AllChannelNamesInLightCtrlDev(devID);
            if (lightChnNames == null || 0 == lightChnNames.Length)
            {
                ShowTips("开关通道数量为0");
                return;
            }
            else
            {
                top = 3;
                for (int i = 0; i < lightChnNames.Count(); i++)
                {
                    UcLightCtrlChn ucChn = new UcLightCtrlChn();
                    ucChn.Location = new Point(3, top);
                    panelLight.Controls.Add(ucChn);
                    ucChn.SetChannelInfo(dev, i, lightChnNames[i]);//.SetChannelInfo(dev, i, trigChnNames[i]);
                    top = ucChn.Bottom + 5;
                }
            }

            if (dev != null && !typeof(IJFDevice_LightControllerWithTrig).IsAssignableFrom(dev.GetType())) //本设备不支持触发控制器接口
            {
                panelTrig.Visible = false;
                return;
            }

            if (!JFHubCenter.Instance.MDCellNameMgr.ContainTrigCtrlDev(devID)) //不包含触发功能
            {
                ShowTips("设备命名表中不包含触发通道名称信息");
                return;
            }
            //panelTrig.Top = panelLight.Bottom + 10;
            panelTrig.Visible = true;
            string[] trigChnNames = JFHubCenter.Instance.MDCellNameMgr.AllChannelNamesInTrigCtrlDev(devID);

            if (trigChnNames == null || 0 == trigChnNames.Length)
            {
                ShowTips("命名通道数量为0");
                return;
            }

            top = 3;
            for (int i = 0; i < trigChnNames.Count(); i++)
            {
                UcTrigCtrlChn ucChn = new UcTrigCtrlChn();
                ucChn.Location = new Point(3, top);
                panelTrig.Controls.Add(ucChn);
                ucChn.SetChannelInfo(dev as IJFDevice_TrigController, i, trigChnNames[i]);
                top = ucChn.Bottom + 5;
            }
        }