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

@@ -10,6 +10,6 @@ namespace PepperDash.Essentials.Core.CrestronIO
{
public string PortDeviceKey { get; set; }
public uint PortNumber { get; set; }
public bool DisablePullUpResistor { get; set; }
}
}

View File

@@ -12,7 +12,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
/// <summary>
/// Represents a generic digital input deviced tied to a versiport
/// </summary>
public class GenericVersiportInputDevice : Device, IDigitalInput
public class GenericVersiportDigitalInputDevice : Device, IDigitalInput
{
public Versiport InputPort { get; private set; }
@@ -26,7 +26,7 @@ namespace PepperDash.Essentials.Core.CrestronIO
}
}
public GenericVersiportInputDevice(string key, Versiport inputPort):
public GenericVersiportDigitalInputDevice(string key, Versiport inputPort):
base(key)
{
InputStateFeedback = new BoolFeedback(InputStateFeedbackFunc);
@@ -42,9 +42,39 @@ namespace PepperDash.Essentials.Core.CrestronIO
}
}
public class GenericVersiportInputDeviceConfigProperties
public class GenericVersibportAnalogInputDevice : Device, IDigitalInput
{
public Versiport InputPort { get; private set; }
public BoolFeedback InputStateFeedback { get; private set; }
public uint MinAnalogChange { get; private set; }
Func<bool> InputStateFeedbackFunc
{
get
{
return () => InputPort.AnalogIn > MinAnalogChange ? true : false;
}
}
public GenericVersibportAnalogInputDevice(string key, Versiport inputPort, uint minAnalogChange) :
base(key)
{
InputStateFeedback = new BoolFeedback(InputStateFeedbackFunc);
MinAnalogChange = minAnalogChange;
InputPort = inputPort;
InputPort.SetVersiportConfiguration(eVersiportConfiguration.AnalogInput);
InputPort.VersiportChange += new VersiportEventHandler(InputPort_VersiportChange);
}
void InputPort_VersiportChange(Versiport port, VersiportEventArgs args)
{
Debug.Console(1, this, "Versiport change: {0}", args.Event);
InputStateFeedback.FireUpdate();
}
}
}

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>

View File

@@ -32,7 +32,7 @@ namespace PepperDash.Essentials
public override void InitializeSystem()
{
//CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Reloads configuration file",
// ConsoleAccessLevelEnum.AccessOperator);
//ConsoleAccessLevelEnum.AccessOperator);
//CrestronConsole.AddNewConsoleCommand(s => TearDown(), "ungo", "Unloads configuration file",
// ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s =>

View File

@@ -130,11 +130,6 @@
<Compile Include="OTHER\Fusion\FusionEventHandlers.cs" />
<Compile Include="OTHER\Fusion\FusionProcessorQueries.cs" />
<Compile Include="OTHER\Fusion\FusionRviDataClasses.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="REMOVE EssentialsApp.cs" />
<Compile Include="OTHER\Fusion\EssentialsHuddleSpaceFusionSystemControllerBase.cs" />
<Compile Include="HttpApiHandler.cs" />
@@ -198,15 +193,6 @@
<Compile Include="UI\SubpageReferenceListSourceItem.cs" />
<None Include="app.config" />
<None Include="Properties\ControlSystem.cfg" />
<None Include="Resources\PepperDash Essentials iPad.sgd">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\PepperDash Essentials TSW-560.sgd">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Resources\PepperDash Essentials TSW-760.sgd">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Essentials Core\PepperDashEssentialsBase\PepperDash_Essentials_Core.csproj">
@@ -218,12 +204,6 @@
<Name>Essentials Devices Common</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.targets" />
<ProjectExtensions>
<VisualStudio>

View File

@@ -207,13 +207,13 @@ namespace PepperDash.Essentials
{
if ((sender as IOccupancyStatusProvider).RoomIsOccupiedFeedback.BoolValue == false)
{
Debug.Console(0, this, "Vacancy Detected");
Debug.Console(1, this, "Notice: Vacancy Detected");
// Trigger the timer when the room is vacant
StartRoomVacancyTimer(eVacancyMode.InInitialVacancy);
}
else
{
Debug.Console(0, this, "Occupancy Detected");
Debug.Console(1, this, "Notice: Occupancy Detected");
// Reset the timer when the room is occupied
RoomVacancyShutdownTimer.Cancel();