Beispiel #1
0
        /// <summary>
        /// 信号输出,已经在task中运行
        /// </summary>
        public override void Output()
        {
            if (IOSerial.Instance.Rs232Param.Use == false)
            {
                Task.Run(() =>
                {
                    lock (lockobj1)
                    {
                        int nRet;
                        nRet = m_pOperator.SetEnumValue("LineSelector", 1);
                        if (nRet != CameraOperator.CO_OK)
                        {
                            Util.Notify("LineSelector异常");
                        }
                        nRet = m_pOperator.SetEnumValue("LineMode", 8);
                        if (nRet != CameraOperator.CO_OK)
                        {
                            Util.Notify("LineMode异常");
                        }
                        nRet = m_pOperator.SetBoolValue("LineInverter", true);
                        if (nRet != CameraOperator.CO_OK)
                        {
                            Util.Notify("LineInverter异常");
                        }
                        Thread.Sleep((int)outLineTime);
                        nRet = m_pOperator.SetBoolValue("LineInverter", false);
                        if (nRet != CameraOperator.CO_OK)
                        {
                            Util.Notify("LineInverter异常");
                        }
                        // g_camera.Parameters[PLCamera.LineSelector].TrySetValue(PLCamera.LineSelector.Line1);
                        //m_pOperator.SetEnumValue("LineSelector", 1);
                        //g_camera.Parameters[PLCamera.LineSource].TrySetValue(PLCamera.LineSource.UserOutput);
                        //g_camera.Parameters[PLCamera.UserOutputValue].TrySetValue(true);
                        //Thread.Sleep((int)outLineTime);
                        //g_camera.Parameters[PLCamera.UserOutputValue].TrySetValue(false);
                        //g_camera.Parameters[PLCamera.timer].TrySetValue(PLCamera.LineSource.Timer1Active.);
                        Util.Notify("海康相机报警输出完成");
                    }
                });
            }

            else
            {
                Task.Run(() =>
                {
                    lock (lockobj2)
                    {
                        try
                        {
                            IOSerial.Instance.WriteDataToSerial("#sw1n");
                            IOSerial.Instance.WriteDataToSerial("#sw2n");
                            IOSerial.Instance.WriteDataToSerial("#sw3n");
                            Thread.Sleep((int)outLineTime);
                            IOSerial.Instance.WriteDataToSerial("#sw1f");
                            IOSerial.Instance.WriteDataToSerial("#sw2f");
                            IOSerial.Instance.WriteDataToSerial("#sw3f");

                            Util.Notify("串口io报警输出完成");
                        }
                        catch (Exception ex)
                        {
                            Util.WriteLog(this.GetType(), ex);
                            Util.Notify("串口io通信失败");
                        }
                    }
                });
            }
        }