mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 20:24:57 +00:00
adjustments made based on testing with hardware
This commit is contained in:
@@ -127,8 +127,20 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
AddPostActivationAction(() =>
|
AddPostActivationAction(() =>
|
||||||
{
|
{
|
||||||
ApplySettingsToSensorFromConfig();
|
OccSensor.OnlineStatusChange += (o, a) =>
|
||||||
});
|
{
|
||||||
|
if (a.DeviceOnLine)
|
||||||
|
{
|
||||||
|
ApplySettingsToSensorFromConfig();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (OccSensor.IsOnline)
|
||||||
|
{
|
||||||
|
ApplySettingsToSensorFromConfig();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -62,8 +62,16 @@ namespace PepperDash.Essentials.Core
|
|||||||
DeviceConfig config)
|
DeviceConfig config)
|
||||||
: base(key, config.Name)
|
: base(key, config.Name)
|
||||||
{
|
{
|
||||||
|
var props = config.Properties.ToObject<GlsOccupancySensorPropertiesConfig>();
|
||||||
|
|
||||||
PropertiesConfig = config.Properties.ToObject<GlsOccupancySensorPropertiesConfig>();
|
if (props != null)
|
||||||
|
{
|
||||||
|
PropertiesConfig = props;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "props are null. Unable to deserialize into GlsOccupancySensorPropertiesConfig");
|
||||||
|
}
|
||||||
|
|
||||||
AddPreActivationAction(() =>
|
AddPreActivationAction(() =>
|
||||||
{
|
{
|
||||||
@@ -77,12 +85,36 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
AddPostActivationAction(() =>
|
AddPostActivationAction(() =>
|
||||||
{
|
{
|
||||||
ApplySettingsToSensorFromConfig();
|
OccSensor.OnlineStatusChange += (o, a) =>
|
||||||
});
|
{
|
||||||
|
if (a.DeviceOnLine)
|
||||||
|
{
|
||||||
|
ApplySettingsToSensorFromConfig();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public GlsOccupancySensorBaseController(string key, string name) : base(key, name) { }
|
public GlsOccupancySensorBaseController(string key, string name)
|
||||||
|
: base(key, name)
|
||||||
|
{
|
||||||
|
AddPostActivationAction(() =>
|
||||||
|
{
|
||||||
|
OccSensor.OnlineStatusChange += (o, a) =>
|
||||||
|
{
|
||||||
|
if (a.DeviceOnLine)
|
||||||
|
{
|
||||||
|
ApplySettingsToSensorFromConfig();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (OccSensor.IsOnline)
|
||||||
|
{
|
||||||
|
ApplySettingsToSensorFromConfig();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -90,20 +122,33 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual void ApplySettingsToSensorFromConfig()
|
protected virtual void ApplySettingsToSensorFromConfig()
|
||||||
{
|
{
|
||||||
|
Debug.Console(1, this, "Attempting to apply settings to sensor from config");
|
||||||
|
|
||||||
if (PropertiesConfig.EnablePir != null)
|
if (PropertiesConfig.EnablePir != null)
|
||||||
{
|
{
|
||||||
|
Debug.Console(1, this, "EnablePir found, attempting to set value from config");
|
||||||
SetPirEnable((bool)PropertiesConfig.EnablePir);
|
SetPirEnable((bool)PropertiesConfig.EnablePir);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "EnablePir null, no value specified in config");
|
||||||
|
}
|
||||||
|
|
||||||
if (PropertiesConfig.EnableLedFlash != null)
|
if (PropertiesConfig.EnableLedFlash != null)
|
||||||
{
|
{
|
||||||
|
Debug.Console(1, this, "EnableLedFlash found, attempting to set value from config");
|
||||||
SetLedFlashEnable((bool)PropertiesConfig.EnableLedFlash);
|
SetLedFlashEnable((bool)PropertiesConfig.EnableLedFlash);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PropertiesConfig.RemoteTimeout != null)
|
if (PropertiesConfig.RemoteTimeout != null)
|
||||||
{
|
{
|
||||||
|
Debug.Console(1, this, "RemoteTimeout found, attempting to set value from config");
|
||||||
SetRemoteTimeout((ushort)PropertiesConfig.RemoteTimeout);
|
SetRemoteTimeout((ushort)PropertiesConfig.RemoteTimeout);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "RemoteTimeout null, no value specified in config");
|
||||||
|
}
|
||||||
|
|
||||||
if (PropertiesConfig.ShortTimeoutState != null)
|
if (PropertiesConfig.ShortTimeoutState != null)
|
||||||
{
|
{
|
||||||
@@ -247,6 +292,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <param name="state"></param>
|
/// <param name="state"></param>
|
||||||
public void SetPirEnable(bool state)
|
public void SetPirEnable(bool state)
|
||||||
{
|
{
|
||||||
|
Debug.Console(1, this, "Setting EnablePir to: {0}", state);
|
||||||
|
|
||||||
if (state)
|
if (state)
|
||||||
{
|
{
|
||||||
OccSensor.EnablePir.BoolValue = state;
|
OccSensor.EnablePir.BoolValue = state;
|
||||||
@@ -332,6 +379,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public void SetRemoteTimeout(ushort time)
|
public void SetRemoteTimeout(ushort time)
|
||||||
{
|
{
|
||||||
|
Debug.Console(1, this, "Setting RemoteTimout to: {0}", time);
|
||||||
|
|
||||||
OccSensor.RemoteTimeout.UShortValue = time;
|
OccSensor.RemoteTimeout.UShortValue = time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInOccupiedStateFeedback.UShortValue);
|
UltrasonicSensitivityInOccupiedStateFeedback = new IntFeedback(() => OccSensor.UsSensitivityInOccupiedStateFeedback.UShortValue);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void ApplySettingsToSensorFromConfig()
|
protected override void ApplySettingsToSensorFromConfig()
|
||||||
@@ -73,13 +75,25 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
if (PropertiesConfig.EnableUsA != null)
|
if (PropertiesConfig.EnableUsA != null)
|
||||||
{
|
{
|
||||||
|
Debug.Console(1, this, "EnableUsA found, attempting to set value from config");
|
||||||
SetUsAEnable((bool)PropertiesConfig.EnableUsA);
|
SetUsAEnable((bool)PropertiesConfig.EnableUsA);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "EnableUsA null, no value specified in config");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (PropertiesConfig.EnableUsB != null)
|
if (PropertiesConfig.EnableUsB != null)
|
||||||
{
|
{
|
||||||
|
Debug.Console(1, this, "EnableUsB found, attempting to set value from config");
|
||||||
SetUsBEnable((bool)PropertiesConfig.EnableUsB);
|
SetUsBEnable((bool)PropertiesConfig.EnableUsB);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "EnablePir null, no value specified in config");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (PropertiesConfig.OrWhenVacatedState != null)
|
if (PropertiesConfig.OrWhenVacatedState != null)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user