generated from PepperDash/EssentialsPluginTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
184 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
using System; | ||
|
||
namespace PanasonicProjectorEpi | ||
{ | ||
public class IpCommandBuilder:ICommandBuilder | ||
{ | ||
private const string CommandWithParameterOnly = "00{0}:{1}"; | ||
private const string CommandOnly = "00{0}"; | ||
|
||
public string Delimiter | ||
{ | ||
get { return "\r"; } | ||
} | ||
|
||
public string GetCommand(string cmd, string parameter) | ||
{ | ||
return String.Format("00{0}:{1}{2}", cmd, parameter, Delimiter); | ||
} | ||
|
||
public string GetCommand(string cmd) | ||
{ | ||
return String.Format("00{0}{1}", cmd, Delimiter); | ||
} | ||
} | ||
namespace PepperDash.Essentials.Plugins.Display.Panasonic.Projector | ||
{ | ||
public class IpCommandBuilder:ICommandBuilder | ||
{ | ||
private const string CommandWithParameterOnly = "00{0}:{1}"; | ||
private const string CommandOnly = "00{0}"; | ||
|
||
public string Delimiter | ||
{ | ||
get { return "\r"; } | ||
} | ||
|
||
public string GetCommand(string cmd, string parameter) | ||
{ | ||
return String.Format("00{0}:{1}{2}", cmd, parameter, Delimiter); | ||
} | ||
|
||
public string GetCommand(string cmd) | ||
{ | ||
return String.Format("00{0}{1}", cmd, Delimiter); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
using PepperDash.Core; | ||
using PepperDash.Core; | ||
using PepperDash.Essentials.Core; | ||
|
||
namespace PanasonicProjectorEpi | ||
{ | ||
public class PanasonicStatusMonitor : StatusMonitorBase | ||
{ | ||
public PanasonicStatusMonitor(IKeyed parent, ICommunicationReceiver coms, long warningTime, long errorTime) | ||
: base(parent, warningTime, errorTime) | ||
{ | ||
coms.TextReceived += (sender, args) => | ||
{ | ||
Status = MonitorStatus.IsOk; | ||
ResetErrorTimers(); | ||
}; | ||
} | ||
|
||
public override void Start() | ||
{ | ||
StartErrorTimers(); | ||
} | ||
|
||
public override void Stop() | ||
{ | ||
StopErrorTimers(); | ||
} | ||
} | ||
namespace PepperDash.Essentials.Plugins.Display.Panasonic.Projector | ||
{ | ||
public class PanasonicStatusMonitor : StatusMonitorBase | ||
{ | ||
public PanasonicStatusMonitor(IKeyed parent, ICommunicationReceiver coms, long warningTime, long errorTime) | ||
: base(parent, warningTime, errorTime) | ||
{ | ||
coms.TextReceived += (sender, args) => | ||
{ | ||
Status = MonitorStatus.IsOk; | ||
ResetErrorTimers(); | ||
}; | ||
} | ||
|
||
public override void Start() | ||
{ | ||
StartErrorTimers(); | ||
} | ||
|
||
public override void Stop() | ||
{ | ||
StopErrorTimers(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,28 @@ | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json; | ||
using PepperDash.Essentials.Core; | ||
|
||
namespace PanasonicProjectorEpi | ||
{ | ||
/// <summary> | ||
/// Plugin device configuration object | ||
/// </summary> | ||
/// <remarks> | ||
/// Rename the class to match the device plugin being created | ||
/// </remarks> | ||
[ConfigSnippet("\"properties\":{\"control\":{}")] | ||
public class PanasonicProjectorControllerConfig | ||
{ | ||
[JsonProperty("control")] | ||
public EssentialsControlPropertiesConfig Control { get; set; } | ||
|
||
[JsonProperty("id")] | ||
public string Id { get; set; } | ||
|
||
[JsonProperty("warmupTimeInSeconds")] | ||
public long WarmupTimeInSeconds { get; set; } | ||
|
||
[JsonProperty("cooldownTimeInSeconds")] | ||
public long CooldownTimeInSeconds { get; set; } | ||
} | ||
namespace PepperDash.Essentials.Plugins.Display.Panasonic.Projector | ||
{ | ||
/// <summary> | ||
/// Plugin device configuration object | ||
/// </summary> | ||
/// <remarks> | ||
/// Rename the class to match the device plugin being created | ||
/// </remarks> | ||
[ConfigSnippet("\"properties\":{\"control\":{}")] | ||
public class PanasonicProjectorControllerConfig | ||
{ | ||
[JsonProperty("control")] | ||
public EssentialsControlPropertiesConfig Control { get; set; } | ||
|
||
[JsonProperty("id")] | ||
public string Id { get; set; } | ||
|
||
[JsonProperty("warmupTimeInSeconds")] | ||
public long WarmupTimeInSeconds { get; set; } | ||
|
||
[JsonProperty("cooldownTimeInSeconds")] | ||
public long CooldownTimeInSeconds { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,55 @@ | ||
using System.Collections.Generic; | ||
using PepperDash.Core; | ||
using PepperDash.Essentials.Core; | ||
using PepperDash.Essentials.Core.Config; | ||
using Crestron.SimplSharpPro.UI; | ||
using PepperDash.Core; | ||
using PepperDash.Essentials.Core; | ||
using PepperDash.Essentials.Core.Config; | ||
using System.Collections.Generic; | ||
|
||
namespace PepperDash.Essentials.Plugins.Display.Panasonic.Projector | ||
{ | ||
/// <summary> | ||
/// Plugin device factory for devices that use IBasicCommunication | ||
/// </summary> | ||
public class PanasonicProjectorControllerFactory : EssentialsPluginDeviceFactory<PanasonicProjectorController> | ||
{ | ||
/// <summary> | ||
/// Plugin device factory constructor | ||
/// </summary> | ||
public PanasonicProjectorControllerFactory() | ||
{ | ||
// Set the minimum Essentials Framework Version | ||
MinimumEssentialsFrameworkVersion = "1.7.5"; | ||
|
||
// In the constructor we initialize the list with the typenames that will build an instance of this device | ||
TypeNames = new List<string> { "panasonicProjector" }; | ||
} | ||
|
||
/// <summary> | ||
/// Builds and returns an instance of EssentialsPluginDeviceTemplate | ||
/// </summary> | ||
/// <param name="dc">device configuration</param> | ||
public override EssentialsDevice BuildDevice(DeviceConfig dc) | ||
{ | ||
Debug.Console(1, "[{0}] Factory Attempting to create new device from type: {1}", dc.Key, dc.Type); | ||
|
||
// get the plugin device properties configuration object & check for null | ||
var propertiesConfig = dc.Properties.ToObject<PanasonicProjectorControllerConfig>(); | ||
if (propertiesConfig == null) | ||
{ | ||
Debug.Console(0, "[{0}] Factory: failed to read properties config for {1}", dc.Key, dc.Name); | ||
return null; | ||
} | ||
|
||
// attempt build the plugin device comms device & check for null | ||
var comms = CommFactory.CreateCommForDevice(dc); | ||
|
||
if (comms != null) | ||
{ | ||
return new PanasonicProjectorController(dc.Key, dc.Name, propertiesConfig, comms); | ||
} | ||
|
||
Debug.Console(1, "[{0}] Factory Notice: No control object present for device {1}", dc.Key, dc.Name); | ||
return null; | ||
} | ||
} | ||
} | ||
|
||
namespace PanasonicProjectorEpi | ||
{ | ||
/// <summary> | ||
/// Plugin device factory for devices that use IBasicCommunication | ||
/// </summary> | ||
/// <remarks> | ||
/// Rename the class to match the device plugin being developed | ||
/// </remarks> | ||
/// <example> | ||
/// "PanasonicProjectorControllerFactory" renamed to "MyDeviceFactory" | ||
/// </example> | ||
public class PanasonicProjectorControllerFactory : EssentialsPluginDeviceFactory<PanasonicProjectorController> | ||
{ | ||
/// <summary> | ||
/// Plugin device factory constructor | ||
/// </summary> | ||
/// <remarks> | ||
/// Update the MinimumEssentialsFrameworkVersion & TypeNames as needed when creating a plugin | ||
/// </remarks> | ||
/// <example> | ||
/// Set the minimum Essentials Framework Version | ||
/// <code> | ||
/// MinimumEssentialsFrameworkVersion = "1.6.4; | ||
/// </code> | ||
/// In the constructor we initialize the list with the typenames that will build an instance of this device | ||
/// <code> | ||
/// TypeNames = new List<string>() { "SamsungMdc", "SamsungMdcDisplay" }; | ||
/// </code> | ||
/// </example> | ||
public PanasonicProjectorControllerFactory() | ||
{ | ||
// Set the minimum Essentials Framework Version | ||
MinimumEssentialsFrameworkVersion = "1.7.5"; | ||
|
||
// In the constructor we initialize the list with the typenames that will build an instance of this device | ||
TypeNames = new List<string> { "panasonicProjector" }; | ||
} | ||
|
||
/// <summary> | ||
/// Builds and returns an instance of EssentialsPluginDeviceTemplate | ||
/// </summary> | ||
/// <param name="dc">device configuration</param> | ||
/// <returns>plugin device or null</returns> | ||
/// <remarks> | ||
/// The example provided below takes the device key, name, properties config and the comms device created. | ||
/// Modify the EssetnialsPlugingDeviceTemplate constructor as needed to meet the requirements of the plugin device. | ||
/// </remarks> | ||
/// <seealso cref="PepperDash.Core.eControlMethod"/> | ||
public override EssentialsDevice BuildDevice(DeviceConfig dc) | ||
{ | ||
Debug.Console(1, "[{0}] Factory Attempting to create new device from type: {1}", dc.Key, dc.Type); | ||
|
||
// get the plugin device properties configuration object & check for null | ||
var propertiesConfig = dc.Properties.ToObject<PanasonicProjectorControllerConfig>(); | ||
if (propertiesConfig == null) | ||
{ | ||
Debug.Console(0, "[{0}] Factory: failed to read properties config for {1}", dc.Key, dc.Name); | ||
return null; | ||
} | ||
|
||
// attempt build the plugin device comms device & check for null | ||
var comms = CommFactory.CreateCommForDevice(dc); | ||
|
||
if (comms != null) | ||
{ | ||
return new PanasonicProjectorController(dc.Key, dc.Name, propertiesConfig, comms); | ||
} | ||
|
||
Debug.Console(1, "[{0}] Factory Notice: No control object present for device {1}", dc.Key, dc.Name); | ||
return null; | ||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
using System; | ||
using System; | ||
using PepperDash.Essentials.Core.Queues; | ||
|
||
namespace PanasonicProjectorEpi | ||
{ | ||
public class QueueMessage:IQueueMessage | ||
{ | ||
private readonly Action _dispatchAction; | ||
|
||
public QueueMessage(Action dispatchAction) | ||
{ | ||
_dispatchAction = dispatchAction; | ||
} | ||
|
||
public void Dispatch() | ||
{ | ||
var handler = _dispatchAction; | ||
|
||
if (handler == null) | ||
{ | ||
return; | ||
} | ||
|
||
handler(); | ||
} | ||
} | ||
namespace PepperDash.Essentials.Plugins.Display.Panasonic.Projector | ||
{ | ||
public class QueueMessage:IQueueMessage | ||
{ | ||
private readonly Action _dispatchAction; | ||
|
||
public QueueMessage(Action dispatchAction) | ||
{ | ||
_dispatchAction = dispatchAction; | ||
} | ||
|
||
public void Dispatch() | ||
{ | ||
var handler = _dispatchAction; | ||
|
||
if (handler == null) | ||
{ | ||
return; | ||
} | ||
|
||
handler(); | ||
} | ||
} | ||
} |
Oops, something went wrong.