コード例 #1
0
        public BasicIrDisplay(string key, string name, IROutputPort port, string irDriverFilepath)
            : base(key, name)
        {
            IrPort = new IrOutputPortController(key + "-ir", port, irDriverFilepath);
            DeviceManager.AddDevice(IrPort);

            PowerIsOnFeedback.OutputChange += (o, a) => {
                Debug.Console(2, this, "Power on={0}", _PowerIsOn);
                if (_PowerIsOn)
                {
                    StartWarmingTimer();
                }
                else
                {
                    StartCoolingTimer();
                }
            };
            IsWarmingUpFeedback.OutputChange   += (o, a) => Debug.Console(2, this, "Warming up={0}", _IsWarmingUp);
            IsCoolingDownFeedback.OutputChange += (o, a) => Debug.Console(2, this, "Cooling down={0}", _IsCoolingDown);

            InputPorts.AddRange(new RoutingPortCollection <RoutingInputPort>
            {
                new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                     eRoutingPortConnectionType.Hdmi, new Action(Hdmi1), this, false),
                new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                     eRoutingPortConnectionType.Hdmi, new Action(Hdmi2), this, false),
                new RoutingInputPort(RoutingPortNames.HdmiIn3, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                     eRoutingPortConnectionType.Hdmi, new Action(Hdmi3), this, false),
                new RoutingInputPort(RoutingPortNames.HdmiIn4, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                     eRoutingPortConnectionType.Hdmi, new Action(Hdmi4), this, false),
                new RoutingInputPort(RoutingPortNames.ComponentIn, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                     eRoutingPortConnectionType.Hdmi, new Action(Component1), this, false),
                new RoutingInputPort(RoutingPortNames.CompositeIn, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                     eRoutingPortConnectionType.Hdmi, new Action(Video1), this, false),
                new RoutingInputPort(RoutingPortNames.AntennaIn, eRoutingSignalType.Audio | eRoutingSignalType.Video,
                                     eRoutingPortConnectionType.Hdmi, new Action(Antenna), this, false),
            });
        }
コード例 #2
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);
        }