mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 12:15:01 +00:00
Merge branch 'development' into hotfix/dmtx4kz100c-fix
This commit is contained in:
10
.github/scripts/GenerateVersionNumber.ps1
vendored
10
.github/scripts/GenerateVersionNumber.ps1
vendored
@@ -1,5 +1,8 @@
|
|||||||
$latestVersions = $(git tag --merged origin/main)
|
$latestVersions = $(git tag --merged origin/main)
|
||||||
$latestVersion = [version]"0.0.0"
|
$latestVersion = [version]"0.0.0"
|
||||||
|
Write-Host "GITHUB_REF: $($Env:GITHUB_REF)"
|
||||||
|
Write-Host "GITHUB_HEAD_REF: $($Env:GITHUB_HEAD_REF)"
|
||||||
|
Write-Host "GITHUB_BASE_REF: $($Env:GITHUB_BASE_REF)"
|
||||||
Foreach ($version in $latestVersions) {
|
Foreach ($version in $latestVersions) {
|
||||||
Write-Host $version
|
Write-Host $version
|
||||||
try {
|
try {
|
||||||
@@ -17,7 +20,13 @@ Foreach ($version in $latestVersions) {
|
|||||||
$newVersion = [version]$latestVersion
|
$newVersion = [version]$latestVersion
|
||||||
$phase = ""
|
$phase = ""
|
||||||
$newVersionString = ""
|
$newVersionString = ""
|
||||||
|
|
||||||
switch -regex ($Env:GITHUB_REF) {
|
switch -regex ($Env:GITHUB_REF) {
|
||||||
|
'^refs\/pull\/*.' {
|
||||||
|
$splitRef = $Env:GITHUB_REF -split "/"
|
||||||
|
$phase = "pr$($splitRef[2])"
|
||||||
|
$newVersionString = "{0}.{1}.{2}-{3}-{4}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1), $phase, $Env:GITHUB_RUN_NUMBER
|
||||||
|
}
|
||||||
'^refs\/heads\/main*.' {
|
'^refs\/heads\/main*.' {
|
||||||
$newVersionString = "{0}.{1}.{2}" -f $newVersion.Major, $newVersion.Minor, $newVersion.Build
|
$newVersionString = "{0}.{1}.{2}" -f $newVersion.Major, $newVersion.Minor, $newVersion.Build
|
||||||
}
|
}
|
||||||
@@ -43,6 +52,7 @@ switch -regex ($Env:GITHUB_REF) {
|
|||||||
$phase = 'hotfix'
|
$phase = 'hotfix'
|
||||||
$newVersionString = "{0}.{1}.{2}-{3}-{4}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1), $phase, $Env:GITHUB_RUN_NUMBER
|
$newVersionString = "{0}.{1}.{2}-{3}-{4}" -f $newVersion.Major, $newVersion.Minor, ($newVersion.Build + 1), $phase, $Env:GITHUB_RUN_NUMBER
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
12
.github/workflows/docker.yml
vendored
12
.github/workflows/docker.yml
vendored
@@ -8,6 +8,9 @@ on:
|
|||||||
- bugfix/*
|
- bugfix/*
|
||||||
- release/*
|
- release/*
|
||||||
- development
|
- development
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- development
|
||||||
|
|
||||||
env:
|
env:
|
||||||
# solution path doesn't need slashes unless there it is multiple folders deep
|
# solution path doesn't need slashes unless there it is multiple folders deep
|
||||||
@@ -29,14 +32,7 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
# And any submodules
|
submodules: true
|
||||||
- name: Checkout submodules
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
git config --global url."https://github.com/".insteadOf "git@github.com:"
|
|
||||||
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
|
|
||||||
git submodule sync --recursive
|
|
||||||
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
|
|
||||||
# Fetch all tags
|
# Fetch all tags
|
||||||
- name: Fetch tags
|
- name: Fetch tags
|
||||||
run: git fetch --tags
|
run: git fetch --tags
|
||||||
|
|||||||
@@ -158,12 +158,12 @@ namespace PepperDash.Essentials.Bridges
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (Debug.Level >= 1)
|
if (Debug.Level >= 1)
|
||||||
Debug.Console(1, this, "EiscApi change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
|
Debug.Console(2, this, "EiscApi change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
|
||||||
var uo = args.Sig.UserObject;
|
var uo = args.Sig.UserObject;
|
||||||
|
|
||||||
if (uo == null) return;
|
if (uo == null) return;
|
||||||
|
|
||||||
Debug.Console(1, this, "Executing Action: {0}", uo.ToString());
|
Debug.Console(2, this, "Executing Action: {0}", uo.ToString());
|
||||||
if (uo is Action<bool>)
|
if (uo is Action<bool>)
|
||||||
(uo as Action<bool>)(args.Sig.BoolValue);
|
(uo as Action<bool>)(args.Sig.BoolValue);
|
||||||
else if (uo is Action<ushort>)
|
else if (uo is Action<ushort>)
|
||||||
|
|||||||
@@ -175,6 +175,10 @@
|
|||||||
{
|
{
|
||||||
"deviceKey": "gls-odt-1",
|
"deviceKey": "gls-odt-1",
|
||||||
"joinStart": 2751
|
"joinStart": 2751
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"deviceKey": "gls-part-1",
|
||||||
|
"joinStart": 2781
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -427,6 +431,19 @@
|
|||||||
"method": "cresnet"
|
"method": "cresnet"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"key": "gls-part-1",
|
||||||
|
"uid": 19,
|
||||||
|
"name": "GLS-PART-CN 1",
|
||||||
|
"type": "glspartcn",
|
||||||
|
"group": "partition",
|
||||||
|
"properties": {
|
||||||
|
"control": {
|
||||||
|
"cresnetId": "90",
|
||||||
|
"method": "cresnet"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"rooms": [],
|
"rooms": [],
|
||||||
|
|||||||
@@ -1,23 +1,15 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Linq;
|
||||||
using System.Linq;
|
using Crestron.SimplSharp;
|
||||||
using System.Text;
|
using Crestron.SimplSharpPro;
|
||||||
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
|
||||||
using Crestron.SimplSharpPro;
|
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
|
||||||
using Crestron.SimplSharpPro.Fusion;
|
using Crestron.SimplSharpPro.Fusion;
|
||||||
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials;
|
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.Core.Fusion;
|
using PepperDash.Essentials.Core.Fusion;
|
||||||
using PepperDash.Essentials.Devices.Common;
|
|
||||||
using PepperDash.Essentials.Devices.Common.Occupancy;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Fusion
|
namespace PepperDash.Essentials.Fusion
|
||||||
{
|
{
|
||||||
public class EssentialsHuddleVtc1FusionController : EssentialsHuddleSpaceFusionSystemControllerBase
|
public class EssentialsHuddleVtc1FusionController : EssentialsHuddleSpaceFusionSystemControllerBase
|
||||||
|
|||||||
@@ -198,11 +198,11 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
var uo = Eisc.BooleanOutput[join].UserObject as Action<bool>;
|
var uo = Eisc.BooleanOutput[join].UserObject as Action<bool>;
|
||||||
if (uo != null)
|
if (uo != null)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Executing Action: {0}", uo.ToString());
|
Debug.Console(2, this, "Executing Action: {0}", uo.ToString());
|
||||||
uo(Convert.ToBoolean(state));
|
uo(Convert.ToBoolean(state));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Debug.Console(1, this, "User Action is null. Nothing to Execute");
|
Debug.Console(2, this, "User Action is null. Nothing to Execute");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "analog":
|
case "analog":
|
||||||
@@ -210,27 +210,27 @@ namespace PepperDash.Essentials.Core.Bridges
|
|||||||
var uo = Eisc.BooleanOutput[join].UserObject as Action<ushort>;
|
var uo = Eisc.BooleanOutput[join].UserObject as Action<ushort>;
|
||||||
if (uo != null)
|
if (uo != null)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Executing Action: {0}", uo.ToString());
|
Debug.Console(2, this, "Executing Action: {0}", uo.ToString());
|
||||||
uo(Convert.ToUInt16(state));
|
uo(Convert.ToUInt16(state));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Debug.Console(1, this, "User Action is null. Nothing to Execute"); break;
|
Debug.Console(2, this, "User Action is null. Nothing to Execute"); break;
|
||||||
}
|
}
|
||||||
case "serial":
|
case "serial":
|
||||||
{
|
{
|
||||||
var uo = Eisc.BooleanOutput[join].UserObject as Action<string>;
|
var uo = Eisc.BooleanOutput[join].UserObject as Action<string>;
|
||||||
if (uo != null)
|
if (uo != null)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Executing Action: {0}", uo.ToString());
|
Debug.Console(2, this, "Executing Action: {0}", uo.ToString());
|
||||||
uo(Convert.ToString(state));
|
uo(Convert.ToString(state));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Debug.Console(1, this, "User Action is null. Nothing to Execute");
|
Debug.Console(2, this, "User Action is null. Nothing to Execute");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Unknown join type. Use digital/serial/analog");
|
Debug.Console(2, "Unknown join type. Use digital/serial/analog");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,130 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
using PepperDash.Essentials.Core;
|
||||||
|
|
||||||
|
namespace PepperDash_Essentials_Core.Bridges.JoinMaps
|
||||||
|
{
|
||||||
|
public class GlsPartitionSensorJoinMap : JoinMapBaseAdvanced
|
||||||
|
{
|
||||||
|
[JoinName("IsOnline")]
|
||||||
|
public JoinDataComplete IsOnline = new JoinDataComplete(
|
||||||
|
new JoinData()
|
||||||
|
{
|
||||||
|
JoinNumber = 1,
|
||||||
|
JoinSpan = 1
|
||||||
|
},
|
||||||
|
new JoinMetadata()
|
||||||
|
{
|
||||||
|
Description = "Sensor Is Online",
|
||||||
|
JoinCapabilities = eJoinCapabilities.ToSIMPL,
|
||||||
|
JoinType = eJoinType.Digital
|
||||||
|
});
|
||||||
|
|
||||||
|
[JoinName("Name")]
|
||||||
|
public JoinDataComplete Name = new JoinDataComplete(
|
||||||
|
new JoinData()
|
||||||
|
{
|
||||||
|
JoinNumber = 1,
|
||||||
|
JoinSpan = 1
|
||||||
|
},
|
||||||
|
new JoinMetadata()
|
||||||
|
{
|
||||||
|
Description = "Sensor Name",
|
||||||
|
JoinCapabilities = eJoinCapabilities.ToSIMPL,
|
||||||
|
JoinType = eJoinType.Serial
|
||||||
|
});
|
||||||
|
|
||||||
|
[JoinName("Enable")]
|
||||||
|
public JoinDataComplete Enable = new JoinDataComplete(
|
||||||
|
new JoinData()
|
||||||
|
{
|
||||||
|
JoinNumber = 2,
|
||||||
|
JoinSpan = 1
|
||||||
|
},
|
||||||
|
new JoinMetadata()
|
||||||
|
{
|
||||||
|
Description = "Sensor Enable",
|
||||||
|
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
|
||||||
|
JoinType = eJoinType.Digital
|
||||||
|
});
|
||||||
|
|
||||||
|
[JoinName("PartitionSensed")]
|
||||||
|
public JoinDataComplete PartitionSensed = new JoinDataComplete(
|
||||||
|
new JoinData()
|
||||||
|
{
|
||||||
|
JoinNumber = 3,
|
||||||
|
JoinSpan = 1
|
||||||
|
},
|
||||||
|
new JoinMetadata()
|
||||||
|
{
|
||||||
|
Description = "Sensor Partition Sensed",
|
||||||
|
JoinCapabilities = eJoinCapabilities.ToSIMPL,
|
||||||
|
JoinType = eJoinType.Digital
|
||||||
|
});
|
||||||
|
|
||||||
|
[JoinName("PartitionNotSensed")]
|
||||||
|
public JoinDataComplete PartitionNotSensed = new JoinDataComplete(
|
||||||
|
new JoinData()
|
||||||
|
{
|
||||||
|
JoinNumber = 4,
|
||||||
|
JoinSpan = 1
|
||||||
|
},
|
||||||
|
new JoinMetadata()
|
||||||
|
{
|
||||||
|
Description = "Sensor Partition Not Sensed",
|
||||||
|
JoinCapabilities = eJoinCapabilities.ToSIMPL,
|
||||||
|
JoinType = eJoinType.Digital
|
||||||
|
});
|
||||||
|
|
||||||
|
[JoinName("IncreaseSensitivity")]
|
||||||
|
public JoinDataComplete IncreaseSensitivity = new JoinDataComplete(
|
||||||
|
new JoinData()
|
||||||
|
{
|
||||||
|
JoinNumber = 6,
|
||||||
|
JoinSpan = 1
|
||||||
|
},
|
||||||
|
new JoinMetadata()
|
||||||
|
{
|
||||||
|
Description = "Sensor Increase Sensitivity",
|
||||||
|
JoinCapabilities = eJoinCapabilities.FromSIMPL,
|
||||||
|
JoinType = eJoinType.Digital
|
||||||
|
});
|
||||||
|
|
||||||
|
[JoinName("DecreaseSensitivity")]
|
||||||
|
public JoinDataComplete DecreaseSensitivity = new JoinDataComplete(
|
||||||
|
new JoinData()
|
||||||
|
{
|
||||||
|
JoinNumber = 7,
|
||||||
|
JoinSpan = 1
|
||||||
|
},
|
||||||
|
new JoinMetadata()
|
||||||
|
{
|
||||||
|
Description = "Sensor Decrease Sensitivity",
|
||||||
|
JoinCapabilities = eJoinCapabilities.FromSIMPL,
|
||||||
|
JoinType = eJoinType.Digital
|
||||||
|
});
|
||||||
|
|
||||||
|
[JoinName("Sensitivity")]
|
||||||
|
public JoinDataComplete Sensitivity = new JoinDataComplete(
|
||||||
|
new JoinData()
|
||||||
|
{
|
||||||
|
JoinNumber = 2,
|
||||||
|
JoinSpan = 1
|
||||||
|
},
|
||||||
|
new JoinMetadata()
|
||||||
|
{
|
||||||
|
Description = "Sensor Sensitivity",
|
||||||
|
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
|
||||||
|
JoinType = eJoinType.Analog
|
||||||
|
});
|
||||||
|
|
||||||
|
public GlsPartitionSensorJoinMap(uint joinStart)
|
||||||
|
: base(joinStart, typeof (GlsPartitionSensorJoinMap))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using Crestron.SimplSharpPro.GeneralIO;
|
using Crestron.SimplSharpPro.GeneralIO;
|
||||||
@@ -13,21 +14,30 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
[Description("Wrapper class for the C2N-RTHS sensor")]
|
[Description("Wrapper class for the C2N-RTHS sensor")]
|
||||||
public class C2nRthsController : CrestronGenericBridgeableBaseDevice
|
public class C2nRthsController : CrestronGenericBridgeableBaseDevice
|
||||||
{
|
{
|
||||||
private readonly C2nRths _device;
|
private C2nRths _device;
|
||||||
|
|
||||||
public IntFeedback TemperatureFeedback { get; private set; }
|
public IntFeedback TemperatureFeedback { get; private set; }
|
||||||
public IntFeedback HumidityFeedback { get; private set; }
|
public IntFeedback HumidityFeedback { get; private set; }
|
||||||
|
|
||||||
public C2nRthsController(string key, string name, GenericBase hardware) : base(key, name, hardware)
|
public C2nRthsController(string key, Func<DeviceConfig, C2nRths> preActivationFunc,
|
||||||
|
DeviceConfig config)
|
||||||
|
: base(key, config.Name)
|
||||||
{
|
{
|
||||||
_device = hardware as C2nRths;
|
|
||||||
|
|
||||||
TemperatureFeedback = new IntFeedback(() => _device.TemperatureFeedback.UShortValue);
|
AddPreActivationAction(() =>
|
||||||
HumidityFeedback = new IntFeedback(() => _device.HumidityFeedback.UShortValue);
|
{
|
||||||
|
_device = preActivationFunc(config);
|
||||||
|
|
||||||
if (_device != null) _device.BaseEvent += DeviceOnBaseEvent;
|
RegisterCrestronGenericBase(_device);
|
||||||
|
|
||||||
|
TemperatureFeedback = new IntFeedback(() => _device.TemperatureFeedback.UShortValue);
|
||||||
|
HumidityFeedback = new IntFeedback(() => _device.HumidityFeedback.UShortValue);
|
||||||
|
|
||||||
|
if (_device != null) _device.BaseEvent += DeviceOnBaseEvent;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void DeviceOnBaseEvent(GenericBase device, BaseEventArgs args)
|
private void DeviceOnBaseEvent(GenericBase device, BaseEventArgs args)
|
||||||
{
|
{
|
||||||
switch (args.EventId)
|
switch (args.EventId)
|
||||||
@@ -76,24 +86,63 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
HumidityFeedback.LinkInputSig(trilist.UShortInput[joinMap.Humidity.JoinNumber]);
|
HumidityFeedback.LinkInputSig(trilist.UShortInput[joinMap.Humidity.JoinNumber]);
|
||||||
|
|
||||||
trilist.StringInput[joinMap.Name.JoinNumber].StringValue = Name;
|
trilist.StringInput[joinMap.Name.JoinNumber].StringValue = Name;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class C2nRthsControllerFactory : EssentialsDeviceFactory<C2nRthsController>
|
trilist.OnlineStatusChange += (d, args) =>
|
||||||
{
|
{
|
||||||
public C2nRthsControllerFactory()
|
if (!args.DeviceOnLine) return;
|
||||||
{
|
|
||||||
TypeNames = new List<string>() { "c2nrths" };
|
UpdateFeedbacksWhenOnline();
|
||||||
|
|
||||||
|
trilist.StringInput[joinMap.Name.JoinNumber].StringValue = Name;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
private void UpdateFeedbacksWhenOnline()
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new C2N-RTHS Device");
|
IsOnline.FireUpdate();
|
||||||
|
TemperatureFeedback.FireUpdate();
|
||||||
|
HumidityFeedback.FireUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region PreActivation
|
||||||
|
|
||||||
|
private static C2nRths GetC2nRthsDevice(DeviceConfig dc)
|
||||||
|
{
|
||||||
var control = CommFactory.GetControlPropertiesConfig(dc);
|
var control = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
var cresnetId = control.CresnetIdInt;
|
var cresnetId = control.CresnetIdInt;
|
||||||
|
var branchId = control.ControlPortNumber;
|
||||||
|
var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey;
|
||||||
|
|
||||||
return new C2nRthsController(dc.Key, dc.Name, new C2nRths(cresnetId, Global.ControlSystem));
|
if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
Debug.Console(0, "Device {0} is a valid cresnet master - creating new C2nRths", parentKey);
|
||||||
|
return new C2nRths(cresnetId, Global.ControlSystem);
|
||||||
|
}
|
||||||
|
var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches;
|
||||||
|
|
||||||
|
if (cresnetBridge != null)
|
||||||
|
{
|
||||||
|
Debug.Console(0, "Device {0} is a valid cresnet master - creating new C2nRths", parentKey);
|
||||||
|
return new C2nRths(cresnetId, cresnetBridge.CresnetBranches[branchId]);
|
||||||
|
}
|
||||||
|
Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public class C2nRthsControllerFactory : EssentialsDeviceFactory<C2nRthsController>
|
||||||
|
{
|
||||||
|
public C2nRthsControllerFactory()
|
||||||
|
{
|
||||||
|
TypeNames = new List<string>() { "c2nrths" };
|
||||||
|
}
|
||||||
|
|
||||||
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
|
{
|
||||||
|
Debug.Console(1, "Factory Attempting to create new C2N-RTHS Device");
|
||||||
|
|
||||||
|
return new C2nRthsController(dc.Key, GetC2nRthsDevice, dc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Crestron.SimplSharpPro;
|
||||||
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
using Crestron.SimplSharpPro.GeneralIO;
|
||||||
|
using PepperDash.Core;
|
||||||
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core
|
||||||
|
{
|
||||||
|
public class DinCenCn2Controller : CrestronGenericBaseDevice, IHasCresnetBranches
|
||||||
|
{
|
||||||
|
private readonly DinCenCn2 _device;
|
||||||
|
|
||||||
|
public CrestronCollection<CresnetBranch> CresnetBranches
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
return _device != null ? _device.Branches : null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public DinCenCn2Controller(string key, string name, DinCenCn2 device, DeviceConfig config)
|
||||||
|
: base(key, name, device)
|
||||||
|
{
|
||||||
|
_device = device;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DinCenCn2ControllerFactory : EssentialsDeviceFactory<DinCenCn2Controller>
|
||||||
|
{
|
||||||
|
public DinCenCn2ControllerFactory()
|
||||||
|
{
|
||||||
|
TypeNames = new List<string>() { "dincencn2", "dincencn2poe", "din-cencn2", "din-cencn2-poe" };
|
||||||
|
}
|
||||||
|
|
||||||
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
|
{
|
||||||
|
Debug.Console(1, "Factory Attempting to create new C2N-RTHS Device");
|
||||||
|
|
||||||
|
var control = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
|
var ipid = control.IpIdInt;
|
||||||
|
|
||||||
|
if (dc.Type.ToLower().Contains("poe"))
|
||||||
|
{
|
||||||
|
return new DinCenCn2Controller(dc.Key, dc.Name, new DinCenCn2Poe(ipid, Global.ControlSystem), dc);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new DinCenCn2Controller(dc.Key, dc.Name, new DinCenCn2(ipid, Global.ControlSystem), dc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
using Crestron.SimplSharpPro;
|
||||||
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core
|
||||||
|
{
|
||||||
|
public interface IHasCresnetBranches
|
||||||
|
{
|
||||||
|
CrestronCollection<CresnetBranch> CresnetBranches { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
[Description("Wrapper class for the Crestron StatusSign device")]
|
[Description("Wrapper class for the Crestron StatusSign device")]
|
||||||
public class StatusSignController : CrestronGenericBridgeableBaseDevice
|
public class StatusSignController : CrestronGenericBridgeableBaseDevice
|
||||||
{
|
{
|
||||||
private readonly StatusSign _device;
|
private StatusSign _device;
|
||||||
|
|
||||||
public BoolFeedback RedLedEnabledFeedback { get; private set; }
|
public BoolFeedback RedLedEnabledFeedback { get; private set; }
|
||||||
public BoolFeedback GreenLedEnabledFeedback { get; private set; }
|
public BoolFeedback GreenLedEnabledFeedback { get; private set; }
|
||||||
@@ -23,34 +23,40 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
public IntFeedback GreenLedBrightnessFeedback { get; private set; }
|
public IntFeedback GreenLedBrightnessFeedback { get; private set; }
|
||||||
public IntFeedback BlueLedBrightnessFeedback { get; private set; }
|
public IntFeedback BlueLedBrightnessFeedback { get; private set; }
|
||||||
|
|
||||||
public StatusSignController(string key, string name, GenericBase hardware) : base(key, name, hardware)
|
public StatusSignController(string key, Func<DeviceConfig, StatusSign> preActivationFunc, DeviceConfig config) : base(key, config.Name)
|
||||||
{
|
{
|
||||||
_device = hardware as StatusSign;
|
AddPreActivationAction(() =>
|
||||||
|
{
|
||||||
|
_device = preActivationFunc(config);
|
||||||
|
|
||||||
RedLedEnabledFeedback =
|
RegisterCrestronGenericBase(_device);
|
||||||
|
|
||||||
|
RedLedEnabledFeedback =
|
||||||
new BoolFeedback(
|
new BoolFeedback(
|
||||||
() =>
|
() =>
|
||||||
_device.Leds[(uint) StatusSign.Led.eLedColor.Red]
|
_device.Leds[(uint)StatusSign.Led.eLedColor.Red]
|
||||||
.ControlFeedback.BoolValue);
|
|
||||||
GreenLedEnabledFeedback =
|
|
||||||
new BoolFeedback(
|
|
||||||
() =>
|
|
||||||
_device.Leds[(uint) StatusSign.Led.eLedColor.Green]
|
|
||||||
.ControlFeedback.BoolValue);
|
|
||||||
BlueLedEnabledFeedback =
|
|
||||||
new BoolFeedback(
|
|
||||||
() =>
|
|
||||||
_device.Leds[(uint) StatusSign.Led.eLedColor.Blue]
|
|
||||||
.ControlFeedback.BoolValue);
|
.ControlFeedback.BoolValue);
|
||||||
|
GreenLedEnabledFeedback =
|
||||||
|
new BoolFeedback(
|
||||||
|
() =>
|
||||||
|
_device.Leds[(uint)StatusSign.Led.eLedColor.Green]
|
||||||
|
.ControlFeedback.BoolValue);
|
||||||
|
BlueLedEnabledFeedback =
|
||||||
|
new BoolFeedback(
|
||||||
|
() =>
|
||||||
|
_device.Leds[(uint)StatusSign.Led.eLedColor.Blue]
|
||||||
|
.ControlFeedback.BoolValue);
|
||||||
|
|
||||||
RedLedBrightnessFeedback =
|
RedLedBrightnessFeedback =
|
||||||
new IntFeedback(() => (int) _device.Leds[(uint) StatusSign.Led.eLedColor.Red].BrightnessFeedback);
|
new IntFeedback(() => (int)_device.Leds[(uint)StatusSign.Led.eLedColor.Red].BrightnessFeedback);
|
||||||
GreenLedBrightnessFeedback =
|
GreenLedBrightnessFeedback =
|
||||||
new IntFeedback(() => (int) _device.Leds[(uint) StatusSign.Led.eLedColor.Green].BrightnessFeedback);
|
new IntFeedback(() => (int)_device.Leds[(uint)StatusSign.Led.eLedColor.Green].BrightnessFeedback);
|
||||||
BlueLedBrightnessFeedback =
|
BlueLedBrightnessFeedback =
|
||||||
new IntFeedback(() => (int) _device.Leds[(uint) StatusSign.Led.eLedColor.Blue].BrightnessFeedback);
|
new IntFeedback(() => (int)_device.Leds[(uint)StatusSign.Led.eLedColor.Blue].BrightnessFeedback);
|
||||||
|
|
||||||
if (_device != null) _device.BaseEvent += _device_BaseEvent;
|
if (_device != null) _device.BaseEvent += _device_BaseEvent;
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _device_BaseEvent(GenericBase device, BaseEventArgs args)
|
void _device_BaseEvent(GenericBase device, BaseEventArgs args)
|
||||||
@@ -167,23 +173,51 @@ namespace PepperDash.Essentials.Core.CrestronIO
|
|||||||
|
|
||||||
device.SetColor(redBrightness, greenBrightness, blueBrightness);
|
device.SetColor(redBrightness, greenBrightness, blueBrightness);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public class StatusSignControllerFactory : EssentialsDeviceFactory<StatusSignController>
|
#region PreActivation
|
||||||
{
|
|
||||||
public StatusSignControllerFactory()
|
private static StatusSign GetStatusSignDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
TypeNames = new List<string>() { "statussign" };
|
|
||||||
}
|
|
||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
|
||||||
{
|
|
||||||
Debug.Console(1, "Factory Attempting to create new StatusSign Device");
|
|
||||||
|
|
||||||
var control = CommFactory.GetControlPropertiesConfig(dc);
|
var control = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
var cresnetId = control.CresnetIdInt;
|
var cresnetId = control.CresnetIdInt;
|
||||||
|
var branchId = control.ControlPortNumber;
|
||||||
|
var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey;
|
||||||
|
|
||||||
return new StatusSignController(dc.Key, dc.Name, new StatusSign(cresnetId, Global.ControlSystem));
|
if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
Debug.Console(0, "Device {0} is a valid cresnet master - creating new StatusSign", parentKey);
|
||||||
|
return new StatusSign(cresnetId, Global.ControlSystem);
|
||||||
|
}
|
||||||
|
var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches;
|
||||||
|
|
||||||
|
if (cresnetBridge != null)
|
||||||
|
{
|
||||||
|
Debug.Console(0, "Device {0} is a valid cresnet master - creating new StatusSign", parentKey);
|
||||||
|
return new StatusSign(cresnetId, cresnetBridge.CresnetBranches[branchId]);
|
||||||
|
}
|
||||||
|
Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public class StatusSignControllerFactory : EssentialsDeviceFactory<StatusSignController>
|
||||||
|
{
|
||||||
|
public StatusSignControllerFactory()
|
||||||
|
{
|
||||||
|
TypeNames = new List<string>() { "statussign" };
|
||||||
|
}
|
||||||
|
|
||||||
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
|
{
|
||||||
|
Debug.Console(1, "Factory Attempting to create new StatusSign Device");
|
||||||
|
|
||||||
|
var control = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
|
var cresnetId = control.CresnetIdInt;
|
||||||
|
|
||||||
|
return new StatusSignController(dc.Key, GetStatusSignDevice, dc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
using System.Linq;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using PepperDash.Core.JsonStandardObjects;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
@@ -11,7 +13,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class CrestronGenericBaseDevice : EssentialsDevice, IOnline, IHasFeedback, ICommunicationMonitor, IUsageTracking
|
public abstract class CrestronGenericBaseDevice : EssentialsDevice, IOnline, IHasFeedback, ICommunicationMonitor, IUsageTracking
|
||||||
{
|
{
|
||||||
public virtual GenericBase Hardware { get; protected set; }
|
protected GenericBase Hardware;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns a list containing the Outputs that we want to expose.
|
/// Returns a list containing the Outputs that we want to expose.
|
||||||
@@ -42,6 +44,24 @@ namespace PepperDash.Essentials.Core
|
|||||||
CommunicationMonitor = new CrestronGenericBaseCommunicationMonitor(this, hardware, 120000, 300000);
|
CommunicationMonitor = new CrestronGenericBaseCommunicationMonitor(this, hardware, 120000, 300000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected CrestronGenericBaseDevice(string key, string name)
|
||||||
|
: base(key, name)
|
||||||
|
{
|
||||||
|
Feedbacks = new FeedbackCollection<Feedback>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void RegisterCrestronGenericBase(GenericBase hardware)
|
||||||
|
{
|
||||||
|
Hardware = hardware;
|
||||||
|
IsOnline = new BoolFeedback("IsOnlineFeedback", () => Hardware.IsOnline);
|
||||||
|
IsRegistered = new BoolFeedback("IsRegistered", () => Hardware.Registered);
|
||||||
|
IpConnectionsText = new StringFeedback("IpConnectionsText", () => Hardware.ConnectedIpList != null ? string.Join(",", Hardware.ConnectedIpList.Select(cip => cip.DeviceIpAddress).ToArray()) : string.Empty);
|
||||||
|
AddToFeedbackList(IsOnline, IpConnectionsText);
|
||||||
|
|
||||||
|
CommunicationMonitor = new CrestronGenericBaseCommunicationMonitor(this, hardware, 120000, 300000);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Make sure that overriding classes call this!
|
/// Make sure that overriding classes call this!
|
||||||
/// Registers the Crestron device, connects up to the base events, starts communication monitor
|
/// Registers the Crestron device, connects up to the base events, starts communication monitor
|
||||||
@@ -135,6 +155,11 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected CrestronGenericBridgeableBaseDevice(string key, string name)
|
||||||
|
: base(key, name)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge);
|
public abstract void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -238,6 +238,42 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void AddDevice(IEnumerable<IKeyed> devicesToAdd)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!DeviceCriticalSection.TryEnter())
|
||||||
|
{
|
||||||
|
Debug.Console(0, Debug.ErrorLogLevel.Error,
|
||||||
|
"Currently unable to add devices to Device Manager. Please try again");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!AddDeviceEnabled)
|
||||||
|
{
|
||||||
|
Debug.Console(0, Debug.ErrorLogLevel.Error,
|
||||||
|
"All devices have been activated. Adding new devices is not allowed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var dev in devicesToAdd)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Devices.Add(dev.Key, dev);
|
||||||
|
}
|
||||||
|
catch (ArgumentException ex)
|
||||||
|
{
|
||||||
|
Debug.Console(0, "Error adding device with key {0} to Device Manager: {1}\r\nStack Trace: {2}",
|
||||||
|
dev.Key, ex.Message, ex.StackTrace);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
DeviceCriticalSection.Leave();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void RemoveDevice(IKeyed newDev)
|
public static void RemoveDevice(IKeyed newDev)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
|
namespace PepperDash_Essentials_Core
|
||||||
|
{
|
||||||
|
public class IsReadyEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public bool IsReady { get; set; }
|
||||||
|
|
||||||
|
public IsReadyEventArgs(bool data)
|
||||||
|
{
|
||||||
|
IsReady = data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public interface IHasReady
|
||||||
|
{
|
||||||
|
event EventHandler<IsReadyEventArgs> IsReadyEvent;
|
||||||
|
bool IsReady { get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,134 +6,192 @@ using Crestron.SimplSharp;
|
|||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
using Crestron.SimplSharpPro.Gateways;
|
using Crestron.SimplSharpPro.Gateways;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using PepperDash_Essentials_Core;
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
[Description("Wrapper class for Crestron Infinet-EX Gateways")]
|
[Description("Wrapper class for Crestron Infinet-EX Gateways")]
|
||||||
public class CenRfgwController : CrestronGenericBaseDevice
|
public class CenRfgwController : CrestronGenericBaseDevice, IHasReady
|
||||||
{
|
{
|
||||||
private GatewayBase _Gateway;
|
public event EventHandler<IsReadyEventArgs> IsReadyEvent;
|
||||||
public GatewayBase GateWay { get { return _Gateway; } }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor for the on-board gateway
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <param name="name"></param>
|
|
||||||
public CenRfgwController(string key, string name, GatewayBase gateway) :
|
|
||||||
base(key, name, gateway)
|
|
||||||
{
|
|
||||||
_Gateway = gateway;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CenRfgwController GetNewExGatewayController(string key, string name, ushort ipId, ushort cresnetId, string gatewayType)
|
|
||||||
{
|
|
||||||
eExGatewayType type = (eExGatewayType)Enum.Parse(typeof(eExGatewayType), gatewayType, true);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var cs = Global.ControlSystem;
|
|
||||||
|
|
||||||
GatewayBase gw = null;
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case eExGatewayType.Ethernet:
|
|
||||||
gw = new CenRfgwEx(ipId, cs);
|
|
||||||
break;
|
|
||||||
case eExGatewayType.EthernetShared:
|
|
||||||
gw = new CenRfgwExEthernetSharable(ipId, cs);
|
|
||||||
break;
|
|
||||||
case eExGatewayType.Cresnet:
|
|
||||||
gw = new CenRfgwExCresnet(cresnetId, cs);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return new CenRfgwController(key, name, gw);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
Debug.Console(0, "ERROR: Cannot create EX Gateway, id {0}, type {1}", type == eExGatewayType.Cresnet ? cresnetId : ipId, gatewayType);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static CenRfgwController GetNewErGatewayController(string key, string name, ushort ipId, ushort cresnetId, string gatewayType)
|
|
||||||
{
|
|
||||||
eExGatewayType type = (eExGatewayType)Enum.Parse(typeof(eExGatewayType), gatewayType, true);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var cs = Global.ControlSystem;
|
|
||||||
|
|
||||||
GatewayBase gw = null;
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case eExGatewayType.Ethernet:
|
|
||||||
gw = new CenErfgwPoe(ipId, cs);
|
|
||||||
break;
|
|
||||||
case eExGatewayType.EthernetShared:
|
|
||||||
gw = new CenErfgwPoeEthernetSharable(ipId, cs);
|
|
||||||
break;
|
|
||||||
case eExGatewayType.Cresnet:
|
|
||||||
gw = new CenErfgwPoeCresnet(cresnetId, cs);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return new CenRfgwController(key, name, gw);
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
Debug.Console(0, "ERROR: Cannot create ER Gateway, id {0}, type {1}", type== eExGatewayType.Cresnet ? cresnetId : ipId, gatewayType);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public enum eExGatewayType
|
|
||||||
{
|
|
||||||
Ethernet, EthernetShared, Cresnet
|
|
||||||
}
|
|
||||||
|
|
||||||
|
public bool IsReady { get; private set; }
|
||||||
|
|
||||||
#region Factory
|
private GatewayBase _gateway;
|
||||||
public class CenRfgwControllerFactory : EssentialsDeviceFactory<CenRfgwController>
|
|
||||||
{
|
|
||||||
public CenRfgwControllerFactory()
|
|
||||||
{
|
|
||||||
TypeNames = new List<string>() { "cenrfgwex", "cenerfgwpoe" };
|
|
||||||
}
|
|
||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public GatewayBase GateWay
|
||||||
{
|
{
|
||||||
|
get { return _gateway; }
|
||||||
Debug.Console(1, "Factory Attempting to create new CEN-GWEXER Device");
|
|
||||||
|
|
||||||
var props = JsonConvert.DeserializeObject<EssentialsRfGatewayConfig>(dc.Properties.ToString());
|
|
||||||
|
|
||||||
var type = dc.Type.ToLower();
|
|
||||||
var control = props.Control;
|
|
||||||
var ipid = control.IpIdInt;
|
|
||||||
var cresnetId = control.CresnetIdInt;
|
|
||||||
var gatewayType = props.GatewayType;
|
|
||||||
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case ("cenrfgwex"):
|
|
||||||
return CenRfgwController.GetNewExGatewayController(dc.Key, dc.Name,
|
|
||||||
(ushort)ipid, (ushort)cresnetId, gatewayType);
|
|
||||||
case ("cenerfgwpoe"):
|
|
||||||
return CenRfgwController.GetNewErGatewayController(dc.Key, dc.Name,
|
|
||||||
(ushort)ipid, (ushort)cresnetId, gatewayType);
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Constructor for the on-board gateway
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <param name="gateway"></param>
|
||||||
|
public CenRfgwController(string key, string name, GatewayBase gateway) :
|
||||||
|
base(key, name, gateway)
|
||||||
|
{
|
||||||
|
_gateway = gateway;
|
||||||
|
IsReady = true;
|
||||||
|
FireIsReadyEvent(IsReady);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CenRfgwController(string key, Func<DeviceConfig, GatewayBase> preActivationFunc, DeviceConfig config) :
|
||||||
|
base(key, config.Name)
|
||||||
|
{
|
||||||
|
IsReady = false;
|
||||||
|
FireIsReadyEvent(IsReady);
|
||||||
|
AddPreActivationAction(() =>
|
||||||
|
{
|
||||||
|
_gateway = preActivationFunc(config);
|
||||||
|
|
||||||
|
IsReady = true;
|
||||||
|
RegisterCrestronGenericBase(_gateway);
|
||||||
|
FireIsReadyEvent(IsReady);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GatewayBase GetNewIpRfGateway(DeviceConfig dc)
|
||||||
|
{
|
||||||
|
var control = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
|
var type = dc.Type;
|
||||||
|
var ipId = control.IpIdInt;
|
||||||
|
|
||||||
|
if (type.Equals("cenrfgwex", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
return new CenRfgwEx(ipId, Global.ControlSystem);
|
||||||
|
}
|
||||||
|
if (type.Equals("cenerfgwpoe", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
return new CenErfgwPoe(ipId, Global.ControlSystem);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FireIsReadyEvent(bool data)
|
||||||
|
{
|
||||||
|
var handler = IsReadyEvent;
|
||||||
|
if (handler == null) return;
|
||||||
|
|
||||||
|
handler(this, new IsReadyEventArgs(data));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GatewayBase GetNewSharedIpRfGateway(DeviceConfig dc)
|
||||||
|
{
|
||||||
|
var control = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
|
var ipId = control.IpIdInt;
|
||||||
|
|
||||||
|
if (dc.Type.Equals("cenrfgwex", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
return new CenRfgwExEthernetSharable(ipId, Global.ControlSystem);
|
||||||
|
}
|
||||||
|
if (dc.Type.Equals("cenerfgwpoe", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
return new CenErfgwPoeEthernetSharable(ipId, Global.ControlSystem);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GatewayBase GetCenRfgwCresnetController(DeviceConfig dc)
|
||||||
|
{
|
||||||
|
var control = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
|
var type = dc.Type;
|
||||||
|
var cresnetId = control.CresnetIdInt;
|
||||||
|
var branchId = control.ControlPortNumber;
|
||||||
|
var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey;
|
||||||
|
|
||||||
|
if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
Debug.Console(0, "Device {0} is a valid cresnet master - creating new CenRfgw", parentKey);
|
||||||
|
if (type.Equals("cenerfgwpoe", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
return new CenErfgwPoeCresnet(cresnetId, Global.ControlSystem);
|
||||||
|
}
|
||||||
|
if (type.Equals("cenrfgwex", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
return new CenRfgwExCresnet(cresnetId, Global.ControlSystem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as ICresnetBridge;
|
||||||
|
|
||||||
|
if (cresnetBridge != null)
|
||||||
|
{
|
||||||
|
Debug.Console(0, "Device {0} is a valid cresnet master - creating new CenRfgw", parentKey);
|
||||||
|
|
||||||
|
if (type.Equals("cenerfgwpoe", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
return new CenErfgwPoeCresnet(cresnetId, cresnetBridge.Branches[branchId]);
|
||||||
|
}
|
||||||
|
if (type.Equals("cenrfgwex", StringComparison.InvariantCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
return new CenRfgwExCresnet(cresnetId, cresnetBridge.Branches[branchId]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public enum EExGatewayType
|
||||||
|
{
|
||||||
|
Ethernet,
|
||||||
|
EthernetShared,
|
||||||
|
Cresnet
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region Factory
|
||||||
|
|
||||||
|
public class CenRfgwControllerFactory : EssentialsDeviceFactory<CenRfgwController>
|
||||||
|
{
|
||||||
|
public CenRfgwControllerFactory()
|
||||||
|
{
|
||||||
|
TypeNames = new List<string> {"cenrfgwex", "cenerfgwpoe"};
|
||||||
|
}
|
||||||
|
|
||||||
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
|
{
|
||||||
|
|
||||||
|
Debug.Console(1, "Factory Attempting to create new CEN-GWEXER Device");
|
||||||
|
|
||||||
|
var props = JsonConvert.DeserializeObject<EssentialsRfGatewayConfig>(dc.Properties.ToString());
|
||||||
|
|
||||||
|
EExGatewayType gatewayType =
|
||||||
|
(EExGatewayType) Enum.Parse(typeof (EExGatewayType), props.GatewayType, true);
|
||||||
|
|
||||||
|
switch (gatewayType)
|
||||||
|
{
|
||||||
|
case (EExGatewayType.Ethernet):
|
||||||
|
return new CenRfgwController(dc.Key, dc.Name, GetNewIpRfGateway(dc));
|
||||||
|
case (EExGatewayType.EthernetShared):
|
||||||
|
return new CenRfgwController(dc.Key, dc.Name, GetNewSharedIpRfGateway(dc));
|
||||||
|
case (EExGatewayType.Cresnet):
|
||||||
|
return new CenRfgwController(dc.Key, GetCenRfgwCresnetController, dc);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,488 +1,488 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using Crestron.SimplSharp.Reflection;
|
using Crestron.SimplSharp.Reflection;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
public static class JoinMapHelper
|
public static class JoinMapHelper
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Attempts to get the serialized join map from config
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="joinMapKey"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static string GetSerializedJoinMapForDevice(string joinMapKey)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(joinMapKey))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
var joinMap = ConfigReader.ConfigObject.JoinMaps[joinMapKey];
|
|
||||||
|
|
||||||
return joinMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Attempts to get the serialized join map from config
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="joinMapKey"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static string GetJoinMapForDevice(string joinMapKey)
|
|
||||||
{
|
|
||||||
return GetSerializedJoinMapForDevice(joinMapKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Attempts to find a custom join map by key and returns it deserialized if found
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="joinMapKey"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public static Dictionary<string, JoinData> TryGetJoinMapAdvancedForDevice(string joinMapKey)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrEmpty(joinMapKey))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
var joinMapSerialzed = ConfigReader.ConfigObject.JoinMaps[joinMapKey];
|
|
||||||
|
|
||||||
if (joinMapSerialzed == null) return null;
|
|
||||||
|
|
||||||
var joinMapData = JsonConvert.DeserializeObject<Dictionary<string, JoinData>>(joinMapSerialzed);
|
|
||||||
|
|
||||||
return joinMapData;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Base class for join maps
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("This is being deprecated in favor of JoinMapBaseAdvanced")]
|
|
||||||
public abstract class JoinMapBase
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Modifies all the join numbers by adding the offset. This should never be called twice
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="joinStart"></param>
|
|
||||||
public abstract void OffsetJoinNumbers(uint joinStart);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The collection of joins and associated metadata
|
|
||||||
/// </summary>
|
|
||||||
public Dictionary<string, JoinMetadata> Joins = new Dictionary<string, JoinMetadata>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Prints the join information to console
|
|
||||||
/// </summary>
|
|
||||||
public void PrintJoinMapInfo()
|
|
||||||
{
|
|
||||||
Debug.Console(0, "{0}:\n", GetType().Name);
|
|
||||||
|
|
||||||
// Get the joins of each type and print them
|
|
||||||
Debug.Console(0, "Digitals:");
|
|
||||||
var digitals = Joins.Where(j => (j.Value.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value);
|
|
||||||
Debug.Console(2, "Found {0} Digital Joins", digitals.Count);
|
|
||||||
PrintJoinList(GetSortedJoins(digitals));
|
|
||||||
|
|
||||||
Debug.Console(0, "Analogs:");
|
|
||||||
var analogs = Joins.Where(j => (j.Value.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value);
|
|
||||||
Debug.Console(2, "Found {0} Analog Joins", analogs.Count);
|
|
||||||
PrintJoinList(GetSortedJoins(analogs));
|
|
||||||
|
|
||||||
Debug.Console(0, "Serials:");
|
|
||||||
var serials = Joins.Where(j => (j.Value.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value);
|
|
||||||
Debug.Console(2, "Found {0} Serial Joins", serials.Count);
|
|
||||||
PrintJoinList(GetSortedJoins(serials));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a sorted list by JoinNumber
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="joins"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
List<KeyValuePair<string, JoinMetadata>> GetSortedJoins(Dictionary<string, JoinMetadata> joins)
|
|
||||||
{
|
|
||||||
var sortedJoins = joins.ToList();
|
|
||||||
|
|
||||||
sortedJoins.Sort((pair1, pair2) => pair1.Value.JoinNumber.CompareTo(pair2.Value.JoinNumber));
|
|
||||||
|
|
||||||
return sortedJoins;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintJoinList(List<KeyValuePair<string, JoinMetadata>> joins)
|
|
||||||
{
|
|
||||||
foreach (var join in joins)
|
|
||||||
{
|
|
||||||
Debug.Console(0,
|
|
||||||
@"Join Number: {0} | Label: '{1}' | JoinSpan: '{2}' | Type: '{3}' | Capabilities: '{4}'",
|
|
||||||
join.Value.JoinNumber,
|
|
||||||
join.Value.Label,
|
|
||||||
join.Value.JoinSpan,
|
|
||||||
join.Value.JoinType.ToString(),
|
|
||||||
join.Value.JoinCapabilities.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the join number for the join with the specified key
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public uint GetJoinForKey(string key)
|
|
||||||
{
|
|
||||||
return Joins.ContainsKey(key) ? Joins[key].JoinNumber : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the join span for the join with the specified key
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public uint GetJoinSpanForKey(string key)
|
|
||||||
{
|
|
||||||
return Joins.ContainsKey(key) ? Joins[key].JoinSpan : 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Base class for join maps
|
|
||||||
/// </summary>
|
|
||||||
public abstract class JoinMapBaseAdvanced
|
|
||||||
{
|
|
||||||
protected uint JoinOffset;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The collection of joins and associated metadata
|
|
||||||
/// </summary>
|
|
||||||
public Dictionary<string, JoinDataComplete> Joins { get; private set; }
|
|
||||||
|
|
||||||
protected JoinMapBaseAdvanced(uint joinStart)
|
|
||||||
{
|
|
||||||
Joins = new Dictionary<string, JoinDataComplete>();
|
|
||||||
|
|
||||||
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), true))
|
|
||||||
// .Select(field => (JoinDataComplete)field.GetValue(this))
|
|
||||||
// .ToDictionary(join => join.GetNameAttribute(), join =>
|
|
||||||
// {
|
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Prints the join information to console
|
|
||||||
/// </summary>
|
|
||||||
public void PrintJoinMapInfo()
|
|
||||||
{
|
|
||||||
Debug.Console(0, "{0}:\n", GetType().Name);
|
|
||||||
|
|
||||||
// Get the joins of each type and print them
|
|
||||||
Debug.Console(0, "Digitals:");
|
|
||||||
var digitals = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value);
|
|
||||||
Debug.Console(2, "Found {0} Digital Joins", digitals.Count);
|
|
||||||
PrintJoinList(GetSortedJoins(digitals));
|
|
||||||
|
|
||||||
Debug.Console(0, "Analogs:");
|
|
||||||
var analogs = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value);
|
|
||||||
Debug.Console(2, "Found {0} Analog Joins", analogs.Count);
|
|
||||||
PrintJoinList(GetSortedJoins(analogs));
|
|
||||||
|
|
||||||
Debug.Console(0, "Serials:");
|
|
||||||
var serials = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value);
|
|
||||||
Debug.Console(2, "Found {0} Serial Joins", serials.Count);
|
|
||||||
PrintJoinList(GetSortedJoins(serials));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a sorted list by JoinNumber
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="joins"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
List<KeyValuePair<string, JoinDataComplete>> GetSortedJoins(Dictionary<string, JoinDataComplete> joins)
|
|
||||||
{
|
|
||||||
var sortedJoins = joins.ToList();
|
|
||||||
|
|
||||||
sortedJoins.Sort((pair1, pair2) => pair1.Value.JoinNumber.CompareTo(pair2.Value.JoinNumber));
|
|
||||||
|
|
||||||
return sortedJoins;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintJoinList(List<KeyValuePair<string, JoinDataComplete>> joins)
|
|
||||||
{
|
|
||||||
foreach (var join in joins)
|
|
||||||
{
|
|
||||||
Debug.Console(0,
|
|
||||||
@"Join Number: {0} | JoinSpan: '{1}' | Label: '{2}' | Type: '{3}' | Capabilities: '{4}'",
|
|
||||||
join.Value.JoinNumber,
|
|
||||||
join.Value.JoinSpan,
|
|
||||||
join.Value.Metadata.Label,
|
|
||||||
join.Value.Metadata.JoinType.ToString(),
|
|
||||||
join.Value.Metadata.JoinCapabilities.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Attempts to find the matching key for the custom join and if found overwrites the default JoinData with the custom
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="joinData"></param>
|
|
||||||
public void SetCustomJoinData(Dictionary<string, JoinData> joinData)
|
|
||||||
{
|
|
||||||
foreach (var customJoinData in joinData)
|
|
||||||
{
|
|
||||||
var join = Joins[customJoinData.Key];
|
|
||||||
|
|
||||||
if (join != null)
|
|
||||||
{
|
|
||||||
join.SetCustomJoinData(customJoinData.Value);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.Console(2, "No mathcing key found in join map for: '{0}'", customJoinData.Key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
PrintJoinMapInfo();
|
|
||||||
}
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// Returns the join number for the join with the specified key
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="key"></param>
|
|
||||||
///// <returns></returns>
|
|
||||||
//public uint GetJoinForKey(string key)
|
|
||||||
//{
|
|
||||||
// return Joins.ContainsKey(key) ? Joins[key].JoinNumber : 0;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// Returns the join span for the join with the specified key
|
|
||||||
///// </summary>
|
|
||||||
///// <param name="key"></param>
|
|
||||||
///// <returns></returns>
|
|
||||||
//public uint GetJoinSpanForKey(string key)
|
|
||||||
//{
|
|
||||||
// return Joins.ContainsKey(key) ? Joins[key].JoinSpan : 0;
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Read = Provides feedback to SIMPL
|
|
||||||
/// Write = Responds to sig values from SIMPL
|
|
||||||
/// </summary>
|
|
||||||
[Flags]
|
|
||||||
public enum eJoinCapabilities
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
ToSIMPL = 1,
|
|
||||||
FromSIMPL = 2,
|
|
||||||
ToFromSIMPL = ToSIMPL | FromSIMPL
|
|
||||||
}
|
|
||||||
|
|
||||||
[Flags]
|
|
||||||
public enum eJoinType
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
Digital = 1,
|
|
||||||
Analog = 2,
|
|
||||||
Serial = 4,
|
|
||||||
DigitalAnalog = Digital | Analog,
|
|
||||||
DigitalSerial = Digital | Serial,
|
|
||||||
AnalogSerial = Analog | Serial,
|
|
||||||
DigitalAnalogSerial = Digital | Analog | Serial
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Metadata describing the join
|
|
||||||
/// </summary>
|
|
||||||
public class JoinMetadata
|
|
||||||
{
|
{
|
||||||
private string _description;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Join number (based on join offset value)
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("joinNumber")]
|
|
||||||
[Obsolete]
|
|
||||||
public uint JoinNumber { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Join range span. If join indicates the start of a range of joins, this indicated the maximum number of joins in the range
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete]
|
|
||||||
[JsonProperty("joinSpan")]
|
|
||||||
public uint JoinSpan { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A label for the join to better describe its usage
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Use Description instead")]
|
|
||||||
[JsonProperty("label")]
|
|
||||||
public string Label { get { return _description; } set { _description = value; } }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A description for the join to better describe its usage
|
/// Attempts to get the serialized join map from config
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("description")]
|
/// <param name="joinMapKey"></param>
|
||||||
public string Description { get { return _description; } set { _description = value; } }
|
/// <returns></returns>
|
||||||
/// <summary>
|
public static string GetSerializedJoinMapForDevice(string joinMapKey)
|
||||||
/// Signal type(s)
|
{
|
||||||
/// </summary>
|
if (string.IsNullOrEmpty(joinMapKey))
|
||||||
[JsonProperty("joinType")]
|
return null;
|
||||||
public eJoinType JoinType { get; set; }
|
|
||||||
/// <summary>
|
var joinMap = ConfigReader.ConfigObject.JoinMaps[joinMapKey];
|
||||||
/// Indicates whether the join is read and/or write
|
|
||||||
/// </summary>
|
return joinMap;
|
||||||
[JsonProperty("joinCapabilities")]
|
}
|
||||||
public eJoinCapabilities JoinCapabilities { get; set; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Indicates a set of valid values (particularly if this translates to an enum
|
/// Attempts to get the serialized join map from config
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("validValues")]
|
/// <param name="joinMapKey"></param>
|
||||||
public string[] ValidValues { get; set; }
|
/// <returns></returns>
|
||||||
|
public static string GetJoinMapForDevice(string joinMapKey)
|
||||||
}
|
{
|
||||||
|
return GetSerializedJoinMapForDevice(joinMapKey);
|
||||||
/// <summary>
|
}
|
||||||
/// Data describing the join. Can be
|
|
||||||
/// </summary>
|
/// <summary>
|
||||||
public class JoinData
|
/// Attempts to find a custom join map by key and returns it deserialized if found
|
||||||
{
|
/// </summary>
|
||||||
/// <summary>
|
/// <param name="joinMapKey"></param>
|
||||||
/// Join number (based on join offset value)
|
/// <returns></returns>
|
||||||
/// </summary>
|
public static Dictionary<string, JoinData> TryGetJoinMapAdvancedForDevice(string joinMapKey)
|
||||||
[JsonProperty("joinNumber")]
|
{
|
||||||
public uint JoinNumber { get; set; }
|
if (string.IsNullOrEmpty(joinMapKey))
|
||||||
/// <summary>
|
return null;
|
||||||
/// Join range span. If join indicates the start of a range of joins, this indicated the maximum number of joins in the range
|
|
||||||
/// </summary>
|
var joinMapSerialzed = ConfigReader.ConfigObject.JoinMaps[joinMapKey];
|
||||||
[JsonProperty("joinSpan")]
|
|
||||||
public uint JoinSpan { get; set; }
|
if (joinMapSerialzed == null) return null;
|
||||||
}
|
|
||||||
|
var joinMapData = JsonConvert.DeserializeObject<Dictionary<string, JoinData>>(joinMapSerialzed);
|
||||||
/// <summary>
|
|
||||||
/// A class to aggregate the JoinData and JoinMetadata for a join
|
return joinMapData;
|
||||||
/// </summary>
|
}
|
||||||
public class JoinDataComplete
|
|
||||||
{
|
}
|
||||||
private uint _joinOffset;
|
|
||||||
|
/// <summary>
|
||||||
private JoinData _data;
|
/// Base class for join maps
|
||||||
public JoinMetadata Metadata { get; set; }
|
/// </summary>
|
||||||
|
[Obsolete("This is being deprecated in favor of JoinMapBaseAdvanced")]
|
||||||
public JoinDataComplete(JoinData data, JoinMetadata metadata)
|
public abstract class JoinMapBase
|
||||||
{
|
{
|
||||||
_data = data;
|
/// <summary>
|
||||||
Metadata = metadata;
|
/// Modifies all the join numbers by adding the offset. This should never be called twice
|
||||||
}
|
/// </summary>
|
||||||
|
/// <param name="joinStart"></param>
|
||||||
/// <summary>
|
public abstract void OffsetJoinNumbers(uint joinStart);
|
||||||
/// Sets the join offset value
|
|
||||||
/// </summary>
|
/// <summary>
|
||||||
/// <param name="joinOffset"></param>
|
/// The collection of joins and associated metadata
|
||||||
public void SetJoinOffset(uint joinOffset)
|
/// </summary>
|
||||||
{
|
public Dictionary<string, JoinMetadata> Joins = new Dictionary<string, JoinMetadata>();
|
||||||
_joinOffset = joinOffset;
|
|
||||||
}
|
/// <summary>
|
||||||
|
/// Prints the join information to console
|
||||||
/// <summary>
|
/// </summary>
|
||||||
/// The join number (including the offset)
|
public void PrintJoinMapInfo()
|
||||||
/// </summary>
|
{
|
||||||
public uint JoinNumber
|
Debug.Console(0, "{0}:\n", GetType().Name);
|
||||||
{
|
|
||||||
get { return _data.JoinNumber+ _joinOffset; }
|
// Get the joins of each type and print them
|
||||||
set { _data.JoinNumber = value; }
|
Debug.Console(0, "Digitals:");
|
||||||
}
|
var digitals = Joins.Where(j => (j.Value.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value);
|
||||||
|
Debug.Console(2, "Found {0} Digital Joins", digitals.Count);
|
||||||
public uint JoinSpan
|
PrintJoinList(GetSortedJoins(digitals));
|
||||||
{
|
|
||||||
get { return _data.JoinSpan; }
|
Debug.Console(0, "Analogs:");
|
||||||
}
|
var analogs = Joins.Where(j => (j.Value.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value);
|
||||||
|
Debug.Console(2, "Found {0} Analog Joins", analogs.Count);
|
||||||
public void SetCustomJoinData(JoinData customJoinData)
|
PrintJoinList(GetSortedJoins(analogs));
|
||||||
{
|
|
||||||
_data = customJoinData;
|
Debug.Console(0, "Serials:");
|
||||||
}
|
var serials = Joins.Where(j => (j.Value.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value);
|
||||||
|
Debug.Console(2, "Found {0} Serial Joins", serials.Count);
|
||||||
public string GetNameAttribute(MemberInfo memberInfo)
|
PrintJoinList(GetSortedJoins(serials));
|
||||||
{
|
|
||||||
var name = string.Empty;
|
}
|
||||||
var attribute = (JoinNameAttribute)CAttribute.GetCustomAttribute(memberInfo, typeof(JoinNameAttribute));
|
|
||||||
|
/// <summary>
|
||||||
if (attribute == null) return name;
|
/// Returns a sorted list by JoinNumber
|
||||||
|
/// </summary>
|
||||||
name = attribute.Name;
|
/// <param name="joins"></param>
|
||||||
Debug.Console(2, "JoinName Attribute value: {0}", name);
|
/// <returns></returns>
|
||||||
return name;
|
List<KeyValuePair<string, JoinMetadata>> GetSortedJoins(Dictionary<string, JoinMetadata> joins)
|
||||||
|
{
|
||||||
|
var sortedJoins = joins.ToList();
|
||||||
|
|
||||||
|
sortedJoins.Sort((pair1, pair2) => pair1.Value.JoinNumber.CompareTo(pair2.Value.JoinNumber));
|
||||||
|
|
||||||
|
return sortedJoins;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintJoinList(List<KeyValuePair<string, JoinMetadata>> joins)
|
||||||
|
{
|
||||||
|
foreach (var join in joins)
|
||||||
|
{
|
||||||
|
Debug.Console(0,
|
||||||
|
@"Join Number: {0} | Label: '{1}' | JoinSpan: '{2}' | Type: '{3}' | Capabilities: '{4}'",
|
||||||
|
join.Value.JoinNumber,
|
||||||
|
join.Value.Label,
|
||||||
|
join.Value.JoinSpan,
|
||||||
|
join.Value.JoinType.ToString(),
|
||||||
|
join.Value.JoinCapabilities.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the join number for the join with the specified key
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public uint GetJoinForKey(string key)
|
||||||
|
{
|
||||||
|
return Joins.ContainsKey(key) ? Joins[key].JoinNumber : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the join span for the join with the specified key
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public uint GetJoinSpanForKey(string key)
|
||||||
|
{
|
||||||
|
return Joins.ContainsKey(key) ? Joins[key].JoinSpan : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Base class for join maps
|
||||||
[AttributeUsage(AttributeTargets.All)]
|
/// </summary>
|
||||||
public class JoinNameAttribute : CAttribute
|
public abstract class JoinMapBaseAdvanced
|
||||||
{
|
{
|
||||||
private string _Name;
|
protected uint JoinOffset;
|
||||||
|
|
||||||
public JoinNameAttribute(string name)
|
/// <summary>
|
||||||
{
|
/// The collection of joins and associated metadata
|
||||||
Debug.Console(2, "Setting Attribute Name: {0}", name);
|
/// </summary>
|
||||||
_Name = name;
|
public Dictionary<string, JoinDataComplete> Joins { get; private set; }
|
||||||
}
|
|
||||||
|
protected JoinMapBaseAdvanced(uint joinStart)
|
||||||
public string Name
|
{
|
||||||
{
|
Joins = new Dictionary<string, JoinDataComplete>();
|
||||||
get { return _Name; }
|
|
||||||
}
|
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), true))
|
||||||
|
// .Select(field => (JoinDataComplete)field.GetValue(this))
|
||||||
|
// .ToDictionary(join => join.GetNameAttribute(), join =>
|
||||||
|
// {
|
||||||
|
// 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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Prints the join information to console
|
||||||
|
/// </summary>
|
||||||
|
public void PrintJoinMapInfo()
|
||||||
|
{
|
||||||
|
Debug.Console(0, "{0}:\n", GetType().Name);
|
||||||
|
|
||||||
|
// Get the joins of each type and print them
|
||||||
|
Debug.Console(0, "Digitals:");
|
||||||
|
var digitals = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value);
|
||||||
|
Debug.Console(2, "Found {0} Digital Joins", digitals.Count);
|
||||||
|
PrintJoinList(GetSortedJoins(digitals));
|
||||||
|
|
||||||
|
Debug.Console(0, "Analogs:");
|
||||||
|
var analogs = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value);
|
||||||
|
Debug.Console(2, "Found {0} Analog Joins", analogs.Count);
|
||||||
|
PrintJoinList(GetSortedJoins(analogs));
|
||||||
|
|
||||||
|
Debug.Console(0, "Serials:");
|
||||||
|
var serials = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value);
|
||||||
|
Debug.Console(2, "Found {0} Serial Joins", serials.Count);
|
||||||
|
PrintJoinList(GetSortedJoins(serials));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a sorted list by JoinNumber
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="joins"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
List<KeyValuePair<string, JoinDataComplete>> GetSortedJoins(Dictionary<string, JoinDataComplete> joins)
|
||||||
|
{
|
||||||
|
var sortedJoins = joins.ToList();
|
||||||
|
|
||||||
|
sortedJoins.Sort((pair1, pair2) => pair1.Value.JoinNumber.CompareTo(pair2.Value.JoinNumber));
|
||||||
|
|
||||||
|
return sortedJoins;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PrintJoinList(List<KeyValuePair<string, JoinDataComplete>> joins)
|
||||||
|
{
|
||||||
|
foreach (var join in joins)
|
||||||
|
{
|
||||||
|
Debug.Console(0,
|
||||||
|
@"Join Number: {0} | JoinSpan: '{1}' | Label: '{2}' | Type: '{3}' | Capabilities: '{4}'",
|
||||||
|
join.Value.JoinNumber,
|
||||||
|
join.Value.JoinSpan,
|
||||||
|
join.Value.Metadata.Label,
|
||||||
|
join.Value.Metadata.JoinType.ToString(),
|
||||||
|
join.Value.Metadata.JoinCapabilities.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Attempts to find the matching key for the custom join and if found overwrites the default JoinData with the custom
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="joinData"></param>
|
||||||
|
public void SetCustomJoinData(Dictionary<string, JoinData> joinData)
|
||||||
|
{
|
||||||
|
foreach (var customJoinData in joinData)
|
||||||
|
{
|
||||||
|
var join = Joins[customJoinData.Key];
|
||||||
|
|
||||||
|
if (join != null)
|
||||||
|
{
|
||||||
|
join.SetCustomJoinData(customJoinData.Value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Console(2, "No mathcing key found in join map for: '{0}'", customJoinData.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintJoinMapInfo();
|
||||||
|
}
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// Returns the join number for the join with the specified key
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="key"></param>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public uint GetJoinForKey(string key)
|
||||||
|
//{
|
||||||
|
// return Joins.ContainsKey(key) ? Joins[key].JoinNumber : 0;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
///// <summary>
|
||||||
|
///// Returns the join span for the join with the specified key
|
||||||
|
///// </summary>
|
||||||
|
///// <param name="key"></param>
|
||||||
|
///// <returns></returns>
|
||||||
|
//public uint GetJoinSpanForKey(string key)
|
||||||
|
//{
|
||||||
|
// return Joins.ContainsKey(key) ? Joins[key].JoinSpan : 0;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Read = Provides feedback to SIMPL
|
||||||
|
/// Write = Responds to sig values from SIMPL
|
||||||
|
/// </summary>
|
||||||
|
[Flags]
|
||||||
|
public enum eJoinCapabilities
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
ToSIMPL = 1,
|
||||||
|
FromSIMPL = 2,
|
||||||
|
ToFromSIMPL = ToSIMPL | FromSIMPL
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum eJoinType
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
Digital = 1,
|
||||||
|
Analog = 2,
|
||||||
|
Serial = 4,
|
||||||
|
DigitalAnalog = Digital | Analog,
|
||||||
|
DigitalSerial = Digital | Serial,
|
||||||
|
AnalogSerial = Analog | Serial,
|
||||||
|
DigitalAnalogSerial = Digital | Analog | Serial
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Metadata describing the join
|
||||||
|
/// </summary>
|
||||||
|
public class JoinMetadata
|
||||||
|
{
|
||||||
|
private string _description;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Join number (based on join offset value)
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("joinNumber")]
|
||||||
|
[Obsolete]
|
||||||
|
public uint JoinNumber { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Join range span. If join indicates the start of a range of joins, this indicated the maximum number of joins in the range
|
||||||
|
/// </summary>
|
||||||
|
[Obsolete]
|
||||||
|
[JsonProperty("joinSpan")]
|
||||||
|
public uint JoinSpan { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A label for the join to better describe its usage
|
||||||
|
/// </summary>
|
||||||
|
[Obsolete("Use Description instead")]
|
||||||
|
[JsonProperty("label")]
|
||||||
|
public string Label { get { return _description; } set { _description = value; } }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A description for the join to better describe its usage
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("description")]
|
||||||
|
public string Description { get { return _description; } set { _description = value; } }
|
||||||
|
/// <summary>
|
||||||
|
/// Signal type(s)
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("joinType")]
|
||||||
|
public eJoinType JoinType { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates whether the join is read and/or write
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("joinCapabilities")]
|
||||||
|
public eJoinCapabilities JoinCapabilities { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates a set of valid values (particularly if this translates to an enum
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("validValues")]
|
||||||
|
public string[] ValidValues { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Data describing the join. Can be
|
||||||
|
/// </summary>
|
||||||
|
public class JoinData
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Join number (based on join offset value)
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("joinNumber")]
|
||||||
|
public uint JoinNumber { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Join range span. If join indicates the start of a range of joins, this indicated the maximum number of joins in the range
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("joinSpan")]
|
||||||
|
public uint JoinSpan { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A class to aggregate the JoinData and JoinMetadata for a join
|
||||||
|
/// </summary>
|
||||||
|
public class JoinDataComplete
|
||||||
|
{
|
||||||
|
private uint _joinOffset;
|
||||||
|
|
||||||
|
private JoinData _data;
|
||||||
|
public JoinMetadata Metadata { get; set; }
|
||||||
|
|
||||||
|
public JoinDataComplete(JoinData data, JoinMetadata metadata)
|
||||||
|
{
|
||||||
|
_data = data;
|
||||||
|
Metadata = metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the join offset value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="joinOffset"></param>
|
||||||
|
public void SetJoinOffset(uint joinOffset)
|
||||||
|
{
|
||||||
|
_joinOffset = joinOffset;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The join number (including the offset)
|
||||||
|
/// </summary>
|
||||||
|
public uint JoinNumber
|
||||||
|
{
|
||||||
|
get { return _data.JoinNumber+ _joinOffset; }
|
||||||
|
set { _data.JoinNumber = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public uint JoinSpan
|
||||||
|
{
|
||||||
|
get { return _data.JoinSpan; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetCustomJoinData(JoinData customJoinData)
|
||||||
|
{
|
||||||
|
_data = customJoinData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetNameAttribute(MemberInfo memberInfo)
|
||||||
|
{
|
||||||
|
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.All)]
|
||||||
|
public class JoinNameAttribute : CAttribute
|
||||||
|
{
|
||||||
|
private string _Name;
|
||||||
|
|
||||||
|
public JoinNameAttribute(string name)
|
||||||
|
{
|
||||||
|
Debug.Console(2, "Setting Attribute Name: {0}", name);
|
||||||
|
_Name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return _Name; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ using PepperDash.Essentials.Core;
|
|||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Common.Occupancy
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
[Description("Wrapper class for CEN-ODT-C-POE")]
|
[Description("Wrapper class for CEN-ODT-C-POE")]
|
||||||
public class CenOdtOccupancySensorBaseController : CrestronGenericBridgeableBaseDevice, IOccupancyStatusProvider
|
public class CenOdtOccupancySensorBaseController : CrestronGenericBridgeableBaseDevice, IOccupancyStatusProvider
|
||||||
@@ -11,7 +11,7 @@ using PepperDash.Essentials.Core;
|
|||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Common.Occupancy
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
[Description("Wrapper class for Single Technology GLS Occupancy Sensors")]
|
[Description("Wrapper class for Single Technology GLS Occupancy Sensors")]
|
||||||
public class GlsOccupancySensorBaseController : CrestronGenericBridgeableBaseDevice, IOccupancyStatusProvider
|
public class GlsOccupancySensorBaseController : CrestronGenericBridgeableBaseDevice, IOccupancyStatusProvider
|
||||||
@@ -55,11 +55,29 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GlsOccupancySensorBaseController(string key, string name, GlsOccupancySensorBase sensor)
|
public GlsOccupancySensorBaseController(string key, Func<DeviceConfig, GlsOccupancySensorBase> preActivationFunc,
|
||||||
: base(key, name, sensor)
|
DeviceConfig config)
|
||||||
|
: base(key, config.Name)
|
||||||
{
|
{
|
||||||
OccSensor = sensor;
|
|
||||||
|
|
||||||
|
AddPreActivationAction(() =>
|
||||||
|
{
|
||||||
|
OccSensor = preActivationFunc(config);
|
||||||
|
|
||||||
|
RegisterCrestronGenericBase(OccSensor);
|
||||||
|
|
||||||
|
RegisterGlsOdtSensorBaseController(OccSensor);
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public GlsOccupancySensorBaseController(string key, string name) : base(key, name) {}
|
||||||
|
|
||||||
|
protected void RegisterGlsOdtSensorBaseController(GlsOccupancySensorBase occSensor)
|
||||||
|
{
|
||||||
|
OccSensor = occSensor;
|
||||||
|
|
||||||
RoomIsOccupiedFeedback = new BoolFeedback(RoomIsOccupiedFeedbackFunc);
|
RoomIsOccupiedFeedback = new BoolFeedback(RoomIsOccupiedFeedbackFunc);
|
||||||
|
|
||||||
PirSensorEnabledFeedback = new BoolFeedback(() => OccSensor.PirEnabledFeedback.BoolValue);
|
PirSensorEnabledFeedback = new BoolFeedback(() => OccSensor.PirEnabledFeedback.BoolValue);
|
||||||
@@ -68,15 +86,18 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy
|
|||||||
|
|
||||||
ShortTimeoutEnabledFeedback = new BoolFeedback(() => OccSensor.ShortTimeoutEnabledFeedback.BoolValue);
|
ShortTimeoutEnabledFeedback = new BoolFeedback(() => OccSensor.ShortTimeoutEnabledFeedback.BoolValue);
|
||||||
|
|
||||||
PirSensitivityInVacantStateFeedback = new IntFeedback(() => OccSensor.PirSensitivityInVacantStateFeedback.UShortValue);
|
PirSensitivityInVacantStateFeedback =
|
||||||
|
new IntFeedback(() => OccSensor.PirSensitivityInVacantStateFeedback.UShortValue);
|
||||||
|
|
||||||
PirSensitivityInOccupiedStateFeedback = new IntFeedback(() => OccSensor.PirSensitivityInOccupiedStateFeedback.UShortValue);
|
PirSensitivityInOccupiedStateFeedback =
|
||||||
|
new IntFeedback(() => OccSensor.PirSensitivityInOccupiedStateFeedback.UShortValue);
|
||||||
|
|
||||||
CurrentTimeoutFeedback = new IntFeedback(() => OccSensor.CurrentTimeoutFeedback.UShortValue);
|
CurrentTimeoutFeedback = new IntFeedback(() => OccSensor.CurrentTimeoutFeedback.UShortValue);
|
||||||
|
|
||||||
LocalTimoutFeedback = new IntFeedback(() => OccSensor.LocalTimeoutFeedback.UShortValue);
|
LocalTimoutFeedback = new IntFeedback(() => OccSensor.LocalTimeoutFeedback.UShortValue);
|
||||||
|
|
||||||
GraceOccupancyDetectedFeedback = new BoolFeedback(() => OccSensor.GraceOccupancyDetectedFeedback.BoolValue);
|
GraceOccupancyDetectedFeedback =
|
||||||
|
new BoolFeedback(() => OccSensor.GraceOccupancyDetectedFeedback.BoolValue);
|
||||||
|
|
||||||
RawOccupancyFeedback = new BoolFeedback(() => OccSensor.RawOccupancyFeedback.BoolValue);
|
RawOccupancyFeedback = new BoolFeedback(() => OccSensor.RawOccupancyFeedback.BoolValue);
|
||||||
|
|
||||||
@@ -84,9 +105,9 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy
|
|||||||
|
|
||||||
ExternalPhotoSensorValue = new IntFeedback(() => OccSensor.ExternalPhotoSensorValueFeedback.UShortValue);
|
ExternalPhotoSensorValue = new IntFeedback(() => OccSensor.ExternalPhotoSensorValueFeedback.UShortValue);
|
||||||
|
|
||||||
OccSensor.BaseEvent += new Crestron.SimplSharpPro.BaseEventHandler(OccSensor_BaseEvent);
|
OccSensor.BaseEvent += OccSensor_BaseEvent;
|
||||||
|
|
||||||
OccSensor.GlsOccupancySensorChange += new GlsOccupancySensorChangeEventHandler(OccSensor_GlsOccupancySensorChange);
|
OccSensor.GlsOccupancySensorChange += OccSensor_GlsOccupancySensorChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -97,40 +118,56 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy
|
|||||||
/// <param name="args"></param>
|
/// <param name="args"></param>
|
||||||
protected virtual void OccSensor_GlsOccupancySensorChange(GlsOccupancySensorBase device, GlsOccupancySensorChangeEventArgs args)
|
protected virtual void OccSensor_GlsOccupancySensorChange(GlsOccupancySensorBase device, GlsOccupancySensorChangeEventArgs args)
|
||||||
{
|
{
|
||||||
if (args.EventId == GlsOccupancySensorBase.PirEnabledFeedbackEventId)
|
switch (args.EventId)
|
||||||
PirSensorEnabledFeedback.FireUpdate();
|
{
|
||||||
else if (args.EventId == GlsOccupancySensorBase.LedFlashEnabledFeedbackEventId)
|
case GlsOccupancySensorBase.PirEnabledFeedbackEventId:
|
||||||
LedFlashEnabledFeedback.FireUpdate();
|
PirSensorEnabledFeedback.FireUpdate();
|
||||||
else if (args.EventId == GlsOccupancySensorBase.ShortTimeoutEnabledFeedbackEventId)
|
break;
|
||||||
ShortTimeoutEnabledFeedback.FireUpdate();
|
case GlsOccupancySensorBase.LedFlashEnabledFeedbackEventId:
|
||||||
else if (args.EventId == GlsOccupancySensorBase.PirSensitivityInOccupiedStateFeedbackEventId)
|
LedFlashEnabledFeedback.FireUpdate();
|
||||||
PirSensitivityInOccupiedStateFeedback.FireUpdate();
|
break;
|
||||||
else if (args.EventId == GlsOccupancySensorBase.PirSensitivityInVacantStateFeedbackEventId)
|
case GlsOccupancySensorBase.ShortTimeoutEnabledFeedbackEventId:
|
||||||
PirSensitivityInVacantStateFeedback.FireUpdate();
|
ShortTimeoutEnabledFeedback.FireUpdate();
|
||||||
|
break;
|
||||||
|
case GlsOccupancySensorBase.PirSensitivityInOccupiedStateFeedbackEventId:
|
||||||
|
PirSensitivityInOccupiedStateFeedback.FireUpdate();
|
||||||
|
break;
|
||||||
|
case GlsOccupancySensorBase.PirSensitivityInVacantStateFeedbackEventId:
|
||||||
|
PirSensitivityInVacantStateFeedback.FireUpdate();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void OccSensor_BaseEvent(Crestron.SimplSharpPro.GenericBase device, Crestron.SimplSharpPro.BaseEventArgs args)
|
protected virtual void OccSensor_BaseEvent(Crestron.SimplSharpPro.GenericBase device, Crestron.SimplSharpPro.BaseEventArgs args)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "GlsOccupancySensorChange EventId: {0}", args.EventId);
|
Debug.Console(2, this, "GlsOccupancySensorChange EventId: {0}", args.EventId);
|
||||||
|
|
||||||
if (args.EventId == Crestron.SimplSharpPro.GeneralIO.GlsOccupancySensorBase.RoomOccupiedFeedbackEventId
|
switch (args.EventId)
|
||||||
|| args.EventId == Crestron.SimplSharpPro.GeneralIO.GlsOccupancySensorBase.RoomVacantFeedbackEventId)
|
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Occupancy State: {0}", OccSensor.OccupancyDetectedFeedback.BoolValue);
|
case Crestron.SimplSharpPro.GeneralIO.GlsOccupancySensorBase.RoomVacantFeedbackEventId:
|
||||||
RoomIsOccupiedFeedback.FireUpdate();
|
case Crestron.SimplSharpPro.GeneralIO.GlsOccupancySensorBase.RoomOccupiedFeedbackEventId:
|
||||||
|
Debug.Console(1, this, "Occupancy State: {0}", OccSensor.OccupancyDetectedFeedback.BoolValue);
|
||||||
|
RoomIsOccupiedFeedback.FireUpdate();
|
||||||
|
break;
|
||||||
|
case GlsOccupancySensorBase.TimeoutFeedbackEventId:
|
||||||
|
CurrentTimeoutFeedback.FireUpdate();
|
||||||
|
break;
|
||||||
|
case GlsOccupancySensorBase.TimeoutLocalFeedbackEventId:
|
||||||
|
LocalTimoutFeedback.FireUpdate();
|
||||||
|
break;
|
||||||
|
case GlsOccupancySensorBase.GraceOccupancyDetectedFeedbackEventId:
|
||||||
|
GraceOccupancyDetectedFeedback.FireUpdate();
|
||||||
|
break;
|
||||||
|
case GlsOccupancySensorBase.RawOccupancyFeedbackEventId:
|
||||||
|
RawOccupancyFeedback.FireUpdate();
|
||||||
|
break;
|
||||||
|
case GlsOccupancySensorBase.InternalPhotoSensorValueFeedbackEventId:
|
||||||
|
InternalPhotoSensorValue.FireUpdate();
|
||||||
|
break;
|
||||||
|
case GlsOccupancySensorBase.ExternalPhotoSensorValueFeedbackEventId:
|
||||||
|
ExternalPhotoSensorValue.FireUpdate();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else if (args.EventId == GlsOccupancySensorBase.TimeoutFeedbackEventId)
|
|
||||||
CurrentTimeoutFeedback.FireUpdate();
|
|
||||||
else if (args.EventId == GlsOccupancySensorBase.TimeoutLocalFeedbackEventId)
|
|
||||||
LocalTimoutFeedback.FireUpdate();
|
|
||||||
else if (args.EventId == GlsOccupancySensorBase.GraceOccupancyDetectedFeedbackEventId)
|
|
||||||
GraceOccupancyDetectedFeedback.FireUpdate();
|
|
||||||
else if (args.EventId == GlsOccupancySensorBase.RawOccupancyFeedbackEventId)
|
|
||||||
RawOccupancyFeedback.FireUpdate();
|
|
||||||
else if (args.EventId == GlsOccupancySensorBase.InternalPhotoSensorValueFeedbackEventId)
|
|
||||||
InternalPhotoSensorValue.FireUpdate();
|
|
||||||
else if (args.EventId == GlsOccupancySensorBase.ExternalPhotoSensorValueFeedbackEventId)
|
|
||||||
ExternalPhotoSensorValue.FireUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetTestMode(bool mode)
|
public void SetTestMode(bool mode)
|
||||||
@@ -373,27 +410,51 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy
|
|||||||
{
|
{
|
||||||
LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge);
|
LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public class GlsOccupancySensorBaseControllerFactory : EssentialsDeviceFactory<GlsOccupancySensorBaseController>
|
#region PreActivation
|
||||||
{
|
|
||||||
public GlsOccupancySensorBaseControllerFactory()
|
private static GlsOirCCn GetGlsOirCCn(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
TypeNames = new List<string>() { "glsoirccn" };
|
var control = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
|
var cresnetId = control.CresnetIdInt;
|
||||||
|
var branchId = control.ControlPortNumber;
|
||||||
|
var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey;
|
||||||
|
|
||||||
|
if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOirCCn", parentKey);
|
||||||
|
return new GlsOirCCn(cresnetId, Global.ControlSystem);
|
||||||
|
}
|
||||||
|
var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches;
|
||||||
|
|
||||||
|
if (cresnetBridge != null)
|
||||||
|
{
|
||||||
|
Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOirCCn", parentKey);
|
||||||
|
return new GlsOirCCn(cresnetId, cresnetBridge.CresnetBranches[branchId]);
|
||||||
|
}
|
||||||
|
Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public class GlsOccupancySensorBaseControllerFactory : EssentialsDeviceFactory<GlsOccupancySensorBaseController>
|
||||||
{
|
{
|
||||||
Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device");
|
public GlsOccupancySensorBaseControllerFactory()
|
||||||
|
{
|
||||||
|
TypeNames = new List<string>() { "glsoirccn" };
|
||||||
|
}
|
||||||
|
|
||||||
var key = dc.Key;
|
|
||||||
var name = dc.Name;
|
|
||||||
var comm = CommFactory.GetControlPropertiesConfig(dc);
|
|
||||||
|
|
||||||
GlsOccupancySensorBase occSensor = new GlsOirCCn(comm.CresnetIdInt, Global.ControlSystem);
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
|
{
|
||||||
|
Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device");
|
||||||
|
|
||||||
|
return new GlsOccupancySensorBaseController(dc.Key, GetGlsOirCCn, dc);
|
||||||
|
}
|
||||||
|
|
||||||
return new GlsOccupancySensorBaseController(key, name, occSensor);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -11,7 +11,7 @@ using PepperDash.Essentials.Core;
|
|||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Common.Occupancy
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
[Description("Wrapper class for Dual Technology GLS Occupancy Sensors")]
|
[Description("Wrapper class for Dual Technology GLS Occupancy Sensors")]
|
||||||
public class GlsOdtOccupancySensorController : GlsOccupancySensorBaseController
|
public class GlsOdtOccupancySensorController : GlsOccupancySensorBaseController
|
||||||
@@ -35,26 +35,35 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy
|
|||||||
public BoolFeedback RawOccupancyUsFeedback { get; private set; }
|
public BoolFeedback RawOccupancyUsFeedback { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
public GlsOdtOccupancySensorController(string key, string name, GlsOdtCCn sensor)
|
public GlsOdtOccupancySensorController(string key, Func<DeviceConfig, GlsOdtCCn> preActivationFunc,
|
||||||
: base(key, name, sensor)
|
DeviceConfig config)
|
||||||
|
: base(key, config.Name)
|
||||||
{
|
{
|
||||||
OccSensor = sensor;
|
AddPreActivationAction(() =>
|
||||||
|
{
|
||||||
|
OccSensor = preActivationFunc(config);
|
||||||
|
|
||||||
AndWhenVacatedFeedback = new BoolFeedback(() => OccSensor.AndWhenVacatedFeedback.BoolValue);
|
RegisterCrestronGenericBase(OccSensor);
|
||||||
|
|
||||||
OrWhenVacatedFeedback = new BoolFeedback(() => OccSensor.OrWhenVacatedFeedback.BoolValue);
|
RegisterGlsOdtSensorBaseController(OccSensor);
|
||||||
|
|
||||||
UltrasonicAEnabledFeedback = new BoolFeedback(() => OccSensor.UsAEnabledFeedback.BoolValue);
|
AndWhenVacatedFeedback = new BoolFeedback(() => OccSensor.AndWhenVacatedFeedback.BoolValue);
|
||||||
|
|
||||||
UltrasonicBEnabledFeedback = new BoolFeedback(() => OccSensor.UsBEnabledFeedback.BoolValue);
|
OrWhenVacatedFeedback = new BoolFeedback(() => OccSensor.OrWhenVacatedFeedback.BoolValue);
|
||||||
|
|
||||||
RawOccupancyPirFeedback = new BoolFeedback(() => OccSensor.RawOccupancyPirFeedback.BoolValue);
|
UltrasonicAEnabledFeedback = new BoolFeedback(() => OccSensor.UsAEnabledFeedback.BoolValue);
|
||||||
|
|
||||||
RawOccupancyUsFeedback = new BoolFeedback(() => OccSensor.RawOccupancyUsFeedback.BoolValue);
|
UltrasonicBEnabledFeedback = new BoolFeedback(() => OccSensor.UsBEnabledFeedback.BoolValue);
|
||||||
|
|
||||||
UltrasonicSensitivityInVacantStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInVacantStateFeedback.UShortValue);
|
RawOccupancyPirFeedback = new BoolFeedback(() => OccSensor.RawOccupancyPirFeedback.BoolValue);
|
||||||
|
|
||||||
UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInOccupiedStateFeedback.UShortValue);
|
RawOccupancyUsFeedback = new BoolFeedback(() => OccSensor.RawOccupancyUsFeedback.BoolValue);
|
||||||
|
|
||||||
|
UltrasonicSensitivityInVacantStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInVacantStateFeedback.UShortValue);
|
||||||
|
|
||||||
|
UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInOccupiedStateFeedback.UShortValue);
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -160,38 +169,51 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy
|
|||||||
{
|
{
|
||||||
LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge);
|
LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public class GlsOdtOccupancySensorControllerFactory : EssentialsDeviceFactory<GlsOdtOccupancySensorController>
|
#region PreActivation
|
||||||
{
|
|
||||||
public GlsOdtOccupancySensorControllerFactory()
|
private static GlsOdtCCn GetGlsOdtCCn(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
TypeNames = new List<string>() { "glsodtccn" };
|
var control = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
}
|
var cresnetId = control.CresnetIdInt;
|
||||||
|
var branchId = control.ControlPortNumber;
|
||||||
|
var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey;
|
||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase))
|
||||||
{
|
|
||||||
Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device");
|
|
||||||
|
|
||||||
var typeName = dc.Type.ToLower();
|
|
||||||
var key = dc.Key;
|
|
||||||
var name = dc.Name;
|
|
||||||
var comm = CommFactory.GetControlPropertiesConfig(dc);
|
|
||||||
|
|
||||||
var occSensor = new GlsOdtCCn(comm.CresnetIdInt, Global.ControlSystem);
|
|
||||||
|
|
||||||
if (occSensor != null)
|
|
||||||
{
|
{
|
||||||
return new GlsOdtOccupancySensorController(key, name, occSensor);
|
Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOdtCCn", parentKey);
|
||||||
|
return new GlsOdtCCn(cresnetId, Global.ControlSystem);
|
||||||
}
|
}
|
||||||
else
|
var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches;
|
||||||
|
|
||||||
|
if (cresnetBridge != null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "ERROR: Unable to create Occupancy Sensor Device. Key: '{0}'", key);
|
Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOdtCCn", parentKey);
|
||||||
return null;
|
return new GlsOdtCCn(cresnetId, cresnetBridge.CresnetBranches[branchId]);
|
||||||
|
}
|
||||||
|
Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public class GlsOdtOccupancySensorControllerFactory : EssentialsDeviceFactory<GlsOdtOccupancySensorController>
|
||||||
|
{
|
||||||
|
public GlsOdtOccupancySensorControllerFactory()
|
||||||
|
{
|
||||||
|
TypeNames = new List<string>() { "glsodtccn" };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
|
{
|
||||||
|
Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device");
|
||||||
|
|
||||||
|
return new GlsOdtOccupancySensorController(dc.Key, GetGlsOdtCCn, dc);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,9 +5,9 @@ using System.Text;
|
|||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Common.Occupancy
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Aggregates the RoomIsOccupied feedbacks of one or more IOccupancyStatusProvider objects
|
/// Aggregates the RoomIsOccupied feedbacks of one or more IOccupancyStatusProvider objects
|
||||||
@@ -0,0 +1,280 @@
|
|||||||
|
using Crestron.SimplSharpPro;
|
||||||
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
using Crestron.SimplSharpPro.GeneralIO;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using PepperDash.Core;
|
||||||
|
using PepperDash.Essentials.Core;
|
||||||
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
|
using PepperDash_Essentials_Core.Bridges.JoinMaps;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
using Crestron.SimplSharpPro;
|
||||||
|
using Crestron.SimplSharpPro.Gateways;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
|
||||||
|
|
||||||
|
using PepperDash.Core;
|
||||||
|
using PepperDash.Essentials.Core;
|
||||||
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
using PepperDash_Essentials_Core;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core
|
||||||
|
{
|
||||||
|
[Description("Wrapper class for GLS Cresnet Partition Sensor")]
|
||||||
|
public class GlsPartitionSensorController : CrestronGenericBridgeableBaseDevice
|
||||||
|
{
|
||||||
|
private GlsPartCn _partitionSensor;
|
||||||
|
|
||||||
|
public StringFeedback NameFeedback { get; private set; }
|
||||||
|
public BoolFeedback EnableFeedback { get; private set; }
|
||||||
|
public BoolFeedback PartitionSensedFeedback { get; private set; }
|
||||||
|
public BoolFeedback PartitionNotSensedFeedback { get; private set; }
|
||||||
|
public IntFeedback SensitivityFeedback { get; private set; }
|
||||||
|
|
||||||
|
public bool InTestMode { get; private set; }
|
||||||
|
public bool TestEnableFeedback { get; private set; }
|
||||||
|
public bool TestPartitionSensedFeedback { get; private set; }
|
||||||
|
public int TestSensitivityFeedback { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
|
public GlsPartitionSensorController(string key, Func<DeviceConfig, GlsPartCn> preActivationFunc, DeviceConfig config)
|
||||||
|
: base(key, config.Name)
|
||||||
|
{
|
||||||
|
AddPreActivationAction(() =>
|
||||||
|
{
|
||||||
|
_partitionSensor = preActivationFunc(config);
|
||||||
|
|
||||||
|
RegisterCrestronGenericBase(_partitionSensor);
|
||||||
|
|
||||||
|
NameFeedback = new StringFeedback(() => Name);
|
||||||
|
EnableFeedback = new BoolFeedback(() => _partitionSensor.EnableFeedback.BoolValue);
|
||||||
|
PartitionSensedFeedback = new BoolFeedback(() => _partitionSensor.PartitionSensedFeedback.BoolValue);
|
||||||
|
PartitionNotSensedFeedback = new BoolFeedback(() => _partitionSensor.PartitionNotSensedFeedback.BoolValue);
|
||||||
|
SensitivityFeedback = new IntFeedback(() => _partitionSensor.SensitivityFeedback.UShortValue);
|
||||||
|
|
||||||
|
if (_partitionSensor != null) _partitionSensor.BaseEvent += PartitionSensor_BaseEvent;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PartitionSensor_BaseEvent(GenericBase device, BaseEventArgs args)
|
||||||
|
{
|
||||||
|
Debug.Console(2, this, "EventId: {0}, Index: {1}", args.EventId, args.Index);
|
||||||
|
|
||||||
|
switch (args.EventId)
|
||||||
|
{
|
||||||
|
case (GlsPartCn.EnableFeedbackEventId):
|
||||||
|
{
|
||||||
|
EnableFeedback.FireUpdate();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (GlsPartCn.PartitionSensedFeedbackEventId):
|
||||||
|
{
|
||||||
|
PartitionSensedFeedback.FireUpdate();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (GlsPartCn.PartitionNotSensedFeedbackEventId):
|
||||||
|
{
|
||||||
|
PartitionNotSensedFeedback.FireUpdate();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case (GlsPartCn.SensitivityFeedbackEventId):
|
||||||
|
{
|
||||||
|
SensitivityFeedback.FireUpdate();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
Debug.Console(2, this, "Unhandled args.EventId: {0}", args.EventId);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetTestMode(bool mode)
|
||||||
|
{
|
||||||
|
InTestMode = mode;
|
||||||
|
Debug.Console(1, this, "InTestMode: {0}", InTestMode.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetTestEnableState(bool state)
|
||||||
|
{
|
||||||
|
if (InTestMode)
|
||||||
|
{
|
||||||
|
TestEnableFeedback = state;
|
||||||
|
Debug.Console(1, this, "TestEnableFeedback: {0}", TestEnableFeedback.ToString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Console(1, this, "InTestMode: {0}, unable to set enable state: {1}", InTestMode.ToString(), state.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetTestPartitionSensedState(bool state)
|
||||||
|
{
|
||||||
|
if (InTestMode)
|
||||||
|
{
|
||||||
|
TestPartitionSensedFeedback = state;
|
||||||
|
Debug.Console(1, this, "TestPartitionSensedFeedback: {0}", TestPartitionSensedFeedback.ToString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Console(1, this, "InTestMode: {0}, unable to set partition state: {1}", InTestMode.ToString(), state.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetTestSensitivityValue(int value)
|
||||||
|
{
|
||||||
|
if (InTestMode)
|
||||||
|
{
|
||||||
|
TestSensitivityFeedback = value;
|
||||||
|
Debug.Console(1, this, "TestSensitivityFeedback: {0}", TestSensitivityFeedback);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Console(1, this, "InTestMode: {0}, unable to set sensitivity value: {1}", InTestMode.ToString(), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetEnableState(bool state)
|
||||||
|
{
|
||||||
|
if (_partitionSensor == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_partitionSensor.Enable.BoolValue = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void IncreaseSensitivity()
|
||||||
|
{
|
||||||
|
if (_partitionSensor == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_partitionSensor.IncreaseSensitivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DecreaseSensitivity()
|
||||||
|
{
|
||||||
|
if (_partitionSensor == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_partitionSensor.DecreaseSensitivity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetSensitivity(ushort value)
|
||||||
|
{
|
||||||
|
if (_partitionSensor == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_partitionSensor.Sensitivity.UShortValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
|
||||||
|
{
|
||||||
|
var joinMap = new GlsPartitionSensorJoinMap(joinStart);
|
||||||
|
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(joinMapSerialized))
|
||||||
|
joinMap = JsonConvert.DeserializeObject<GlsPartitionSensorJoinMap>(joinMapSerialized);
|
||||||
|
|
||||||
|
if (bridge != null)
|
||||||
|
{
|
||||||
|
bridge.AddJoinMap(Key, joinMap);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Console(0, this, "Please update config to use 'type': 'EiscApiAdvanced' to get all join map features for this device");
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||||
|
Debug.Console(0, this, "Linking to Bridge Type {0}", GetType().Name);
|
||||||
|
|
||||||
|
// link input from simpl
|
||||||
|
trilist.SetSigTrueAction(joinMap.Enable.JoinNumber, () => SetEnableState(true));
|
||||||
|
trilist.SetSigFalseAction(joinMap.Enable.JoinNumber, () => SetEnableState(false));
|
||||||
|
trilist.SetSigTrueAction(joinMap.IncreaseSensitivity.JoinNumber, IncreaseSensitivity);
|
||||||
|
trilist.SetSigTrueAction(joinMap.DecreaseSensitivity.JoinNumber, DecreaseSensitivity);
|
||||||
|
trilist.SetUShortSigAction(joinMap.Sensitivity.JoinNumber, SetSensitivity);
|
||||||
|
|
||||||
|
// link output to simpl
|
||||||
|
IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);
|
||||||
|
EnableFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Enable.JoinNumber]);
|
||||||
|
PartitionSensedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PartitionSensed.JoinNumber]);
|
||||||
|
PartitionNotSensedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PartitionNotSensed.JoinNumber]);
|
||||||
|
SensitivityFeedback.LinkInputSig(trilist.UShortInput[joinMap.Sensitivity.JoinNumber]);
|
||||||
|
|
||||||
|
FeedbacksFireUpdates();
|
||||||
|
|
||||||
|
// update when device is online
|
||||||
|
_partitionSensor.OnlineStatusChange += (o, a) =>
|
||||||
|
{
|
||||||
|
if (a.DeviceOnLine)
|
||||||
|
{
|
||||||
|
FeedbacksFireUpdates();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// update when trilist is online
|
||||||
|
trilist.OnlineStatusChange += (o, a) =>
|
||||||
|
{
|
||||||
|
if (a.DeviceOnLine)
|
||||||
|
{
|
||||||
|
FeedbacksFireUpdates();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FeedbacksFireUpdates()
|
||||||
|
{
|
||||||
|
IsOnline.FireUpdate();
|
||||||
|
NameFeedback.FireUpdate();
|
||||||
|
EnableFeedback.FireUpdate();
|
||||||
|
PartitionSensedFeedback.FireUpdate();
|
||||||
|
PartitionNotSensedFeedback.FireUpdate();
|
||||||
|
SensitivityFeedback.FireUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region PreActivation
|
||||||
|
|
||||||
|
private static GlsPartCn GetGlsPartCnDevice(DeviceConfig dc)
|
||||||
|
{
|
||||||
|
var control = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
|
var cresnetId = control.CresnetIdInt;
|
||||||
|
var branchId = control.ControlPortNumber;
|
||||||
|
var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey;
|
||||||
|
|
||||||
|
if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase))
|
||||||
|
{
|
||||||
|
Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsPartCn", parentKey);
|
||||||
|
return new GlsPartCn(cresnetId, Global.ControlSystem);
|
||||||
|
}
|
||||||
|
var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches;
|
||||||
|
|
||||||
|
if (cresnetBridge != null)
|
||||||
|
{
|
||||||
|
Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsPartCn", parentKey);
|
||||||
|
return new GlsPartCn(cresnetId, cresnetBridge.CresnetBranches[branchId]);
|
||||||
|
}
|
||||||
|
Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
public class GlsPartitionSensorControllerFactory : EssentialsDeviceFactory<GlsPartitionSensorController>
|
||||||
|
{
|
||||||
|
public GlsPartitionSensorControllerFactory()
|
||||||
|
{
|
||||||
|
TypeNames = new List<string>() { "glspartcn" };
|
||||||
|
}
|
||||||
|
|
||||||
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
|
{
|
||||||
|
Debug.Console(1, "Factory Attempting to create new C2N-RTHS Device");
|
||||||
|
|
||||||
|
return new GlsPartitionSensorController(dc.Key, GetGlsPartCnDevice, dc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -137,6 +137,7 @@
|
|||||||
<Compile Include="Bridges\JoinMaps\GenericLightingJoinMap.cs" />
|
<Compile Include="Bridges\JoinMaps\GenericLightingJoinMap.cs" />
|
||||||
<Compile Include="Bridges\JoinMaps\GenericRelayControllerJoinMap.cs" />
|
<Compile Include="Bridges\JoinMaps\GenericRelayControllerJoinMap.cs" />
|
||||||
<Compile Include="Bridges\JoinMaps\GlsOccupancySensorBaseJoinMap.cs" />
|
<Compile Include="Bridges\JoinMaps\GlsOccupancySensorBaseJoinMap.cs" />
|
||||||
|
<Compile Include="Bridges\JoinMaps\GlsPartitionSensorJoinMap.cs" />
|
||||||
<Compile Include="Bridges\JoinMaps\HdMdNxM4kEControllerJoinMap.cs" />
|
<Compile Include="Bridges\JoinMaps\HdMdNxM4kEControllerJoinMap.cs" />
|
||||||
<Compile Include="Bridges\JoinMaps\HdMdxxxCEControllerJoinMap.cs" />
|
<Compile Include="Bridges\JoinMaps\HdMdxxxCEControllerJoinMap.cs" />
|
||||||
<Compile Include="Bridges\JoinMaps\Hrxxx0WirelessRemoteControllerJoinMap.cs" />
|
<Compile Include="Bridges\JoinMaps\Hrxxx0WirelessRemoteControllerJoinMap.cs" />
|
||||||
@@ -171,6 +172,8 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Crestron IO\Cards\CenCi33Controller.cs" />
|
<Compile Include="Crestron IO\Cards\CenCi33Controller.cs" />
|
||||||
<Compile Include="Crestron IO\Cards\InternalCardCageController.cs" />
|
<Compile Include="Crestron IO\Cards\InternalCardCageController.cs" />
|
||||||
|
<Compile Include="Crestron IO\DinCenCn\DinCenCnController.cs" />
|
||||||
|
<Compile Include="Crestron IO\DinCenCn\IHasCresnetBranches.cs" />
|
||||||
<Compile Include="Crestron IO\Inputs\CenIoDigIn104Controller.cs" />
|
<Compile Include="Crestron IO\Inputs\CenIoDigIn104Controller.cs" />
|
||||||
<Compile Include="Crestron IO\Inputs\GenericDigitalInputDevice.cs" />
|
<Compile Include="Crestron IO\Inputs\GenericDigitalInputDevice.cs" />
|
||||||
<Compile Include="Crestron IO\Inputs\GenericVersiportInputDevice.cs" />
|
<Compile Include="Crestron IO\Inputs\GenericVersiportInputDevice.cs" />
|
||||||
@@ -192,6 +195,7 @@
|
|||||||
<Compile Include="Devices\VolumeDeviceChangeEventArgs.cs" />
|
<Compile Include="Devices\VolumeDeviceChangeEventArgs.cs" />
|
||||||
<Compile Include="Factory\DeviceFactory.cs" />
|
<Compile Include="Factory\DeviceFactory.cs" />
|
||||||
<Compile Include="Factory\IDeviceFactory.cs" />
|
<Compile Include="Factory\IDeviceFactory.cs" />
|
||||||
|
<Compile Include="Factory\ReadyEventArgs.cs" />
|
||||||
<Compile Include="Feedbacks\BoolFeedback.cs" />
|
<Compile Include="Feedbacks\BoolFeedback.cs" />
|
||||||
<Compile Include="Feedbacks\FeedbackCollection.cs" />
|
<Compile Include="Feedbacks\FeedbackCollection.cs" />
|
||||||
<Compile Include="Feedbacks\FeedbackEventArgs.cs" />
|
<Compile Include="Feedbacks\FeedbackEventArgs.cs" />
|
||||||
@@ -213,6 +217,11 @@
|
|||||||
<Compile Include="Monitoring\SystemMonitorController.cs" />
|
<Compile Include="Monitoring\SystemMonitorController.cs" />
|
||||||
<Compile Include="Microphone Privacy\MicrophonePrivacyController.cs" />
|
<Compile Include="Microphone Privacy\MicrophonePrivacyController.cs" />
|
||||||
<Compile Include="Microphone Privacy\MicrophonePrivacyControllerConfig.cs" />
|
<Compile Include="Microphone Privacy\MicrophonePrivacyControllerConfig.cs" />
|
||||||
|
<Compile Include="Occupancy\CenOdtOccupancySensorBaseController.cs" />
|
||||||
|
<Compile Include="Occupancy\GlsOccupancySensorBaseController.cs" />
|
||||||
|
<Compile Include="Occupancy\GlsOdtOccupancySensorController.cs" />
|
||||||
|
<Compile Include="Occupancy\IOccupancyStatusProviderAggregator.cs" />
|
||||||
|
<Compile Include="PartitionSensor\GlsPartitionSensorController.cs" />
|
||||||
<Compile Include="Plugins\PluginLoader.cs" />
|
<Compile Include="Plugins\PluginLoader.cs" />
|
||||||
<Compile Include="Presets\PresetBase.cs" />
|
<Compile Include="Presets\PresetBase.cs" />
|
||||||
<Compile Include="Plugins\IPluginDeviceFactory.cs" />
|
<Compile Include="Plugins\IPluginDeviceFactory.cs" />
|
||||||
|
|||||||
@@ -21,30 +21,70 @@ namespace PepperDash.Essentials.Core
|
|||||||
[Description("Wrapper class for all HR-Series remotes")]
|
[Description("Wrapper class for all HR-Series remotes")]
|
||||||
public class Hrxx0WirelessRemoteController : EssentialsBridgeableDevice, IHasFeedback
|
public class Hrxx0WirelessRemoteController : EssentialsBridgeableDevice, IHasFeedback
|
||||||
{
|
{
|
||||||
|
private CenRfgwController _gateway;
|
||||||
|
|
||||||
private Hr1x0WirelessRemoteBase _remote;
|
private Hr1x0WirelessRemoteBase _remote;
|
||||||
|
|
||||||
public FeedbackCollection<Feedback> Feedbacks { get; set; }
|
public FeedbackCollection<Feedback> Feedbacks { get; set; }
|
||||||
|
|
||||||
public CrestronCollection<Button> Buttons { get { return _remote.Button; } }
|
public CrestronCollection<Button> Buttons { get { return _remote.Button; } }
|
||||||
|
|
||||||
|
private DeviceConfig _config;
|
||||||
|
|
||||||
public Hrxx0WirelessRemoteController(string key, Func<DeviceConfig, Hr1x0WirelessRemoteBase> preActivationFunc,
|
public Hrxx0WirelessRemoteController(string key, Func<DeviceConfig, Hr1x0WirelessRemoteBase> preActivationFunc,
|
||||||
DeviceConfig config)
|
DeviceConfig config)
|
||||||
: base(key, config.Name)
|
: base(key, config.Name)
|
||||||
{
|
{
|
||||||
Feedbacks = new FeedbackCollection<Feedback>();
|
Feedbacks = new FeedbackCollection<Feedback>();
|
||||||
|
|
||||||
AddPreActivationAction(() =>
|
var props = JsonConvert.DeserializeObject<CrestronRemotePropertiesConfig>(config.Properties.ToString());
|
||||||
|
|
||||||
|
var type = config.Type;
|
||||||
|
var rfId = (uint)props.Control.InfinetIdInt;
|
||||||
|
_config = config;
|
||||||
|
|
||||||
|
GatewayBase gateway;
|
||||||
|
|
||||||
|
if (props.GatewayDeviceKey == "processor")
|
||||||
{
|
{
|
||||||
_remote = preActivationFunc(config);
|
gateway = Global.ControlSystem.ControllerRFGatewayDevice;
|
||||||
|
}
|
||||||
|
|
||||||
_remote.ButtonStateChange += new ButtonEventHandler(_remote_ButtonStateChange);
|
else
|
||||||
|
{
|
||||||
|
var gatewayDev = DeviceManager.GetDeviceForKey(props.GatewayDeviceKey) as CenRfgwController;
|
||||||
|
if (gatewayDev == null)
|
||||||
|
{
|
||||||
|
Debug.Console(0, "GetHr1x0WirelessRemote: Device '{0}' is not a valid device", props.GatewayDeviceKey);
|
||||||
|
}
|
||||||
|
if (gatewayDev != null)
|
||||||
|
{
|
||||||
|
Debug.Console(0, "GetHr1x0WirelessRemote: Device '{0}' is a valid device", props.GatewayDeviceKey);
|
||||||
|
gateway = gatewayDev.GateWay;
|
||||||
|
_gateway = gatewayDev;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Feedbacks.Add(new BoolFeedback("BatteryCritical", () => _remote.BatteryCriticalFeedback.BoolValue));
|
if (_gateway == null) return;
|
||||||
Feedbacks.Add(new BoolFeedback("BatteryLow", () => _remote.BatteryLowFeedback.BoolValue));
|
|
||||||
Feedbacks.Add(new IntFeedback("BatteryVoltage", () => _remote.BatteryVoltageFeedback.UShortValue));
|
|
||||||
|
|
||||||
_remote.BaseEvent += new BaseEventHandler(_remote_BaseEvent);
|
_gateway.IsReadyEvent += _gateway_IsReadyEvent;
|
||||||
});
|
if (_gateway.IsReady)
|
||||||
|
{
|
||||||
|
AddPreActivationAction(() =>
|
||||||
|
{
|
||||||
|
_remote = preActivationFunc(config);
|
||||||
|
|
||||||
|
RegisterEvents();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _gateway_IsReadyEvent(object sender, PepperDash_Essentials_Core.IsReadyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.IsReady != true) return;
|
||||||
|
_remote = GetHr1x0WirelessRemote(_config);
|
||||||
|
|
||||||
|
RegisterEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _remote_BaseEvent(GenericBase device, BaseEventArgs args)
|
void _remote_BaseEvent(GenericBase device, BaseEventArgs args)
|
||||||
@@ -57,6 +97,17 @@ namespace PepperDash.Essentials.Core
|
|||||||
Feedbacks["BatteryVoltage"].FireUpdate();
|
Feedbacks["BatteryVoltage"].FireUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void RegisterEvents()
|
||||||
|
{
|
||||||
|
_remote.ButtonStateChange += _remote_ButtonStateChange;
|
||||||
|
|
||||||
|
Feedbacks.Add(new BoolFeedback("BatteryCritical", () => _remote.BatteryCriticalFeedback.BoolValue));
|
||||||
|
Feedbacks.Add(new BoolFeedback("BatteryLow", () => _remote.BatteryLowFeedback.BoolValue));
|
||||||
|
Feedbacks.Add(new IntFeedback("BatteryVoltage", () => _remote.BatteryVoltageFeedback.UShortValue));
|
||||||
|
|
||||||
|
_remote.BaseEvent += _remote_BaseEvent;
|
||||||
|
}
|
||||||
|
|
||||||
void _remote_ButtonStateChange(GenericBase device, ButtonEventArgs args)
|
void _remote_ButtonStateChange(GenericBase device, ButtonEventArgs args)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -112,22 +163,29 @@ namespace PepperDash.Essentials.Core
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Hr1x0WirelessRemoteBase remoteBase;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case ("hr100"):
|
case ("hr100"):
|
||||||
return new Hr100(rfId, gateway);
|
remoteBase = new Hr100(rfId, gateway);
|
||||||
|
break;
|
||||||
case ("hr150"):
|
case ("hr150"):
|
||||||
return new Hr150(rfId, gateway);
|
remoteBase = new Hr150(rfId, gateway);
|
||||||
|
break;
|
||||||
case ("hr310"):
|
case ("hr310"):
|
||||||
return new Hr310(rfId, gateway);
|
remoteBase = new Hr310(rfId, gateway);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void gateway_BaseEvent(GenericBase device, BaseEventArgs args)
|
// register the device when using an internal RF gateway
|
||||||
{
|
if (props.GatewayDeviceKey == "processor")
|
||||||
throw new NotImplementedException();
|
{
|
||||||
|
remoteBase.RegisterWithLogging(config.Key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return remoteBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -249,4 +307,4 @@ namespace PepperDash.Essentials.Core
|
|||||||
trilist.BooleanInput[join].BoolValue = b;
|
trilist.BooleanInput[join].BoolValue = b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -4,14 +4,16 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharpPro.DM;
|
using Crestron.SimplSharpPro.DM;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.DM.Config;
|
using PepperDash.Essentials.DM.Config;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.DM.Chassis
|
namespace PepperDash.Essentials.DM.Chassis
|
||||||
{
|
{
|
||||||
public class HdMdNxM4kEController : Device, IRoutingInputsOutputs, IRouting
|
public class HdMdNxM4kEController : CrestronGenericBaseDevice, IRoutingInputsOutputs, IRouting
|
||||||
{
|
{
|
||||||
public HdMdNxM Chassis { get; private set; }
|
public HdMdNxM Chassis { get; private set; }
|
||||||
|
|
||||||
@@ -27,7 +29,7 @@ namespace PepperDash.Essentials.DM.Chassis
|
|||||||
/// <param name="chassis"></param>
|
/// <param name="chassis"></param>
|
||||||
public HdMdNxM4kEController(string key, string name, HdMdNxM chassis,
|
public HdMdNxM4kEController(string key, string name, HdMdNxM chassis,
|
||||||
HdMdNxM4kEPropertiesConfig props)
|
HdMdNxM4kEPropertiesConfig props)
|
||||||
: base(key, name)
|
: base(key, name, chassis)
|
||||||
{
|
{
|
||||||
Chassis = chassis;
|
Chassis = chassis;
|
||||||
|
|
||||||
@@ -99,6 +101,8 @@ namespace PepperDash.Essentials.DM.Chassis
|
|||||||
/// <param name="type"></param>
|
/// <param name="type"></param>
|
||||||
/// <param name="properties"></param>
|
/// <param name="properties"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
|
/// /*
|
||||||
|
/*
|
||||||
public static HdMdNxM4kEController GetController(string key, string name,
|
public static HdMdNxM4kEController GetController(string key, string name,
|
||||||
string type, HdMdNxM4kEPropertiesConfig properties)
|
string type, HdMdNxM4kEPropertiesConfig properties)
|
||||||
{
|
{
|
||||||
@@ -123,6 +127,35 @@ namespace PepperDash.Essentials.DM.Chassis
|
|||||||
Debug.Console(0, "ERROR Creating device key {0}: \r{1}", key, e);
|
Debug.Console(0, "ERROR Creating device key {0}: \r{1}", key, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
#region Factory
|
||||||
|
|
||||||
|
public class HdMdNxM4kEFactory : EssentialsDeviceFactory<HdMdNxM4kEController>
|
||||||
|
{
|
||||||
|
public HdMdNxM4kEFactory()
|
||||||
|
{
|
||||||
|
TypeNames = new List<string>() {"hdmd4x14ke"};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
|
{
|
||||||
|
Debug.Console(1, "Factory Attempting to create new HD-MD-NxM-4K-E Device");
|
||||||
|
|
||||||
|
var props = JsonConvert.DeserializeObject<HdMdNxM4kEPropertiesConfig>(dc.Properties.ToString());
|
||||||
|
|
||||||
|
var type = dc.Type.ToLower();
|
||||||
|
var control = props.Control;
|
||||||
|
var ipid = control.IpIdInt;
|
||||||
|
var address = control.TcpSshProperties.Address;
|
||||||
|
|
||||||
|
return new HdMdNxM4kEController(dc.Key, dc.Name, new HdMd4x14kE(ipid, address, Global.ControlSystem), props);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,8 +114,6 @@
|
|||||||
<Compile Include="Codec\iCodecAudio.cs" />
|
<Compile Include="Codec\iCodecAudio.cs" />
|
||||||
<Compile Include="ImageProcessors\TVOneCorio.cs" />
|
<Compile Include="ImageProcessors\TVOneCorio.cs" />
|
||||||
<Compile Include="ImageProcessors\TVOneCorioPropertiesConfig.cs" />
|
<Compile Include="ImageProcessors\TVOneCorioPropertiesConfig.cs" />
|
||||||
<Compile Include="Occupancy\CenOdtOccupancySensorBaseController.cs" />
|
|
||||||
<Compile Include="Occupancy\GlsOdtOccupancySensorController.cs" />
|
|
||||||
<Compile Include="Power Controllers\Digitallogger.cs" />
|
<Compile Include="Power Controllers\Digitallogger.cs" />
|
||||||
<Compile Include="Power Controllers\DigitalLoggerPropertiesConfig.cs" />
|
<Compile Include="Power Controllers\DigitalLoggerPropertiesConfig.cs" />
|
||||||
<Compile Include="ImageProcessors\AnalogWay\AnalongWayLiveCore.cs" />
|
<Compile Include="ImageProcessors\AnalogWay\AnalongWayLiveCore.cs" />
|
||||||
@@ -150,8 +148,6 @@
|
|||||||
<Compile Include="Environment\Somfy\RelayControlledShade.cs" />
|
<Compile Include="Environment\Somfy\RelayControlledShade.cs" />
|
||||||
<Compile Include="Factory\DeviceFactory.cs" />
|
<Compile Include="Factory\DeviceFactory.cs" />
|
||||||
<Compile Include="Generic\GenericSource.cs" />
|
<Compile Include="Generic\GenericSource.cs" />
|
||||||
<Compile Include="Occupancy\GlsOccupancySensorBaseController.cs" />
|
|
||||||
<Compile Include="Occupancy\IOccupancyStatusProviderAggregator.cs" />
|
|
||||||
<Compile Include="SetTopBox\SetTopBoxPropertiesConfig.cs" />
|
<Compile Include="SetTopBox\SetTopBoxPropertiesConfig.cs" />
|
||||||
<Compile Include="Streaming\AppleTV.cs" />
|
<Compile Include="Streaming\AppleTV.cs" />
|
||||||
<Compile Include="Audio\GenericAudioOut.cs" />
|
<Compile Include="Audio\GenericAudioOut.cs" />
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ using PepperDash.Essentials.Core.CrestronIO;
|
|||||||
using PepperDash.Essentials.Devices.Common;
|
using PepperDash.Essentials.Devices.Common;
|
||||||
using PepperDash.Essentials.Devices.Common.DSP;
|
using PepperDash.Essentials.Devices.Common.DSP;
|
||||||
using PepperDash.Essentials.Devices.Common.VideoCodec;
|
using PepperDash.Essentials.Devices.Common.VideoCodec;
|
||||||
using PepperDash.Essentials.Devices.Common.Occupancy;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Devices.Common.Environment;
|
using PepperDash.Essentials.Devices.Common.Environment;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Common
|
namespace PepperDash.Essentials.Devices.Common
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ using PepperDash.Essentials.Core.Config;
|
|||||||
using PepperDash.Essentials.Core.Routing;
|
using PepperDash.Essentials.Core.Routing;
|
||||||
using PepperDash.Essentials.Devices.Common.Cameras;
|
using PepperDash.Essentials.Devices.Common.Cameras;
|
||||||
using PepperDash.Essentials.Devices.Common.Codec;
|
using PepperDash.Essentials.Devices.Common.Codec;
|
||||||
using PepperDash.Essentials.Devices.Common.Occupancy;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Devices.Common.VideoCodec;
|
using PepperDash.Essentials.Devices.Common.VideoCodec;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
||||||
@@ -601,9 +601,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
|||||||
//JsonSerializerSettings settings = new JsonSerializerSettings();
|
//JsonSerializerSettings settings = new JsonSerializerSettings();
|
||||||
//settings.NullValueHandling = NullValueHandling.Ignore;
|
//settings.NullValueHandling = NullValueHandling.Ignore;
|
||||||
//settings.MissingMemberHandling = MissingMemberHandling.Ignore;
|
//settings.MissingMemberHandling = MissingMemberHandling.Ignore;
|
||||||
//settings.ObjectCreationHandling = ObjectCreationHandling.Auto;
|
//settings.ObjectCreationHandling = ObjectCreationHandling.Auto;
|
||||||
|
|
||||||
if (response.IndexOf("\"Status\":{") > -1)
|
if (response.IndexOf("\"Status\":{") > -1 || response.IndexOf("\"Status\": {") > -1)
|
||||||
{
|
{
|
||||||
// Status Message
|
// Status Message
|
||||||
|
|
||||||
@@ -775,8 +775,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
|||||||
if (!SyncState.InitialConfigurationMessageWasReceived)
|
if (!SyncState.InitialConfigurationMessageWasReceived)
|
||||||
SendText("xConfiguration");
|
SendText("xConfiguration");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (response.IndexOf("\"Configuration\":{") > -1)
|
else if (response.IndexOf("\"Configuration\":{") > -1 || response.IndexOf("\"Configuration\": {") > -1)
|
||||||
{
|
{
|
||||||
// Configuration Message
|
// Configuration Message
|
||||||
|
|
||||||
@@ -791,39 +791,39 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (response.IndexOf("\"Event\":{") > -1)
|
else if (response.IndexOf("\"Event\":{") > -1 || response.IndexOf("\"Event\": {") > -1)
|
||||||
{
|
{
|
||||||
if (response.IndexOf("\"CallDisconnect\":{") > -1)
|
if (response.IndexOf("\"CallDisconnect\":{") > -1 || response.IndexOf("\"CallDisconnect\": {") > -1)
|
||||||
{
|
{
|
||||||
CiscoCodecEvents.RootObject eventReceived = new CiscoCodecEvents.RootObject();
|
CiscoCodecEvents.RootObject eventReceived = new CiscoCodecEvents.RootObject();
|
||||||
|
|
||||||
JsonConvert.PopulateObject(response, eventReceived);
|
JsonConvert.PopulateObject(response, eventReceived);
|
||||||
|
|
||||||
EvalutateDisconnectEvent(eventReceived);
|
EvalutateDisconnectEvent(eventReceived);
|
||||||
}
|
}
|
||||||
else if (response.IndexOf("\"Bookings\":{") > -1) // The list has changed, reload it
|
else if (response.IndexOf("\"Bookings\":{") > -1 || response.IndexOf("\"Bookings\": {") > -1) // The list has changed, reload it
|
||||||
{
|
{
|
||||||
GetBookings(null);
|
GetBookings(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (response.IndexOf("\"CommandResponse\":{") > -1)
|
else if (response.IndexOf("\"CommandResponse\":{") > -1 || response.IndexOf("\"CommandResponse\": {") > -1)
|
||||||
{
|
{
|
||||||
// CommandResponse Message
|
// CommandResponse Message
|
||||||
|
|
||||||
if (response.IndexOf("\"CallHistoryRecentsResult\":{") > -1)
|
if (response.IndexOf("\"CallHistoryRecentsResult\":{") > -1 || response.IndexOf("\"CallHistoryRecentsResult\": {") > -1)
|
||||||
{
|
{
|
||||||
var codecCallHistory = new CiscoCallHistory.RootObject();
|
var codecCallHistory = new CiscoCallHistory.RootObject();
|
||||||
|
|
||||||
JsonConvert.PopulateObject(response, codecCallHistory);
|
JsonConvert.PopulateObject(response, codecCallHistory);
|
||||||
|
|
||||||
CallHistory.ConvertCiscoCallHistoryToGeneric(codecCallHistory.CommandResponse.CallHistoryRecentsResult.Entry);
|
CallHistory.ConvertCiscoCallHistoryToGeneric(codecCallHistory.CommandResponse.CallHistoryRecentsResult.Entry);
|
||||||
}
|
}
|
||||||
else if (response.IndexOf("\"CallHistoryDeleteEntryResult\":{") > -1)
|
else if (response.IndexOf("\"CallHistoryDeleteEntryResult\":{") > -1 || response.IndexOf("\"CallHistoryDeleteEntryResult\": {") > -1)
|
||||||
{
|
{
|
||||||
GetCallHistory();
|
GetCallHistory();
|
||||||
}
|
}
|
||||||
else if (response.IndexOf("\"PhonebookSearchResult\":{") > -1)
|
else if (response.IndexOf("\"PhonebookSearchResult\":{") > -1 || response.IndexOf("\"PhonebookSearchResult\": {") > -1)
|
||||||
{
|
{
|
||||||
var codecPhonebookResponse = new CiscoCodecPhonebook.RootObject();
|
var codecPhonebookResponse = new CiscoCodecPhonebook.RootObject();
|
||||||
|
|
||||||
@@ -1658,7 +1658,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (CodecStatus.Status.SIP.Registration.Count > 0)
|
if (CodecStatus.Status.SIP != null && CodecStatus.Status.SIP.Registration.Count > 0)
|
||||||
{
|
{
|
||||||
var match = Regex.Match(CodecStatus.Status.SIP.Registration[0].URI.Value, @"(\d+)"); // extract numbers only
|
var match = Regex.Match(CodecStatus.Status.SIP.Registration[0].URI.Value, @"(\d+)"); // extract numbers only
|
||||||
if (match.Success)
|
if (match.Success)
|
||||||
@@ -1678,17 +1678,26 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
|
|||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public override string SipUri
|
|
||||||
{
|
public override string SipUri
|
||||||
get
|
{
|
||||||
{
|
get
|
||||||
if (CodecStatus.Status.SIP.AlternateURI.Primary.URI.Value != null)
|
{
|
||||||
return CodecStatus.Status.SIP.AlternateURI.Primary.URI.Value;
|
if (CodecStatus.Status.SIP != null && CodecStatus.Status.SIP.AlternateURI.Primary.URI.Value != null)
|
||||||
else
|
{
|
||||||
return string.Empty;
|
return CodecStatus.Status.SIP.AlternateURI.Primary.URI.Value;
|
||||||
}
|
}
|
||||||
}
|
else if (CodecStatus.Status.UserInterface != null &&
|
||||||
|
CodecStatus.Status.UserInterface.ContactInfo.ContactMethod[0].Number.Value != null)
|
||||||
|
{
|
||||||
|
return CodecStatus.Status.UserInterface.ContactInfo.ContactMethod[0].Number.Value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override bool AutoAnswerEnabled
|
public override bool AutoAnswerEnabled
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ using PepperDash.Essentials.Core.Config;
|
|||||||
using PepperDash.Essentials.Core.Routing;
|
using PepperDash.Essentials.Core.Routing;
|
||||||
using PepperDash.Essentials.Devices.Common.Cameras;
|
using PepperDash.Essentials.Devices.Common.Cameras;
|
||||||
using PepperDash.Essentials.Devices.Common.Codec;
|
using PepperDash.Essentials.Devices.Common.Codec;
|
||||||
using PepperDash.Essentials.Devices.Common.Occupancy;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Devices.Common.VideoCodec;
|
using PepperDash.Essentials.Devices.Common.VideoCodec;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom
|
namespace PepperDash.Essentials.Devices.Common.VideoCodec.ZoomRoom
|
||||||
|
|||||||
Reference in New Issue
Block a user