public void Initialize(TcpServerConfigObject serverConfigObject)
 {
     try
     {
         if (serverConfigObject != null || string.IsNullOrEmpty(serverConfigObject.Key))
         {
             Key               = serverConfigObject.Key;
             MaxClients        = serverConfigObject.MaxClients;
             Port              = serverConfigObject.Port;
             SharedKeyRequired = serverConfigObject.SharedKeyRequired;
             SharedKey         = serverConfigObject.SharedKey;
             HeartbeatRequired = serverConfigObject.HeartbeatRequired;
             HeartbeatRequiredIntervalInSeconds = serverConfigObject.HeartbeatRequiredIntervalInSeconds;
             HeartbeatStringToMatch             = serverConfigObject.HeartbeatStringToMatch;
             BufferSize       = serverConfigObject.BufferSize;
             ReceiveQueueSize = serverConfigObject.ReceiveQueueSize > 20 ? serverConfigObject.ReceiveQueueSize : 20;
             MessageQueue     = new CrestronQueue <GenericTcpServerCommMethodReceiveTextArgs>(ReceiveQueueSize);
         }
         else
         {
             ErrorLog.Error("Could not initialize server with key: {0}", serverConfigObject.Key);
         }
     }
     catch
     {
         ErrorLog.Error("Could not initialize server with key: {0}", serverConfigObject.Key);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new object pool with a specified initial and max capacity.
        /// </summary>
        /// <param name="initialCapacity">Initial pool capacity.</param>
        /// <param name="maxCapacity">Max pool capacity</param>
        /// <param name="initFunc">Initialization function</param>
        /// <exception cref="ArgumentException">Invalid initial or max capacity.</exception>
        public ObjectPool(int initialCapacity, int maxCapacity, Func <T> initFunc)
        {
            if (initialCapacity < 1)
            {
                throw new ArgumentException("Initial capacity cannot be less than 1.");
            }

            if (maxCapacity < 1)
            {
                throw new ArgumentException("Max capacity cannot be less than 1.");
            }

            if (initialCapacity > maxCapacity)
            {
                throw new ArgumentException("Initial capacity cannot be greater than max capacity.");
            }

            MaxCapacity = maxCapacity;
            _objectPool = new CrestronQueue <T>(initialCapacity);

            if (initialCapacity > 0)
            {
                AddToPool(initialCapacity, initFunc);
            }
        }
Exemplo n.º 3
0
        public SamsungDisplayComPortHandler(IComPortDevice comPort)
        {
            _comPort = comPort;
            _rxQueue = new CrestronQueue <byte>(1000);

            CrestronEnvironment.ProgramStatusEventHandler += type =>
            {
                if (type == eProgramStatusEventType.Stopping)
                {
                    _programStopping = true;

                    if (_txThread != null && _txThread.ThreadState == Thread.eThreadStates.ThreadRunning)
                    {
                        _txQueue.Enqueue(null);
                    }

                    if (_rxThread != null && _rxThread.ThreadState == Thread.eThreadStates.ThreadRunning)
                    {
                        _rxQueue.Enqueue(0x00);
                    }
                }
            };

            _txQueue = new CrestronQueue <byte[]>(50);
        }
        /// <summary>
        /// CCDDisplay Plugin device constructor for ISerialComport transport
        /// </summary>
        /// <param name="key"></param>
        /// <param name="name"></param>
        /// <param name="config"></param>
        /// <param name="display">Loaded and initialized instance of CCD Display driver instance</param>
        public ClearOneDSPDevice(string key, string name, ClearOneDSPConfig config, IBasicCommunication comm)
            : base(key, name)
        {
            Debug.Console(0, this, "Constructing new {0} instance", name);

            _config                 = config;
            _commandQueue           = new CrestronQueue(100);
            _responseQueue          = new CrestronQueue <string>();
            _responseParseThread    = new Thread(parseResponse, null, Thread.eThreadStartOptions.Running);
            _commandInProgressTimer = new CTimer((o) => { _commandInProgress = null; }, Timeout.Infinite);

            _devices = new Dictionary <string, ClearOneDSPDeviceInfo>();

            Communication             = comm;
            _portGather               = new CommunicationGather(Communication, "\x0D\x0A");
            _portGather.LineReceived += this.lineReceived;

            if (config.CommunicationMonitorProperties != null)
            {
                CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, config.CommunicationMonitorProperties);
            }
            else
            {
                //#warning Need to deal with this poll string
                CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 30000, 30000, 60000, new Action(() =>
                {
                    if (_devices.Count == 0)
                    {
                        _commandQueue.Enqueue("** VER");
                    }
                    //sendLine("** VER");

                    foreach (var controlPoint in LevelControlPoints.Values)
                    {
                        controlPoint.Poll();
                    }
                }));
            }

            LevelControlPoints = new Dictionary <string, ClearOneDSPVolumeControl>();
            foreach (KeyValuePair <string, ClearOneLevelControlBlockConfig> kvp in _config.LevelControlBlocks)
            {
                this.LevelControlPoints.Add(kvp.Key, new ClearOneDSPVolumeControl(kvp.Key, kvp.Value, this));
            }

            CrestronConsole.AddNewConsoleCommand((s) =>
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine("Devices:");
                foreach (var kvp in _devices)
                {
                    sb.AppendFormat("\tDevice: {0}\r\n", kvp.Key);
                    sb.AppendFormat("\t\tModel:     {0}\r\n", kvp.Value.DeviceType.ToString());
                    sb.AppendFormat("\t\tId:        {0}\r\n", kvp.Value.DeviceId);
                    sb.AppendFormat("\t\tFirmware:  {0}\r\n", kvp.Value.Version);
                }
                CrestronConsole.ConsoleCommandResponse("{0}", sb.ToString());
            },
                                                 Key + "INFO", "Print Driver Info", ConsoleAccessLevelEnum.AccessOperator);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initialzes all methods that are required to setup the class. Connection is established on port 1702.
        /// </summary>
        public static void Initialize(string host, ushort port)
        {
            if (!isInitialized)
            {
                try
                {
                    if (debug == 1)
                    {
                        ErrorLog.Notice("QsysProcessor is initializing.");
                    }
                    commandQueue       = new CrestronQueue <string>();
                    responseQueue      = new CrestronQueue <string>();
                    commandQueueTimer  = new CTimer(CommandQueueDequeue, null, 0, 50);
                    responseQueueTimer = new CTimer(ResponseQueueDequeue, null, 0, 50);

                    client    = new TCPClientDevice();
                    client.ID = 1710;
                    client.ConnectionStatus += new StatusEventHandler(client_ConnectionStatus);
                    client.ResponseString   += new ResponseEventHandler(client_ResponseString);
                    client.Connect(host, port);
                }
                catch (Exception e)
                {
                }
            }
        }
Exemplo n.º 6
0
 public void Initialize()
 {
     _receivedData        = new CrestronQueue <string>();
     _receivedDataDequeue = new CTimer(DataReceivedDequeue, null, 0, 10);
     _waitForConnection   = new CTimer(WaitForConnection, null, 0, 5000);
     Processor.AddRoomInterface(this);
 }
Exemplo n.º 7
0
        public NecComPortHandler(IComPortDevice comPort)
        {
            _comPort = comPort;
            RxQueue  = new CrestronQueue <byte>(1000);

            var port = _comPort as ComPort;

            if (port != null)
            {
                if (!port.Registered)
                {
                    if (port.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                    {
                        ErrorLog.Error("Could not register com port {0}", _comPort.ID);
                    }
                }
            }

            var spec = new ComPort.ComPortSpec()
            {
                BaudRate          = ComPort.eComBaudRates.ComspecBaudRate9600,
                DataBits          = ComPort.eComDataBits.ComspecDataBits8,
                Parity            = ComPort.eComParityType.ComspecParityNone,
                StopBits          = ComPort.eComStopBits.ComspecStopBits1,
                Protocol          = ComPort.eComProtocolType.ComspecProtocolRS232,
                HardwareHandShake = ComPort.eComHardwareHandshakeType.ComspecHardwareHandshakeNone,
                SoftwareHandshake = ComPort.eComSoftwareHandshakeType.ComspecSoftwareHandshakeNone,
                ReportCTSChanges  = false
            };


            _comPort.SetComPortSpec(spec);
        }
Exemplo n.º 8
0
        public TVOneCorio(string key, string name, IBasicCommunication comm, TVOneCorioPropertiesConfig 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");
            }
        }
Exemplo n.º 9
0
 /// <summary>
 /// Initialize called by the constructor that accepts a client config object. Can be called later to reset properties of client.
 /// </summary>
 /// <param name="clientConfigObject"></param>
 public void Initialize(TcpClientConfigObject clientConfigObject)
 {
     try
     {
         if (clientConfigObject != null)
         {
             var TcpSshProperties = clientConfigObject.Control.TcpSshProperties;
             Hostname                = TcpSshProperties.Address;
             AutoReconnect           = TcpSshProperties.AutoReconnect;
             AutoReconnectIntervalMs = TcpSshProperties.AutoReconnectIntervalMs > 1000 ?
                                       TcpSshProperties.AutoReconnectIntervalMs : 5000;
             SharedKey         = clientConfigObject.SharedKey;
             SharedKeyRequired = clientConfigObject.SharedKeyRequired;
             HeartbeatEnabled  = clientConfigObject.HeartbeatRequired;
             HeartbeatRequiredIntervalInSeconds = clientConfigObject.HeartbeatRequiredIntervalInSeconds > 0 ?
                                                  clientConfigObject.HeartbeatRequiredIntervalInSeconds : (ushort)15;
             HeartbeatString  = string.IsNullOrEmpty(clientConfigObject.HeartbeatStringToMatch) ? "heartbeat" : clientConfigObject.HeartbeatStringToMatch;
             Port             = TcpSshProperties.Port;
             BufferSize       = TcpSshProperties.BufferSize > 2000 ? TcpSshProperties.BufferSize : 2000;
             ReceiveQueueSize = clientConfigObject.ReceiveQueueSize > 20 ? clientConfigObject.ReceiveQueueSize : 20;
             MessageQueue     = new CrestronQueue <GenericTcpServerCommMethodReceiveTextArgs>(ReceiveQueueSize);
         }
         else
         {
             ErrorLog.Error("Could not initialize client with key: {0}", Key);
         }
     }
     catch
     {
         ErrorLog.Error("Could not initialize client with key: {0}", Key);
     }
 }
Exemplo n.º 10
0
        /// <summary>
        /// Constructor for S+. Make sure to set key, address, port, and buffersize using init method
        /// </summary>
        public GenericUdpServer()
            : base("Uninitialized Udp Server")
        {
            BufferSize   = 5000;
            DequeueLock  = new CCriticalSection();
            MessageQueue = new CrestronQueue <GenericUdpReceiveTextExtraArgs>();

            CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
            CrestronEnvironment.EthernetEventHandler      += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler);
        }
Exemplo n.º 11
0
 /// <summary>
 /// A TCP Socket Client connection.
 /// </summary>
 /// <param name="address">Address the client should connect to</param>
 /// <param name="port">The remote TCP port number to use</param>
 /// <param name="bufferSize">Size of the buffer</param>
 /// <remarks>The client will automatically deal with program stops and LAN links going down / up.</remarks>
 public TCPSocketClient(string address, int port, int bufferSize)
 {
     ProgramRunning              = true;
     _client                     = new TCPClient(address, port, bufferSize);
     _client.SocketStatusChange += new TCPClientSocketStatusChangeEventHandler(OnSocketStatusChange);
     CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(ProgramStatusEventHandler);
     CrestronEnvironment.EthernetEventHandler      += new EthernetEventHandler(OnEthernetEvent);
     _sendQueue   = new CrestronQueue <byte[]>(50);
     ReceiveQueue = new CrestronQueue <byte>(bufferSize);
 }
Exemplo n.º 12
0
        /// <summary>
        /// Initialzes all methods that are required to setup the class. Connection is established on port 1702.
        /// </summary>
        public void Initialize(string id, string host, ushort port, string username, string password, ushort useExternalConnection)
        {
            if (!isInitialized)
            {
                try
                {
                    coreId = id;

                    externalConnection = Convert.ToBoolean(useExternalConnection);

                    if (username.Length > 0)
                    {
                        this.username = username;
                    }
                    else
                    {
                        this.username = string.Empty;
                    }

                    if (password.Length > 0)
                    {
                        this.password = password;
                    }
                    else
                    {
                        this.password = string.Empty;
                    }

                    QsysCoreManager.AddCore(this);

                    if (debug == 1)
                    {
                        ErrorLog.Notice("QsysProcessor is initializing.");
                    }

                    commandQueue       = new CrestronQueue <string>();
                    responseQueue      = new CrestronQueue <string>();
                    commandQueueTimer  = new CTimer(CommandQueueDequeue, null, 0, 50);
                    responseQueueTimer = new CTimer(ResponseQueueDequeue, null, 0, 50);

                    client    = new TCPClientDevice();
                    client.ID = 1710;
                    client.ConnectionStatus += new StatusEventHandler(client_ConnectionStatus);
                    client.ResponseString   += new ResponseEventHandler(client_ResponseString);
                    client.Connect(host, port);
                }
                catch (Exception e)
                {
                    if (debug == 1 || debug == 2)
                    {
                        ErrorLog.Error("Error in QsysProcessor Iniitialize: {0}", e.Message);
                    }
                }
            }
        }
Exemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="key"></param>
        /// <param name="address"></param>
        /// <param name="port"></param>
        /// <param name="buffefSize"></param>
        public GenericUdpServer(string key, string address, int port, int buffefSize)
            : base(key)
        {
            Hostname   = address;
            Port       = port;
            BufferSize = buffefSize;

            DequeueLock  = new CCriticalSection();
            MessageQueue = new CrestronQueue <GenericUdpReceiveTextExtraArgs>();

            CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
            CrestronEnvironment.EthernetEventHandler      += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler);
        }
Exemplo n.º 14
0
        public DigitalLogger(string key, string name, DigitalLoggerPropertiesConfig props) :
            base(key, name)
        {
            CircuitCount  = 8;
            this.userName = props.userName;
            this.password = props.password;
            CommandQueue  = new CrestronQueue(100);

            WebClient             = new HttpClient();
            WebClient.UserName    = this.userName;
            WebClient.Password    = this.password;
            this.address          = props.address;
            WebClient.HostAddress = props.address;
        }
Exemplo n.º 15
0
        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));
            }
        }
Exemplo n.º 16
0
        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();
        }
Exemplo n.º 17
0
        /// <summary>
        /// Initialize new core
        /// </summary>
        public bool Initialize(int _coreID, string _host, ushort _port, string _user, string _pass)
        {
            if (this.initRun)
            {
                return(false);
            }

            bool added = QsysMain.AddCore(this, this.coreID);

            this.coreID    = _coreID;
            this.coreIP    = _host;
            this.corePort  = _port;
            this.loginUser = _user;
            this.loginPass = _pass;

            if (added)
            {
                this.SendDebug(string.Format("Add core {0} @ {1}:{2} & initialize", coreID, coreIP, corePort));
            }

            if (this.commandQueue == null)
            {
                this.commandQueue = new CrestronQueue <string>();
            }

            if (this.responseQueue == null)
            {
                this.responseQueue = new CrestronQueue <string>();
            }

            if (this.commandQueueTimer == null)
            {
                this.commandQueueTimer = new CTimer(CommandQueueDequeue, null, 0, 50);
            }

            if (this.responseQueueTimer == null)
            {
                this.responseQueueTimer = new CTimer(ResponseQueueDequeue, null, 0, 50);
            }

            if (this.isConnected == false)
            {
                this.initializeConnection();
            }
            this.initRun = true;
            return(true);
        }
Exemplo n.º 18
0
        //Initialize
        public void Initialize(int _panelId)
        {
            if (this.initRun)
            {
                return;
            }

            panelId = _panelId;

            this.SendDebug(string.Format("Added and initialized Panel ", _panelId));

            for (int i = 1; i <= 8; i++)
            {
                if (!Areas.ContainsKey(i))
                {
                    ElkArea a = new ElkArea();
                    a.Initialize(this, i);
                    Areas.Add(i, a);
                }
            }
            for (int i = 1; i <= 208; i++)
            {
                if (!Zones.ContainsKey(i))
                {
                    ElkZone z = new ElkZone();
                    z.Initialize(this, i);
                    Zones.Add(i, z);
                }
            }
            for (int i = 1; i <= 208; i++)
            {
                if (!Outputs.ContainsKey(i))
                {
                    ElkOutput o = new ElkOutput();
                    o.Initialize(this, i);
                    Outputs.Add(i, o);
                }
            }

            commandQueue  = new CrestronQueue <string>();
            responseQueue = new CrestronQueue <string>();

            this.panelId = _panelId;

            this.initRun = true;
        }
Exemplo n.º 19
0
        // Constructor
        public TCPServerDemo(IPEndPoint ip)
        {
            CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(this.HandleProgramEvent);
            CrestronEnvironment.SystemEventHandler        += new SystemEventHandler(this.HandleSystemEvent);

            this.myIP = ip;
            txMsgs    = new CrestronQueue <string>(50);
            rxMsgs    = new CrestronQueue <string>(50);

            _TCPServer = new TCPServer("0.0.0.0", ip.Port, 1000);
            _TCPServer.WaitForConnectionAsync(new TCPServerClientConnectCallback(ConnectProcessor));

            _TCPServer.SocketStatusChange += new TCPServerSocketStatusChangeEventHandler(SocketStatusHandler);

            _tRXProcessorIL = 0;
            _tSendDataIL    = 0;
        }
Exemplo n.º 20
0
        // Constructor
        public PakedgeP8E(string name, String newIP)
            : base(name)
        {
            // Register system event handlers
            CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(this.HandleProgramEvent);
            CrestronEnvironment.SystemEventHandler        += new SystemEventHandler(this.HandleSystemEvent);

            _SentMessages = new CrestronQueue <string>();

            _Socket = new TCPClient(newIP, 23, 16384);
            _Socket.SocketSendOrReceiveTimeOutInMs = 20000;

            _Socket.SocketStatusChange += new TCPClientSocketStatusChangeEventHandler(SocketStatusHandler);

            Outlets = new List <Outlet>();

            Login(null);
        }
Exemplo n.º 21
0
        public NecComPortHandler(ComPort comPort)
        {
            ComPort = comPort;
            RxQueue = new CrestronQueue <byte>(1000);

            if (!ComPort.Registered)
            {
                if (ComPort.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("Could not register com port {0}", ComPort.ID);
                }
            }

            ComPort.SetComPortSpec(ComPort.eComBaudRates.ComspecBaudRate9600,
                                   ComPort.eComDataBits.ComspecDataBits8,
                                   ComPort.eComParityType.ComspecParityNone,
                                   ComPort.eComStopBits.ComspecStopBits1,
                                   ComPort.eComProtocolType.ComspecProtocolRS232,
                                   ComPort.eComHardwareHandshakeType.ComspecHardwareHandshakeNone,
                                   ComPort.eComSoftwareHandshakeType.ComspecSoftwareHandshakeNone,
                                   false);
        }
Exemplo n.º 22
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));
            }
        }
Exemplo n.º 23
0
        public ComPortHandler(IComPortDevice comPort)
        {
            _bytes   = new byte[10000];
            _port    = comPort;
            _rxQueue = new CrestronQueue <byte[]>();

            var cp = _port as ComPort;

            if (cp != null && !cp.Registered)
            {
                var result = cp.Register();
                if (result != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    CloudLog.Warn("Registering comport for {0} result: {1}", GetType().Name, result);
                }
            }

            try
            {
                var spec = new ComPort.ComPortSpec()
                {
                    BaudRate          = ComPort.eComBaudRates.ComspecBaudRate38400,
                    DataBits          = ComPort.eComDataBits.ComspecDataBits8,
                    StopBits          = ComPort.eComStopBits.ComspecStopBits1,
                    Parity            = ComPort.eComParityType.ComspecParityNone,
                    HardwareHandShake = ComPort.eComHardwareHandshakeType.ComspecHardwareHandshakeNone,
                    SoftwareHandshake = ComPort.eComSoftwareHandshakeType.ComspecSoftwareHandshakeNone,
                    Protocol          = ComPort.eComProtocolType.ComspecProtocolRS232,
                    ReportCTSChanges  = false
                };
                _port.SetComPortSpec(spec);
            }
            catch (Exception e)
            {
                CloudLog.Error("Error could not set comport spec for {0}, {1}", GetType().Name, e.Message);
            }
        }
Exemplo n.º 24
0
 public SshClientControl()
 {
     disposed = false;
     cmdQueue = new CrestronQueue <string>();
     CrestronInvoke.BeginInvoke(ProcessResponse);
 }
Exemplo n.º 25
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();
        }