Added ability to disable pull up resistor on versiports from config.

This commit is contained in:
Neil Dorin
2018-01-22 14:25:37 -07:00
parent cb41b31018
commit 42c4c705c9
10 changed files with 69 additions and 56884 deletions

View File

@@ -213,7 +213,9 @@ namespace PepperDash.Essentials.Devices.Common
var regSuccess = vp.Register();
if (regSuccess == eDeviceRegistrationUnRegistrationResponse.Success)
{
return new GenericVersiportInputDevice(key, vp);
if (props.DisablePullUpResistor)
vp.DisablePullUpResistor = true;
return new GenericVersiportDigitalInputDevice(key, vp);
}
else
{
@@ -243,14 +245,14 @@ namespace PepperDash.Essentials.Devices.Common
{
var cs = (portDevice as CrestronControlSystem);
if(cs != null)
if (cs != null)
if (cs.SupportsRelay && props.PortNumber <= cs.NumberOfRelayPorts)
{
Relay relay = cs.RelayPorts[props.PortNumber];
if (!relay.Registered)
{
if(relay.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
if (relay.Register() == eDeviceRegistrationUnRegistrationResponse.Success)
return new GenericRelayDevice(key, relay);
else
Debug.Console(0, "Attempt to register relay {0} on device with key '{1}' failed.", props.PortNumber, props.PortDeviceKey);
@@ -290,7 +292,7 @@ namespace PepperDash.Essentials.Devices.Common
else if (typeName == "occsensor")
{
var props = JsonConvert.DeserializeObject<GlsOccupancySensorConfigurationProperties>(properties.ToString());
uint id = 0x00;
GlsOccupancySensorBase occSensor = null;
@@ -300,7 +302,7 @@ namespace PepperDash.Essentials.Devices.Common
}
catch (Exception e)
{
Debug.Console(0, "ERROR:Unable to convert Crestnet ID: {0} to hex. Error:\n{1}", props.CresnetId, e);
Debug.Console(0, "ERROR:Unable to convert Cresnet ID: {0} to hex. Error:\n{1}", props.CresnetId, e);
}
switch (props.Model.ToLower())

View File

@@ -16,11 +16,16 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy
public BoolFeedback RoomIsOccupiedFeedback { get; private set; }
// Debug properties
public bool InTestMode { get; private set; }
public bool TestRoomIsOccupiedFeedback { get; private set; }
public Func<bool> RoomIsOccupiedFeedbackFunc
{
get
{
return () => OccSensor.OccupancyDetectedFeedback.BoolValue;
return () => InTestMode ? TestRoomIsOccupiedFeedback : OccSensor.OccupancyDetectedFeedback.BoolValue;
}
}
@@ -37,6 +42,25 @@ namespace PepperDash.Essentials.Devices.Common.Occupancy
{
RoomIsOccupiedFeedback.FireUpdate();
}
public void SetTestMode(bool mode)
{
InTestMode = mode;
Debug.Console(1, this, "In Mock Mode: '{0}'", InTestMode);
}
public void SetTestState(bool state)
{
if (!InTestMode)
Debug.Console(1, "Mock mode not enabled");
else
{
TestRoomIsOccupiedFeedback = state;
RoomIsOccupiedFeedback.FireUpdate();
}
}
}
/// <summary>