diff --git a/PepperDashEssentials/AppServer/Messengers/IRunRouteActionMessenger.cs b/PepperDashEssentials/AppServer/Messengers/IRunRouteActionMessenger.cs index 6ccc3da7..c39d1dfb 100644 --- a/PepperDashEssentials/AppServer/Messengers/IRunRouteActionMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/IRunRouteActionMessenger.cs @@ -42,7 +42,7 @@ namespace PepperDash.Essentials.AppServer.Messengers { appServerController.AddAction(MessagePath + "/fullStatus", new Action(SendRoutingFullMessageObject)); - appServerController.AddAction(string.Format(@"/device/inRoomPc-1/source"), new Action(c => + appServerController.AddAction(MessagePath + "/source", new Action(c => { RoutingDevice.RunRouteAction(c.SourceListItem, c.SourceListKey); })); diff --git a/PepperDashEssentials/AppServer/Messengers/Ddvc01AtcMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs similarity index 97% rename from PepperDashEssentials/AppServer/Messengers/Ddvc01AtcMessenger.cs rename to PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs index eee94350..019b7742 100644 --- a/PepperDashEssentials/AppServer/Messengers/Ddvc01AtcMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLAtcMessenger.cs @@ -12,7 +12,7 @@ using PepperDash.Essentials.Devices.Common.Codec; namespace PepperDash.Essentials.AppServer.Messengers { - public class Ddvc01AtcMessenger : MessengerBase + public class SIMPLAtcMessenger : MessengerBase { BasicTriList EISC; @@ -97,7 +97,7 @@ namespace PepperDash.Essentials.AppServer.Messengers /// /// /// - public Ddvc01AtcMessenger(string key, BasicTriList eisc, string messagePath) + public SIMPLAtcMessenger(string key, BasicTriList eisc, string messagePath) : base(key, messagePath) { EISC = eisc; diff --git a/PepperDashEssentials/AppServer/Messengers/Ddvc01VtcMessenger.cs b/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs similarity index 99% rename from PepperDashEssentials/AppServer/Messengers/Ddvc01VtcMessenger.cs rename to PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs index b7dfa22c..d0163288 100644 --- a/PepperDashEssentials/AppServer/Messengers/Ddvc01VtcMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/SIMPLVtcMessenger.cs @@ -13,7 +13,7 @@ using PepperDash.Essentials.Devices.Common.Cameras; namespace PepperDash.Essentials.AppServer.Messengers { - public class Ddvc01VtcMessenger : MessengerBase + public class SIMPLVtcMessenger : MessengerBase { BasicTriList EISC; @@ -240,7 +240,7 @@ namespace PepperDash.Essentials.AppServer.Messengers /// /// /// - public Ddvc01VtcMessenger(string key, BasicTriList eisc, string messagePath) + public SIMPLVtcMessenger(string key, BasicTriList eisc, string messagePath) : base(key, messagePath) { EISC = eisc; diff --git a/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs b/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs index 863f1681..b85431fb 100644 --- a/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs +++ b/PepperDashEssentials/AppServer/RoomBridges/MobileControlDdvc01RoomBridge.cs @@ -18,10 +18,16 @@ using PepperDash.Essentials.Room.Config; namespace PepperDash.Essentials.Room.MobileControl { - public class MobileControlDdvc01RoomBridge : MobileControlBridgeBase, IDelayedConfiguration + public class MobileControlSIMPLRoomBridge : MobileControlBridgeBase, IDelayedConfiguration { public class BoolJoin { + + /// + /// 1 + /// + public const uint ConfigIsInEssentials = 100; + /// /// 301 /// @@ -237,8 +243,8 @@ namespace PepperDash.Essentials.Room.MobileControl MobileControlDdvc01DeviceBridge SourceBridge; - Ddvc01AtcMessenger AtcMessenger; - Ddvc01VtcMessenger VtcMessenger; + SIMPLAtcMessenger AtcMessenger; + SIMPLVtcMessenger VtcMessenger; /// @@ -247,7 +253,7 @@ namespace PepperDash.Essentials.Room.MobileControl /// /// /// - public MobileControlDdvc01RoomBridge(string key, string name, uint ipId) + public MobileControlSIMPLRoomBridge(string key, string name, uint ipId) : base(key, name) { try @@ -278,24 +284,33 @@ namespace PepperDash.Essentials.Room.MobileControl SetupFeedbacks(); var atcKey = string.Format("atc-{0}-{1}", this.Key, Parent.Key); - AtcMessenger = new Ddvc01AtcMessenger(atcKey, EISC, "/device/audioCodec"); + AtcMessenger = new SIMPLAtcMessenger(atcKey, EISC, "/device/audioCodec"); AtcMessenger.RegisterWithAppServer(Parent); var vtcKey = string.Format("atc-{0}-{1}", this.Key, Parent.Key); - VtcMessenger = new Ddvc01VtcMessenger(vtcKey, EISC, "/device/videoCodec"); + VtcMessenger = new SIMPLVtcMessenger(vtcKey, EISC, "/device/videoCodec"); VtcMessenger.RegisterWithAppServer(Parent); EISC.SigChange += EISC_SigChange; EISC.OnlineStatusChange += (o, a) => { - Debug.Console(1, this, "DDVC EISC online={0}. Config is ready={1}", a.DeviceOnLine, EISC.BooleanOutput[BoolJoin.ConfigIsReady].BoolValue); + Debug.Console(1, this, "DDVC EISC online={0}. Config is ready={1}. Use Essentials Config={2}", + a.DeviceOnLine, EISC.BooleanOutput[BoolJoin.ConfigIsReady].BoolValue, EISC.BooleanOutput[BoolJoin.ConfigIsInEssentials].BoolValue); + if (a.DeviceOnLine && EISC.BooleanOutput[BoolJoin.ConfigIsReady].BoolValue) LoadConfigValues(); + + if (a.DeviceOnLine && EISC.BooleanOutput[BoolJoin.ConfigIsInEssentials].BoolValue) + UseEssentialsConfig(); }; // load config if it's already there if (EISC.IsOnline && EISC.BooleanOutput[BoolJoin.ConfigIsReady].BoolValue) // || EISC.BooleanInput[BoolJoin.ConfigIsReady].BoolValue) LoadConfigValues(); + if (EISC.IsOnline && EISC.BooleanOutput[BoolJoin.ConfigIsInEssentials].BoolValue) + { + UseEssentialsConfig(); + } CrestronConsole.AddNewConsoleCommand(s => { @@ -322,6 +337,22 @@ namespace PepperDash.Essentials.Room.MobileControl return base.CustomActivate(); } + void UseEssentialsConfig() + { + ConfigIsLoaded = false; + + SetupDeviceMessengers(); + + Debug.Console(0, this, "******* ESSENTIALS CONFIG: \r{0}", JsonConvert.SerializeObject(ConfigReader.ConfigObject, Formatting.Indented)); + + var handler = ConfigurationIsReady; + if (handler != null) + { + handler(this, new EventArgs()); + } + + ConfigIsLoaded = true; + } /// /// Setup the actions to take place on various incoming API calls @@ -373,6 +404,9 @@ namespace PepperDash.Essentials.Room.MobileControl EISC.PulseBool(BoolJoin.ShutdownCancel))); } + + + /// /// /// @@ -782,13 +816,18 @@ namespace PepperDash.Essentials.Room.MobileControl var messengerKey = string.Format("device-{0}-{1}", this.Key, Parent.Key); + if (DeviceManager.GetDeviceForKey(messengerKey) != null) + { + Debug.Console(2, this, "Messenger with key: {0} already exists. Skipping...", messengerKey); + continue; + } var dev = ConfigReader.ConfigObject.GetDeviceForKey(props.DeviceKey); if (dev == null) { Debug.Console(1, this, "Unable to find device config for key: '{0}'", props.DeviceKey); - return; + continue; } var type = device.Type.ToLower(); @@ -798,7 +837,6 @@ namespace PepperDash.Essentials.Room.MobileControl { Debug.Console(2, this, "Adding SIMPLCameraMessenger for: '{0}'", props.DeviceKey); messenger = new SIMPLCameraMessenger(messengerKey, EISC, "/device/" + props.DeviceKey, props.JoinStart); - } else if (type.Equals("simplroutemessenger")) { @@ -931,12 +969,15 @@ namespace PepperDash.Essentials.Room.MobileControl if (Debug.Level >= 1) Debug.Console(1, this, "DDVC EISC change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); var uo = args.Sig.UserObject; - if (uo is Action) - (uo as Action)(args.Sig.BoolValue); - else if (uo is Action) - (uo as Action)(args.Sig.UShortValue); - else if (uo is Action) - (uo as Action)(args.Sig.StringValue); + if (uo != null) + { + if (uo is Action) + (uo as Action)(args.Sig.BoolValue); + else if (uo is Action) + (uo as Action)(args.Sig.UShortValue); + else if (uo is Action) + (uo as Action)(args.Sig.StringValue); + } } /// diff --git a/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs b/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs index cf087e5f..ce8b2f5e 100644 --- a/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs +++ b/PepperDashEssentials/Bridges/JoinMaps/CameraControllerJoinMap.cs @@ -25,6 +25,19 @@ namespace PepperDash.Essentials.Bridges public CameraControllerJoinMap() { + Joins = new Dictionary(); + + Joins.Add("isOnline", new JoinMetadata() + { JoinNumber = 9, Label = "IsOnline", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add("powerOn", new JoinMetadata() + { JoinNumber = 7, Label = "PowerOn", JoinCapabilities = eJoinCapabilities.Read | eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add("powerOff", new JoinMetadata() + { JoinNumber = 8, Label = "PowerOff", JoinCapabilities = eJoinCapabilities.Read | eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); + Joins.Add("up", new JoinMetadata() + { JoinNumber = 1, Label = "TiltUp", JoinCapabilities = eJoinCapabilities.Write, JoinSpan = 1, JoinType = eJoinType.Digital }); + + + // Digital IsOnline = 9; PowerOff = 8; @@ -37,14 +50,23 @@ namespace PepperDash.Essentials.Bridges ZoomOut = 6; PresetRecallOffset = 10; PresetSaveOffset = 30; - NumberOfPresets = 5; + // Analog + NumberOfPresets = 5; } public override void OffsetJoinNumbers(uint joinStart) { var joinOffset = joinStart - 1; + + foreach (var join in Joins) + { + join.Value.JoinNumber = join.Value.JoinNumber + joinOffset; + } + + + IsOnline = IsOnline + joinOffset; PowerOff = PowerOff + joinOffset; PowerOn = PowerOn + joinOffset; diff --git a/PepperDashEssentials/Factory/DeviceFactory.cs b/PepperDashEssentials/Factory/DeviceFactory.cs index 24c4bfe1..1e0e8ffb 100644 --- a/PepperDashEssentials/Factory/DeviceFactory.cs +++ b/PepperDashEssentials/Factory/DeviceFactory.cs @@ -69,7 +69,7 @@ namespace PepperDash.Essentials { var comm = CommFactory.GetControlPropertiesConfig(dc); - var bridge = new PepperDash.Essentials.Room.MobileControl.MobileControlDdvc01RoomBridge(key, name, comm.IpIdInt); + var bridge = new PepperDash.Essentials.Room.MobileControl.MobileControlSIMPLRoomBridge(key, name, comm.IpIdInt); bridge.AddPreActivationAction(() => { var parent = DeviceManager.AllDevices.FirstOrDefault(d => d.Key == "appServer") as MobileControlSystemController; diff --git a/PepperDashEssentials/PepperDashEssentials.csproj b/PepperDashEssentials/PepperDashEssentials.csproj index 6cb64c5b..3b1679c0 100644 --- a/PepperDashEssentials/PepperDashEssentials.csproj +++ b/PepperDashEssentials/PepperDashEssentials.csproj @@ -110,9 +110,9 @@ - + - + diff --git a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs index 23669066..cdba6c4d 100644 --- a/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs +++ b/essentials-framework/Essentials Core/PepperDashEssentialsBase/JoinMaps/JoinMapBase.cs @@ -40,8 +40,33 @@ namespace PepperDash.Essentials.Core /// public abstract void OffsetJoinNumbers(uint joinStart); + public Dictionary Joins { get; set; } + } + + public enum eJoinCapabilities + { + Read = 1, + Write = 2 + } + + public enum eJoinType + { + Digital = 1, + Analog = 2, + Serial = 4 + } + + public class JoinMetadata + { + public string Label { get; set; } + public eJoinType JoinType { get; set; } + public uint JoinNumber { get; set; } + public uint JoinSpan { get; set; } + public eJoinCapabilities JoinCapabilities { get; set; } } + + } \ No newline at end of file