/// <summary> /// Constructor of the Control System Class. Make sure the constructor always exists. /// If it doesn't exit, the code will not run on your 3-Series processor. /// </summary> public ControlSystem() : base() { // subscribe to control system events CrestronEnvironment.SystemEventHandler += new SystemEventHandler(CrestronEnvironment_SystemEventHandler); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler); // Set the number of threads which you want to use in your program - At this point the threads cannot be created but we should // define the max number of threads which we will use in the system. // the right number depends on your project; do not make this number unnecessarily large Thread.MaxNumberOfUserThreads = 20; // ensure this processor has ethernet if (this.SupportsEthernet) { // create new dmtx401c object and subscribe to its events dmTx = new DmTx401C(0x03, this); // IPID for the dmtx is 3 dmTx.BaseEvent += dmTx_BaseEvent; dmTx.HdmiInput.InputStreamChange += HdmiInput_InputStreamChange; dmTx.HdmiInput.VideoAttributes.AttributeChange += Hdmi_AttributeChange; dmTx.VgaInput.InputStreamChange += VgaInput_InputStreamChange; dmTx.VgaInput.VideoAttributes.AttributeChange += Vga_AttributeChange; dmTx.DisplayPortInput.InputStreamChange += DisplayPortInput_InputStreamChange; dmTx.DisplayPortInput.VideoAttributes.AttributeChange += DisplayPort_AttributeChange; dmTx.OnlineStatusChange += Device_OnlineStatusChange; // create new tt100 object using the dmtx401 constructor, and subscribe to its events connectIt = new Tt1xx(dmTx); connectIt.ButtonStateChange += connectIt_ButtonStateChange; connectIt.OnlineStatusChange += Device_OnlineStatusChange; // register the dmtx to this program, the tt100 will be registered as part of the dmtx if (dmTx.Register() == eDeviceRegistrationUnRegistrationResponse.Success) ErrorLog.Notice(">>> The DM-TX-401-c has been registered successfully"); else ErrorLog.Error(">>> The DM-TX-401-C was not registered: {0}", dmTx.RegistrationFailureReason); // create new dmrmc100c object and subscribe to its events dmRmc = new DmRmcScalerC(0x04, this); // IPID for the dmtx is 4 dmRmc.DmInput.InputStreamChange += DmRmc_InputStreamChange; dmRmc.ComPorts[1].SerialDataReceived += DmRmc_SerialDataReceived; dmRmc.OnlineStatusChange += Device_OnlineStatusChange; dmRmc.Scaler.OutputChange += Scaler_OutputChange; // register device with the control system if (dmRmc.Register() == eDeviceRegistrationUnRegistrationResponse.Success) ErrorLog.Notice(">>> The DM-RMC-Scaler-C has been registered successfully"); else ErrorLog.Error(">>> The DM-RMC-Scaler-C was not registered: {0}", dmRmc.RegistrationFailureReason); // create a new xpanel room object and subscribe to its events xPanelUi = new XpanelForSmartGraphics(0x0b, this); xPanelUi.SigChange += xPanelUi_SigChange; xPanelUi.OnlineStatusChange += Device_OnlineStatusChange; // pathway to the SGD file for this ui project string xPanelSgdFilePath = string.Format("{0}\\Config.Standalone.sgd", Directory.GetApplicationDirectory()); // make sure file exists in the application directory if (File.Exists(xPanelSgdFilePath)) { // load the SGD file for this ui project xPanelUi.LoadSmartObjects(xPanelSgdFilePath); // create reference for the various smart objects in the ui project dmRmcOutputResList = xPanelUi.SmartObjects[(uint)eSmartObjectIds.DmRmcOutputResList]; dmRmcAspectModeList = xPanelUi.SmartObjects[(uint)eSmartObjectIds.DmRmcAspectList]; dmRmcUnderscanList = xPanelUi.SmartObjects[(uint)eSmartObjectIds.DmRmcUnderscanList]; // subscribe to the smart object sig events dmRmcOutputResList.SigChange += dmRmcOutputResList_SigChange; dmRmcAspectModeList.SigChange += dmRmcAspectModeList_SigChange; dmRmcUnderscanList.SigChange += dmRmcUnderscanList_SigChange; } else { ErrorLog.Error(">>> Could not find xpanel SGD file. SmartObjects will not work at this time"); } // register device with the control system if (xPanelUi.Register() == eDeviceRegistrationUnRegistrationResponse.Success) ErrorLog.Notice(">>> xPanel has been registered successfully"); else ErrorLog.Error(">>> xPanel was not registered: {0}", xPanelUi.RegistrationFailureReason); } else { ErrorLog.Error(">>> This processor does not support ethernet, so this program will not run"); } // create a new timer object to track system inactivity or unplugged cables ShutdownTimer = new CTimer(ShutownTimerCallback, Timeout.Infinite, Timeout.Infinite); }
/// <summary> /// Make a Crestron RMC and put it in here /// </summary> public DmRmcScalerCController(string key, string name, DmRmcScalerC rmc) : base(key, name, rmc) { _rmc = rmc; DmIn = new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.DmCat, 0, this); HdmiOut = new RoutingOutputPort(DmPortName.HdmiOut, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.Hdmi, null, this); EdidManufacturerFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Manufacturer.StringValue); EdidNameFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.Name.StringValue); EdidPreferredTimingFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.PreferredTiming.StringValue); EdidSerialNumberFeedback = new StringFeedback(() => _rmc.HdmiOutput.ConnectedDevice.SerialNumber.StringValue); VideoOutputResolutionFeedback = new StringFeedback(() => _rmc.HdmiOutput.GetVideoResolutionString()); _rmc.HdmiOutput.OutputStreamChange += HdmiOutput_OutputStreamChange; _rmc.HdmiOutput.ConnectedDevice.DeviceInformationChange += ConnectedDevice_DeviceInformationChange; InputPorts = new RoutingPortCollection <RoutingInputPort> { DmIn }; OutputPorts = new RoutingPortCollection <RoutingOutputPort> { HdmiOut }; // Set Ports for CEC HdmiOut.Port = _rmc.HdmiOutput; }
public override void InitializeSystem() { try { // Currently only runs on DMPS architecture if (this.SystemControl == null) { // Eventually we'll handle external switchers, too ErrorLog.Error("Sorry, this program only runs on DMPS3 processors!"); } else { var control = this.SystemControl as Dmps3SystemControl; control.SystemPowerOn(); // Samsung MDC = 9600 baud, 8 data bits, no parity, 1 stop bit var displayComSettings = new ComPort.ComPortSpec(); displayComSettings.Protocol = ComPort.eComProtocolType.ComspecProtocolRS232; displayComSettings.BaudRate = ComPort.eComBaudRates.ComspecBaudRate9600; displayComSettings.DataBits = ComPort.eComDataBits.ComspecDataBits8; displayComSettings.Parity = ComPort.eComParityType.ComspecParityNone; displayComSettings.StopBits = ComPort.eComStopBits.ComspecStopBits1; displayComSettings.HardwareHandShake = ComPort.eComHardwareHandshakeType.ComspecHardwareHandshakeNone; displayComSettings.SoftwareHandshake = ComPort.eComSoftwareHandshakeType.ComspecSoftwareHandshakeNone; // Assume DM transmitter is connected to DM input 6 _source[0] = this.SwitcherInputs[6] as DMInput; _tx1 = new DmTx200C2G(0x14, _source[0]); _tx1.HdmiInput.InputStreamChange += new EndpointInputStreamChangeEventHandler((input, args) => tx_InputStreamChange(0, input, args)); _tx1.VgaInput.InputStreamChange += new EndpointInputStreamChangeEventHandler((input, args) => tx_InputStreamChange(0, input, args)); // Assume DM transmitter is connected to DM input 7 _source[1] = this.SwitcherInputs[7] as DMInput; _tx2 = new DmTx200C2G(0x15, _source[1]); _tx2.HdmiInput.InputStreamChange += new EndpointInputStreamChangeEventHandler((input, args) => tx_InputStreamChange(1, input, args)); _tx2.VgaInput.InputStreamChange += new EndpointInputStreamChangeEventHandler((input, args) => tx_InputStreamChange(1, input, args)); // Assume DM roombox is connected to DM output 3 _rmc1 = new DmRmcScalerC(0x16, this.SwitcherOutputs[3] as DMOutput); _rmc1.ComPorts[1].SetComPortSpec(displayComSettings); } } catch (Exception e) { ErrorLog.Error("Error in InitializeSystem: {0}", e.StackTrace); } }