diff --git a/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs b/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs index fe859e93..52f2f9e6 100644 --- a/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs +++ b/PepperDashEssentials/Bridges/Bridges.BridgeFactory.cs @@ -47,6 +47,11 @@ namespace PepperDash.Essentials { Debug.Console(2, "Launch essentialstvone"); return new EssentialsTVOne(key, name, properties); } + else if (typeName == "essentialslighting") + { + Debug.Console(2, "Launch essentialslighting"); + return new EssentialsLightsBridge(key, name, properties); + } return null; } } diff --git a/PepperDashEssentials/Bridges/EssentialsLightsBridge.cs b/PepperDashEssentials/Bridges/EssentialsLightsBridge.cs index 5fb81c0f..b22a8b07 100644 --- a/PepperDashEssentials/Bridges/EssentialsLightsBridge.cs +++ b/PepperDashEssentials/Bridges/EssentialsLightsBridge.cs @@ -31,12 +31,18 @@ namespace PepperDash.Essentials } public override bool CustomActivate() { // Create EiscApis + ICommunicationMonitor comm = null; try { foreach (var device in DeviceManager.AllDevices) { if (device.Key == this.Properties.connectionDeviceKey) { + + if (!(device is ICommunicationMonitor)) + { + comm = device as ICommunicationMonitor; + } Debug.Console(2, "deviceKey {0} Matches", device.Key); Lights = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.Core.Lighting.LightingBase; break; @@ -51,13 +57,26 @@ namespace PepperDash.Essentials { foreach (string Ipid in Properties.EiscApiIpids) { + var ApiEisc = new BridgeApiEisc(Ipid); - Debug.Console(2, "Connecting EiscApi {0} to {1}", ApiEisc.Ipid, TVOneCorio.Name); + Debug.Console(2, "Connecting EiscApi {0} to {1}", ApiEisc.Ipid, Lights.Name); ushort x = 1; - Lights.Is - var tempDevice = Lights as PepperDash.Core.Device; - tempDevice. - .OnlineFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.Online]); + + if(comm != null) + { + comm.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.Online]); + } + ApiEisc.Eisc.SetUShortSigAction(ApiMap.CallPreset, u => Lights.SelectScene(Lights.LightingScenes[u])); + int sceneIndex = 1; + foreach (var scene in Lights.LightingScenes) + { + var tempIndex = sceneIndex - 1; + ApiEisc.Eisc.SetSigTrueAction((uint)(ApiMap.LightingSceneOffset + sceneIndex), () => Lights.SelectScene(Lights.LightingScenes[tempIndex])); + scene.IsActiveFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[(uint)(ApiMap.LightingSceneOffset + sceneIndex)]); + ApiEisc.Eisc.StringInput[(uint)(ApiMap.LightingSceneOffset + sceneIndex)].StringValue = scene.Name; + ApiEisc.Eisc.BooleanInput[(uint)(ApiMap.ButtonVisibilityOffset + sceneIndex)].BoolValue = true; + sceneIndex++; + } } } @@ -85,10 +104,10 @@ namespace PepperDash.Essentials public class EssentialsLightsBridgeApiMap { - public ushort CallPreset = 1; - public ushort PresetFeedback = 1; public ushort Online = 1; - + public ushort LightingSceneOffset = 10; + public ushort ButtonVisibilityOffset = 40; + public ushort CallPreset = 1; public EssentialsLightsBridgeApiMap() { diff --git a/essentials-framework b/essentials-framework index 5fde7251..f17d3457 160000 --- a/essentials-framework +++ b/essentials-framework @@ -1 +1 @@ -Subproject commit 5fde72515cb1d55c30e8589971943f2f7f344113 +Subproject commit f17d34576b06bf6e7d2ae2447e5225e5caa73969