Skip to content

Commit

Permalink
Adds example of GenericQueue on EssentialsPluginTemplateDevice and up…
Browse files Browse the repository at this point in the history
…dates dependency version to 1.7.5
  • Loading branch information
ndorin committed Feb 5, 2021
1 parent dc0b129 commit 4143783
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Bridges;
using PepperDash_Essentials_Core.Queues;


namespace EssentialsPluginTemplate
{
Expand All @@ -24,6 +26,11 @@ public class EssentialsPluginTemplateDevice : EssentialsBridgeableDevice
/// </summary>
private EssentialsPluginConfigObjectTemplate _config;

/// <summary>
/// Provides a queue and dedicated worker thread for processing feedback messages from a device.
/// </summary>
private GenericQueue ReceiveQueue;

#region IBasicCommunication Properties and Constructor. Remove if not needed.

// TODO [ ] Add, modify, remove properties and fields as needed for the plugin being developed
Expand Down Expand Up @@ -100,6 +107,8 @@ public EssentialsPluginTemplateDevice(string key, string name, EssentialsPluginC

_config = config;

ReceiveQueue = new GenericQueue(key + "-rxqueue"); // If you need to set the thread priority, use one of the available overloaded constructors.

ConnectFeedback = new BoolFeedback(() => Connect);
OnlineFeedback = new BoolFeedback(() => _commsMonitor.IsOnline);
StatusFeedback = new IntFeedback(() => (int)_commsMonitor.Status);
Expand Down Expand Up @@ -149,7 +158,9 @@ private void socket_ConnectionChange(object sender, GenericSocketStatusChageEven
private void Handle_LineRecieved(object sender, GenericCommMethodReceiveTextArgs args)
{
// TODO [ ] Implement method
throw new System.NotImplementedException();

// Enqueues the message to be processed in a dedicated thread, but the specified method
ReceiveQueue.Enqueue(new ProcessStringMessage(args.Text, ProcessFeedbackMessage));
}

// TODO [ ] If not using an HEX/byte based API with no delimeter, delete the method below
Expand All @@ -166,6 +177,15 @@ void Handle_TextReceived(object sender, GenericCommMethodReceiveTextArgs e)
throw new System.NotImplementedException();
}

/// <summary>
/// This method should perform any necessary parsing of feedback messages from the device
/// </summary>
/// <param name="message"></param>
void ProcessFeedbackMessage(string message)
{

}


// TODO [ ] If not using an ACII based API, delete the properties below
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public EssentialsPluginFactoryCrestronDeviceTemplate()
{
// Set the minimum Essentials Framework Version
// TODO [ ] Update the Essentials minimum framework version which this plugin has been tested against
MinimumEssentialsFrameworkVersion = "1.6.4";
MinimumEssentialsFrameworkVersion = "1.7.5";

// In the constructor we initialize the list with the typenames that will build an instance of this device
// TODO [ ] Update the TypeNames for the plugin being developed
Expand Down
2 changes: 1 addition & 1 deletion packages.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<packages>
<package id="PepperDashEssentials" version="1.6.4" targetFramework="net35" allowedVersions="[1.0,2.0)"/>
<package id="PepperDashEssentials" version="1.7.5" targetFramework="net35" allowedVersions="[1.0,2.0)"/>
</packages>

0 comments on commit 4143783

Please sign in to comment.