Reviewed with AW, decided best to remove console commands and create a public method that can be called using DEVJSON to print current settiings.

This commit is contained in:
jkdevito
2021-02-01 11:10:33 -06:00
parent c6cfecdbbb
commit e0dcde5c35
3 changed files with 53 additions and 95 deletions

View File

@@ -119,12 +119,6 @@ namespace PepperDash.Essentials.Core
OccSensor.BaseEvent += new Crestron.SimplSharpPro.BaseEventHandler(OccSensor_BaseEvent); OccSensor.BaseEvent += new Crestron.SimplSharpPro.BaseEventHandler(OccSensor_BaseEvent);
OccSensor.CenOccupancySensorChange += new GenericEventHandler(OccSensor_CenOccupancySensorChange); OccSensor.CenOccupancySensorChange += new GenericEventHandler(OccSensor_CenOccupancySensorChange);
CrestronConsole.AddNewConsoleCommand(GetSettings,
"occsensorstatus",
"Reports current occupancy sensor settings. Requires a device key.",
ConsoleAccessLevelEnum.AccessOperator);
} }
/// <summary> /// <summary>
@@ -432,42 +426,33 @@ namespace PepperDash.Essentials.Core
} }
} }
private static void GetSettings(string key) /// <summary>
/// Method to print current settings to console
/// </summary>
public void GetSettings()
{ {
var dev = DeviceManager.GetDeviceForKey(key);
if (dev == null) return;
var sensor = dev as CenOdtOccupancySensorBaseController;
if (sensor == null) return;
if (!sensor.Hardware.IsOnline)
{
Debug.Console(0, sensor.Key, "Sensor IsOnline: {0}", sensor.Hardware.IsOnline);
return;
}
var dash = new string('*', 50); var dash = new string('*', 50);
CrestronConsole.PrintLine(string.Format("{0}\n", dash)); CrestronConsole.PrintLine(string.Format("{0}\n", dash));
Debug.Console(0, sensor.Key, "Timeout Current: {0} | Remote: {1}", Debug.Console(0, Key, "Timeout Current: {0} | Remote: {1}",
sensor.CurrentTimeoutFeedback.UShortValue, OccSensor.CurrentTimeoutFeedback.UShortValue,
sensor.RemoteTimeoutFeedback.UShortValue); OccSensor.RemoteTimeout.UShortValue);
Debug.Console(0, sensor.Key, "Short Timeout Enabled: {0}", Debug.Console(0, Key, "Short Timeout Enabled: {0}",
sensor.ShortTimeoutEnabledFeedback.BoolValue); OccSensor.ShortTimeoutEnabledFeedback.BoolValue);
Debug.Console(0, sensor.Key, "PIR Sensor Enabled: {0} | Sensitivity Occupied: {1} | Sensitivity Vacant: {2}", Debug.Console(0, Key, "PIR Sensor Enabled: {0} | Sensitivity Occupied: {1} | Sensitivity Vacant: {2}",
sensor.PirSensorEnabledFeedback.BoolValue, OccSensor.PassiveInfraredSensorEnabledFeedback.BoolValue,
sensor.PirSensitivityInOccupiedStateFeedback.UShortValue, OccSensor.PassiveInfraredSensorSensitivityInOccupiedStateFeedback,
sensor.PirSensitivityInVacantStateFeedback.UShortValue); OccSensor.PassiveInfraredSensorSensitivityInVacantStateFeedback);
Debug.Console(0, sensor.Key, "Ultrasonic Enabled A: {0} | B: {1}", Debug.Console(0, Key, "Ultrasonic Enabled A: {0} | B: {1}",
sensor.UltrasonicAEnabledFeedback.BoolValue, OccSensor.UltrasonicSensorSideAEnabledFeedback.BoolValue,
sensor.UltrasonicBEnabledFeedback.BoolValue); OccSensor.UltrasonicSensorSideBEnabledFeedback.BoolValue);
Debug.Console(0, sensor.Key, "Ultrasonic Sensitivity Occupied: {0} | Vacant: {1}", Debug.Console(0, Key, "Ultrasonic Sensitivity Occupied: {0} | Vacant: {1}",
sensor.UltrasonicSensitivityInOccupiedStateFeedback.UShortValue, OccSensor.UltrasonicSensorSensitivityInOccupiedStateFeedback,
sensor.UltrasonicSensitivityInVacantStateFeedback.UShortValue); OccSensor.UltrasonicSensorSensitivityInVacantStateFeedback);
CrestronConsole.PrintLine(string.Format("{0}\n", dash)); CrestronConsole.PrintLine(string.Format("{0}\n", dash));
} }

View File

@@ -70,11 +70,6 @@ namespace PepperDash.Essentials.Core
RegisterGlsOdtSensorBaseController(OccSensor); RegisterGlsOdtSensorBaseController(OccSensor);
}); });
CrestronConsole.AddNewConsoleCommand(GetSettings,
"occsensorstatus",
"Reports current occupancy sensor settings. Requires a device key.",
ConsoleAccessLevelEnum.AccessOperator);
} }
public GlsOccupancySensorBaseController(string key, string name) : base(key, name) { } public GlsOccupancySensorBaseController(string key, string name) : base(key, name) { }
@@ -298,34 +293,26 @@ namespace PepperDash.Essentials.Core
OccSensor.ExternalPhotoSensorMinimumChange.UShortValue = value; OccSensor.ExternalPhotoSensorMinimumChange.UShortValue = value;
} }
private static void GetSettings(string key) /// <summary>
/// Method to print current occ settings to console.
/// </summary>
/// <param name="key"></param>
public void GetSettings()
{ {
var dev = DeviceManager.GetDeviceForKey(key);
if (dev == null) return;
var sensor = dev as GlsOccupancySensorBaseController;
if (sensor == null) return;
if (!sensor.Hardware.IsOnline)
{
Debug.Console(0, sensor.Key, "Sensor IsOnline: {0}", sensor.Hardware.IsOnline);
return;
}
var dash = new string('*', 50); var dash = new string('*', 50);
CrestronConsole.PrintLine(string.Format("{0}\n", dash)); CrestronConsole.PrintLine(string.Format("{0}\n", dash));
Debug.Console(0, sensor.Key, "Timeout Current: {0} | Local: {1}", Debug.Console(0, Key, "Timeout Current: {0} | Local: {1}",
sensor.CurrentTimeoutFeedback.UShortValue, OccSensor.CurrentTimeoutFeedback.UShortValue,
sensor.LocalTimoutFeedback.UShortValue); OccSensor.LocalTimeoutFeedback.UShortValue);
Debug.Console(0, sensor.Key, "Short Timeout Enabled: {0}", Debug.Console(0, Key, "Short Timeout Enabled: {0}",
sensor.ShortTimeoutEnabledFeedback.BoolValue); OccSensor.ShortTimeoutEnabledFeedback.BoolValue);
Debug.Console(0, sensor.Key, "PIR Sensor Enabled: {0} | Sensitivity Occupied: {1} | Sensitivity Vacant: {2}", Debug.Console(0, Key, "PIR Sensor Enabled: {0} | Sensitivity Occupied: {1} | Sensitivity Vacant: {2}",
sensor.PirSensorEnabledFeedback.BoolValue, OccSensor.PirEnabledFeedback.BoolValue,
sensor.PirSensitivityInOccupiedStateFeedback.UShortValue, OccSensor.PirSensitivityInOccupiedStateFeedback.UShortValue,
sensor.PirSensitivityInVacantStateFeedback.UShortValue); OccSensor.PirSensitivityInVacantStateFeedback.UShortValue);
CrestronConsole.PrintLine(string.Format("{0}\n", dash)); CrestronConsole.PrintLine(string.Format("{0}\n", dash));
} }

View File

@@ -64,11 +64,6 @@ namespace PepperDash.Essentials.Core
UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInOccupiedStateFeedback.UShortValue); UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInOccupiedStateFeedback.UShortValue);
}); });
CrestronConsole.AddNewConsoleCommand(GetSettings,
"occsensorstatus",
"Reports current occupancy sensor settings. Requires a device key.",
ConsoleAccessLevelEnum.AccessOperator);
} }
/// <summary> /// <summary>
@@ -175,42 +170,33 @@ namespace PepperDash.Essentials.Core
LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge); LinkOccSensorToApi(this, trilist, joinStart, joinMapKey, bridge);
} }
private static void GetSettings(string key) /// <summary>
/// Method to print occ sensor settings to console.
/// </summary>
public void GetSettings()
{ {
var dev = DeviceManager.GetDeviceForKey(key);
if (dev == null) return;
var sensor = dev as GlsOdtOccupancySensorController;
if (sensor == null) return;
if (!sensor.Hardware.IsOnline)
{
Debug.Console(0, sensor.Key, "Sensor IsOnline: {0}", sensor.Hardware.IsOnline);
return;
}
var dash = new string('*', 50); var dash = new string('*', 50);
CrestronConsole.PrintLine(string.Format("{0}\n", dash)); CrestronConsole.PrintLine(string.Format("{0}\n", dash));
Debug.Console(0, sensor.Key, "Timeout Current: {0} | Local: {1}", Debug.Console(0, Key, "Timeout Current: {0} | Local: {1}",
sensor.CurrentTimeoutFeedback.UShortValue, OccSensor.CurrentTimeoutFeedback.UShortValue,
sensor.LocalTimoutFeedback.UShortValue); OccSensor.LocalTimeoutFeedback.UShortValue);
Debug.Console(0, sensor.Key, "Short Timeout Enabled: {0}", Debug.Console(0, Key, "Short Timeout Enabled: {0}",
sensor.ShortTimeoutEnabledFeedback.BoolValue); OccSensor.ShortTimeoutEnabledFeedback.BoolValue);
Debug.Console(0, sensor.Key, "PIR Sensor Enabled: {0} | Sensitivity Occupied: {1} | Sensitivity Vacant: {2}", Debug.Console(0, Key, "PIR Sensor Enabled: {0} | Sensitivity Occupied: {1} | Sensitivity Vacant: {2}",
sensor.PirSensorEnabledFeedback.BoolValue, OccSensor.PirEnabledFeedback.BoolValue,
sensor.PirSensitivityInOccupiedStateFeedback.UShortValue, OccSensor.PirSensitivityInOccupiedStateFeedback.UShortValue,
sensor.PirSensitivityInVacantStateFeedback.UShortValue); OccSensor.PirSensitivityInVacantStateFeedback.UShortValue);
Debug.Console(0, sensor.Key, "Ultrasonic Enabled A: {0} | B: {1}", Debug.Console(0, Key, "Ultrasonic Enabled A: {0} | B: {1}",
sensor.UltrasonicAEnabledFeedback.BoolValue, OccSensor.UsAEnabledFeedback.BoolValue,
sensor.UltrasonicBEnabledFeedback.BoolValue); OccSensor.UsBEnabledFeedback.BoolValue);
Debug.Console(0, sensor.Key, "Ultrasonic Sensitivity Occupied: {0} | Vacant: {1}", Debug.Console(0, Key, "Ultrasonic Sensitivity Occupied: {0} | Vacant: {1}",
sensor.UltrasonicSensitivityInOccupiedStateFeedback.UShortValue, OccSensor.UsSensitivityInOccupiedStateFeedback.UShortValue,
sensor.UltrasonicSensitivityInVacantStateFeedback.UShortValue); OccSensor.UsSensitivityInVacantStateFeedback.UShortValue);
CrestronConsole.PrintLine(string.Format("{0}\n", dash)); CrestronConsole.PrintLine(string.Format("{0}\n", dash));
} }