/// <summary> /// Builds and returns an instance of EssentialsPluginDeviceTemplate /// </summary> /// <param name="dc">device configuration</param> /// <returns>plugin device or null</returns> /// <remarks> /// The example provided below takes the device key, name, properties config and the comms device created. /// Modify the EssetnialsPlugingDeviceTemplate constructor as needed to meet the requirements of the plugin device. /// </remarks> /// <seealso cref="PepperDash.Core.eControlMethod"/> public override EssentialsDevice BuildDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc) { Debug.Console(1, "[{0}] Factory Attempting to create new device from type: {1}", dc.Key, dc.Type); // get the plugin device properties configuration object & check for null var propertiesConfig = dc.Properties.ToObject <EssentialsPluginConfigObjectTemplate>(); if (propertiesConfig == null) { Debug.Console(0, "[{0}] Factory: failed to read properties config for {1}", dc.Key, dc.Name); return(null); } // attempt build the plugin device comms device & check for null // TODO { ] As of PepperDash Core 1.0.41, HTTP and HTTPS are not valid eControlMethods and will throw an exception. var comms = CommFactory.CreateCommForDevice(dc); if (comms == null) { Debug.Console(1, "[{0}] Factory Notice: No control object present for device {1}", dc.Key, dc.Name); return(null); } else { return(new EssentialsPluginTemplateDevice(dc.Key, dc.Name, propertiesConfig, comms)); } }
/// <summary> /// Builds and returns an instance of EssentialsPluginTemplateCrestronDevice /// </summary> /// <param name="dc">device configuration</param> /// <returns>plugin device or null</returns> /// <remarks> /// The example provided below takes the device key, name, properties config and the comms device created. /// Modify the EssetnialsPlugingDeviceTemplate constructor as needed to meet the requirements of the plugin device. /// </remarks> /// <seealso cref="PepperDash.Core.eControlMethod"/> public override EssentialsDevice BuildDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc) { Debug.Console(1, "[{0}] Factory Attempting to create new device from type: {1}", dc.Key, dc.Type); // get the plugin device properties configuration object & check for null var propertiesConfig = dc.Properties.ToObject <EssentialsPluginConfigObjectTemplate>(); if (propertiesConfig == null) { Debug.Console(0, "[{0}] Factory: failed to read properties config for {1}", dc.Key, dc.Name); return(null); } var controlConfig = CommFactory.GetControlPropertiesConfig(dc); if (controlConfig == null) { var myTouchpanel = new Tsw760(controlConfig.IpIdInt, Global.ControlSystem); return(new EssentialsPluginTemplateCrestronDevice(dc.Key, dc.Name, propertiesConfig, myTouchpanel)); } else { Debug.Console(0, "[{0}] Factory: Unable to get control properties from device config for {1}", dc.Key, dc.Name); return(null); } }
/// <summary> /// Builds and returns an instance of MockOccupancyDetector /// </summary> /// <param name="dc">device configuration</param> /// <returns>plugin device or null</returns> /// <remarks> /// The example provided below takes the device key, name, properties config and the comms device created. /// Modify the EssetnialsPlugingDeviceTemplate constructor as needed to meet the requirements of the plugin device. /// </remarks> /// <seealso cref="PepperDash.Core.eControlMethod"/> public override EssentialsDevice BuildDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc) { Debug.Console(1, "[{0}] Factory Attempting to create new device from type: {1}", dc.Key, dc.Type); // get the plugin device properties configuration object & check for null var propertiesConfig = dc.Properties.ToObject <MockOccupancyDetectorPluginConfigObject>(); if (propertiesConfig == null) { Debug.Console(0, "[{0}] Factory: failed to read properties config for {1}", dc.Key, dc.Name); return(null); } // TODO [ ] Discuss with Andrew/Neil on recommended best practice // Method 1 //var username = dc.Properties["control"].Value<TcpSshPropertiesConfig>("tcpSshProperties").Username; //var password = dc.Properties["control"].Value<TcpSshPropertiesConfig>("tcpSshProperties").Password; //var method = dc.Properties["control"].Value<string>("method"); // Method 2 - Returns a JValue, has to be casted to string //var username = (string)dc.Properties["control"]["tcpSshProperties"]["username"]; //var password = (string)dc.Properties["control"]["tcpSshProperties"]["password"]; //var method = (string)dc.Properties["control"]["method"]; // build the plugin device comms & check for null // TODO { ] As of PepperDash Core 1.0.41, HTTP and HTTPS are not valid eControlMethods and will throw an exception. //var comms = CommFactory.CreateCommForDevice(dc); //if (comms == null) //{ // Debug.Console(0, "[{0}] Factory: failed to create comm for {1}", dc.Key, dc.Name); // return null; //} return(new MockOccupancyDetector(dc.Key, dc.Name, propertiesConfig));//, comms); }