예제 #1
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");
            }
        }
예제 #2
0
        void Init()
        {
            PortGather = new CommunicationGather(Communication, '\x0d');
            PortGather.LineReceived += this.Port_LineReceived;
            CommunicationMonitor     = new GenericCommunicationMonitor(this, Communication, 30000, 120000, 300000, "\x02QPW\x03");         // Query Power

            InputPorts.Add(new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                                eRoutingPortConnectionType.Hdmi, new Action(InputHdmi1), this));
            InputPorts.Add(new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                                eRoutingPortConnectionType.Hdmi, new Action(InputHdmi2), this));

            InputPorts.Add(new RoutingInputPort(RoutingPortNames.DviIn, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                                eRoutingPortConnectionType.Dvi, new Action(InputDvi1), this));
            InputPorts.Add(new RoutingInputPort(RoutingPortNames.CompositeIn, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                                eRoutingPortConnectionType.Composite, new Action(InputVideo1), this));
            InputPorts.Add(new RoutingInputPort(RoutingPortNames.VgaIn, eRoutingSignalType.Video,
                                                eRoutingPortConnectionType.Vga, new Action(InputVga), this));


            VolumeLevelFeedback = new IntFeedback(() => { return(_VolumeLevel); });
            MuteFeedback        = new BoolFeedback(() => _IsMuted);

            //    new BoolCueActionPair(CommonBoolCue.Menu, b => { if(b) Send(MenuIrCmd); }),
            //    new BoolCueActionPair(CommonBoolCue.Up, b => { if(b) Send(UpIrCmd); }),
            //    new BoolCueActionPair(CommonBoolCue.Down, b => { if(b) Send(DownIrCmd); }),
            //    new BoolCueActionPair(CommonBoolCue.Left, b => { if(b) Send(LeftIrCmd); }),
            //    new BoolCueActionPair(CommonBoolCue.Right, b => { if(b) Send(RightIrCmd); }),
            //    new BoolCueActionPair(CommonBoolCue.Select, b => { if(b) Send(SelectIrCmd); }),
            //    new BoolCueActionPair(CommonBoolCue.Exit, b => { if(b) Send(ExitIrCmd); }),
            //};
        }
예제 #3
0
        /// <summary>
        /// Intial logic to set up instance
        /// </summary>
        void Init()
        {
            // Will gather to the specified delimiter
            PortGather = new CommunicationGather(Communication, '\x03');
            PortGather.LineReceived += this.Port_LineReceived;

            // Constuct the CommunicationMonitor
            CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 30000, 120000, 300000, "\x02QPW\x03\x02QMI\x03"); // Query Power

            // Define the input ports
            InputPorts.Add(new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                                eRoutingPortConnectionType.Hdmi, new Action(InputHdmi1), this));
            InputPorts.Add(new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                                eRoutingPortConnectionType.Hdmi, new Action(InputHdmi2), this));
            InputPorts.Add(new RoutingInputPort(RoutingPortNames.DviIn, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                                eRoutingPortConnectionType.Dvi, new Action(InputDvi1), this));
            InputPorts.Add(new RoutingInputPort(RoutingPortNames.VgaIn, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                                eRoutingPortConnectionType.Vga, new Action(InputVga), this));

            // Define the feedback Funcs
            VolumeLevelFeedback = new IntFeedback(() => { return(_VolumeLevel); });
            MuteFeedback        = new BoolFeedback(() => _IsMuted);
            InputNumberFeedback = new IntFeedback(() => { Debug.Console(2, this, "CHange Input number {0}", InputNumber); return(InputNumber); });

            // Set the warmup time
            WarmupTime = 17000;
        }
        /// <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);
        }
예제 #5
0
        public CameraVisca(string key, string name, IBasicCommunication comm, CameraPropertiesConfig props) :
            base(key, name)
        {
            // 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);
        }
예제 #6
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;
 }
예제 #7
0
        /// <summary>
        /// Constructor for COM
        /// </summary>
        public AvocorDisplay(string key, string name, ComPort port, ComPort.ComPortSpec spec, string id)
            : base(key, name)
        {
            Communication = new ComPortController(key + "-com", port, spec);

            PortGather = new CommunicationGather(Communication, '\x0d');
            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();
        }
예제 #8
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();
        }
예제 #9
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));
            }
        }
예제 #10
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();
        }
        /// <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
        }
예제 #12
0
        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");
            }
        }
예제 #13
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);
        }
예제 #14
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));
            }
        }
예제 #15
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();
        }