-
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
Trevor Payne
committed
May 4, 2023
1 parent
d9c82d1
commit 58acaed
Showing
6 changed files
with
189 additions
and
40 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
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
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,147 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using PepperDash.Essentials.Core; | ||
using PepperDash.Essentials.Core.Bridges; | ||
using PepperDash_Essentials_Core.Devices; | ||
|
||
namespace Pdu_Wattbox_Epi | ||
{ | ||
public class WattboxJoinmapDynamic : JoinMapBaseAdvanced | ||
{ | ||
public readonly PduJoinMapBase BaseJoinMap; | ||
|
||
public WattboxJoinmapDynamic(uint joinStart, IEnumerable<KeyValuePair<int, IHasPowerCycle>> pduOutlets) | ||
: base(joinStart, typeof (WattboxJoinmapDynamic)) | ||
{ | ||
BaseJoinMap = new PduJoinMapBase(joinStart); | ||
|
||
|
||
Joins.Add("Name", BaseJoinMap.Joins["Name"]); | ||
Joins.Add("Online", BaseJoinMap.Joins["Online"]); | ||
Joins.Add("OutletCount", BaseJoinMap.Joins["OutletCount"]); | ||
|
||
foreach (var index in pduOutlets.Select(outlet => outlet.Key)) | ||
{ | ||
SetOutletNameJoinData(index); | ||
SetOutletEnabledJoinData(index); | ||
SetOutletPowerCycleJoinData(index); | ||
SetOutletPowerOffJoinData(index); | ||
SetOutletPowerOnJoinData(index); | ||
} | ||
|
||
} | ||
|
||
private void SetOutletNameJoinData(int index) | ||
{ | ||
|
||
var joinData = new JoinData | ||
{ | ||
|
||
JoinNumber = (uint)((index - 1)*4 + BaseJoinMap.OutletName.JoinNumber), | ||
JoinSpan = 1 | ||
}; | ||
|
||
var joinMetaData = new JoinMetadata | ||
{ | ||
Description = string.Format("Outlet {0} Name", index), | ||
JoinCapabilities = eJoinCapabilities.ToSIMPL, | ||
JoinType = eJoinType.Serial | ||
}; | ||
|
||
var joinDataComplete = new JoinDataComplete(joinData, joinMetaData); | ||
|
||
Joins.Add(string.Format("Outlet {0} Name", index), joinDataComplete); | ||
|
||
} | ||
|
||
private void SetOutletEnabledJoinData(int index) | ||
{ | ||
|
||
var joinData = new JoinData | ||
{ | ||
|
||
JoinNumber = (uint)(((index - 1) * 4) + BaseJoinMap.OutletEnabled.JoinNumber), | ||
JoinSpan = 1 | ||
}; | ||
|
||
var joinMetaData = new JoinMetadata | ||
{ | ||
Description = string.Format("Outlet {0} Enabled", index), | ||
JoinCapabilities = eJoinCapabilities.ToSIMPL, | ||
JoinType = eJoinType.Digital | ||
}; | ||
|
||
var joinDataComplete = new JoinDataComplete(joinData, joinMetaData); | ||
|
||
Joins.Add(string.Format("Outlet {0} Enabled", index), joinDataComplete); | ||
|
||
} | ||
private void SetOutletPowerOffJoinData(int index) | ||
{ | ||
|
||
var joinData = new JoinData | ||
{ | ||
|
||
JoinNumber = (uint)(((index - 1) * 4) + BaseJoinMap.OutletPowerOff.JoinNumber), | ||
JoinSpan = 1 | ||
}; | ||
|
||
var joinMetaData = new JoinMetadata | ||
{ | ||
Description = string.Format("Outlet {0} Power Off", index), | ||
JoinCapabilities = eJoinCapabilities.ToFromSIMPL, | ||
JoinType = eJoinType.Digital | ||
}; | ||
|
||
var joinDataComplete = new JoinDataComplete(joinData, joinMetaData); | ||
|
||
Joins.Add(string.Format("Outlet {0} Power Off", index), joinDataComplete); | ||
|
||
} | ||
private void SetOutletPowerOnJoinData(int index) | ||
{ | ||
|
||
var joinData = new JoinData | ||
{ | ||
|
||
JoinNumber = (uint)(((index - 1) * 4) + BaseJoinMap.OutletPowerOn.JoinNumber), | ||
JoinSpan = 1 | ||
}; | ||
|
||
var joinMetaData = new JoinMetadata | ||
{ | ||
Description = string.Format("Outlet {0} Power On", index), | ||
JoinCapabilities = eJoinCapabilities.ToFromSIMPL, | ||
JoinType = eJoinType.Digital | ||
}; | ||
|
||
var joinDataComplete = new JoinDataComplete(joinData, joinMetaData); | ||
|
||
Joins.Add(string.Format("Outlet {0} Power On", index), joinDataComplete); | ||
|
||
} | ||
private void SetOutletPowerCycleJoinData(int index) | ||
{ | ||
|
||
var joinData = new JoinData | ||
{ | ||
|
||
JoinNumber = (uint)(((index - 1) * 4) + BaseJoinMap.OutletPowerCycle.JoinNumber), | ||
JoinSpan = 1 | ||
}; | ||
|
||
var joinMetaData = new JoinMetadata | ||
{ | ||
Description = string.Format("Outlet {0} Power Cycle", index), | ||
JoinCapabilities = eJoinCapabilities.FromSIMPL, | ||
JoinType = eJoinType.Digital | ||
}; | ||
|
||
var joinDataComplete = new JoinDataComplete(joinData, joinMetaData); | ||
|
||
Joins.Add(string.Format("Outlet {0} Power Cycle", index), joinDataComplete); | ||
|
||
} | ||
|
||
} | ||
} |
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