Compare commits

...

11 Commits

Author SHA1 Message Date
Neil Dorin
2ee1ca974e Merge pull request #112 from PepperDash/feature/fix-master-repo-push-workflow
Fixes push actions for build repos for releases
2020-04-14 16:52:48 -06:00
Andrew Welker
1141ed192d fixes issues with push to build repos 2020-04-14 16:32:48 -06:00
Andrew Welker
3b2b69de1b Merge pull request #103 from PepperDash/feature/ConfigWriterCCritical
#101 Fixes scope issue with CCriticalSection() in ConfigWriter
2020-04-10 15:24:53 -06:00
Jason T Alborough
29a79490ba #101 Fixes scope issue with CCriticalSection() in ConfigWriter 2020-04-10 16:29:48 -04:00
Andrew Welker
da50272980 Merge pull request #88 from PepperDash/feature/fix-get-name-attribute-issue
Feature/fix get name attribute issue
2020-04-05 09:25:28 -06:00
Neil Dorin
c8f095f0a3 Updates CameraControllerJoinMap to use new constructor for base class 2020-04-05 09:07:05 -06:00
Andrew Welker
42fbd813a2 updated methods for creating joinMap dict 2020-04-04 22:06:56 -06:00
Andrew Welker
69f5460442 trying to fix JoinMapBaseAdvanced 2020-04-04 21:09:00 -06:00
Neil Dorin
b32212083d Adds debug statment to detect if JoinNameAttribute constructor has been called 2020-04-04 14:44:43 -06:00
Neil Dorin
88702f97c6 moves logic to add joins out of the constructor and into new AddJoins() method to allow it to be called from extended class after fields have been initialized. 2020-04-04 14:12:49 -06:00
Andrew Welker
9b759daca1 Merge pull request #87 from PepperDash/feature/updated-IDeviceFactory-for-plugin-implementation
Feature/updated i device factory for plugin implementation
2020-04-04 11:27:19 -06:00
5 changed files with 163 additions and 156 deletions

View File

@@ -56,11 +56,21 @@ jobs:
- name: Zip Build Output
shell: powershell
run: ./.github/scripts/ZipBuildOutput.ps1
# Write the version to a file to be consumed by the push jobs
- name: Write Version
run: Write-Output "$($Env:VERSION)" | Out-File -FilePath "$($Env:GITHUB_HOME)\output\version.txt"
# Upload the build output as an artifact
- name: Upload Build Output
uses: actions/upload-artifact@v1
with:
name: Build
path: ./${{ env.SOLUTION_FILE}}-${{ env.VERSION}}.zip
# Upload the Version file as an artifact
- name: Upload version.txt
uses: actions/upload-artifact@v1
with:
name: Version
path: ${{env.GITHUB_HOME}}\output\version.txt
# Upload the build package to the release
- name: Upload Release Package
id: upload_release
@@ -72,7 +82,6 @@ jobs:
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# This step always runs and pushes the build to the internal build rep
Internal_Push_Output:
needs: Build_Project
runs-on: windows-latest
@@ -102,85 +111,8 @@ jobs:
Remove-Item -Path ./Version/version.txt
Remove-Item -Path ./Version
# Checkout/Create the branch
- name: Create new branch
run: git checkout -b $($Env:GITHUB_REF -replace "refs/heads/")
# Download the build output into the repo
- name: Download Build output
uses: actions/download-artifact@v1
with:
name: Build
path: ./
- name: Check directory
run: Get-ChildItem ./
# Unzip the build package file
- name: Unzip Build file
run: |
Get-ChildItem .\*.zip | Expand-Archive -DestinationPath .\
Remove-Item -Path .\*.zip
- name: Check directory again
run: Get-ChildItem ./
# Copy Contents of output folder to root directory
- name: Copy Files to root & delete output directory
run: |
Remove-Item -Path .\* -Include @("*.cpz","*.md","*.cplz","*.json","*.dll","*.clz")
Get-ChildItem -Path .\output\* | Copy-Item -Destination .\
Remove-Item -Path .\output -Recurse
# Commits the build output to the branch and tags it with the version
- name: Commit build output and tag the commit
shell: powershell
run: |
git config user.email "actions@pepperdash.com"
git config user.name "GitHub Actions"
git add .
$commit = "Build $($Env:GITHUB_RUN_NUMBER) from commit: https://github.com/$($Env:GITHUB_REPOSITORY)/commit/$($Env:GITHUB_SHA)"
Write-Host "Commit: $commit"
git commit -m $commit
git tag $($Env:VERSION)
# Push the commit
- name: Push to Builds Repo
shell: powershell
run: |
$branch = $($Env:GITHUB_REF) -replace "refs/heads/"
Write-Host "Branch: $branch"
git push -u origin $($branch) --force
# Push the tags
- name: Push tags
run: git push --tags origin
- name: Check Directory
run: Get-ChildItem ./
# This step only runs if the branch is master or release/ runs and pushes the build to the public build repo
Public_Push_Output:
needs: Build_Project
runs-on: windows-latest
if: contains(github.ref, 'master') || contains(github.ref, 'release')
steps:
# Checkout the repo
- name: Checkout Builds Repo
uses: actions/checkout@v2
with:
token: ${{ secrets.BUILDS_TOKEN }}
repository: PepperDash/Essentials-Builds
ref: ${{ Env.GITHUB_REF }}
# Download the version artifact from the build job
- name: Download Build Version Info
uses: actions/download-artifact@v1
with:
name: Version
- name: Check Directory
run: Get-ChildItem "./"
# Set the version number environment variable from the file we just downloaded
- name: Set Version Number
shell: powershell
run: |
Get-ChildItem "./Version"
$version = Get-Content -Path ./Version/version.txt
Write-Host "Version: $version"
Write-Output "::set-env name=VERSION::$version"
Remove-Item -Path ./Version/version.txt
Remove-Item -Path ./Version
# Checkout/Create the branch
- name: Create new branch
run: git checkout -b $($Env:GITHUB_REF -replace "refs/heads/")
- name: Checkout Master branch
run: git checkout master
# Download the build output into the repo
- name: Download Build output
uses: actions/download-artifact@v1
@@ -216,10 +148,80 @@ jobs:
# Push the commit
- name: Push to Builds Repo
shell: powershell
run: |
$branch = $($Env:GITHUB_REF) -replace "refs/heads/"
Write-Host "Branch: $branch"
git push -u origin $($branch) --force
run: git push -u origin master --force
# Push the tags
- name: Push tags
run: git push --tags origin
- name: Check Directory
run: Get-ChildItem ./
# This step only runs if the branch is master or release/ runs and pushes the build to the public build repo
Public_Push_Output:
needs: Build_Project
runs-on: windows-latest
steps:
# Checkout the repo
- name: Checkout Builds Repo
uses: actions/checkout@v2
with:
token: ${{ secrets.BUILDS_TOKEN }}
repository: PepperDash/Essentials-Builds
ref: ${{ Env.GITHUB_REF }}
# Download the version artifact from the build job
- name: Download Build Version Info
uses: actions/download-artifact@v1
with:
name: Version
- name: Check Directory
run: Get-ChildItem "./"
# Set the version number environment variable from the file we just downloaded
- name: Set Version Number
shell: powershell
run: |
Get-ChildItem "./Version"
$version = Get-Content -Path ./Version/version.txt
Write-Host "Version: $version"
Write-Output "::set-env name=VERSION::$version"
Remove-Item -Path ./Version/version.txt
Remove-Item -Path ./Version
# Checkout master branch
- name: Create new branch
run: git checkout master
# Download the build output into the repo
- name: Download Build output
uses: actions/download-artifact@v1
with:
name: Build
path: ./
- name: Check directory
run: Get-ChildItem ./
# Unzip the build package file
- name: Unzip Build file
run: |
Get-ChildItem .\*.zip | Expand-Archive -DestinationPath .\
Remove-Item -Path .\*.zip
- name: Check directory again
run: Get-ChildItem ./
# Copy Contents of output folder to root directory
- name: Copy Files to root & delete output directory
run: |
Remove-Item -Path .\* -Include @("*.cpz","*.md","*.cplz","*.json","*.dll","*.clz")
Get-ChildItem -Path .\output\* | Copy-Item -Destination .\
Remove-Item -Path .\output -Recurse
# Commits the build output to the branch and tags it with the version
- name: Commit build output and tag the commit
shell: powershell
run: |
git config user.email "actions@pepperdash.com"
git config user.name "GitHub Actions"
git add .
$commit = "Build $($Env:GITHUB_RUN_NUMBER) from commit: https://github.com/$($Env:GITHUB_REPOSITORY)/commit/$($Env:GITHUB_SHA)"
Write-Host "Commit: $commit"
git commit -m $commit
git tag $($Env:VERSION)
# Push the commit
- name: Push to Builds Repo
shell: powershell
run: git push -u origin master --force
# Push the tags
- name: Push tags
run: git push --tags origin

View File

@@ -18,7 +18,7 @@ namespace PepperDash.Essentials.Bridges
public static void LinkToApi(this PepperDash.Essentials.Devices.Common.Cameras.CameraBase cameraDevice, BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge)
{
CameraControllerJoinMap joinMap = new CameraControllerJoinMap(joinStart);
// Adds the join map to the bridge
bridge.AddJoinMap(cameraDevice.Key, joinMap);

View File

@@ -57,7 +57,7 @@ namespace PepperDash.Essentials.Bridges
public JoinDataComplete SupportsPresets = new JoinDataComplete(new JoinData() { JoinNumber = 57, JoinSpan = 1 }, new JoinMetadata() { Label = "Supports Presets", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital });
public CameraControllerJoinMap(uint joinStart)
:base(joinStart)
: base(joinStart, typeof(CameraControllerJoinMap))
{
}
}

View File

@@ -19,7 +19,8 @@ namespace PepperDash.Essentials.Core.Config
public const long WriteTimeout = 30000;
public static CTimer WriteTimer;
public static CTimer WriteTimer;
static CCriticalSection fileLock = new CCriticalSection();
/// <summary>
/// Updates the config properties of a device
@@ -127,8 +128,6 @@ namespace PepperDash.Essentials.Core.Config
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Writing Configuration to file");
var fileLock = new CCriticalSection();
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to write config file: '{0}'", filePath);
try

View File

@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharp.Reflection;
using PepperDash.Core;
@@ -26,12 +24,7 @@ namespace PepperDash.Essentials.Core
var joinMap = ConfigReader.ConfigObject.JoinMaps[joinMapKey];
if (joinMap != null)
{
return joinMap;
}
else
return null;
return joinMap;
}
/// <summary>
@@ -46,17 +39,11 @@ namespace PepperDash.Essentials.Core
var joinMapSerialzed = ConfigReader.ConfigObject.JoinMaps[joinMapKey];
if (joinMapSerialzed != null)
{
var joinMapData = JsonConvert.DeserializeObject<Dictionary<string, JoinData>>(joinMapSerialzed);
if (joinMapSerialzed == null) return null;
if (joinMapData != null)
return joinMapData;
else
return null;
}
else
return null;
var joinMapData = JsonConvert.DeserializeObject<Dictionary<string, JoinData>>(joinMapSerialzed);
return joinMapData;
}
}
@@ -83,7 +70,7 @@ namespace PepperDash.Essentials.Core
/// </summary>
public void PrintJoinMapInfo()
{
Debug.Console(0, "{0}:\n", this.GetType().Name);
Debug.Console(0, "{0}:\n", GetType().Name);
// Get the joins of each type and print them
Debug.Console(0, "Digitals:");
@@ -138,10 +125,7 @@ namespace PepperDash.Essentials.Core
/// <returns></returns>
public uint GetJoinForKey(string key)
{
if (Joins.ContainsKey(key))
return Joins[key].JoinNumber;
else return 0;
return Joins.ContainsKey(key) ? Joins[key].JoinNumber : 0;
}
/// <summary>
@@ -151,12 +135,8 @@ namespace PepperDash.Essentials.Core
/// <returns></returns>
public uint GetJoinSpanForKey(string key)
{
if (Joins.ContainsKey(key))
return Joins[key].JoinSpan;
else return 0;
return Joins.ContainsKey(key) ? Joins[key].JoinSpan : 0;
}
}
/// <summary>
@@ -164,7 +144,7 @@ namespace PepperDash.Essentials.Core
/// </summary>
public abstract class JoinMapBaseAdvanced
{
protected uint _joinOffset;
protected uint JoinOffset;
/// <summary>
/// The collection of joins and associated metadata
@@ -175,36 +155,55 @@ namespace PepperDash.Essentials.Core
{
Joins = new Dictionary<string, JoinDataComplete>();
_joinOffset = joinStart - 1;
JoinOffset = joinStart - 1;
}
protected JoinMapBaseAdvanced(uint joinStart, Type type):this(joinStart)
{
AddJoins(type);
}
protected void AddJoins(Type type)
{
// Add all the JoinDataComplete properties to the Joins Dictionary and pass in the offset
Joins = this.GetType()
.GetCType()
.GetFields(BindingFlags.Public | BindingFlags.Instance)
.Where(field => field.IsDefined(typeof(JoinNameAttribute), false))
.Select(prop => (JoinDataComplete)prop.GetValue(this))
.ToDictionary(join => join.GetNameAttribute(), join =>
{
join.SetJoinOffset(_joinOffset);
return join;
});
//var type = this.GetType();
//var cType = type.GetCType();
//var fields = cType.GetFields(BindingFlags.Public | BindingFlags.Instance);
//foreach (var field in fields)
//{
// if (field.IsDefined(typeof(JoinNameAttribute), true))
// {
// var value = field.GetValue(this) as JoinDataComplete;
// if (value != null)
//Joins = this.GetType()
// .GetCType()
// .GetFields(BindingFlags.Public | BindingFlags.Instance)
// .Where(field => field.IsDefined(typeof(JoinNameAttribute), true))
// .Select(field => (JoinDataComplete)field.GetValue(this))
// .ToDictionary(join => join.GetNameAttribute(), join =>
// {
// value.SetJoinOffset(_joinOffset);
// Joins.Add(value.GetNameAttribute(), value);
// }
// }
//}
// join.SetJoinOffset(_joinOffset);
// return join;
// });
//type = this.GetType(); <- this wasn't working because 'this' was always the base class, never the derived class
var fields =
type.GetCType()
.GetFields(BindingFlags.Public | BindingFlags.Instance)
.Where(f => f.IsDefined(typeof (JoinNameAttribute), true));
foreach (var field in fields)
{
var childClass = Convert.ChangeType(this, type, null);
var value = field.GetValue(childClass) as JoinDataComplete; //this here is JoinMapBaseAdvanced, not the child class. JoinMapBaseAdvanced has no fields.
if (value == null)
{
Debug.Console(0, "Unable to caset base class to {0}", type.Name);
continue;
}
value.SetJoinOffset(JoinOffset);
var joinName = value.GetNameAttribute(field);
if (String.IsNullOrEmpty(joinName)) continue;
Joins.Add(joinName, value);
}
PrintJoinMapInfo();
}
@@ -214,7 +213,7 @@ namespace PepperDash.Essentials.Core
/// </summary>
public void PrintJoinMapInfo()
{
Debug.Console(0, "{0}:\n", this.GetType().Name);
Debug.Console(0, "{0}:\n", GetType().Name);
// Get the joins of each type and print them
Debug.Console(0, "Digitals:");
@@ -435,26 +434,33 @@ namespace PepperDash.Essentials.Core
_data = customJoinData;
}
public string GetNameAttribute()
public string GetNameAttribute(MemberInfo memberInfo)
{
string name = string.Empty;
JoinNameAttribute attribute = (JoinNameAttribute)Attribute.GetCustomAttribute(typeof(JoinDataComplete), typeof(JoinNameAttribute));
if (attribute != null)
{
name = attribute.Name;
}
var name = string.Empty;
var attribute = (JoinNameAttribute)CAttribute.GetCustomAttribute(memberInfo, typeof(JoinNameAttribute));
if (attribute == null) return name;
name = attribute.Name;
Debug.Console(2, "JoinName Attribute value: {0}", name);
return name;
}
}
[AttributeUsage(AttributeTargets.Field)]
[AttributeUsage(AttributeTargets.All)]
public class JoinNameAttribute : Attribute
{
public string Name { get; set; }
private string _Name;
public JoinNameAttribute(string name)
{
Name = name;
Debug.Console(2, "Setting Attribute Name: {0}", name);
_Name = name;
}
public string Name
{
get { return _Name; }
}
}
}