This commit is contained in:
bitm0de
2020-02-18 22:39:27 -07:00
18 changed files with 941 additions and 508 deletions

View File

@@ -166,6 +166,16 @@ 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;
} }
else if (device is StatusSignController)
{
(device as StatusSignController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is C2nRthsController)
{
(device as C2nRthsController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
} }
} }

View File

@@ -0,0 +1,38 @@
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 C2nRthsControllerApiExtensions
{
public static void LinkToApi(this C2nRthsController device, BasicTriList triList, uint joinStart,
string joinMapKey)
{
var joinMap = new C2nRthsControllerJoinMap();
var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<C2nRthsControllerJoinMap>(joinMapSerialized);
joinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, device, "Linking to Trilist '{0}'", triList.ID.ToString("X"));
triList.SetBoolSigAction(joinMap.TemperatureFormat, device.SetTemperatureFormat);
device.IsOnline.LinkInputSig(triList.BooleanInput[joinMap.IsOnline]);
device.TemperatureFeedback.LinkInputSig(triList.UShortInput[joinMap.Temperature]);
device.HumidityFeedback.LinkInputSig(triList.UShortInput[joinMap.Humidity]);
triList.StringInput[joinMap.Name].StringValue = device.Name;
}
}
}

View File

@@ -1,110 +1,114 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Essentials.Devices.Common.Occupancy; using PepperDash.Essentials.Devices.Common.Occupancy;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Core; using PepperDash.Core;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace PepperDash.Essentials.Bridges namespace PepperDash.Essentials.Bridges
{ {
public static class GlsOccupancySensorBaseControllerApiExtensions public static class GlsOccupancySensorBaseControllerApiExtensions
{ {
public static void LinkToApi(this GlsOccupancySensorBaseController occController, BasicTriList trilist, uint joinStart, string joinMapKey) public static void LinkToApi(this GlsOccupancySensorBaseController occController, BasicTriList trilist, uint joinStart, string joinMapKey)
{ {
GlsOccupancySensorBaseJoinMap joinMap = new GlsOccupancySensorBaseJoinMap(); GlsOccupancySensorBaseJoinMap joinMap = new GlsOccupancySensorBaseJoinMap();
var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey); var joinMapSerialized = JoinMapHelper.GetJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized)) if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<GlsOccupancySensorBaseJoinMap>(joinMapSerialized); joinMap = JsonConvert.DeserializeObject<GlsOccupancySensorBaseJoinMap>(joinMapSerialized);
joinMap.OffsetJoinNumbers(joinStart); joinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, occController, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); Debug.Console(1, occController, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
#region Single and Dual Sensor Stuff #region Single and Dual Sensor Stuff
occController.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]); occController.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
// Occupied status // Occupied status
trilist.SetSigTrueAction(joinMap.ForceOccupied, new Action(() => occController.ForceOccupied())); trilist.SetSigTrueAction(joinMap.ForceOccupied, new Action(() => occController.ForceOccupied()));
trilist.SetSigTrueAction(joinMap.ForceVacant, new Action(() => occController.ForceVacant())); trilist.SetSigTrueAction(joinMap.ForceVacant, new Action(() => occController.ForceVacant()));
occController.RoomIsOccupiedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RoomOccupiedFeedback]); occController.RoomIsOccupiedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RoomOccupiedFeedback]);
occController.RoomIsOccupiedFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.RoomVacantFeedback]); occController.RoomIsOccupiedFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.RoomVacantFeedback]);
occController.RawOccupancyFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyFeedback]); occController.RawOccupancyFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyFeedback]);
// Timouts // Timouts
trilist.SetUShortSigAction(joinMap.Timeout, new Action<ushort>((u) => occController.SetRemoteTimeout(u))); trilist.SetUShortSigAction(joinMap.Timeout, new Action<ushort>((u) => occController.SetRemoteTimeout(u)));
occController.CurrentTimeoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.Timeout]); occController.CurrentTimeoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.Timeout]);
occController.LocalTimoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeoutLocalFeedback]); occController.LocalTimoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeoutLocalFeedback]);
// LED Flash // LED Flash
trilist.SetSigTrueAction(joinMap.EnableLedFlash, new Action(() => occController.SetLedFlashEnable(true))); trilist.SetSigTrueAction(joinMap.EnableLedFlash, new Action(() => occController.SetLedFlashEnable(true)));
trilist.SetSigTrueAction(joinMap.DisableLedFlash, new Action(() => occController.SetLedFlashEnable(false))); trilist.SetSigTrueAction(joinMap.DisableLedFlash, new Action(() => occController.SetLedFlashEnable(false)));
occController.LedFlashEnabledFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.EnableLedFlash]); occController.LedFlashEnabledFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.EnableLedFlash]);
// Short Timeout // Short Timeout
trilist.SetSigTrueAction(joinMap.EnableShortTimeout, new Action(() => occController.SetShortTimeoutState(true))); trilist.SetSigTrueAction(joinMap.EnableShortTimeout, new Action(() => occController.SetShortTimeoutState(true)));
trilist.SetSigTrueAction(joinMap.DisableShortTimeout, new Action(() => occController.SetShortTimeoutState(false))); trilist.SetSigTrueAction(joinMap.DisableShortTimeout, new Action(() => occController.SetShortTimeoutState(false)));
occController.ShortTimeoutEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableShortTimeout]); occController.ShortTimeoutEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableShortTimeout]);
// PIR Sensor // PIR Sensor
trilist.SetSigTrueAction(joinMap.EnablePir, new Action(() => occController.SetPirEnable(true))); trilist.SetSigTrueAction(joinMap.EnablePir, new Action(() => occController.SetPirEnable(true)));
trilist.SetSigTrueAction(joinMap.DisablePir, new Action(() => occController.SetPirEnable(false))); trilist.SetSigTrueAction(joinMap.DisablePir, new Action(() => occController.SetPirEnable(false)));
occController.PirSensorEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnablePir]); occController.PirSensorEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnablePir]);
// PIR Sensitivity in Occupied State // PIR Sensitivity in Occupied State
trilist.SetBoolSigAction(joinMap.IncrementPirInOccupiedState, new Action<bool>((b) => occController.IncrementPirSensitivityInOccupiedState(b))); trilist.SetBoolSigAction(joinMap.IncrementPirInOccupiedState, new Action<bool>((b) => occController.IncrementPirSensitivityInOccupiedState(b)));
trilist.SetBoolSigAction(joinMap.DecrementPirInOccupiedState, new Action<bool>((b) => occController.DecrementPirSensitivityInOccupiedState(b))); trilist.SetBoolSigAction(joinMap.DecrementPirInOccupiedState, new Action<bool>((b) => occController.DecrementPirSensitivityInOccupiedState(b)));
occController.PirSensitivityInOccupiedStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.PirSensitivityInOccupiedState]); occController.PirSensitivityInOccupiedStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.PirSensitivityInOccupiedState]);
// PIR Sensitivity in Vacant State // PIR Sensitivity in Vacant State
trilist.SetBoolSigAction(joinMap.IncrementPirInVacantState, new Action<bool>((b) => occController.IncrementPirSensitivityInVacantState(b))); trilist.SetBoolSigAction(joinMap.IncrementPirInVacantState, new Action<bool>((b) => occController.IncrementPirSensitivityInVacantState(b)));
trilist.SetBoolSigAction(joinMap.DecrementPirInVacantState, new Action<bool>((b) => occController.DecrementPirSensitivityInVacantState(b))); trilist.SetBoolSigAction(joinMap.DecrementPirInVacantState, new Action<bool>((b) => occController.DecrementPirSensitivityInVacantState(b)));
occController.PirSensitivityInVacantStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.PirSensitivityInVacantState]); occController.PirSensitivityInVacantStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.PirSensitivityInVacantState]);
#endregion #endregion
#region Dual Technology Sensor Stuff #region Dual Technology Sensor Stuff
var odtOccController = occController as GlsOdtOccupancySensorController; var odtOccController = occController as GlsOdtOccupancySensorController;
if (odtOccController != null) if (odtOccController != null)
{ {
// OR When Vacated // OR When Vacated
trilist.SetBoolSigAction(joinMap.OrWhenVacated, new Action<bool>((b) => odtOccController.SetOrWhenVacatedState(b))); trilist.SetBoolSigAction(joinMap.OrWhenVacated, new Action<bool>((b) => odtOccController.SetOrWhenVacatedState(b)));
odtOccController.OrWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.OrWhenVacated]); odtOccController.OrWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.OrWhenVacated]);
// AND When Vacated // AND When Vacated
trilist.SetBoolSigAction(joinMap.AndWhenVacated, new Action<bool>((b) => odtOccController.SetAndWhenVacatedState(b))); trilist.SetBoolSigAction(joinMap.AndWhenVacated, new Action<bool>((b) => odtOccController.SetAndWhenVacatedState(b)));
odtOccController.AndWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AndWhenVacated]); odtOccController.AndWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AndWhenVacated]);
// Ultrasonic A Sensor // Ultrasonic A Sensor
trilist.SetSigTrueAction(joinMap.EnableUsA, new Action(() => odtOccController.SetUsAEnable(true))); trilist.SetSigTrueAction(joinMap.EnableUsA, new Action(() => odtOccController.SetUsAEnable(true)));
trilist.SetSigTrueAction(joinMap.DisableUsA, new Action(() => odtOccController.SetUsAEnable(false))); trilist.SetSigTrueAction(joinMap.DisableUsA, new Action(() => odtOccController.SetUsAEnable(false)));
odtOccController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsA]); odtOccController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsA]);
// Ultrasonic B Sensor // Ultrasonic B Sensor
trilist.SetSigTrueAction(joinMap.EnableUsB, new Action(() => odtOccController.SetUsBEnable(true))); trilist.SetSigTrueAction(joinMap.EnableUsB, new Action(() => odtOccController.SetUsBEnable(true)));
trilist.SetSigTrueAction(joinMap.DisableUsB, new Action(() => odtOccController.SetUsBEnable(false))); trilist.SetSigTrueAction(joinMap.DisableUsB, new Action(() => odtOccController.SetUsBEnable(false)));
odtOccController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsB]); odtOccController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsB]);
// US Sensitivity in Occupied State // US Sensitivity in Occupied State
trilist.SetBoolSigAction(joinMap.IncrementUsInOccupiedState, new Action<bool>((b) => odtOccController.IncrementUsSensitivityInOccupiedState(b))); trilist.SetBoolSigAction(joinMap.IncrementUsInOccupiedState, new Action<bool>((b) => odtOccController.IncrementUsSensitivityInOccupiedState(b)));
trilist.SetBoolSigAction(joinMap.DecrementUsInOccupiedState, new Action<bool>((b) => odtOccController.DecrementUsSensitivityInOccupiedState(b))); trilist.SetBoolSigAction(joinMap.DecrementUsInOccupiedState, new Action<bool>((b) => odtOccController.DecrementUsSensitivityInOccupiedState(b)));
odtOccController.UltrasonicSensitivityInOccupiedStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.UsSensitivityInOccupiedState]); odtOccController.UltrasonicSensitivityInOccupiedStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.UsSensitivityInOccupiedState]);
// US Sensitivity in Vacant State // US Sensitivity in Vacant State
trilist.SetBoolSigAction(joinMap.IncrementUsInVacantState, new Action<bool>((b) => odtOccController.IncrementUsSensitivityInVacantState(b))); trilist.SetBoolSigAction(joinMap.IncrementUsInVacantState, new Action<bool>((b) => odtOccController.IncrementUsSensitivityInVacantState(b)));
trilist.SetBoolSigAction(joinMap.DecrementUsInVacantState, new Action<bool>((b) => odtOccController.DecrementUsSensitivityInVacantState(b))); trilist.SetBoolSigAction(joinMap.DecrementUsInVacantState, new Action<bool>((b) => odtOccController.DecrementUsSensitivityInVacantState(b)));
odtOccController.UltrasonicSensitivityInVacantStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.UsSensitivityInVacantState]); odtOccController.UltrasonicSensitivityInVacantStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.UsSensitivityInVacantState]);
} //Sensor Raw States
#endregion odtOccController.RawOccupancyPirFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyPirFeedback]);
} odtOccController.RawOccupancyUsFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyUsFeedback]);
}
}
#endregion
}
}
} }

View File

@@ -0,0 +1,43 @@
using System.Linq;
using Crestron.SimplSharp.Reflection;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Bridges
{
public class C2nRthsControllerJoinMap:JoinMapBase
{
public uint IsOnline { get; set; }
public uint Name { get; set; }
public uint Temperature { get; set; }
public uint Humidity { get; set; }
public uint TemperatureFormat { get; set; }
public C2nRthsControllerJoinMap()
{
//digital
IsOnline = 1;
TemperatureFormat = 2;
//Analog
Temperature = 2;
Humidity = 3;
//serial
Name = 1;
}
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);
}
}
}
}

View File

@@ -1,219 +1,230 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Bridges namespace PepperDash.Essentials.Bridges
{ {
public class GlsOccupancySensorBaseJoinMap : JoinMapBase public class GlsOccupancySensorBaseJoinMap : JoinMapBase
{ {
#region Digitals #region Digitals
/// <summary> /// <summary>
/// High when device is online /// High when device is online
/// </summary> /// </summary>
public uint IsOnline { get; set; } public uint IsOnline { get; set; }
/// <summary> /// <summary>
/// Forces the device to report occupied status /// Forces the device to report occupied status
/// </summary> /// </summary>
public uint ForceOccupied { get; set; } public uint ForceOccupied { get; set; }
/// <summary> /// <summary>
/// Forces the device to report vacant status /// Forces the device to report vacant status
/// </summary> /// </summary>
public uint ForceVacant { get; set; } public uint ForceVacant { get; set; }
/// <summary> /// <summary>
/// Enables raw status reporting /// Enables raw status reporting
/// </summary> /// </summary>
public uint EnableRawStates { get; set; } public uint EnableRawStates { get; set; }
/// <summary> /// <summary>
/// High when raw occupancy is detected /// High when raw occupancy is detected
/// </summary> /// </summary>
public uint RawOccupancyFeedback { get; set; } public uint RawOccupancyFeedback { get; set; }
/// <summary> /// <summary>
/// High when occupancy is detected /// High when PIR sensor detects motion
/// </summary> /// </summary>
public uint RoomOccupiedFeedback { get; set; } public uint RawOccupancyPirFeedback { get; set; }
/// <summary> /// <summary>
/// Hich when occupancy is detected in the grace period /// High when US sensor detects motion
/// </summary> /// </summary>
public uint GraceOccupancyDetectedFeedback { get; set; } public uint RawOccupancyUsFeedback { get; set; }
/// <summary> /// <summary>
/// High when vacancy is detected /// High when occupancy is detected
/// </summary> /// </summary>
public uint RoomVacantFeedback { get; set; } public uint RoomOccupiedFeedback { get; set; }
/// <summary>
/// <summary> /// Hich when occupancy is detected in the grace period
/// Enables the LED Flash when set high /// </summary>
/// </summary> public uint GraceOccupancyDetectedFeedback { get; set; }
public uint EnableLedFlash { get; set; } /// <summary>
/// <summary> /// High when vacancy is detected
/// Disables the LED flash when set high /// </summary>
/// </summary> public uint RoomVacantFeedback { get; set; }
public uint DisableLedFlash { get; set; }
/// <summary> /// <summary>
/// Enables the Short Timeout /// Enables the LED Flash when set high
/// </summary> /// </summary>
public uint EnableShortTimeout { get; set; } public uint EnableLedFlash { get; set; }
/// <summary> /// <summary>
/// Disables the Short Timout /// Disables the LED flash when set high
/// </summary> /// </summary>
public uint DisableShortTimeout { get; set; } public uint DisableLedFlash { get; set; }
/// <summary> /// <summary>
/// Set high to enable one technology to trigger occupancy /// Enables the Short Timeout
/// </summary> /// </summary>
public uint OrWhenVacated { get; set; } public uint EnableShortTimeout { get; set; }
/// <summary> /// <summary>
/// Set high to require both technologies to trigger occupancy /// Disables the Short Timout
/// </summary> /// </summary>
public uint AndWhenVacated { get; set; } public uint DisableShortTimeout { get; set; }
/// <summary> /// <summary>
/// Enables Ultrasonic Sensor A /// Set high to enable one technology to trigger occupancy
/// </summary> /// </summary>
public uint EnableUsA { get; set; } public uint OrWhenVacated { get; set; }
/// <summary> /// <summary>
/// Disables Ultrasonic Sensor A /// Set high to require both technologies to trigger occupancy
/// </summary> /// </summary>
public uint DisableUsA { get; set; } public uint AndWhenVacated { get; set; }
/// <summary> /// <summary>
/// Enables Ultrasonic Sensor B /// Enables Ultrasonic Sensor A
/// </summary> /// </summary>
public uint EnableUsB { get; set; } public uint EnableUsA { get; set; }
/// <summary> /// <summary>
/// Disables Ultrasonic Sensor B /// Disables Ultrasonic Sensor A
/// </summary> /// </summary>
public uint DisableUsB { get; set; } public uint DisableUsA { get; set; }
/// <summary> /// <summary>
/// Enables Pir /// Enables Ultrasonic Sensor B
/// </summary> /// </summary>
public uint EnablePir { get; set; } public uint EnableUsB { get; set; }
/// <summary> /// <summary>
/// Disables Pir /// Disables Ultrasonic Sensor B
/// </summary> /// </summary>
public uint DisablePir { get; set; } public uint DisableUsB { get; set; }
public uint IncrementUsInOccupiedState { get; set; } /// <summary>
public uint DecrementUsInOccupiedState { get; set; } /// Enables Pir
public uint IncrementUsInVacantState { get; set; } /// </summary>
public uint DecrementUsInVacantState { get; set; } public uint EnablePir { get; set; }
public uint IncrementPirInOccupiedState { get; set; } /// <summary>
public uint DecrementPirInOccupiedState { get; set; } /// Disables Pir
public uint IncrementPirInVacantState { get; set; } /// </summary>
public uint DecrementPirInVacantState { get; set; } public uint DisablePir { get; set; }
#endregion public uint IncrementUsInOccupiedState { get; set; }
public uint DecrementUsInOccupiedState { get; set; }
#region Analogs public uint IncrementUsInVacantState { get; set; }
/// <summary> public uint DecrementUsInVacantState { get; set; }
/// Sets adn reports the remote timeout value public uint IncrementPirInOccupiedState { get; set; }
/// </summary> public uint DecrementPirInOccupiedState { get; set; }
public uint Timeout { get; set; } public uint IncrementPirInVacantState { get; set; }
/// <summary> public uint DecrementPirInVacantState { get; set; }
/// Reports the local timeout value #endregion
/// </summary>
public uint TimeoutLocalFeedback { get; set; } #region Analogs
/// <summary> /// <summary>
/// Sets the minimum internal photo sensor value and reports the current level /// Sets adn reports the remote timeout value
/// </summary> /// </summary>
public uint InternalPhotoSensorValue { get; set; } public uint Timeout { get; set; }
/// <summary> /// <summary>
/// Sets the minimum external photo sensor value and reports the current level /// Reports the local timeout value
/// </summary> /// </summary>
public uint ExternalPhotoSensorValue { get; set; } public uint TimeoutLocalFeedback { get; set; }
/// <summary>
public uint UsSensitivityInOccupiedState { get; set; } /// Sets the minimum internal photo sensor value and reports the current level
/// </summary>
public uint UsSensitivityInVacantState { get; set; } public uint InternalPhotoSensorValue { get; set; }
/// <summary>
public uint PirSensitivityInOccupiedState { get; set; } /// Sets the minimum external photo sensor value and reports the current level
/// </summary>
public uint PirSensitivityInVacantState { get; set; } public uint ExternalPhotoSensorValue { get; set; }
#endregion
public uint UsSensitivityInOccupiedState { get; set; }
public GlsOccupancySensorBaseJoinMap()
{ public uint UsSensitivityInVacantState { get; set; }
IsOnline = 1;
ForceOccupied = 2; public uint PirSensitivityInOccupiedState { get; set; }
ForceVacant = 3;
EnableRawStates = 4; public uint PirSensitivityInVacantState { get; set; }
RoomOccupiedFeedback = 2; #endregion
GraceOccupancyDetectedFeedback = 3;
RoomVacantFeedback = 4; public GlsOccupancySensorBaseJoinMap()
RawOccupancyFeedback = 5; {
EnableLedFlash = 11; IsOnline = 1;
DisableLedFlash = 12; ForceOccupied = 2;
EnableShortTimeout = 13; ForceVacant = 3;
DisableShortTimeout = 14; EnableRawStates = 4;
OrWhenVacated = 15; RoomOccupiedFeedback = 2;
AndWhenVacated = 16; GraceOccupancyDetectedFeedback = 3;
EnableUsA = 17; RoomVacantFeedback = 4;
DisableUsA = 18; RawOccupancyFeedback = 5;
EnableUsB = 19; RawOccupancyPirFeedback = 6;
DisableUsB = 20; RawOccupancyUsFeedback = 7;
EnablePir = 21; EnableLedFlash = 11;
DisablePir = 22; DisableLedFlash = 12;
DisablePir = 23; EnableShortTimeout = 13;
IncrementUsInOccupiedState = 24; DisableShortTimeout = 14;
DecrementUsInOccupiedState = 25; OrWhenVacated = 15;
IncrementUsInVacantState = 26; AndWhenVacated = 16;
DecrementUsInVacantState = 27; EnableUsA = 17;
IncrementPirInOccupiedState = 28; DisableUsA = 18;
DecrementPirInOccupiedState = 29; EnableUsB = 19;
IncrementPirInVacantState = 30; DisableUsB = 20;
DecrementPirInVacantState = 31; EnablePir = 21;
DisablePir = 22;
Timeout = 1; IncrementUsInOccupiedState = 23;
TimeoutLocalFeedback = 2; DecrementUsInOccupiedState = 24;
InternalPhotoSensorValue = 3; IncrementUsInVacantState = 25;
ExternalPhotoSensorValue = 4; DecrementUsInVacantState = 26;
UsSensitivityInOccupiedState = 5; IncrementPirInOccupiedState = 27;
UsSensitivityInVacantState = 6; DecrementPirInOccupiedState = 28;
PirSensitivityInOccupiedState = 7; IncrementPirInVacantState = 29;
PirSensitivityInVacantState = 8; DecrementPirInVacantState = 30;
}
Timeout = 1;
public override void OffsetJoinNumbers(uint joinStart) TimeoutLocalFeedback = 2;
{ InternalPhotoSensorValue = 3;
var joinOffset = joinStart - 1; ExternalPhotoSensorValue = 4;
UsSensitivityInOccupiedState = 5;
IsOnline = IsOnline + joinOffset; UsSensitivityInVacantState = 6;
ForceOccupied = ForceOccupied + joinOffset; PirSensitivityInOccupiedState = 7;
ForceVacant = ForceVacant + joinOffset; PirSensitivityInVacantState = 8;
EnableRawStates = EnableRawStates + joinOffset; }
RoomOccupiedFeedback = RoomOccupiedFeedback + joinOffset;
GraceOccupancyDetectedFeedback = GraceOccupancyDetectedFeedback + joinOffset; public override void OffsetJoinNumbers(uint joinStart)
RoomVacantFeedback = RoomVacantFeedback + joinOffset; {
RawOccupancyFeedback = RawOccupancyFeedback + joinOffset; var joinOffset = joinStart - 1;
EnableLedFlash = EnableLedFlash + joinOffset;
DisableLedFlash = DisableLedFlash + joinOffset; IsOnline = IsOnline + joinOffset;
EnableShortTimeout = EnableShortTimeout + joinOffset; ForceOccupied = ForceOccupied + joinOffset;
DisableShortTimeout = DisableShortTimeout + joinOffset; ForceVacant = ForceVacant + joinOffset;
OrWhenVacated = OrWhenVacated + joinOffset; EnableRawStates = EnableRawStates + joinOffset;
AndWhenVacated = AndWhenVacated + joinOffset; RoomOccupiedFeedback = RoomOccupiedFeedback + joinOffset;
EnableUsA = EnableUsA + joinOffset; GraceOccupancyDetectedFeedback = GraceOccupancyDetectedFeedback + joinOffset;
DisableUsA = DisableUsA + joinOffset; RoomVacantFeedback = RoomVacantFeedback + joinOffset;
EnableUsB = EnableUsB + joinOffset; RawOccupancyFeedback = RawOccupancyFeedback + joinOffset;
DisableUsB = DisableUsB + joinOffset; RawOccupancyPirFeedback = RawOccupancyPirFeedback + joinOffset;
EnablePir = EnablePir + joinOffset; RawOccupancyUsFeedback = RawOccupancyUsFeedback + joinOffset;
DisablePir = DisablePir + joinOffset; EnableLedFlash = EnableLedFlash + joinOffset;
DisablePir = DisablePir + joinOffset; DisableLedFlash = DisableLedFlash + joinOffset;
IncrementUsInOccupiedState = IncrementUsInOccupiedState + joinOffset; EnableShortTimeout = EnableShortTimeout + joinOffset;
DecrementUsInOccupiedState = DecrementUsInOccupiedState + joinOffset; DisableShortTimeout = DisableShortTimeout + joinOffset;
IncrementUsInVacantState = IncrementUsInVacantState + joinOffset; OrWhenVacated = OrWhenVacated + joinOffset;
DecrementUsInVacantState = DecrementUsInVacantState + joinOffset; AndWhenVacated = AndWhenVacated + joinOffset;
IncrementPirInOccupiedState = IncrementPirInOccupiedState + joinOffset; EnableUsA = EnableUsA + joinOffset;
DecrementPirInOccupiedState = DecrementPirInOccupiedState + joinOffset; DisableUsA = DisableUsA + joinOffset;
IncrementPirInVacantState = IncrementPirInVacantState + joinOffset; EnableUsB = EnableUsB + joinOffset;
DecrementPirInVacantState = DecrementPirInVacantState + joinOffset; DisableUsB = DisableUsB + joinOffset;
EnablePir = EnablePir + joinOffset;
Timeout = Timeout + joinOffset; DisablePir = DisablePir + joinOffset;
TimeoutLocalFeedback = TimeoutLocalFeedback + joinOffset; DisablePir = DisablePir + joinOffset;
InternalPhotoSensorValue = InternalPhotoSensorValue + joinOffset; IncrementUsInOccupiedState = IncrementUsInOccupiedState + joinOffset;
ExternalPhotoSensorValue = ExternalPhotoSensorValue + joinOffset; DecrementUsInOccupiedState = DecrementUsInOccupiedState + joinOffset;
UsSensitivityInOccupiedState = UsSensitivityInOccupiedState + joinOffset; IncrementUsInVacantState = IncrementUsInVacantState + joinOffset;
UsSensitivityInVacantState = UsSensitivityInVacantState + joinOffset; DecrementUsInVacantState = DecrementUsInVacantState + joinOffset;
PirSensitivityInOccupiedState = PirSensitivityInOccupiedState + joinOffset; IncrementPirInOccupiedState = IncrementPirInOccupiedState + joinOffset;
PirSensitivityInVacantState = PirSensitivityInVacantState + joinOffset; DecrementPirInOccupiedState = DecrementPirInOccupiedState + joinOffset;
} IncrementPirInVacantState = IncrementPirInVacantState + joinOffset;
} DecrementPirInVacantState = DecrementPirInVacantState + joinOffset;
} Timeout = Timeout + joinOffset;
TimeoutLocalFeedback = TimeoutLocalFeedback + joinOffset;
InternalPhotoSensorValue = InternalPhotoSensorValue + joinOffset;
ExternalPhotoSensorValue = ExternalPhotoSensorValue + joinOffset;
UsSensitivityInOccupiedState = UsSensitivityInOccupiedState + joinOffset;
UsSensitivityInVacantState = UsSensitivityInVacantState + joinOffset;
PirSensitivityInOccupiedState = PirSensitivityInOccupiedState + joinOffset;
PirSensitivityInVacantState = PirSensitivityInVacantState + joinOffset;
}
}
}

View File

@@ -0,0 +1,49 @@
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 Name { 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()
{
//digital
IsOnline = 1;
RedControl = 2;
GreenControl = 3;
BlueControl = 4;
//Analog
RedLed = 2;
GreenLed = 3;
BlueLed = 4;
//string
Name = 1;
}
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);
}
}
}
}

View File

@@ -0,0 +1,65 @@
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();
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));
trilist.StringInput[joinMap.Name].StringValue = ssDevice.Name;
ssDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
ssDevice.RedLedEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RedControl]);
ssDevice.BlueLedEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.BlueControl]);
ssDevice.GreenLedEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.GreenControl]);
ssDevice.RedLedBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.RedLed]);
ssDevice.BlueLedBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.BlueLed]);
ssDevice.GreenLedBrightnessFeedback.LinkInputSig(trilist.UShortInput[joinMap.GreenLed]);
}
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);
}
}
}

View File

@@ -96,7 +96,7 @@ namespace PepperDash.Essentials
string directoryPrefix; string directoryPrefix;
directoryPrefix = Crestron.SimplSharp.CrestronIO.Directory.GetApplicationRootDirectory(); directoryPrefix = Crestron.SimplSharp.CrestronIO.Directory.GetApplicationRootDirectory();
var version = Crestron.SimplSharp.Reflection.Assembly.GetExecutingAssembly().GetName().Version; var version = Crestron.SimplSharp.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
Global.SetAssemblyVersion(string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build)); Global.SetAssemblyVersion(string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build));

View File

@@ -119,9 +119,11 @@
<Compile Include="Bridges\AppleTvBridge.cs" /> <Compile Include="Bridges\AppleTvBridge.cs" />
<Compile Include="Bridges\BridgeBase.cs" /> <Compile Include="Bridges\BridgeBase.cs" />
<Compile Include="Bridges\BridgeFactory.cs" /> <Compile Include="Bridges\BridgeFactory.cs" />
<Compile Include="Bridges\C2nRthsControllerBridge.cs" />
<Compile Include="Bridges\CameraControllerBridge.cs" /> <Compile Include="Bridges\CameraControllerBridge.cs" />
<Compile Include="Bridges\AirMediaControllerBridge.cs" /> <Compile Include="Bridges\AirMediaControllerBridge.cs" />
<Compile Include="Bridges\DmBladeChassisControllerBridge.cs" /> <Compile Include="Bridges\DmBladeChassisControllerBridge.cs" />
<Compile Include="Bridges\JoinMaps\C2nRthsControllerJoinMap.cs" />
<Compile Include="Bridges\JoinMaps\DmBladeChassisControllerJoinMap.cs" /> <Compile Include="Bridges\JoinMaps\DmBladeChassisControllerJoinMap.cs" />
<Compile Include="Bridges\DmpsAudioOutputControllerBridge.cs" /> <Compile Include="Bridges\DmpsAudioOutputControllerBridge.cs" />
<Compile Include="Bridges\DmpsRoutingControllerBridge.cs" /> <Compile Include="Bridges\DmpsRoutingControllerBridge.cs" />
@@ -153,7 +155,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="Factory\DeviceFactory.cs" /> <Compile Include="Factory\DeviceFactory.cs" />
<Compile Include="Devices\Amplifier.cs" /> <Compile Include="Devices\Amplifier.cs" />

View File

@@ -106,12 +106,18 @@ namespace PepperDash.Essentials
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "WARNING: Registration failed. Continuing, but panel may not function: {0}", Panel.RegistrationFailureReason); Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "WARNING: Registration failed. Continuing, but panel may not function: {0}", Panel.RegistrationFailureReason);
// Give up cleanly if SGD is not present. // Give up cleanly if SGD is not present.
var sgdName = Global.FilePathPrefix var sgdName = Global.FilePathPrefix + "sgd" + Global.DirectorySeparator + props.SgdFile;
+ Global.DirectorySeparator + "sgd" + Global.DirectorySeparator + props.SgdFile;
if (!File.Exists(sgdName)) if (!File.Exists(sgdName))
{ {
Debug.Console(0, this, "ERROR: Smart object file '{0}' not present. Exiting TSW load", sgdName); Debug.Console(0, this, "Smart object file '{0}' not present in User folder. Looking for embedded file", sgdName);
return;
sgdName = Global.ApplicationDirectoryPathPrefix + Global.DirectorySeparator + "SGD" + Global.DirectorySeparator + props.SgdFile;
if (!File.Exists(sgdName))
{
Debug.Console(0, this, "Unable to find SGD file '{0}' in User sgd or application SGD folder. Exiting touchpanel load.", sgdName);
return;
}
} }
Panel.LoadSmartObjects(sgdName); Panel.LoadSmartObjects(sgdName);

View File

@@ -0,0 +1,44 @@
using System;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.GeneralIO;
using PepperDash.Core;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Core.CrestronIO
{
public class C2nRthsController:CrestronGenericBaseDevice
{
private C2nRths _device;
public IntFeedback TemperatureFeedback { get; private set; }
public IntFeedback HumidityFeedback { get; private set; }
public C2nRthsController(string key, string name, GenericBase hardware) : base(key, name, hardware)
{
_device = hardware as C2nRths;
TemperatureFeedback = new IntFeedback(() => _device.TemperatureFeedback.UShortValue);
HumidityFeedback = new IntFeedback(() => _device.HumidityFeedback.UShortValue);
_device.BaseEvent += DeviceOnBaseEvent;
}
private void DeviceOnBaseEvent(GenericBase device, BaseEventArgs args)
{
switch (args.EventId)
{
case C2nRths.TemperatureFeedbackEventId:
TemperatureFeedback.FireUpdate();
break;
case C2nRths.HumidityFeedbackEventId:
HumidityFeedback.FireUpdate();
break;
}
}
public void SetTemperatureFormat(bool setToC)
{
_device.TemperatureFormat.BoolValue = setToC;
}
}
}

View File

@@ -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);
}
}
}
}

View File

@@ -1,156 +1,169 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core; using PepperDash.Core;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
/// <summary> /// <summary>
/// A bridge class to cover the basic features of GenericBase hardware /// A bridge class to cover the basic features of GenericBase hardware
/// </summary> /// </summary>
public class CrestronGenericBaseDevice : Device, IOnline, IHasFeedback, ICommunicationMonitor, IUsageTracking public class CrestronGenericBaseDevice : Device, IOnline, IHasFeedback, ICommunicationMonitor, IUsageTracking
{ {
public virtual GenericBase Hardware { get; protected set; } public virtual GenericBase Hardware { get; protected set; }
/// <summary> /// <summary>
/// Returns a list containing the Outputs that we want to expose. /// Returns a list containing the Outputs that we want to expose.
/// </summary> /// </summary>
public FeedbackCollection<Feedback> Feedbacks { get; private set; } public FeedbackCollection<Feedback> Feedbacks { get; private set; }
public BoolFeedback IsOnline { get; private set; } public BoolFeedback IsOnline { get; private set; }
public BoolFeedback IsRegistered { get; private set; } public BoolFeedback IsRegistered { get; private set; }
public StringFeedback IpConnectionsText { get; private set; } public StringFeedback IpConnectionsText { get; private set; }
/// <summary> /// <summary>
/// Used by implementing classes to prevent registration with Crestron TLDM. For /// Used by implementing classes to prevent registration with Crestron TLDM. For
/// devices like RMCs and TXs attached to a chassis. /// devices like RMCs and TXs attached to a chassis.
/// </summary> /// </summary>
public bool PreventRegistration { get; protected set; } public bool PreventRegistration { get; protected set; }
public CrestronGenericBaseDevice(string key, string name, GenericBase hardware) public CrestronGenericBaseDevice(string key, string name, GenericBase hardware)
: base(key, name) : base(key, name)
{ {
Feedbacks = new FeedbackCollection<Feedback>(); Feedbacks = new FeedbackCollection<Feedback>();
Hardware = hardware; Hardware = hardware;
IsOnline = new BoolFeedback("IsOnlineFeedback", () => Hardware.IsOnline); IsOnline = new BoolFeedback("IsOnlineFeedback", () => Hardware.IsOnline);
IsRegistered = new BoolFeedback("IsRegistered", () => Hardware.Registered); IsRegistered = new BoolFeedback("IsRegistered", () => Hardware.Registered);
IpConnectionsText = new StringFeedback("IpConnectionsText", () => IpConnectionsText = new StringFeedback("IpConnectionsText", () =>
string.Join(",", Hardware.ConnectedIpList.Select(cip => cip.DeviceIpAddress).ToArray())); {
if (Hardware.ConnectedIpList != null)
AddToFeedbackList(IsOnline, IsRegistered, IpConnectionsText); return string.Join(",", Hardware.ConnectedIpList.Select(cip => cip.DeviceIpAddress).ToArray());
else
CommunicationMonitor = new CrestronGenericBaseCommunicationMonitor(this, hardware, 120000, 300000); return string.Empty;
} });
AddToFeedbackList(IsOnline, IpConnectionsText);
/// <summary>
/// Make sure that overriding classes call this! CommunicationMonitor = new CrestronGenericBaseCommunicationMonitor(this, hardware, 120000, 300000);
/// Registers the Crestron device, connects up to the base events, starts communication monitor }
/// </summary>
public override bool CustomActivate() /// <summary>
{ /// Make sure that overriding classes call this!
Debug.Console(0, this, "Activating"); /// Registers the Crestron device, connects up to the base events, starts communication monitor
if (!PreventRegistration) /// </summary>
{ public override bool CustomActivate()
//Debug.Console(1, this, " Does not require registration. Skipping"); {
Debug.Console(0, this, "Activating");
var response = Hardware.RegisterWithLogging(Key); if (!PreventRegistration)
if (response != eDeviceRegistrationUnRegistrationResponse.Success) {
{ //Debug.Console(1, this, " Does not require registration. Skipping");
//Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response);
return false; var response = Hardware.RegisterWithLogging(Key);
} if (response != eDeviceRegistrationUnRegistrationResponse.Success)
} {
//Debug.Console(0, this, "ERROR: Cannot register Crestron device: {0}", response);
Hardware.OnlineStatusChange += new OnlineStatusChangeEventHandler(Hardware_OnlineStatusChange); return false;
CommunicationMonitor.Start(); }
return true; IsRegistered.FireUpdate();
} }
/// <summary> foreach (var f in Feedbacks)
/// This disconnects events and unregisters the base hardware device. {
/// </summary> f.FireUpdate();
/// <returns></returns> }
public override bool Deactivate()
{ Hardware.OnlineStatusChange += new OnlineStatusChangeEventHandler(Hardware_OnlineStatusChange);
CommunicationMonitor.Stop(); CommunicationMonitor.Start();
Hardware.OnlineStatusChange -= Hardware_OnlineStatusChange;
return true;
return Hardware.UnRegister() == eDeviceRegistrationUnRegistrationResponse.Success; }
}
/// <summary>
/// <summary> /// This disconnects events and unregisters the base hardware device.
/// Adds feedback(s) to the list /// </summary>
/// </summary> /// <returns></returns>
/// <param name="newFbs"></param> public override bool Deactivate()
public void AddToFeedbackList(params Feedback[] newFbs) {
{ CommunicationMonitor.Stop();
foreach (var f in newFbs) Hardware.OnlineStatusChange -= Hardware_OnlineStatusChange;
{
if (f != null) var success = Hardware.UnRegister() == eDeviceRegistrationUnRegistrationResponse.Success;
{
if (!Feedbacks.Contains(f)) IsRegistered.FireUpdate();
{
Feedbacks.Add(f); return success;
} }
}
} /// <summary>
} /// Adds feedback(s) to the list
/// </summary>
void Hardware_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) /// <param name="newFbs"></param>
{ public void AddToFeedbackList(params Feedback[] newFbs)
if (args.DeviceOnLine) {
{ foreach (var f in newFbs)
foreach (var feedback in Feedbacks) {
{ if (f != null)
if (feedback != null) {
feedback.FireUpdate(); if (!Feedbacks.Contains(f))
} {
} Feedbacks.Add(f);
} }
}
#region IStatusMonitor Members }
}
public StatusMonitorBase CommunicationMonitor { get; private set; }
#endregion void Hardware_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
{
#region IUsageTracking Members Debug.Console(2, this, "OnlineStatusChange Event. Online = {0}", args.DeviceOnLine);
foreach (var feedback in Feedbacks)
public UsageTracking UsageTracker { get; set; } {
if (feedback != null)
#endregion feedback.FireUpdate();
} }
}
//***********************************************************************************
public class CrestronGenericBaseDeviceEventIds #region IStatusMonitor Members
{
public const uint IsOnline = 1; public StatusMonitorBase CommunicationMonitor { get; private set; }
public const uint IpConnectionsText =2; #endregion
}
#region IUsageTracking Members
/// <summary>
/// Adds logging to Register() failure public UsageTracking UsageTracker { get; set; }
/// </summary>
public static class GenericBaseExtensions #endregion
{ }
public static eDeviceRegistrationUnRegistrationResponse RegisterWithLogging(this GenericBase device, string key)
{ //***********************************************************************************
var result = device.Register(); public class CrestronGenericBaseDeviceEventIds
var level = result == eDeviceRegistrationUnRegistrationResponse.Success ? {
Debug.ErrorLogLevel.Notice : Debug.ErrorLogLevel.Error; public const uint IsOnline = 1;
Debug.Console(0, level, "Register device result: '{0}', type '{1}', result {2}", key, device, result); public const uint IpConnectionsText =2;
//if (result != eDeviceRegistrationUnRegistrationResponse.Success) }
//{
// Debug.Console(0, Debug.ErrorLogLevel.Error, "Cannot register device '{0}': {1}", key, result); /// <summary>
//} /// Adds logging to Register() failure
return result; /// </summary>
} public static class GenericBaseExtensions
{
} public static eDeviceRegistrationUnRegistrationResponse RegisterWithLogging(this GenericBase device, string key)
{
var result = device.Register();
var level = result == eDeviceRegistrationUnRegistrationResponse.Success ?
Debug.ErrorLogLevel.Notice : Debug.ErrorLogLevel.Error;
Debug.Console(0, level, "Register device result: '{0}', type '{1}', result {2}", key, device, result);
//if (result != eDeviceRegistrationUnRegistrationResponse.Success)
//{
// Debug.Console(0, Debug.ErrorLogLevel.Error, "Cannot register device '{0}': {1}", key, result);
//}
return result;
}
}
} }

View File

@@ -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
{ {
@@ -59,6 +60,20 @@ namespace PepperDash.Essentials.Core
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));
}
if (typeName == "c2nrths")
{
var control = CommFactory.GetControlPropertiesConfig(dc);
var cresnetId = control.CresnetIdInt;
return new C2nRthsController(key, name, new C2nRths(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))

View File

@@ -26,6 +26,17 @@ namespace PepperDash.Essentials.Core
/// </summary> /// </summary>
public static string FilePathPrefix { get; private set; } public static string FilePathPrefix { get; private set; }
/// <summary>
/// The file path prefix to the applciation directory
/// </summary>
public static string ApplicationDirectoryPathPrefix
{
get
{
return Crestron.SimplSharp.CrestronIO.Directory.GetApplicationDirectory();
}
}
/// <summary> /// <summary>
/// Returns the directory separator character based on the running OS /// Returns the directory separator character based on the running OS
/// </summary> /// </summary>

View File

@@ -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>
@@ -119,6 +119,7 @@
<Compile Include="Config\Essentials\ConfigWriter.cs" /> <Compile Include="Config\Essentials\ConfigWriter.cs" />
<Compile Include="Config\Essentials\EssentialsConfig.cs" /> <Compile Include="Config\Essentials\EssentialsConfig.cs" />
<Compile Include="Config\SourceDevicePropertiesConfigBase.cs" /> <Compile Include="Config\SourceDevicePropertiesConfigBase.cs" />
<Compile Include="Crestron IO\C2nRts\C2nRthsController.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" />
@@ -126,6 +127,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" />

View File

@@ -24,7 +24,11 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy
public IntFeedback UltrasonicSensitivityInVacantStateFeedback { get; private set; } public IntFeedback UltrasonicSensitivityInVacantStateFeedback { get; private set; }
public IntFeedback UltrasonicSensitivityInOccupiedStateFeedback { get; private set; } public IntFeedback UltrasonicSensitivityInOccupiedStateFeedback { get; private set; }
public BoolFeedback RawOccupancyPirFeedback { get; private set; }
public BoolFeedback RawOccupancyUsFeedback { get; private set; }
public GlsOdtOccupancySensorController(string key, string name, GlsOdtCCn sensor) public GlsOdtOccupancySensorController(string key, string name, GlsOdtCCn sensor)
@@ -38,11 +42,15 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy
UltrasonicAEnabledFeedback = new BoolFeedback(() => OccSensor.UsAEnabledFeedback.BoolValue); UltrasonicAEnabledFeedback = new BoolFeedback(() => OccSensor.UsAEnabledFeedback.BoolValue);
UltrasonicBEnabledFeedback = new BoolFeedback(() => OccSensor.UsBEnabledFeedback.BoolValue); UltrasonicBEnabledFeedback = new BoolFeedback(() => OccSensor.UsBEnabledFeedback.BoolValue);
RawOccupancyPirFeedback = new BoolFeedback(() => OccSensor.RawOccupancyPirFeedback.BoolValue);
RawOccupancyUsFeedback = new BoolFeedback(() => OccSensor.RawOccupancyUsFeedback.BoolValue);
UltrasonicSensitivityInVacantStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInVacantStateFeedback.UShortValue); UltrasonicSensitivityInVacantStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInVacantStateFeedback.UShortValue);
UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInOccupiedStateFeedback.UShortValue); UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInOccupiedStateFeedback.UShortValue);
} }
/// <summary> /// <summary>
@@ -52,20 +60,23 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy
/// <param name="device"></param> /// <param name="device"></param>
/// <param name="args"></param> /// <param name="args"></param>
protected override void OccSensor_GlsOccupancySensorChange(GlsOccupancySensorBase device, GlsOccupancySensorChangeEventArgs args) protected override void OccSensor_GlsOccupancySensorChange(GlsOccupancySensorBase device, GlsOccupancySensorChangeEventArgs args)
{ {
if (args.EventId == GlsOccupancySensorBase.AndWhenVacatedFeedbackEventId) if (args.EventId == GlsOccupancySensorBase.AndWhenVacatedFeedbackEventId)
AndWhenVacatedFeedback.FireUpdate(); AndWhenVacatedFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.OrWhenVacatedFeedbackEventId) else if (args.EventId == GlsOccupancySensorBase.OrWhenVacatedFeedbackEventId)
OrWhenVacatedFeedback.FireUpdate(); OrWhenVacatedFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.UsAEnabledFeedbackEventId) else if (args.EventId == GlsOccupancySensorBase.UsAEnabledFeedbackEventId)
UltrasonicAEnabledFeedback.FireUpdate(); UltrasonicAEnabledFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.UsBEnabledFeedbackEventId) else if (args.EventId == GlsOccupancySensorBase.UsBEnabledFeedbackEventId)
UltrasonicBEnabledFeedback.FireUpdate(); UltrasonicBEnabledFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.UsSensitivityInOccupiedStateFeedbackEventId) else if (args.EventId == GlsOccupancySensorBase.RawOccupancyPirFeedbackEventId)
UltrasonicSensitivityInOccupiedStateFeedback.FireUpdate(); RawOccupancyPirFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.UsSensitivityInVacantStateFeedbackEventId) else if (args.EventId == GlsOccupancySensorBase.RawOccupancyUsFeedbackEventId)
UltrasonicSensitivityInVacantStateFeedback.FireUpdate(); RawOccupancyUsFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.UsSensitivityInOccupiedStateFeedbackEventId)
UltrasonicSensitivityInOccupiedStateFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.UsSensitivityInVacantStateFeedbackEventId)
UltrasonicSensitivityInVacantStateFeedback.FireUpdate();
base.OccSensor_GlsOccupancySensorChange(device, args); base.OccSensor_GlsOccupancySensorChange(device, args);
} }