mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-27 19:34:51 +00:00
Progress on comm bridge
This commit is contained in:
@@ -10,6 +10,7 @@ using Newtonsoft.Json;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Devices;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
|
||||
namespace PepperDash.Essentials.Bridges
|
||||
{
|
||||
@@ -46,17 +47,37 @@ namespace PepperDash.Essentials.Bridges
|
||||
/// </summary>
|
||||
public class EiscApi : BridgeApi
|
||||
{
|
||||
public EiscApiPropertiesConfig PropertiesConfig { get; private set; }
|
||||
|
||||
public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; }
|
||||
|
||||
|
||||
public EiscApi(string key, uint ipid, string hostname) :
|
||||
base(key)
|
||||
public EiscApi(DeviceConfig dc) :
|
||||
base(dc.Key)
|
||||
{
|
||||
Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(ipid, hostname, Global.ControlSystem);
|
||||
PropertiesConfig = JsonConvert.DeserializeObject<EiscApiPropertiesConfig>(dc.Properties.ToString());
|
||||
|
||||
Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(PropertiesConfig.Control.IpIdInt, PropertiesConfig.Control.TcpSshProperties.Address, Global.ControlSystem);
|
||||
|
||||
Eisc.SigChange += new Crestron.SimplSharpPro.DeviceSupport.SigEventHandler(Eisc_SigChange);
|
||||
|
||||
Eisc.Register();
|
||||
|
||||
AddPostActivationAction( () =>
|
||||
{
|
||||
foreach (var d in PropertiesConfig.Devices)
|
||||
{
|
||||
var device = DeviceManager.GetDeviceForKey(d.DeviceKey);
|
||||
|
||||
if (device != null)
|
||||
{
|
||||
if (device is GenericComm)
|
||||
{
|
||||
(device as GenericComm).LinkToApi(Eisc, d.JoinStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -83,7 +104,6 @@ namespace PepperDash.Essentials.Bridges
|
||||
[JsonProperty("control")]
|
||||
public EssentialsControlPropertiesConfig Control { get; set; }
|
||||
|
||||
|
||||
[JsonProperty("devices")]
|
||||
public List<ApiDevice> Devices { get; set; }
|
||||
|
||||
@@ -93,7 +113,7 @@ namespace PepperDash.Essentials.Bridges
|
||||
public string DeviceKey { get; set; }
|
||||
|
||||
[JsonProperty("joinStart")]
|
||||
public int JoinStart { get; set; }
|
||||
public uint JoinStart { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -165,42 +185,42 @@ namespace PepperDash.Essentials.Bridges
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Each flavor of API is a static class with static properties and a static constructor that
|
||||
/// links up the things to do.
|
||||
/// </summary>
|
||||
public class DmChassisControllerApi : DeviceApiBase
|
||||
{
|
||||
IntFeedback Output1Feedback;
|
||||
IntFeedback Output2Feedback;
|
||||
///// <summary>
|
||||
///// Each flavor of API is a static class with static properties and a static constructor that
|
||||
///// links up the things to do.
|
||||
///// </summary>
|
||||
//public class DmChassisControllerApi : DeviceApiBase
|
||||
//{
|
||||
// IntFeedback Output1Feedback;
|
||||
// IntFeedback Output2Feedback;
|
||||
|
||||
public DmChassisControllerApi(DmChassisController dev)
|
||||
{
|
||||
Output1Feedback = new IntFeedback( new Func<int>(() => 1));
|
||||
Output2Feedback = new IntFeedback( new Func<int>(() => 2));
|
||||
// public DmChassisControllerApi(DmChassisController dev)
|
||||
// {
|
||||
// Output1Feedback = new IntFeedback( new Func<int>(() => 1));
|
||||
// Output2Feedback = new IntFeedback( new Func<int>(() => 2));
|
||||
|
||||
ActionApi = new Dictionary<string, Object>
|
||||
{
|
||||
// ActionApi = new Dictionary<string, Object>
|
||||
// {
|
||||
|
||||
};
|
||||
// };
|
||||
|
||||
FeedbackApi = new Dictionary<string, Feedback>
|
||||
{
|
||||
{ "Output-1/fb", Output1Feedback },
|
||||
{ "Output-2/fb", Output2Feedback }
|
||||
};
|
||||
}
|
||||
// FeedbackApi = new Dictionary<string, Feedback>
|
||||
// {
|
||||
// { "Output-1/fb", Output1Feedback },
|
||||
// { "Output-2/fb", Output2Feedback }
|
||||
// };
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// Factory method
|
||||
/// </summary>
|
||||
/// <param name="dev"></param>
|
||||
/// <returns></returns>
|
||||
public static DmChassisControllerApi GetActionApiForDevice(DmChassisController dev)
|
||||
{
|
||||
return new DmChassisControllerApi(dev);
|
||||
}
|
||||
}
|
||||
// /// <summary>
|
||||
// /// Factory method
|
||||
// /// </summary>
|
||||
// /// <param name="dev"></param>
|
||||
// /// <returns></returns>
|
||||
// public static DmChassisControllerApi GetActionApiForDevice(DmChassisController dev)
|
||||
// {
|
||||
// return new DmChassisControllerApi(dev);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.Routing;
|
||||
using PepperDash.Essentials.Bridges;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.EthernetCommunication;
|
||||
|
||||
@@ -16,7 +17,7 @@ namespace PepperDash.Essentials
|
||||
{
|
||||
public class BridgeFactory
|
||||
{
|
||||
public static IKeyed GetDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc)
|
||||
public static IKeyed GetDevice(DeviceConfig dc)
|
||||
{
|
||||
// ? why is this static JTA 2018-06-13?
|
||||
|
||||
@@ -25,22 +26,18 @@ namespace PepperDash.Essentials
|
||||
var type = dc.Type;
|
||||
var properties = dc.Properties;
|
||||
var propAnon = new { };
|
||||
JsonConvert.DeserializeAnonymousType(dc.Properties.ToString(), propAnon);
|
||||
|
||||
var typeName = dc.Type.ToLower();
|
||||
var groupName = dc.Group.ToLower();
|
||||
|
||||
Debug.Console(0, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString());
|
||||
if (typeName == "dm")
|
||||
|
||||
if (typeName == "eiscapi")
|
||||
{
|
||||
return new DmBridge(key, name, properties);
|
||||
return new EiscApi(dc);
|
||||
}
|
||||
else if (typeName == "comm")
|
||||
{
|
||||
return new CommBridge(key, name, properties);
|
||||
}
|
||||
else
|
||||
return null;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,81 +9,74 @@ using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.DM;
|
||||
|
||||
namespace PepperDash.Essentials.Bridges.TEST
|
||||
namespace PepperDash.Essentials.Bridges
|
||||
{
|
||||
public static class IBasicCommunicationExtensions
|
||||
{
|
||||
public static void LinkToApi(this GenericComm comm, BasicTriList trilist, uint joinStart)
|
||||
{
|
||||
// this is a permanent event handler. This cannot be -= from event
|
||||
comm.CommPort.TextReceived += (s, a) => trilist.SetString(joinStart, a.Text);
|
||||
trilist.SetStringSigAction(joinStart, new Action<string>(s => comm.CommPort.SendText(s)));
|
||||
trilist.SetStringSigAction(joinStart + 1, new Action<string>(s => comm.SetPortConfig(s)));
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static class DmChassisControllerApiExtensions
|
||||
{
|
||||
public static void LinkToApi(this PepperDash.Essentials.DM.DmChassisController chassis,
|
||||
BasicTriList trilist, Dictionary<string,uint> map, uint joinstart)
|
||||
{
|
||||
uint joinOffset = joinstart - 1;
|
||||
var sComm = comm.CommPort as ISocketStatus;
|
||||
if (sComm != null)
|
||||
{
|
||||
sComm.ConnectionChange += (s, a) =>
|
||||
{
|
||||
trilist.SetUshort(joinStart, (ushort)(a.Client.ClientStatus));
|
||||
trilist.SetBool(joinStart, a.Client.ClientStatus ==
|
||||
Crestron.SimplSharp.CrestronSockets.SocketStatus.SOCKET_STATUS_CONNECTED);
|
||||
};
|
||||
|
||||
uint videoSelectOffset = 0 + joinOffset;
|
||||
uint audioSelectOffset = 40 + joinOffset;
|
||||
trilist.SetBoolSigAction(joinStart, new Action<bool>(b =>
|
||||
{
|
||||
if (b)
|
||||
{
|
||||
sComm.Connect();
|
||||
}
|
||||
else
|
||||
{
|
||||
sComm.Disconnect();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
///// <summary>
|
||||
/////
|
||||
///// </summary>
|
||||
//public static class DmChassisControllerApiExtensions
|
||||
//{
|
||||
// public static void LinkToApi(this PepperDash.Essentials.DM.DmChassisController chassis,
|
||||
// BasicTriList trilist, Dictionary<string,uint> map, uint joinstart)
|
||||
// {
|
||||
// uint joinOffset = joinstart - 1;
|
||||
|
||||
// uint videoSelectOffset = 0 + joinOffset;
|
||||
// uint audioSelectOffset = 40 + joinOffset;
|
||||
|
||||
|
||||
// loop chassis number of inupts
|
||||
for (uint i = 1; i <= chassis.Chassis.NumberOfOutputs; i++)
|
||||
{
|
||||
trilist.SetUShortSigAction(videoSelectOffset + i, new Action<ushort>(u => chassis.ExecuteSwitch(u, i, eRoutingSignalType.Video)));
|
||||
trilist.SetUShortSigAction(audioSelectOffset + i, new Action<ushort>(u => chassis.ExecuteSwitch(u, i, eRoutingSignalType.Audio)));
|
||||
}
|
||||
// // loop chassis number of inupts
|
||||
// for (uint i = 1; i <= chassis.Chassis.NumberOfOutputs; i++)
|
||||
// {
|
||||
// trilist.SetUShortSigAction(videoSelectOffset + i, new Action<ushort>(u => chassis.ExecuteSwitch(u, i, eRoutingSignalType.Video)));
|
||||
// trilist.SetUShortSigAction(audioSelectOffset + i, new Action<ushort>(u => chassis.ExecuteSwitch(u, i, eRoutingSignalType.Audio)));
|
||||
// }
|
||||
|
||||
// wire up output change detection (try to add feedbacks or something to DMChassisController??
|
||||
// // wire up output change detection (try to add feedbacks or something to DMChassisController??
|
||||
|
||||
// names?
|
||||
// // names?
|
||||
|
||||
// HDCP?
|
||||
// // HDCP?
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// For trilists to com sockets only
|
||||
/// </summary>
|
||||
public static class IBasicCommunicationApiExtensions
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="comm"></param>
|
||||
/// <param name="trilist"></param>
|
||||
/// <param name="joinStart"></param>
|
||||
public static void LinkToApi(this IBasicCommunication comm, BasicTriList trilist, uint joinStart)
|
||||
{
|
||||
// this is a permanent event handler. This cannot be -= from event
|
||||
comm.TextReceived += (s, a) => trilist.SetString(joinStart, a.Text);
|
||||
trilist.SetStringSigAction(joinStart, new Action<string>(s => comm.SendText(s)));
|
||||
|
||||
var sComm = comm as ISocketStatus;
|
||||
if (sComm != null)
|
||||
{
|
||||
sComm.ConnectionChange += (s, a) =>
|
||||
{
|
||||
trilist.SetUshort(joinStart, (ushort)(a.Client.ClientStatus));
|
||||
trilist.SetBool(joinStart, a.Client.ClientStatus ==
|
||||
Crestron.SimplSharp.CrestronSockets.SocketStatus.SOCKET_STATUS_CONNECTED);
|
||||
};
|
||||
|
||||
trilist.SetBoolSigAction(joinStart, new Action<bool>(b =>
|
||||
{
|
||||
if (b)
|
||||
{
|
||||
sComm.Connect();
|
||||
}
|
||||
else
|
||||
{
|
||||
sComm.Disconnect();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -231,9 +231,12 @@ namespace PepperDash.Essentials
|
||||
continue;
|
||||
}
|
||||
|
||||
// Try local factory first
|
||||
// Try local factories first
|
||||
var newDev = DeviceFactory.GetDevice(devConf);
|
||||
|
||||
if (newDev == null)
|
||||
newDev = BridgeFactory.GetDevice(devConf);
|
||||
|
||||
// Then associated library factories
|
||||
if (newDev == null)
|
||||
newDev = PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf);
|
||||
|
||||
@@ -112,6 +112,7 @@
|
||||
<Compile Include="Audio\EssentialsVolumeLevelConfig.cs" />
|
||||
<Compile Include="Bridges\BridgeBase.cs" />
|
||||
<Compile Include="Bridges\BridgeFactory.cs" />
|
||||
<Compile Include="Bridges\IBasicCommunicationBridgeMap.cs" />
|
||||
<Compile Include="Configuration ORIGINAL\Builders\TPConfig.cs" />
|
||||
<Compile Include="Configuration ORIGINAL\Configuration.cs" />
|
||||
<Compile Include="Configuration ORIGINAL\ConfigurationHelpers.cs" />
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Submodule essentials-framework updated: ae1719ee9b...88149415b7
Reference in New Issue
Block a user