Ejemplo n.º 1
0
        private ControlClass()
        {
            //读取App.config文件中的appSettings
            //所有相关组件的配置都写在appSetting中
            var reader = new AppSettingsReader();

            //初始化继电器
            string relay1ComName = (string)reader.GetValue("Relay1ComName", typeof(string));
            byte   relay1Address = (byte)(reader.GetValue("Relay1Address", typeof(byte)));

            Relay1 = new Relay(relay1ComName, relay1Address);
            Relay2 = new Relay((string)reader.GetValue("Relay2ComName", typeof(string)),
                               (byte)reader.GetValue("Relay2Address", typeof(byte)));
            //初始化控制器
            uint baudRate   = (uint)reader.GetValue("BaudRate", typeof(uint));
            uint byteSize   = (uint)reader.GetValue("ByteSize", typeof(uint));
            uint parity     = (uint)reader.GetValue("Parity", typeof(uint));
            uint stopBits   = (uint)reader.GetValue("StopBits", typeof(uint));
            uint motorCOMID = uint.Parse((string)reader.GetValue("COMID", typeof(string)));


            motorController = new MotorController(baudRate, byteSize, parity, stopBits, motorCOMID);
            //motorController.OpenCom();
            //初始化摄像头
            DVRLoginInfo leftLoginInfo = new DVRLoginInfo()
            {
                DVRIPAddress  = (string)reader.GetValue("LeftCamIP", typeof(string)),
                DVRPortNumber = (short)reader.GetValue("LeftCamPort", typeof(short)),
                DVRUserName   = (string)reader.GetValue("LeftCamUsername", typeof(string)),
                DVRPassword   = (string)reader.GetValue("LeftCamPassword", typeof(string))
            };

            DVRLoginInfo rightDvrLoginInfo = new DVRLoginInfo()
            {
                DVRIPAddress  = (string)reader.GetValue("RightCamIP", typeof(string)),
                DVRPortNumber = (short)reader.GetValue("RightCamPort", typeof(short)),
                DVRUserName   = (string)reader.GetValue("RightCamUsername", typeof(string)),
                DVRPassword   = (string)reader.GetValue("RightCamPassword", typeof(string))
            };

            videoCap = new VideoCapture(leftLoginInfo, rightDvrLoginInfo);
            videoCap.Login();
            //中心坐标
            int x = (int)reader.GetValue("X", typeof(int));
            int y = (int)reader.GetValue("Y", typeof(int));

            center = new Point(960, 540);
        }
Ejemplo n.º 2
0
        public ControlClass()
        {
            //读取App.config中的appSettings
            var reader = new AppSettingsReader();

            string relay1ComName = (string)reader.GetValue("Relay1ComName", typeof(string));
            byte   relay1Address = (byte)(reader.GetValue("Relay1Address", typeof(byte)));

            relay1 = new Relay(relay1ComName, relay1Address);
            relay2 = new Relay((string)reader.GetValue("Relay2ComName", typeof(string)),
                               (byte)reader.GetValue("Relay2Address", typeof(byte)));

            uint baudRate   = (uint)reader.GetValue("BaudRate", typeof(uint));
            uint byteSize   = (uint)reader.GetValue("ByteSize", typeof(uint));
            uint parity     = (uint)reader.GetValue("Parity", typeof(uint));
            uint stopBits   = (uint)reader.GetValue("StopBits", typeof(uint));
            uint motorCOMID = uint.Parse((string)reader.GetValue("COMID", typeof(string)));

            motorController = new MotorController(baudRate, byteSize, parity, stopBits, motorCOMID);
        }