/// <summary> /// The factory method for Core "things". Also iterates the Factory methods that have /// been loaded from plugins /// </summary> /// <param name="dc"></param> /// <returns></returns> public static IKeyed GetDevice(DeviceConfig dc) { var key = dc.Key; var name = dc.Name; var type = dc.Type; var properties = dc.Properties; var typeName = dc.Type.ToLower(); // Check "core" types first if (typeName == "genericcomm") { Debug.Console(1, "Factory Attempting to create new Generic Comm Device"); return(new GenericComm(dc)); } else if (typeName == "ceniodigin104") { var control = CommFactory.GetControlPropertiesConfig(dc); var ipid = control.IpIdInt; return(new CenIoDigIn104Controller(key, name, new Crestron.SimplSharpPro.GeneralIO.CenIoDi104(ipid, Global.ControlSystem))); } // then check for types that have been added by plugin dlls. if (FactoryMethods.ContainsKey(typeName)) { Debug.Console(0, Debug.ErrorLogLevel.Notice, "Loading '{0}' from plugin", dc.Type); return(FactoryMethods[typeName](dc)); } return(null); }
public GenericComm(DeviceConfig config) : base(config) { PropertiesConfig = CommFactory.GetControlPropertiesConfig(config); CommPort = CommFactory.CreateCommForDevice(config); }
public override EssentialsDevice BuildDevice(DeviceConfig dc) { Debug.Console(1, "Factory Attempting to create new CEN-DIGIN-104 Device"); var control = CommFactory.GetControlPropertiesConfig(dc); var ipid = control.IpIdInt; return(new CenIoDigIn104Controller(dc.Key, dc.Name, new Crestron.SimplSharpPro.GeneralIO.CenIoDi104(ipid, Global.ControlSystem))); }
public override EssentialsDevice BuildDevice(DeviceConfig dc) { Debug.Console(1, "Factory Attempting to create new Comm Mock Device"); var comm = CommFactory.CreateCommForDevice(dc); var props = Newtonsoft.Json.JsonConvert.DeserializeObject <ConsoleCommMockDevicePropertiesConfig>( dc.Properties.ToString()); return(new ConsoleCommMockDevice(dc.Key, dc.Name, props, comm)); }
public GenericComm(DeviceConfig config) : base(config) { PropertiesConfig = CommFactory.GetControlPropertiesConfig(config); var commPort = CommFactory.CreateCommForDevice(config); //Fixing decision to require '-comPorts' in delcaration for DGE in order to get a device with comports included if (commPort == null) { config.Key = config.Key + "-comPorts"; commPort = CommFactory.CreateCommForDevice(config); } CommPort = commPort; }
protected override void CustomSetConfig(DeviceConfig config) { PropertiesConfig = CommFactory.GetControlPropertiesConfig(config); ConfigWriter.UpdateDeviceConfig(config); }