Compare commits

...

42 Commits
1.7.3 ... 1.7.6

Author SHA1 Message Date
Andrew Welker
3ebe44be34 Merge pull request #606 from PepperDash/hotfix/fusion-static-asset-fixes
Hotfix/fusion static asset fixes
2021-02-10 15:56:46 -07:00
Andrew Welker
e7b322c303 add error log for some exceptions 2021-02-10 15:39:37 -07:00
Neil Dorin
08491bdf2a Adds null checks if asset creation fails and returns null 2021-02-10 15:01:40 -07:00
Neil Dorin
f1fa3c07fd #605 Adds try/catch and more meaningful messages when adding static assets fails 2021-02-10 14:15:00 -07:00
Neil Dorin
b19b4ae26e Updated to latest DBs to expose new eCrestronSeries property and adds new property to Global to reflect. Updates startup message to print series 2021-02-09 15:27:32 -07:00
Andrew Welker
7f8215199d update processor type comparisons 2021-02-08 17:29:35 -07:00
Andrew Welker
e782339dcc Merge pull request #601 from PepperDash/hotfix/various-bugs
Hotfix/various bugs
2021-02-08 16:32:51 -07:00
Neil Dorin
766ed3ab51 #588 Updates all room classes to properly set SourceListKey based on precedence 2021-02-08 16:15:17 -07:00
Neil Dorin
cd0e3f7001 #599 Updates how feedbacks are fired in Tx_OnlineStatusChange 2021-02-08 16:11:49 -07:00
Neil Dorin
29d5ecb13f #588 Updates how EssentialsHuddleVtc1Room sets SourceListKey 2021-02-08 16:11:04 -07:00
Neil Dorin
2987f600bb #588 Update to how SourceListKey gets set in EssentialsRoomBase 2021-02-08 16:10:39 -07:00
Neil Dorin
5c23aeca48 Adds missing constructor to take both pacing and capacity arguments 2021-02-08 16:10:08 -07:00
Neil Dorin
6ef8ba3639 Removes redundant .FireUpdate() calls in Tx_OnlineStatusChange 2021-02-08 16:09:50 -07:00
Neil Dorin
4f7ad4ccb9 fixes #599 by checking for registration status before updating feedbacks 2021-02-08 15:43:04 -07:00
Neil Dorin
e03b0dc1bb #600 Adds additional properties and constructors to GenericQueue 2021-02-08 15:06:05 -07:00
Andrew Welker
7eb6748682 Merge pull request #596 from PepperDash/hotfix/dge-device-info
Hotfix/dge device info
2021-02-04 11:41:31 -07:00
Andrew Welker
225c6281b9 Merge branch 'main' into hotfix/dge-device-info 2021-02-04 11:25:10 -07:00
Andrew Welker
249e9f372e Merge pull request #593 from PepperDash/hotfix/occupancy-sensor-debug
Hotfix/occupancy sensor debug
2021-02-04 11:22:30 -07:00
Andrew Welker
4dfab9a287 got DeviceInfo Parsing working correctly 2021-02-04 11:17:49 -07:00
Neil Dorin
ec43749ba4 Tested working with GLS-ODT-C-CN hardware 2021-02-04 11:01:21 -07:00
Neil Dorin
2e4202ccce adjustments made based on testing with hardware 2021-02-04 10:52:02 -07:00
Neil Dorin
4c16dd07b5 fixes #594 with standby state in CiscoSparkCodec 2021-02-04 10:39:29 -07:00
Neil Dorin
0c4ad1c4df Merge branch 'hotfix/occupancy-sensor-debug' of https://github.com/PepperDash/Essentials into hotfix/occupancy-sensor-debug 2021-02-04 09:31:06 -07:00
Neil Dorin
eb90fb343d adds missing condition to set remoteTimeout from config value 2021-02-04 09:30:45 -07:00
Andrew Welker
2967a0f968 turn on dev info and stream debugging for temp client 2021-02-04 08:50:50 -07:00
Andrew Welker
7b2a8b17b7 Merge branch 'main' into hotfix/occupancy-sensor-debug 2021-02-03 21:32:15 -07:00
Neil Dorin
89ca614d3d Minor updates after testing at runtime. 2021-02-03 21:17:27 -07:00
Neil Dorin
355df1341e #592 Adds properties config class for occ sensors 2021-02-03 16:01:24 -07:00
Andrew Welker
504c21204f Merge pull request #590 from PepperDash/hotfix/add-routing-interface
Update RoutingInterfaces.cs
2021-02-03 09:45:24 -07:00
Andrew Welker
8dba5a335b Merge branch 'main' into hotfix/add-routing-interface 2021-02-03 09:15:19 -07:00
Neil Dorin
3d6d578663 Merge pull request #582 from PepperDash/hotfix/stop-internal-samsung-comms-debug
Remove unnecessary debug statements
2021-02-02 16:11:27 -07:00
Andrew Welker
5eb65fd723 Update RoutingInterfaces.cs 2021-02-02 15:30:43 -07:00
jkdevito
e0dcde5c35 Reviewed with AW, decided best to remove console commands and create a public method that can be called using DEVJSON to print current settiings. 2021-02-01 11:10:33 -06:00
jkdevito
c6cfecdbbb Added console command to print occupancy sensor settings in console. 2021-02-01 08:24:54 -06:00
Andrew Welker
30bdac93ee Merge branch 'main' into hotfix/stop-internal-samsung-comms-debug 2021-01-29 16:00:22 -07:00
Andrew Welker
1228431bc2 remove unnecessary debug statements 2021-01-29 14:18:48 -07:00
Andrew Welker
5a2070de3f Merge pull request #580 from PepperDash/hotfix/IrSetTopBoxBase-must-implement-ITvPresetsProvider
Hotfix/ir set top box base must implement i tv presets provider
2021-01-28 16:13:08 -07:00
Andrew Welker
bc1645065c Merge pull request #579 from PepperDash/hotfix/IrSetTopBoxBase-must-implement-ITvPresetsProvider
Implements ITvPresetsProvider on IrSetTopBoxBase
2021-01-28 16:12:22 -07:00
Neil Dorin
21f9795bcd Implements ITvPresetsProvider on IrSetTopBoxBase 2021-01-28 14:05:59 -07:00
Neil Dorin
a69bc94945 Merge pull request #576 from PepperDash/hotfix/fix-queue-priority
Hotfix/fix queue priority
2021-01-27 12:08:04 -07:00
Andrew Welker
864c8ddf77 Merge pull request #575 from PepperDash/hotfix/fix-queue-priority
Set default queue thread priority to medium
2021-01-27 12:04:29 -07:00
Andrew Welker
5764149306 #560 set default queue thread priority to medium 2021-01-27 10:48:23 -07:00
24 changed files with 2099 additions and 1529 deletions

View File

@@ -130,7 +130,7 @@ namespace PepperDash.Essentials
if (CrestronEnvironment.DevicePlatform != eDevicePlatform.Server) // Handles 3-series running Windows CE OS
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on 3-series Appliance", Global.AssemblyVersion);
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on {1} Appliance", Global.AssemblyVersion, Global.ProcessorSeries.ToString());
// Check if User/ProgramX exists
if (Directory.Exists(Global.ApplicationDirectoryPathPrefix + dirSeparator + "User"
@@ -323,7 +323,12 @@ namespace PepperDash.Essentials
// Skip this to prevent unnecessary warnings
if (devConf.Key == "processor")
{
if (devConf.Type.ToLower() != Global.ControlSystem.ControllerPrompt.ToLower())
var prompt = Global.ControlSystem.ControllerPrompt;
var typeMatch = String.Equals(devConf.Type, prompt, StringComparison.OrdinalIgnoreCase) &&
String.Equals(devConf.Type, prompt.Replace("-", ""), StringComparison.OrdinalIgnoreCase);
if (!typeMatch)
Debug.Console(0,
"WARNING: Config file defines processor type as '{0}' but actual processor is '{1}'! Some ports may not be available",
devConf.Type.ToUpper(), Global.ControlSystem.ControllerPrompt.ToUpper());

View File

@@ -30,27 +30,29 @@ namespace PepperDash.Essentials.Fusion
foreach (var display in displays.Values.Cast<DisplayBase>())
{
Debug.Console(2, this, "Setting up Static Asset for {0}", display.Key);
var disp = display; // Local scope variable
display.UsageTracker = new UsageTracking(display) { UsageIsTracked = true };
display.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded;
Debug.Console(2, this, "Setting up Static Asset for {0}", disp.Key);
disp.UsageTracker = new UsageTracking(disp) { UsageIsTracked = true };
disp.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded;
var dispPowerOnAction = new Action<bool>(b =>
{
if (!b)
{
display.PowerOn();
disp.PowerOn();
}
});
var dispPowerOffAction = new Action<bool>(b =>
{
if (!b)
{
display.PowerOff();
disp.PowerOff();
}
});
var deviceConfig = ConfigReader.ConfigObject.GetDeviceForKey(display.Key);
var deviceConfig = ConfigReader.ConfigObject.GetDeviceForKey(disp.Key);
FusionAsset tempAsset;
@@ -63,30 +65,36 @@ namespace PepperDash.Essentials.Fusion
{
// Create a new asset
tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom),
display.Name, "Display", "");
disp.Name, "Display", "");
FusionStaticAssets.Add(deviceConfig.Uid, tempAsset);
}
var dispAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Display",
tempAsset.InstanceId);
dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction;
dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction;
var defaultTwoWayDisplay = display as IHasPowerControlWithFeedback;
if (dispAsset != null)
{
dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction;
dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction;
// Use extension methods
dispAsset.TrySetMakeModel(disp);
dispAsset.TryLinkAssetErrorToCommunication(disp);
}
var defaultTwoWayDisplay = disp as IHasPowerControlWithFeedback;
if (defaultTwoWayDisplay != null)
{
defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig);
if (display is IDisplayUsage)
if (disp is IDisplayUsage)
{
(display as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig);
(disp as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig);
}
defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig);
if(dispAsset != null)
defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig);
}
// Use extension methods
dispAsset.TrySetMakeModel(display);
dispAsset.TryLinkAssetErrorToCommunication(display);
}
}
catch (Exception e)

View File

@@ -274,10 +274,23 @@ namespace PepperDash.Essentials
CallTypeFeedback = new IntFeedback(() => 0);
SourceListKey = "default";
SetSourceListKey();
EnablePowerOnToLastSource = true;
}
private void SetSourceListKey()
{
if (!string.IsNullOrEmpty(PropertiesConfig.SourceListKey))
{
SetSourceListKey(PropertiesConfig.SourceListKey);
}
else
{
SetSourceListKey(Key);
}
}
void InitializeDisplay(DisplayBase disp)
{
if (disp != null)
@@ -333,7 +346,6 @@ namespace PepperDash.Essentials
this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight();
this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark();
this.SourceListKey = PropertiesConfig.SourceListKey;
this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem;
this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100);

View File

@@ -201,11 +201,25 @@ namespace PepperDash.Essentials
IsCoolingDownFeedback.FireUpdate();
};
}
SetSourceListKey();
SourceListKey = "default";
EnablePowerOnToLastSource = true;
}
private void SetSourceListKey()
{
if (!string.IsNullOrEmpty(PropertiesConfig.SourceListKey))
{
SetSourceListKey(PropertiesConfig.SourceListKey);
}
else
{
SetSourceListKey(Key);
}
}
protected override void CustomSetConfig(DeviceConfig config)
{
var newPropertiesConfig = JsonConvert.DeserializeObject<EssentialsHuddleRoomPropertiesConfig>(config.Properties.ToString());
@@ -256,7 +270,6 @@ namespace PepperDash.Essentials
this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight();
this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark();
this.SourceListKey = PropertiesConfig.SourceListKey;
this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem;
this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100);

View File

@@ -51,20 +51,6 @@ namespace PepperDash.Essentials
//************************
public override string SourceListKey
{
get
{
return _SourceListKey;
}
set
{
_SourceListKey = value;
SetCodecExternalSources();
}
}
protected override Func<bool> OnFeedbackFunc
{
get
@@ -338,7 +324,8 @@ namespace PepperDash.Essentials
CallTypeFeedback = new IntFeedback(() => 0);
SourceListKey = "default";
SetSourceListKey();
EnablePowerOnToLastSource = true;
}
catch (Exception e)
@@ -347,6 +334,21 @@ namespace PepperDash.Essentials
}
}
private void SetSourceListKey()
{
if (!string.IsNullOrEmpty(PropertiesConfig.SourceListKey))
{
SetSourceListKey(PropertiesConfig.SourceListKey);
}
else
{
SetSourceListKey(Key);
}
SetCodecExternalSources();
}
protected override void CustomSetConfig(DeviceConfig config)
{
var newPropertiesConfig = JsonConvert.DeserializeObject<EssentialsHuddleVtc1PropertiesConfig>(config.Properties.ToString());
@@ -370,13 +372,14 @@ namespace PepperDash.Essentials
this.LogoUrlLightBkgnd = PropertiesConfig.LogoLight.GetLogoUrlLight();
this.LogoUrlDarkBkgnd = PropertiesConfig.LogoDark.GetLogoUrlDark();
this.SourceListKey = PropertiesConfig.SourceListKey;
this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem;
this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100);
return base.CustomActivate();
}
/// <summary>
///
/// </summary>
@@ -597,12 +600,21 @@ namespace PepperDash.Essentials
if (VideoCodec.UsageTracker.InUseTracker.InUseFeedback.BoolValue)
{
Debug.Console(1, this, "Video Codec in use, deactivating standby on codec");
VideoCodec.StandbyDeactivate();
}
if (VideoCodec.StandbyIsOnFeedback.BoolValue)
{
VideoCodec.StandbyDeactivate();
}
else
{
Debug.Console(1, this, "Video codec not in standby. No need to wake.");
}
}
else
{
Debug.Console(1, this, "Room OnFeedback state: {0}", OnFeedback.BoolValue);
}
// report back when done

View File

@@ -130,6 +130,12 @@ namespace PepperDash.Essentials.Core
void Hardware_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
{
Debug.Console(2, this, "OnlineStatusChange Event. Online = {0}", args.DeviceOnLine);
if (!Hardware.Registered)
{
return; // protects in cases where device has been unregistered and feedbacks would attempt to access null sigs.
}
foreach (var feedback in Feedbacks)
{
if (feedback != null)

View File

@@ -31,7 +31,7 @@ namespace PepperDash.Essentials.Core
/// </summary>
bool HasDpad { get; }
PepperDash.Essentials.Core.Presets.DevicePresetsModel PresetsModel { get; }
PepperDash.Essentials.Core.Presets.DevicePresetsModel TvPresets { get; }
void LoadPresets(string filePath);
void DvrList(bool pressRelease);

View File

@@ -1676,20 +1676,46 @@ namespace PepperDash.Essentials.Core.Fusion
public static FusionStaticAsset CreateStaticAsset(this FusionRoom fr, uint number, string name, string type,
string instanceId)
{
Debug.Console(0, "Adding Fusion Static Asset '{0}' to slot {1} with GUID: '{2}'", name, number, instanceId);
try
{
Debug.Console(0, "Adding Fusion Static Asset '{0}' to slot {1} with GUID: '{2}'", name, number, instanceId);
fr.AddAsset(eAssetType.StaticAsset, number, name, type, instanceId);
return fr.UserConfigurableAssetDetails[number].Asset as FusionStaticAsset;
fr.AddAsset(eAssetType.StaticAsset, number, name, type, instanceId);
return fr.UserConfigurableAssetDetails[number].Asset as FusionStaticAsset;
}
catch (InvalidOperationException ex)
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. /r/nError: {1}", name, ex);
return null;
}
catch (Exception e)
{
Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e);
return null;
}
}
public static FusionOccupancySensor CreateOccupancySensorAsset(this FusionRoom fr, uint number, string name,
string type, string instanceId)
{
Debug.Console(0, "Adding Fusion Occupancy Sensor Asset '{0}' to slot {1} with GUID: '{2}'", name, number,
instanceId);
try
{
Debug.Console(0, "Adding Fusion Occupancy Sensor Asset '{0}' to slot {1} with GUID: '{2}'", name, number,
instanceId);
fr.AddAsset(eAssetType.OccupancySensor, number, name, type, instanceId);
return fr.UserConfigurableAssetDetails[number].Asset as FusionOccupancySensor;
fr.AddAsset(eAssetType.OccupancySensor, number, name, type, instanceId);
return fr.UserConfigurableAssetDetails[number].Asset as FusionOccupancySensor;
}
catch (InvalidOperationException ex)
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. Error: {1}", name, ex);
return null;
}
catch (Exception e)
{
Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e);
return null;
}
}
}

View File

@@ -26,6 +26,8 @@ namespace PepperDash.Essentials.Core
public static LicenseManager LicenseManager { get; set; }
public static eCrestronSeries ProcessorSeries { get { return CrestronEnvironment.ProgramCompatibility; } }
/// <summary>
/// The file path prefix to the folder containing configuration files
/// </summary>

View File

@@ -13,448 +13,586 @@ using PepperDash.Essentials.Core.Bridges;
namespace PepperDash.Essentials.Core
{
[Description("Wrapper class for Single Technology GLS Occupancy Sensors")]
public class GlsOccupancySensorBaseController : CrestronGenericBridgeableBaseDevice, IOccupancyStatusProvider
{
public GlsOccupancySensorBase OccSensor { get; private set; }
[Description("Wrapper class for Single Technology GLS Occupancy Sensors")]
[ConfigSnippet("\"properties\": {\"control\": {\"method\": \"cresnet\",\"cresnetId\": \"97\"},\"enablePir\": true,\"enableLedFlash\": true,\"enableRawStates\":true,\"remoteTimeout\": 30,\"internalPhotoSensorMinChange\": 0,\"externalPhotoSensorMinChange\": 0}")]
public class GlsOccupancySensorBaseController : CrestronGenericBridgeableBaseDevice, IOccupancyStatusProvider
{
public GlsOccupancySensorPropertiesConfig PropertiesConfig { get; private set; }
public BoolFeedback RoomIsOccupiedFeedback { get; private set; }
public GlsOccupancySensorBase OccSensor { get; private set; }
public BoolFeedback GraceOccupancyDetectedFeedback { get; private set; }
public BoolFeedback RoomIsOccupiedFeedback { get; private set; }
public BoolFeedback RawOccupancyFeedback { get; private set; }
public BoolFeedback GraceOccupancyDetectedFeedback { get; private set; }
public BoolFeedback PirSensorEnabledFeedback { get; private set; }
public BoolFeedback RawOccupancyFeedback { get; private set; }
public BoolFeedback LedFlashEnabledFeedback { get; private set; }
public BoolFeedback PirSensorEnabledFeedback { get; private set; }
public BoolFeedback ShortTimeoutEnabledFeedback { get; private set; }
public BoolFeedback LedFlashEnabledFeedback { get; private set; }
public IntFeedback PirSensitivityInVacantStateFeedback { get; private set; }
public BoolFeedback ShortTimeoutEnabledFeedback { get; private set; }
public IntFeedback PirSensitivityInOccupiedStateFeedback { get; private set; }
public IntFeedback PirSensitivityInVacantStateFeedback { get; private set; }
public IntFeedback CurrentTimeoutFeedback { get; private set; }
public IntFeedback PirSensitivityInOccupiedStateFeedback { get; private set; }
public IntFeedback LocalTimoutFeedback { get; private set; }
public IntFeedback CurrentTimeoutFeedback { get; private set; }
public IntFeedback InternalPhotoSensorValue { get; set; }
public IntFeedback LocalTimoutFeedback { get; private set; }
public IntFeedback ExternalPhotoSensorValue { get; set; }
public IntFeedback InternalPhotoSensorValue { get; set; }
// Debug properties
public bool InTestMode { get; private set; }
public IntFeedback ExternalPhotoSensorValue { get; set; }
public bool TestRoomIsOccupiedFeedback { get; private set; }
// Debug properties
public bool InTestMode { get; private set; }
public Func<bool> RoomIsOccupiedFeedbackFunc
{
get
public bool TestRoomIsOccupiedFeedback { get; private set; }
public Func<bool> RoomIsOccupiedFeedbackFunc
{
get
{
return () => InTestMode ? TestRoomIsOccupiedFeedback : OccSensor.OccupancyDetectedFeedback.BoolValue;
}
}
public GlsOccupancySensorBaseController(string key, Func<DeviceConfig, GlsOccupancySensorBase> preActivationFunc,
DeviceConfig config)
: base(key, config.Name)
{
var props = config.Properties.ToObject<GlsOccupancySensorPropertiesConfig>();
if (props != null)
{
return () => InTestMode ? TestRoomIsOccupiedFeedback : OccSensor.OccupancyDetectedFeedback.BoolValue;
}
}
public GlsOccupancySensorBaseController(string key, Func<DeviceConfig, GlsOccupancySensorBase> preActivationFunc,
DeviceConfig config)
: base(key, config.Name)
{
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);
PirSensorEnabledFeedback = new BoolFeedback(() => OccSensor.PirEnabledFeedback.BoolValue);
LedFlashEnabledFeedback = new BoolFeedback(() => OccSensor.LedFlashEnabledFeedback.BoolValue);
ShortTimeoutEnabledFeedback = new BoolFeedback(() => OccSensor.ShortTimeoutEnabledFeedback.BoolValue);
PirSensitivityInVacantStateFeedback =
new IntFeedback(() => OccSensor.PirSensitivityInVacantStateFeedback.UShortValue);
PirSensitivityInOccupiedStateFeedback =
new IntFeedback(() => OccSensor.PirSensitivityInOccupiedStateFeedback.UShortValue);
CurrentTimeoutFeedback = new IntFeedback(() => OccSensor.CurrentTimeoutFeedback.UShortValue);
LocalTimoutFeedback = new IntFeedback(() => OccSensor.LocalTimeoutFeedback.UShortValue);
GraceOccupancyDetectedFeedback =
new BoolFeedback(() => OccSensor.GraceOccupancyDetectedFeedback.BoolValue);
RawOccupancyFeedback = new BoolFeedback(() => OccSensor.RawOccupancyFeedback.BoolValue);
InternalPhotoSensorValue = new IntFeedback(() => OccSensor.InternalPhotoSensorValueFeedback.UShortValue);
ExternalPhotoSensorValue = new IntFeedback(() => OccSensor.ExternalPhotoSensorValueFeedback.UShortValue);
OccSensor.BaseEvent += OccSensor_BaseEvent;
OccSensor.GlsOccupancySensorChange += OccSensor_GlsOccupancySensorChange;
}
/// <summary>
/// Catches events for feedbacks on the base class. Any extending wrapper class should call this delegate after it checks for it's own event IDs.
/// </summary>
/// <param name="device"></param>
/// <param name="args"></param>
protected virtual void OccSensor_GlsOccupancySensorChange(GlsOccupancySensorBase device, GlsOccupancySensorChangeEventArgs args)
{
switch (args.EventId)
{
case GlsOccupancySensorBase.PirEnabledFeedbackEventId:
PirSensorEnabledFeedback.FireUpdate();
break;
case GlsOccupancySensorBase.LedFlashEnabledFeedbackEventId:
LedFlashEnabledFeedback.FireUpdate();
break;
case GlsOccupancySensorBase.ShortTimeoutEnabledFeedbackEventId:
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)
{
Debug.Console(2, this, "GlsOccupancySensorChange EventId: {0}", args.EventId);
switch (args.EventId)
{
case Crestron.SimplSharpPro.GeneralIO.GlsOccupancySensorBase.RoomVacantFeedbackEventId:
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;
}
}
public void SetTestMode(bool mode)
{
InTestMode = mode;
Debug.Console(1, this, "In Mock Mode: '{0}'", InTestMode);
}
public void SetTestOccupiedState(bool state)
{
if (!InTestMode)
Debug.Console(1, "Mock mode not enabled");
else
{
TestRoomIsOccupiedFeedback = state;
RoomIsOccupiedFeedback.FireUpdate();
}
}
/// <summary>
/// Enables or disables the PIR sensor
/// </summary>
/// <param name="state"></param>
public void SetPirEnable(bool state)
{
if (state)
{
OccSensor.EnablePir.BoolValue = state;
OccSensor.DisablePir.BoolValue = !state;
PropertiesConfig = props;
}
else
{
OccSensor.EnablePir.BoolValue = state;
OccSensor.DisablePir.BoolValue = !state;
}
}
/// <summary>
/// Enables or disables the LED Flash
/// </summary>
/// <param name="state"></param>
public void SetLedFlashEnable(bool state)
{
if (state)
{
OccSensor.EnableLedFlash.BoolValue = state;
OccSensor.DisableLedFlash.BoolValue = !state;
}
else
{
OccSensor.EnableLedFlash.BoolValue = state;
OccSensor.DisableLedFlash.BoolValue = !state;
}
}
/// <summary>
/// Enables or disables short timeout based on state
/// </summary>
/// <param name="state"></param>
public void SetShortTimeoutState(bool state)
{
if (state)
{
OccSensor.EnableShortTimeout.BoolValue = state;
OccSensor.DisableShortTimeout.BoolValue = !state;
}
else
{
OccSensor.EnableShortTimeout.BoolValue = state;
OccSensor.DisableShortTimeout.BoolValue = !state;
}
}
public void IncrementPirSensitivityInOccupiedState(bool pressRelease)
{
OccSensor.IncrementPirSensitivityInOccupiedState.BoolValue = pressRelease;
}
public void DecrementPirSensitivityInOccupiedState(bool pressRelease)
{
OccSensor.DecrementPirSensitivityInOccupiedState.BoolValue = pressRelease;
}
public void IncrementPirSensitivityInVacantState(bool pressRelease)
{
OccSensor.IncrementPirSensitivityInVacantState.BoolValue = pressRelease;
}
public void DecrementPirSensitivityInVacantState(bool pressRelease)
{
OccSensor.DecrementPirSensitivityInVacantState.BoolValue = pressRelease;
}
public void ForceOccupied()
{
OccSensor.ForceOccupied.BoolValue = true;
}
public void ForceVacant()
{
OccSensor.ForceVacant.BoolValue = true;
}
public void EnableRawStates(bool state)
{
OccSensor.EnableRawStates.BoolValue = state;
}
public void SetRemoteTimeout(ushort time)
{
OccSensor.RemoteTimeout.UShortValue = time;
}
public void SetInternalPhotoSensorMinChange(ushort value)
{
OccSensor.InternalPhotoSensorMinimumChange.UShortValue = value;
}
public void SetExternalPhotoSensorMinChange(ushort value)
{
OccSensor.ExternalPhotoSensorMinimumChange.UShortValue = value;
}
protected void LinkOccSensorToApi(GlsOccupancySensorBaseController occController, BasicTriList trilist,
uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
var joinMap = new GlsOccupancySensorBaseJoinMap(joinStart);
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<GlsOccupancySensorBaseJoinMap>(joinMapSerialized);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
Debug.Console(1, this, "props are null. Unable to deserialize into GlsOccupancySensorPropertiesConfig");
}
Debug.Console(1, occController, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
AddPreActivationAction(() =>
{
OccSensor = preActivationFunc(config);
#region Single and Dual Sensor Stuff
occController.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);
trilist.StringInput[joinMap.Name.JoinNumber].StringValue = occController.Name;
RegisterCrestronGenericBase(OccSensor);
trilist.OnlineStatusChange += (d, args) =>
RegisterGlsOdtSensorBaseController(OccSensor);
});
AddPostActivationAction(() =>
{
if (args.DeviceOnLine)
OccSensor.OnlineStatusChange += (o, a) =>
{
trilist.StringInput[joinMap.Name.JoinNumber].StringValue = occController.Name;
}
};
if (a.DeviceOnLine)
{
ApplySettingsToSensorFromConfig();
}
};
});
}
// Occupied status
trilist.SetSigTrueAction(joinMap.ForceOccupied.JoinNumber, occController.ForceOccupied);
trilist.SetSigTrueAction(joinMap.ForceVacant.JoinNumber, occController.ForceVacant);
occController.RoomIsOccupiedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RoomOccupiedFeedback.JoinNumber]);
occController.RoomIsOccupiedFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.RoomVacantFeedback.JoinNumber]);
occController.RawOccupancyFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyFeedback.JoinNumber]);
trilist.SetBoolSigAction(joinMap.EnableRawStates.JoinNumber, occController.EnableRawStates);
// Timouts
trilist.SetUShortSigAction(joinMap.Timeout.JoinNumber, occController.SetRemoteTimeout);
occController.CurrentTimeoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.Timeout.JoinNumber]);
occController.LocalTimoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeoutLocalFeedback.JoinNumber]);
// LED Flash
trilist.SetSigTrueAction(joinMap.EnableLedFlash.JoinNumber, () => occController.SetLedFlashEnable(true));
trilist.SetSigTrueAction(joinMap.DisableLedFlash.JoinNumber, () => occController.SetLedFlashEnable(false));
occController.LedFlashEnabledFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.EnableLedFlash.JoinNumber]);
// Short Timeout
trilist.SetSigTrueAction(joinMap.EnableShortTimeout.JoinNumber, () => occController.SetShortTimeoutState(true));
trilist.SetSigTrueAction(joinMap.DisableShortTimeout.JoinNumber, () => occController.SetShortTimeoutState(false));
occController.ShortTimeoutEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableShortTimeout.JoinNumber]);
// PIR Sensor
trilist.SetSigTrueAction(joinMap.EnablePir.JoinNumber, () => occController.SetPirEnable(true));
trilist.SetSigTrueAction(joinMap.DisablePir.JoinNumber, () => occController.SetPirEnable(false));
occController.PirSensorEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnablePir.JoinNumber]);
// PIR Sensitivity in Occupied State
trilist.SetBoolSigAction(joinMap.IncrementPirInOccupiedState.JoinNumber, occController.IncrementPirSensitivityInOccupiedState);
trilist.SetBoolSigAction(joinMap.DecrementPirInOccupiedState.JoinNumber, occController.DecrementPirSensitivityInOccupiedState);
occController.PirSensitivityInOccupiedStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.PirSensitivityInOccupiedState.JoinNumber]);
// PIR Sensitivity in Vacant State
trilist.SetBoolSigAction(joinMap.IncrementPirInVacantState.JoinNumber, occController.IncrementPirSensitivityInVacantState);
trilist.SetBoolSigAction(joinMap.DecrementPirInVacantState.JoinNumber, occController.DecrementPirSensitivityInVacantState);
occController.PirSensitivityInVacantStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.PirSensitivityInVacantState.JoinNumber]);
#endregion
#region Dual Technology Sensor Stuff
var odtOccController = occController as GlsOdtOccupancySensorController;
if (odtOccController == null) return;
// OR When Vacated
trilist.SetBoolSigAction(joinMap.OrWhenVacated.JoinNumber, odtOccController.SetOrWhenVacatedState);
odtOccController.OrWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.OrWhenVacated.JoinNumber]);
// AND When Vacated
trilist.SetBoolSigAction(joinMap.AndWhenVacated.JoinNumber, odtOccController.SetAndWhenVacatedState);
odtOccController.AndWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AndWhenVacated.JoinNumber]);
// Ultrasonic A Sensor
trilist.SetSigTrueAction(joinMap.EnableUsA.JoinNumber, () => odtOccController.SetUsAEnable(true));
trilist.SetSigTrueAction(joinMap.DisableUsA.JoinNumber, () => odtOccController.SetUsAEnable(false));
odtOccController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsA.JoinNumber]);
// Ultrasonic B Sensor
trilist.SetSigTrueAction(joinMap.EnableUsB.JoinNumber, () => odtOccController.SetUsBEnable(true));
trilist.SetSigTrueAction(joinMap.DisableUsB.JoinNumber, () => odtOccController.SetUsBEnable(false));
odtOccController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsB.JoinNumber]);
// US Sensitivity in Occupied State
trilist.SetBoolSigAction(joinMap.IncrementUsInOccupiedState.JoinNumber, odtOccController.IncrementUsSensitivityInOccupiedState);
trilist.SetBoolSigAction(joinMap.DecrementUsInOccupiedState.JoinNumber, odtOccController.DecrementUsSensitivityInOccupiedState);
odtOccController.UltrasonicSensitivityInOccupiedStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.UsSensitivityInOccupiedState.JoinNumber]);
// US Sensitivity in Vacant State
trilist.SetBoolSigAction(joinMap.IncrementUsInVacantState.JoinNumber, odtOccController.IncrementUsSensitivityInVacantState);
trilist.SetBoolSigAction(joinMap.DecrementUsInVacantState.JoinNumber, odtOccController.DecrementUsSensitivityInVacantState);
odtOccController.UltrasonicSensitivityInVacantStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.UsSensitivityInVacantState.JoinNumber]);
//Sensor Raw States
odtOccController.RawOccupancyPirFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyPirFeedback.JoinNumber]);
odtOccController.RawOccupancyUsFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyUsFeedback.JoinNumber]);
#endregion
}
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
public GlsOccupancySensorBaseController(string key, string name, DeviceConfig config)
: base(key, name)
{
LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge);
var props = config.Properties.ToObject<GlsOccupancySensorPropertiesConfig>();
if (props != null)
{
PropertiesConfig = props;
}
else
{
Debug.Console(1, this, "props are null. Unable to deserialize into GlsOccupancySensorPropertiesConfig");
}
AddPostActivationAction(() =>
{
OccSensor.OnlineStatusChange += (o, a) =>
{
if (a.DeviceOnLine)
{
ApplySettingsToSensorFromConfig();
}
};
if (OccSensor.IsOnline)
{
ApplySettingsToSensorFromConfig();
}
});
}
#region PreActivation
private static GlsOirCCn GetGlsOirCCn(DeviceConfig dc)
/// <summary>
/// Applies any sensor settings defined in config
/// </summary>
protected virtual void ApplySettingsToSensorFromConfig()
{
var control = CommFactory.GetControlPropertiesConfig(dc);
var cresnetId = control.CresnetIdInt;
var branchId = control.ControlPortNumber;
var parentKey = string.IsNullOrEmpty(control.ControlPortDevKey) ? "processor" : control.ControlPortDevKey;
Debug.Console(1, this, "Attempting to apply settings to sensor from config");
if (parentKey.Equals("processor", StringComparison.CurrentCultureIgnoreCase))
if (PropertiesConfig.EnablePir != null)
{
Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOirCCn", parentKey);
return new GlsOirCCn(cresnetId, Global.ControlSystem);
Debug.Console(1, this, "EnablePir found, attempting to set value from config");
SetPirEnable((bool)PropertiesConfig.EnablePir);
}
else
{
Debug.Console(1, this, "EnablePir null, no value specified in config");
}
var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches;
if (cresnetBridge != null)
if (PropertiesConfig.EnableLedFlash != null)
{
Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOirCCn", parentKey);
return new GlsOirCCn(cresnetId, cresnetBridge.CresnetBranches[branchId]);
Debug.Console(1, this, "EnableLedFlash found, attempting to set value from config");
SetLedFlashEnable((bool)PropertiesConfig.EnableLedFlash);
}
if (PropertiesConfig.RemoteTimeout != null)
{
Debug.Console(1, this, "RemoteTimeout found, attempting to set value from config");
SetRemoteTimeout((ushort)PropertiesConfig.RemoteTimeout);
}
else
{
Debug.Console(1, this, "RemoteTimeout null, no value specified in config");
}
if (PropertiesConfig.ShortTimeoutState != null)
{
SetShortTimeoutState((bool)PropertiesConfig.ShortTimeoutState);
}
if (PropertiesConfig.EnableRawStates != null)
{
EnableRawStates((bool)PropertiesConfig.EnableRawStates);
}
if (PropertiesConfig.InternalPhotoSensorMinChange != null)
{
SetInternalPhotoSensorMinChange((ushort)PropertiesConfig.InternalPhotoSensorMinChange);
}
if (PropertiesConfig.ExternalPhotoSensorMinChange != null)
{
SetExternalPhotoSensorMinChange((ushort)PropertiesConfig.ExternalPhotoSensorMinChange);
}
Debug.Console(0, "Device {0} is not a valid cresnet master", parentKey);
return null;
}
#endregion
public class GlsOccupancySensorBaseControllerFactory : EssentialsDeviceFactory<GlsOccupancySensorBaseController>
{
public GlsOccupancySensorBaseControllerFactory()
{
TypeNames = new List<string>() { "glsoirccn" };
}
protected void RegisterGlsOdtSensorBaseController(GlsOccupancySensorBase occSensor)
{
OccSensor = occSensor;
RoomIsOccupiedFeedback = new BoolFeedback(RoomIsOccupiedFeedbackFunc);
PirSensorEnabledFeedback = new BoolFeedback(() => OccSensor.PirEnabledFeedback.BoolValue);
LedFlashEnabledFeedback = new BoolFeedback(() => OccSensor.LedFlashEnabledFeedback.BoolValue);
ShortTimeoutEnabledFeedback = new BoolFeedback(() => OccSensor.ShortTimeoutEnabledFeedback.BoolValue);
PirSensitivityInVacantStateFeedback =
new IntFeedback(() => OccSensor.PirSensitivityInVacantStateFeedback.UShortValue);
PirSensitivityInOccupiedStateFeedback =
new IntFeedback(() => OccSensor.PirSensitivityInOccupiedStateFeedback.UShortValue);
CurrentTimeoutFeedback = new IntFeedback(() => OccSensor.CurrentTimeoutFeedback.UShortValue);
LocalTimoutFeedback = new IntFeedback(() => OccSensor.LocalTimeoutFeedback.UShortValue);
GraceOccupancyDetectedFeedback =
new BoolFeedback(() => OccSensor.GraceOccupancyDetectedFeedback.BoolValue);
RawOccupancyFeedback = new BoolFeedback(() => OccSensor.RawOccupancyFeedback.BoolValue);
InternalPhotoSensorValue = new IntFeedback(() => OccSensor.InternalPhotoSensorValueFeedback.UShortValue);
ExternalPhotoSensorValue = new IntFeedback(() => OccSensor.ExternalPhotoSensorValueFeedback.UShortValue);
OccSensor.BaseEvent += OccSensor_BaseEvent;
OccSensor.GlsOccupancySensorChange += OccSensor_GlsOccupancySensorChange;
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device");
/// <summary>
/// Catches events for feedbacks on the base class. Any extending wrapper class should call this delegate after it checks for it's own event IDs.
/// </summary>
/// <param name="device"></param>
/// <param name="args"></param>
protected virtual void OccSensor_GlsOccupancySensorChange(GlsOccupancySensorBase device, GlsOccupancySensorChangeEventArgs args)
{
switch (args.EventId)
{
case GlsOccupancySensorBase.PirEnabledFeedbackEventId:
PirSensorEnabledFeedback.FireUpdate();
break;
case GlsOccupancySensorBase.LedFlashEnabledFeedbackEventId:
LedFlashEnabledFeedback.FireUpdate();
break;
case GlsOccupancySensorBase.ShortTimeoutEnabledFeedbackEventId:
ShortTimeoutEnabledFeedback.FireUpdate();
break;
case GlsOccupancySensorBase.PirSensitivityInOccupiedStateFeedbackEventId:
PirSensitivityInOccupiedStateFeedback.FireUpdate();
break;
case GlsOccupancySensorBase.PirSensitivityInVacantStateFeedbackEventId:
PirSensitivityInVacantStateFeedback.FireUpdate();
break;
}
}
return new GlsOccupancySensorBaseController(dc.Key, GetGlsOirCCn, dc);
}
protected virtual void OccSensor_BaseEvent(Crestron.SimplSharpPro.GenericBase device, Crestron.SimplSharpPro.BaseEventArgs args)
{
Debug.Console(2, this, "GlsOccupancySensorChange EventId: {0}", args.EventId);
switch (args.EventId)
{
case Crestron.SimplSharpPro.GeneralIO.GlsOccupancySensorBase.RoomVacantFeedbackEventId:
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;
}
}
public void SetTestMode(bool mode)
{
InTestMode = mode;
Debug.Console(1, this, "In Mock Mode: '{0}'", InTestMode);
}
public void SetTestOccupiedState(bool state)
{
if (!InTestMode)
Debug.Console(1, "Mock mode not enabled");
else
{
TestRoomIsOccupiedFeedback = state;
RoomIsOccupiedFeedback.FireUpdate();
}
}
/// <summary>
/// Enables or disables the PIR sensor
/// </summary>
/// <param name="state"></param>
public void SetPirEnable(bool state)
{
Debug.Console(1, this, "Setting EnablePir to: {0}", state);
if (state)
{
OccSensor.EnablePir.BoolValue = state;
OccSensor.DisablePir.BoolValue = !state;
}
else
{
OccSensor.EnablePir.BoolValue = state;
OccSensor.DisablePir.BoolValue = !state;
}
}
/// <summary>
/// Enables or disables the LED Flash
/// </summary>
/// <param name="state"></param>
public void SetLedFlashEnable(bool state)
{
if (state)
{
OccSensor.EnableLedFlash.BoolValue = state;
OccSensor.DisableLedFlash.BoolValue = !state;
}
else
{
OccSensor.EnableLedFlash.BoolValue = state;
OccSensor.DisableLedFlash.BoolValue = !state;
}
}
/// <summary>
/// Enables or disables short timeout based on state
/// </summary>
/// <param name="state"></param>
public void SetShortTimeoutState(bool state)
{
if (state)
{
OccSensor.EnableShortTimeout.BoolValue = state;
OccSensor.DisableShortTimeout.BoolValue = !state;
}
else
{
OccSensor.EnableShortTimeout.BoolValue = state;
OccSensor.DisableShortTimeout.BoolValue = !state;
}
}
public void IncrementPirSensitivityInOccupiedState(bool pressRelease)
{
OccSensor.IncrementPirSensitivityInOccupiedState.BoolValue = pressRelease;
}
public void DecrementPirSensitivityInOccupiedState(bool pressRelease)
{
OccSensor.DecrementPirSensitivityInOccupiedState.BoolValue = pressRelease;
}
public void IncrementPirSensitivityInVacantState(bool pressRelease)
{
OccSensor.IncrementPirSensitivityInVacantState.BoolValue = pressRelease;
}
public void DecrementPirSensitivityInVacantState(bool pressRelease)
{
OccSensor.DecrementPirSensitivityInVacantState.BoolValue = pressRelease;
}
public void ForceOccupied()
{
OccSensor.ForceOccupied.BoolValue = true;
}
public void ForceVacant()
{
OccSensor.ForceVacant.BoolValue = true;
}
public void EnableRawStates(bool state)
{
OccSensor.EnableRawStates.BoolValue = state;
}
public void SetRemoteTimeout(ushort time)
{
Debug.Console(1, this, "Setting RemoteTimout to: {0}", time);
OccSensor.RemoteTimeout.UShortValue = time;
}
public void SetInternalPhotoSensorMinChange(ushort value)
{
OccSensor.InternalPhotoSensorMinimumChange.UShortValue = value;
}
public void SetExternalPhotoSensorMinChange(ushort value)
{
OccSensor.ExternalPhotoSensorMinimumChange.UShortValue = value;
}
/// <summary>
/// Method to print current occ settings to console.
/// </summary>
/// <param name="key"></param>
public virtual void GetSettings()
{
var dash = new string('*', 50);
CrestronConsole.PrintLine(string.Format("{0}\n", dash));
Debug.Console(0, this, "Vacancy Detected: {0}",
OccSensor.VacancyDetectedFeedback.BoolValue);
Debug.Console(0, this, "Timeout Current: {0} | Local: {1}",
OccSensor.CurrentTimeoutFeedback.UShortValue,
OccSensor.LocalTimeoutFeedback.UShortValue);
Debug.Console(0, this, "Short Timeout Enabled: {0}",
OccSensor.ShortTimeoutEnabledFeedback.BoolValue);
Debug.Console(0, this, "PIR Sensor Enabled: {0} | Sensitivity Occupied: {1} | Sensitivity Vacant: {2}",
OccSensor.PirEnabledFeedback.BoolValue,
OccSensor.PirSensitivityInOccupiedStateFeedback.UShortValue,
OccSensor.PirSensitivityInVacantStateFeedback.UShortValue);
CrestronConsole.PrintLine(string.Format("{0}\n", dash));
}
protected void LinkOccSensorToApi(GlsOccupancySensorBaseController occController, BasicTriList trilist,
uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
var joinMap = new GlsOccupancySensorBaseJoinMap(joinStart);
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<GlsOccupancySensorBaseJoinMap>(joinMapSerialized);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
Debug.Console(1, occController, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
#region Single and Dual Sensor Stuff
occController.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);
trilist.StringInput[joinMap.Name.JoinNumber].StringValue = occController.Name;
trilist.OnlineStatusChange += (d, args) =>
{
if (args.DeviceOnLine)
{
trilist.StringInput[joinMap.Name.JoinNumber].StringValue = occController.Name;
}
};
// Occupied status
trilist.SetSigTrueAction(joinMap.ForceOccupied.JoinNumber, occController.ForceOccupied);
trilist.SetSigTrueAction(joinMap.ForceVacant.JoinNumber, occController.ForceVacant);
occController.RoomIsOccupiedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RoomOccupiedFeedback.JoinNumber]);
occController.RoomIsOccupiedFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.RoomVacantFeedback.JoinNumber]);
occController.RawOccupancyFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyFeedback.JoinNumber]);
trilist.SetBoolSigAction(joinMap.EnableRawStates.JoinNumber, occController.EnableRawStates);
// Timouts
trilist.SetUShortSigAction(joinMap.Timeout.JoinNumber, occController.SetRemoteTimeout);
occController.CurrentTimeoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.Timeout.JoinNumber]);
occController.LocalTimoutFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeoutLocalFeedback.JoinNumber]);
// LED Flash
trilist.SetSigTrueAction(joinMap.EnableLedFlash.JoinNumber, () => occController.SetLedFlashEnable(true));
trilist.SetSigTrueAction(joinMap.DisableLedFlash.JoinNumber, () => occController.SetLedFlashEnable(false));
occController.LedFlashEnabledFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.EnableLedFlash.JoinNumber]);
// Short Timeout
trilist.SetSigTrueAction(joinMap.EnableShortTimeout.JoinNumber, () => occController.SetShortTimeoutState(true));
trilist.SetSigTrueAction(joinMap.DisableShortTimeout.JoinNumber, () => occController.SetShortTimeoutState(false));
occController.ShortTimeoutEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableShortTimeout.JoinNumber]);
// PIR Sensor
trilist.SetSigTrueAction(joinMap.EnablePir.JoinNumber, () => occController.SetPirEnable(true));
trilist.SetSigTrueAction(joinMap.DisablePir.JoinNumber, () => occController.SetPirEnable(false));
occController.PirSensorEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnablePir.JoinNumber]);
// PIR Sensitivity in Occupied State
trilist.SetBoolSigAction(joinMap.IncrementPirInOccupiedState.JoinNumber, occController.IncrementPirSensitivityInOccupiedState);
trilist.SetBoolSigAction(joinMap.DecrementPirInOccupiedState.JoinNumber, occController.DecrementPirSensitivityInOccupiedState);
occController.PirSensitivityInOccupiedStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.PirSensitivityInOccupiedState.JoinNumber]);
// PIR Sensitivity in Vacant State
trilist.SetBoolSigAction(joinMap.IncrementPirInVacantState.JoinNumber, occController.IncrementPirSensitivityInVacantState);
trilist.SetBoolSigAction(joinMap.DecrementPirInVacantState.JoinNumber, occController.DecrementPirSensitivityInVacantState);
occController.PirSensitivityInVacantStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.PirSensitivityInVacantState.JoinNumber]);
#endregion
#region Dual Technology Sensor Stuff
var odtOccController = occController as GlsOdtOccupancySensorController;
if (odtOccController == null) return;
// OR When Vacated
trilist.SetBoolSigAction(joinMap.OrWhenVacated.JoinNumber, odtOccController.SetOrWhenVacatedState);
odtOccController.OrWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.OrWhenVacated.JoinNumber]);
// AND When Vacated
trilist.SetBoolSigAction(joinMap.AndWhenVacated.JoinNumber, odtOccController.SetAndWhenVacatedState);
odtOccController.AndWhenVacatedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AndWhenVacated.JoinNumber]);
// Ultrasonic A Sensor
trilist.SetSigTrueAction(joinMap.EnableUsA.JoinNumber, () => odtOccController.SetUsAEnable(true));
trilist.SetSigTrueAction(joinMap.DisableUsA.JoinNumber, () => odtOccController.SetUsAEnable(false));
odtOccController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsA.JoinNumber]);
// Ultrasonic B Sensor
trilist.SetSigTrueAction(joinMap.EnableUsB.JoinNumber, () => odtOccController.SetUsBEnable(true));
trilist.SetSigTrueAction(joinMap.DisableUsB.JoinNumber, () => odtOccController.SetUsBEnable(false));
odtOccController.UltrasonicAEnabledFeedback.LinkInputSig(trilist.BooleanInput[joinMap.EnableUsB.JoinNumber]);
// US Sensitivity in Occupied State
trilist.SetBoolSigAction(joinMap.IncrementUsInOccupiedState.JoinNumber, odtOccController.IncrementUsSensitivityInOccupiedState);
trilist.SetBoolSigAction(joinMap.DecrementUsInOccupiedState.JoinNumber, odtOccController.DecrementUsSensitivityInOccupiedState);
odtOccController.UltrasonicSensitivityInOccupiedStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.UsSensitivityInOccupiedState.JoinNumber]);
// US Sensitivity in Vacant State
trilist.SetBoolSigAction(joinMap.IncrementUsInVacantState.JoinNumber, odtOccController.IncrementUsSensitivityInVacantState);
trilist.SetBoolSigAction(joinMap.DecrementUsInVacantState.JoinNumber, odtOccController.DecrementUsSensitivityInVacantState);
odtOccController.UltrasonicSensitivityInVacantStateFeedback.LinkInputSig(trilist.UShortInput[joinMap.UsSensitivityInVacantState.JoinNumber]);
//Sensor Raw States
odtOccController.RawOccupancyPirFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyPirFeedback.JoinNumber]);
odtOccController.RawOccupancyUsFeedback.LinkInputSig(trilist.BooleanInput[joinMap.RawOccupancyUsFeedback.JoinNumber]);
#endregion
}
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge);
}
#region PreActivation
private static GlsOirCCn GetGlsOirCCn(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 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 class GlsOccupancySensorBaseControllerFactory : EssentialsDeviceFactory<GlsOccupancySensorBaseController>
{
public GlsOccupancySensorBaseControllerFactory()
{
TypeNames = new List<string>() { "glsoirccn" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device");
return new GlsOccupancySensorBaseController(dc.Key, GetGlsOirCCn, dc);
}
}
}
}
}
}

View File

@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json;
namespace PepperDash.Essentials.Core
{
/// <summary>
/// Defines configuration properties for Crestron GLS series occupancy sensors
/// </summary>
public class GlsOccupancySensorPropertiesConfig
{
// Single Technology Sensors (PIR): GlsOccupancySensorBase
[JsonProperty("enablePir")]
public bool? EnablePir { get; set; }
[JsonProperty("enableLedFlash")]
public bool? EnableLedFlash { get; set; }
[JsonProperty("shortTimeoutState")]
public bool? ShortTimeoutState { get; set; }
[JsonProperty("enableRawStates")]
public bool? EnableRawStates { get; set; }
[JsonProperty("remoteTimeout")]
public ushort? RemoteTimeout { get; set; }
[JsonProperty("internalPhotoSensorMinChange")]
public ushort? InternalPhotoSensorMinChange { get; set; }
[JsonProperty("externalPhotoSensorMinChange")]
public ushort? ExternalPhotoSensorMinChange { get; set; }
// Dual Technology Sensors: GlsOdtCCn
[JsonProperty("enableUsA")]
public bool? EnableUsA { get; set; }
[JsonProperty("enableUsB")]
public bool? EnableUsB { get; set; }
[JsonProperty("orWhenVacatedState")]
public bool? OrWhenVacatedState { get; set; }
[JsonProperty("andWhenVacatedState")]
public bool? AndWhenVacatedState { get; set; }
}
}

View File

@@ -13,206 +13,266 @@ using PepperDash.Essentials.Core.Bridges;
namespace PepperDash.Essentials.Core
{
[Description("Wrapper class for Dual Technology GLS Occupancy Sensors")]
[Description("Wrapper class for Dual Technology GLS Occupancy Sensors")]
[ConfigSnippet("\"properties\": {\"control\": {\"method\": \"cresnet\",\"cresnetId\": \"97\"},\"enablePir\": true,\"enableLedFlash\": true,\"enableRawStates\":true,\"remoteTimeout\": 30,\"internalPhotoSensorMinChange\": 0,\"externalPhotoSensorMinChange\": 0,\"enableUsA\": true,\"enableUsB\": true,\"orWhenVacatedState\": true}")]
public class GlsOdtOccupancySensorController : GlsOccupancySensorBaseController
{
public new GlsOdtCCn OccSensor { get; private set; }
{
public new GlsOdtCCn OccSensor { get; private set; }
public BoolFeedback OrWhenVacatedFeedback { get; private set; }
public BoolFeedback OrWhenVacatedFeedback { get; private set; }
public BoolFeedback AndWhenVacatedFeedback { get; private set; }
public BoolFeedback AndWhenVacatedFeedback { get; private set; }
public BoolFeedback UltrasonicAEnabledFeedback { get; private set; }
public BoolFeedback UltrasonicAEnabledFeedback { get; private set; }
public BoolFeedback UltrasonicBEnabledFeedback { get; private set; }
public BoolFeedback UltrasonicBEnabledFeedback { get; private set; }
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 RawOccupancyPirFeedback { get; private set; }
public BoolFeedback RawOccupancyUsFeedback { get; private set; }
public BoolFeedback RawOccupancyUsFeedback { get; private set; }
public GlsOdtOccupancySensorController(string key, Func<DeviceConfig, GlsOdtCCn> preActivationFunc,
DeviceConfig config)
: base(key, config.Name)
public GlsOdtOccupancySensorController(string key, Func<DeviceConfig, GlsOdtCCn> preActivationFunc,
DeviceConfig config)
: base(key, config.Name, config)
{
AddPreActivationAction(() =>
{
OccSensor = preActivationFunc(config);
RegisterCrestronGenericBase(OccSensor);
RegisterGlsOdtSensorBaseController(OccSensor);
AndWhenVacatedFeedback = new BoolFeedback(() => OccSensor.AndWhenVacatedFeedback.BoolValue);
OrWhenVacatedFeedback = new BoolFeedback(() => OccSensor.OrWhenVacatedFeedback.BoolValue);
UltrasonicAEnabledFeedback = new BoolFeedback(() => OccSensor.UsAEnabledFeedback.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);
UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInOccupiedStateFeedback.UShortValue);
});
}
protected override void ApplySettingsToSensorFromConfig()
{
AddPreActivationAction(() =>
base.ApplySettingsToSensorFromConfig();
if (PropertiesConfig.EnableUsA != null)
{
OccSensor = preActivationFunc(config);
RegisterCrestronGenericBase(OccSensor);
RegisterGlsOdtSensorBaseController(OccSensor);
AndWhenVacatedFeedback = new BoolFeedback(() => OccSensor.AndWhenVacatedFeedback.BoolValue);
OrWhenVacatedFeedback = new BoolFeedback(() => OccSensor.OrWhenVacatedFeedback.BoolValue);
UltrasonicAEnabledFeedback = new BoolFeedback(() => OccSensor.UsAEnabledFeedback.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);
UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInOccupiedStateFeedback.UShortValue);
});
}
/// <summary>
/// Overrides the base class event delegate to fire feedbacks for event IDs that pertain to this extended class.
/// Then calls the base delegate method to ensure any common event IDs are captured.
/// </summary>
/// <param name="device"></param>
/// <param name="args"></param>
protected override void OccSensor_GlsOccupancySensorChange(GlsOccupancySensorBase device, GlsOccupancySensorChangeEventArgs args)
{
if (args.EventId == GlsOccupancySensorBase.AndWhenVacatedFeedbackEventId)
AndWhenVacatedFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.OrWhenVacatedFeedbackEventId)
OrWhenVacatedFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.UsAEnabledFeedbackEventId)
UltrasonicAEnabledFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.UsBEnabledFeedbackEventId)
UltrasonicBEnabledFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.UsSensitivityInOccupiedStateFeedbackEventId)
UltrasonicSensitivityInOccupiedStateFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.UsSensitivityInVacantStateFeedbackEventId)
UltrasonicSensitivityInVacantStateFeedback.FireUpdate();
base.OccSensor_GlsOccupancySensorChange(device, args);
}
/// <summary>
/// Overrides the base class event delegate to fire feedbacks for event IDs that pertain to this extended class.
/// Then calls the base delegate method to ensure any common event IDs are captured.
/// </summary>
/// <param name="device"></param>
/// <param name="args"></param>
protected override void OccSensor_BaseEvent(Crestron.SimplSharpPro.GenericBase device, Crestron.SimplSharpPro.BaseEventArgs args)
{
if (args.EventId == GlsOccupancySensorBase.RawOccupancyPirFeedbackEventId)
RawOccupancyPirFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.RawOccupancyUsFeedbackEventId)
RawOccupancyUsFeedback.FireUpdate();
base.OccSensor_BaseEvent(device, args);
}
/// <summary>
/// Sets the OrWhenVacated state
/// </summary>
/// <param name="state"></param>
public void SetOrWhenVacatedState(bool state)
{
OccSensor.OrWhenVacated.BoolValue = state;
}
/// <summary>
/// Sets the AndWhenVacated state
/// </summary>
/// <param name="state"></param>
public void SetAndWhenVacatedState(bool state)
{
OccSensor.AndWhenVacated.BoolValue = state;
}
/// <summary>
/// Enables or disables the Ultrasonic A sensor
/// </summary>
/// <param name="state"></param>
public void SetUsAEnable(bool state)
{
OccSensor.EnableUsA.BoolValue = state;
OccSensor.DisableUsA.BoolValue = !state;
}
/// <summary>
/// Enables or disables the Ultrasonic B sensor
/// </summary>
/// <param name="state"></param>
public void SetUsBEnable(bool state)
{
OccSensor.EnableUsB.BoolValue = state;
OccSensor.DisableUsB.BoolValue = !state;
}
public void IncrementUsSensitivityInOccupiedState(bool pressRelease)
{
OccSensor.IncrementUsSensitivityInOccupiedState.BoolValue = pressRelease;
}
public void DecrementUsSensitivityInOccupiedState(bool pressRelease)
{
OccSensor.DecrementUsSensitivityInOccupiedState.BoolValue = pressRelease;
}
public void IncrementUsSensitivityInVacantState(bool pressRelease)
{
OccSensor.IncrementUsSensitivityInVacantState.BoolValue = pressRelease;
}
public void DecrementUsSensitivityInVacantState(bool pressRelease)
{
OccSensor.DecrementUsSensitivityInVacantState.BoolValue = pressRelease;
}
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge);
}
#region PreActivation
private static GlsOdtCCn GetGlsOdtCCn(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 GlsOdtCCn", parentKey);
return new GlsOdtCCn(cresnetId, Global.ControlSystem);
Debug.Console(1, this, "EnableUsA found, attempting to set value from config");
SetUsAEnable((bool)PropertiesConfig.EnableUsA);
}
var cresnetBridge = DeviceManager.GetDeviceForKey(parentKey) as IHasCresnetBranches;
if (cresnetBridge != null)
else
{
Debug.Console(0, "Device {0} is a valid cresnet master - creating new GlsOdtCCn", parentKey);
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" };
Debug.Console(1, this, "EnableUsA null, no value specified in config");
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
if (PropertiesConfig.EnableUsB != null)
{
Debug.Console(1, "Factory Attempting to create new GlsOccupancySensorBaseController Device");
return new GlsOdtOccupancySensorController(dc.Key, GetGlsOdtCCn, dc);
Debug.Console(1, this, "EnableUsB found, attempting to set value from config");
SetUsBEnable((bool)PropertiesConfig.EnableUsB);
}
else
{
Debug.Console(1, this, "EnablePir null, no value specified in config");
}
if (PropertiesConfig.OrWhenVacatedState != null)
{
SetOrWhenVacatedState((bool)PropertiesConfig.OrWhenVacatedState);
}
if (PropertiesConfig.AndWhenVacatedState != null)
{
SetAndWhenVacatedState((bool)PropertiesConfig.AndWhenVacatedState);
}
}
}
/// <summary>
/// Overrides the base class event delegate to fire feedbacks for event IDs that pertain to this extended class.
/// Then calls the base delegate method to ensure any common event IDs are captured.
/// </summary>
/// <param name="device"></param>
/// <param name="args"></param>
protected override void OccSensor_GlsOccupancySensorChange(GlsOccupancySensorBase device, GlsOccupancySensorChangeEventArgs args)
{
if (args.EventId == GlsOccupancySensorBase.AndWhenVacatedFeedbackEventId)
AndWhenVacatedFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.OrWhenVacatedFeedbackEventId)
OrWhenVacatedFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.UsAEnabledFeedbackEventId)
UltrasonicAEnabledFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.UsBEnabledFeedbackEventId)
UltrasonicBEnabledFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.UsSensitivityInOccupiedStateFeedbackEventId)
UltrasonicSensitivityInOccupiedStateFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.UsSensitivityInVacantStateFeedbackEventId)
UltrasonicSensitivityInVacantStateFeedback.FireUpdate();
base.OccSensor_GlsOccupancySensorChange(device, args);
}
/// <summary>
/// Overrides the base class event delegate to fire feedbacks for event IDs that pertain to this extended class.
/// Then calls the base delegate method to ensure any common event IDs are captured.
/// </summary>
/// <param name="device"></param>
/// <param name="args"></param>
protected override void OccSensor_BaseEvent(Crestron.SimplSharpPro.GenericBase device, Crestron.SimplSharpPro.BaseEventArgs args)
{
if (args.EventId == GlsOccupancySensorBase.RawOccupancyPirFeedbackEventId)
RawOccupancyPirFeedback.FireUpdate();
else if (args.EventId == GlsOccupancySensorBase.RawOccupancyUsFeedbackEventId)
RawOccupancyUsFeedback.FireUpdate();
base.OccSensor_BaseEvent(device, args);
}
/// <summary>
/// Sets the OrWhenVacated state
/// </summary>
/// <param name="state"></param>
public void SetOrWhenVacatedState(bool state)
{
OccSensor.OrWhenVacated.BoolValue = state;
}
/// <summary>
/// Sets the AndWhenVacated state
/// </summary>
/// <param name="state"></param>
public void SetAndWhenVacatedState(bool state)
{
OccSensor.AndWhenVacated.BoolValue = state;
}
/// <summary>
/// Enables or disables the Ultrasonic A sensor
/// </summary>
/// <param name="state"></param>
public void SetUsAEnable(bool state)
{
OccSensor.EnableUsA.BoolValue = state;
OccSensor.DisableUsA.BoolValue = !state;
}
/// <summary>
/// Enables or disables the Ultrasonic B sensor
/// </summary>
/// <param name="state"></param>
public void SetUsBEnable(bool state)
{
OccSensor.EnableUsB.BoolValue = state;
OccSensor.DisableUsB.BoolValue = !state;
}
public void IncrementUsSensitivityInOccupiedState(bool pressRelease)
{
OccSensor.IncrementUsSensitivityInOccupiedState.BoolValue = pressRelease;
}
public void DecrementUsSensitivityInOccupiedState(bool pressRelease)
{
OccSensor.DecrementUsSensitivityInOccupiedState.BoolValue = pressRelease;
}
public void IncrementUsSensitivityInVacantState(bool pressRelease)
{
OccSensor.IncrementUsSensitivityInVacantState.BoolValue = pressRelease;
}
public void DecrementUsSensitivityInVacantState(bool pressRelease)
{
OccSensor.DecrementUsSensitivityInVacantState.BoolValue = pressRelease;
}
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge);
}
/// <summary>
/// Method to print occ sensor settings to console.
/// </summary>
public override void GetSettings()
{
base.GetSettings();
Debug.Console(0, this, "Ultrasonic Enabled A: {0} | B: {1}",
OccSensor.UsAEnabledFeedback.BoolValue,
OccSensor.UsBEnabledFeedback.BoolValue);
Debug.Console(0, this, "Ultrasonic Sensitivity Occupied: {0} | Vacant: {1}",
OccSensor.UsSensitivityInOccupiedStateFeedback.UShortValue,
OccSensor.UsSensitivityInVacantStateFeedback.UShortValue);
var dash = new string('*', 50);
CrestronConsole.PrintLine(string.Format("{0}\n", dash));
}
#region PreActivation
private static GlsOdtCCn GetGlsOdtCCn(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 GlsOdtCCn", parentKey);
return new GlsOdtCCn(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 GlsOdtCCn", parentKey);
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);
}
}
}

View File

@@ -227,6 +227,7 @@
<Compile Include="Global\EthernetAdapterInfo.cs" />
<Compile Include="Interfaces\ILogStrings.cs" />
<Compile Include="Interfaces\ILogStringsWithLevel.cs" />
<Compile Include="Occupancy\GlsOccupancySensorPropertiesConfig.cs" />
<Compile Include="Queues\ComsMessage.cs" />
<Compile Include="Queues\ProcessStringMessage.cs" />
<Compile Include="Queues\GenericQueue.cs" />

View File

@@ -18,41 +18,52 @@ namespace PepperDash_Essentials_Core.Queues
private bool _delayEnabled;
private int _delayTime;
private const Thread.eThreadPriority _defaultPriority = Thread.eThreadPriority.MediumPriority;
/// <summary>
/// If the instance has been disposed.
/// </summary>
public bool Disposed { get; private set; }
/// <summary>
/// Returns the capacity of the CrestronQueue (fixed Size property)
/// </summary>
public int QueueCapacity
{
get
{
return _queue.Size;
}
}
/// <summary>
/// Returns the number of elements currently in the CrestronQueue
/// </summary>
public int QueueCount
{
get
{
return _queue.Count;
}
}
/// <summary>
/// Constructor with no thread priority
/// </summary>
/// <param name="key"></param>
public GenericQueue(string key)
: this(key, Thread.eThreadPriority.NotSet)
: this(key, _defaultPriority, 0, 0)
{
}
/// <summary>
/// Constructor for generic queue with no pacing
/// Constructor with queue size
/// </summary>
/// <param name="key">Key</param>
public GenericQueue(string key, Thread.eThreadPriority priority)
/// <param name="key"></param>
/// <param name="capacity">Fixed size for the queue to hold</param>
public GenericQueue(string key, int capacity)
: this(key, _defaultPriority, capacity, 0)
{
_key = key;
_queue = new CrestronQueue<IQueueMessage>(25);
_worker = new Thread(ProcessQueue, null, Thread.eThreadStartOptions.Running)
{
Priority = priority
};
CrestronEnvironment.ProgramStatusEventHandler += programEvent =>
{
if (programEvent != eProgramStatusEventType.Stopping)
return;
Dispose();
};
}
/// <summary>
@@ -60,10 +71,20 @@ namespace PepperDash_Essentials_Core.Queues
/// </summary>
/// <param name="key">Key</param>
/// <param name="pacing">Pacing in ms between actions</param>
public GenericQueue(string key, int pacing)
: this(key)
public GenericQueue(int pacing, string key)
: this(key, _defaultPriority, 0, pacing)
{
}
/// <summary>
/// Constructor with pacing and capacity
/// </summary>
/// <param name="key"></param>
/// <param name="pacing"></param>
/// <param name="capacity"></param>
public GenericQueue(string key, int pacing, int capacity)
: this(key, _defaultPriority, capacity, pacing)
{
SetDelayValues(pacing);
}
/// <summary>
@@ -73,8 +94,52 @@ namespace PepperDash_Essentials_Core.Queues
/// <param name="pacing"></param>
/// <param name="priority"></param>
public GenericQueue(string key, int pacing, Thread.eThreadPriority priority)
: this(key, priority)
: this(key, priority, 0, pacing)
{
}
/// <summary>
/// Constructor with pacing, priority and capacity
/// </summary>
/// <param name="key"></param>
/// <param name="priority"></param>
/// <param name="capacity"></param>
public GenericQueue(string key, Thread.eThreadPriority priority, int capacity)
: this(key, priority, capacity, 0)
{
}
/// <summary>
/// Constructor with pacing, priority and capacity
/// </summary>
/// <param name="key"></param>
/// <param name="pacing"></param>
/// <param name="priority"></param>
/// <param name="capacity"></param>
public GenericQueue(string key, int pacing, Thread.eThreadPriority priority, int capacity)
: this(key, priority, capacity, pacing)
{
}
/// <summary>
/// Constructor for generic queue with no pacing
/// </summary>
/// <param name="key">Key</param>
/// <param name="priority"></param>
private GenericQueue(string key, Thread.eThreadPriority priority, int capacity, int pacing)
{
_key = key;
int cap = 25; // sets default
if (capacity > 0)
{
cap = capacity; // overrides default
}
_queue = new CrestronQueue<IQueueMessage>(cap);
_worker = new Thread(ProcessQueue, null, Thread.eThreadStartOptions.Running)
{
Priority = priority
};
SetDelayValues(pacing);
}
@@ -82,6 +147,14 @@ namespace PepperDash_Essentials_Core.Queues
{
_delayEnabled = pacing > 0;
_delayTime = pacing;
CrestronEnvironment.ProgramStatusEventHandler += programEvent =>
{
if (programEvent != eProgramStatusEventType.Stopping)
return;
Dispose();
};
}
/// <summary>

View File

@@ -53,18 +53,22 @@ namespace PepperDash.Essentials.Core
/// </summary>
///
protected string _SourceListKey;
public virtual string SourceListKey {
public string SourceListKey {
get
{
return _SourceListKey;
}
set
private set
{
_SourceListKey = value;
if (value != _SourceListKey)
{
_SourceListKey = value;
}
}
}
protected const string _defaultSourceListKey = "default";
/// <summary>
/// Timer used for informing the UIs of a shutdown
/// </summary>
@@ -160,6 +164,22 @@ namespace PepperDash.Essentials.Core
return base.CustomActivate();
}
/// <summary>
/// Sets the SourceListKey property to the passed in value or the default if no value passed in
/// </summary>
/// <param name="sourceListKey"></param>
protected void SetSourceListKey(string sourceListKey)
{
if (!string.IsNullOrEmpty(sourceListKey))
{
SourceListKey = sourceListKey;
}
else
{
sourceListKey = _defaultSourceListKey;
}
}
/// <summary>
/// If mobile control is enabled, sets the appropriate properties
/// </summary>

View File

@@ -92,6 +92,16 @@ namespace PepperDash.Essentials.Core
void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType);
}
public interface IRoutingWithClear : IRouting
{
/// <summary>
/// Clears a route to an output, however a device needs to do that
/// </summary>
/// <param name="outputSelector">Output to clear</param>
/// <param name="signalType">signal type to clear</param>
void ClearRoute(object outputSelector, eRoutingSignalType signalType);
}
public interface IRoutingNumeric : IRouting
{
void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type);

View File

@@ -169,9 +169,9 @@ namespace PepperDash.Essentials.Core.PageManagers
}
// Build presets
if (stb.HasPresets && stb.PresetsModel != null)
if (stb.HasPresets && stb.TvPresets != null)
{
PresetsView = new DevicePresetsView(trilist, stb.PresetsModel);
PresetsView = new DevicePresetsView(trilist, stb.TvPresets);
}
}

View File

@@ -18,8 +18,8 @@ namespace PepperDash.Essentials.Core.PageManagers
{
SetTopBox = stb;
TriList = trilist;
if(stb.PresetsModel != null)
PresetsView = new DevicePresetsView(trilist, stb.PresetsModel);
if(stb.TvPresets != null)
PresetsView = new DevicePresetsView(trilist, stb.TvPresets);
}
public override void Show()

View File

@@ -44,7 +44,7 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs
DeviceInfo = new DeviceInfo();
//_dge.OnlineStatusChange += (currentDevice, args) => { if (args.DeviceOnLine) UpdateDeviceInfo(); };
_dge.OnlineStatusChange += (currentDevice, args) => { if (args.DeviceOnLine) UpdateDeviceInfo(); };
_dc = dc;
@@ -123,29 +123,56 @@ namespace PepperDash.Essentials.DM.Endpoints.DGEs
gather.LineReceived += (sender, args) =>
{
if (args.Text.ToLower().Contains("host"))
try
{
DeviceInfo.HostName = args.Text.Split(';')[1].Trim();
Debug.Console(1, this, "{0}", args.Text);
tcpClient.Disconnect();
return;
if (args.Text.ToLower().Contains("host"))
{
DeviceInfo.HostName = args.Text.Split(':')[1].Trim();
Debug.Console(1, this, "hostname: {0}", DeviceInfo.HostName);
tcpClient.Disconnect();
return;
}
//ignore console prompt
/*if (args.Text.ToLower().Contains(">"))
{
Debug.Console(1, this, "Ignoring console");
return;
}
if (args.Text.ToLower().Contains("dge"))
{
Debug.Console(1, this, "Ignoring DGE");
return;
}*/
if (!args.Text.Contains('['))
{
return;
}
var splitResponse = args.Text.Split('[');
foreach (string t in splitResponse)
{
Debug.Console(1, this, "{0}", t);
}
DeviceInfo.SerialNumber = splitResponse[1].Split(' ')[4].Replace("#", "");
DeviceInfo.FirmwareVersion = splitResponse[1].Split(' ')[0];
Debug.Console(1, this, "Firmware: {0} SerialNumber: {1}", DeviceInfo.FirmwareVersion,
DeviceInfo.SerialNumber);
tcpClient.SendText("host\r\n");
}
//ignore console prompt
if (args.Text.ToLower().Contains(">"))
catch (Exception ex)
{
return;
Debug.Console(0, this, "Exception getting data: {0}", ex.Message);
Debug.Console(0, this, "response: {0}", args.Text);
}
if (!args.Text.ToLower().Contains("dge"))
{
return;
}
DeviceInfo.SerialNumber = args.Text.Split('[')[1].Split(' ')[4].Replace("#", "");
DeviceInfo.FirmwareVersion = args.Text.Split('[')[1].Split(' ')[1];
tcpClient.SendText("host\r\n");
};
tcpClient.Connect();

View File

@@ -1,46 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
//using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.DM;
using Crestron.SimplSharpPro.DM.Endpoints;
using Crestron.SimplSharpPro.DM.Endpoints.Transmitters;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.DM.Config;
namespace PepperDash.Essentials.DM
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
//using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.DM;
using Crestron.SimplSharpPro.DM.Endpoints;
using Crestron.SimplSharpPro.DM.Endpoints.Transmitters;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.DM.Config;
namespace PepperDash.Essentials.DM
{
using eVst = DmTx401C.eSourceSelection;
[Description("Wrapper class for DM-TX-401-C")]
public class DmTx401CController : DmTxControllerBase, ITxRoutingWithFeedback, IIROutputPorts, IComPorts, IHasFreeRun, IVgaBrightnessContrastControls
{
public DmTx401C Tx { get; private set; }
public RoutingInputPortWithVideoStatuses HdmiIn { get; private set; }
public RoutingInputPortWithVideoStatuses DisplayPortIn { get; private set; }
public RoutingInputPortWithVideoStatuses VgaIn { get; private set; }
public RoutingInputPortWithVideoStatuses CompositeIn { get; private set; }
public RoutingOutputPort DmOut { get; private set; }
public override StringFeedback ActiveVideoInputFeedback { get; protected set; }
public IntFeedback VideoSourceNumericFeedback { get; protected set; }
public IntFeedback AudioSourceNumericFeedback { get; protected set; }
public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; }
public BoolFeedback DisplayPortVideoSyncFeedback { get; protected set; }
public BoolFeedback HdmiVideoSyncFeedback { get; protected set; }
public BoolFeedback VgaVideoSyncFeedback { get; protected set; }
public BoolFeedback FreeRunEnabledFeedback { get; protected set; }
public IntFeedback VgaBrightnessFeedback { get; protected set; }
public class DmTx401CController : DmTxControllerBase, ITxRoutingWithFeedback, IIROutputPorts, IComPorts, IHasFreeRun, IVgaBrightnessContrastControls
{
public DmTx401C Tx { get; private set; }
public RoutingInputPortWithVideoStatuses HdmiIn { get; private set; }
public RoutingInputPortWithVideoStatuses DisplayPortIn { get; private set; }
public RoutingInputPortWithVideoStatuses VgaIn { get; private set; }
public RoutingInputPortWithVideoStatuses CompositeIn { get; private set; }
public RoutingOutputPort DmOut { get; private set; }
public override StringFeedback ActiveVideoInputFeedback { get; protected set; }
public IntFeedback VideoSourceNumericFeedback { get; protected set; }
public IntFeedback AudioSourceNumericFeedback { get; protected set; }
public IntFeedback HdmiInHdcpCapabilityFeedback { get; protected set; }
public BoolFeedback DisplayPortVideoSyncFeedback { get; protected set; }
public BoolFeedback HdmiVideoSyncFeedback { get; protected set; }
public BoolFeedback VgaVideoSyncFeedback { get; protected set; }
public BoolFeedback FreeRunEnabledFeedback { get; protected set; }
public IntFeedback VgaBrightnessFeedback { get; protected set; }
public IntFeedback VgaContrastFeedback { get; protected set; }
//IroutingNumericEvent
@@ -54,88 +54,88 @@ namespace PepperDash.Essentials.DM
{
var newEvent = NumericSwitchChange;
if (newEvent != null) newEvent(this, e);
}
/// <summary>
/// Helps get the "real" inputs, including when in Auto
/// </summary>
public BaseDmTx401.eSourceSelection ActualVideoInput
{
get
{
if (Tx.VideoSourceFeedback != BaseDmTx401.eSourceSelection.Auto)
return Tx.VideoSourceFeedback;
else // auto
{
if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue)
return BaseDmTx401.eSourceSelection.HDMI;
else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue)
return BaseDmTx401.eSourceSelection.VGA;
else if (Tx.DisplayPortInput.SyncDetectedFeedback.BoolValue)
return BaseDmTx401.eSourceSelection.DisplayPort;
else if (Tx.CvbsInput.SyncDetectedFeedback.BoolValue)
return BaseDmTx401.eSourceSelection.Composite;
else
return BaseDmTx401.eSourceSelection.Disabled;
}
}
}
public RoutingPortCollection<RoutingInputPort> InputPorts
{
get
{
return new RoutingPortCollection<RoutingInputPort>
{
HdmiIn,
DisplayPortIn,
VgaIn,
CompositeIn,
AnyVideoInput
};
}
}
public RoutingPortCollection<RoutingOutputPort> OutputPorts
{
get
{
return new RoutingPortCollection<RoutingOutputPort> { DmOut };
}
}
/// <summary>
///
/// </summary>
/// <param name="key"></param>
/// <param name="name"></param>
/// <param name="tx"></param>
public DmTx401CController(string key, string name, DmTx401C tx)
: base(key, name, tx)
{
Tx = tx;
HdmiIn = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn,
eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.HDMI, this,
}
/// <summary>
/// Helps get the "real" inputs, including when in Auto
/// </summary>
public BaseDmTx401.eSourceSelection ActualVideoInput
{
get
{
if (Tx.VideoSourceFeedback != BaseDmTx401.eSourceSelection.Auto)
return Tx.VideoSourceFeedback;
else // auto
{
if (Tx.HdmiInput.SyncDetectedFeedback.BoolValue)
return BaseDmTx401.eSourceSelection.HDMI;
else if (Tx.VgaInput.SyncDetectedFeedback.BoolValue)
return BaseDmTx401.eSourceSelection.VGA;
else if (Tx.DisplayPortInput.SyncDetectedFeedback.BoolValue)
return BaseDmTx401.eSourceSelection.DisplayPort;
else if (Tx.CvbsInput.SyncDetectedFeedback.BoolValue)
return BaseDmTx401.eSourceSelection.Composite;
else
return BaseDmTx401.eSourceSelection.Disabled;
}
}
}
public RoutingPortCollection<RoutingInputPort> InputPorts
{
get
{
return new RoutingPortCollection<RoutingInputPort>
{
HdmiIn,
DisplayPortIn,
VgaIn,
CompositeIn,
AnyVideoInput
};
}
}
public RoutingPortCollection<RoutingOutputPort> OutputPorts
{
get
{
return new RoutingPortCollection<RoutingOutputPort> { DmOut };
}
}
/// <summary>
///
/// </summary>
/// <param name="key"></param>
/// <param name="name"></param>
/// <param name="tx"></param>
public DmTx401CController(string key, string name, DmTx401C tx)
: base(key, name, tx)
{
Tx = tx;
HdmiIn = new RoutingInputPortWithVideoStatuses(DmPortName.HdmiIn,
eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.HDMI, this,
VideoStatusHelper.GetHdmiInputStatusFuncs(tx.HdmiInput))
{
FeedbackMatchObject = eVst.HDMI
};
DisplayPortIn = new RoutingInputPortWithVideoStatuses(DmPortName.DisplayPortIn,
eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.DisplayPort, this,
};
DisplayPortIn = new RoutingInputPortWithVideoStatuses(DmPortName.DisplayPortIn,
eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, eVst.DisplayPort, this,
VideoStatusHelper.GetDisplayPortInputStatusFuncs(tx.DisplayPortInput))
{
FeedbackMatchObject = eVst.DisplayPort
};
VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn,
eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eVst.VGA, this,
};
VgaIn = new RoutingInputPortWithVideoStatuses(DmPortName.VgaIn,
eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, eVst.VGA, this,
VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput))
{
FeedbackMatchObject = eVst.VGA
};
CompositeIn = new RoutingInputPortWithVideoStatuses(DmPortName.CompositeIn,
eRoutingSignalType.Video, eRoutingPortConnectionType.Composite, eVst.Composite, this,
};
CompositeIn = new RoutingInputPortWithVideoStatuses(DmPortName.CompositeIn,
eRoutingSignalType.Video, eRoutingPortConnectionType.Composite, eVst.Composite, this,
VideoStatusHelper.GetVgaInputStatusFuncs(tx.VgaInput))
{
FeedbackMatchObject = eVst.Composite
@@ -146,185 +146,184 @@ namespace PepperDash.Essentials.DM
Tx.BaseEvent += Tx_BaseEvent;
Tx.OnlineStatusChange += Tx_OnlineStatusChange;
Tx.VgaInput.InputStreamChange += VgaInputOnInputStreamChange;
tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange;
ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput",
tx.VgaInput.VideoControls.ControlChange += VideoControls_ControlChange;
ActiveVideoInputFeedback = new StringFeedback("ActiveVideoInput",
() => ActualVideoInput.ToString());
VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback);
VideoSourceNumericFeedback = new IntFeedback(() => (int)Tx.VideoSourceFeedback);
AudioSourceNumericFeedback = new IntFeedback(() => (int)Tx.AudioSourceFeedback);
HdmiInHdcpCapabilityFeedback = new IntFeedback("HdmiInHdcpCapability", () => tx.HdmiInput.HdcpSupportOnFeedback.BoolValue ? 1 : 0);
HdcpStateFeedback = HdmiInHdcpCapabilityFeedback;
HdcpStateFeedback = HdmiInHdcpCapabilityFeedback;
HdcpSupportCapability = eHdcpCapabilityType.HdcpAutoSupport;
DisplayPortVideoSyncFeedback = new BoolFeedback("DisplayPortVideoSync", () => (bool)tx.DisplayPortInput.SyncDetectedFeedback.BoolValue);
HdmiVideoSyncFeedback = new BoolFeedback(() => (bool)tx.HdmiInput.SyncDetectedFeedback.BoolValue);
VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue);
FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled);
VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue);
VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue);
var combinedFuncs = new VideoStatusFuncsWrapper
{
HdcpActiveFeedbackFunc = () =>
(ActualVideoInput == eVst.HDMI
&& tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue)
|| (ActualVideoInput == eVst.DisplayPort
&& tx.DisplayPortInput.VideoAttributes.HdcpActiveFeedback.BoolValue),
HdcpStateFeedbackFunc = () =>
{
if (ActualVideoInput == eVst.HDMI)
return tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString();
if (ActualVideoInput == eVst.DisplayPort)
return tx.DisplayPortInput.VideoAttributes.HdcpStateFeedback.ToString();
return "";
},
VideoResolutionFeedbackFunc = () =>
{
if (ActualVideoInput == eVst.HDMI)
return tx.HdmiInput.VideoAttributes.GetVideoResolutionString();
if (ActualVideoInput == eVst.DisplayPort)
return tx.DisplayPortInput.VideoAttributes.GetVideoResolutionString();
if (ActualVideoInput == eVst.VGA)
return tx.VgaInput.VideoAttributes.GetVideoResolutionString();
if (ActualVideoInput == eVst.Composite)
return tx.CvbsInput.VideoAttributes.GetVideoResolutionString();
return "";
},
VideoSyncFeedbackFunc = () =>
(ActualVideoInput == eVst.HDMI
&& tx.HdmiInput.SyncDetectedFeedback.BoolValue)
|| (ActualVideoInput == eVst.DisplayPort
&& tx.DisplayPortInput.SyncDetectedFeedback.BoolValue)
|| (ActualVideoInput == eVst.VGA
&& tx.VgaInput.SyncDetectedFeedback.BoolValue)
|| (ActualVideoInput == eVst.Composite
&& tx.CvbsInput.SyncDetectedFeedback.BoolValue)
};
AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn,
eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs);
DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.DmCat, null, this);
AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback,
AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback,
AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback,
AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, DisplayPortVideoSyncFeedback,
HdmiVideoSyncFeedback, VgaVideoSyncFeedback);
// Set Ports for CEC
DisplayPortIn.Port = Tx.DisplayPortInput;
HdmiIn.Port = Tx.HdmiInput;
DmOut.Port = Tx.DmOutput;
}
public override bool CustomActivate()
{
// Link up all of these damned events to the various RoutingPorts via a helper handler
Tx.HdmiInput.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId);
Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId);
Tx.DisplayPortInput.InputStreamChange += (o, a) => FowardInputStreamChange(DisplayPortIn, a.EventId);
Tx.DisplayPortInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(DisplayPortIn, a.EventId);
Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaIn, a.EventId);
Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId);
// Base does register and sets up comm monitoring.
return base.CustomActivate();
}
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
var joinMap = GetDmTxJoinMap(joinStart, joinMapKey);
if (HdmiVideoSyncFeedback != null)
{
HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]);
}
if (VgaVideoSyncFeedback != null)
VgaVideoSyncFeedback = new BoolFeedback(() => (bool)tx.VgaInput.SyncDetectedFeedback.BoolValue);
FreeRunEnabledFeedback = new BoolFeedback(() => tx.VgaInput.FreeRunFeedback == eDmFreeRunSetting.Enabled);
VgaBrightnessFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.BrightnessFeedback.UShortValue);
VgaContrastFeedback = new IntFeedback(() => tx.VgaInput.VideoControls.ContrastFeedback.UShortValue);
var combinedFuncs = new VideoStatusFuncsWrapper
{
HdcpActiveFeedbackFunc = () =>
(ActualVideoInput == eVst.HDMI
&& tx.HdmiInput.VideoAttributes.HdcpActiveFeedback.BoolValue)
|| (ActualVideoInput == eVst.DisplayPort
&& tx.DisplayPortInput.VideoAttributes.HdcpActiveFeedback.BoolValue),
HdcpStateFeedbackFunc = () =>
{
if (ActualVideoInput == eVst.HDMI)
return tx.HdmiInput.VideoAttributes.HdcpStateFeedback.ToString();
if (ActualVideoInput == eVst.DisplayPort)
return tx.DisplayPortInput.VideoAttributes.HdcpStateFeedback.ToString();
return "";
},
VideoResolutionFeedbackFunc = () =>
{
if (ActualVideoInput == eVst.HDMI)
return tx.HdmiInput.VideoAttributes.GetVideoResolutionString();
if (ActualVideoInput == eVst.DisplayPort)
return tx.DisplayPortInput.VideoAttributes.GetVideoResolutionString();
if (ActualVideoInput == eVst.VGA)
return tx.VgaInput.VideoAttributes.GetVideoResolutionString();
if (ActualVideoInput == eVst.Composite)
return tx.CvbsInput.VideoAttributes.GetVideoResolutionString();
return "";
},
VideoSyncFeedbackFunc = () =>
(ActualVideoInput == eVst.HDMI
&& tx.HdmiInput.SyncDetectedFeedback.BoolValue)
|| (ActualVideoInput == eVst.DisplayPort
&& tx.DisplayPortInput.SyncDetectedFeedback.BoolValue)
|| (ActualVideoInput == eVst.VGA
&& tx.VgaInput.SyncDetectedFeedback.BoolValue)
|| (ActualVideoInput == eVst.Composite
&& tx.CvbsInput.SyncDetectedFeedback.BoolValue)
};
AnyVideoInput = new RoutingInputPortWithVideoStatuses(DmPortName.AnyVideoIn,
eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, 0, this, combinedFuncs);
DmOut = new RoutingOutputPort(DmPortName.DmOut, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.DmCat, null, this);
AddToFeedbackList(ActiveVideoInputFeedback, VideoSourceNumericFeedback, AudioSourceNumericFeedback,
AnyVideoInput.VideoStatus.HasVideoStatusFeedback, AnyVideoInput.VideoStatus.HdcpActiveFeedback,
AnyVideoInput.VideoStatus.HdcpStateFeedback, AnyVideoInput.VideoStatus.VideoResolutionFeedback,
AnyVideoInput.VideoStatus.VideoSyncFeedback, HdmiInHdcpCapabilityFeedback, DisplayPortVideoSyncFeedback,
HdmiVideoSyncFeedback, VgaVideoSyncFeedback);
// Set Ports for CEC
DisplayPortIn.Port = Tx.DisplayPortInput;
HdmiIn.Port = Tx.HdmiInput;
DmOut.Port = Tx.DmOutput;
}
public override bool CustomActivate()
{
// Link up all of these damned events to the various RoutingPorts via a helper handler
Tx.HdmiInput.InputStreamChange += (o, a) => FowardInputStreamChange(HdmiIn, a.EventId);
Tx.HdmiInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(HdmiIn, a.EventId);
Tx.DisplayPortInput.InputStreamChange += (o, a) => FowardInputStreamChange(DisplayPortIn, a.EventId);
Tx.DisplayPortInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(DisplayPortIn, a.EventId);
Tx.VgaInput.InputStreamChange += (o, a) => FowardInputStreamChange(VgaIn, a.EventId);
Tx.VgaInput.VideoAttributes.AttributeChange += (o, a) => ForwardVideoAttributeChange(VgaIn, a.EventId);
// Base does register and sets up comm monitoring.
return base.CustomActivate();
}
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
var joinMap = GetDmTxJoinMap(joinStart, joinMapKey);
if (HdmiVideoSyncFeedback != null)
{
VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]);
}
LinkDmTxToApi(this, trilist, joinMap, bridge);
}
public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type)
{
Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input);
switch (input)
{
case 0:
{
ExecuteSwitch(eVst.Auto, null, type);
break;
}
case 1:
{
ExecuteSwitch(DisplayPortIn.Selector, null, type);
break;
}
case 2:
{
ExecuteSwitch(HdmiIn.Selector, null, type);
break;
}
case 3:
{
ExecuteSwitch(VgaIn.Selector, null, type);
break;
}
case 4:
{
ExecuteSwitch(CompositeIn.Selector, null, type);
break;
}
case 5:
{
ExecuteSwitch(eVst.Disabled, null, type);
break;
}
}
}
public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType)
{
if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video)
Tx.VideoSource = (eVst)inputSelector;
if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio)
Tx.AudioSource = (eVst)inputSelector;
HdmiVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input1VideoSyncStatus.JoinNumber]);
}
if (VgaVideoSyncFeedback != null)
{
VgaVideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Input2VideoSyncStatus.JoinNumber]);
}
LinkDmTxToApi(this, trilist, joinMap, bridge);
}
public void ExecuteNumericSwitch(ushort input, ushort output, eRoutingSignalType type)
{
Debug.Console(2, this, "Executing Numeric Switch to input {0}.", input);
switch (input)
{
case 0:
{
ExecuteSwitch(eVst.Auto, null, type);
break;
}
case 1:
{
ExecuteSwitch(DisplayPortIn.Selector, null, type);
break;
}
case 2:
{
ExecuteSwitch(HdmiIn.Selector, null, type);
break;
}
case 3:
{
ExecuteSwitch(VgaIn.Selector, null, type);
break;
}
case 4:
{
ExecuteSwitch(CompositeIn.Selector, null, type);
break;
}
case 5:
{
ExecuteSwitch(eVst.Disabled, null, type);
break;
}
}
}
public void ExecuteSwitch(object inputSelector, object outputSelector, eRoutingSignalType signalType)
{
if ((signalType | eRoutingSignalType.Video) == eRoutingSignalType.Video)
Tx.VideoSource = (eVst)inputSelector;
if ((signalType | eRoutingSignalType.Audio) == eRoutingSignalType.Audio)
Tx.AudioSource = (eVst)inputSelector;
}
void Tx_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args)
{
var localVideoInputPort =
InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.VideoSourceFeedback);
var localAudioInputPort =
InputPorts.FirstOrDefault(p => (eVst)p.Selector == Tx.AudioSourceFeedback);
ActiveVideoInputFeedback.FireUpdate();
VideoSourceNumericFeedback.FireUpdate();
AudioSourceNumericFeedback.FireUpdate();
OnSwitchChange(new RoutingNumericEventArgs(1, VideoSourceNumericFeedback.UShortValue, OutputPorts.First(), localVideoInputPort, eRoutingSignalType.Video));
OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localAudioInputPort, eRoutingSignalType.Audio));
}
void Tx_BaseEvent(GenericBase device, BaseEventArgs args)
@@ -348,7 +347,7 @@ namespace PepperDash.Essentials.DM
OnSwitchChange(new RoutingNumericEventArgs(1, AudioSourceNumericFeedback.UShortValue, OutputPorts.First(), localInputAudioPort, eRoutingSignalType.Audio));
break;
}
}
}
void VideoControls_ControlChange(object sender, GenericEventArgs args)
{
@@ -364,7 +363,7 @@ namespace PepperDash.Essentials.DM
VgaContrastFeedback.FireUpdate();
break;
}
}
}
/// <summary>
/// Enables or disables free run
@@ -391,10 +390,10 @@ namespace PepperDash.Essentials.DM
public void SetVgaContrast(ushort level)
{
Tx.VgaInput.VideoControls.Contrast.UShortValue = level;
}
/// <summary>
/// Relays the input stream change to the appropriate RoutingInputPort.
}
/// <summary>
/// Relays the input stream change to the appropriate RoutingInputPort.
/// </summary>
void FowardInputStreamChange(RoutingInputPortWithVideoStatuses inputPort, int eventId)
{
@@ -404,36 +403,36 @@ namespace PepperDash.Essentials.DM
}
inputPort.VideoStatus.VideoSyncFeedback.FireUpdate();
AnyVideoInput.VideoStatus.VideoSyncFeedback.FireUpdate();
}
/// <summary>
/// Relays the VideoAttributes change to a RoutingInputPort
/// </summary>
void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId)
{
//// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds
//Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}",
// args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType());
switch (eventId)
{
case VideoAttributeEventIds.HdcpActiveFeedbackEventId:
inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate();
AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate();
break;
case VideoAttributeEventIds.HdcpStateFeedbackEventId:
inputPort.VideoStatus.HdcpStateFeedback.FireUpdate();
AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate();
break;
case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId:
case VideoAttributeEventIds.VerticalResolutionFeedbackEventId:
inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate();
AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate();
break;
case VideoAttributeEventIds.FramesPerSecondFeedbackEventId:
inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate();
AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate();
break;
}
}
/// <summary>
/// Relays the VideoAttributes change to a RoutingInputPort
/// </summary>
void ForwardVideoAttributeChange(RoutingInputPortWithVideoStatuses inputPort, int eventId)
{
//// LOCATION: Crestron.SimplSharpPro.DM.VideoAttributeEventIds
//Debug.Console(2, this, "VideoAttributes_AttributeChange event id={0} from {1}",
// args.EventId, (sender as VideoAttributesEnhanced).Owner.GetType());
switch (eventId)
{
case VideoAttributeEventIds.HdcpActiveFeedbackEventId:
inputPort.VideoStatus.HdcpActiveFeedback.FireUpdate();
AnyVideoInput.VideoStatus.HdcpActiveFeedback.FireUpdate();
break;
case VideoAttributeEventIds.HdcpStateFeedbackEventId:
inputPort.VideoStatus.HdcpStateFeedback.FireUpdate();
AnyVideoInput.VideoStatus.HdcpStateFeedback.FireUpdate();
break;
case VideoAttributeEventIds.HorizontalResolutionFeedbackEventId:
case VideoAttributeEventIds.VerticalResolutionFeedbackEventId:
inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate();
AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate();
break;
case VideoAttributeEventIds.FramesPerSecondFeedbackEventId:
inputPort.VideoStatus.VideoResolutionFeedback.FireUpdate();
AnyVideoInput.VideoStatus.VideoResolutionFeedback.FireUpdate();
break;
}
}
void HdmiInputStreamChangeEvent(EndpointInputStream inputStream, EndpointInputStreamEventArgs args)
@@ -477,18 +476,18 @@ namespace PepperDash.Essentials.DM
VgaVideoSyncFeedback.FireUpdate();
break;
}
}
#region IIROutputPorts Members
public CrestronCollection<IROutputPort> IROutputPorts { get { return Tx.IROutputPorts; } }
public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } }
#endregion
#region IComPorts Members
public CrestronCollection<ComPort> ComPorts { get { return Tx.ComPorts; } }
public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } }
#endregion
}
}
#region IIROutputPorts Members
public CrestronCollection<IROutputPort> IROutputPorts { get { return Tx.IROutputPorts; } }
public int NumberOfIROutputPorts { get { return Tx.NumberOfIROutputPorts; } }
#endregion
#region IComPorts Members
public CrestronCollection<ComPort> ComPorts { get { return Tx.ComPorts; } }
public int NumberOfComPorts { get { return Tx.NumberOfComPorts; } }
#endregion
}
}

View File

@@ -149,7 +149,7 @@ namespace PepperDash.Essentials.Devices.Displays
public override bool CustomActivate()
{
Communication.Connect();
CommunicationMonitor.StatusChange += (o, a) => { Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status); };
CommunicationMonitor.StatusChange += (o, a) => Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status);
CommunicationMonitor.Start();
return true;
}
@@ -188,9 +188,6 @@ namespace PepperDash.Essentials.Devices.Displays
IncomingBuffer.CopyTo(newBytes, 0);
e.Bytes.CopyTo(newBytes, IncomingBuffer.Length);
if (Debug.Level == 2) // This check is here to prevent following string format from building unnecessarily on level 0 or 1
Debug.Console(2, this, "Received:{0}", ComTextHelper.GetEscapedText(newBytes));
// Need to find AA FF and have
for (int i = 0; i < newBytes.Length; i++)
{
@@ -364,8 +361,6 @@ namespace PepperDash.Essentials.Devices.Displays
}
checksum = checksum & 0x000000FF; // mask off MSBs
b[b.Length - 1] = (byte)checksum;
if(Debug.Level == 2) // This check is here to prevent following string format from building unnecessarily on level 0 or 1
Debug.Console(2, this, "Sending:{0}", ComTextHelper.GetEscapedText(b));
if (b[1] == 0x12)
LastCommandSentWasVolume = true;

View File

@@ -12,11 +12,12 @@ using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Presets;
using PepperDash.Essentials.Core.Routing;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
namespace PepperDash.Essentials.Devices.Common
{
[Description("Wrapper class for an IR Set Top Box")]
public class IRSetTopBoxBase : EssentialsBridgeableDevice, ISetTopBoxControls, IRoutingOutputs, IUsageTracking, IHasPowerControl
public class IRSetTopBoxBase : EssentialsBridgeableDevice, ISetTopBoxControls, IRoutingOutputs, IUsageTracking, IHasPowerControl, ITvPresetsProvider
{
public IrOutputPortController IrPort { get; private set; }
@@ -28,7 +29,7 @@ namespace PepperDash.Essentials.Devices.Common
public bool HasDpad { get; set; }
public bool HasNumeric { get; set; }
public DevicePresetsModel PresetsModel { get; private set; }
public DevicePresetsModel TvPresets { get; private set; }
public IRSetTopBoxBase(string key, string name, IrOutputPortController portCont,
SetTopBoxPropertiesConfig props)
@@ -66,8 +67,8 @@ namespace PepperDash.Essentials.Devices.Common
public void LoadPresets(string filePath)
{
PresetsModel = new DevicePresetsModel(Key + "-presets", this, filePath);
DeviceManager.AddDevice(PresetsModel);
TvPresets = new DevicePresetsModel(Key + "-presets", this, filePath);
DeviceManager.AddDevice(TvPresets);
}

View File

@@ -1369,7 +1369,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
set
{
// If the incoming value is "On" it sets the BoolValue true, otherwise sets it false
BoolValue = value == "On";
BoolValue = value == "On" || value == "Standby";
OnValueChanged();
}
}