Skip to content

Commit

Permalink
Merge pull request #9 from PepperDash-Engineering/main
Browse files Browse the repository at this point in the history
merge main into Dev
  • Loading branch information
ngenovese11 authored Oct 7, 2022
2 parents 0a43a17 + e498d40 commit 245e1ca
Show file tree
Hide file tree
Showing 22 changed files with 357 additions and 210 deletions.
45 changes: 45 additions & 0 deletions .github/scripts/GenerateVersionNumber.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
$latestVersions = $(git tag --merged origin/main)
$latestVersion = [version]"0.0.0"
Foreach ($version in $latestVersions) {
Write-Host $version
try {
if (([version]$version) -ge $latestVersion) {
$latestVersion = $version
Write-Host "Setting latest version to: $latestVersion"
}
}
catch {
Write-Host "Unable to convert $($version). Skipping"
continue;
}
}

$newVersion = [version]$latestVersion
$phase = ""
$newVersionString = ""
switch -regex ($Env:GITHUB_REF) {
'^refs\/heads\/master*.' {
$newVersionString = "{0}.{1}.{2}" -f $newVersion.Major, $newVersion.Minor, $newVersion.Build
}
'^refs\/heads\/feature\/*.' {
$phase = 'alpha'
$newVersionString = "{0}.{1}.{2}-{3}-{4}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1), $phase, $Env:GITHUB_RUN_NUMBER
}
'^refs\/heads\/release\/*.' {
$splitRef = $Env:GITHUB_REF -split "/"
$version = [version]($splitRef[-1] -replace "v", "")
$phase = 'rc'
$newVersionString = "{0}.{1}.{2}-{3}-{4}" -f $version.Major, $version.Minor, $version.Build, $phase, $Env:GITHUB_RUN_NUMBER
}
'^refs\/heads\/dev*.' {
$phase = 'beta'
$newVersionString = "{0}.{1}.{2}-{3}-{4}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1), $phase, $Env:GITHUB_RUN_NUMBER
}
'^refs\/heads\/hotfix\/*.' {
$phase = 'hotfix'
$newVersionString = "{0}.{1}.{2}-{3}-{4}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1), $phase, $Env:GITHUB_RUN_NUMBER
}
}


Write-Output $newVersionString
2 changes: 1 addition & 1 deletion .github/workflows/essentialsplugins-betabuilds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:
RELEASE_BRANCH: main
jobs:
Build_Project:
runs-on: windows-latest
runs-on: windows-2019
outputs:
version: ${{steps.setVersionNumber.outputs.version}}
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/essentialsplugins-releasebuilds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ env:
RELEASE_BRANCH: main
jobs:
Build_Project:
runs-on: windows-latest
runs-on: windows-2019
outputs:
version: ${{steps.setVersionNumber.outputs.version}}
steps:
Expand Down
10 changes: 10 additions & 0 deletions ApcEpi.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApcEpi", "src\ApcEpi.csproj", "{9D249E47-8F95-4437-A6BB-563510287AD1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{3699BBAD-D83B-479A-9896-9CDA2E5998EA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "testing", "testing", "{3E9860BF-E3F8-48B6-922A-CBE42C01113A}"
ProjectSection(SolutionItems) = preProject
testing\configurationFile.json = testing\configurationFile.json
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -17,4 +24,7 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{9D249E47-8F95-4437-A6BB-563510287AD1} = {3699BBAD-D83B-479A-9896-9CDA2E5998EA}
EndGlobalSection
EndGlobal
110 changes: 97 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,106 @@
# Internal Essentials Plugin Template (c) 2020
# PepperDash Apc Plugin

## License
> The APC plugin endeavors to provide device control and routing over Apc Type Power devices.
Provided under MIT license
## Types

## Overview
1. Ap89xx

Use this repo as a template when creating a new plugin for Essentials. For more information about plugins, refer to the Essentials Wiki [Plugins](https://github.com/PepperDash/Essentials/wiki/Plugins) article.
## Join Map

## Github Actions
### Digitals

This repo contains two Github Action workflows that will build this project automatically. Modify the SOLUTION_PATH and SOLUTION_FILE environment variables as needed. Any branches named `feature/*`, `release/*`, `hotfix/*` or `development` will automatically be built with the action and create a release in the repository with a version number based on the latest release on the master branch. If there are no releases yet, the version number will be 0.0.1. The version number will be modified based on what branch triggered the build:
| Join | To Simpl | From Simpl |
| ------- | ---------------------- | ------------------------ |
| 1 | Device Online | - |
| 2-50 | Reserved For Future | Reserved For Future |
| 51-100 | Power On Feedback | Power On |
| 100-151 | - | Power Off |
| 151-200 | - | Power Toggle |

- `feature` branch builds will be tagged with an `alpha` descriptor, with the Action run appended: `0.0.1-alpha-1`
- `development` branch builds will be tagged with a `beta` descriptor, with the Action run appended: `0.0.1-beta-2`
- `release` branches will be tagged with an `rc` descriptor, with the Action run appended: `0.0.1-rc-3`
- `hotfix` branch builds will be tagged with a `hotfix` descriptor, with the Action run appended: `0.0.1-hotfix-4`
### Analogs

Builds on the Master branch will ONLY be triggered by manually creating a release using the web interface in the repository. They will be versioned with the tag that is created when the release is created. The tags MUST take the form `major.minor.revision` to be compatible with the build process. A tag like `v0.1.0-alpha` is NOT compatabile and may result in the build process failing.
| Join | To Simpl | From Simpl |
| ------- | ---------------------- | ------------------------ |
| 1 | - | - |
| 2-50 | - | - |
| 51-100 | - | - |
| 100-151 | - | - |
| 151-200 | - | - |

If you have any questions about the action, contact Andrew Welker or Neil Dorin.
### Serials

| Join | To Simpl | From Simpl |
| ------- | ---------------------- | ------------------------ |
| 1 | Device Name | - |
| 2-50 | - | - |
| 51-100 | Outlet Name | - |
| 100-151 | - | - |
| 151-200 | - | - |

### Join Details

---

1. Outlet Name is defined by the Name property in config, and is not necesarily what will be in the APC software; and the APC software requires outlet names to no contain spaces or characters.

## Config Example

```JSON
{
"key": "PowerSupply01",
"uid": 74,
"name": "PowerSupply01",
"type": "Ap89xx",
"group": "power",
"properties": {
"control": {
"endOfLineString": "\n",
"deviceReadyResponsePattern": "",
"method": "ssh",
"tcpSshProperties": {
"address": "0.0.0.0",
"port": 22,
"autoReconnect": true,
"AutoReconnectIntervalMs": 10000,
"username": "apc",
"password": "apc"
}
},
"outlets":
{
"outlet01" : {
"name": "My First Outlet",
"outletIndex": 1,
"delayOn": 30,
"delayOff": 2
},
"outlet02" : {
"name": "Another Awesome Outlet",
"outletIndex": 4,
"delayOn": 30,
"delayOff": 2
}
}
}
}
```

### Config Details

---
__Properties:__

#### "outlets"

- Dictionary that defines the outlets to be controlled
- "key" - defines and sets the name of the outlet in the APC software. This value must be unique and contain no spaces or specials charaters
- "name" - defines the name that will be sent to the bridge for a UI friendly name. If this value is not set it will be the key
- "outletIndex" - outletNumber to be controlled
- "delayOn" - NOT YET IMPLEMENTED
- "delayOff" - NOT YET IMPLEMENTED

## Planned Updates

1. Create a custom StatusMonitor to get more detailed infomation
1. Add ability to set on/off delays by outlet
2 changes: 1 addition & 1 deletion packages.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<packages>
<package id="PepperDashEssentials" version="1.6.4" targetFramework="net35" allowedVersions="[1.0,2.0)"/>
<package id="PepperDashEssentials" version="1.8.0" targetFramework="net35" allowedVersions="[1.0,2.0)"/>
</packages>
4 changes: 1 addition & 3 deletions src/Abstractions/IApDeviceBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Queues;

namespace ApcEpi.Abstractions
{
public interface IApDeviceBuilder : IKeyName
{
ICommunicationMonitor Monitor { get; }
IBasicCommunication Coms { get; }
ReadOnlyDictionary<uint, IApOutlet> Outlets { get; }
CTimer Poll { get; }

EssentialsDevice Build();
}
}
2 changes: 2 additions & 0 deletions src/Abstractions/IApOutlet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@ public interface IApOutlet : IKeyName, IOnline, IPower
{
int OutletIndex { get; }
StringFeedback NameFeedback { get; }
bool PowerStatus { get; set; }
void SetIsOnline();
}
}
1 change: 1 addition & 0 deletions src/ApcEpi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<Compile Include="Abstractions\IApDevice.cs" />
<Compile Include="Entities\Outlet\ApOutlet.cs" />
<Compile Include="Entities\Outlet\ApOutletOnline.cs" />
<Compile Include="Messages\ConnectionQueueMessage.cs" />
<Compile Include="Services\NameCommands\ApOutletName.cs" />
<Compile Include="Entities\Outlet\ApOutletPower.cs" />
<Compile Include="JoinMaps\ApDeviceJoinMap.cs" />
Expand Down
14 changes: 2 additions & 12 deletions src/Builders/Ap89XxBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Devices;

namespace ApcEpi.Builders
{
Expand All @@ -19,21 +18,13 @@ private Ap89XxBuilder(string key, string name, IBasicCommunication coms, ApDevic
Name = name;
Key = key;
Outlets = BuildOutletsFromConfig(key, config, coms);
Monitor = new GenericCommunicationMonitoredDevice(
Key,
Name,
Coms,
"about\r");

Poll = new CTimer(_ => ApDevice.PollDevice(coms), null, Timeout.Infinite);
}

public string Key { get; private set; }
public string Name { get; private set; }
public IBasicCommunication Coms { get; private set; }
public ICommunicationMonitor Monitor { get; private set; }

public ReadOnlyDictionary<uint, IApOutlet> Outlets { get; private set; }
public CTimer Poll { get; private set; }

public static ReadOnlyDictionary<uint, IApOutlet> BuildOutletsFromConfig(
string parentKey,
Expand All @@ -42,7 +33,7 @@ public static ReadOnlyDictionary<uint, IApOutlet> BuildOutletsFromConfig(
{
var outlets = config
.Outlets
.Select(x => new ApOutlet(parentKey + "-" + x.Key, x.Value.Name, x.Value.OutletIndex, coms))
.Select(x => new ApOutlet(x.Key, x.Value.Name, x.Value.OutletIndex, parentKey, coms))
.ToDictionary<ApOutlet, uint, IApOutlet>(outlet => (uint) outlet.OutletIndex, outlet => outlet);

return new ReadOnlyDictionary<uint, IApOutlet>(outlets);
Expand All @@ -58,7 +49,6 @@ public static IApDeviceBuilder GetFromDeviceConfig(DeviceConfig dc)

public EssentialsDevice Build()
{
Debug.Console(1, this, "Building...");
return new ApDevice(this);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/Config/ApDeviceConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public class ApOutletConfig
public int OutletIndex { get; set; }
public int DelayOn { get; set; }
public int DelayOff { get; set; }
public bool IsInvisible { get; set; }
}
}
Loading

0 comments on commit 245e1ca

Please sign in to comment.