diff --git a/Essentials/PepperDashEssentials/Config/EssentialsConfig.cs b/Essentials/PepperDashEssentials/Config/EssentialsConfig.cs index 44f8fa8f..f0d38425 100644 --- a/Essentials/PepperDashEssentials/Config/EssentialsConfig.cs +++ b/Essentials/PepperDashEssentials/Config/EssentialsConfig.cs @@ -22,7 +22,7 @@ namespace PepperDash.Essentials [JsonProperty("template_url")] public string TemplateUrl { get; set; } - public CotijaConfig Cotija { get; private set; } + //public CotijaConfig Cotija { get; private set; } public string SystemUuid { @@ -49,7 +49,7 @@ namespace PepperDash.Essentials } [JsonProperty("rooms")] - public List Rooms { get; private set; } + public List Rooms { get; set; } } /// @@ -60,7 +60,5 @@ namespace PepperDash.Essentials public EssentialsConfig System { get; set; } public EssentialsConfig Template { get; set; } - - //public CotijaConfig Cotija { get; set; } } } \ No newline at end of file diff --git a/Essentials/PepperDashEssentials/ControlSystem.cs b/Essentials/PepperDashEssentials/ControlSystem.cs index 57c10aba..537921c9 100644 --- a/Essentials/PepperDashEssentials/ControlSystem.cs +++ b/Essentials/PepperDashEssentials/ControlSystem.cs @@ -42,6 +42,21 @@ namespace PepperDash.Essentials }, "listtielines", "Prints out all tie lines", ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(s => + { + CrestronConsole.ConsoleCommandResponse + ("Current running configuration. This is the merged system and template configuration"); + CrestronConsole.ConsoleCommandResponse(Newtonsoft.Json.JsonConvert.SerializeObject + (ConfigReader.ConfigObject, Newtonsoft.Json.Formatting.Indented)); + }, "showconfig", "Shows the current running merged config", ConsoleAccessLevelEnum.AccessOperator); + + CrestronConsole.AddNewConsoleCommand(s => + { + CrestronConsole.ConsoleCommandResponse("This system can be found at the following URLs:\r" + + "System URL: {0}\r" + + "Template URL: {1}", ConfigReader.ConfigObject.SystemUrl, ConfigReader.ConfigObject.TemplateUrl); + }, "portalinfo", "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator); + GoWithLoad(); } diff --git a/Essentials/PepperDashEssentials/PepperDashEssentials.csproj b/Essentials/PepperDashEssentials/PepperDashEssentials.csproj index bb41a4e1..04050521 100644 --- a/Essentials/PepperDashEssentials/PepperDashEssentials.csproj +++ b/Essentials/PepperDashEssentials/PepperDashEssentials.csproj @@ -134,11 +134,13 @@ + + diff --git a/Essentials/PepperDashEssentials/Properties/AssemblyInfo.cs b/Essentials/PepperDashEssentials/Properties/AssemblyInfo.cs index be8d7f37..c2ca7ef3 100644 --- a/Essentials/PepperDashEssentials/Properties/AssemblyInfo.cs +++ b/Essentials/PepperDashEssentials/Properties/AssemblyInfo.cs @@ -4,5 +4,5 @@ [assembly: AssemblyCompany("PepperDash Technology Corp")] [assembly: AssemblyProduct("PepperDashEssentials")] [assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2017")] -[assembly: AssemblyVersion("1.0.34.*")] +[assembly: AssemblyVersion("1.0.35.*")] diff --git a/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs b/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs index 58ef4223..11147c2b 100644 --- a/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs +++ b/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs @@ -19,7 +19,7 @@ namespace PepperDash.Essentials { GenericHttpSseClient SseClient; - CCriticalSection FileLock; + //CCriticalSection FileLock; /// /// Prevents post operations from stomping on each other and getting lost @@ -153,34 +153,37 @@ namespace PepperDash.Essentials /// URL of the server, including the port number, if not 80. Format: "serverUrlOrIp:port" void RegisterSystemToServer() { +#warning THIS SHOULD NOT GO until the config is ready - in cases of config populated from elsewhere (DDVC) try { string filePath = string.Format(@"\NVRAM\Program{0}\configurationFile.json", Global.ControlSystem.ProgramNumber); - string postBody = null; + var confObject = ConfigReader.ConfigObject; + string postBody = JsonConvert.SerializeObject(confObject); + SystemUuid = confObject.SystemUuid; - if (string.IsNullOrEmpty(filePath)) - { - Debug.Console(0, this, "Error reading file. No path specified."); - return; - } + //if (string.IsNullOrEmpty(filePath)) + //{ + // Debug.Console(0, this, "Error reading file. No path specified."); + // return; + //} - FileLock = new CCriticalSection(); -#warning NEIL I think we need to review this usage. Don't think it ever blocks +// FileLock = new CCriticalSection(); +//#warning NEIL I think we need to review this usage. Don't think it ever blocks - if (FileLock.TryEnter()) - { - Debug.Console(1, this, "Reading configuration file to extract system UUID..."); +// if (FileLock.TryEnter()) +// { +// Debug.Console(1, this, "Reading configuration file to extract system UUID..."); - postBody = File.ReadToEnd(filePath, Encoding.ASCII); +// postBody = File.ReadToEnd(filePath, Encoding.ASCII); - Debug.Console(2, this, "{0}", postBody); +// Debug.Console(2, this, "{0}", postBody); - FileLock.Leave(); - } +// FileLock.Leave(); +// } if (string.IsNullOrEmpty(postBody)) { - Debug.Console(1, "Post Body is null or empty"); + Debug.Console(1, this, "ERROR: Config post body is empty. Cannot register with server."); } else { @@ -188,11 +191,9 @@ namespace PepperDash.Essentials Client = new HttpClient(); Client.Verbose = true; Client.KeepAlive = true; - - SystemUuid = Essentials.ConfigReader.ConfigObject.SystemUuid; - string url = string.Format("http://{0}/api/system/join/{1}", Config.ServerUrl, SystemUuid); - Debug.Console(1, this, "Sending config to {0}", url); + string url = string.Format("http://{0}/api/system/join/{1}", Config.ServerUrl, SystemUuid); + Debug.Console(1, this, "Joining server at {0}", url); HttpClientRequest request = new HttpClientRequest(); request.Url.Parse(url); @@ -206,7 +207,7 @@ namespace PepperDash.Essentials } catch (Exception e) { - Debug.Console(0, this, "Error Initilizing Room: {0}", e); + Debug.Console(0, this, "ERROR: Initilizing Room: {0}", e); } } diff --git a/Essentials/PepperDashEssentials/Room/Cotija/Interfaces.cs b/Essentials/PepperDashEssentials/Room/Cotija/Interfaces.cs new file mode 100644 index 00000000..1aab82fb --- /dev/null +++ b/Essentials/PepperDashEssentials/Room/Cotija/Interfaces.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Room.Cotija +{ + public interface IDelayedConfiguration + { + event EventHandler ConfigurationIsReady; + } +} \ No newline at end of file diff --git a/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs b/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs index e9e84ec6..2c88aee5 100644 --- a/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs +++ b/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs @@ -10,11 +10,13 @@ using Newtonsoft.Json.Linq; using PepperDash.Core; using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Room.Config; + namespace PepperDash.Essentials.Room.Cotija { - public class CotijaDdvc01RoomBridge : Device + public class CotijaDdvc01RoomBridge : Device, IDelayedConfiguration { public class BoolJoin { @@ -109,6 +111,10 @@ namespace PepperDash.Essentials.Room.Cotija public const uint ConfigRoomURI = 505; } + /// + /// Fires when the config is ready, to be used by the controller class to forward config to server + /// + public event EventHandler ConfigurationIsReady; public ThreeSeriesTcpIpEthernetIntersystemCommunications EISC { get; private set; } @@ -277,7 +283,7 @@ namespace PepperDash.Essentials.Room.Cotija if (string.IsNullOrEmpty(num)) break; var name = EISC.StringInput[i + 1].StringValue; - rmProps.SpeedDials.Add(new DDVC01SpeedDial { Number = num, Name = name}; + rmProps.SpeedDials.Add(new DDVC01SpeedDial { Number = num, Name = name}); } // volume control names var volCount = EISC.UShortInput[701].UShortValue; @@ -286,12 +292,40 @@ namespace PepperDash.Essentials.Room.Cotija { rmProps.VolumeSliderNames.Add(EISC.StringInput[i].StringValue); } + + // There should be cotija devices in here, I think... + if(co.Devices == null) + co.Devices = new List(); // Source list! This might be brutal!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! rmProps.SourceListKey = "default"; co.SourceLists = new Dictionary>(); var newSl = new Dictionary(); // add sources... + for (uint i = 0; i<= 19; i++) + { + var name = EISC.StringInput[601 + i].StringValue; + if(string.IsNullOrEmpty(name)) + break; + var icon = EISC.StringInput[651 + i].StringValue; + var key = EISC.StringInput[671 + i].StringValue; + var type = EISC.StringInput[701 + i].StringValue; + var newSLI = new SourceListItem{ + Icon = icon, + Name = name, + Order = (int)i + 1, + SourceKey = key, + }; + + // add dev to devices list + var devConf = new DeviceConfig { + Group = "ddvc01", + Key = key, + Name = name, + Type = type + }; + co.Devices.Add(devConf); + } co.SourceLists.Add("default", newSl); diff --git a/Release Package/PepperDashEssentials.cpz b/Release Package/PepperDashEssentials.cpz index 11fd7f0b..700a51d3 100644 Binary files a/Release Package/PepperDashEssentials.cpz and b/Release Package/PepperDashEssentials.cpz differ