コード例 #1
0
        public AnalogWayLiveCore(string key, string name, IBasicCommunication comm, AnalogWayLiveCorePropertiesConfig props) :
            base(key, name)
        {
            this.userName = props.userName;
            this.password = props.password;
            CommandQueue  = new CrestronQueue(100);


            Communication = comm;

            var socket = comm as ISocketStatus;

            if (socket != null)
            {
                // This instance uses IP control
                socket.ConnectionChange += new EventHandler <GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
            }
            else
            {
                // This instance uses RS-232 control
            }
            PortGather = new CommunicationGather(Communication, "\x0a");
            PortGather.LineReceived += this.Port_LineReceived;
            if (props.CommunicationMonitorProperties != null)
            {
                CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, props.CommunicationMonitorProperties);
            }
            else
            {
                //#warning Need to deal with this poll string
                CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 120000, 120000, 300000, "System.Status\x0A\x0D");
            }
        }
コード例 #2
0
        public GenericComm(DeviceConfig config)
            : base(config)
        {
            PropertiesConfig = CommFactory.GetControlPropertiesConfig(config);

            CommPort = CommFactory.CreateCommForDevice(config);
        }
コード例 #3
0
        /// <summary>
        /// Constructor for IBasicCommunication
        /// </summary>
        public PanasonicDisplay(string key, string name, IBasicCommunication comm, DeviceConfig config)
            : base(key, name)
        {
            Config = config;

            Communication = comm;

            Init();
        }
コード例 #4
0
 public ConsoleCommMockDevice(string key, string name, ConsoleCommMockDevicePropertiesConfig props, IBasicCommunication comm)
     : base(key, name)
 {
     Communication            = comm;
     PortGather               = new CommunicationGather(Communication, '\x0d');
     PortGather.LineReceived += this.Port_LineReceived;
     CommunicationMonitor     = new GenericCommunicationMonitor(this, Communication, props.CommunicationMonitorProperties);
     LineEnding               = props.LineEnding;
 }
コード例 #5
0
        /// <summary>
        /// Constructor for IBasicCommunication
        /// </summary>
        public SamsungMDC(string key, string name, IBasicCommunication comm, string id)
            : base(key, name)
        {
            Communication = comm;
            Communication.BytesReceived += new EventHandler <GenericCommMethodReceiveBytesArgs>(Communication_BytesReceived);

            ID = id == null ? (byte)0x01 : Convert.ToByte(id, 16); // If id is null, set default value of 0x01, otherwise assign value passed in constructor
            Init();
        }
コード例 #6
0
        /// <summary>
        /// Constructor for IBasicCommunication
        /// </summary>
        public AvocorDisplay(string key, string name, IBasicCommunication comm, string id)
            : base(key, name)
        {
            Communication = comm;
            //Communication.BytesReceived += new EventHandler<GenericCommMethodReceiveBytesArgs>(Communication_BytesReceived);

            PortGather = new CommunicationGather(Communication, '\x08');
            PortGather.IncludeDelimiter = true;
            PortGather.LineReceived    += new EventHandler <GenericCommMethodReceiveTextArgs>(PortGather_LineReceived);

            ID = id == null ? (byte)0x01 : Convert.ToByte(id, 16); // If id is null, set default value of 0x01, otherwise assign value passed in constructor
            Init();
        }
コード例 #7
0
        public GenericCommunicationMonitoredDevice(string key, string name, string hostname, int port, string pollString,
                                                   long pollTime, long warningTime, long errorTime)
            : base(key, name)
        {
            Client = new GenericTcpIpClient(key + "-tcp", hostname, port, 512);
            CommunicationMonitor = new GenericCommunicationMonitor(this, Client, pollTime, warningTime, errorTime, pollString);

            // ------------------------------------------------------DELETE THIS
            CommunicationMonitor.StatusChange += (o, a) =>
            {
                Debug.Console(2, this, "Communication monitor status change: {0}", a.Status);
            };
        }
コード例 #8
0
        public GenericCommunicationMonitoredDevice(string key, string name, IBasicCommunication comm, string pollString,
                                                   long pollTime, long warningTime, long errorTime)
            : base(key, name)
        {
            Client = comm;
            CommunicationMonitor = new GenericCommunicationMonitor(this, Client, pollTime, warningTime, errorTime, pollString);

            // ------------------------------------------------------DELETE THIS
            CommunicationMonitor.StatusChange += (o, a) =>
            {
                Debug.Console(2, this, "Communication monitor status change: {0}", a.Status);
            };
        }
コード例 #9
0
ファイル: QscDsp.cs プロジェクト: xielong87/Essentials
        public QscDsp(string key, string name, IBasicCommunication comm, QscDspPropertiesConfig props) :
            base(key, name)
        {
            CommandQueue = new CrestronQueue(100);

            Communication = comm;
            var socket = comm as ISocketStatus;

            if (socket != null)
            {
                // This instance uses IP control
                socket.ConnectionChange += new EventHandler <GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
            }
            else
            {
                // This instance uses RS-232 control
            }
            PortGather = new CommunicationGather(Communication, "\x0a");
            PortGather.LineReceived += this.Port_LineReceived;

            LevelControlPoints = new Dictionary <string, QscDspLevelControl>();
            Dialers            = new Dictionary <string, QscDspDialer>();

            if (props.CommunicationMonitorProperties != null)
            {
                CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, props.CommunicationMonitorProperties);
            }
            else
            {
                CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 20000, 120000, 300000, "cgp 1\x0D\x0A");
            }


            foreach (KeyValuePair <string, QscDspLevelControlBlockConfig> block in props.LevelControlBlocks)
            {
                this.LevelControlPoints.Add(block.Key, new QscDspLevelControl(block.Key, block.Value, this));
                Debug.Console(2, this, "Added LevelControlPoint {0}", block.Key);
            }
            foreach (KeyValuePair <string, QscDspPresets> preset in props.presets)
            {
                this.addPreset(preset.Value);
                Debug.Console(2, this, "Added Preset {0} {1}", preset.Value.label, preset.Value.preset);
            }
            foreach (KeyValuePair <string, QscDialerConfig> dialerConfig in props.dialerControlBlocks)
            {
                Debug.Console(2, this, "Added Dialer {0}\n {1}", dialerConfig.Key, dialerConfig.Value);
                this.Dialers.Add(dialerConfig.Key, new QscDspDialer(dialerConfig.Value, this));
            }
        }
コード例 #10
0
        /// <summary>
        /// Poll is a provided action instead of string
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="client"></param>
        /// <param name="pollTime"></param>
        /// <param name="warningTime"></param>
        /// <param name="errorTime"></param>
        /// <param name="pollBytes"></param>
        public GenericCommunicationMonitor(IKeyed parent, IBasicCommunication client, long pollTime,
                                           long warningTime, long errorTime, Action pollAction) :
            base(parent, warningTime, errorTime)
        {
            if (pollTime > warningTime || pollTime > errorTime)
            {
                throw new ArgumentException("pollTime must be less than warning or errorTime");
            }
            //if (pollTime < 5000)
            //    throw new ArgumentException("pollTime cannot be less than 5000 ms");

            Client     = client;
            PollTime   = pollTime;
            PollAction = pollAction;
        }
コード例 #11
0
ファイル: etc.cs プロジェクト: michaelh1142/pdt-etc-epi
        public etc(string key, string name, IBasicCommunication comm, DeviceConfig dc)
            : base(key, name)
        {
            _Dc = dc;


            Communication = comm;
            var socket = comm as ISocketStatus;

            if (socket != null)
            {
                socket.ConnectionChange += new EventHandler <GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
            }

            var config = JsonConvert.DeserializeObject <EtcConfigObject>(dc.Properties.ToString());


            PortGather = new CommunicationGather(Communication, "\x0D");
            PortGather.LineReceived += this.Port_LineReceived;

            CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 20000, 120000, 300000, "?ETHERNET, 0\x0D");
            CommunicationMonitor.Start();

            TestTxFeedback          = new StringFeedback(() => TestTx);
            CommandPassThruFeedback = new StringFeedback(() => DeviceRx);
            ActivePresetFeedback    = new StringFeedback(() => ActivePreset);

            CommandQueue = new CrestronQueue(100);
            cmdTimer     = new CommandTimer();


            Scenes = new Dictionary <string, EtcScene>();

            if (config.scenes != null)
            {
                Debug.Console(2, this, "Zone List Exists");
                foreach (KeyValuePair <string, EtcSceneConfig> scene in config.scenes)
                {
                    string itemkey = scene.Key;
                    var    value   = scene.Value;
                    Debug.Console(2, this, "Adding: Key: {0} Value Label: {1} Enabled: {2}", itemkey, value.sceneName, value.enabled);
                    EtcScene thisScene = new EtcScene(value, this);
                    Scenes.Add(itemkey, thisScene);
                }
            }

            Initialize();
        }
コード例 #12
0
ファイル: GenericComm.cs プロジェクト: srmeteor/Essentials
        public GenericComm(DeviceConfig config)
            : base(config)
        {
            PropertiesConfig = CommFactory.GetControlPropertiesConfig(config);

            var commPort = CommFactory.CreateCommForDevice(config);

            //Fixing decision to require '-comPorts' in delcaration for DGE in order to get a device with comports included
            if (commPort == null)
            {
                config.Key = config.Key + "-comPorts";
                commPort   = CommFactory.CreateCommForDevice(config);
            }

            CommPort = commPort;
        }
        /// <summary>
        /// Plugin device constructor for devices that need IBasicCommunication
        /// </summary>
        /// <param name="key"></param>
        /// <param name="name"></param>
        /// <param name="config"></param>
        /// <param name="comms"></param>
        public EssentialsPluginTemplateDevice(string key, string name, EssentialsPluginConfigObjectTemplate config, IBasicCommunication comms)
            : base(key, name)
        {
            Debug.Console(0, this, "Constructing new {0} instance", name);

            // TODO [ ] Update the constructor as needed for the plugin device being developed

            _config = config;

            ConnectFeedback = new BoolFeedback(() => Connect);
            OnlineFeedback  = new BoolFeedback(() => _commsMonitor.IsOnline);
            StatusFeedback  = new IntFeedback(() => (int)_commsMonitor.Status);

            _comms        = comms;
            _commsMonitor = new GenericCommunicationMonitor(this, _comms, _config.PollTimeMs, _config.WarningTimeoutMs, _config.ErrorTimeoutMs, Poll);

            var socket = _comms as ISocketStatus;

            if (socket != null)
            {
                // device comms is IP **ELSE** device comms is RS232
                socket.ConnectionChange += socket_ConnectionChange;
                Connect = true;
            }

            #region Communication data event handlers.  Comment out any that don't apply to the API type

            // Only one of the below handlers should be necessary.

            // _comms gather for any API that has a defined delimiter
            // TODO [ ] If not using an ASCII based API, remove the line below
            _commsGather = new CommunicationGather(_comms, CommsDelimiter);
            _commsGather.LineReceived += Handle_LineRecieved;

            // _comms byte buffer for HEX/byte based API's with no delimiter
            // TODO [ ] If not using an HEX/byte based API, remove the line below
            _comms.BytesReceived += Handle_BytesReceived;

            // _comms byte buffer for HEX/byte based API's with no delimiter
            // TODO [ ] If not using an HEX/byte based API, remove the line below
            _comms.TextReceived += Handle_TextReceived;

            #endregion
        }
コード例 #14
0
        public EssentialCommsPort(EssentialsControlPropertiesConfig config, string keyPrefix)
        {
            Comm = CommFactory.CreateCommForConfig(config, keyPrefix);
            // var PortGather = new CommunicationGather(Comm, config.EndOfLineChar);
            Comm.TextReceived += new EventHandler <GenericCommMethodReceiveTextArgs>(Communication_TextReceived);

            var socket = Comm as ISocketStatus;

            StatusFeedback    = new IntFeedback(() => { return((int)socket.ClientStatus); });
            ConnectedFeedback = new BoolFeedback(() => { return(Comm.IsConnected); });

            if (socket != null)
            {
                socket.ConnectionChange += new EventHandler <GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
            }
            else
            {
            }
        }
コード例 #15
0
ファイル: LutronQuantum.cs プロジェクト: srmeteor/Essentials
        public LutronQuantumArea(string key, string name, IBasicCommunication comm, LutronQuantumPropertiesConfig props)
            : base(key, name)
        {
            Communication = comm;

            IntegrationId = props.IntegrationId;

            if (props.Control.Method != eControlMethod.Com)
            {
                Username = props.Control.TcpSshProperties.Username;
                Password = props.Control.TcpSshProperties.Password;
            }


            LightingScenes = props.Scenes;

            var socket = comm as ISocketStatus;

            if (socket != null)
            {
                // IP Control
                socket.ConnectionChange += new EventHandler <GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
            }
            else
            {
                // RS-232 Control
            }

            Communication.TextReceived += new EventHandler <GenericCommMethodReceiveTextArgs>(Communication_TextReceived);

            PortGather = new CommunicationGather(Communication, Delimiter);
            PortGather.LineReceived += new EventHandler <GenericCommMethodReceiveTextArgs>(PortGather_LineReceived);

            if (props.CommunicationMonitorProperties != null)
            {
                CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, props.CommunicationMonitorProperties);
            }
            else
            {
                CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 120000, 120000, 300000, "?ETHERNET,0\x0d\x0a");
            }
        }
コード例 #16
0
        public etc(string key, string name, IBasicCommunication comm, DeviceConfig dc)
            : base(key, name)
        {
            Debug.Console(2, this, "Constructor - etc");
            _Dc = dc;


            Communication = comm;
            var socket = comm as ISocketStatus;

            if (socket != null)
            {
                socket.ConnectionChange += new EventHandler <GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
            }

            PortGather = new CommunicationGather(Communication, "\x0D\x0A");
            PortGather.LineReceived += this.Port_LineReceived;
            CommunicationMonitor     = new GenericCommunicationMonitor(this, Communication, 20000, 120000, 300000, "?ETHERNET, 0\x0D");
            CommunicationMonitor.Start();

            Initialize(_Dc);
        }
コード例 #17
0
ファイル: CameraVisca.cs プロジェクト: srmeteor/Essentials
        public CameraVisca(string key, string name, IBasicCommunication comm, CameraPropertiesConfig props) :
            base(key, name)
        {
            Presets = props.Presets;

            OutputPorts.Add(new RoutingOutputPort("videoOut", eRoutingSignalType.Video, eRoutingPortConnectionType.None, null, this, true));

            // Default to all capabilties
            Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom | eCameraCapabilities.Focus;

            Communication = comm;
            var socket = comm as ISocketStatus;

            if (socket != null)
            {
                // This instance uses IP control
                socket.ConnectionChange += new EventHandler <GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
            }
            else
            {
                // This instance uses RS-232 control
            }
            PortGather = new CommunicationGather(Communication, "\xFF");


            Communication.BytesReceived += new EventHandler <GenericCommMethodReceiveBytesArgs>(Communication_BytesReceived);
            PowerIsOnFeedback            = new BoolFeedback(() => { return(PowerIsOn); });

            if (props.CommunicationMonitorProperties != null)
            {
                CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, props.CommunicationMonitorProperties);
            }
            else
            {
                CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 20000, 120000, 300000, "\x81\x09\x04\x00\xFF");
            }
            DeviceManager.AddDevice(CommunicationMonitor);
        }
コード例 #18
0
        public BiampTesiraForteDsp(string key, string name, IBasicCommunication comm, BiampTesiraFortePropertiesConfig props) :
            base(key, name)
        {
            CommandQueue = new CrestronQueue(100);

            Communication = comm;
            var socket = comm as ISocketStatus;

            if (socket != null)
            {
                // This instance uses IP control

                socket.ConnectionChange += new EventHandler <GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
            }
            else
            {
                // This instance uses RS-232 control
            }
            PortGather = new CommunicationGather(Communication, "\x0d\x0a");
            PortGather.LineReceived += this.Port_LineReceived;
            if (props.CommunicationMonitorProperties != null)
            {
                CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, props.CommunicationMonitorProperties);
            }
            else
            {
//#warning Need to deal with this poll string
                CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 120000, 120000, 300000, "SESSION get aliases\x0d\x0a");
            }

            LevelControlPoints = new Dictionary <string, TesiraForteLevelControl>();

            foreach (KeyValuePair <string, BiampTesiraForteLevelControlBlockConfig> block in props.LevelControlBlocks)
            {
                this.LevelControlPoints.Add(block.Key, new TesiraForteLevelControl(block.Key, block.Value, this));
            }
        }
コード例 #19
0
        /// <summary>
        /// Consturctor for base Tesira DSP Device
        /// </summary>
        /// <param name="key">Tesira DSP Device Key</param>
        /// <param name="name">Tesira DSP Device Friendly Name</param>
        /// <param name="comm">Device Communication Object</param>
        /// <param name="dc">Full device configuration object</param>
        public TesiraDsp(string key, string name, IBasicCommunication comm, DeviceConfig dc)
            : base(key, name)
        {
            _dc = dc;

            Debug.Console(0, this, "Made it to device constructor");

            _commandQueue = new CrestronQueue(100);
            Communication = comm;
            var socket = comm as ISocketStatus;

            if (socket != null)
            {
                // This instance uses IP control
                socket.ConnectionChange += new EventHandler <GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
                _isSerialComm            = false;
            }
            else
            {
                // This instance uses RS-232 control
                _isSerialComm = true;
            }
            PortGather = new CommunicationGather(Communication, "\x0D\x0A");
            PortGather.LineReceived += Port_LineReceived;

            CommandPassthruFeedback = new StringFeedback(() => DeviceRx);

            CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 20000, 120000, 300000, () => SendLine("SESSION set verbose false"));

            // Custom monitoring, will check the heartbeat tracker count every 20s and reset. Heartbeat sbould be coming in every 20s if subscriptions are valid
            DeviceManager.AddDevice(CommunicationMonitor);

            ControlPointList = new List <ISubscribedComponent>();

            //Initialize Dictionaries
            Feedbacks        = new FeedbackCollection <Feedback>();
            Faders           = new Dictionary <string, TesiraDspFaderControl>();
            Presets          = new Dictionary <string, TesiraDspPresets>();
            Dialers          = new Dictionary <string, TesiraDspDialer>();
            Switchers        = new Dictionary <string, TesiraDspSwitcher>();
            States           = new Dictionary <string, TesiraDspStateControl>();
            Meters           = new Dictionary <string, TesiraDspMeter>();
            CrosspointStates = new Dictionary <string, TesiraDspCrosspointState>();
            RoomCombiners    = new Dictionary <string, TesiraDspRoomCombiner>();


            CommunicationMonitor.StatusChange += CommunicationMonitor_StatusChange;
            CrestronConsole.AddNewConsoleCommand(SendLine, "send" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
            CrestronConsole.AddNewConsoleCommand(s => Communication.Connect(), "con" + Key, "", ConsoleAccessLevelEnum.AccessOperator);

            Feedbacks.Add(CommunicationMonitor.IsOnlineFeedback);
            Feedbacks.Add(CommandPassthruFeedback);

            //Start CommnicationMonitor in PostActivation phase
            AddPostActivationAction(() =>
            {
                Communication.Connect();
                if (_isSerialComm)
                {
                    CommunicationMonitor.Start();
                }
            });

            CreateDspObjects();
        }
コード例 #20
0
        /// <summary>
        /// Returns a comm method of either com port, TCP, SSH, and puts this into the DeviceManager
        /// </summary>
        /// <param name="deviceConfig">The Device config object</param>
        public static IBasicCommunication CreateCommForDevice(DeviceConfig deviceConfig)
        {
            EssentialsControlPropertiesConfig controlConfig = GetControlPropertiesConfig(deviceConfig);

            if (controlConfig == null)
            {
                return(null);
            }

            IBasicCommunication comm = null;

            try
            {
                var c = controlConfig.TcpSshProperties;
                switch (controlConfig.Method)
                {
                case eControlMethod.Com:
                    comm = new ComPortController(deviceConfig.Key + "-com", GetComPort(controlConfig), controlConfig.ComParams);
                    break;

                case eControlMethod.Cec:
                    comm = new CecPortController(deviceConfig.Key + "-cec", GetCecPort(controlConfig));
                    break;

                case eControlMethod.IR:
                    break;

                case eControlMethod.Ssh:
                {
                    var ssh = new GenericSshClient(deviceConfig.Key + "-ssh", c.Address, c.Port, c.Username, c.Password);
                    ssh.AutoReconnect = c.AutoReconnect;
                    if (ssh.AutoReconnect)
                    {
                        ssh.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs;
                    }
                    comm = ssh;
                    break;
                }

                case eControlMethod.Tcpip:
                {
                    var tcp = new GenericTcpIpClient(deviceConfig.Key + "-tcp", c.Address, c.Port, c.BufferSize);
                    tcp.AutoReconnect = c.AutoReconnect;
                    if (tcp.AutoReconnect)
                    {
                        tcp.AutoReconnectIntervalMs = c.AutoReconnectIntervalMs;
                    }
                    comm = tcp;
                    break;
                }

                case eControlMethod.Udp:
                {
                    var udp = new GenericUdpServer(deviceConfig.Key + "-udp", c.Address, c.Port, c.BufferSize);
                    comm = udp;
                    break;
                }

                case eControlMethod.Telnet:
                    break;

                default:
                    break;
                }
            }
            catch (Exception e)
            {
                Debug.Console(0, "Cannot create communication from JSON:\r{0}\r\rException:\r{1}",
                              deviceConfig.Properties.ToString(), e);
            }

            // put it in the device manager if it's the right flavor
            var comDev = comm as Device;

            if (comDev != null)
            {
                DeviceManager.AddDevice(comDev);
            }
            return(comm);
        }
コード例 #21
0
 /// <summary>
 /// Constructor for IBasicCommunication
 /// </summary>
 public PanasonicThDisplay(string key, string name, IBasicCommunication comm)
     : base(key, name)
 {
     Communication = comm;
     Init();
 }
コード例 #22
0
 public GenericCommunicationMonitoredDevice(string key, string name, IBasicCommunication comm, string pollString)
     : this(key, name, comm, pollString, 30000, 120000, 300000)
 {
 }
コード例 #23
0
 /// <summary>
 /// Build the monitor from a config object
 /// </summary>
 public GenericCommunicationMonitor(IKeyed parent, IBasicCommunication client,
                                    CommunicationMonitorConfig props) :
     this(parent, client, props.PollInterval, props.TimeToWarning, props.TimeToError, props.PollString)
 {
 }
コード例 #24
0
ファイル: NECPSXMDisplay.cs プロジェクト: srmeteor/Essentials
 /// <summary>
 /// Constructor for IBasicCommunication
 /// </summary>
 public NecPSXMDisplay(string key, string name, IBasicCommunication comm)
     : base(key, name)
 {
     Communication = comm;
     Init();
 }
コード例 #25
0
        /// <summary>
        /// CameraVisca Plugin device constructor using IBasicCommunication
        /// </summary>
        /// <param name="key"></param>
        /// <param name="name"></param>
        /// <param name="config"></param>
        /// <param name="comms"></param>
        public CameraVisca(string key, string name, CameraViscaConfig config, IBasicCommunication comm)
            : base(key, name)
        {
            Debug.Console(0, this, "Constructing new {0} instance", name);

            _config = config;
            Enabled = _config.Enabled;

            _visca = new ViscaProtocolProcessor(comm.SendBytes, new Action <byte, string, object[]>((l, f, o) =>
            {
                Debug.Console(l, this, f, o);
            }));

            _camera             = new ViscaCamera((ViscaCameraId)_config.Id, null, _visca);
            _camera.PollEnabled = Enabled;

            Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom | eCameraCapabilities.Focus;
            ControlMode  = eCameraControlMode.Auto;

            ConnectFeedback       = new BoolFeedback(() => Connect);
            OnlineFeedback        = new BoolFeedback(() => _commsMonitor.IsOnline);
            StatusFeedback        = new IntFeedback(() => (int)_commsMonitor.Status);
            PowerIsOnFeedback     = new BoolFeedback(() => _camera.Power);
            CameraIsOffFeedback   = new BoolFeedback(() => !_camera.Power);
            CameraIsMutedFeedback = new BoolFeedback(() => _camera.Mute);

            _camera.PowerChanged += (o, e) => { PowerIsOnFeedback.FireUpdate(); CameraIsOffFeedback.FireUpdate(); };
            _camera.MuteChanged  += (o, e) => { CameraIsMutedFeedback.FireUpdate(); };

            _cameraPollCommands = new Dictionary <string, Action>()
            {
                { "AE", _camera.AEPoll },
                { "Aperture", _camera.AperturePoll },
                { "BackLight", _camera.BackLightPoll },
                { "BGain", _camera.BGainPoll },
                { "ExpComp", _camera.ExpCompPoll },
                { "FocusAuto", _camera.FocusAutoPoll },
                { "FocusPosition", _camera.FocusPositionPoll },
                { "Gain", _camera.GainPoll },
                { "Iris", _camera.IrisPoll },
                { "Mute", _camera.MutePoll },
                { "PTZPosition", _camera.PanTiltPositionPoll },
                { "Power", _camera.PowerPoll },
                { "RGain", _camera.RGainPoll },
                { "Shutter", _camera.ShutterPoll },
                { "Title", _camera.TitlePoll },
                { "WB", _camera.WBModePoll },
                { "WD", _camera.WideDynamicModePoll },
                { "ZoomPosition", _camera.ZoomPositionPoll },
            };

            _comms = comm;

            // TODO: For VISCA camera current library implementation only
            // serial is supported, so socket code is not needed
            var socket = _comms as ISocketStatus;

            if (socket != null)
            {
                socket.ConnectionChange += socket_ConnectionChange;
                if (Enabled)
                {
                    Connect = true;
                }
            }

            if (_config.CommunicationMonitorProperties != null)
            {
                if (!String.IsNullOrEmpty(_config.CommunicationMonitorProperties.PollString))
                {
                    foreach (var poll in _config.CommunicationMonitorProperties.PollString.Split(','))
                    {
                        if (_cameraPollCommands.ContainsKey(poll.Trim()))
                        {
                            _poll.Add(_cameraPollCommands[poll.Trim()]);
                        }
                    }
                }

                _commsMonitor = new GenericCommunicationMonitor(this, _comms,
                                                                _config.CommunicationMonitorProperties.PollInterval,
                                                                _config.CommunicationMonitorProperties.TimeToWarning,
                                                                _config.CommunicationMonitorProperties.TimeToError,
                                                                () => _poll.ForEach((pollAction) => pollAction())
                                                                );
            }
            else
            {
                // We do not have CommunicationMonitorProperties and therefore
                // no Poll string defined, using ALL poll functions
                _poll.AddRange(_cameraPollCommands.Values);
                _commsMonitor = new GenericCommunicationMonitor(this, _comms, 10000, 20000, 30000, () => _poll.ForEach((pollAction) => pollAction()));
            }

            _commsMonitor.Client.BytesReceived += (s, e) => _visca.ProcessIncomingData(e.Bytes);
            DeviceManager.AddDevice(CommunicationMonitor);

            // Handle Increase PTZ move speed
            #region PTZ Speed Increase

            // if FastSpeedHoldTimeMs defined in config, enable SpeedIncrease behaivor
            if (_config.FastSpeedHoldTimeMs > 0)
            {
                _ptzSpeedIncreaseBehaivor = true;

                if (_config.PanSpeedSlow > 0)
                {
                    _camera.PanSpeed = _config.PanSpeedSlow;
                }

                if (_config.TiltSpeedSlow > 0)
                {
                    _camera.TiltSpeed = _config.TiltSpeedSlow;
                }

                _ptzPanNormalSpeed  = _camera.PanSpeed;
                _ptzTiltNormalSpeed = _camera.TiltSpeed;

                _ptzSpeedIncreaseAction = ptzCommand =>
                {
                    // Kill Speed Increase Timer as we already in fast pace
                    ptzSpeedChangeTimerDispose();
                    // if Fast speeds not defined, use Max values
                    _camera.PanSpeed  = (_config.PanSpeedFast > 0) ? _config.PanSpeedFast : Visca.ViscaDefaults.PanSpeedLimits.High;
                    _camera.TiltSpeed = (_config.TiltSpeedFast > 0) ? _config.PanSpeedFast : Visca.ViscaDefaults.TiltSpeedLimits.High;
                    // we passed current ptz command to action, so we repeat it with increased speed
                    (ptzCommand as Action).Invoke();
                };
            }

            #endregion PTZ Speed Increase
        }