-
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.
intitial plugin creationg with base features
- overall online status - individual outlet naming, online, power
- Loading branch information
1 parent
92544e9
commit 601470a
Showing
23 changed files
with
833 additions
and
108 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using PepperDash.Core; | ||
using PepperDash.Essentials.Core; | ||
|
||
namespace ApcEpi.Abstractions | ||
{ | ||
public interface IApDevice : IKeyName, IOnline, ICommunicationMonitor, IHasFeedback | ||
{ | ||
|
||
} | ||
} |
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,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Crestron.SimplSharp; | ||
using PepperDash.Core; | ||
using PepperDash.Essentials.Core; | ||
|
||
namespace ApcEpi.Abstractions | ||
{ | ||
public interface IApDeviceBuilder : IKeyName | ||
{ | ||
ICommunicationMonitor Monitor { get; } | ||
IBasicCommunication Coms { get; } | ||
ReadOnlyDictionary<uint, IApOutlet> Outlets { get; } | ||
CTimer Poll { get; } | ||
|
||
EssentialsDevice Build(); | ||
} | ||
} |
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,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Crestron.SimplSharp; | ||
using PepperDash.Core; | ||
using PepperDash.Essentials.Core; | ||
|
||
namespace ApcEpi.Abstractions | ||
{ | ||
public interface IApOutlet : IKeyName, IOnline, IPower | ||
{ | ||
int OutletIndex { get; } | ||
StringFeedback NameFeedback { get; } | ||
} | ||
} |
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,9 @@ | ||
using PepperDash.Essentials.Core; | ||
|
||
namespace ApcEpi.Abstractions | ||
{ | ||
public interface IOutletName : IApDevice | ||
{ | ||
bool TryGetOutletNameFeedback(uint outletIndex, out StringFeedback result); | ||
} | ||
} |
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,9 @@ | ||
using PepperDash.Essentials.Core; | ||
|
||
namespace ApcEpi.Abstractions | ||
{ | ||
public interface IOutletOnline : IApDevice | ||
{ | ||
bool TryGetOutletOnlineFeedback(uint outletIndex, out BoolFeedback result); | ||
} | ||
} |
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,12 @@ | ||
using PepperDash.Essentials.Core; | ||
|
||
namespace ApcEpi.Abstractions | ||
{ | ||
public interface IOutletPower : IApDevice | ||
{ | ||
bool TryGetOutletPowerFeedback(uint outletIndex, out BoolFeedback result); | ||
void ToggleOutletPower(uint outletIndex); | ||
void TurnOutletOff(uint outletIndex); | ||
void TurnOutletOn(uint outletIndex); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
using System; | ||
using System.Linq; | ||
using ApcEpi.Abstractions; | ||
using ApcEpi.Config; | ||
using ApcEpi.Devices; | ||
using ApcEpi.Entities.Outlet; | ||
using Crestron.SimplSharp; | ||
using PepperDash.Core; | ||
using PepperDash.Essentials.Core; | ||
using PepperDash.Essentials.Core.Config; | ||
using PepperDash.Essentials.Core.Devices; | ||
|
||
namespace ApcEpi.Builders | ||
{ | ||
public class Ap89XxBuilder : IApDeviceBuilder | ||
{ | ||
public static IApDeviceBuilder GetFromDeviceConfig(DeviceConfig dc) | ||
{ | ||
var config = dc.Properties.ToObject<ApDeviceConfig>(); | ||
var coms = CommFactory.CreateCommForDevice(dc); | ||
|
||
return new Ap89XxBuilder(dc.Key, dc.Name, coms, config); | ||
} | ||
|
||
private Ap89XxBuilder(string key, string name, IBasicCommunication coms, ApDeviceConfig config) | ||
{ | ||
Coms = coms; | ||
Name = name; | ||
Key = key; | ||
Outlets = BuildOutletsFromConfig(config, coms); | ||
Monitor = new GenericCommunicationMonitoredDevice( | ||
Key, | ||
Name, | ||
Coms, | ||
"about\r"); | ||
|
||
Poll = new CTimer(_ => ApDevice.PollDevice(coms), null, Timeout.Infinite, 5000); | ||
} | ||
|
||
public static ReadOnlyDictionary<uint, IApOutlet> BuildOutletsFromConfig(ApDeviceConfig config, IBasicCommunication coms) | ||
{ | ||
var outlets = config | ||
.Outlets | ||
.Select(x => new ApOutlet(x.Key, x.Value.Name, x.Value.OutletIndex, coms)) | ||
.ToDictionary<ApOutlet, uint, IApOutlet>(outlet => (uint) outlet.OutletIndex, outlet => outlet); | ||
|
||
return new ReadOnlyDictionary<uint, IApOutlet>(outlets); | ||
} | ||
|
||
public string Key { get; private set; } | ||
public string Name { get; private set; } | ||
public ICommunicationMonitor Monitor { get; private set; } | ||
public IBasicCommunication Coms { get; private set; } | ||
public ReadOnlyDictionary<uint, IApOutlet> Outlets { get; private set; } | ||
public CTimer Poll { get; private set; } | ||
|
||
public EssentialsDevice Build() | ||
{ | ||
Debug.Console(1, this, "Building..."); | ||
return new ApDevice(this); | ||
} | ||
} | ||
} |
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,24 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using Crestron.SimplSharp; | ||
using Crestron.SimplSharpPro; | ||
using PepperDash.Core; | ||
|
||
namespace ApcEpi.Config | ||
{ | ||
public class ApDeviceConfig | ||
{ | ||
public ControlPropertiesConfig Control { get; set; } | ||
public Dictionary<string, ApOutletConfig> Outlets { get; set; } | ||
} | ||
|
||
public class ApOutletConfig | ||
{ | ||
public string Name { get; set; } | ||
public int OutletIndex { get; set; } | ||
public int DelayOn { get; set; } | ||
public int DelayOff { get; set; } | ||
} | ||
} |
Oops, something went wrong.