diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..c969d2a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,34 @@ +--- +name: Bug report +about: Create a report to help us improve +title: "[BUG]-" +labels: bug +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**Stacktrace** + +Include a stack trace of the exception if possible. +``` +Paste stack trace here +``` + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/essentials-plugin-request.md b/.github/ISSUE_TEMPLATE/essentials-plugin-request.md new file mode 100644 index 0000000..0bee158 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/essentials-plugin-request.md @@ -0,0 +1,17 @@ +--- +name: Essentials Plugin Request +about: Request an Essentials Plugin +title: "[REQUEST] - " +labels: plugin request +assignees: '' + +--- + +** Describe the Plugin ** +What do you want the plugin to do? Is it for a specific device? If it's for a specific device, include the manufacturer and model, along with links to API documentation if available. + +** Does it need to be available in SIMPL Windows? ** +If it does, describe the functionality that should be exposed to SIMPL Windows via EISC. This may include an example join map, or other way of documenting the layout of the EISC. + +** Additional Features or functionality ** +Describe additional features or functionality that this plugin should have. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..0a854e7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,21 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: "[FEATURE]-" +labels: enhancement +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] +If this is a request for support for a new device or type, be as specific as possible and include any pertinent manufacturer and model information. + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/scripts/GenerateVersionNumber.ps1 b/.github/scripts/GenerateVersionNumber.ps1 new file mode 100644 index 0000000..5d5a3ec --- /dev/null +++ b/.github/scripts/GenerateVersionNumber.ps1 @@ -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\/main*.' { + $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 diff --git a/.github/scripts/UpdateAssemblyVersion.ps1 b/.github/scripts/UpdateAssemblyVersion.ps1 new file mode 100644 index 0000000..e52b31e --- /dev/null +++ b/.github/scripts/UpdateAssemblyVersion.ps1 @@ -0,0 +1,40 @@ +function Update-SourceVersion { + Param ([string]$Version) + #$fullVersion = $Version + $baseVersion = [regex]::Match($Version, "(\d+.\d+.\d+).*").captures.groups[1].value + $NewAssemblyVersion = ‘AssemblyVersion("‘ + $baseVersion + ‘.*")’ + Write-Output "AssemblyVersion = $NewAssemblyVersion" + $NewAssemblyInformationalVersion = ‘AssemblyInformationalVersion("‘ + $Version + ‘")’ + Write-Output "AssemblyInformationalVersion = $NewAssemblyInformationalVersion" + + foreach ($o in $input) { + Write-output $o.FullName + $TmpFile = $o.FullName + “.tmp” + get-content $o.FullName | + ForEach-Object { + $_ -replace ‘AssemblyVersion\(".*"\)’, $NewAssemblyVersion } | + ForEach-Object { + $_ -replace ‘AssemblyInformationalVersion\(".*"\)’, $NewAssemblyInformationalVersion + } > $TmpFile + move-item $TmpFile $o.FullName -force + } +} + +function Update-AllAssemblyInfoFiles ( $version ) { + foreach ($file in “AssemblyInfo.cs”, “AssemblyInfo.vb” ) { + get-childitem -Path $Env:GITHUB_WORKSPACE -recurse | Where-Object { $_.Name -eq $file } | Update-SourceVersion $version ; + } +} + +# validate arguments +$r = [System.Text.RegularExpressions.Regex]::Match($args[0], "\d+\.\d+\.\d+.*"); +if ($r.Success) { + Write-Output "Updating Assembly Version to $args ..."; + Update-AllAssemblyInfoFiles $args[0]; +} +else { + Write-Output ” “; + Write-Output “Error: Input version does not match x.y.z format!” + Write-Output ” “; + Write-Output "Unable to apply version to AssemblyInfo.cs files"; +} diff --git a/.github/scripts/ZipBuildOutput.ps1 b/.github/scripts/ZipBuildOutput.ps1 new file mode 100644 index 0000000..ca4a9a7 --- /dev/null +++ b/.github/scripts/ZipBuildOutput.ps1 @@ -0,0 +1,42 @@ +# Uncomment these for local testing +# $Env:GITHUB_WORKSPACE = "C:\Working Directories\PD\essentials" +# $Env:SOLUTION_FILE = "PepperDashEssentials" +# $Env:VERSION = "0.0.0-buildType-test" + +# Sets the root directory for the operation +$destination = "$($Env:GITHUB_HOME)\output" +New-Item -ItemType Directory -Force -Path ($destination) +Get-ChildItem ($destination) +$exclusions = @(git submodule foreach --quiet 'echo $name') +# Trying to get any .json schema files (not currently working) +# Gets any files with the listed extensions. +Get-ChildItem -recurse -Path "$($Env:GITHUB_WORKSPACE)" -include "*.cplz" | ForEach-Object { + $allowed = $true; + # Exclude any files in submodules + foreach ($exclude in $exclusions) { + if ((Split-Path $_.FullName -Parent).contains("$($exclude)")) { + $allowed = $false; + break; + } + } + if ($allowed) { + Write-Host "allowing $($_)" + $_; + } +} | Copy-Item -Destination ($destination) -Force +Write-Host "Getting matching files..." +# Get any files from the output folder that match the following extensions +Get-ChildItem -Path $destination | Where-Object {($_.Extension -eq ".clz") -or ($_.Extension -eq ".cpz" -or ($_.Extension -eq ".cplz"))} | ForEach-Object { + # Replace the extensions with dll and xml and create an array + $filenames = @($($_ -replace "cpz|clz|cplz", "dll"), $($_ -replace "cpz|clz|cplz", "xml")) + Write-Host "Filenames:" + Write-Host $filenames + if ($filenames.length -gt 0) { + # Attempt to get the files and return them to the output directory + Get-ChildItem -Recurse -Path "$($Env:GITHUB_WORKSPACE)" -include $filenames | Copy-Item -Destination ($destination) -Force + } +} +Get-ChildItem -Path $destination\*.cplz | Rename-Item -NewName { "$($_.BaseName)-$($Env:VERSION)$($_.Extension)" } +Compress-Archive -Path $destination -DestinationPath "$($Env:GITHUB_WORKSPACE)\$($Env:SOLUTION_FILE)-$($Env:VERSION).zip" -Force +Write-Host "Output Contents post Zip" +Get-ChildItem -Path $destination \ No newline at end of file diff --git a/.github/workflows/essentialsplugins-betabuilds-caller.yml b/.github/workflows/essentialsplugins-betabuilds-caller.yml new file mode 100644 index 0000000..8ca618c --- /dev/null +++ b/.github/workflows/essentialsplugins-betabuilds-caller.yml @@ -0,0 +1,22 @@ +name: Beta Build + +on: + push: + branches-ignore: + - "main" + + workflow_dispatch: + inputs: + branch: + description: 'Branch to build' + required: true + type: string + +jobs: + call-workflow: + uses: PepperDash/workflow-templates/.github/workflows/essentialsplugins-builds.yml@main + secrets: inherit + with: + branch: ${{ github.ref_name }} + default-branch: "main" + diff --git a/.github/workflows/essentialsplugins-releasebuilds-caller.yml b/.github/workflows/essentialsplugins-releasebuilds-caller.yml new file mode 100644 index 0000000..c8a3374 --- /dev/null +++ b/.github/workflows/essentialsplugins-releasebuilds-caller.yml @@ -0,0 +1,24 @@ + +name: Release Build + +on: + release: + types: + - released + branches: + - "main" + + workflow_dispatch: + inputs: + branch: + description: 'Branch to build' + required: true + type: string + +jobs: + call-workflow: + uses: PepperDash/workflow-templates/.github/workflows/essentialsplugins-builds.yml@main + secrets: inherit + with: + branch: "main" + default-branch: "main" \ No newline at end of file diff --git a/GetPackages.BAT b/GetPackages.BAT new file mode 100644 index 0000000..9b6def3 --- /dev/null +++ b/GetPackages.BAT @@ -0,0 +1,2 @@ +@Echo ON +nuget install .\packages.config -OutputDirectory .\packages -excludeVersion diff --git a/packages.config b/packages.config new file mode 100644 index 0000000..c0df495 --- /dev/null +++ b/packages.config @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/Bridge/ColorlightZ6JoinMap.cs b/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/Bridge/ColorlightZ6JoinMap.cs deleted file mode 100644 index 3ec0a19..0000000 --- a/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/Bridge/ColorlightZ6JoinMap.cs +++ /dev/null @@ -1,48 +0,0 @@ -using PepperDash.Essentials.Core; - -namespace PepperDash.Essentials.Generic.ColorlightZ6.Bridge -{ - public class ColorlightZ6JoinMap : JoinMapBaseAdvanced - { - [JoinName("brightness")] public JoinDataComplete Brightness = - new JoinDataComplete(new JoinData {JoinNumber = 1, JoinSpan = 1}, - new JoinMetadata - { - Label = "Brightness control", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("preset")] public JoinDataComplete Preset = - new JoinDataComplete(new JoinData {JoinNumber = 2, JoinSpan = 1}, - new JoinMetadata - { - Label = "Preset Recall", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Analog - }); - - [JoinName("showOn")] public JoinDataComplete ShowOn = - new JoinDataComplete(new JoinData {JoinNumber = 1, JoinSpan = 1}, - new JoinMetadata - { - Label = "Show On", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("showOff")] public JoinDataComplete ShowOff = - new JoinDataComplete(new JoinData {JoinNumber = 1, JoinSpan = 1}, - new JoinMetadata - { - Label = "Show Off", - JoinCapabilities = eJoinCapabilities.FromSIMPL, - JoinType = eJoinType.Digital - }); - - public ColorlightZ6JoinMap(uint joinStart) : base(joinStart, typeof (ColorlightZ6JoinMap)) - { - } - - } -} \ No newline at end of file diff --git a/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/ColorlightZ6Controller.cs b/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/ColorlightZ6Controller.cs deleted file mode 100644 index 3b4385b..0000000 --- a/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/ColorlightZ6Controller.cs +++ /dev/null @@ -1,183 +0,0 @@ -using System; -using System.Linq; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro.CrestronThread; -using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Generic.ColorlightZ6; -using PepperDash.Essentials.Generic.ColorlightZ6.Bridge; - -namespace Pepperdash.Essentials.Generic.ColorlightZ6 -{ - public class ColorlightZ6Controller:EssentialsBridgeableDevice - { - private Thread _queueProcess; - private readonly CrestronQueue _myQueue = new CrestronQueue(100); - private CTimer _heartbeatTimer; - private const long HeartbeatTime = 1000; - private readonly ushort _id; - - public IBasicCommunication Communications { get; private set; } - - public ColorlightZ6Controller(string key, string name, IBasicCommunication comm, ColorlightZ6Properties config):base(key, name) - { - Communications = comm; - - var socket = Communications as ISocketStatus; - - if (socket != null) - { - socket.ConnectionChange += SocketOnConnectionChange; - } - - Communications.BytesReceived += CommunicationsOnBytesReceived; - - _id = config.Id; - - Debug.Console(0,this, "Creating Colorlight Z6 controller with id {0}", _id); - } - - private void CommunicationsOnBytesReceived(object sender, GenericCommMethodReceiveBytesArgs genericCommMethodReceiveBytesArgs) - { - Debug.Console(0,this,"Device Response: {0}", BitConverter.ToString(genericCommMethodReceiveBytesArgs.Bytes)); - - _myQueue.Enqueue(genericCommMethodReceiveBytesArgs.Bytes); - - if (_queueProcess == null || _queueProcess.ThreadState == Thread.eThreadStates.ThreadFinished) return; - - _queueProcess = new Thread(ProcessQueue, null); - } - - private object ProcessQueue(object obj) - { - while (!_myQueue.IsEmpty) - { - var myResponse = _myQueue.Dequeue(); - - Debug.Console(2, this, "response: {0}", myResponse); - } - return null; - } - - public override bool CustomActivate() - { - Debug.Console(0, this, "Activating Colorlight Z6 {0}", _id); - Communications.Connect(); - return true; - } - - private void SocketOnConnectionChange(object sender, GenericSocketStatusChageEventArgs genericSocketStatusChageEventArgs) - { - if (genericSocketStatusChageEventArgs.Client.IsConnected) - { - if (_heartbeatTimer == null) - { - _heartbeatTimer = new CTimer(SendHeartbeat,null, 0, HeartbeatTime); - } - - return; - } - - _heartbeatTimer.Stop(); - _heartbeatTimer.Dispose(); - _heartbeatTimer = null; - } - - private void SendHeartbeat(object o) - { - Communications.SendBytes(new byte[]{0x99, 0x99, 0x04, 0x00}); - } - - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - Debug.Console(0, this, "Connecting to SIMPL Bridge with joinStart {0}", joinStart); - - var joinMap = new ColorlightZ6JoinMap(joinStart); - - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - - var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey); - - if (customJoins != null) - { - joinMap.SetCustomJoinData(customJoins); - } - - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to Bridge Type {0}", GetType().Name); - - - trilist.SetUShortSigAction(joinMap.Brightness.JoinNumber, SetBrightness); - - - trilist.SetUShortSigAction(joinMap.Preset.JoinNumber, RecallPreset); - - - trilist.SetBoolSigAction(joinMap.ShowOn.JoinNumber, SetShowOn); - - - trilist.SetBoolSigAction(joinMap.ShowOff.JoinNumber, SetShowOff); - } - - public void SetBrightness(ushort brightness) - { - var brightnessPercent = (float) Math.Round(brightness/65535.0f,1); - - Debug.Console(0,this,"Brightness Level {0} Percent {1}", brightness, brightnessPercent * 100); - - var brightnessBytes = BitConverter.GetBytes(brightnessPercent); - - var commandBase = new byte[] - { - 0x21, 0x00, 0x14, 0x00, 0x00, 0x00, (byte) (_id >> 8), (byte) (_id & 0xFF), 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00 - }; - - var command = commandBase.Concat(brightnessBytes).ToArray(); - - Debug.Console(0, this, "Brightness Command {0}", BitConverter.ToString(command)); - - Communications.SendBytes(command); - } - - public void RecallPreset(ushort preset) - { - var command = new byte[] - { - 0x74, 0x00, 0x11, 0x00, 0x00, 0x00, (byte) (_id >> 8), (byte) (_id & 0xFF), 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, (byte) preset - }; - - Debug.Console(0, this, "Preset Command {0}", BitConverter.ToString(command)); - Communications.SendBytes(command); - } - - public void SetShowOn(bool notUsed) - { - var command = new byte[] - { - 0x11, 0x00, 0x11, 0x00, 0x00, 0x00, (byte) (_id >> 8), (byte) (_id & 0xFF), 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x01 - }; - - Communications.SendBytes(command); - } - - public void SetShowOff(bool notUsed) - { - var command = new byte[] - { - 0x11, 0x00, 0x11, 0x00, 0x00, 0x00, (byte) (_id >> 8), (byte) (_id & 0xFF), 0xFF, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 - }; - - Communications.SendBytes(command); - } - } -} - diff --git a/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi.projectinfo b/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi.projectinfo deleted file mode 100644 index c7c829c..0000000 Binary files a/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi.projectinfo and /dev/null differ diff --git a/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi.sln b/src/ColorlightZ6.sln similarity index 78% rename from pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi.sln rename to src/ColorlightZ6.sln index 702ba59..ae11888 100644 --- a/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi.sln +++ b/src/ColorlightZ6.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 10.00 # Visual Studio 2008 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pepperdash-generic-colorlightZ6-epi", "pepperdash-generic-colorlightZ6-epi\pepperdash-generic-colorlightZ6-epi.csproj", "{8F8B7548-7AE3-4899-9B3B-5877767F4984}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "epi-colorlight-Z6", "epi-colorlight-Z6.csproj", "{8F8B7548-7AE3-4899-9B3B-5877767F4984}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/ColorlightZ6BridgeJoinMap.cs b/src/ColorlightZ6BridgeJoinMap.cs new file mode 100644 index 0000000..8778cff --- /dev/null +++ b/src/ColorlightZ6BridgeJoinMap.cs @@ -0,0 +1,83 @@ +using PepperDash.Essentials.Core; + +namespace ColorlightZ6 +{ + public class ColorlightZ6JoinMap : JoinMapBaseAdvanced + { + [JoinName("Brightness")] public JoinDataComplete Brightness = + new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Brightness control", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("Preset")] public JoinDataComplete Preset = + new JoinDataComplete( + new JoinData + { + JoinNumber = 2, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Preset Recall", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Analog + }); + + [JoinName("ShowOn")] public JoinDataComplete ShowOn = + new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Show On", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("ShowOff")] public JoinDataComplete ShowOff = + new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Show Off", + JoinCapabilities = eJoinCapabilities.FromSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("Name")] + public JoinDataComplete DeviceName = new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Device Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + public ColorlightZ6JoinMap(uint joinStart) + : base(joinStart, typeof (ColorlightZ6JoinMap)) + { + } + + } +} \ No newline at end of file diff --git a/src/ColorlightZ6Controller.cs b/src/ColorlightZ6Controller.cs new file mode 100644 index 0000000..ed2fc94 --- /dev/null +++ b/src/ColorlightZ6Controller.cs @@ -0,0 +1,182 @@ +using System; +using System.Linq; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.CrestronThread; +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; + +namespace ColorlightZ6 +{ + public class ColorlightZ6Controller : EssentialsBridgeableDevice + { + private Thread _queueProcess; + private readonly CrestronQueue _myQueue = new CrestronQueue(100); + private CTimer _heartbeatTimer; + private const long HeartbeatTime = 1000; + private readonly ushort _id; + + public IBasicCommunication Communications { get; private set; } + + public ColorlightZ6Controller(string key, string name, IBasicCommunication comm, ColorlightZ6Properties config) + : base(key, name) + { + Communications = comm; + + var socket = Communications as ISocketStatus; + + if (socket != null) + { + socket.ConnectionChange += SocketOnConnectionChange; + } + + Communications.BytesReceived += CommunicationsOnBytesReceived; + + _id = config.Id; + + Debug.Console(0, this, "Creating Colorlight Z6 controller with id {0}", _id); + } + + private void CommunicationsOnBytesReceived(object sender, GenericCommMethodReceiveBytesArgs genericCommMethodReceiveBytesArgs) + { + Debug.Console(0, this, "Device Response: {0}", BitConverter.ToString(genericCommMethodReceiveBytesArgs.Bytes)); + + _myQueue.Enqueue(genericCommMethodReceiveBytesArgs.Bytes); + + if (_queueProcess == null || _queueProcess.ThreadState == Thread.eThreadStates.ThreadFinished) return; + + _queueProcess = new Thread(ProcessQueue, null); + } + + private object ProcessQueue(object obj) + { + while (!_myQueue.IsEmpty) + { + var myResponse = _myQueue.Dequeue(); + + Debug.Console(2, this, "response: {0}", myResponse); + } + return null; + } + + public override bool CustomActivate() + { + Debug.Console(0, this, "Activating Colorlight Z6 {0}", _id); + Communications.Connect(); + return true; + } + + private void SocketOnConnectionChange(object sender, GenericSocketStatusChageEventArgs genericSocketStatusChageEventArgs) + { + if (genericSocketStatusChageEventArgs.Client.IsConnected) + { + if (_heartbeatTimer == null) + { + _heartbeatTimer = new CTimer(SendHeartbeat, null, 0, HeartbeatTime); + } + + return; + } + + _heartbeatTimer.Stop(); + _heartbeatTimer.Dispose(); + _heartbeatTimer = null; + } + + private void SendHeartbeat(object o) + { + Communications.SendBytes(new byte[] { 0x99, 0x99, 0x04, 0x00 }); + } + + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + Debug.Console(0, this, "Connecting to SIMPL Bridge with joinStart {0}", joinStart); + + var joinMap = new ColorlightZ6JoinMap(joinStart); + + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + + var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey); + + if (customJoins != null) + { + joinMap.SetCustomJoinData(customJoins); + } + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(0, "Linking to Bridge Type {0}", GetType().Name); + + + trilist.SetUShortSigAction(joinMap.Brightness.JoinNumber, SetBrightness); + + + trilist.SetUShortSigAction(joinMap.Preset.JoinNumber, RecallPreset); + + + trilist.SetBoolSigAction(joinMap.ShowOn.JoinNumber, SetShowOn); + + + trilist.SetBoolSigAction(joinMap.ShowOff.JoinNumber, SetShowOff); + } + + public void SetBrightness(ushort brightness) + { + var brightnessPercent = (float)Math.Round(brightness / 65535.0f, 1); + + Debug.Console(0, this, "Brightness Level {0} Percent {1}", brightness, brightnessPercent * 100); + + var brightnessBytes = BitConverter.GetBytes(brightnessPercent); + + var commandBase = new byte[] + { + 0x21, 0x00, 0x14, 0x00, 0x00, 0x00, (byte) (_id >> 8), (byte) (_id & 0xFF), 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00 + }; + + var command = commandBase.Concat(brightnessBytes).ToArray(); + + Debug.Console(0, this, "Brightness Command {0}", BitConverter.ToString(command)); + + Communications.SendBytes(command); + } + + public void RecallPreset(ushort preset) + { + var command = new byte[] + { + 0x74, 0x00, 0x11, 0x00, 0x00, 0x00, (byte) (_id >> 8), (byte) (_id & 0xFF), 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, (byte) preset + }; + + Debug.Console(0, this, "Preset Command {0}", BitConverter.ToString(command)); + Communications.SendBytes(command); + } + + public void SetShowOn(bool notUsed) + { + var command = new byte[] + { + 0x11, 0x00, 0x11, 0x00, 0x00, 0x00, (byte) (_id >> 8), (byte) (_id & 0xFF), 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01 + }; + + Communications.SendBytes(command); + } + + public void SetShowOff(bool notUsed) + { + var command = new byte[] + { + 0x11, 0x00, 0x11, 0x00, 0x00, 0x00, (byte) (_id >> 8), (byte) (_id & 0xFF), 0xFF, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00 + }; + + Communications.SendBytes(command); + } + } +} + diff --git a/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/PluginFactory.cs b/src/ColorlightZ6Factory.cs similarity index 54% rename from pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/PluginFactory.cs rename to src/ColorlightZ6Factory.cs index dde6c51..f737513 100644 --- a/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/PluginFactory.cs +++ b/src/ColorlightZ6Factory.cs @@ -1,10 +1,9 @@ using System.Collections.Generic; using PepperDash.Core; -using Pepperdash.Essentials.Generic.ColorlightZ6; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; -namespace PepperDash.Essentials.Generic.ColorlightZ6 +namespace ColorlightZ6 { public class PluginFactory: EssentialsPluginDeviceFactory { @@ -19,14 +18,21 @@ public PluginFactory() public override EssentialsDevice BuildDevice(DeviceConfig dc) { - Debug.Console(0, "Creating Colorlight Z6 controller..."); - var comm = CommFactory.CreateCommForDevice(dc); + Debug.Console(1, "[{0}] Factory Attempting to create new device from type: {1}", dc.Key, dc.Type); var config = dc.Properties.ToObject(); - - var device = new ColorlightZ6Controller(dc.Key, dc.Name, comm, config); - - return device; + if (config == null) + { + Debug.Console(0, "[{0}] Factory: failed to read properties config for {1}", dc.Key, dc.Name); + return null; + } + + var comm = CommFactory.CreateCommForDevice(dc); + + if(comm != null) return new ColorlightZ6Controller(dc.Key, dc.Name, comm, config); + + Debug.Console(0, "[{0}] Factory Notice: No control object present for device {1}", dc.Key, dc.Name); + return null; } #endregion diff --git a/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/ColorlightZ6Properties.cs b/src/ColorlightZ6PropertiesConfig.cs similarity index 56% rename from pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/ColorlightZ6Properties.cs rename to src/ColorlightZ6PropertiesConfig.cs index 75ab43c..960c9a8 100644 --- a/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/ColorlightZ6Properties.cs +++ b/src/ColorlightZ6PropertiesConfig.cs @@ -1,11 +1,14 @@ -using PepperDash.Core; +using Newtonsoft.Json; +using PepperDash.Core; -namespace PepperDash.Essentials.Generic.ColorlightZ6 +namespace ColorlightZ6 { public class ColorlightZ6Properties { + [JsonProperty("control")] public ControlPropertiesConfig Control { get; set; } + [JsonProperty("id")] public ushort Id { get; set; } } } \ No newline at end of file diff --git a/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs similarity index 100% rename from pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/Properties/AssemblyInfo.cs rename to src/Properties/AssemblyInfo.cs diff --git a/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/Properties/ControlSystem.cfg b/src/Properties/ControlSystem.cfg similarity index 100% rename from pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/Properties/ControlSystem.cfg rename to src/Properties/ControlSystem.cfg diff --git a/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi.csproj b/src/epi-colorlight-Z6.csproj similarity index 86% rename from pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi.csproj rename to src/epi-colorlight-Z6.csproj index 1f4100b..8cd175b 100644 --- a/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi/pepperdash-generic-colorlightZ6-epi.csproj +++ b/src/epi-colorlight-Z6.csproj @@ -7,8 +7,8 @@ {8F8B7548-7AE3-4899-9B3B-5877767F4984} Library Properties - pepperdash_generic_colorlightZ6_epi - pepperdash-generic-colorlightZ6-epi + ColorlightZ6 + PepperDash.Essentials.Plugin.Colorlight.Z6 {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} WindowsCE E2BECB1F-8C8C-41ba-B736-9BE7D946A398 @@ -46,14 +46,18 @@ off + + False + ..\packages\PepperDashEssentials\lib\net35\Essentials Devices Common.dll + False - ..\..\submodule\essentials-builds\PepperDash_Core.dll + ..\packages\PepperDashEssentials\lib\net35\PepperDash_Core.dll False - ..\..\submodule\essentials-builds\PepperDash_Essentials_Core.dll + ..\packages\PepperDashEssentials\lib\net35\PepperDash_Essentials_Core.dll False @@ -83,10 +87,10 @@ - + - - + + diff --git a/submodule/essentials-builds b/submodule/essentials-builds deleted file mode 160000 index 39b4d07..0000000 --- a/submodule/essentials-builds +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 39b4d07afdd86136600e5cc0c30c00a1e5400c6e diff --git a/submodules/Essentials Devices Common.cplz b/submodules/Essentials Devices Common.cplz deleted file mode 100644 index 3e205cd..0000000 Binary files a/submodules/Essentials Devices Common.cplz and /dev/null differ diff --git a/submodules/Essentials Devices Common.dll b/submodules/Essentials Devices Common.dll deleted file mode 100644 index bb87f57..0000000 Binary files a/submodules/Essentials Devices Common.dll and /dev/null differ diff --git a/submodules/Essentials_DM.cplz b/submodules/Essentials_DM.cplz deleted file mode 100644 index 60f6ad6..0000000 Binary files a/submodules/Essentials_DM.cplz and /dev/null differ diff --git a/submodules/PepperDashEssentials.cpz b/submodules/PepperDashEssentials.cpz deleted file mode 100644 index 02d7082..0000000 Binary files a/submodules/PepperDashEssentials.cpz and /dev/null differ diff --git a/submodules/PepperDashEssentials.dll b/submodules/PepperDashEssentials.dll deleted file mode 100644 index 3d1a256..0000000 Binary files a/submodules/PepperDashEssentials.dll and /dev/null differ diff --git a/submodules/PepperDash_Core.clz b/submodules/PepperDash_Core.clz deleted file mode 100644 index 73ffceb..0000000 Binary files a/submodules/PepperDash_Core.clz and /dev/null differ diff --git a/submodules/PepperDash_Core.dll b/submodules/PepperDash_Core.dll deleted file mode 100644 index 308d3a6..0000000 Binary files a/submodules/PepperDash_Core.dll and /dev/null differ diff --git a/submodules/PepperDash_Core.xml b/submodules/PepperDash_Core.xml deleted file mode 100644 index c0f11a3..0000000 --- a/submodules/PepperDash_Core.xml +++ /dev/null @@ -1,3656 +0,0 @@ - - - - PepperDash_Core - - - - - The core event and status-bearing class that most if not all device and connectors can derive from. - - - - - Named Keyed device interface. Forces the devie to have a Unique Key and a name. - - - - - Unique key interface to require a unique key for the class - - - - - Unique Key - - - - - Isn't it obvious :) - - - - - Base constructor for all Devices. - - - - - - Gets this device ready to be used in the system. Runs any added pre-activation items, and - all post-activation at end. Classes needing additional logic to - run should override CustomActivate() - - - - - Called in between Pre and PostActivationActions when Activate() is called. - Override to provide addtitional setup when calling activation. Overriding classes - do not need to call base.CustomActivate() - - true if device activated successfully. - - - - Call to deactivate device - unlink events, etc. Overriding classes do not - need to call base.Deactivate() - - - - - - Helper method to check object for bool value false and fire an Action method - - Should be of type bool, others will be ignored - Action to be run when o is false - - - - Unique Key - - - - - Name of the devie - - - - - - - - - - - - - - - A bandaid client that monitors whether the server is reachable - - - - - Timer to operate the bandaid monitor client in a loop. - - - - - - - - - - - - - - - constructor S+ Does not accept a key. Use initialze with key to set the debug key on this device. If using with + make sure to set all properties manually. - - - - - constructor with debug key set at instantiation. Make sure to set all properties before listening. - - - - - - Contstructor that sets all properties by calling the initialize method with a config object. - - - - - - Disconnects all clients and stops the server - - - - - Initialize Key for device using client name from SIMPL+. Called on Listen from SIMPL+ - - - - - - Start listening on the specified port - - - - - Stop Listeneing - - - - - Disconnects Client - - - - - - Disconnect All Clients - - - - - Broadcast text from server to all connected clients - - - - - - Not sure this is useful in library, maybe Pro?? - - - - - - - Secure Server Socket Status Changed Callback - - - - - - - - Secure TCP Client Connected to Secure Server Callback - - - - - - - Secure Received Data Async Callback - - - - - - - - Private Event Handler method to handle the closing of connections when the program stops - - - - - - Starts the monitor client cycle. Timed wait, then call RunMonitorClient - - - - - - - - - - - - - - - On monitor connect, restart the operation - - - - - If the client hangs, add to counter and maybe fire the choke event - - - - - Event for Receiving text - - - - - Event for client connection socket status change - - - - - Event for Server State Change - - - - - For a server with a pre shared key, this will fire after the communication is established and the key exchange is complete. If no shared key, this will fire - after connection is successful. Use this event to know when the client is ready for communication to avoid stepping on shared key. - - - - - A band aid event to notify user that the server has choked. - - - - - 3 by default - - - - - Text representation of the Socket Status enum values for the server - - - - - Bool showing if socket is connected - - - - - S+ helper for IsConnected - - - - - Bool showing if socket is connected - - - - - S+ helper for IsConnected - - - - - Number of clients currently connected. - - - - - Port Server should listen on - - - - - S+ helper for Port - - - - - Bool to show whether the server requires a preshared key. Must be set the same in the client, and if true shared keys must be identical on server/client - - - - - S+ helper for requires shared key bool - - - - - SharedKey is sent for varification to the server. Shared key can be any text (255 char limit in SIMPL+ Module), but must match the Shared Key on the Server module. - If SharedKey changes while server is listening or clients are connected, disconnect and stop listening will be called - - - - - Heartbeat Required bool sets whether server disconnects client if heartbeat is not received - - - - - S+ Helper for Heartbeat Required - - - - - Milliseconds before server expects another heartbeat. Set by property HeartbeatRequiredIntervalInSeconds which is driven from S+ - - - - - Simpl+ Heartbeat Analog value in seconds - - - - - String to Match for heartbeat. If null or empty any string will reset heartbeat timer - - - - - Defaults to 2000 - - - - - Private flag to note that the server has stopped intentionally - - - - - Constants - - - - - Generic boolean change - - - - - Generic Ushort change - - - - - Response Code Ushort change - - - - - Generic String chagne - - - - - Response string change - - - - - Error string change - - - - - An embedded JsonToSimpl master object. - - - - - SIMPL+ can only execute the default constructor. If you have variables that require initialization, please - use an Initialize method - - - - - - - - - - - - - - - - - - - After save operation on JSON master happens, send it to server - - - - - - Constructor - - - - - Initialize method - - - - - Retrieve password by index - - - - - - Password validation method - - - - - - Builds the user entered passwrod string, will attempt to validate the user entered - password against the selected password when the length of the 2 are equal - - - - - - Clears the user entered password and resets the LEDs - - - - - Protected boolean change event handler - - - - - - - - Protected ushort change event handler - - - - - - - - Protected string change event handler - - - - - - - - If password changes while selected change event will be notifed and update the client - - - - - - - Password selected - - - - - Password selected key - - - - - Used to build the password entered by the user - - - - - Boolean event - - - - - Ushort event - - - - - String event - - - - Privates * - - - - SIMPL+ default constructor. - - - - - Sets up class - overriding methods should always call this. - - - - - - Adds a child "module" to this master - - - - - - Called from the child to add changed or new values for saving - - - - Events * - - - - Mirrors the Unique ID for now. - - - - - Merely for use in debug messages - - - - - This will be prepended to all paths to allow path swapping or for more organized - sub-paths - - - - - This is added to the end of all paths - - - - - Enables debugging output to the console. Certain error messages will be logged to the - system's error log regardless of this setting - - - - - Ushort helper for Debug property - - - - Privates * - - - - SIMPL+ default constructor. - - - - - Read, evaluate and udpate status - - - - - Sets the filepath as well as registers this with the Global.Masters list - - - - - Represents a device that uses basic connection - - - - - An incoming communication stream - - - - - For IBasicCommunication classes that have SocketStatus. GenericSshClient, - GenericTcpIpClient - - - - - Queue to temporarily store received messages with the source IP and Port info - - - - - Constructor for S+. Make sure to set key, address, port, and buffersize using init method - - - - - - - - - - - - - - Call from S+ to initialize values - - - - - - - - - - - - - - - - - - - - Enables the UDP Server - - - - - Disabled the UDP Server - - - - - Recursive method to receive data - - - - - - - This method gets spooled up in its own thread an protected by a CCriticalSection to prevent multiple threads from running concurrently. - It will dequeue items as they are enqueued automatically. - - - - - General send method - - - - - - - - - - - - - - - - - - - - - - This event will fire when a message is dequeued that includes the source IP and Port info if needed to determine the source of the received data. - - - - - - - - - - - - - - - - - - - - - - - - - Address of server - - - - - Port on server - - - - - Another damn S+ helper because S+ seems to treat large port nums as signed ints - which screws up things - - - - - Indicates that the UDP Server is enabled - - - - - Defaults to 2000 - - - - - - - - - - - - - - - - - - - Stupid S+ Constructor - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Defaults to 32768 - - - - - - - - - - Typical constructor. - - - - - S+ Constructor - Must set all properties before calling Connect - - - - - Just to help S+ set the key - - - - - Handles closing this up when the program shuts down - - - - - Connect to the server, using the provided properties. - - - - - Disconnect the clients and put away it's resources. - - - - - Kills the stream, cleans up the client and sets it to null - - - - - Anything to do with reestablishing connection on failures - - - - - Kills the stream - - - - - Handles the keyboard interactive authentication, should it be required. - - - - - Handler for data receive on ShellStream. Passes data across to queue for line parsing. - - - - - Error event handler for client events - disconnect, etc. Will forward those events via ConnectionChange - event - - - - - Helper for ConnectionChange event - - - - - Sends text to the server - - - - - - Sends Bytes to the server - - - - - - Event that fires when data is received. Delivers args with byte array - - - - - Event that fires when data is received. Delivered as text. - - - - - Event when the connection status changes. - - - - - Address of server - - - - - Port on server - - - - - Username for server - - - - - And... Password for server. That was worth documenting! - - - - - True when the server is connected - when status == 2. - - - - - S+ helper for IsConnected - - - - - - - - - - Contains the familiar Simpl analog status values. This drives the ConnectionChange event - and IsConnected with be true when this == 2. - - - - - Determines whether client will attempt reconnection on failure. Default is true - - - - - Will be set and unset by connect and disconnect only - - - - - S+ helper for AutoReconnect - - - - - Millisecond value, determines the timeout period in between reconnect attempts. - Set to 5000 by default - - - - - Fired when connection changes - - - - - S+ Constructor - - - - - EventArgs class - - Connection State - The Client - - - - Connection State - - - - - Connection Status represented as a ushort - - - - - The client - - - - - Socket Status as represented by - - - - Privates * - - - - SIMPL+ default constructor. - - - - - Loads in JSON and triggers evaluation on all children - - - - - - Loads JSON into JsonObject, but does not trigger evaluation by children - - - - - - - - - - - Adds a file master. If the master's key or filename is equivalent to any existing - master, this will fail - - New master to add - - - - - Gets a master by its key. Case-insensitive - - - - - Not in use - - - - - Not in use - - - - - Generic RESTful communication class - - - - - Constructor - - - - - Generic RESTful submit request - - - - - - - - - - Private HTTP submit request - - - - - - - - - - Private HTTPS submit request - - - - - - - - - - Private method to encode username and password to Base64 string - - - - authorization - - - - Protected method to handle boolean change events - - - - - - - - Protected mehtod to handle ushort change events - - - - - - - - Protected method to handle string change events - - - - - - - - Boolean event handler - - - - - Ushort event handler - - - - - String event handler - - - - - Tcp Server Config object with properties for a tcp server with shared key and heartbeat capabilities - - - - - Uique key - - - - - Max Clients that the server will allow to connect. - - - - - Bool value for secure. Currently not implemented in TCP sockets as they are not dynamic - - - - - Port for the server to listen on - - - - - Require a shared key that both server and client negotiate. If negotiation fails server disconnects the client - - - - - The shared key that must match on the server and client - - - - - Require a heartbeat on the client/server connection that will cause the server/client to disconnect if the heartbeat is not received. - heartbeats do not raise received events. - - - - - The interval in seconds for the heartbeat from the client. If not received client is disconnected - - - - - HeartbeatString that will be checked against the message received. defaults to heartbeat if no string is provided. - - - - - Client buffer size. See Crestron help. defaults to 2000 if not greater than 2000 - - - - - Receive Queue size must be greater than 20 or defaults to 20 - - - - - - - - - - - - - - - - - - - Stores the state of the request - - - - - Waithandle for main thread. - - - - - - - - - - Defaults to Environment.NewLine; - - - - - This is something of a band-aid callback. If the client times out during the connection process, because the server - is stuck, this will fire. It is intended to be used by the Server class monitor client, to help - keep a watch on the server and reset it if necessary. - - - - - Semaphore on connect method - - - - - Flag Set only when the disconnect method is called. - - - - - private Timer for auto reconnect - - - - - Used to force disconnection on a dead connect attempt - - - - - Internal secure client - - - - - Queue lock - - - - - Queue to temporarily store received messages with the source IP and Port info. Defaults to size 20. Use constructor or set queue size property before - calling initialize. - - - - - Contstructor that sets all properties by calling the initialize method with a config object. - - - - - - Just to help S+ set the key - - - - - Initialize called by the constructor that accepts a client config object. Can be called later to reset properties of client. - - - - - - Handles closing this up when the program shuts down - - - - - Connect Method. Will return if already connected. Will write errors if missing address, port, or unique key/name. - - - - - - - - - - Internal call to close up client. ALWAYS use this when disconnecting. - - - - ff - Called from Connect failure or Socket Status change if - auto reconnect and socket disconnected (Not disconnected by user) - - - - - Receive callback - - - - - - - This method gets spooled up in its own thread an protected by a CCriticalSection to prevent multiple threads from running concurrently. - It will dequeue items as they are enqueued automatically. - - - - - - - - - - General send method - - - - - - - - - - SocketStatusChange Callback - - - - - - - Helper for ConnectionChange event - - - - - Helper to fire ClientReadyForCommunications event - - - - - Event for Receiving text. Once subscribed to this event the receive callback will start a thread that dequeues the messages and invokes the event on a new thread. - It is not recommended to use both the TextReceived event and the TextReceivedQueueInvoke event. - - - - - For a client with a pre shared key, this will fire after the communication is established and the key exchange is complete. If you require - a key and subscribe to the socket change event and try to send data on a connection the data sent will interfere with the key exchange and disconnect. - - - - - Address of server - - - - - Port on server - - - - - S+ helper - - - - - Bool to show whether the server requires a preshared key. This is used in the DynamicTCPServer class - - - - - S+ helper for requires shared key bool - - - - - SharedKey is sent for varification to the server. Shared key can be any text (255 char limit in SIMPL+ Module), but must match the Shared Key on the Server module - - - - - flag to show the client is waiting for the server to send the shared key - - - - - Defaults to 2000 - - - - - Bool showing if socket is connected - - - - - S+ helper for IsConnected - - - - - Bool showing if socket is ready for communication after shared key exchange - - - - - S+ helper for IsReadyForCommunication - - - - - Client socket status Read only - - - - - Contains the familiar Simpl analog status values. This drives the ConnectionChange event - and IsConnected would be true when this == 2. - - - - - Status text shows the message associated with socket status - - - - - bool to track if auto reconnect should be set on the socket - - - - - S+ helper for AutoReconnect - - - - - Milliseconds to wait before attempting to reconnect. Defaults to 5000 - - - - - Milliseconds before server expects another heartbeat. Set by property HeartbeatRequiredIntervalInSeconds which is driven from S+ - - - - - Simpl+ Heartbeat Analog value in seconds - - - - - Receive Queue size. Defaults to 20. Will set to 20 if QueueSize property is less than 20. Use constructor or set queue size property before - calling initialize. - - - - - Band aid delegate for choked server - - - - - Creates or gets a debug context - - - - - - - Do not use. For S+ access. - - - - - Used to save memory when shutting down - - - - - - Callback for console command - - - - - - Sets the debug level - - Valid values 0 (no debug), 1 (critical), 2 (all messages) - - - - Prints message to console if current debug level is equal to or higher than the level of this message. - Uses CrestronConsole.PrintLine. - - - Console format string - Object parameters - - - - Appends a device Key to the beginning of a message - - - - - Writes the memory object after timeout - - - - - Writes the memory - use SaveMemoryOnTimeout - - - - - - - - - - Helper to get the file path for this app's debug memory - - - - - Describes the folder location where a given program stores it's debug level memory. By default, the - file written will be named appNdebug where N is 1-10. - - - - - This is something of a band-aid callback. If the client times out during the connection process, because the server - is stuck, this will fire. It is intended to be used by the Server class monitor client, to help - keep a watch on the server and reset it if necessary. - - - - - Semaphore on connect method - - - - - Flag Set only when the disconnect method is called. - - - - - private Timer for auto reconnect - - - - - Used to force disconnection on a dead connect attempt - - - - - Internal secure client - - - - - Just to help S+ set the key - - - - - Handles closing this up when the program shuts down - - - - - Connect Method. Will return if already connected. Will write errors if missing address, port, or unique key/name. - - - - - - - - - - Internal call to close up client. ALWAYS use this when disconnecting. - - - - ff - Called from Connect failure or Socket Status change if - auto reconnect and socket disconnected (Not disconnected by user) - - - - - Receive callback - - - - - - - - - - - - General send method - - - - - - - - - - SocketStatusChange Callback - - - - - - - Helper for ConnectionChange event - - - - - Helper to fire ClientReadyForCommunications event - - - - - For a client with a pre shared key, this will fire after the communication is established and the key exchange is complete. If you require - a key and subscribe to the socket change event and try to send data on a connection the data sent will interfere with the key exchange and disconnect. - - - - - Address of server - - - - - Port on server - - - - - S+ helper - - - - - Bool to show whether the server requires a preshared key. This is used in the DynamicTCPServer class - - - - - S+ helper for requires shared key bool - - - - - SharedKey is sent for varification to the server. Shared key can be any text (255 char limit in SIMPL+ Module), but must match the Shared Key on the Server module - - - - - flag to show the client is waiting for the server to send the shared key - - - - - Defaults to 2000 - - - - - Bool showing if socket is connected - - - - - S+ helper for IsConnected - - - - - Bool showing if socket is ready for communication after shared key exchange - - - - - S+ helper for IsReadyForCommunication - - - - - Client socket status Read only - - - - - Contains the familiar Simpl analog status values. This drives the ConnectionChange event - and IsConnected would be true when this == 2. - - - - - Status text shows the message associated with socket status - - - - - bool to track if auto reconnect should be set on the socket - - - - - S+ helper for AutoReconnect - - - - - Milliseconds to wait before attempting to reconnect. Defaults to 5000 - - - - - Band aid delegate for choked server - - - - - Constants - - - - - Generic boolean value change constant - - - - - Evaluated boolean change constant - - - - - Update busy change const - - - - - Password is valid change constant - - - - - Password LED change constant - - - - - Generic ushort value change constant - - - - - Password count - - - - - Password selecte index change constant - - - - - Password length - - - - - Generic string value change constant - - - - - Call this before doing anything else - - - - - - - - - Set the JPath to evaluate for a given bool out index. - - - - - Set the JPath for a ushort out index. - - - - - Set the JPath for a string output index. - - - - - Evalutates all outputs with defined paths. called by S+ when paths are ready to process - and by Master when file is read. - - - - - Processes a bool property, converting to bool, firing off a BoolChange event - - - - - Processes the given path. - - JPath formatted path to the desired property - The string value of the property, or a default value if it - doesn't exist - This will return false in the case that EvaulateAllOnJsonChange - is false and the path does not evaluate to a property in the incoming JSON. - - - - Called from Master to read inputs and update their values in master JObject - Callback should hit one of the following four methods - - - - - Called during Process(...) to get the path to a given property. By default, - returns PathPrefix+path+PathSuffix. Override to change the way path is built. - - - - - Use a callback to reduce task switch/threading - - - - - This will be prepended to all paths to allow path swapping or for more organized - sub-paths - - - - - This is added to the end of all paths - - - - - Device class - - - - - Constructor - - - - - Initialize method - - - - - - - BoolChange event handler helper - - - - - - - - UshrtChange event handler helper - - - - - - - - StringChange event handler helper - - - - - - - - ObjectChange event handler helper - - - - - - - - JSON config key property - - - - - JSON config name property - - - - - JSON config type property - - - - - JSON config properties - - - - - Bool change event handler - - - - - Ushort change event handler - - - - - String change event handler - - - - - Object change event handler - - - - - Background class that manages debug features for sockets - - - - - Sets up the backing class. Adds console commands for S#Pro programs - - - - - Helper for socket list, to show types - - - - - - - - - - - - - - - - - Processor info class - - - - - Constructor - - - - - Ethernet info class - - - - - Constructor - - - - - Control subnet info class - - - - - Constructor - - - - - Program info class - - - - - Constructor - - - - - - For newer >=2.4.1 array lookups. - - - - - - - - - - - - - - - - - - - Provides the path append for GetFullPath - - - - - - - - - - - - Constants for Simpl modules - - - - - S+ values delegate - - - - - S+ values wrapper - - - - - S+ types enum - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Reads the config file, checks if it needs a merge, merges and saves, then returns the merged Object. - - JObject of config file - - - - - - - - - - - Merges the contents of a base and a delta array, matching the entries on a top-level property - given by propertyName. Returns a merge of them. Items in the delta array that do not have - a matched item in base array will not be merged. Non keyed system items will replace the template items. - - - - - Helper for using with JTokens. Converts to JObject - - - - - Merge o2 onto o1 - - - - - - - Server listen lock - - - - - Queue lock - - - - - Queue to temporarily store received messages with the source IP and Port info. Defaults to size 20. Use constructor or set queue size property before - calling initialize. - - - - - A bandaid client that monitors whether the server is reachable - - - - - Timer to operate the bandaid monitor client in a loop. - - - - - - - - - - - - - - - constructor S+ Does not accept a key. Use initialze with key to set the debug key on this device. If using with + make sure to set all properties manually. - - - - - constructor with debug key set at instantiation. Make sure to set all properties before listening. - - - - - - Contstructor that sets all properties by calling the initialize method with a config object. This does set Queue size. - - - - - - Disconnects all clients and stops the server - - - - - Initialize Key for device using client name from SIMPL+. Called on Listen from SIMPL+ - - - - - - Start listening on the specified port - - - - - Stop Listeneing - - - - - Disconnects Client - - - - - - Disconnect All Clients - - - - - Broadcast text from server to all connected clients - - - - - - Not sure this is useful in library, maybe Pro?? - - - - - - - Secure Server Socket Status Changed Callback - - - - - - - - Secure TCP Client Connected to Secure Server Callback - - - - - - - Secure Received Data Async Callback - - - - - - - - This method gets spooled up in its own thread an protected by a CCriticalSection to prevent multiple threads from running concurrently. - It will dequeue items as they are enqueued automatically. - - - - - Private Event Handler method to handle the closing of connections when the program stops - - - - - - Starts the monitor client cycle. Timed wait, then call RunMonitorClient - - - - - - - - - - - - - - - On monitor connect, restart the operation - - - - - If the client hangs, add to counter and maybe fire the choke event - - - - - Event for Receiving text - - - - - Event for Receiving text. Once subscribed to this event the receive callback will start a thread that dequeues the messages and invokes the event on a new thread. - It is not recommended to use both the TextReceived event and the TextReceivedQueueInvoke event. - - - - - Event for client connection socket status change - - - - - Event for Server State Change - - - - - For a server with a pre shared key, this will fire after the communication is established and the key exchange is complete. If no shared key, this will fire - after connection is successful. Use this event to know when the client is ready for communication to avoid stepping on shared key. - - - - - A band aid event to notify user that the server has choked. - - - - - Receive Queue size. Defaults to 20. Will set to 20 if QueueSize property is less than 20. Use constructor or set queue size property before - calling initialize. - - - - - 3 by default - - - - - Text representation of the Socket Status enum values for the server - - - - - Bool showing if socket is connected - - - - - S+ helper for IsConnected - - - - - Bool showing if socket is connected - - - - - S+ helper for IsConnected - - - - - Max number of clients this server will allow for connection. Crestron max is 64. This number should be less than 65 - - - - - Number of clients currently connected. - - - - - Port Server should listen on - - - - - S+ helper for Port - - - - - Bool to show whether the server requires a preshared key. Must be set the same in the client, and if true shared keys must be identical on server/client - - - - - S+ helper for requires shared key bool - - - - - SharedKey is sent for varification to the server. Shared key can be any text (255 char limit in SIMPL+ Module), but must match the Shared Key on the Server module. - If SharedKey changes while server is listening or clients are connected, disconnect and stop listening will be called - - - - - Heartbeat Required bool sets whether server disconnects client if heartbeat is not received - - - - - S+ Helper for Heartbeat Required - - - - - Milliseconds before server expects another heartbeat. Set by property HeartbeatRequiredIntervalInSeconds which is driven from S+ - - - - - Simpl+ Heartbeat Analog value in seconds - - - - - String to Match for heartbeat. If null or empty any string will reset heartbeat timer - - - - - Defaults to 2000 - - - - - Private flag to note that the server has stopped intentionally - - - - - - - - - - This delegate defines handler for IBasicCommunication status changes - - Device firing the status change - - - - - - - - - - Stupid S+ Constructor - - - - - - - - - - Stupid S+ Constructor - - - - - - - - - - System Info class - - - - - Constructor - - - - - Gets the current processor info - - - - - Gets the current ethernet info - - - - - Gets the current control subnet info - - - - - Gets the program info by index - - - - - - Gets the processor uptime and passes it to S+ - - - - - Gets the program uptime, by index, and passes it to S+ - - - - - - Sends command to console, passes response back using string change event - - - - - - private method to parse console messages - - - - - - - - - - Protected boolean change event handler - - - - - - - - Protected string change event handler - - - - - - - - Protected processor config change event handler - - - - - - - - Ethernet change event handler - - - - - - - - Control Subnet change event handler - - - - - - - - Program change event handler - - - - - - - - JSON password configuration - - - - - Constructor - - - - - Password object configured password - - - - - - Gets a level or creates it if not existing - - - - - - - The level of debug messages to print - - - - - Property to tell the program not to intitialize when it boots, if desired - - - - - Describes the folder location where a given program stores it's debug level memory. By default, the - file written will be named appNdebug where N is 1-10. - - - - - The name of the file containing the current debug settings. - - - - - When true, the IncludedExcludedKeys dict will contain keys to include. - When false (default), IncludedExcludedKeys will contain keys to exclude. - - - - - Used to save memory when shutting down - - - - - - Callback for console command - - - - - - Callback for console command - - - - - - Callback for console command - - - - - - Sets the debug level - - Valid values 0 (no debug), 1 (critical), 2 (all messages) - - - - Sets the flag to prevent application starting on next boot - - - - - - - - - - - Prints message to console if current debug level is equal to or higher than the level of this message. - Uses CrestronConsole.PrintLine. - - - Console format string - Object parameters - - - - Logs to Console when at-level, and all messages to error log, including device key - - - - - Logs to Console when at-level, and all messages to error log - - - - - Logs to both console and the custom user log (not the built-in error log). If appdebug level is set at - or above the level provided, then the output will be written to both console and the log. Otherwise - it will only be written to the log. - - - - - - - - Logs to both console and the custom user log (not the built-in error log). If appdebug level is set at - or above the level provided, then the output will be written to both console and the log. Otherwise - it will only be written to the log. - - - - String.format string - Parameters for substitution in the format string. - - - - Prints to log and error log - - - - - - - Writes the memory object after timeout - - - - - Writes the memory - use SaveMemoryOnTimeout - - - - - - - - - - Helper to get the file path for this app's debug memory - - - - - Crestron Control Methods for a comm object - - - - - Public dictionary of known passwords - - - - - Private dictionary, used when passwords are updated - - - - - Timer used to wait until password changes have stopped before updating the dictionary - - - - - Timer length - - - - - Constructor - - - - - Initialize password manager - - - - - Updates password stored in the dictonary - - - - - - - CTimer callback function - - - - - Method to change the default timer value, (default 5000ms/5s) - - - - - - Helper method for debugging to see what passwords are in the lists - - - - - Protected boolean change event handler - - - - - - - - Protected ushort change event handler - - - - - - - - Protected string change event handler - - - - - - - - Protected password change event handler - - - - - - - - Boolean event - - - - - Ushort event - - - - - String event - - - - - Event to notify clients of an updated password at the specified index (uint) - - - - - Stupid S+ Constructor - - - - - Stupid S+ Constructor - - - - - Stupid S+ Constructor - - - - - Stupid S+ Constructor - - - - - Stupid S+ Constructor - - - - - - - - - - For Simpl+ - - - - - True when the preset is found - - - - - S+ helper for stupid S+ - - - - - A class to handle basic TCP/IP communications with a server - - - - - Set only when the disconnect method is called. - - - - - Constructor - - - - - - - - - Constructor - - - - - - Default constructor for S+ - - - - - Just to help S+ set the key - - - - - Handles closing this up when the program shuts down - - - - - - - - - - - Attempts to connect to the server - - - - - Attempts to disconnect the client - - - - - Does the actual disconnect business - - - - - Callback method for connection attempt - - - - - - Disconnects, waits and attemtps to connect again - - - - - Recieves incoming data - - - - - - - General send method - - - - - This is useful from console and...? - - - - - Sends Bytes to the server - - - - - - Socket Status Change Handler - - - - - - - Fires when data is received from the server and returns it as a Byte array - - - - - Fires when data is received from the server and returns it as text - - - - - - - - - - Address of server - - - - - Port on server - - - - - Another damn S+ helper because S+ seems to treat large port nums as signed ints - which screws up things - - - - - Defaults to 2000 - - - - - The actual client class - - - - - True if connected to the server - - - - - S+ helper for IsConnected - - - - - Status of the socket - - - - - Contains the familiar Simpl analog status values. This drives the ConnectionChange event - and IsConnected with be true when this == 2. - - - - - Status of the socket - - - - - Connection failure reason - - - - - If true, enables AutoConnect - - - - - S+ helper for AutoReconnect - - - - - Milliseconds to wait before attempting to reconnect. Defaults to 5000 - - - - - - - - - - Configuration properties for TCP/SSH Connections - - - - - Address to connect to - - - - - Port to connect to - - - - - Username credential - - - - - Passord credential - - - - - Defaults to 32768 - - - - - Defaults to true - - - - - Defaults to 5000ms - - - - - Bool change event args - - - - - Constructor - - - - - Constructor overload - - - - - - - Constructor overload - - - - - - - - Boolean state property - - - - - Boolean ushort value property - - - - - Boolean change event args type - - - - - Boolean change event args index - - - - - Ushort change event args - - - - - Constructor - - - - - Constructor overload - - - - - - - Constructor overload - - - - - - - - Ushort change event args integer value - - - - - Ushort change event args type - - - - - Ushort change event args index - - - - - String change event args - - - - - Constructor - - - - - Constructor overload - - - - - - - Constructor overload - - - - - - - - String change event args value - - - - - String change event args type - - - - - string change event args index - - - - - Client config object for TCP client with server that inherits from TcpSshPropertiesConfig and adds properties for shared key and heartbeat - - - - - TcpSsh Properties - - - - - Bool value for secure. Currently not implemented in TCP sockets as they are not dynamic - - - - - Require a shared key that both server and client negotiate. If negotiation fails server disconnects the client - - - - - The shared key that must match on the server and client - - - - - Require a heartbeat on the client/server connection that will cause the server/client to disconnect if the heartbeat is not received. - heartbeats do not raise received events. - - - - - The interval in seconds for the heartbeat from the client. If not received client is disconnected - - - - - HeartbeatString that will be checked against the message received. defaults to heartbeat if no string is provided. - - - - - Receive Queue size must be greater than 20 or defaults to 20 - - - - Privates * - - - - SIMPL+ default constructor. - - - - - Read, evaluate and udpate status - - - - - Returns the FileInfo object for a given path, with possible wildcards - - - - - - - - - - - - - - - - - - Sets the filepath as well as registers this with the Global.Masters list - - - - - Device communication parameter class - - - - - Constructor - - - - - Device TCP/SSH properties class - - - - - Constructor - - - - - Device control class - - - - - Constructor - - - - - Device properties class - - - - - Constructor - - - - - Root device class - - - - - Constants for simpl modules - - - - - Json object evaluated constant - - - - - Json object changed constant - - - - - - - - - - Default constructor - - - - - Constructor overload - - - - - - - Constructor overload - - - - - - - - Device change event args object - - - - - Device change event args type - - - - - Device change event args index - - - - - - - - - - - - - - - For Simpl+ - - - - - True when user is found - - - - - For stupid S+ - - - - - - - - - - Constants - - - - - Processor Change Event Args Class - - - - - Constructor - - - - - Constructor overload - - - - - Constructor - - - - - Ethernet Change Event Args Class - - - - - Constructor - - - - - Constructor overload - - - - - - - Constructor overload - - - - - - - Control Subnet Chage Event Args Class - - - - - Constructor - - - - - Constructor overload - - - - - Constructor overload - - - - - Program Change Event Args Class - - - - - Constructor - - - - - Constructor overload - - - - - - - Constructor overload - - - - - - - Defines the string event handler for line events on the gather - - - - - - Attaches to IBasicCommunication as a text gather - - - - - For receive buffer - - - - - Delimiter, like it says! - - - - - Fires up a gather, given a IBasicCommunicaion port and char for de - - - - - - - - - - - - - - Disconnects this gather from the Port's TextReceived event. This will not fire LineReceived - after the this call. - - - - - Handler for raw data coming from port - - - - - - - - - - - - Deconstructor. Disconnects from port TextReceived events. - - - - - Event that fires when a line is received from the IBasicCommunication source. - The event merely contains the text, not an EventArgs type class. - - - - - The communication port that this gathers on - - - - - Default false. If true, the delimiter will be included in the line output - events - - - - diff --git a/submodules/PepperDash_Essentials_Core.cplz b/submodules/PepperDash_Essentials_Core.cplz deleted file mode 100644 index f598f0f..0000000 Binary files a/submodules/PepperDash_Essentials_Core.cplz and /dev/null differ diff --git a/submodules/PepperDash_Essentials_Core.dll b/submodules/PepperDash_Essentials_Core.dll deleted file mode 100644 index 0b88635..0000000 Binary files a/submodules/PepperDash_Essentials_Core.dll and /dev/null differ