mirror of
https://github.com/PepperDash/EssentialsPluginTemplate.git
synced 2026-01-11 19:44:38 +00:00
Merge pull request #7 from PepperDash/feature/updates
Update to new JoinMap and plugin loading mechanisms
This commit is contained in:
4
.github/scripts/GenerateVersionNumber.ps1
vendored
4
.github/scripts/GenerateVersionNumber.ps1
vendored
@@ -1,4 +1,4 @@
|
|||||||
$latestVersions = $(git tag --merged origin/master)
|
$latestVersions = $(git tag --merged origin/main)
|
||||||
$latestVersion = [version]"0.0.0"
|
$latestVersion = [version]"0.0.0"
|
||||||
Foreach ($version in $latestVersions) {
|
Foreach ($version in $latestVersions) {
|
||||||
Write-Host $version
|
Write-Host $version
|
||||||
@@ -17,7 +17,7 @@ $newVersion = [version]$latestVersion
|
|||||||
$phase = ""
|
$phase = ""
|
||||||
$newVersionString = ""
|
$newVersionString = ""
|
||||||
switch -regex ($Env:GITHUB_REF) {
|
switch -regex ($Env:GITHUB_REF) {
|
||||||
'^refs\/heads\/master*.' {
|
'^refs\/heads\/main*.' {
|
||||||
$newVersionString = "{0}.{1}.{2}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1)
|
$newVersionString = "{0}.{1}.{2}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1)
|
||||||
}
|
}
|
||||||
'^refs\/heads\/feature\/*.' {
|
'^refs\/heads\/feature\/*.' {
|
||||||
|
|||||||
13
.github/workflows/docker.yml
vendored
13
.github/workflows/docker.yml
vendored
@@ -6,7 +6,7 @@ on:
|
|||||||
- feature/*
|
- feature/*
|
||||||
- hotfix/*
|
- hotfix/*
|
||||||
- release/*
|
- release/*
|
||||||
- master
|
- main
|
||||||
- development
|
- development
|
||||||
|
|
||||||
env:
|
env:
|
||||||
@@ -18,8 +18,8 @@ env:
|
|||||||
VERSION: 0.0.0-buildtype-buildnumber
|
VERSION: 0.0.0-buildtype-buildnumber
|
||||||
# Defaults to debug for build type
|
# Defaults to debug for build type
|
||||||
BUILD_TYPE: Debug
|
BUILD_TYPE: Debug
|
||||||
# Defaults to master as the release branch. Change as necessary
|
# Defaults to main as the release branch. Change as necessary
|
||||||
RELEASE_BRANCH: master
|
RELEASE_BRANCH: main
|
||||||
jobs:
|
jobs:
|
||||||
Build_Project:
|
Build_Project:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
@@ -38,7 +38,7 @@ jobs:
|
|||||||
git submodule sync --recursive
|
git submodule sync --recursive
|
||||||
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
|
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
|
||||||
# Set the BUILD_TYPE environment variable
|
# Set the BUILD_TYPE environment variable
|
||||||
- name: Set Build to Release if triggered from Master
|
- name: Set Build to Release if triggered from main
|
||||||
run: |
|
run: |
|
||||||
if("$($Env:GITHUB_REF)".contains("$($Env:RELEASE_BRANCH)")) {
|
if("$($Env:GITHUB_REF)".contains("$($Env:RELEASE_BRANCH)")) {
|
||||||
Write-Host "Setting build type to Release"
|
Write-Host "Setting build type to Release"
|
||||||
@@ -59,6 +59,11 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
Write-Output ${{ env.VERSION }}
|
Write-Output ${{ env.VERSION }}
|
||||||
./.github/scripts/UpdateAssemblyVersion.ps1 ${{ env.VERSION }}
|
./.github/scripts/UpdateAssemblyVersion.ps1 ${{ env.VERSION }}
|
||||||
|
- name: Login to Docker
|
||||||
|
uses: azure/docker-login@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKERHUB_USER }}
|
||||||
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
||||||
# Build the solutions in the docker image
|
# Build the solutions in the docker image
|
||||||
- name: Build Solution
|
- name: Build Solution
|
||||||
shell: powershell
|
shell: powershell
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -355,3 +355,5 @@ MigrationBackup/
|
|||||||
# Crestron Zip Files
|
# Crestron Zip Files
|
||||||
*.cplz
|
*.cplz
|
||||||
*.clz
|
*.clz
|
||||||
|
*.projectinfo
|
||||||
|
*.suo
|
||||||
|
|||||||
Submodule EssentialsBuilds updated: 855dccd0d4...e29501be5d
@@ -1,52 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Crestron.SimplSharp; // For Basic SIMPL# Classes
|
|
||||||
using Crestron.SimplSharpPro; // For Basic SIMPL#Pro classes
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
|
|
||||||
using PepperDash.Essentials;
|
|
||||||
using PepperDash.Essentials.Core;
|
|
||||||
using PepperDash.Essentials.Core.Config;
|
|
||||||
using PepperDash.Core;
|
|
||||||
|
|
||||||
namespace EssentialsPluginTemplateEPI
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// This class contains the necessary properties and static methods required to function as an Essentials Plugin
|
|
||||||
/// </summary>
|
|
||||||
public class EssentialsPluginFactory
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// This string is used to define the minimum version of the
|
|
||||||
/// Essentials Framework required for this plugin
|
|
||||||
/// </summary>
|
|
||||||
public static string MinimumEssentialsFrameworkVersion = "1.4.31";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// This method will get called by Essentials when this plugin is loaded.
|
|
||||||
/// Use it to add factory methods for all new Device types defined in this plugin
|
|
||||||
/// </summary>
|
|
||||||
public static void LoadPlugin()
|
|
||||||
{
|
|
||||||
PepperDash.Essentials.Core.DeviceFactory.AddFactoryForType("EssentialsPluginTemplate", EssentialsPluginFactory.BuildDevice);
|
|
||||||
|
|
||||||
// Add additional factories for each type here
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Builds an instance of the device type. There should be method like this defined for each device type your plugin needs
|
|
||||||
/// to be able to build
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="dc">The device configuration</param>
|
|
||||||
/// <returns>The device</returns>
|
|
||||||
public static EssentialsPluginTemplateDevice BuildDevice(DeviceConfig dc)
|
|
||||||
{
|
|
||||||
var config = JsonConvert.DeserializeObject<EssentialsPluginTemplatePropertiesConfig>(dc.Properties.ToString());
|
|
||||||
var newDevice = new EssentialsPluginTemplateDevice(dc.Key, dc.Name, config);
|
|
||||||
return newDevice;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core;
|
|
||||||
using PepperDash.Essentials.Bridges;
|
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
|
|
||||||
namespace EssentialsPluginTemplateEPI
|
|
||||||
{
|
|
||||||
public static class EssentialsPluginTemplateBridge
|
|
||||||
{
|
|
||||||
public static void LinkToApiExt(this EssentialsPluginFactory DspDevice, BasicTriList trilist, uint joinStart, string joinMapKey)
|
|
||||||
{
|
|
||||||
// Construct the default join map
|
|
||||||
EssentialsPluginTemplateBridgeJoinMap joinMap = new EssentialsPluginTemplateBridgeJoinMap();
|
|
||||||
|
|
||||||
// Attempt to get a custom join map if specified in config
|
|
||||||
var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey);
|
|
||||||
|
|
||||||
// If we find a custom join map, deserialize it
|
|
||||||
if (!string.IsNullOrEmpty(joinMapSerialized))
|
|
||||||
joinMap = JsonConvert.DeserializeObject<EssentialsPluginTemplateBridgeJoinMap>(joinMapSerialized);
|
|
||||||
|
|
||||||
// Offset the joins based on the join start
|
|
||||||
joinMap.OffsetJoinNumbers(joinStart);
|
|
||||||
|
|
||||||
|
|
||||||
// Set all your join actions here
|
|
||||||
|
|
||||||
|
|
||||||
// Link all your feedbacks to joins here
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public class EssentialsPluginTemplateBridgeJoinMap : JoinMapBase
|
|
||||||
{
|
|
||||||
// Specify your joins here
|
|
||||||
|
|
||||||
|
|
||||||
public EssentialsPluginTemplateBridgeJoinMap()
|
|
||||||
{
|
|
||||||
// Set the values of your joins here
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OffsetJoinNumbers(uint joinStart)
|
|
||||||
{
|
|
||||||
// Offset the joins from joinStart as applicable
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +1,16 @@
|
|||||||
using System;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using System.Collections.Generic;
|
using Newtonsoft.Json;
|
||||||
using System.Linq;
|
using PDT.EssentialsPluginTemplate.EPI;
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
|
||||||
|
|
||||||
using PepperDash.Essentials;
|
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Bridges;
|
|
||||||
|
|
||||||
namespace EssentialsPluginTemplateEPI
|
namespace EssentialsPluginTemplateEPI
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Example of a plugin device
|
/// Example of a plugin device
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EssentialsPluginTemplateDevice : Device, IBridge
|
public class EssentialsPluginTemplateDevice : EssentialsDevice, IBridgeAdvanced
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Device Constructor. Called by BuildDevice
|
/// Device Constructor. Called by BuildDevice
|
||||||
@@ -46,9 +40,28 @@ namespace EssentialsPluginTemplateEPI
|
|||||||
/// <param name="trilist"></param>
|
/// <param name="trilist"></param>
|
||||||
/// <param name="joinStart"></param>
|
/// <param name="joinStart"></param>
|
||||||
/// <param name="joinMapKey"></param>
|
/// <param name="joinMapKey"></param>
|
||||||
public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey)
|
public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
|
||||||
{
|
{
|
||||||
this.LinkToApi(trilist, joinStart, joinMapKey);
|
// Construct the default join map
|
||||||
|
var joinMap = new EssentialsPluginTemplateBridgeJoinMap(joinStart);
|
||||||
|
|
||||||
|
// Attempt to get a custom join map if specified in config
|
||||||
|
var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey);
|
||||||
|
|
||||||
|
// If we find a custom join map, deserialize it
|
||||||
|
if (!string.IsNullOrEmpty(joinMapSerialized))
|
||||||
|
joinMap = JsonConvert.DeserializeObject<EssentialsPluginTemplateBridgeJoinMap>(joinMapSerialized);
|
||||||
|
|
||||||
|
//Checking if the bridge is null allows for backwards compatability with configurations that use EiscApi instead of EiscApiAdvanced
|
||||||
|
if (bridge != null)
|
||||||
|
{
|
||||||
|
bridge.AddJoinMap(Key, joinMap);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set all your join actions here
|
||||||
|
|
||||||
|
|
||||||
|
// Link all your feedbacks to joins here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Crestron.SimplSharp; // For Basic SIMPL# Classes
|
||||||
|
using Crestron.SimplSharpPro; // For Basic SIMPL#Pro classes
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
using PepperDash.Essentials;
|
||||||
|
using PepperDash.Essentials.Core;
|
||||||
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using PepperDash.Core;
|
||||||
|
|
||||||
|
namespace EssentialsPluginTemplateEPI
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This class contains the necessary properties and methods required to function as an Essentials Plugin
|
||||||
|
/// </summary>
|
||||||
|
public class EssentialsPluginFactory:EssentialsPluginDeviceFactory<EssentialsPluginTemplateDevice>
|
||||||
|
{
|
||||||
|
public EssentialsPluginFactory()
|
||||||
|
{
|
||||||
|
// This string is used to define the minimum version of the
|
||||||
|
// Essentials Framework required for this plugin
|
||||||
|
MinimumEssentialsFrameworkVersion = "1.6.1";
|
||||||
|
|
||||||
|
//The strings defined in this list will be used in the configuration file to build the device in this plugin.
|
||||||
|
TypeNames = new List<string> {"essentialsPluginTemplateDevice"};
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Overrides of EssentialsDeviceFactory<EssentialsPluginTemplateDevice>
|
||||||
|
|
||||||
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
|
{
|
||||||
|
var config = dc.Properties.ToObject<EssentialsPluginTemplatePropertiesConfig>();
|
||||||
|
var newDevice = new EssentialsPluginTemplateDevice(dc.Key, dc.Name, config);
|
||||||
|
return newDevice;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
using PepperDash.Essentials.Core;
|
||||||
|
|
||||||
|
namespace PDT.EssentialsPluginTemplate.EPI
|
||||||
|
{
|
||||||
|
public class EssentialsPluginTemplateBridgeJoinMap : JoinMapBaseAdvanced
|
||||||
|
{
|
||||||
|
[JoinName("IsOnline")]
|
||||||
|
public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData {JoinNumber = 1, JoinSpan = 1},
|
||||||
|
new JoinMetadata
|
||||||
|
{
|
||||||
|
Description = "Device is Online",
|
||||||
|
JoinType = eJoinType.Digital,
|
||||||
|
JoinCapabilities = eJoinCapabilities.ToSIMPL
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
public EssentialsPluginTemplateBridgeJoinMap(uint joinStart):base(joinStart, typeof(EssentialsPluginTemplateBridgeJoinMap))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -91,9 +91,9 @@
|
|||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="EssentailsPluginTemplate.cs" />
|
|
||||||
<Compile Include="EssentialsPluginTemplateBridge.cs" />
|
|
||||||
<Compile Include="EssentialsPluginTemplateConfigObject.cs" />
|
<Compile Include="EssentialsPluginTemplateConfigObject.cs" />
|
||||||
|
<Compile Include="EssentialsPluginTemplateFactory.cs" />
|
||||||
|
<Compile Include="EssentialsPluginTemplateJoinMap.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="EssentialsPluginTemplateDevice.cs" />
|
<Compile Include="EssentialsPluginTemplateDevice.cs" />
|
||||||
<None Include="Properties\ControlSystem.cfg" />
|
<None Include="Properties\ControlSystem.cfg" />
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user