Skip to content

Commit

Permalink
refactor: update namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jkdevito committed Oct 1, 2024
1 parent b314439 commit 2fd56b3
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 216 deletions.
2 changes: 1 addition & 1 deletion src/ICommandBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace PanasonicProjectorEpi
namespace PepperDash.Essentials.Plugins.Display.Panasonic.Projector
{
public interface ICommandBuilder
{
Expand Down
44 changes: 22 additions & 22 deletions src/IpCommandBuilder.cs
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);
}
}
}
2 changes: 1 addition & 1 deletion src/PanasonicInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System;
using System.Collections.Generic;

namespace PanasonicProjectorEpi
namespace PepperDash.Essentials.Plugins.Display.Panasonic.Projector
{
#if SERIES4
public class PanasonicInputs : ISelectableItems<byte>
Expand Down
50 changes: 25 additions & 25 deletions src/PanasonicIpStatusMonitor.cs
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();
}
}
}
8 changes: 1 addition & 7 deletions src/PanasonicProjectorController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,11 @@
using PepperDash.Essentials.Core.Routing;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;

namespace PanasonicProjectorEpi
namespace PepperDash.Essentials.Plugins.Display.Panasonic.Projector
{
/// <summary>
/// Plugin device template for third party devices that use IBasicCommunication
/// </summary>
/// <remarks>
/// Rename the class to match the device plugin being developed.
/// </remarks>
/// <example>
/// "EssentialsPluginDeviceTemplate" renamed to "SamsungMdcDevice"
/// </example>
public class PanasonicProjectorController : TwoWayDisplayBase, IBridgeAdvanced, ICommunicationMonitor
#if SERIES4
,IHasInputs<byte, int>
Expand Down
50 changes: 25 additions & 25 deletions src/PanasonicProjectorControllerConfig.cs
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; }
}
}
132 changes: 53 additions & 79 deletions src/PanasonicProjectorControllerFactory.cs
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;
}
}
}


48 changes: 24 additions & 24 deletions src/QueueMessage.cs
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();
}
}
}
Loading

0 comments on commit 2fd56b3

Please sign in to comment.