Exemplo n.º 1
0
        public void UpdateChannelStatus()
        {
            if (InvokeRequired)
            {
                Invoke(new Action(UpdateChannelStatus));
                return;
            }
            if (!IsChnValid)
            {
                isChkEnableSetting   = false;
                chkEnable.Checked    = false;
                isChkEnableSetting   = true;
                chkEnable.Enabled    = false;
                isTrkSetting         = true;
                trkIntensity.Value   = 0;
                isTrkSetting         = false;
                trkIntensity.Enabled = false;
                tbIntensity.Text     = "Unvalid";
                tbIntensity.Enabled  = false;
                return;
            }

            chkEnable.Enabled = true;
            bool isEnable = false;
            int  err      = _module.GetLightChannelEnable(_chn, out isEnable);

            isChkEnableSetting = true;
            if (0 != err)
            {
                chkEnable.Checked = false;
            }
            else
            {
                chkEnable.Checked = isEnable;
            }
            isChkEnableSetting    = false;
            trkIntensity.Enabled  = isEnable;
            tbIntensity.Enabled   = isEnable;
            tbIntensity.BackColor = SystemColors.Control;
            int val = 0;

            err = _module.GetLightIntensity(_chn, out val);
            if (!isIntensityEditting)
            {
                if (err != 0)
                {
                    //trkIntensity.Value = 0;
                    tbIntensity.Text = "Error";
                }
                else
                {
                    //trkIntensity.Value = val;
                    tbIntensity.Text = val.ToString();
                }
            }
            if (!isTrkFocus)
            {
                isTrkSetting = true;
                if (err != 0)
                {
                    trkIntensity.Value = 0;
                    //tbIntensity.Text = "Error";
                }
                else
                {
                    trkIntensity.Value = val;
                    //tbIntensity.Text = val.ToString();
                }
                isTrkSetting = false;
            }
        }
Exemplo n.º 2
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);
        }