Skip to content

Commit d78fc1d

Browse files
Merge pull request #7 from PepperDash/feature/updates
Update to new JoinMap and plugin loading mechanisms
2 parents 03e2e68 + 10c23fc commit d78fc1d

12 files changed

+112
-131
lines changed

.github/scripts/GenerateVersionNumber.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$latestVersions = $(git tag --merged origin/master)
1+
$latestVersions = $(git tag --merged origin/main)
22
$latestVersion = [version]"0.0.0"
33
Foreach ($version in $latestVersions) {
44
Write-Host $version
@@ -17,7 +17,7 @@ $newVersion = [version]$latestVersion
1717
$phase = ""
1818
$newVersionString = ""
1919
switch -regex ($Env:GITHUB_REF) {
20-
'^refs\/heads\/master*.' {
20+
'^refs\/heads\/main*.' {
2121
$newVersionString = "{0}.{1}.{2}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1)
2222
}
2323
'^refs\/heads\/feature\/*.' {

.github/workflows/docker.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- feature/*
77
- hotfix/*
88
- release/*
9-
- master
9+
- main
1010
- development
1111

1212
env:
@@ -18,8 +18,8 @@ env:
1818
VERSION: 0.0.0-buildtype-buildnumber
1919
# Defaults to debug for build type
2020
BUILD_TYPE: Debug
21-
# Defaults to master as the release branch. Change as necessary
22-
RELEASE_BRANCH: master
21+
# Defaults to main as the release branch. Change as necessary
22+
RELEASE_BRANCH: main
2323
jobs:
2424
Build_Project:
2525
runs-on: windows-latest
@@ -38,7 +38,7 @@ jobs:
3838
git submodule sync --recursive
3939
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
4040
# Set the BUILD_TYPE environment variable
41-
- name: Set Build to Release if triggered from Master
41+
- name: Set Build to Release if triggered from main
4242
run: |
4343
if("$($Env:GITHUB_REF)".contains("$($Env:RELEASE_BRANCH)")) {
4444
Write-Host "Setting build type to Release"
@@ -59,6 +59,11 @@ jobs:
5959
run: |
6060
Write-Output ${{ env.VERSION }}
6161
./.github/scripts/UpdateAssemblyVersion.ps1 ${{ env.VERSION }}
62+
- name: Login to Docker
63+
uses: azure/docker-login@v1
64+
with:
65+
username: ${{ secrets.DOCKERHUB_USER }}
66+
password: ${{ secrets.DOCKERHUB_PASSWORD }}
6267
# Build the solutions in the docker image
6368
- name: Build Solution
6469
shell: powershell

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,3 +355,5 @@ MigrationBackup/
355355
# Crestron Zip Files
356356
*.cplz
357357
*.clz
358+
*.projectinfo
359+
*.suo

EssentialsBuilds

PDT.EssentialsPluginTemplate.EPI/EssentailsPluginTemplate.cs

Lines changed: 0 additions & 52 deletions
This file was deleted.

PDT.EssentialsPluginTemplate.EPI/EssentialsPluginTemplateBridge.cs

Lines changed: 0 additions & 57 deletions
This file was deleted.

PDT.EssentialsPluginTemplate.EPI/EssentialsPluginTemplateDevice.cs

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using Crestron.SimplSharp;
6-
using Crestron.SimplSharpPro.DeviceSupport;
7-
8-
using PepperDash.Essentials;
1+
using Crestron.SimplSharpPro.DeviceSupport;
2+
using Newtonsoft.Json;
3+
using PDT.EssentialsPluginTemplate.EPI;
94
using PepperDash.Essentials.Core;
10-
using PepperDash.Essentials.Core.Config;
5+
using PepperDash.Essentials.Core.Bridges;
116
using PepperDash.Core;
12-
using PepperDash.Essentials.Bridges;
137

148
namespace EssentialsPluginTemplateEPI
159
{
1610
/// <summary>
1711
/// Example of a plugin device
1812
/// </summary>
19-
public class EssentialsPluginTemplateDevice : Device, IBridge
13+
public class EssentialsPluginTemplateDevice : EssentialsDevice, IBridgeAdvanced
2014
{
2115
/// <summary>
2216
/// Device Constructor. Called by BuildDevice
@@ -46,9 +40,28 @@ public override bool CustomActivate()
4640
/// <param name="trilist"></param>
4741
/// <param name="joinStart"></param>
4842
/// <param name="joinMapKey"></param>
49-
public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey)
43+
public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
5044
{
51-
this.LinkToApi(trilist, joinStart, joinMapKey);
45+
// Construct the default join map
46+
var joinMap = new EssentialsPluginTemplateBridgeJoinMap(joinStart);
47+
48+
// Attempt to get a custom join map if specified in config
49+
var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey);
50+
51+
// If we find a custom join map, deserialize it
52+
if (!string.IsNullOrEmpty(joinMapSerialized))
53+
joinMap = JsonConvert.DeserializeObject<EssentialsPluginTemplateBridgeJoinMap>(joinMapSerialized);
54+
55+
//Checking if the bridge is null allows for backwards compatability with configurations that use EiscApi instead of EiscApiAdvanced
56+
if (bridge != null)
57+
{
58+
bridge.AddJoinMap(Key, joinMap);
59+
}
60+
61+
// Set all your join actions here
62+
63+
64+
// Link all your feedbacks to joins here
5265
}
5366
}
5467
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Crestron.SimplSharp; // For Basic SIMPL# Classes
4+
using Crestron.SimplSharpPro; // For Basic SIMPL#Pro classes
5+
6+
using Newtonsoft.Json;
7+
using Newtonsoft.Json.Linq;
8+
9+
using PepperDash.Essentials;
10+
using PepperDash.Essentials.Core;
11+
using PepperDash.Essentials.Core.Config;
12+
using PepperDash.Core;
13+
14+
namespace EssentialsPluginTemplateEPI
15+
{
16+
/// <summary>
17+
/// This class contains the necessary properties and methods required to function as an Essentials Plugin
18+
/// </summary>
19+
public class EssentialsPluginFactory:EssentialsPluginDeviceFactory<EssentialsPluginTemplateDevice>
20+
{
21+
public EssentialsPluginFactory()
22+
{
23+
// This string is used to define the minimum version of the
24+
// Essentials Framework required for this plugin
25+
MinimumEssentialsFrameworkVersion = "1.6.1";
26+
27+
//The strings defined in this list will be used in the configuration file to build the device in this plugin.
28+
TypeNames = new List<string> {"essentialsPluginTemplateDevice"};
29+
}
30+
31+
#region Overrides of EssentialsDeviceFactory<EssentialsPluginTemplateDevice>
32+
33+
public override EssentialsDevice BuildDevice(DeviceConfig dc)
34+
{
35+
var config = dc.Properties.ToObject<EssentialsPluginTemplatePropertiesConfig>();
36+
var newDevice = new EssentialsPluginTemplateDevice(dc.Key, dc.Name, config);
37+
return newDevice;
38+
}
39+
40+
#endregion
41+
}
42+
}
43+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using Crestron.SimplSharp;
6+
using PepperDash.Essentials.Core;
7+
8+
namespace PDT.EssentialsPluginTemplate.EPI
9+
{
10+
public class EssentialsPluginTemplateBridgeJoinMap : JoinMapBaseAdvanced
11+
{
12+
[JoinName("IsOnline")]
13+
public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData {JoinNumber = 1, JoinSpan = 1},
14+
new JoinMetadata
15+
{
16+
Description = "Device is Online",
17+
JoinType = eJoinType.Digital,
18+
JoinCapabilities = eJoinCapabilities.ToSIMPL
19+
});
20+
21+
22+
public EssentialsPluginTemplateBridgeJoinMap(uint joinStart):base(joinStart, typeof(EssentialsPluginTemplateBridgeJoinMap))
23+
{
24+
25+
}
26+
}
27+
}

PDT.EssentialsPluginTemplate.EPI/PDT.EssentialsPluginTemplate.EPI.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@
9191
<Reference Include="System.Data" />
9292
</ItemGroup>
9393
<ItemGroup>
94-
<Compile Include="EssentailsPluginTemplate.cs" />
95-
<Compile Include="EssentialsPluginTemplateBridge.cs" />
9694
<Compile Include="EssentialsPluginTemplateConfigObject.cs" />
95+
<Compile Include="EssentialsPluginTemplateFactory.cs" />
96+
<Compile Include="EssentialsPluginTemplateJoinMap.cs" />
9797
<Compile Include="Properties\AssemblyInfo.cs" />
9898
<Compile Include="EssentialsPluginTemplateDevice.cs" />
9999
<None Include="Properties\ControlSystem.cfg" />

0 commit comments

Comments
 (0)