Example #1
0
        /// <summary>
        /// 方法:边沿信号判断
        /// </summary>
        /// <param name="last"></param>
        /// <param name="now"></param>
        /// <returns></returns>
        public static ProCommon.Communal.EffectiveSignal JudgeEdge(bool last, bool now)
        {
            ProCommon.Communal.EffectiveSignal edge = ProCommon.Communal.EffectiveSignal.RaiseEdge;
            if (!last)
            {
                if (now)
                {
                    edge = ProCommon.Communal.EffectiveSignal.RaiseEdge;
                }
                else
                {
                    edge = ProCommon.Communal.EffectiveSignal.LogicFalse;
                }
            }
            else
            {
                if (!now)
                {
                    edge = ProCommon.Communal.EffectiveSignal.FallEdge;
                }
                else
                {
                    edge = ProCommon.Communal.EffectiveSignal.LogicTrue;
                }
            }

            return(edge);
        }
Example #2
0
        /// <summary>
        /// 方法:设置触发边沿信号模式
        /// </summary>
        /// <param name="edgemode">边缘模式</param>
        /// <returns></returns>
        public bool SetTriggerActivation(ProCommon.Communal.EffectiveSignal edgemode)
        {
            bool rt = false;

            if (ICameraDriverable != null)
            {
                rt = ICameraDriverable.SetTriggerActivation(edgemode);
            }
            return(rt);
        }
Example #3
0
        /// <summary>
        /// 方法:设置触发信号边缘
        /// [注:用于触发源为硬触发]
        /// </summary>
        /// <param name="dege">边缘信号</param>
        /// <returns></returns>
        protected override bool DoSetTriggerActivation(ProCommon.Communal.EffectiveSignal edge)
        {
            bool rt = false;

            MVSDK.CameraSdkStatus status = MVSDK.CameraSdkStatus.CAMERA_STATUS_FAILED;
            try
            {
                if (_deviceRef > 0)
                {
                    switch (edge)
                    {
                    case ProCommon.Communal.EffectiveSignal.FallEdge:
                    {
                        status = MVSDK.MvApi.CameraSetExtTrigSignalType(_deviceRef, 1);        //MVSDK.emExtTrigSignal.EXT_TRIG_TRAILING_EDGE=1
                    }
                    break;

                    case ProCommon.Communal.EffectiveSignal.RaiseEdge:
                    {
                        status = MVSDK.MvApi.CameraSetExtTrigSignalType(_deviceRef, 0);          //MVSDK.emExtTrigSignal.EXT_TRIG_LEADING_EDGE=0
                    }
                    break;

                    default:
                        break;
                    }

                    rt = (MVSDK.CameraSdkStatus.CAMERA_STATUS_SUCCESS == status) ? true : false;
                    if (!rt)
                    {
                        if (DriverExceptionDel != null)
                        {
                            DriverExceptionDel(string.Format("错误:迈德威视相机设置触发信号边沿失败!\n错误代码:{0:X8}", System.Convert.ToInt32(status)));
                        }
                    }
                }
                else
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:迈德威视相机设置设备采集信号边沿失败!\n错误描述:{0}", "设备未连接"));
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }

            return(rt);
        }
Example #4
0
        /// <summary>
        /// 方法:设置触发信号边缘
        /// [注:用于触发源为硬触发]
        /// </summary>
        /// <param name="dege">边缘信号</param>
        /// <returns></returns>
        protected override bool DoSetTriggerActivation(ProCommon.Communal.EffectiveSignal edge)
        {
            bool rt = false;

            try
            {
                if (_deviceRef != null)
                {
                    switch (edge)
                    {
                    case ProCommon.Communal.EffectiveSignal.FallEdge:
                    {
                        using (ThridLibray.IEnumParameter p = _deviceRef.ParameterCollection[ThridLibray.ParametrizeNameSet.TriggerActivation])
                        {
                            rt = p.SetValue("FallingEdge");
                        }
                    }
                    break;

                    case ProCommon.Communal.EffectiveSignal.RaiseEdge:
                    {
                        using (ThridLibray.IEnumParameter p = _deviceRef.ParameterCollection[ThridLibray.ParametrizeNameSet.TriggerActivation])
                        {
                            rt = p.SetValue("RisingEdge");
                        }
                    }
                    break;

                    default:
                        break;
                    }
                }

                rt = true;
                if (!rt)
                {
                    if (DriverExceptionDel != null)
                    {
                        DriverExceptionDel(string.Format("错误:大华相机触信号边沿设置失败!\n错误代码:{0:X8}", 99));
                    }
                }
            }
            catch
            {
            }
            finally
            {
            }
            return(rt);
        }
Example #5
0
        /// <summary>
        /// 方法:设置触发信号边缘
        /// </summary>
        /// <param name="degemode"></param>
        /// <returns></returns>
        protected override bool DoSetTriggerActivation(ProCommon.Communal.EffectiveSignal edge)
        {
            bool rt = false;

            try
            {
                if (!AcqHandle.TupleEqual(new HalconDotNet.HTuple()))
                {
                    rt = true;
                }
            }
            catch (HalconDotNet.HalconException hex)
            {
            }
            finally
            {
            }
            return(rt);
        }
Example #6
0
        /// <summary>
        /// 方法:设置相机输出信号
        /// </summary>
        /// <param name="idx">输入端口号</param>
        /// <param name="triglogic">触发信号逻辑</param>
        /// <param name="delaytime">边沿信号时的延时,单位毫秒</param>
        /// <returns></returns>
        public bool SetOutPut(int idx, ProCommon.Communal.EffectiveSignal triglogic, int delaytime)
        {
            bool rt = false;

            if (ICameraDriverable != null)
            {
                switch (triglogic)
                {
                case ProCommon.Communal.EffectiveSignal.FallEdge:
                    rt = ICameraDriverable.SetOutPut(idx, true);
                    if (rt)
                    {
                        System.Threading.Thread.Sleep(delaytime);
                        rt = ICameraDriverable.SetOutPut(idx, false);
                    }
                    break;

                case ProCommon.Communal.EffectiveSignal.LogicFalse:
                    rt = ICameraDriverable.SetOutPut(idx, false);
                    break;

                case ProCommon.Communal.EffectiveSignal.LogicTrue:
                    rt = ICameraDriverable.SetOutPut(idx, true);
                    break;

                case ProCommon.Communal.EffectiveSignal.RaiseEdge:
                    rt = ICameraDriverable.SetOutPut(idx, false);
                    if (rt)
                    {
                        System.Threading.Thread.Sleep(delaytime);
                        rt = ICameraDriverable.SetOutPut(idx, true);
                    }
                    break;

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