/// <summary> /// Reads all devices from config and adds them to DeviceManager /// </summary> public void LoadDevices() { // Build the processor wrapper class DeviceManager.AddDevice(new PepperDash.Essentials.Core.Devices.CrestronProcessor("processor")); // Add global System Monitor device DeviceManager.AddDevice(new PepperDash.Essentials.Core.Monitoring.SystemMonitorController("systemMonitor")); foreach (var devConf in ConfigReader.ConfigObject.Devices) { try { Debug.Console(0, Debug.ErrorLogLevel.Notice, "Creating device '{0}', type '{1}'", devConf.Key, devConf.Type); // Skip this to prevent unnecessary warnings if (devConf.Key == "processor") { if (devConf.Type.ToLower() != Global.ControlSystem.ControllerPrompt.ToLower()) { Debug.Console(0, "WARNING: Config file defines processor type as '{0}' but actual processor is '{1}'! Some ports may not be available", devConf.Type.ToUpper(), Global.ControlSystem.ControllerPrompt.ToUpper()); } // Check if the processor is a DMPS model if (this.ControllerPrompt.IndexOf("dmps", StringComparison.OrdinalIgnoreCase) > -1) { Debug.Console(2, "Adding DmpsRoutingController for {0} to Device Manager.", this.ControllerPrompt); var propertiesConfig = JsonConvert.DeserializeObject <DM.Config.DmpsRoutingPropertiesConfig>(devConf.Properties.ToString()); if (propertiesConfig == null) { propertiesConfig = new DM.Config.DmpsRoutingPropertiesConfig(); } var dmpsRoutingController = DmpsRoutingController.GetDmpsRoutingController("processor-avRouting", this.ControllerPrompt, propertiesConfig); DeviceManager.AddDevice(dmpsRoutingController); } else if (this.ControllerPrompt.IndexOf("mpc3", StringComparison.OrdinalIgnoreCase) > -1) { Debug.Console(2, "MPC3 processor type detected. Adding Mpc3TouchpanelController."); var butToken = devConf.Properties["buttons"]; if (butToken != null) { var buttons = butToken.ToObject <Dictionary <string, Essentials.Core.Touchpanels.KeypadButton> >(); var tpController = new Essentials.Core.Touchpanels.Mpc3TouchpanelController(devConf.Key, devConf.Name, Global.ControlSystem, buttons); DeviceManager.AddDevice(tpController); } else { Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Unable to deserialize buttons collection for device: {0}", devConf.Key); } } else { Debug.Console(2, "************Processor is not DMPS type***************"); } continue; } // Try local factories first IKeyed newDev = null; if (newDev == null) { newDev = PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf); } // //if (newDev == null) // newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf); // if (newDev != null) { DeviceManager.AddDevice(newDev); } else { Debug.Console(0, Debug.ErrorLogLevel.Notice, "ERROR: Cannot load unknown device type '{0}', key '{1}'.", devConf.Type, devConf.Key); } } catch (Exception e) { Debug.Console(0, Debug.ErrorLogLevel.Notice, "ERROR: Creating device {0}. Skipping device. \r{1}", devConf.Key, e); } } Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Devices Loaded."); }
public static void LinkToApi(this DmpsRoutingController dmpsRouter, BasicTriList trilist, uint joinStart, string joinMapKey) { DmpsRoutingControllerJoinMap joinMap = new DmpsRoutingControllerJoinMap(); var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); if (!string.IsNullOrEmpty(joinMapSerialized)) { joinMap = JsonConvert.DeserializeObject <DmpsRoutingControllerJoinMap>(joinMapSerialized); } joinMap.OffsetJoinNumbers(joinStart); Debug.Console(1, dmpsRouter, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); // Link up outputs for (uint i = 1; i <= dmpsRouter.Dmps.NumberOfSwitcherInputs; i++) { Debug.Console(2, dmpsRouter, "Linking Input Card {0}", i); var ioSlot = i; //if (dmpsRouter.TxDictionary.ContainsKey(ioSlot)) //{ // Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot); // var TxKey = dmpsRouter.TxDictionary[ioSlot]; // var TxDevice = DeviceManager.GetDeviceForKey(TxKey) as DmTxControllerBase; // //TxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); // // TxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); // // trilist.SetUShortSigAction((ApiMap.HdcpSupport[ioSlot]), u => TxDevice.SetHdcpSupportAll((ePdtHdcpSupport)(u))); // // TxDevice.HdcpSupportAllFeedback.LinkInputSig(trilist.UShortInput[joinMap. + ioSlot]); // // trilist.UShortInput[ApiMap.HdcpSupportCapability[ioSlot]].UShortValue = TxDevice.HdcpSupportCapability; //} //else //{ // // dmChassis.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[ApiMap.TxVideoSyncStatus[ioSlot]]); //} if (dmpsRouter.VideoInputSyncFeedbacks[ioSlot] != null) { dmpsRouter.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]); } if (dmpsRouter.InputNameFeedbacks[ioSlot] != null) { dmpsRouter.InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames + ioSlot]); } trilist.SetStringSigAction(joinMap.InputNames + ioSlot, new Action <string>(s => { var inputCard = dmpsRouter.Dmps.SwitcherInputs[ioSlot] as DMInput; if (inputCard != null) { if (inputCard.NameFeedback != null && !string.IsNullOrEmpty(inputCard.NameFeedback.StringValue) && inputCard.NameFeedback.StringValue != s) { if (inputCard.Name != null) { inputCard.Name.StringValue = s; } } } })); if (dmpsRouter.InputEndpointOnlineFeedbacks[ioSlot] != null) { dmpsRouter.InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]); } } for (uint i = 1; i <= dmpsRouter.Dmps.NumberOfSwitcherOutputs; i++) { Debug.Console(2, dmpsRouter, "Linking Output Card {0}", i); var ioSlot = i; // Control trilist.SetUShortSigAction(joinMap.OutputVideo + ioSlot, new Action <ushort>(o => dmpsRouter.ExecuteSwitch(o, ioSlot, eRoutingSignalType.Video))); trilist.SetUShortSigAction(joinMap.OutputAudio + ioSlot, new Action <ushort>(o => dmpsRouter.ExecuteSwitch(o, ioSlot, eRoutingSignalType.Audio))); trilist.SetStringSigAction(joinMap.OutputNames + ioSlot, new Action <string>(s => { var outputCard = dmpsRouter.Dmps.SwitcherOutputs[ioSlot] as DMOutput; //Debug.Console(2, dmpsRouter, "Output Name String Sig Action for Output Card {0}", ioSlot); if (outputCard != null) { //Debug.Console(2, dmpsRouter, "Card Type: {0}", outputCard.CardInputOutputType); if (!(outputCard is Crestron.SimplSharpPro.DM.Cards.Card.Dmps3CodecOutput) && outputCard.NameFeedback != null) { if (!string.IsNullOrEmpty(outputCard.NameFeedback.StringValue)) { //Debug.Console(2, dmpsRouter, "NameFeedabck: {0}", outputCard.NameFeedback.StringValue); if (outputCard.NameFeedback.StringValue != s && outputCard.Name != null) { outputCard.Name.StringValue = s; } } } } })); // Feedback if (dmpsRouter.VideoOutputFeedbacks[ioSlot] != null) { dmpsRouter.VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo + ioSlot]); } if (dmpsRouter.AudioOutputFeedbacks[ioSlot] != null) { dmpsRouter.AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio + ioSlot]); } if (dmpsRouter.OutputNameFeedbacks[ioSlot] != null) { dmpsRouter.OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames + ioSlot]); } if (dmpsRouter.OutputVideoRouteNameFeedbacks[ioSlot] != null) { dmpsRouter.OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames + ioSlot]); } if (dmpsRouter.OutputAudioRouteNameFeedbacks[ioSlot] != null) { dmpsRouter.OutputAudioRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentAudioInputNames + ioSlot]); } if (dmpsRouter.OutputEndpointOnlineFeedbacks[ioSlot] != null) { dmpsRouter.OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]); } } }
/// <summary> /// Reads all devices from config and adds them to DeviceManager /// </summary> public void LoadDevices() { // Build the processor wrapper class DeviceManager.AddDevice(new PepperDash.Essentials.Core.Devices.CrestronProcessor("processor")); // Add global System Monitor device DeviceManager.AddDevice(new PepperDash.Essentials.Core.Monitoring.SystemMonitorController("systemMonitor")); foreach (var devConf in ConfigReader.ConfigObject.Devices) { try { Debug.Console(0, Debug.ErrorLogLevel.Notice, "Creating device '{0}', type '{1}'", devConf.Key, devConf.Type); // Skip this to prevent unnecessary warnings if (devConf.Key == "processor") { if (devConf.Type.ToLower() != Global.ControlSystem.ControllerPrompt.ToLower()) { Debug.Console(0, "WARNING: Config file defines processor type as '{0}' but actual processor is '{1}'! Some ports may not be available", devConf.Type.ToUpper(), Global.ControlSystem.ControllerPrompt.ToUpper()); } // Check if the processor is a DMPS model if (this.ControllerPrompt.IndexOf("dmps", StringComparison.OrdinalIgnoreCase) > -1) { Debug.Console(2, "Adding DmpsRoutingController for {0} to Device Manager.", this.ControllerPrompt); var propertiesConfig = JsonConvert.DeserializeObject <DM.Config.DmpsRoutingPropertiesConfig>(devConf.Properties.ToString()); if (propertiesConfig == null) { propertiesConfig = new DM.Config.DmpsRoutingPropertiesConfig(); } var dmpsRoutingController = DmpsRoutingController.GetDmpsRoutingController("processor-avRouting", this.ControllerPrompt, propertiesConfig); DeviceManager.AddDevice(dmpsRoutingController); } else { Debug.Console(2, "************Processor is not DMPS type***************"); } continue; } // Try local factories first var newDev = DeviceFactory.GetDevice(devConf); if (newDev == null) { newDev = BridgeFactory.GetDevice(devConf); } // Then associated library factories if (newDev == null) { newDev = PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf); } if (newDev == null) { newDev = PepperDash.Essentials.Devices.Common.DeviceFactory.GetDevice(devConf); } if (newDev == null) { newDev = PepperDash.Essentials.DM.DeviceFactory.GetDevice(devConf); } if (newDev == null) { newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf); } //if (newDev == null) // might want to consider the ability to override an essentials "type" //{ // // iterate plugin factories // foreach (var f in FactoryObjects) // { // var cresFactory = f as IGetCrestronDevice; // if (cresFactory != null) // { // newDev = cresFactory.GetDevice(devConf, this); // } // } //} if (newDev != null) { DeviceManager.AddDevice(newDev); } else { Debug.Console(0, Debug.ErrorLogLevel.Notice, "ERROR: Cannot load unknown device type '{0}', key '{1}'.", devConf.Type, devConf.Key); } } catch (Exception e) { Debug.Console(0, Debug.ErrorLogLevel.Notice, "ERROR: Creating device {0}. Skipping device. \r{1}", devConf.Key, e); } } Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Devices Loaded."); }