Skip to content

Commit

Permalink
refactor: rename config.cs and factory.cs files
Browse files Browse the repository at this point in the history
  • Loading branch information
jkdevito committed Oct 1, 2024
1 parent 9195d68 commit f2c6df3
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/PanasonicProjectorConfig.cs
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; }
}
}
54 changes: 54 additions & 0 deletions src/PanasonicProjectorFactory.cs
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;
}
}
}

0 comments on commit f2c6df3

Please sign in to comment.