mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 12:44:58 +00:00
Adds Display Controller base with some basic functioanlity.
This commit is contained in:
@@ -87,6 +87,11 @@ namespace PepperDash.Essentials.Bridges
|
|||||||
(device as GenericComm).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
|
(device as GenericComm).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
else if (device is PepperDash.Essentials.Core.TwoWayDisplayBase)
|
||||||
|
{
|
||||||
|
(device as TwoWayDisplayBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
else if (device is DmChassisController)
|
else if (device is DmChassisController)
|
||||||
{
|
{
|
||||||
(device as DmChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
|
(device as DmChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
|
||||||
|
|||||||
@@ -14,168 +14,128 @@ using Crestron.SimplSharpPro;
|
|||||||
using Crestron.SimplSharpPro.EthernetCommunication;
|
using Crestron.SimplSharpPro.EthernetCommunication;
|
||||||
|
|
||||||
namespace PepperDash.Essentials
|
namespace PepperDash.Essentials
|
||||||
|
|
||||||
{
|
{
|
||||||
public class BridgeFactory
|
public class BridgeFactory
|
||||||
{
|
{
|
||||||
public static IKeyed GetDevice(DeviceConfig dc)
|
public static IKeyed GetDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
// ? why is this static JTA 2018-06-13?
|
// ? why is this static JTA 2018-06-13?
|
||||||
|
|
||||||
var key = dc.Key;
|
var key = dc.Key;
|
||||||
var name = dc.Name;
|
var name = dc.Name;
|
||||||
var type = dc.Type;
|
var type = dc.Type;
|
||||||
var properties = dc.Properties;
|
var properties = dc.Properties;
|
||||||
var propAnon = new { };
|
var propAnon = new { };
|
||||||
|
|
||||||
var typeName = dc.Type.ToLower();
|
var typeName = dc.Type.ToLower();
|
||||||
var groupName = dc.Group.ToLower();
|
var groupName = dc.Group.ToLower();
|
||||||
|
|
||||||
//Debug.Console(2, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString());
|
//Debug.Console(2, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString());
|
||||||
|
|
||||||
if (typeName == "eiscapi")
|
if (typeName == "eiscapi")
|
||||||
{
|
{
|
||||||
return new EiscApi(dc);
|
return new EiscApi(dc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class CommBridge : Device
|
||||||
|
{
|
||||||
|
public CommBridgeProperties Properties { get; private set; }
|
||||||
|
|
||||||
|
public List<IBasicCommunication> CommDevices { get; private set; }
|
||||||
|
|
||||||
|
public CommBridge(string key, string name, JToken properties)
|
||||||
|
: base(key, name)
|
||||||
|
{
|
||||||
|
Properties = JsonConvert.DeserializeObject<CommBridgeProperties>(properties.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool CustomActivate()
|
||||||
|
{
|
||||||
|
// Create EiscApis
|
||||||
|
if (Properties.Eiscs != null)
|
||||||
|
{
|
||||||
|
foreach (var eisc in Properties.Eiscs)
|
||||||
|
{
|
||||||
|
var ApiEisc = new BridgeApiEisc(eisc.IpId, eisc.Hostname);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public class DmBridge : Device
|
foreach (var deviceKey in Properties.CommDevices)
|
||||||
{
|
{
|
||||||
public EiscBridgeProperties Properties { get; private set; }
|
var device = DeviceManager.GetDeviceForKey(deviceKey);
|
||||||
|
|
||||||
public PepperDash.Essentials.DM.DmChassisController DmSwitch { get; private set; }
|
if (device != null)
|
||||||
|
{
|
||||||
public DmBridge(string key, string name, JToken properties) : base(key, name)
|
Debug.Console(0, "deviceKey {0} Found in Device Manager", device.Key);
|
||||||
{
|
CommDevices.Add(device as IBasicCommunication);
|
||||||
Properties = JsonConvert.DeserializeObject<EiscBridgeProperties>(properties.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CustomActivate()
|
|
||||||
{
|
|
||||||
// Create EiscApis
|
|
||||||
if (Properties.Eiscs != null)
|
|
||||||
{
|
|
||||||
foreach (var eisc in Properties.Eiscs)
|
|
||||||
{
|
|
||||||
var ApiEisc = new BridgeApiEisc(eisc.IpId, eisc.Hostname);
|
|
||||||
|
|
||||||
ApiEisc.Eisc.SetUShortSigAction(101, u => DmSwitch.ExecuteSwitch(u,1, eRoutingSignalType.Video));
|
|
||||||
ApiEisc.Eisc.SetUShortSigAction(102, u => DmSwitch.ExecuteSwitch(u,2, eRoutingSignalType.Video));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
foreach (var device in DeviceManager.AllDevices)
|
{
|
||||||
{
|
Debug.Console(0, "deviceKey {0} Not Found in Device Manager", deviceKey);
|
||||||
if (device.Key == this.Properties.ParentDeviceKey)
|
|
||||||
{
|
|
||||||
Debug.Console(0, "deviceKey {0} Matches", device.Key);
|
|
||||||
DmSwitch = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.DM.DmChassisController;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Console(0, "deviceKey {0} doesn't match", device.Key);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(0, "Bridge {0} Activated", this.Name);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Iterate through all the CommDevices and link up their Actions and Feedbacks
|
||||||
|
|
||||||
|
Debug.Console(0, "Bridge {0} Activated", this.Name);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
public class CommBridge : Device
|
|
||||||
{
|
|
||||||
public CommBridgeProperties Properties { get; private set; }
|
|
||||||
|
|
||||||
public List<IBasicCommunication> CommDevices { get; private set; }
|
|
||||||
|
|
||||||
public CommBridge(string key, string name, JToken properties)
|
|
||||||
: base(key, name)
|
|
||||||
{
|
|
||||||
Properties = JsonConvert.DeserializeObject<CommBridgeProperties>(properties.ToString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CustomActivate()
|
|
||||||
{
|
|
||||||
// Create EiscApis
|
|
||||||
if (Properties.Eiscs != null)
|
|
||||||
{
|
|
||||||
foreach (var eisc in Properties.Eiscs)
|
|
||||||
{
|
|
||||||
var ApiEisc = new BridgeApiEisc(eisc.IpId, eisc.Hostname);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var deviceKey in Properties.CommDevices)
|
|
||||||
{
|
|
||||||
var device = DeviceManager.GetDeviceForKey(deviceKey);
|
|
||||||
|
|
||||||
if (device != null)
|
|
||||||
{
|
|
||||||
Debug.Console(0, "deviceKey {0} Found in Device Manager", device.Key);
|
|
||||||
CommDevices.Add(device as IBasicCommunication);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Console(0, "deviceKey {0} Not Found in Device Manager", deviceKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Iterate through all the CommDevices and link up their Actions and Feedbacks
|
|
||||||
|
|
||||||
Debug.Console(0, "Bridge {0} Activated", this.Name);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public class EiscBridgeProperties
|
public class EiscBridgeProperties
|
||||||
{
|
{
|
||||||
public string ParentDeviceKey { get; set; }
|
public string ParentDeviceKey { get; set; }
|
||||||
public eApiType ApiType { get; set; }
|
public eApiType ApiType { get; set; }
|
||||||
public List<EiscProperties> Eiscs { get; set; }
|
public List<EiscProperties> Eiscs { get; set; }
|
||||||
public string ApiOverrideFilePath { get; set; }
|
public string ApiOverrideFilePath { get; set; }
|
||||||
|
|
||||||
public class EiscProperties
|
public class EiscProperties
|
||||||
{
|
{
|
||||||
public string IpId { get; set; }
|
public string IpId { get; set; }
|
||||||
public string Hostname { get; set; }
|
public string Hostname { get; set; }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class CommBridgeProperties : EiscBridgeProperties
|
public class CommBridgeProperties : EiscBridgeProperties
|
||||||
{
|
{
|
||||||
public List<string> CommDevices { get; set; }
|
public List<string> CommDevices { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum eApiType { Eisc = 0 }
|
public enum eApiType { Eisc = 0 }
|
||||||
|
|
||||||
public class BridgeApiEisc
|
public class BridgeApiEisc
|
||||||
{
|
{
|
||||||
public uint Ipid { get; private set; }
|
public uint Ipid { get; private set; }
|
||||||
public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; }
|
public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; }
|
||||||
|
|
||||||
public BridgeApiEisc(string ipid, string hostname)
|
public BridgeApiEisc(string ipid, string hostname)
|
||||||
{
|
{
|
||||||
Ipid = (UInt32)int.Parse(ipid, System.Globalization.NumberStyles.HexNumber);
|
Ipid = (UInt32)int.Parse(ipid, System.Globalization.NumberStyles.HexNumber);
|
||||||
Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(Ipid, hostname, Global.ControlSystem);
|
Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(Ipid, hostname, Global.ControlSystem);
|
||||||
Eisc.Register();
|
Eisc.Register();
|
||||||
Eisc.SigChange += Eisc_SigChange;
|
Eisc.SigChange += Eisc_SigChange;
|
||||||
Debug.Console(0, "BridgeApiEisc Created at Ipid {0}", ipid);
|
Debug.Console(0, "BridgeApiEisc Created at Ipid {0}", ipid);
|
||||||
}
|
|
||||||
void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args)
|
|
||||||
{
|
|
||||||
if (Debug.Level >= 1)
|
|
||||||
Debug.Console(1, "BridgeApiEisc change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
|
|
||||||
var uo = args.Sig.UserObject;
|
|
||||||
if (uo is Action<bool>)
|
|
||||||
(uo as Action<bool>)(args.Sig.BoolValue);
|
|
||||||
else if (uo is Action<ushort>)
|
|
||||||
(uo as Action<ushort>)(args.Sig.UShortValue);
|
|
||||||
else if (uo is Action<string>)
|
|
||||||
(uo as Action<string>)(args.Sig.StringValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args)
|
||||||
|
{
|
||||||
|
if (Debug.Level >= 1)
|
||||||
|
Debug.Console(1, "BridgeApiEisc change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
|
||||||
|
var uo = args.Sig.UserObject;
|
||||||
|
if (uo is Action<bool>)
|
||||||
|
(uo as Action<bool>)(args.Sig.BoolValue);
|
||||||
|
else if (uo is Action<ushort>)
|
||||||
|
(uo as Action<ushort>)(args.Sig.UShortValue);
|
||||||
|
else if (uo is Action<string>)
|
||||||
|
(uo as Action<string>)(args.Sig.StringValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ using PepperDash.Essentials.Devices.Common;
|
|||||||
|
|
||||||
namespace PepperDash.Essentials.Bridges
|
namespace PepperDash.Essentials.Bridges
|
||||||
{
|
{
|
||||||
public static class SamsungDisplayControllerApiExtensions
|
public static class DisplayControllerApiExtensions
|
||||||
{
|
{
|
||||||
public static void LinkToApi(this PepperDash.Essentials.Core.TwoWayDisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey)
|
public static void LinkToApi(this PepperDash.Essentials.Core.TwoWayDisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey)
|
||||||
{
|
{
|
||||||
@@ -20,10 +20,10 @@ namespace PepperDash.Essentials.Bridges
|
|||||||
{
|
{
|
||||||
joinMap = new DisplayControllerJoinMap();
|
joinMap = new DisplayControllerJoinMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
joinMap.OffsetJoinNumbers(joinStart);
|
joinMap.OffsetJoinNumbers(joinStart);
|
||||||
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||||
Debug.Console(0, "Linking to lighting Type {0}", displayDevice.GetType().Name.ToString());
|
Debug.Console(0, "Linking to Bridge Type {0}", displayDevice.GetType().Name.ToString());
|
||||||
|
|
||||||
var commMonitor = displayDevice as ICommunicationMonitor;
|
var commMonitor = displayDevice as ICommunicationMonitor;
|
||||||
commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
|
commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
|
||||||
@@ -36,7 +36,19 @@ namespace PepperDash.Essentials.Bridges
|
|||||||
// Poewer On
|
// Poewer On
|
||||||
trilist.SetSigTrueAction(joinMap.PowerOn, () => displayDevice.PowerOn());
|
trilist.SetSigTrueAction(joinMap.PowerOn, () => displayDevice.PowerOn());
|
||||||
displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn]);
|
displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn]);
|
||||||
|
|
||||||
|
|
||||||
|
trilist.SetUShortSigAction(joinMap.InputSelect, (a) =>
|
||||||
|
{
|
||||||
|
if (a == 0)
|
||||||
|
{
|
||||||
|
displayDevice.PowerOff();
|
||||||
|
}
|
||||||
|
else if (a > 0 && a < displayDevice.InputPorts.Count)
|
||||||
|
{
|
||||||
|
displayDevice.ExecuteSwitch(displayDevice.InputPorts.ElementAt(a - 1).Selector);
|
||||||
|
}
|
||||||
|
});
|
||||||
// GenericLighitng Actions & FeedBack
|
// GenericLighitng Actions & FeedBack
|
||||||
|
|
||||||
// int sceneIndex = 1;
|
// int sceneIndex = 1;
|
||||||
@@ -83,6 +95,7 @@ namespace PepperDash.Essentials.Bridges
|
|||||||
{
|
{
|
||||||
public uint IsOnline { get; set; }
|
public uint IsOnline { get; set; }
|
||||||
public uint PowerOff { get; set; }
|
public uint PowerOff { get; set; }
|
||||||
|
public uint InputSelect { get; set; }
|
||||||
public uint PowerOn { get; set; }
|
public uint PowerOn { get; set; }
|
||||||
public uint SelectScene { get; set; }
|
public uint SelectScene { get; set; }
|
||||||
public uint LightingSceneOffset { get; set; }
|
public uint LightingSceneOffset { get; set; }
|
||||||
@@ -95,7 +108,7 @@ namespace PepperDash.Essentials.Bridges
|
|||||||
IsOnline = 1;
|
IsOnline = 1;
|
||||||
PowerOff = 1;
|
PowerOff = 1;
|
||||||
PowerOn = 2;
|
PowerOn = 2;
|
||||||
SelectScene = 1;
|
InputSelect = 1;
|
||||||
IntegrationIdSet = 1;
|
IntegrationIdSet = 1;
|
||||||
LightingSceneOffset = 10;
|
LightingSceneOffset = 10;
|
||||||
ButtonVisibilityOffset = 40;
|
ButtonVisibilityOffset = 40;
|
||||||
|
|||||||
Submodule essentials-framework updated: 78182ecd86...2cfdc4f266
Reference in New Issue
Block a user