mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 20:54:55 +00:00
ECS-1244 Added StatusSignController Class and bridge
This commit is contained in:
@@ -166,6 +166,11 @@ namespace PepperDash.Essentials.Bridges
|
|||||||
(device as PepperDash.Essentials.Devices.Common.Occupancy.GlsOccupancySensorBaseController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
|
(device as PepperDash.Essentials.Devices.Common.Occupancy.GlsOccupancySensorBaseController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (device is StatusSignController)
|
||||||
|
{
|
||||||
|
(device as StatusSignController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using Crestron.SimplSharp.Reflection;
|
||||||
|
using PepperDash.Essentials.Core;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Bridges
|
||||||
|
{
|
||||||
|
public class StatusSignControllerJoinMap:JoinMapBase
|
||||||
|
{
|
||||||
|
public uint IsOnline { get; set; }
|
||||||
|
public uint RedLed { get; set; }
|
||||||
|
public uint GreenLed { get; set; }
|
||||||
|
public uint BlueLed { get; set; }
|
||||||
|
public uint RedControl { get; set; }
|
||||||
|
public uint GreenControl { get; set; }
|
||||||
|
public uint BlueControl { get; set; }
|
||||||
|
|
||||||
|
public StatusSignControllerJoinMap(uint joinStart)
|
||||||
|
{
|
||||||
|
//digital
|
||||||
|
IsOnline = 1;
|
||||||
|
RedControl = 2;
|
||||||
|
GreenControl = 3;
|
||||||
|
BlueControl = 4;
|
||||||
|
|
||||||
|
//Analog
|
||||||
|
RedLed = 2;
|
||||||
|
GreenLed = 3;
|
||||||
|
BlueLed = 4;
|
||||||
|
|
||||||
|
OffsetJoinNumbers(joinStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OffsetJoinNumbers(uint joinStart)
|
||||||
|
{
|
||||||
|
var joinOffset = joinStart - 1;
|
||||||
|
var properties =
|
||||||
|
GetType().GetCType().GetProperties().Where(p => p.PropertyType == typeof (uint)).ToList();
|
||||||
|
|
||||||
|
foreach (var propertyInfo in properties)
|
||||||
|
{
|
||||||
|
propertyInfo.SetValue(this, (uint) propertyInfo.GetValue(this, null) + joinOffset, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
53
PepperDashEssentials/Bridges/StatusSignControllerBridge.cs
Normal file
53
PepperDashEssentials/Bridges/StatusSignControllerBridge.cs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using PepperDash.Core;
|
||||||
|
using PepperDash.Essentials.Core;
|
||||||
|
using PepperDash.Essentials.Core.CrestronIO;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Bridges
|
||||||
|
{
|
||||||
|
public static class StatusSignDeviceApiExtensions
|
||||||
|
{
|
||||||
|
public static void LinkToApi(this StatusSignController ssDevice, BasicTriList trilist, uint joinStart,
|
||||||
|
string joinMapKey)
|
||||||
|
{
|
||||||
|
var joinMap = new StatusSignControllerJoinMap(joinStart);
|
||||||
|
|
||||||
|
var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(joinMapSerialized))
|
||||||
|
joinMap = JsonConvert.DeserializeObject<StatusSignControllerJoinMap>(joinMapSerialized);
|
||||||
|
|
||||||
|
joinMap.OffsetJoinNumbers(joinStart);
|
||||||
|
|
||||||
|
Debug.Console(1, ssDevice, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||||
|
|
||||||
|
trilist.SetBoolSigAction(joinMap.RedControl, b => EnableControl(trilist, joinMap, ssDevice));
|
||||||
|
trilist.SetBoolSigAction(joinMap.GreenControl, b => EnableControl(trilist, joinMap, ssDevice));
|
||||||
|
trilist.SetBoolSigAction(joinMap.BlueControl, b => EnableControl(trilist, joinMap, ssDevice));
|
||||||
|
|
||||||
|
trilist.SetUShortSigAction(joinMap.RedLed, u => SetColor(trilist, joinMap, ssDevice));
|
||||||
|
trilist.SetUShortSigAction(joinMap.GreenLed, u => SetColor(trilist, joinMap, ssDevice));
|
||||||
|
trilist.SetUShortSigAction(joinMap.BlueLed, u => SetColor(trilist, joinMap, ssDevice));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void EnableControl(BasicTriList triList, StatusSignControllerJoinMap joinMap,
|
||||||
|
StatusSignController device)
|
||||||
|
{
|
||||||
|
var redEnable = triList.BooleanOutput[joinMap.RedControl].BoolValue;
|
||||||
|
var greenEnable = triList.BooleanOutput[joinMap.GreenControl].BoolValue;
|
||||||
|
var blueEnable = triList.BooleanOutput[joinMap.BlueControl].BoolValue;
|
||||||
|
device.EnableLedControl(redEnable, greenEnable, blueEnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SetColor(BasicTriList triList, StatusSignControllerJoinMap joinMap,
|
||||||
|
StatusSignController device)
|
||||||
|
{
|
||||||
|
var redBrightness = triList.UShortOutput[joinMap.RedLed].UShortValue;
|
||||||
|
var greenBrightness = triList.UShortOutput[joinMap.GreenLed].UShortValue;
|
||||||
|
var blueBrightness = triList.UShortOutput[joinMap.BlueLed].UShortValue;
|
||||||
|
|
||||||
|
device.SetColor(redBrightness, greenBrightness, blueBrightness);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -153,7 +153,9 @@
|
|||||||
<Compile Include="Bridges\JoinMaps\IBasicCommunicationJoinMap.cs" />
|
<Compile Include="Bridges\JoinMaps\IBasicCommunicationJoinMap.cs" />
|
||||||
<Compile Include="Bridges\JoinMaps\IDigitalInputJoinMap.cs" />
|
<Compile Include="Bridges\JoinMaps\IDigitalInputJoinMap.cs" />
|
||||||
<Compile Include="Bridges\JoinMaps\GlsOccupancySensorBaseJoinMap.cs" />
|
<Compile Include="Bridges\JoinMaps\GlsOccupancySensorBaseJoinMap.cs" />
|
||||||
|
<Compile Include="Bridges\JoinMaps\StatusSignControllerJoinMap.cs" />
|
||||||
<Compile Include="Bridges\JoinMaps\SystemMonitorJoinMap.cs" />
|
<Compile Include="Bridges\JoinMaps\SystemMonitorJoinMap.cs" />
|
||||||
|
<Compile Include="Bridges\StatusSignControllerBridge.cs" />
|
||||||
<Compile Include="Bridges\SystemMonitorBridge.cs" />
|
<Compile Include="Bridges\SystemMonitorBridge.cs" />
|
||||||
<Compile Include="Configuration ORIGINAL\Builders\TPConfig.cs" />
|
<Compile Include="Configuration ORIGINAL\Builders\TPConfig.cs" />
|
||||||
<Compile Include="Configuration ORIGINAL\Configuration.cs" />
|
<Compile Include="Configuration ORIGINAL\Configuration.cs" />
|
||||||
|
|||||||
@@ -0,0 +1,107 @@
|
|||||||
|
using System;
|
||||||
|
using Crestron.SimplSharpPro;
|
||||||
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
using Crestron.SimplSharpPro.GeneralIO;
|
||||||
|
using PepperDash.Core;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core.CrestronIO
|
||||||
|
{
|
||||||
|
public class StatusSignController:CrestronGenericBaseDevice
|
||||||
|
{
|
||||||
|
private StatusSign _device;
|
||||||
|
|
||||||
|
public BoolFeedback RedLedEnabledFeedback { get; private set; }
|
||||||
|
public BoolFeedback GreenLedEnabledFeedback { get; private set; }
|
||||||
|
public BoolFeedback BlueLedEnabledFeedback { get; private set; }
|
||||||
|
|
||||||
|
public IntFeedback RedLedBrightnessFeedback { get; private set; }
|
||||||
|
public IntFeedback GreenLedBrightnessFeedback { get; private set; }
|
||||||
|
public IntFeedback BlueLedBrightnessFeedback { get; private set; }
|
||||||
|
|
||||||
|
public StatusSignController(string key, string name, GenericBase hardware) : base(key, name, hardware)
|
||||||
|
{
|
||||||
|
_device = hardware as StatusSign;
|
||||||
|
|
||||||
|
RedLedEnabledFeedback =
|
||||||
|
new BoolFeedback(
|
||||||
|
() =>
|
||||||
|
_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);
|
||||||
|
|
||||||
|
RedLedBrightnessFeedback =
|
||||||
|
new IntFeedback(() => (int) _device.Leds[(uint) StatusSign.Led.eLedColor.Red].BrightnessFeedback);
|
||||||
|
GreenLedBrightnessFeedback =
|
||||||
|
new IntFeedback(() => (int) _device.Leds[(uint) StatusSign.Led.eLedColor.Green].BrightnessFeedback);
|
||||||
|
BlueLedBrightnessFeedback =
|
||||||
|
new IntFeedback(() => (int) _device.Leds[(uint) StatusSign.Led.eLedColor.Blue].BrightnessFeedback);
|
||||||
|
|
||||||
|
_device.BaseEvent += _device_BaseEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
void _device_BaseEvent(GenericBase device, BaseEventArgs args)
|
||||||
|
{
|
||||||
|
switch (args.EventId)
|
||||||
|
{
|
||||||
|
case StatusSign.LedBrightnessFeedbackEventId:
|
||||||
|
RedLedBrightnessFeedback.FireUpdate();
|
||||||
|
GreenLedBrightnessFeedback.FireUpdate();
|
||||||
|
BlueLedBrightnessFeedback.FireUpdate();
|
||||||
|
break;
|
||||||
|
case StatusSign.LedControlFeedbackEventId:
|
||||||
|
RedLedEnabledFeedback.FireUpdate();
|
||||||
|
GreenLedEnabledFeedback.FireUpdate();
|
||||||
|
BlueLedEnabledFeedback.FireUpdate();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EnableLedControl(bool red, bool green, bool blue)
|
||||||
|
{
|
||||||
|
_device.Leds[(uint) StatusSign.Led.eLedColor.Red].Control.BoolValue = red;
|
||||||
|
_device.Leds[(uint)StatusSign.Led.eLedColor.Green].Control.BoolValue = green;
|
||||||
|
_device.Leds[(uint)StatusSign.Led.eLedColor.Blue].Control.BoolValue = blue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetColor(uint red, uint green, uint blue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_device.Leds[(uint)StatusSign.Led.eLedColor.Red].Brightness =
|
||||||
|
(StatusSign.Led.eBrightnessPercentageValues)SimplSharpDeviceHelper.PercentToUshort(red);
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException)
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "Error converting value to Red LED brightness. value: {0}", red);
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_device.Leds[(uint)StatusSign.Led.eLedColor.Green].Brightness =
|
||||||
|
(StatusSign.Led.eBrightnessPercentageValues)SimplSharpDeviceHelper.PercentToUshort(green);
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException)
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "Error converting value to Green LED brightness. value: {0}", green);
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_device.Leds[(uint)StatusSign.Led.eLedColor.Blue].Brightness =
|
||||||
|
(StatusSign.Led.eBrightnessPercentageValues)SimplSharpDeviceHelper.PercentToUshort(blue);
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException)
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "Error converting value to Blue LED brightness. value: {0}", blue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,10 +4,11 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
|
using Crestron.SimplSharpPro.GeneralIO;
|
||||||
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.CrestronIO;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
@@ -55,10 +56,17 @@ namespace PepperDash.Essentials.Core
|
|||||||
else if (typeName == "ceniodigin104")
|
else if (typeName == "ceniodigin104")
|
||||||
{
|
{
|
||||||
var control = CommFactory.GetControlPropertiesConfig(dc);
|
var control = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
var ipid = control.CresnetIdInt;
|
var ipid = control.IpIdInt;
|
||||||
|
|
||||||
return new CenIoDigIn104Controller(key, name, new Crestron.SimplSharpPro.GeneralIO.CenIoDi104(ipid, Global.ControlSystem));
|
return new CenIoDigIn104Controller(key, name, new Crestron.SimplSharpPro.GeneralIO.CenIoDi104(ipid, Global.ControlSystem));
|
||||||
}
|
}
|
||||||
|
if (typeName == "statussign")
|
||||||
|
{
|
||||||
|
var control = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
|
var cresnetId = control.CresnetIdInt;
|
||||||
|
|
||||||
|
return new StatusSignController(key, name, new StatusSign(cresnetId, Global.ControlSystem));
|
||||||
|
}
|
||||||
|
|
||||||
// then check for types that have been added by plugin dlls.
|
// then check for types that have been added by plugin dlls.
|
||||||
if (FactoryMethods.ContainsKey(typeName))
|
if (FactoryMethods.ContainsKey(typeName))
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Crestron.SimplSharpPro.GeneralIO, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
|
<Reference Include="Crestron.SimplSharpPro.GeneralIO, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.GeneralIO.dll</HintPath>
|
<HintPath>..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.GeneralIO.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Crestron.SimplSharpPro.Remotes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
|
<Reference Include="Crestron.SimplSharpPro.Remotes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
@@ -125,6 +125,7 @@
|
|||||||
<Compile Include="Crestron IO\IOPortConfig.cs" />
|
<Compile Include="Crestron IO\IOPortConfig.cs" />
|
||||||
<Compile Include="Crestron IO\Relay\GenericRelayDevice.cs" />
|
<Compile Include="Crestron IO\Relay\GenericRelayDevice.cs" />
|
||||||
<Compile Include="Crestron IO\Relay\ISwitchedOutput.cs" />
|
<Compile Include="Crestron IO\Relay\ISwitchedOutput.cs" />
|
||||||
|
<Compile Include="Crestron IO\StatusSign\StatusSignController.cs" />
|
||||||
<Compile Include="Devices\CodecInterfaces.cs" />
|
<Compile Include="Devices\CodecInterfaces.cs" />
|
||||||
<Compile Include="Devices\CrestronProcessor.cs" />
|
<Compile Include="Devices\CrestronProcessor.cs" />
|
||||||
<Compile Include="Devices\DeviceApiBase.cs" />
|
<Compile Include="Devices\DeviceApiBase.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user