private void CreateDriver(string filename, uint comPortNumber)
        {
            // Use reflection to get the driver
            _device = GetAssembly <IBasicVideoServer>(filename, "IBasicVideoServer", "ISerialComport");

            if (_device != null)
            {
                // Set up hardware
                ComPorts[_deviceComPortNumber].Register();
                var serialTransport = new SerialTransport(ComPorts[comPortNumber]);
                var serialDriver    = _device as ISerialComport;
                serialTransport.SetComPortSpec(serialDriver.ComSpec);

                // Initialize the transport
                serialDriver.Initialize(serialTransport);

                // Suscribe to events
                _device.StateChangeEvent += new Action <VideoServerStateObjects, IBasicVideoServer, byte>(VideoServerStateChange);

                // Set all default values for the VT Pro project
                SetDefaultValues();

                // Set the device ID
                _device.Id = _deviceId;

                // Connect the driver to the device
                _device.Connect();
            }
        }
Esempio n. 2
0
        private void TestComDisplay()
        {
            CrestronConsole.PrintLine("Running RS-232 display tests...");

            // Check display connection point. If 0 -> control system, otherwise AV Switcher
            ComPort displayPort = this.ComPorts[1];

            // if comport is not registered, register it
            if (!displayPort.Registered)
            {
                if (displayPort.Register() != eDeviceRegistrationUnRegistrationResponse.Success)
                {
                    ErrorLog.Error("Failed to register comport {0} -- {1}", 1, displayPort.DeviceRegistrationFailureReason);
                }
            }

            // Create new SerialTransport object passing target ComPort as constructor argument
            SerialTransport transport       = new SerialTransport(displayPort);
            SspCompanyVideoDisplayComport d = new SspCompanyVideoDisplayComport();

            transport.SetComPortSpec(((ISerialComport)d).ComSpec);
            ((ISerialComport)d).Initialize(transport);
            d.StateChangeEvent += new Action <DisplayStateObjects, IBasicVideoDisplay, byte>(StateChangeEvent);
            Displays.Add(d);

            ((ISerialComport)d).Connect();
            CrestronConsole.PrintLine("Connection status: {0}", d.Connected);
            d.SetVolume(10);
            d.SetInputSource(Crestron.ThirdPartyCommon.Class.VideoConnections.Hdmi1);
            CrestronConsole.PrintLine("Connection status: {0}", d.Connected);
        }