mirror of
https://github.com/PepperDash/EssentialsPluginTemplate.git
synced 2026-02-11 02:34:41 +00:00
Compare commits
4 Commits
docs/versi
...
templateCl
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
788bbd2c6d | ||
|
|
45f5bfb8ef | ||
|
|
4fd9dd739e | ||
|
|
46ba57bac5 |
@@ -1,99 +0,0 @@
|
|||||||
// For Basic SIMPL# Classes
|
|
||||||
// For Basic SIMPL#Pro classes
|
|
||||||
|
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
|
||||||
using Crestron.SimplSharpPro;
|
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core;
|
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
|
||||||
|
|
||||||
namespace EssentialsPluginTemplate
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Plugin device
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// Rename the class to match the device plugin being developed.
|
|
||||||
/// </remarks>
|
|
||||||
/// <example>
|
|
||||||
/// "EssentialsPluginDeviceTemplate" renamed to "SamsungMdcDevice"
|
|
||||||
/// </example>
|
|
||||||
public class EssentialsPluginTemplateCrestronDevice : CrestronGenericBridgeableBaseDevice
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// It is often desirable to store the config
|
|
||||||
/// </summary>
|
|
||||||
private EssentialsPluginTemplateConfigObject _config;
|
|
||||||
|
|
||||||
|
|
||||||
#region Constructor for Devices without IBasicCommunication. Remove if not needed
|
|
||||||
/// <summary>
|
|
||||||
/// Plugin device constructor for Crestron devices
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <param name="name"></param>
|
|
||||||
/// <param name="config"></param>
|
|
||||||
/// <param name="hardware"></param>
|
|
||||||
public EssentialsPluginTemplateCrestronDevice(string key, string name, EssentialsPluginTemplateConfigObject config, GenericBase hardware)
|
|
||||||
: base(key, name, hardware)
|
|
||||||
{
|
|
||||||
Debug.Console(0, this, "Constructing new {0} instance", name);
|
|
||||||
|
|
||||||
// The base class takes care of registering the hardware device for you
|
|
||||||
|
|
||||||
// TODO [ ] Update the constructor as needed for the plugin device being developed
|
|
||||||
|
|
||||||
_config = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
#region Overrides of EssentialsBridgeableDevice
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Links the plugin device to the EISC bridge
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="trilist"></param>
|
|
||||||
/// <param name="joinStart"></param>
|
|
||||||
/// <param name="joinMapKey"></param>
|
|
||||||
/// <param name="bridge"></param>
|
|
||||||
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
|
|
||||||
{
|
|
||||||
var joinMap = new EssentialsPluginTemplateBridgeJoinMap(joinStart);
|
|
||||||
|
|
||||||
// This adds the join map to the collection on the bridge
|
|
||||||
if (bridge != null)
|
|
||||||
{
|
|
||||||
bridge.AddJoinMap(Key, joinMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey);
|
|
||||||
|
|
||||||
if (customJoins != null)
|
|
||||||
{
|
|
||||||
joinMap.SetCustomJoinData(customJoins);
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
|
||||||
Debug.Console(0, "Linking to Bridge Type {0}", GetType().Name);
|
|
||||||
|
|
||||||
// TODO [ ] Implement bridge links as needed
|
|
||||||
|
|
||||||
// links to bridge
|
|
||||||
trilist.SetString(joinMap.DeviceName.JoinNumber, Name);
|
|
||||||
|
|
||||||
trilist.OnlineStatusChange += (o, a) =>
|
|
||||||
{
|
|
||||||
if (!a.DeviceOnLine) return;
|
|
||||||
|
|
||||||
trilist.SetString(joinMap.DeviceName.JoinNumber, Name);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,7 +1,4 @@
|
|||||||
// For Basic SIMPL# Classes
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
// For Basic SIMPL#Pro classes
|
|
||||||
|
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
@@ -21,9 +18,6 @@ namespace EssentialsPluginTemplate
|
|||||||
/// </example>
|
/// </example>
|
||||||
public class EssentialsPluginTemplateDevice : EssentialsBridgeableDevice
|
public class EssentialsPluginTemplateDevice : EssentialsBridgeableDevice
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// It is often desirable to store the config
|
|
||||||
/// </summary>
|
|
||||||
private EssentialsPluginTemplateConfigObject _config;
|
private EssentialsPluginTemplateConfigObject _config;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -33,21 +27,14 @@ namespace EssentialsPluginTemplate
|
|||||||
|
|
||||||
#region IBasicCommunication Properties and Constructor. Remove if not needed.
|
#region IBasicCommunication Properties and Constructor. Remove if not needed.
|
||||||
|
|
||||||
// TODO [ ] Add, modify, remove properties and fields as needed for the plugin being developed
|
|
||||||
private readonly IBasicCommunication _comms;
|
private readonly IBasicCommunication _comms;
|
||||||
private readonly GenericCommunicationMonitor _commsMonitor;
|
private readonly GenericCommunicationMonitor _commsMonitor;
|
||||||
|
|
||||||
// _comms gather for ASCII based API's
|
|
||||||
// TODO [ ] If not using an ASCII based API, delete the properties below
|
|
||||||
private readonly CommunicationGather _commsGather;
|
private readonly CommunicationGather _commsGather;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Set this value to that of the delimiter used by the API (if applicable)
|
/// Set this value to that of the delimiter used by the API (if applicable)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private const string CommsDelimiter = "\r";
|
private const string CommsDelimiter = "\r";
|
||||||
|
|
||||||
// _comms byte buffer for HEX/byte based API's
|
|
||||||
// TODO [ ] If not using an HEX/byte based API, delete the properties below
|
|
||||||
private byte[] _commsByteBuffer = { };
|
private byte[] _commsByteBuffer = { };
|
||||||
|
|
||||||
|
|
||||||
@@ -103,11 +90,9 @@ namespace EssentialsPluginTemplate
|
|||||||
{
|
{
|
||||||
Debug.Console(0, this, "Constructing new {0} instance", name);
|
Debug.Console(0, this, "Constructing new {0} instance", name);
|
||||||
|
|
||||||
// TODO [ ] Update the constructor as needed for the plugin device being developed
|
|
||||||
|
|
||||||
_config = config;
|
_config = config;
|
||||||
|
|
||||||
ReceiveQueue = new GenericQueue(key + "-rxqueue"); // If you need to set the thread priority, use one of the available overloaded constructors.
|
ReceiveQueue = new GenericQueue(key + "-rxqueue");
|
||||||
|
|
||||||
ConnectFeedback = new BoolFeedback(() => Connect);
|
ConnectFeedback = new BoolFeedback(() => Connect);
|
||||||
OnlineFeedback = new BoolFeedback(() => _commsMonitor.IsOnline);
|
OnlineFeedback = new BoolFeedback(() => _commsMonitor.IsOnline);
|
||||||
@@ -119,26 +104,15 @@ namespace EssentialsPluginTemplate
|
|||||||
var socket = _comms as ISocketStatus;
|
var socket = _comms as ISocketStatus;
|
||||||
if (socket != null)
|
if (socket != null)
|
||||||
{
|
{
|
||||||
// device comms is IP **ELSE** device comms is RS232
|
|
||||||
socket.ConnectionChange += socket_ConnectionChange;
|
socket.ConnectionChange += socket_ConnectionChange;
|
||||||
Connect = true;
|
Connect = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Communication data event handlers. Comment out any that don't apply to the API type
|
#region Communication data event handlers. Comment out any that don't apply to the API type
|
||||||
|
|
||||||
// Only one of the below handlers should be necessary.
|
|
||||||
|
|
||||||
// _comms gather for any API that has a defined delimiter
|
|
||||||
// TODO [ ] If not using an ASCII based API, remove the line below
|
|
||||||
_commsGather = new CommunicationGather(_comms, CommsDelimiter);
|
_commsGather = new CommunicationGather(_comms, CommsDelimiter);
|
||||||
_commsGather.LineReceived += Handle_LineRecieved;
|
_commsGather.LineReceived += Handle_LineRecieved;
|
||||||
|
|
||||||
// _comms byte buffer for HEX/byte based API's with no delimiter
|
|
||||||
// TODO [ ] If not using an HEX/byte based API, remove the line below
|
|
||||||
_comms.BytesReceived += Handle_BytesReceived;
|
_comms.BytesReceived += Handle_BytesReceived;
|
||||||
|
|
||||||
// _comms byte buffer for HEX/byte based API's with no delimiter
|
|
||||||
// TODO [ ] If not using an HEX/byte based API, remove the line below
|
|
||||||
_comms.TextReceived += Handle_TextReceived;
|
_comms.TextReceived += Handle_TextReceived;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -154,26 +128,18 @@ namespace EssentialsPluginTemplate
|
|||||||
StatusFeedback.FireUpdate();
|
StatusFeedback.FireUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO [ ] If not using an API with a delimeter, delete the method below
|
|
||||||
private void Handle_LineRecieved(object sender, GenericCommMethodReceiveTextArgs args)
|
private void Handle_LineRecieved(object sender, GenericCommMethodReceiveTextArgs args)
|
||||||
{
|
{
|
||||||
// TODO [ ] Implement method
|
|
||||||
|
|
||||||
// Enqueues the message to be processed in a dedicated thread, but the specified method
|
|
||||||
ReceiveQueue.Enqueue(new ProcessStringMessage(args.Text, ProcessFeedbackMessage));
|
ReceiveQueue.Enqueue(new ProcessStringMessage(args.Text, ProcessFeedbackMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO [ ] If not using an HEX/byte based API with no delimeter, delete the method below
|
|
||||||
private void Handle_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs args)
|
private void Handle_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs args)
|
||||||
{
|
{
|
||||||
// TODO [ ] Implement method
|
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO [ ] If not using an ASCII based API with no delimeter, delete the method below
|
|
||||||
void Handle_TextReceived(object sender, GenericCommMethodReceiveTextArgs e)
|
void Handle_TextReceived(object sender, GenericCommMethodReceiveTextArgs e)
|
||||||
{
|
{
|
||||||
// TODO [ ] Implement method
|
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,11 +149,9 @@ namespace EssentialsPluginTemplate
|
|||||||
/// <param name="message"></param>
|
/// <param name="message"></param>
|
||||||
void ProcessFeedbackMessage(string message)
|
void ProcessFeedbackMessage(string message)
|
||||||
{
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO [ ] If not using an ACII based API, delete the properties below
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends text to the device plugin comms
|
/// Sends text to the device plugin comms
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -199,10 +163,9 @@ namespace EssentialsPluginTemplate
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(text)) return;
|
if (string.IsNullOrEmpty(text)) return;
|
||||||
|
|
||||||
_comms.SendText(string.Format("{0}{1}", text, CommsDelimiter));
|
_comms.SendText($"{text}{CommsDelimiter}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO [ ] If not using an HEX/byte based API, delete the properties below
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends bytes to the device plugin comms
|
/// Sends bytes to the device plugin comms
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -225,8 +188,6 @@ namespace EssentialsPluginTemplate
|
|||||||
/// </remarks>
|
/// </remarks>
|
||||||
public void Poll()
|
public void Poll()
|
||||||
{
|
{
|
||||||
// TODO [ ] Update Poll method as needed for the plugin being developed
|
|
||||||
// Example: SendText("getstatus");
|
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,7 +207,6 @@ namespace EssentialsPluginTemplate
|
|||||||
{
|
{
|
||||||
var joinMap = new EssentialsPluginTemplateBridgeJoinMap(joinStart);
|
var joinMap = new EssentialsPluginTemplateBridgeJoinMap(joinStart);
|
||||||
|
|
||||||
// This adds the join map to the collection on the bridge
|
|
||||||
if (bridge != null)
|
if (bridge != null)
|
||||||
{
|
{
|
||||||
bridge.AddJoinMap(Key, joinMap);
|
bridge.AddJoinMap(Key, joinMap);
|
||||||
@@ -262,9 +222,7 @@ namespace EssentialsPluginTemplate
|
|||||||
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 Bridge Type {0}", GetType().Name);
|
Debug.Console(0, "Linking to Bridge Type {0}", GetType().Name);
|
||||||
|
|
||||||
// TODO [ ] Implement bridge links as needed
|
|
||||||
|
|
||||||
// links to bridge
|
|
||||||
trilist.SetString(joinMap.DeviceName.JoinNumber, Name);
|
trilist.SetString(joinMap.DeviceName.JoinNumber, Name);
|
||||||
|
|
||||||
trilist.SetBoolSigAction(joinMap.Connect.JoinNumber, sig => Connect = sig);
|
trilist.SetBoolSigAction(joinMap.Connect.JoinNumber, sig => Connect = sig);
|
||||||
@@ -286,7 +244,6 @@ namespace EssentialsPluginTemplate
|
|||||||
|
|
||||||
private void UpdateFeedbacks()
|
private void UpdateFeedbacks()
|
||||||
{
|
{
|
||||||
// TODO [ ] Update as needed for the plugin being developed
|
|
||||||
ConnectFeedback.FireUpdate();
|
ConnectFeedback.FireUpdate();
|
||||||
OnlineFeedback.FireUpdate();
|
OnlineFeedback.FireUpdate();
|
||||||
StatusFeedback.FireUpdate();
|
StatusFeedback.FireUpdate();
|
||||||
|
|||||||
@@ -1,86 +0,0 @@
|
|||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core;
|
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
|
||||||
|
|
||||||
namespace EssentialsPluginTemplate
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Plugin device template for logic devices that don't communicate outside the program
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// Rename the class to match the device plugin being developed.
|
|
||||||
/// </remarks>
|
|
||||||
/// <example>
|
|
||||||
/// "EssentialsPluginTemplateLogicDevice" renamed to "SamsungMdcDevice"
|
|
||||||
/// </example>
|
|
||||||
public class EssentialsPluginTemplateLogicDevice : EssentialsBridgeableDevice
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// It is often desirable to store the config
|
|
||||||
/// </summary>
|
|
||||||
private EssentialsPluginTemplateConfigObject _config;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Plugin device constructor
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <param name="name"></param>
|
|
||||||
/// <param name="config"></param>
|
|
||||||
public EssentialsPluginTemplateLogicDevice(string key, string name, EssentialsPluginTemplateConfigObject config)
|
|
||||||
: base(key, name)
|
|
||||||
{
|
|
||||||
Debug.Console(0, this, "Constructing new {0} instance", name);
|
|
||||||
|
|
||||||
// TODO [ ] Update the constructor as needed for the plugin device being developed
|
|
||||||
|
|
||||||
_config = config;
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Overrides of EssentialsBridgeableDevice
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Links the plugin device to the EISC bridge
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="trilist"></param>
|
|
||||||
/// <param name="joinStart"></param>
|
|
||||||
/// <param name="joinMapKey"></param>
|
|
||||||
/// <param name="bridge"></param>
|
|
||||||
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
|
|
||||||
{
|
|
||||||
var joinMap = new EssentialsPluginTemplateBridgeJoinMap(joinStart);
|
|
||||||
|
|
||||||
// This adds the join map to the collection on the bridge
|
|
||||||
if (bridge != null)
|
|
||||||
{
|
|
||||||
bridge.AddJoinMap(Key, joinMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey);
|
|
||||||
|
|
||||||
if (customJoins != null)
|
|
||||||
{
|
|
||||||
joinMap.SetCustomJoinData(customJoins);
|
|
||||||
}
|
|
||||||
|
|
||||||
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
|
||||||
Debug.Console(0, "Linking to Bridge Type {0}", GetType().Name);
|
|
||||||
|
|
||||||
// TODO [ ] Implement bridge links as needed
|
|
||||||
|
|
||||||
// links to bridge
|
|
||||||
trilist.SetString(joinMap.DeviceName.JoinNumber, Name);
|
|
||||||
|
|
||||||
trilist.OnlineStatusChange += (o, a) =>
|
|
||||||
{
|
|
||||||
if (!a.DeviceOnLine) return;
|
|
||||||
|
|
||||||
trilist.SetString(joinMap.DeviceName.JoinNumber, Name);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user