From d18f79ac48868b6743dc80f6b2fee51eb5064fc0 Mon Sep 17 00:00:00 2001 From: Neil Dorin Date: Wed, 5 Feb 2020 15:24:00 -0700 Subject: [PATCH] Removes complete Configuration ORIGINAL folder and all classes (obsolete) --- .../Builders/TPConfig.cs | 72 ----- .../Configuration Original/ConfigTieLine.cs | 82 ----- .../Configuration Original/Configuration.cs | 287 ------------------ .../ConfigurationHelpers.cs | 20 -- .../Factories/CommFactory.cs | 54 ---- .../Factories/DeviceMonitorFactory.cs | 38 --- .../Factories/DisplayFactory.cs | 122 -------- .../Factories/DmFactory.cs | 101 ------ .../Factories/FactoryHelper.cs | 124 -------- .../Factories/PcFactory.cs | 34 --- .../Factories/RemoteFactory.cs | 127 -------- .../Factories/TouchpanelFactory.cs | 48 --- .../PepperDashEssentials.csproj | 12 - 13 files changed, 1121 deletions(-) delete mode 100644 PepperDashEssentials/Configuration Original/Builders/TPConfig.cs delete mode 100644 PepperDashEssentials/Configuration Original/ConfigTieLine.cs delete mode 100644 PepperDashEssentials/Configuration Original/Configuration.cs delete mode 100644 PepperDashEssentials/Configuration Original/ConfigurationHelpers.cs delete mode 100644 PepperDashEssentials/Configuration Original/Factories/CommFactory.cs delete mode 100644 PepperDashEssentials/Configuration Original/Factories/DeviceMonitorFactory.cs delete mode 100644 PepperDashEssentials/Configuration Original/Factories/DisplayFactory.cs delete mode 100644 PepperDashEssentials/Configuration Original/Factories/DmFactory.cs delete mode 100644 PepperDashEssentials/Configuration Original/Factories/FactoryHelper.cs delete mode 100644 PepperDashEssentials/Configuration Original/Factories/PcFactory.cs delete mode 100644 PepperDashEssentials/Configuration Original/Factories/RemoteFactory.cs delete mode 100644 PepperDashEssentials/Configuration Original/Factories/TouchpanelFactory.cs diff --git a/PepperDashEssentials/Configuration Original/Builders/TPConfig.cs b/PepperDashEssentials/Configuration Original/Builders/TPConfig.cs deleted file mode 100644 index 94edaf14..00000000 --- a/PepperDashEssentials/Configuration Original/Builders/TPConfig.cs +++ /dev/null @@ -1,72 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; - -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Config; - -namespace PepperDash.Essentials -{ - - //public class TPConfig : DeviceConfig - //{ - // new public TPConfigProperties Properties { get; set; } - //} - - //public class TPConfigProperties - //{ - // /* - // "properties": { - // "ipId": "aa", - // "defaultSystemKey": "system1", - // "sgdPath": "\\NVRAM\\Program1\\Sgds\\PepperDash Essentials TSW1050_v0.9.sgd", - // "usesSplashPage": true, - // "showDate": true, - // "showTime": false - // } - // */ - // public uint IpId { get; set; } - // public string deafultSystemKey { get; set; } - // public string SgdPath { get; set; } - // public bool UsesSplashPage { get; set; } - // public bool ShowDate { get; set; } - // public bool ShowTime { get; set; } - - //} - - - - - ///// - ///// The gist of this converter: The comspec JSON comes in with normal values that need to be converted - ///// into enum names. This converter takes the value and applies the appropriate enum's name prefix to the value - ///// and then returns the enum value using Enum.Parse - ///// - //public class TPPropertiesConverter : JsonConverter - //{ - // public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - // { - // return JObject.Load(reader); - // } - - // /// - // /// This will be hit with every value in the ComPortConfig class. We only need to - // /// do custom conversion on the comspec items. - // /// - // public override bool CanConvert(Type objectType) - // { - // return true; - // } - - // public override bool CanRead { get { return true; } } - // public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - // { - // throw new NotImplementedException(); - // } - //} -} \ No newline at end of file diff --git a/PepperDashEssentials/Configuration Original/ConfigTieLine.cs b/PepperDashEssentials/Configuration Original/ConfigTieLine.cs deleted file mode 100644 index fabdd409..00000000 --- a/PepperDashEssentials/Configuration Original/ConfigTieLine.cs +++ /dev/null @@ -1,82 +0,0 @@ -using System.Linq; -using Newtonsoft.Json; - -using PepperDash.Essentials.Core; -using PepperDash.Core; - -namespace PepperDash.Essentials -{ - public class ConfigTieLine - { - [JsonProperty(Required=Required.Always)] - public string SourceDeviceKey { get; set; } - - [JsonProperty(Required = Required.Always)] - public string SourcePortKey { get; set; } - - [JsonProperty(Required = Required.Always)] - public string DestinationDeviceKey { get; set; } - - [JsonProperty(Required = Required.Always)] - public string DestinationPortKey { get; set; } - - public override string ToString() - { - return string.Format("Tie line: [{0}]{1} --> [{2}]{3}", SourceDeviceKey, SourcePortKey, DestinationDeviceKey, DestinationPortKey); - } - - /// - /// Returns a tie line if one can be constructed between the two devices and ports - /// - /// TieLine or null if devices or ports don't exist - public TieLine GetTieLine() - { - var sourceDevice = (IRoutingOutputs)DeviceManager.GetDeviceForKey(SourceDeviceKey); - var destinationDevice = (IRoutingInputs)DeviceManager.GetDeviceForKey(DestinationDeviceKey); - - if (sourceDevice == null) - { - Debug.Console(0, " Cannot create TieLine. Source device '{0}' not found or does not have outputs", - SourceDeviceKey); - return null; - } - else if (destinationDevice == null) - { - Debug.Console(0, " Cannot create TieLine. Destination device '{0}' not found or does not have inputs", - DestinationDeviceKey); - return null; - } - else - { - // Get the ports by key name from the lists - RoutingOutputPort sourcePort = sourceDevice.OutputPorts.FirstOrDefault( - p => p.Key.Equals(SourcePortKey, System.StringComparison.OrdinalIgnoreCase)); - //RoutingOutputPort sourcePort = null; - //sourceDevice.OutputPorts.TryGetValue(SourcePortKey, out sourcePort); - if (sourcePort == null) - { - Debug.Console(0, " Cannot create TieLine {0}-->{1}. Source device does not have output port '{2}'", - sourceDevice.Key, destinationDevice.Key, SourcePortKey); - return null; - } - - RoutingInputPort destinationPort = destinationDevice.InputPorts.FirstOrDefault( - p => p.Key.Equals(DestinationPortKey, System.StringComparison.OrdinalIgnoreCase)); - //RoutingInputPort destinationPort = null; - //destinationDevice.InputPorts.TryGetValue(DestinationPortKey, out destinationPort); - if (destinationPort == null) - { - Debug.Console(0, " Cannot create TieLine {0}-->{1}. Destination device does not have input port '{2}'", - sourceDevice.Key, destinationDevice.Key, DestinationPortKey); - return null; - } - - var tl = new TieLine(sourcePort, destinationPort); - Debug.Console(1, " Created {0}", this); - return tl; - } - } - - } - -} \ No newline at end of file diff --git a/PepperDashEssentials/Configuration Original/Configuration.cs b/PepperDashEssentials/Configuration Original/Configuration.cs deleted file mode 100644 index 30350e79..00000000 --- a/PepperDashEssentials/Configuration Original/Configuration.cs +++ /dev/null @@ -1,287 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Crestron.SimplSharp; -using Crestron.SimplSharp.CrestronIO; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro.CrestronThread; -using Crestron.SimplSharpPro.Diagnostics; -using Crestron.SimplSharpPro.EthernetCommunication; -using Crestron.SimplSharpPro.UI; - -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Devices; -//using PepperDash.Essentials.Core.Devices.Dm; -//using PepperDash.Essentials.Fusion; -using PepperDash.Core; - -namespace PepperDash.Essentials -{ - public static class Configuration - { - - public static string LastPath { get; private set; } - public static CrestronControlSystem ControlSystem { get; private set; } - - public static void Initialize(CrestronControlSystem cs) - { - CrestronConsole.AddNewConsoleCommand(ReloadFromConsole, "configreload", "Reloads configuration file", - ConsoleAccessLevelEnum.AccessOperator); - ControlSystem = cs; - } - - public static bool ReadConfiguration(string filePath) - { - try - { - // Read file - if (File.Exists(filePath)) - { - LastPath = filePath; - string json = File.ReadToEnd(filePath, System.Text.Encoding.ASCII); - JObject jo = JObject.Parse(json); - - var info = JsonConvert.DeserializeObject(jo["info"].ToString()); - Debug.Console(0, "\r[Config] file read:"); - Debug.Console(0, " File: {0}", filePath); - Debug.Console(0, " Name: {0}", info.Name); - Debug.Console(0, " Type: {0}", info.SystemTemplateType); - Debug.Console(0, " Date: {0}", info.EditDate); - Debug.Console(0, " ConfigVersion: {0}", info.Version); - Debug.Console(0, " EditedBy: {0}", info.EditedBy); - Debug.Console(0, " Comment: {0}\r", info.Comment); - - // Get the main config object - var jConfig = jo["configuration"]; - - // Devices - var jDevices = (JArray)jConfig["devices"]; - CreateDevices(jDevices); - - // TieLines - var jRouting = jConfig["routing"]; - CreateRouting(jRouting); - - /// Parse the available source list(s) - var jSourceLists = (JArray)jConfig["sourceLists"]; - var jSourceListJson = jSourceLists.ToString(); - List sourceLists = JsonConvert.DeserializeObject>(jSourceListJson); - - // System - var jSystems = (JArray)jConfig["systems"]; - CreateSystems(jSystems, sourceLists); - - // Activate everything - DeviceManager.ActivateAll(); - } - else - { - Debug.Console(0, "[Config] file not found '{0}'", filePath); - return false; - } - } - catch (Exception e) - { - Debug.Console(0, "Configuration read error: \r {0}", e); - return false; - } - - return true; - } - - static void CreateDevices(JArray jDevices) - { - //Debug.Console(0, " Creating {0} devices", jDevices.Count); - //for (int i = 0; i < jDevices.Count; i++) - //{ - // var jDev = jDevices[i]; - - // //var devConfig = JsonConvert.DeserializeObject(jDev.ToString()); - // //Debug.Console(0, "++++++++++++{0}", devConfig); - - - // var group = jDev["group"].Value(); - // Debug.Console(0, " [{0}], creating {1}:{2}", jDev["key"].Value(), - // group, jDev["type"].Value()); - - // Device dev = null; - // if (group.Equals("Display", StringComparison.OrdinalIgnoreCase)) - // dev = DisplayFactory.CreateDisplay(jDev); - // else if (group.Equals("DeviceMonitor", StringComparison.OrdinalIgnoreCase)) - // dev = DeviceManagerFactory.Create(jDev); - // //else if (group.Equals("Pc", StringComparison.OrdinalIgnoreCase)) - // // dev = PcFactory.Create(jDev); - // //else if (group.Equals("SetTopBox", StringComparison.OrdinalIgnoreCase)) - // // dev = SetTopBoxFactory.Create(jDev); - // //else if (group.Equals("DiscPlayer", StringComparison.OrdinalIgnoreCase)) - // // dev = DiscPlayerFactory.Create(jDev); - // //else if (group.Equals("Touchpanel", StringComparison.OrdinalIgnoreCase)) - // // dev = TouchpanelFactory.Create(jDev); - // else if (group.Equals("dmEndpoint", StringComparison.OrdinalIgnoreCase)) // Add Transmitter and Receiver - // dev = DmFactory.Create(jDev); - // else if (group.Equals("dmChassic", StringComparison.OrdinalIgnoreCase)) - // dev = DmFactory.CreateChassis(jDev); - // else if (group.Equals("processor", StringComparison.OrdinalIgnoreCase)) - // continue; // ignore it. Has no value right now. - // //else if (group.Equals("remote", StringComparison.OrdinalIgnoreCase)) - // // dev = RemoteFactory.Create(jDev); - // else - // { - // Debug.Console(0, " ERROR: Device [{0}] has unknown Group '{1}'. Skipping", - // jDev["key"].Value(), group); - // continue; - // } - - // if (dev != null) - // DeviceManager.AddDevice(dev); - // else - // Debug.Console(0, " ERROR: failed to create device {0}", - // jDev["key"].Value()); - //} - } - - static void CreateSystems(JArray jSystems, List sourceLists) - { -// // assuming one system -// var jSystem = jSystems[0]; -// var name = jSystem.Value("name"); -// var key = FactoryHelper.KeyOrConvertName(jSystem.Value("key"), name); - -// if (jSystem.Value("type").Equals("EssentialsHuddleSpace", StringComparison.OrdinalIgnoreCase)) -// { -// var sys = new HuddleSpaceRoom(key, name); -// var props = jSystem["properties"]; -// var displayKey = props["displayKey"].Value(); -// if (displayKey != null) -// sys.DefaultDisplay = (DisplayBase)DeviceManager.GetDeviceForKey(displayKey); - -// // Add sources from passed in config list -// var myList = sourceLists.FirstOrDefault( -// l => l.Key.Equals(props.Value("sourceListKey"), StringComparison.OrdinalIgnoreCase)); -// if (myList != null) -// AddSourcesToSystem(sys, myList); - -// DeviceManager.AddDevice(sys); - -// //spin up a fusion thing too -//#warning add this fusion connector back in later -// //DeviceManager.AddDevice(new EssentialsHuddleSpaceFusionSystemController(sys, 0xf1)); - //} - } - - //static void AddSourcesToSystem(Room system, ConfigSourceList configList) - //{ - //foreach (var configItem in configList.PresentationSources) - //{ - // var src = (IPresentationSource)DeviceManager.GetDeviceForKey(configItem.SourceKey); - // if (src != null) - // system.Sources.Add(configItem.Number, src); - // else - // Debug.Console(0, system, "cannot find source '{0}' from list {1}", - // configItem.SourceKey, configList.Name); - //} - //} - - /// - /// Links up routing, creates tie lines - /// - /// The "Routing" JArray from configuration - static void CreateRouting(JToken jRouting) - { - var jsonTieLines = jRouting["tieLines"].ToString(); - var tieLineConfigs = JsonConvert.DeserializeObject>(jsonTieLines); - foreach (var c in tieLineConfigs) - { - var tl = c.GetTieLine(); - if (tl != null) - TieLineCollection.Default.Add(tl); - } - } - - - /// - /// Returns the IIROutputPorts device (control system, etc) that contains a given IR port - /// - /// - static IROutputPort GetIrPort(JToken propsToken) - { - var portDevName = propsToken.Value("IrPortDevice"); - var portNum = propsToken.Value("IrPortNumber"); - if (portDevName.Equals("controlSystem", StringComparison.OrdinalIgnoreCase)) - { - IIROutputPorts irDev = ControlSystem; - if (portNum <= irDev.NumberOfIROutputPorts) - return ControlSystem.IROutputPorts[portNum]; - else - Debug.Console(0, "[Config] ERROR: IR Port {0} out of range. Range 0-{1} on {2}", portNum, - ControlSystem.IROutputPorts.Count, irDev.ToString()); - } - return null; - } - - static void HandleUnknownType(JToken devToken, string type) - { - Debug.Console(0, "[Config] ERROR: Type '{0}' not found in group '{1}'", type, - devToken.Value("Group")); - } - - static void HandleDeviceCreationError(JToken devToken, Exception e) - { - Debug.Console(0, "[Config] ERROR creating device [{0}]: \r{1}", - devToken["Key"].Value(), e); - } - - /// - /// Console helper to reload - /// - static void ReloadFromConsole(string s) - { - // Gotta tear down everything first! - - if (!string.IsNullOrEmpty(LastPath)) - { - ReadConfiguration(LastPath); - } - } - } - - public class ConfigSourceList - { - [JsonProperty(Required = Required.Always)] - public string Key { get; set; } - - [JsonProperty(Required = Required.Always)] - public string Name { get; set; } - - [JsonProperty(Required = Required.Always)] - public List PresentationSources { get; set; } - - } - - public class ConfigSourceItem - { - [JsonProperty(Required = Required.Always)] - public uint Number { get; set; } - - [JsonProperty(Required = Required.Always)] - public string SourceKey { get; set; } - - public string AlternateName { get; set; } - } - - public class ConfigInfo - { - public string SystemTemplateType { get; set; } - public string ProcessorType { get; set; } - public string Name { get; set; } - public uint ProgramSlotNumber { get; set; } - public string Version { get; set; } - public string EditedBy { get; set; } - public string EditDate { get; set; } - public string Comment { get; set; } - } -} \ No newline at end of file diff --git a/PepperDashEssentials/Configuration Original/ConfigurationHelpers.cs b/PepperDashEssentials/Configuration Original/ConfigurationHelpers.cs deleted file mode 100644 index c5dd4c65..00000000 --- a/PepperDashEssentials/Configuration Original/ConfigurationHelpers.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Newtonsoft.Json; - -namespace PepperDash.Essentials -{ - public class SourceListConfigProperties - { - [JsonProperty(Required= Required.Always)] - public uint Number { get; set; } - [JsonProperty(Required= Required.Always)] - public string SourceKey { get; set; } - public string AltName { get; set; } - public string AltIcon { get; set; } - - public SourceListConfigProperties() - { - AltName = ""; - AltIcon = ""; - } - } -} \ No newline at end of file diff --git a/PepperDashEssentials/Configuration Original/Factories/CommFactory.cs b/PepperDashEssentials/Configuration Original/Factories/CommFactory.cs deleted file mode 100644 index a1b23a4e..00000000 --- a/PepperDashEssentials/Configuration Original/Factories/CommFactory.cs +++ /dev/null @@ -1,54 +0,0 @@ -//using System; -//using Crestron.SimplSharpPro; - -//using Newtonsoft.Json; -//using Newtonsoft.Json.Linq; - -//using PepperDash.Essentials.Core; -//using PepperDash.Essentials.Devices; -//using PepperDash.Core; - -//namespace PepperDash.Essentials -//{ -// public class CommFactory -// { -// public static IBasicCommunication CreateCommForDevice(JToken devToken) -// { -// var devKey = devToken.Value("key"); -// IBasicCommunication comm = null; -// try -// { -// var control = devToken["properties"]["control"]; -// var commMethod = control["method"].Value(); -// if (commMethod == "com") -// { -// var comConfig = JsonConvert.DeserializeObject( -// control["comParams"].ToString(), -// new JsonSerializerSettings -// { -// // Needs ObjectCreationHandling to make the ComSpec struct populate -// ObjectCreationHandling = ObjectCreationHandling.Replace, -// Converters = new JsonConverter[] { new ComSpecJsonConverter() } -// }); -// comm = new ComPortController(devKey + "-com", comConfig.GetComPort(), comConfig.ComSpec); -// } -// else if (commMethod == "tcpIp") -// { -// var tcpConfig = JsonConvert.DeserializeObject(control["tcpParams"].ToString()); -// comm = new GenericTcpIpClient(devKey + "-tcp", tcpConfig.Address, tcpConfig.Port, tcpConfig.BufferSize); -// } -// } -// catch (Exception e) -// { -// Debug.Console(0, "Cannot create communication from JSON:\r{0}\r\rException:\r{1}", devToken.ToString(), e); -// } - -// // put it in the device manager if it's the right flavor -// var comDev = comm as Device; -// if (comDev != null) -// DeviceManager.AddDevice(comDev); - -// return comm; -// } -// } -//} \ No newline at end of file diff --git a/PepperDashEssentials/Configuration Original/Factories/DeviceMonitorFactory.cs b/PepperDashEssentials/Configuration Original/Factories/DeviceMonitorFactory.cs deleted file mode 100644 index fca42458..00000000 --- a/PepperDashEssentials/Configuration Original/Factories/DeviceMonitorFactory.cs +++ /dev/null @@ -1,38 +0,0 @@ -//using System; -//using Crestron.SimplSharpPro; - -//using Newtonsoft.Json.Linq; - -//using PepperDash.Essentials.Core; -//using PepperDash.Essentials.Core.Devices; -//using PepperDash.Core; - -//namespace PepperDash.Essentials -//{ -// public class DeviceManagerFactory -// { -// public static Device Create(JToken devToken) -// { -// Device dev = null; -// try -// { -// var devType = devToken.Value("type"); -// var devKey = devToken.Value("key"); -// var devName = devToken.Value("name"); -// if (devType.Equals("DeviceMonitor", StringComparison.OrdinalIgnoreCase)) -// { -// var comm = CommFactory.CreateCommForDevice(devToken); -// if (comm == null) return null; -// dev = new GenericCommunicationMonitoredDevice(devKey, devName, comm, devToken["properties"]["pollString"].Value()); -// } -// else -// FactoryHelper.HandleUnknownType(devToken, devType); -// } -// catch (Exception e) -// { -// FactoryHelper.HandleDeviceCreationError(devToken, e); -// } -// return dev; -// } -// } -//} \ No newline at end of file diff --git a/PepperDashEssentials/Configuration Original/Factories/DisplayFactory.cs b/PepperDashEssentials/Configuration Original/Factories/DisplayFactory.cs deleted file mode 100644 index 4b226662..00000000 --- a/PepperDashEssentials/Configuration Original/Factories/DisplayFactory.cs +++ /dev/null @@ -1,122 +0,0 @@ -//using System; -//using System.Collections.Generic; -//using System.Linq; -//using System.Text; -//using Crestron.SimplSharp; - -//using Newtonsoft.Json; -//using Newtonsoft.Json.Linq; - -//using PepperDash.Essentials.Core; -//using PepperDash.Essentials.Devices; -//using PepperDash.Essentials.Displays; -//using PepperDash.Core; - -//namespace PepperDash.Essentials -//{ -// public class DisplayFactory -// { -// public static DisplayBase CreateDisplay(JToken devToken) -// { -// DisplayBase dev = null; -// try -// { -// var devType = devToken.Value("type"); -// var devKey = devToken.Value("key"); -// var devName = devToken.Value("name"); -// var properties = devToken["properties"]; - -// if (devType.Equals("MockDisplay", StringComparison.OrdinalIgnoreCase)) -// dev = new MockDisplay(devKey, devName); - -// else if (devType.Equals("NecMPSX", StringComparison.OrdinalIgnoreCase)) -// { -// var comm = CommFactory.CreateCommForDevice(devToken); -// if (comm == null) return null; -// dev = new NecPSXMDisplayCom(devKey, devName, comm); - - - -// //var commMethod = properties["control"]["method"].Value(); - -// //// Helper-ize this? -// //if(commMethod == "com") -// //{ -// // // Move some of this up above??? -// // var comConfig = JsonConvert.DeserializeObject( -// // properties["control"]["comParams"].ToString(), -// // new JsonSerializerSettings { -// // // Needs ObjectCreationHandling to make the ComSpec struct populate -// // ObjectCreationHandling = ObjectCreationHandling.Replace, -// // Converters = new JsonConverter[] { new ComSpecJsonConverter() } -// // }); -// // dev = new NecPSXMDisplayCom(devKey, devName, comConfig.GetComPort(), comConfig.ComSpec); -// //} -// //else if (commMethod == "tcpIp") -// //{ -// // var spec = properties["control"]["tcpSpec"]; -// // var host = spec["address"].Value(); -// // var port = spec["port"].Value(); -// // dev = new NecPSXMDisplayCom(devKey, devName, host, port); -// //} - - - -// } - -// else if (devType.Equals("NecNpPa550", StringComparison.OrdinalIgnoreCase)) -// { -// var proj = new NecPaSeriesProjector(devKey, devName); -// var comm = CreateCommunicationFromPropertiesToken( -// devKey + "-comm", properties, 3000); -// proj.CommunicationMethod = comm; -// dev = proj; -// } -// else -// FactoryHelper.HandleUnknownType(devToken, devType); -// } -// catch (Exception e) -// { -// FactoryHelper.HandleDeviceCreationError(devToken, e); -// } -// return dev; -// } - -// public static IBasicCommunication CreateCommunicationFromPropertiesToken( -// string commKey, JToken properties, int bufferSize) -// { -// Debug.Console(2, "Building port from: {0}", properties.ToString()); - -// var tcpToken = properties["TcpIp"]; -// if (tcpToken != null) -// { -// // Convert the Tcp property -// var spec = JsonConvert.DeserializeObject(tcpToken.ToString()); - -// var tcp = new GenericTcpIpClient(commKey, spec.Address, spec.Port, bufferSize); -// DeviceManager.AddDevice(tcp); -// return tcp; -// } - -// var com = properties["Com"]; -// if (com != null) -// { -// // Make the interim config object -// var comConfig = JsonConvert.DeserializeObject(com.ToString(), -// new JsonSerializerSettings { ObjectCreationHandling = ObjectCreationHandling.Replace }); - -// // Get the IComPorts hardware device from the Device or Control System -// var comDev = comConfig.GetIComPortsDeviceFromManagedDevice(); -// if (comDev != null) -// { -// var controller = new ComPortController(commKey, comDev.ComPorts[comConfig.ComPortNumber], comConfig.ComSpec); -// DeviceManager.AddDevice(controller); -// return controller; -// } -// } -// Debug.Console(0, "No Tcp or Com port information for port {0}", commKey); -// return null; -// } - -// } -//} \ No newline at end of file diff --git a/PepperDashEssentials/Configuration Original/Factories/DmFactory.cs b/PepperDashEssentials/Configuration Original/Factories/DmFactory.cs deleted file mode 100644 index ef2d1a03..00000000 --- a/PepperDashEssentials/Configuration Original/Factories/DmFactory.cs +++ /dev/null @@ -1,101 +0,0 @@ -using System; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DM; -using Crestron.SimplSharpPro.DM.Endpoints.Receivers; -using Crestron.SimplSharpPro.DM.Endpoints.Transmitters; - -using Newtonsoft.Json.Linq; - -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Devices; -//using PepperDash.Essentials.Devices.Dm; -using PepperDash.Core; - -namespace PepperDash.Essentials -{ - public class DmFactory - { - public static Device Create(JToken devToken) - { - Device dev = null; - try - { - var devType = devToken.Value("type"); - var devKey = devToken.Value("key"); - var devName = devToken.Value("name"); - // Catch all 200 series TX - var devprops = devToken["properties"]; - var ipId = Convert.ToUInt32(devprops.Value("ipId"), 16); - var parent = devprops.Value("parent"); - if (parent == null) - parent = "controlSystem"; - - if (devType.StartsWith("DmTx2", StringComparison.OrdinalIgnoreCase)) - { - DmTx201C tx; - if (parent.Equals("controlSystem", StringComparison.OrdinalIgnoreCase)) - { - tx = new DmTx201C(ipId, Global.ControlSystem); - //dev = new DmTx201SBasicController(devKey, devName, tx); - } - - } - else if (devType.StartsWith("DmRmc", StringComparison.OrdinalIgnoreCase)) - { - DmRmc100C rmc; - if (parent.Equals("controlSystem", StringComparison.OrdinalIgnoreCase)) - { - rmc = new DmRmc100C(ipId, Global.ControlSystem); - //dev = new DmRmcBaseController(devKey, devName, rmc); - } - } - else - FactoryHelper.HandleUnknownType(devToken, devType); - } - catch (Exception e) - { - FactoryHelper.HandleDeviceCreationError(devToken, e); - } - return dev; - } - - - public static Device CreateChassis(JToken devToken) - { - Device dev = null; - try - { - var devType = devToken.Value("type"); - var devKey = devToken.Value("key"); - var devName = devToken.Value("name"); - // Catch all 200 series TX - var devprops = devToken["properties"]; - var ipId = Convert.ToUInt32(devprops.Value("ipId"), 16); - var parent = devprops.Value("parent"); - if (parent == null) - parent = "controlSystem"; - - if (devType.Equals("dmmd8x8", StringComparison.OrdinalIgnoreCase)) - { - var dm = new DmMd8x8(ipId, Global.ControlSystem); - //dev = new DmChassisController(devKey, devName, dm); - } - else if (devType.Equals("dmmd16x16", StringComparison.OrdinalIgnoreCase)) - { - var dm = new DmMd16x16(ipId, Global.ControlSystem); - //dev = new DmChassisController(devKey, devName, dm); - } - else if (devType.Equals("dmmd32x32", StringComparison.OrdinalIgnoreCase)) - { - var dm = new DmMd32x32(ipId, Global.ControlSystem); - //dev = new DmChassisController(devKey, devName, dm); - } - } - catch (Exception e) - { - FactoryHelper.HandleDeviceCreationError(devToken, e); - } - return dev; - } - } -} \ No newline at end of file diff --git a/PepperDashEssentials/Configuration Original/Factories/FactoryHelper.cs b/PepperDashEssentials/Configuration Original/Factories/FactoryHelper.cs deleted file mode 100644 index 4f12b92f..00000000 --- a/PepperDashEssentials/Configuration Original/Factories/FactoryHelper.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; - -using Newtonsoft.Json; -using Newtonsoft.Json.Converters; -using Newtonsoft.Json.Linq; - -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Devices; -using PepperDash.Core; - -namespace PepperDash.Essentials -{ - public static class FactoryHelper - { - public static string IrDriverPathPrefix = Global.FilePathPrefix + "IR" + Global.DirectorySeparator; - - public static void HandleUnknownType(JToken devToken, string type) - { - Debug.Console(0, "[Config] ERROR: Type '{0}' not found in group '{1}'", type, - devToken.Value("group")); - } - - public static void HandleDeviceCreationError(JToken devToken, Exception e) - { - Debug.Console(0, "[Config] ERROR creating device [{0}]: \r{1}", - devToken["key"].Value(), e); - Debug.Console(0, "Relevant config:\r{0}", devToken.ToString(Newtonsoft.Json.Formatting.Indented)); - } - - /// - /// Finds either the ControlSystem or a device controller that contains IR ports and - /// returns a port from the hardware device - /// - /// - /// Crestron IrPort or null if device doesn't have IR or is not found - public static IrOutPortConfig GetIrPort(JToken propsToken) - { - var irSpec = propsToken["control"]["irSpec"]; - var portDevKey = irSpec.Value("portDeviceKey"); - var portNum = irSpec.Value("portNumber"); - IIROutputPorts irDev = null; - if (portDevKey.Equals("controlSystem", StringComparison.OrdinalIgnoreCase) - || portDevKey.Equals("processor", StringComparison.OrdinalIgnoreCase)) - irDev = Global.ControlSystem; - else - irDev = DeviceManager.GetDeviceForKey(portDevKey) as IIROutputPorts; - - if (irDev == null) - { - Debug.Console(0, "[Config] Error, device with IR ports '{0}' not found", portDevKey); - return null; - } - - if (portNum <= irDev.NumberOfIROutputPorts) // success! - { - var file = IrDriverPathPrefix + irSpec["file"].Value(); - return new IrOutPortConfig { Port = irDev.IROutputPorts[portNum], FileName = file }; - } - else - { - Debug.Console(0, "[Config] Error, device '{0}' IR port {1} out of range", - portDevKey, portNum); - return null; - } - } - - - /// - /// Finds either the ControlSystem or a device controller that contains com ports and - /// returns a port from the hardware device - /// - /// The Properties token from the device's config - /// Crestron ComPort or null if device doesn't have IR or is not found - public static ComPort GetComPort(JToken propsToken) - { - var portDevKey = propsToken.Value("comPortDevice"); - var portNum = propsToken.Value("comPortNumber"); - IComPorts comDev = null; - if (portDevKey.Equals("controlSystem", StringComparison.OrdinalIgnoreCase)) - comDev = Global.ControlSystem; - else - comDev = DeviceManager.GetDeviceForKey(portDevKey) as IComPorts; - - if (comDev == null) - { - Debug.Console(0, "[Config] Error, device with com ports '{0}' not found", portDevKey); - return null; - } - - if (portNum <= comDev.NumberOfComPorts) // success! - return comDev.ComPorts[portNum]; - else - { - Debug.Console(0, "[Config] Error, device '{0}' com port {1} out of range", - portDevKey, portNum); - return null; - } - } - - /// - /// Returns the key if it exists or converts the name into a key - /// - public static string KeyOrConvertName(string key, string name) - { - if (string.IsNullOrEmpty(key)) - return name.Replace(' ', '-'); - return key; - } - } - - /// - /// Wrapper to help in IR port creation - /// - public class IrOutPortConfig - { - public IROutputPort Port { get; set; } - public string FileName { get; set; } - } -} \ No newline at end of file diff --git a/PepperDashEssentials/Configuration Original/Factories/PcFactory.cs b/PepperDashEssentials/Configuration Original/Factories/PcFactory.cs deleted file mode 100644 index c8413321..00000000 --- a/PepperDashEssentials/Configuration Original/Factories/PcFactory.cs +++ /dev/null @@ -1,34 +0,0 @@ -//using System; -//using Crestron.SimplSharpPro; - -//using Newtonsoft.Json.Linq; - -//using PepperDash.Essentials.Core; -//using PepperDash.Essentials.Devices; -//using PepperDash.Core; - -//namespace PepperDash.Essentials -//{ -// public class PcFactory -// { -// public static Device Create(JToken devToken) -// { -// Device dev = null; -// //try -// //{ -// // var devType = devToken.Value("type"); -// // var devKey = devToken.Value("key"); -// // var devName = devToken.Value("name"); -// // if (devType.Equals("laptop", StringComparison.OrdinalIgnoreCase)) -// // dev = new Laptop(devKey, devName); -// // else -// // FactoryHelper.HandleUnknownType(devToken, devType); -// //} -// //catch (Exception e) -// //{ -// // FactoryHelper.HandleDeviceCreationError(devToken, e); -// //} -// return dev; -// } -// } -//} \ No newline at end of file diff --git a/PepperDashEssentials/Configuration Original/Factories/RemoteFactory.cs b/PepperDashEssentials/Configuration Original/Factories/RemoteFactory.cs deleted file mode 100644 index c28d1da7..00000000 --- a/PepperDashEssentials/Configuration Original/Factories/RemoteFactory.cs +++ /dev/null @@ -1,127 +0,0 @@ -//using System; -//using System.Collections.Generic; -//using Crestron.SimplSharpPro; -//using Crestron.SimplSharpPro.Remotes; -//using Crestron.SimplSharpPro.UI; -//using Newtonsoft.Json; -//using Newtonsoft.Json.Linq; - -//using PepperDash.Essentials.Core; -//using PepperDash.Essentials.Devices; -////using PepperDash.Essentials.Remotes; -//using PepperDash.Core; - -//namespace PepperDash.Essentials -//{ -// //public class RemoteFactory -// //{ -// // public static Device Create(JToken devToken) -// // { -// // Hr150Controller dev = null; -// // try -// // { -// // var devType = devToken.Value("type"); -// // var devKey = devToken.Value("key"); -// // var devName = devToken.Value("name"); -// // var props = devToken["properties"]; - -// // if (devType.Equals("hr150", StringComparison.OrdinalIgnoreCase)) -// // { -// // uint id = Convert.ToUInt32(props.Value("rfId"), 16); -// // var parent = props.Value("rfGateway"); -// // RFExGateway rf = GetGateway(parent); - -// // var hw = new Hr150(id, rf); -// // dev = new Hr150Controller(devKey, devName, hw); - -// // // Have to add the buttons and default source after all devices are spun up -// // dev.AddPostActivationAction(() => -// // { -// // var defaultSystemKey = props.Value("defaultSystemKey"); -// // dev.SetCurrentRoom((EssentialsRoom)DeviceManager.GetDeviceForKey(defaultSystemKey)); - -// // // Link custom buttons -// // var buttonProps = JsonConvert.DeserializeObject>(props["buttons"].ToString()); -// // foreach (var kvp in buttonProps) -// // { -// // var split = kvp.Value.Split(':'); -// // if (split[0].Equals("source")) -// // { -// // var src = DeviceManager.GetDeviceForKey(split[1]) as IPresentationSource; -// // if (src == null) -// // { -// // Debug.Console(0, dev, "Error: Cannot add source key '{0}'", split[1]); -// // continue; -// // } -// // dev.SetCustomButtonAsSource(kvp.Key, src); -// // } -// // else if (split[0] == "room") -// // { -// // if (split[1] == "off") -// // dev.SetCustomButtonAsRoomOff(kvp.Key); -// // } -// // } -// // }); -// // } -// // else if (devType.Equals("tsr302", StringComparison.OrdinalIgnoreCase)) -// // { -// // uint id = Convert.ToUInt32(props.Value("rfId"), 16); -// // var parent = props.Value("rfGateway"); -// // RFExGateway rf = GetGateway(parent); -// // var sgd = props.Value("sgdPath"); - -// // var hw = new Tsr302(id, rf); - -// // //dev = new Hr150Controller(devKey, devName, hw); - -// // //// Have to add the buttons and default source after all devices are spun up -// // //dev.AddPostActivationAction(() => -// // //{ -// // // var defaultSystemKey = props.Value("defaultSystemKey"); -// // // dev.SetCurrentRoom((EssentialsRoom)DeviceManager.GetDeviceForKey(defaultSystemKey)); - -// // // // Link custom buttons -// // // var buttonProps = JsonConvert.DeserializeObject>(props["buttons"].ToString()); -// // // foreach (var kvp in buttonProps) -// // // { -// // // var split = kvp.Value.Split(':'); -// // // if (split[0].Equals("source")) -// // // { -// // // var src = DeviceManager.GetDeviceForKey(split[1]) as IPresentationSource; -// // // if (src == null) -// // // { -// // // Debug.Console(0, dev, "Error: Cannot add source key '{0}'", split[1]); -// // // continue; -// // // } -// // // dev.SetCustomButtonAsSource(kvp.Key, src); -// // // } -// // // else if (split[0] == "room") -// // // { -// // // if (split[1] == "off") -// // // dev.SetCustomButtonAsRoomOff(kvp.Key); -// // // } -// // // } -// // //}); -// // } -// // } -// // catch (Exception e) -// // { -// // FactoryHelper.HandleDeviceCreationError(devToken, e); -// // } -// // return dev; -// // } - -// // public static RFExGateway GetGateway(string parent) -// // { -// // if (parent == null) -// // parent = "controlSystem"; -// // RFExGateway rf = null; -// // if (parent.Equals("controlSystem", StringComparison.OrdinalIgnoreCase) -// // || parent.Equals("processor", StringComparison.OrdinalIgnoreCase)) -// // { -// // rf = Global.ControlSystem.ControllerRFGatewayDevice; -// // } -// // return rf; -// // } -// //} -//} \ No newline at end of file diff --git a/PepperDashEssentials/Configuration Original/Factories/TouchpanelFactory.cs b/PepperDashEssentials/Configuration Original/Factories/TouchpanelFactory.cs deleted file mode 100644 index 024bc083..00000000 --- a/PepperDashEssentials/Configuration Original/Factories/TouchpanelFactory.cs +++ /dev/null @@ -1,48 +0,0 @@ -//using System; -//using Crestron.SimplSharpPro; -//using Crestron.SimplSharpPro.UI; - -//using Newtonsoft.Json.Linq; - -//using PepperDash.Essentials.Core; -//using PepperDash.Essentials.Devices; -//using PepperDash.Core; - -//namespace PepperDash.Essentials -//{ -// public class TouchpanelFactory -// { -// public static Device Create(JToken devToken) -// { -// SmartGraphicsTouchpanelControllerBase dev = null; -// try -// { -// var devType = devToken.Value("type"); -// var devKey = devToken.Value("key"); -// var devName = devToken.Value("name"); -// var props = devToken["properties"]; -// if (devType.Equals("Tsw1052", StringComparison.OrdinalIgnoreCase)) -// { -// uint ipId = Convert.ToUInt32(props.Value("ipId"), 16); -// var hw = new Tsw1052(ipId, Global.ControlSystem); -// dev = TouchpanelControllerFactory.Create(devKey, devName, hw, props.Value("sgdPath")); -// dev.UsesSplashPage = props.Value("usesSplashPage"); -// dev.ShowDate = props.Value("showDate"); -// dev.ShowTime = props.Value("showTime"); - -// // This plugs the system key into the tp, but it won't be linked up until later -// dev.AddPostActivationAction(() => -// { -// var defaultSystemKey = props.Value("defaultSystemKey"); -// dev.SetCurrentRoom((EssentialsRoom)DeviceManager.GetDeviceForKey(defaultSystemKey)); -// }); -// } -// } -// catch (Exception e) -// { -// FactoryHelper.HandleDeviceCreationError(devToken, e); -// } -// return dev; -// } -// } -//} \ No newline at end of file diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index 371d2213..82ebc282 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -155,18 +155,6 @@ - - - - - - - - - - - -