/// <summary>
 /// Constructor for TCP
 /// </summary>
 public SamsungMDC(string key, string name, string hostname, int port, string id)
     : base(key, name)
 {
     Communication = new GenericTcpIpClient(key + "-tcp", hostname, port, 5000);
     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();
 }
        /// <summary>
        /// Constructor for TCP
        /// </summary>
        public AvocorDisplay(string key, string name, string hostname, int port, string id)
            : base(key, name)
        {
            Communication = new GenericTcpIpClient(key + "-tcp", hostname, port, 5000);

            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();
        }
Exemple #3
0
        public void InitialzeConnection(string _host, ushort _port)
        {
            this.panelIp   = _host;
            this.panelPort = _port;

            if (this.panelIp.Length > 0)
            {
                this.SendDebug(string.Format("Initializing Panel {0} connection @ {1}:{2} & initialize", panelId, panelIp, panelPort));

                this.tcpClient = new GenericTcpIpClient("elk", this.panelIp, this.panelPort, 2000);

                this.tcpClient.TextReceived     += TcpClientOnTextReceived;
                this.tcpClient.ConnectionChange += tcpClient_ConnectionChange;
                this.tcpClient.AutoReconnect     = true;
                this.tcpClient.Connect();
            }
        }
Exemple #4
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);
        }
Exemple #5
0
 /// <summary>
 /// Constructor for TCP
 /// </summary>
 public PanasonicThDisplay(string key, string name, string hostname, int port)
     : base(key, name)
 {
     Communication = new GenericTcpIpClient(key + "-tcp", hostname, port, 5000);
     Init();
 }