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.
refactor: rename config.cs and factory.cs files
- Loading branch information
Showing
2 changed files
with
77 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Newtonsoft.Json; | ||
using PepperDash.Essentials.Core; | ||
|
||
namespace PepperDash.Essentials.Plugins.Display.Panasonic.Projector | ||
{ | ||
/// <summary> | ||
/// Plugin device configuration object | ||
/// </summary> | ||
public class PanasonicProjectorConfig | ||
{ | ||
[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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
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 PanasonicProjectorFactory : EssentialsPluginDeviceFactory<PanasonicProjectorController> | ||
{ | ||
/// <summary> | ||
/// Plugin device factory constructor | ||
/// </summary> | ||
public PanasonicProjectorFactory() | ||
{ | ||
// Set the minimum Essentials Framework Version | ||
MinimumEssentialsFrameworkVersion = "1.11.1"; | ||
|
||
// 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<PanasonicProjectorConfig>(); | ||
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; | ||
} | ||
} | ||
} | ||
|