mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 20:24:57 +00:00
Removed funcs and updated feedbacks in constructor
This commit is contained in:
@@ -1,15 +1,9 @@
|
|||||||
using System;
|
using Crestron.SimplSharpPro;
|
||||||
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.GeneralIO;
|
using Crestron.SimplSharpPro.GeneralIO;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
using PepperDash_Essentials_Core.Bridges.JoinMaps;
|
using PepperDash_Essentials_Core.Bridges.JoinMaps;
|
||||||
|
|
||||||
@@ -18,15 +12,12 @@ namespace PepperDash.Essentials.Devices.Common.PartitionSensor
|
|||||||
[Description("Wrapper class for GLS Cresnet Partition Sensor")]
|
[Description("Wrapper class for GLS Cresnet Partition Sensor")]
|
||||||
public class GlsPartitionSensorController : CrestronGenericBridgeableBaseDevice
|
public class GlsPartitionSensorController : CrestronGenericBridgeableBaseDevice
|
||||||
{
|
{
|
||||||
public GlsPartCn PartitionSensor { get; private set; }
|
private readonly GlsPartCn _partitionSensor;
|
||||||
|
|
||||||
public StringFeedback NameFeedback { get; private set; }
|
public StringFeedback NameFeedback { get; private set; }
|
||||||
|
|
||||||
public BoolFeedback EnableFeedback { get; private set; }
|
public BoolFeedback EnableFeedback { get; private set; }
|
||||||
|
|
||||||
public BoolFeedback PartitionSensedFeedback { get; private set; }
|
public BoolFeedback PartitionSensedFeedback { get; private set; }
|
||||||
public BoolFeedback PartitionNotSensedFeedback { get; private set; }
|
public BoolFeedback PartitionNotSensedFeedback { get; private set; }
|
||||||
|
|
||||||
public IntFeedback SensitivityFeedback { get; private set; }
|
public IntFeedback SensitivityFeedback { get; private set; }
|
||||||
|
|
||||||
public bool InTestMode { get; private set; }
|
public bool InTestMode { get; private set; }
|
||||||
@@ -34,31 +25,6 @@ namespace PepperDash.Essentials.Devices.Common.PartitionSensor
|
|||||||
public bool TestPartitionSensedFeedback { get; private set; }
|
public bool TestPartitionSensedFeedback { get; private set; }
|
||||||
public int TestSensitivityFeedback { get; private set; }
|
public int TestSensitivityFeedback { get; private set; }
|
||||||
|
|
||||||
public Func<string> NameFeedbackFunc
|
|
||||||
{
|
|
||||||
get { return () => Name; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public Func<bool> EnableFeedbackFunc
|
|
||||||
{
|
|
||||||
get { return () => InTestMode ? TestEnableFeedback : PartitionSensor.EnableFeedback.BoolValue; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public Func<bool> PartitionSensedFeedbackFunc
|
|
||||||
{
|
|
||||||
get { return () => InTestMode ? TestPartitionSensedFeedback : PartitionSensor.PartitionSensedFeedback.BoolValue; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public Func<bool> PartitionNotSensedFeedbackFunc
|
|
||||||
{
|
|
||||||
get { return () => InTestMode ? TestPartitionSensedFeedback : PartitionSensor.PartitionNotSensedFeedback.BoolValue; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public Func<int> SensitivityFeedbackFunc
|
|
||||||
{
|
|
||||||
get { return () => InTestMode ? TestSensitivityFeedback : PartitionSensor.SensitivityFeedback.UShortValue; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -68,15 +34,15 @@ namespace PepperDash.Essentials.Devices.Common.PartitionSensor
|
|||||||
public GlsPartitionSensorController(string key, string name, GlsPartCn hardware)
|
public GlsPartitionSensorController(string key, string name, GlsPartCn hardware)
|
||||||
: base(key, name, hardware)
|
: base(key, name, hardware)
|
||||||
{
|
{
|
||||||
PartitionSensor = hardware;
|
_partitionSensor = hardware;
|
||||||
|
|
||||||
NameFeedback = new StringFeedback(NameFeedbackFunc);
|
NameFeedback = new StringFeedback(() => Name);
|
||||||
EnableFeedback = new BoolFeedback(EnableFeedbackFunc);
|
EnableFeedback = new BoolFeedback(() => _partitionSensor.EnableFeedback.BoolValue);
|
||||||
PartitionSensedFeedback = new BoolFeedback(PartitionSensedFeedbackFunc);
|
PartitionSensedFeedback = new BoolFeedback(() => _partitionSensor.PartitionSensedFeedback.BoolValue);
|
||||||
PartitionNotSensedFeedback = new BoolFeedback(PartitionNotSensedFeedbackFunc);
|
PartitionNotSensedFeedback = new BoolFeedback(() => _partitionSensor.PartitionNotSensedFeedback.BoolValue);
|
||||||
SensitivityFeedback = new IntFeedback(SensitivityFeedbackFunc);
|
SensitivityFeedback = new IntFeedback(() => _partitionSensor.SensitivityFeedback.UShortValue);
|
||||||
|
|
||||||
if (PartitionSensor != null) PartitionSensor.BaseEvent += PartitionSensor_BaseEvent;
|
if (_partitionSensor != null) _partitionSensor.BaseEvent += PartitionSensor_BaseEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -108,7 +74,7 @@ namespace PepperDash.Essentials.Devices.Common.PartitionSensor
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "args.EventId: {0}", args.EventId);
|
Debug.Console(2, this, "Unhandled args.EventId: {0}", args.EventId);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,37 +124,36 @@ namespace PepperDash.Essentials.Devices.Common.PartitionSensor
|
|||||||
|
|
||||||
public void SetEnableState(bool state)
|
public void SetEnableState(bool state)
|
||||||
{
|
{
|
||||||
if (PartitionSensor == null)
|
if (_partitionSensor == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PartitionSensor.Enable.BoolValue = state;
|
_partitionSensor.Enable.BoolValue = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void IncreaseSensitivity()
|
public void IncreaseSensitivity()
|
||||||
{
|
{
|
||||||
if (PartitionSensor == null)
|
if (_partitionSensor == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PartitionSensor.IncreaseSensitivity();
|
_partitionSensor.IncreaseSensitivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DecreaseSensitivity()
|
public void DecreaseSensitivity()
|
||||||
{
|
{
|
||||||
if (PartitionSensor == null)
|
if (_partitionSensor == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PartitionSensor.DecreaseSensitivity();
|
_partitionSensor.DecreaseSensitivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSensitivity(ushort value)
|
public void SetSensitivity(ushort value)
|
||||||
{
|
{
|
||||||
if (PartitionSensor == null)
|
if (_partitionSensor == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PartitionSensor.Sensitivity.UShortValue = (ushort)value;
|
_partitionSensor.Sensitivity.UShortValue = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
|
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
|
||||||
{
|
{
|
||||||
var joinMap = new GlsPartitionSensorJoinMap(joinStart);
|
var joinMap = new GlsPartitionSensorJoinMap(joinStart);
|
||||||
@@ -220,13 +185,13 @@ namespace PepperDash.Essentials.Devices.Common.PartitionSensor
|
|||||||
IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);
|
IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);
|
||||||
EnableFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Enable.JoinNumber]);
|
EnableFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Enable.JoinNumber]);
|
||||||
PartitionSensedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PartitionSensed.JoinNumber]);
|
PartitionSensedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PartitionSensed.JoinNumber]);
|
||||||
PartitionNotSensedFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PartitionNotSensed.JoinNumber]);
|
PartitionNotSensedFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PartitionNotSensed.JoinNumber]);
|
||||||
SensitivityFeedback.LinkInputSig(trilist.UShortInput[joinMap.Sensitivity.JoinNumber]);
|
SensitivityFeedback.LinkInputSig(trilist.UShortInput[joinMap.Sensitivity.JoinNumber]);
|
||||||
|
|
||||||
FeedbacksFireUpdates();
|
FeedbacksFireUpdates();
|
||||||
|
|
||||||
// update when device is online
|
// update when device is online
|
||||||
PartitionSensor.OnlineStatusChange += (o, a) =>
|
_partitionSensor.OnlineStatusChange += (o, a) =>
|
||||||
{
|
{
|
||||||
if (a.DeviceOnLine)
|
if (a.DeviceOnLine)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,13 +1,8 @@
|
|||||||
using System;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro.GeneralIO;
|
using Crestron.SimplSharpPro.GeneralIO;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
using PepperDash.Essentials.Devices.Common.Occupancy;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Common.PartitionSensor
|
namespace PepperDash.Essentials.Devices.Common.PartitionSensor
|
||||||
{
|
{
|
||||||
@@ -21,14 +16,11 @@ namespace PepperDash.Essentials.Devices.Common.PartitionSensor
|
|||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
||||||
{
|
{
|
||||||
Debug.Console(2, "Factory Attempting to create new GLS-PART-CN Device");
|
Debug.Console(2, "Factory Attempting to create new GLS-PART-CN Device");
|
||||||
|
|
||||||
var typeName = dc.Type.ToLower();
|
|
||||||
var key = dc.Key;
|
|
||||||
var name = dc.Name;
|
|
||||||
var comm = CommFactory.GetControlPropertiesConfig(dc);
|
var comm = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
if (comm == null)
|
if (comm == null)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "ERROR: Control Properties Config are null");
|
Debug.Console(0, "ERROR: Control Properties Config for {0} is null", dc.Key);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user