diff --git a/PepperDashEssentials/Bridges/BridgeBase.cs b/PepperDashEssentials/Bridges/BridgeBase.cs index e8536df1..cf2d2f27 100644 --- a/PepperDashEssentials/Bridges/BridgeBase.cs +++ b/PepperDashEssentials/Bridges/BridgeBase.cs @@ -92,6 +92,10 @@ namespace PepperDash.Essentials.Bridges }; } + + /// + /// API class for IBasicCommunication devices + /// public class IBasicCommunicationApi : DeviceApiBase { public IBasicCommunication Device { get; set; } diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index b4bfc66a..343b28ad 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -105,6 +105,8 @@ + + @@ -154,6 +156,7 @@ + diff --git a/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs b/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs index 7141a577..ea217f28 100644 --- a/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs +++ b/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs @@ -80,8 +80,26 @@ namespace PepperDash.Essentials }, "mobilehttpdebug", "1 enables more verbose HTTP response debugging", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(TestHttpRequest, - "mobilehttprequest", "Tests an HTTP get to URL given", ConsoleAccessLevelEnum.AccessOperator); - + "mobilehttprequest", "Tests an HTTP get to URL given", ConsoleAccessLevelEnum.AccessOperator); + + + CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler); + } + + /// + /// Sends message to server to indicate the system is shutting down + /// + /// + void CrestronEnvironment_ProgramStatusEventHandler(eProgramStatusEventType programEventType) + { + if (programEventType == eProgramStatusEventType.Stopping && WSClient.Connected) + { + SendMessageToServer(JObject.FromObject( new + { + type = "/system/close" + })); + + } } /// @@ -449,7 +467,12 @@ namespace PepperDash.Essentials /// /// void HandleHeartBeat(JToken content) - { + { + SendMessageToServer(JObject.FromObject(new + { + type = "/system/heartbeatAck" + })); + var code = content["userCode"]; if(code != null) { diff --git a/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs b/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs index 48bd33fa..78512263 100644 --- a/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs +++ b/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs @@ -250,6 +250,18 @@ namespace PepperDash.Essentials.Room.Cotija EISC.PulseBool(BoolJoin.ShutdownEnd))); Parent.AddAction(@"/room/room1/shutdownCancel", new Action(() => EISC.PulseBool(BoolJoin.ShutdownCancel))); + + + // Source Device (Current Source)' + + SourceDeviceMapDictionary sourceJoinMap = new SourceDeviceMapDictionary(); + + var prefix = @"/device/currentSource/"; + + foreach (var item in sourceJoinMap) + { + Parent.AddAction(prefix + item.Key, new PressAndHoldAction(b => EISC.SetBool(item.Value, b))); + } } /// @@ -319,12 +331,17 @@ namespace PepperDash.Essentials.Room.Cotija //Room if (co.Rooms == null) co.Rooms = new List(); - var rm = new EssentialsRoomConfig(); - if (co.Rooms.Count == 0) - { - Debug.Console(0, this, "Adding room to config"); - co.Rooms.Add(rm); - } + var rm = new EssentialsRoomConfig(); + if (co.Rooms.Count == 0) + { + Debug.Console(0, this, "Adding room to config"); + co.Rooms.Add(rm); + } + else + { + Debug.Console(0, this, "Replacing Room[0] in config"); + co.Rooms[0] = rm; + } rm.Name = EISC.StringOutput[501].StringValue; rm.Key = "room1"; rm.Type = "ddvc01"; diff --git a/PepperDashEssentials/Room/Cotija/RoomBridges/SourceDeviceMapDictionary.cs b/PepperDashEssentials/Room/Cotija/RoomBridges/SourceDeviceMapDictionary.cs new file mode 100644 index 00000000..ecd29d59 --- /dev/null +++ b/PepperDashEssentials/Room/Cotija/RoomBridges/SourceDeviceMapDictionary.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Room.Cotija +{ + + /// + /// Contains all of the default joins that map to API funtions + /// + public class SourceDeviceMapDictionary : Dictionary + { + + public SourceDeviceMapDictionary(): base() + { + var dictionary = new Dictionary + { + {"preset01", 101}, + {"preset02", 102}, + {"preset03", 103}, + {"preset04", 104}, + {"preset05", 105}, + {"preset06", 106}, + {"preset07", 107}, + {"preset08", 108}, + {"preset09", 109}, + {"preset10", 110}, + {"preset11", 111}, + {"preset12", 112}, + {"preset13", 113}, + {"preset14", 114}, + {"preset15", 115}, + {"preset16", 116}, + {"preset17", 117}, + {"preset18", 118}, + {"preset19", 119}, + {"preset20", 120}, + {"preset21", 121}, + {"preset22", 122}, + {"preset23", 123}, + {"preset24", 124}, + + {"key0", 130}, + {"key1", 131}, + {"key2", 132}, + {"key3", 133}, + {"key4", 134}, + {"key5", 135}, + {"key6", 136}, + {"key7", 137}, + {"key8", 138}, + {"key9", 139}, + {"keyDash", 140}, + {"keyEnter", 141}, + {"channelUp", 142}, + {"channelDown", 143}, + {"channelLast", 144}, + {"exit", 145}, + {"power", 146}, + {"red", 147}, + {"green", 148}, + {"yellow", 149}, + {"blue", 150}, + {"video", 151}, + {"previous", 152}, + {"next", 153}, + {"rewind", 154}, + {"ffwd", 155}, + {"closedCaption", 156}, + {"stop", 157}, + {"pause", 158}, + {"cursorUp", 159}, + {"cursorDown", 160}, + {"cursorLeft", 161}, + {"cursorRight", 162}, + {"settings", 163}, + {"info", 164}, + {"return", 165}, + {"guide", 166}, + {"reboot", 167}, + + {"play", 170}, + {"cursorOk", 171}, + {"record", 172}, + {"menu", 173}, + {"topMenu", 174} + }; + + + } + } +} \ No newline at end of file diff --git a/Release Package/PepperDashEssentials.cpz b/Release Package/PepperDashEssentials.cpz index a98c5497..102c997c 100644 Binary files a/Release Package/PepperDashEssentials.cpz and b/Release Package/PepperDashEssentials.cpz differ diff --git a/Release Package/PepperDashEssentials.dll b/Release Package/PepperDashEssentials.dll index 234c04d4..7bb8d442 100644 Binary files a/Release Package/PepperDashEssentials.dll and b/Release Package/PepperDashEssentials.dll differ