mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 12:15:01 +00:00
Merge branch 'development-2.0.0' into feature-2.0.0/remove-crestron-io
This commit is contained in:
@@ -1,43 +0,0 @@
|
|||||||
using System;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
|
||||||
{
|
|
||||||
[Obsolete("This Device will be moved to a plugin in a future update")]
|
|
||||||
public class DigitalLoggerJoinMap : JoinMapBase
|
|
||||||
{
|
|
||||||
public uint IsOnline { get; set; }
|
|
||||||
public uint CircuitNames { get; set; }
|
|
||||||
public uint CircuitState { get; set; }
|
|
||||||
public uint CircuitCycle { get; set; }
|
|
||||||
public uint CircuitIsCritical { get; set; }
|
|
||||||
public uint CircuitOnCmd { get; set; }
|
|
||||||
public uint CircuitOffCmd { get; set; }
|
|
||||||
|
|
||||||
public DigitalLoggerJoinMap()
|
|
||||||
{
|
|
||||||
// Digital
|
|
||||||
IsOnline = 9;
|
|
||||||
CircuitState = 0;
|
|
||||||
CircuitCycle = 0;
|
|
||||||
CircuitIsCritical = 10;
|
|
||||||
CircuitOnCmd = 10;
|
|
||||||
CircuitOffCmd = 20;
|
|
||||||
// Serial
|
|
||||||
CircuitNames = 0;
|
|
||||||
// Analog
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OffsetJoinNumbers(uint joinStart)
|
|
||||||
{
|
|
||||||
var joinOffset = joinStart - 1;
|
|
||||||
|
|
||||||
IsOnline = IsOnline + joinOffset;
|
|
||||||
CircuitNames = CircuitNames + joinOffset;
|
|
||||||
CircuitState = CircuitState + joinOffset;
|
|
||||||
CircuitCycle = CircuitCycle + joinOffset;
|
|
||||||
CircuitIsCritical = CircuitIsCritical + joinOffset;
|
|
||||||
CircuitOnCmd = CircuitOnCmd + joinOffset;
|
|
||||||
CircuitOffCmd = CircuitOffCmd + joinOffset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -155,146 +155,3 @@ namespace PepperDash.Essentials.Core.Bridges.JoinMaps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace PepperDash_Essentials_Core.Bridges.JoinMaps
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("use PepperDash.Essentials.Core.Bridges.JoinMaps version")]
|
|
||||||
public class GlsPartitionSensorJoinMap:JoinMapBaseAdvanced
|
|
||||||
{
|
|
||||||
[JoinName("IsOnline")]
|
|
||||||
public JoinDataComplete IsOnline = new JoinDataComplete(
|
|
||||||
new JoinData
|
|
||||||
{
|
|
||||||
JoinNumber = 1,
|
|
||||||
JoinSpan = 1
|
|
||||||
},
|
|
||||||
new JoinMetadata
|
|
||||||
{
|
|
||||||
Description = "Sensor Is Online",
|
|
||||||
JoinCapabilities = eJoinCapabilities.ToSIMPL,
|
|
||||||
JoinType = eJoinType.Digital
|
|
||||||
});
|
|
||||||
|
|
||||||
[JoinName("Name")]
|
|
||||||
public JoinDataComplete Name = new JoinDataComplete(
|
|
||||||
new JoinData
|
|
||||||
{
|
|
||||||
JoinNumber = 1,
|
|
||||||
JoinSpan = 1
|
|
||||||
},
|
|
||||||
new JoinMetadata
|
|
||||||
{
|
|
||||||
Description = "Sensor Name",
|
|
||||||
JoinCapabilities = eJoinCapabilities.ToSIMPL,
|
|
||||||
JoinType = eJoinType.Serial
|
|
||||||
});
|
|
||||||
|
|
||||||
[JoinName("Enable")]
|
|
||||||
public JoinDataComplete Enable = new JoinDataComplete(
|
|
||||||
new JoinData
|
|
||||||
{
|
|
||||||
JoinNumber = 2,
|
|
||||||
JoinSpan = 1
|
|
||||||
},
|
|
||||||
new JoinMetadata
|
|
||||||
{
|
|
||||||
Description = "Sensor Enable",
|
|
||||||
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
|
|
||||||
JoinType = eJoinType.Digital
|
|
||||||
});
|
|
||||||
|
|
||||||
[JoinName("PartitionSensed")]
|
|
||||||
public JoinDataComplete PartitionSensed = new JoinDataComplete(
|
|
||||||
new JoinData
|
|
||||||
{
|
|
||||||
JoinNumber = 3,
|
|
||||||
JoinSpan = 1
|
|
||||||
},
|
|
||||||
new JoinMetadata
|
|
||||||
{
|
|
||||||
Description = "Sensor Partition Sensed",
|
|
||||||
JoinCapabilities = eJoinCapabilities.ToSIMPL,
|
|
||||||
JoinType = eJoinType.Digital
|
|
||||||
});
|
|
||||||
|
|
||||||
[JoinName("PartitionNotSensed")]
|
|
||||||
public JoinDataComplete PartitionNotSensed = new JoinDataComplete(
|
|
||||||
new JoinData
|
|
||||||
{
|
|
||||||
JoinNumber = 4,
|
|
||||||
JoinSpan = 1
|
|
||||||
},
|
|
||||||
new JoinMetadata
|
|
||||||
{
|
|
||||||
Description = "Sensor Partition Not Sensed",
|
|
||||||
JoinCapabilities = eJoinCapabilities.ToSIMPL,
|
|
||||||
JoinType = eJoinType.Digital
|
|
||||||
});
|
|
||||||
|
|
||||||
[JoinName("IncreaseSensitivity")]
|
|
||||||
public JoinDataComplete IncreaseSensitivity = new JoinDataComplete(
|
|
||||||
new JoinData
|
|
||||||
{
|
|
||||||
JoinNumber = 6,
|
|
||||||
JoinSpan = 1
|
|
||||||
},
|
|
||||||
new JoinMetadata
|
|
||||||
{
|
|
||||||
Description = "Sensor Increase Sensitivity",
|
|
||||||
JoinCapabilities = eJoinCapabilities.FromSIMPL,
|
|
||||||
JoinType = eJoinType.Digital
|
|
||||||
});
|
|
||||||
|
|
||||||
[JoinName("DecreaseSensitivity")]
|
|
||||||
public JoinDataComplete DecreaseSensitivity = new JoinDataComplete(
|
|
||||||
new JoinData
|
|
||||||
{
|
|
||||||
JoinNumber = 7,
|
|
||||||
JoinSpan = 1
|
|
||||||
},
|
|
||||||
new JoinMetadata
|
|
||||||
{
|
|
||||||
Description = "Sensor Decrease Sensitivity",
|
|
||||||
JoinCapabilities = eJoinCapabilities.FromSIMPL,
|
|
||||||
JoinType = eJoinType.Digital
|
|
||||||
});
|
|
||||||
|
|
||||||
[JoinName("Sensitivity")]
|
|
||||||
public JoinDataComplete Sensitivity = new JoinDataComplete(
|
|
||||||
new JoinData
|
|
||||||
{
|
|
||||||
JoinNumber = 2,
|
|
||||||
JoinSpan = 1
|
|
||||||
},
|
|
||||||
new JoinMetadata
|
|
||||||
{
|
|
||||||
Description = "Sensor Sensitivity",
|
|
||||||
JoinCapabilities = eJoinCapabilities.ToFromSIMPL,
|
|
||||||
JoinType = eJoinType.Analog
|
|
||||||
});
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor to use when instantiating this Join Map without inheriting from it
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="joinStart">Join this join map will start at</param>
|
|
||||||
public GlsPartitionSensorJoinMap(uint joinStart)
|
|
||||||
: this(joinStart, typeof(GlsPartitionSensorJoinMap))
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor to use when extending this Join map
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="joinStart">Join this join map will start at</param>
|
|
||||||
/// <param name="type">Type of the child join map</param>
|
|
||||||
protected GlsPartitionSensorJoinMap(uint joinStart, Type type)
|
|
||||||
: base(joinStart, type)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -7,14 +7,4 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
|||||||
bool BrandingEnabled { get; }
|
bool BrandingEnabled { get; }
|
||||||
void InitializeBranding(string roomKey);
|
void InitializeBranding(string roomKey);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
namespace PepperDash_Essentials_Core.DeviceTypeInterfaces
|
|
||||||
{
|
|
||||||
[Obsolete("Use PepperDash.Essentials.Core.DeviceTypeInterfaces")]
|
|
||||||
public interface IHasBranding
|
|
||||||
{
|
|
||||||
bool BrandingEnabled { get; }
|
|
||||||
void InitializeBranding(string roomKey);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -12,18 +12,4 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
|||||||
void EndPhoneCall();
|
void EndPhoneCall();
|
||||||
void SendDtmfToPhone(string digit);
|
void SendDtmfToPhone(string digit);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
namespace PepperDash_Essentials_Core.DeviceTypeInterfaces
|
|
||||||
{
|
|
||||||
[Obsolete("Use PepperDash.Essentials.Core.DeviceTypeInterfaces")]
|
|
||||||
public interface IHasPhoneDialing
|
|
||||||
{
|
|
||||||
BoolFeedback PhoneOffHookFeedback { get; }
|
|
||||||
StringFeedback CallerIdNameFeedback { get; }
|
|
||||||
StringFeedback CallerIdNumberFeedback { get; }
|
|
||||||
void DialPhoneCall(string number);
|
|
||||||
void EndPhoneCall();
|
|
||||||
void SendDtmfToPhone(string digit);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -16,20 +16,3 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
|||||||
List<LanguageLabel> RoomNames { get; set; }
|
List<LanguageLabel> RoomNames { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace PepperDash_Essentials_Core.DeviceTypeInterfaces
|
|
||||||
{
|
|
||||||
[Obsolete("Use PepperDash.Essentials.Core.DeviceTypeInterfaces")]
|
|
||||||
public interface ILanguageDefinition
|
|
||||||
{
|
|
||||||
string LocaleName { get; set; }
|
|
||||||
string FriendlyName { get; set; }
|
|
||||||
bool Enable { get; set; }
|
|
||||||
List<LanguageLabel> UiLabels { get; set; }
|
|
||||||
List<LanguageLabel> Sources { get; set; }
|
|
||||||
List<LanguageLabel> Destinations { get; set; }
|
|
||||||
List<LanguageLabel> SourceGroupNames { get; set; }
|
|
||||||
List<LanguageLabel> DestinationGroupNames { get; set; }
|
|
||||||
List<LanguageLabel> RoomNames { get; set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -11,15 +11,3 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace PepperDash_Essentials_Core.DeviceTypeInterfaces
|
|
||||||
{
|
|
||||||
[Obsolete("Use PepperDash.Essentials.Core.DeviceTypeInterfaces")]
|
|
||||||
public interface ILanguageProvider
|
|
||||||
{
|
|
||||||
ILanguageDefinition CurrentLanguage { get; set; }
|
|
||||||
|
|
||||||
event EventHandler CurrentLanguageChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -13,17 +13,6 @@ using PepperDash.Essentials.Core.SmartObjects;
|
|||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// Defines the ability to power a device on and off
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Will be replaced by IHasPowerControlWithFeedback")]
|
|
||||||
public interface IPower
|
|
||||||
{
|
|
||||||
void PowerOn();
|
|
||||||
void PowerOff();
|
|
||||||
void PowerToggle();
|
|
||||||
BoolFeedback PowerIsOnFeedback { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Adds feedback for current power state
|
/// Adds feedback for current power state
|
||||||
|
|||||||
@@ -10,16 +10,4 @@ namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
|
|||||||
public string DisplayText { get; set; }
|
public string DisplayText { get; set; }
|
||||||
public uint JoinNumber { get; set; }
|
public uint JoinNumber { get; set; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
namespace PepperDash_Essentials_Core.DeviceTypeInterfaces
|
|
||||||
{
|
|
||||||
[Obsolete("Use PepperDash.Essentials.Core.DeviceTypeInterfaces")]
|
|
||||||
public class LanguageLabel
|
|
||||||
{
|
|
||||||
public string Key { get; set; }
|
|
||||||
public string Description { get; set; }
|
|
||||||
public string DisplayText { get; set; }
|
|
||||||
public uint JoinNumber { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -35,35 +35,6 @@ namespace PepperDash.Essentials.Core.Devices
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Generic monitor for TCP reachability. Default with 30s poll, 120s warning and 300s error times
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete]
|
|
||||||
public GenericCommunicationMonitoredDevice(string key, string name, string hostname, int port, string pollString)
|
|
||||||
: this(key, name, hostname, port, pollString, 30000, 120000, 300000)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Monitor for TCP reachability
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete]
|
|
||||||
public GenericCommunicationMonitoredDevice(string key, string name, string hostname, int port, string pollString,
|
|
||||||
long pollTime, long warningTime, long errorTime)
|
|
||||||
: base(key, name)
|
|
||||||
{
|
|
||||||
Client = new GenericTcpIpClient(key + "-tcp", hostname, port, 512);
|
|
||||||
CommunicationMonitor = new GenericCommunicationMonitor(this, Client, pollTime, warningTime, errorTime, pollString);
|
|
||||||
|
|
||||||
// ------------------------------------------------------DELETE THIS
|
|
||||||
CommunicationMonitor.StatusChange += (o, a) =>
|
|
||||||
{
|
|
||||||
Debug.Console(2, this, "Communication monitor status change: {0}", a.Status);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public override bool CustomActivate()
|
public override bool CustomActivate()
|
||||||
{
|
{
|
||||||
CommunicationMonitor.Start();
|
CommunicationMonitor.Start();
|
||||||
|
|||||||
@@ -9,18 +9,6 @@ using Crestron.SimplSharpPro.UI;
|
|||||||
|
|
||||||
namespace PepperDash.Essentials.Core
|
namespace PepperDash.Essentials.Core
|
||||||
{
|
{
|
||||||
//[Obsolete]
|
|
||||||
//public class PresentationDeviceType
|
|
||||||
//{
|
|
||||||
// public const ushort Default = 1;
|
|
||||||
// public const ushort CableSetTopBox = 2;
|
|
||||||
// public const ushort SatelliteSetTopBox = 3;
|
|
||||||
// public const ushort Dvd = 4;
|
|
||||||
// public const ushort Bluray = 5;
|
|
||||||
// public const ushort PC = 9;
|
|
||||||
// public const ushort Laptop = 10;
|
|
||||||
//}
|
|
||||||
|
|
||||||
public enum PresentationSourceType
|
public enum PresentationSourceType
|
||||||
{
|
{
|
||||||
None, Dvd, Laptop, PC, SetTopBox, VCR
|
None, Dvd, Laptop, PC, SetTopBox, VCR
|
||||||
|
|||||||
@@ -20,9 +20,6 @@ namespace PepperDash.Essentials.Core
|
|||||||
public IrOutputPortController IrPort { get; private set; }
|
public IrOutputPortController IrPort { get; private set; }
|
||||||
public ushort IrPulseTime { get; set; }
|
public ushort IrPulseTime { get; set; }
|
||||||
|
|
||||||
[Obsolete("This property will be removed in version 2.0.0")]
|
|
||||||
public override BoolFeedback PowerIsOnFeedback { get; protected set; }
|
|
||||||
|
|
||||||
protected Func<bool> PowerIsOnFeedbackFunc
|
protected Func<bool> PowerIsOnFeedbackFunc
|
||||||
{
|
{
|
||||||
get { return () => _PowerIsOn; }
|
get { return () => _PowerIsOn; }
|
||||||
@@ -46,14 +43,6 @@ namespace PepperDash.Essentials.Core
|
|||||||
IrPort = new IrOutputPortController(key + "-ir", port, irDriverFilepath);
|
IrPort = new IrOutputPortController(key + "-ir", port, irDriverFilepath);
|
||||||
DeviceManager.AddDevice(IrPort);
|
DeviceManager.AddDevice(IrPort);
|
||||||
|
|
||||||
PowerIsOnFeedback = new BoolFeedback(PowerIsOnFeedbackFunc);
|
|
||||||
|
|
||||||
PowerIsOnFeedback.OutputChange += (o, a) =>
|
|
||||||
{
|
|
||||||
Debug.Console(2, this, "Power on={0}", _PowerIsOn);
|
|
||||||
if (_PowerIsOn) StartWarmingTimer();
|
|
||||||
else StartCoolingTimer();
|
|
||||||
};
|
|
||||||
IsWarmingUpFeedback.OutputChange += (o, a) => Debug.Console(2, this, "Warming up={0}", _IsWarmingUp);
|
IsWarmingUpFeedback.OutputChange += (o, a) => Debug.Console(2, this, "Warming up={0}", _IsWarmingUp);
|
||||||
IsCoolingDownFeedback.OutputChange += (o, a) => Debug.Console(2, this, "Cooling down={0}", _IsCoolingDown);
|
IsCoolingDownFeedback.OutputChange += (o, a) => Debug.Console(2, this, "Cooling down={0}", _IsCoolingDown);
|
||||||
|
|
||||||
@@ -117,20 +106,17 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
IrPort.Pulse(IROutputStandardCommands.IROut_POWER_ON, IrPulseTime);
|
IrPort.Pulse(IROutputStandardCommands.IROut_POWER_ON, IrPulseTime);
|
||||||
_PowerIsOn = true;
|
_PowerIsOn = true;
|
||||||
PowerIsOnFeedback.FireUpdate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PowerOff()
|
public override void PowerOff()
|
||||||
{
|
{
|
||||||
_PowerIsOn = false;
|
_PowerIsOn = false;
|
||||||
PowerIsOnFeedback.FireUpdate();
|
|
||||||
IrPort.Pulse(IROutputStandardCommands.IROut_POWER_OFF, IrPulseTime);
|
IrPort.Pulse(IROutputStandardCommands.IROut_POWER_OFF, IrPulseTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PowerToggle()
|
public override void PowerToggle()
|
||||||
{
|
{
|
||||||
_PowerIsOn = false;
|
_PowerIsOn = false;
|
||||||
PowerIsOnFeedback.FireUpdate();
|
|
||||||
IrPort.Pulse(IROutputStandardCommands.IROut_POWER, IrPulseTime);
|
IrPort.Pulse(IROutputStandardCommands.IROut_POWER, IrPulseTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -193,7 +179,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
action();
|
action();
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!PowerIsOnFeedback.BoolValue)
|
if (!_PowerIsOn)
|
||||||
{
|
{
|
||||||
PowerOn();
|
PowerOn();
|
||||||
EventHandler<FeedbackEventArgs> oneTimer = null;
|
EventHandler<FeedbackEventArgs> oneTimer = null;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class DisplayBase : EssentialsDevice, IHasFeedback, IRoutingSinkWithSwitching, IHasPowerControl, IWarmingCooling, IUsageTracking, IPower
|
public abstract class DisplayBase : EssentialsDevice, IHasFeedback, IRoutingSinkWithSwitching, IHasPowerControl, IWarmingCooling, IUsageTracking
|
||||||
{
|
{
|
||||||
public event SourceInfoChangeHandler CurrentSourceChange;
|
public event SourceInfoChangeHandler CurrentSourceChange;
|
||||||
|
|
||||||
@@ -51,9 +51,6 @@ namespace PepperDash.Essentials.Core
|
|||||||
public BoolFeedback IsCoolingDownFeedback { get; protected set; }
|
public BoolFeedback IsCoolingDownFeedback { get; protected set; }
|
||||||
public BoolFeedback IsWarmingUpFeedback { get; private set; }
|
public BoolFeedback IsWarmingUpFeedback { get; private set; }
|
||||||
|
|
||||||
[Obsolete("This property will be removed in version 2.0.0")]
|
|
||||||
public abstract BoolFeedback PowerIsOnFeedback { get; protected set; }
|
|
||||||
|
|
||||||
public UsageTracking UsageTracker { get; set; }
|
public UsageTracking UsageTracker { get; set; }
|
||||||
|
|
||||||
public uint WarmupTime { get; set; }
|
public uint WarmupTime { get; set; }
|
||||||
@@ -269,7 +266,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
abstract protected Func<string> CurrentInputFeedbackFunc { get; }
|
abstract protected Func<string> CurrentInputFeedbackFunc { get; }
|
||||||
|
|
||||||
public override BoolFeedback PowerIsOnFeedback { get; protected set; }
|
public BoolFeedback PowerIsOnFeedback { get; protected set; }
|
||||||
|
|
||||||
abstract protected Func<bool> PowerIsOnFeedbackFunc { get; }
|
abstract protected Func<bool> PowerIsOnFeedbackFunc { get; }
|
||||||
|
|
||||||
|
|||||||
@@ -23,24 +23,3 @@ namespace PepperDash.Essentials.Core
|
|||||||
bool IsReady { get; }
|
bool IsReady { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace PepperDash_Essentials_Core
|
|
||||||
{
|
|
||||||
[Obsolete("Use PepperDash.Essentials.Core")]
|
|
||||||
public class IsReadyEventArgs : EventArgs
|
|
||||||
{
|
|
||||||
public bool IsReady { get; set; }
|
|
||||||
|
|
||||||
public IsReadyEventArgs(bool data)
|
|
||||||
{
|
|
||||||
IsReady = data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete("Use PepperDash.Essentials.Core")]
|
|
||||||
public interface IHasReady
|
|
||||||
{
|
|
||||||
event EventHandler<IsReadyEventArgs> IsReadyEvent;
|
|
||||||
bool IsReady { get; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -81,97 +81,6 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Base class for join maps
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("This is being deprecated in favor of JoinMapBaseAdvanced")]
|
|
||||||
public abstract class JoinMapBase
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Modifies all the join numbers by adding the offset. This should never be called twice
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="joinStart"></param>
|
|
||||||
public abstract void OffsetJoinNumbers(uint joinStart);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The collection of joins and associated metadata
|
|
||||||
/// </summary>
|
|
||||||
public Dictionary<string, JoinMetadata> Joins = new Dictionary<string, JoinMetadata>();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Prints the join information to console
|
|
||||||
/// </summary>
|
|
||||||
public void PrintJoinMapInfo()
|
|
||||||
{
|
|
||||||
CrestronConsole.ConsoleCommandResponse("{0}:\n", GetType().Name);
|
|
||||||
|
|
||||||
// Get the joins of each type and print them
|
|
||||||
CrestronConsole.ConsoleCommandResponse("Digitals:");
|
|
||||||
var digitals = Joins.Where(j => (j.Value.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value);
|
|
||||||
CrestronConsole.ConsoleCommandResponse("Found {0} Digital Joins", digitals.Count);
|
|
||||||
PrintJoinList(GetSortedJoins(digitals));
|
|
||||||
|
|
||||||
CrestronConsole.ConsoleCommandResponse("Analogs:");
|
|
||||||
var analogs = Joins.Where(j => (j.Value.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value);
|
|
||||||
CrestronConsole.ConsoleCommandResponse("Found {0} Analog Joins", analogs.Count);
|
|
||||||
PrintJoinList(GetSortedJoins(analogs));
|
|
||||||
|
|
||||||
CrestronConsole.ConsoleCommandResponse("Serials:");
|
|
||||||
var serials = Joins.Where(j => (j.Value.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value);
|
|
||||||
CrestronConsole.ConsoleCommandResponse("Found {0} Serial Joins", serials.Count);
|
|
||||||
PrintJoinList(GetSortedJoins(serials));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns a sorted list by JoinNumber
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="joins"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
List<KeyValuePair<string, JoinMetadata>> GetSortedJoins(Dictionary<string, JoinMetadata> joins)
|
|
||||||
{
|
|
||||||
var sortedJoins = joins.ToList();
|
|
||||||
|
|
||||||
sortedJoins.Sort((pair1, pair2) => pair1.Value.JoinNumber.CompareTo(pair2.Value.JoinNumber));
|
|
||||||
|
|
||||||
return sortedJoins;
|
|
||||||
}
|
|
||||||
|
|
||||||
void PrintJoinList(List<KeyValuePair<string, JoinMetadata>> joins)
|
|
||||||
{
|
|
||||||
foreach (var join in joins)
|
|
||||||
{
|
|
||||||
CrestronConsole.ConsoleCommandResponse(
|
|
||||||
@"Join Number: {0} | Label: '{1}' | JoinSpan: '{2}' | Type: '{3}' | Capabilities: '{4}'",
|
|
||||||
join.Value.JoinNumber,
|
|
||||||
join.Value.Label,
|
|
||||||
join.Value.JoinSpan,
|
|
||||||
join.Value.JoinType.ToString(),
|
|
||||||
join.Value.JoinCapabilities.ToString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the join number for the join with the specified key
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public uint GetJoinForKey(string key)
|
|
||||||
{
|
|
||||||
return Joins.ContainsKey(key) ? Joins[key].JoinNumber : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the join span for the join with the specified key
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
public uint GetJoinSpanForKey(string key)
|
|
||||||
{
|
|
||||||
return Joins.ContainsKey(key) ? Joins[key].JoinSpan : 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Base class for join maps
|
/// Base class for join maps
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -432,27 +341,6 @@ namespace PepperDash.Essentials.Core
|
|||||||
public class JoinMetadata
|
public class JoinMetadata
|
||||||
{
|
{
|
||||||
private string _description;
|
private string _description;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Join number (based on join offset value)
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("joinNumber")]
|
|
||||||
[Obsolete]
|
|
||||||
public uint JoinNumber { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Join range span. If join indicates the start of a range of joins, this indicated the maximum number of joins in the range
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete]
|
|
||||||
[JsonProperty("joinSpan")]
|
|
||||||
public uint JoinSpan { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// A label for the join to better describe its usage
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Use Description instead")]
|
|
||||||
[JsonProperty("label")]
|
|
||||||
public string Label { get { return _description; } set { _description = value; } }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A description for the join to better describe its usage
|
/// A description for the join to better describe its usage
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -62,78 +62,6 @@ namespace PepperDash.Essentials.Core.Queues
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Shows either the byte[] or string to be sent
|
|
||||||
/// </summary>
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return _bytes != null ? _bytes.ToString() : _string;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace PepperDash_Essentials_Core.Queues
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// IBasicCommunication Message for IQueue
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Use PepperDash.Essentials.Core.Queues")]
|
|
||||||
public class ComsMessage : IQueueMessage
|
|
||||||
{
|
|
||||||
private readonly byte[] _bytes;
|
|
||||||
private readonly IBasicCommunication _coms;
|
|
||||||
private readonly string _string;
|
|
||||||
private readonly bool _isByteMessage;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor for a string message
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="coms">IBasicCommunication to send the message</param>
|
|
||||||
/// <param name="message">Message to send</param>
|
|
||||||
public ComsMessage(IBasicCommunication coms, string message)
|
|
||||||
{
|
|
||||||
Validate(coms, message);
|
|
||||||
_coms = coms;
|
|
||||||
_string = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor for a byte message
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="coms">IBasicCommunication to send the message</param>
|
|
||||||
/// <param name="message">Message to send</param>
|
|
||||||
public ComsMessage(IBasicCommunication coms, byte[] message)
|
|
||||||
{
|
|
||||||
Validate(coms, message);
|
|
||||||
_coms = coms;
|
|
||||||
_bytes = message;
|
|
||||||
_isByteMessage = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Validate(IBasicCommunication coms, object message)
|
|
||||||
{
|
|
||||||
if (coms == null)
|
|
||||||
throw new ArgumentNullException("coms");
|
|
||||||
|
|
||||||
if (message == null)
|
|
||||||
throw new ArgumentNullException("message");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Dispatchs the string/byte[] to the IBasicCommunication specified
|
|
||||||
/// </summary>
|
|
||||||
public void Dispatch()
|
|
||||||
{
|
|
||||||
if (_isByteMessage)
|
|
||||||
{
|
|
||||||
_coms.SendBytes(_bytes);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_coms.SendText(_string);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Shows either the byte[] or string to be sent
|
/// Shows either the byte[] or string to be sent
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Threading;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharp.Reflection;
|
|
||||||
using Crestron.SimplSharpPro.CrestronThread;
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
using Thread = Crestron.SimplSharpPro.CrestronThread.Thread;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Queues
|
namespace PepperDash.Essentials.Core.Queues
|
||||||
{
|
{
|
||||||
@@ -12,7 +13,7 @@ namespace PepperDash.Essentials.Core.Queues
|
|||||||
public class GenericQueue : IQueue<IQueueMessage>
|
public class GenericQueue : IQueue<IQueueMessage>
|
||||||
{
|
{
|
||||||
private readonly string _key;
|
private readonly string _key;
|
||||||
protected readonly CrestronQueue<IQueueMessage> _queue;
|
protected readonly ConcurrentQueue<IQueueMessage> _queue;
|
||||||
protected readonly Thread _worker;
|
protected readonly Thread _worker;
|
||||||
protected readonly CEvent _waitHandle = new CEvent();
|
protected readonly CEvent _waitHandle = new CEvent();
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@ namespace PepperDash.Essentials.Core.Queues
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _queue.Size;
|
return int.MaxValue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,7 +138,8 @@ namespace PepperDash.Essentials.Core.Queues
|
|||||||
{
|
{
|
||||||
cap = capacity; // overrides default
|
cap = capacity; // overrides default
|
||||||
}
|
}
|
||||||
_queue = new CrestronQueue<IQueueMessage>(cap);
|
|
||||||
|
_queue = new ConcurrentQueue<IQueueMessage>();
|
||||||
_worker = new Thread(ProcessQueue, null, Thread.eThreadStartOptions.Running)
|
_worker = new Thread(ProcessQueue, null, Thread.eThreadStartOptions.Running)
|
||||||
{
|
{
|
||||||
Priority = priority,
|
Priority = priority,
|
||||||
@@ -170,14 +172,9 @@ namespace PepperDash.Essentials.Core.Queues
|
|||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
IQueueMessage item = null;
|
if (_queue.TryDequeue(out var item) && item == null)
|
||||||
|
break;
|
||||||
|
|
||||||
if (_queue.Count > 0)
|
|
||||||
{
|
|
||||||
item = _queue.Dequeue();
|
|
||||||
if (item == null)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -188,7 +185,7 @@ namespace PepperDash.Essentials.Core.Queues
|
|||||||
if (_delayEnabled)
|
if (_delayEnabled)
|
||||||
Thread.Sleep(_delayTime);
|
Thread.Sleep(_delayTime);
|
||||||
}
|
}
|
||||||
catch (System.Threading.ThreadAbortException)
|
catch (ThreadAbortException)
|
||||||
{
|
{
|
||||||
//swallowing this exception, as it should only happen on shut down
|
//swallowing this exception, as it should only happen on shut down
|
||||||
}
|
}
|
||||||
@@ -244,14 +241,13 @@ namespace PepperDash.Essentials.Core.Queues
|
|||||||
|
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Disposing...");
|
using (_waitHandle)
|
||||||
if (_queue != null && !_queue.Disposed)
|
|
||||||
{
|
{
|
||||||
_queue.Clear();
|
Debug.Console(2, this, "Disposing...");
|
||||||
Enqueue(null);
|
_queue.Enqueue(null);
|
||||||
|
_waitHandle.Set();
|
||||||
|
_worker.Join();
|
||||||
}
|
}
|
||||||
_worker.Abort();
|
|
||||||
_waitHandle.Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Disposed = true;
|
Disposed = true;
|
||||||
@@ -271,261 +267,3 @@ namespace PepperDash.Essentials.Core.Queues
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace PepperDash_Essentials_Core.Queues
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Threadsafe processing of queued items with pacing if required
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Use PepperDash.Essentials.Core.Queues")]
|
|
||||||
public class GenericQueue : IQueue<IQueueMessage>
|
|
||||||
{
|
|
||||||
private readonly string _key;
|
|
||||||
protected readonly CrestronQueue<IQueueMessage> _queue;
|
|
||||||
protected readonly Thread _worker;
|
|
||||||
protected readonly CEvent _waitHandle = new CEvent();
|
|
||||||
|
|
||||||
private bool _delayEnabled;
|
|
||||||
private int _delayTime;
|
|
||||||
|
|
||||||
private const Thread.eThreadPriority _defaultPriority = Thread.eThreadPriority.MediumPriority;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// If the instance has been disposed.
|
|
||||||
/// </summary>
|
|
||||||
public bool Disposed { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the capacity of the CrestronQueue (fixed Size property)
|
|
||||||
/// </summary>
|
|
||||||
public int QueueCapacity
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _queue.Size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Returns the number of elements currently in the CrestronQueue
|
|
||||||
/// </summary>
|
|
||||||
public int QueueCount
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return _queue.Count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor with no thread priority
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
public GenericQueue(string key)
|
|
||||||
: this(key, _defaultPriority, 0, 0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor with queue size
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <param name="capacity">Fixed size for the queue to hold</param>
|
|
||||||
public GenericQueue(string key, int capacity)
|
|
||||||
: this(key, _defaultPriority, capacity, 0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor for generic queue with no pacing
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key">Key</param>
|
|
||||||
/// <param name="pacing">Pacing in ms between actions</param>
|
|
||||||
public GenericQueue(int pacing, string key)
|
|
||||||
: this(key, _defaultPriority, 0, pacing)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor with pacing and capacity
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <param name="pacing"></param>
|
|
||||||
/// <param name="capacity"></param>
|
|
||||||
public GenericQueue(string key, int pacing, int capacity)
|
|
||||||
: this(key, _defaultPriority, capacity, pacing)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor with pacing and priority
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <param name="pacing"></param>
|
|
||||||
/// <param name="priority"></param>
|
|
||||||
public GenericQueue(string key, int pacing, Thread.eThreadPriority priority)
|
|
||||||
: this(key, priority, 0, pacing)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor with pacing, priority and capacity
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <param name="priority"></param>
|
|
||||||
/// <param name="capacity"></param>
|
|
||||||
public GenericQueue(string key, Thread.eThreadPriority priority, int capacity)
|
|
||||||
: this(key, priority, capacity, 0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor with pacing, priority and capacity
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key"></param>
|
|
||||||
/// <param name="pacing"></param>
|
|
||||||
/// <param name="priority"></param>
|
|
||||||
/// <param name="capacity"></param>
|
|
||||||
public GenericQueue(string key, int pacing, Thread.eThreadPriority priority, int capacity)
|
|
||||||
: this(key, priority, capacity, pacing)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor for generic queue with no pacing
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="key">Key</param>
|
|
||||||
/// <param name="priority"></param>
|
|
||||||
/// <param name="capacity"></param>
|
|
||||||
/// <param name="pacing"></param>
|
|
||||||
protected GenericQueue(string key, Thread.eThreadPriority priority, int capacity, int pacing)
|
|
||||||
{
|
|
||||||
_key = key;
|
|
||||||
int cap = 25; // sets default
|
|
||||||
if (capacity > 0)
|
|
||||||
{
|
|
||||||
cap = capacity; // overrides default
|
|
||||||
}
|
|
||||||
_queue = new CrestronQueue<IQueueMessage>(cap);
|
|
||||||
_worker = new Thread(ProcessQueue, null, Thread.eThreadStartOptions.Running)
|
|
||||||
{
|
|
||||||
Priority = priority
|
|
||||||
};
|
|
||||||
|
|
||||||
SetDelayValues(pacing);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetDelayValues(int pacing)
|
|
||||||
{
|
|
||||||
_delayEnabled = pacing > 0;
|
|
||||||
_delayTime = pacing;
|
|
||||||
|
|
||||||
CrestronEnvironment.ProgramStatusEventHandler += programEvent =>
|
|
||||||
{
|
|
||||||
if (programEvent != eProgramStatusEventType.Stopping)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Dispose(true);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Thread callback
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="obj">The action used to process dequeued items</param>
|
|
||||||
/// <returns>Null when the thread is exited</returns>
|
|
||||||
private object ProcessQueue(object obj)
|
|
||||||
{
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
IQueueMessage item = null;
|
|
||||||
|
|
||||||
if (_queue.Count > 0)
|
|
||||||
{
|
|
||||||
item = _queue.Dequeue();
|
|
||||||
if (item == null)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (item != null)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Debug.Console(2, this, "Processing queue item: '{0}'", item.ToString());
|
|
||||||
item.Dispatch();
|
|
||||||
|
|
||||||
if (_delayEnabled)
|
|
||||||
Thread.Sleep(_delayTime);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Caught an exception in the Queue {0}", ex.Message);
|
|
||||||
Debug.Console(2, this, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.StackTrace);
|
|
||||||
|
|
||||||
if (ex.InnerException != null)
|
|
||||||
{
|
|
||||||
Debug.Console(0, this, Debug.ErrorLogLevel.Error, "Caught an exception in the Queue {0}", ex.InnerException.Message);
|
|
||||||
Debug.Console(2, this, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.InnerException.StackTrace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else _waitHandle.Wait();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Enqueue(IQueueMessage item)
|
|
||||||
{
|
|
||||||
_queue.Enqueue(item);
|
|
||||||
_waitHandle.Set();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Disposes the thread and cleans up resources. Thread cannot be restarted once
|
|
||||||
/// disposed.
|
|
||||||
/// </summary>
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Dispose(true);
|
|
||||||
CrestronEnvironment.GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Actually does the disposing. If you override this method, be sure to either call the base implementation
|
|
||||||
/// or clean up all the resources yourself.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="disposing">set to true unless called from finalizer</param>
|
|
||||||
protected void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (Disposed)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (disposing)
|
|
||||||
{
|
|
||||||
Debug.Console(2, this, "Disposing...");
|
|
||||||
if (_queue != null && !_queue.Disposed)
|
|
||||||
{
|
|
||||||
_queue.Clear();
|
|
||||||
Enqueue(null);
|
|
||||||
}
|
|
||||||
_worker.Abort();
|
|
||||||
_waitHandle.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
Disposed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
~GenericQueue()
|
|
||||||
{
|
|
||||||
Dispose(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Key
|
|
||||||
/// </summary>
|
|
||||||
public string Key
|
|
||||||
{
|
|
||||||
get { return _key; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Queues
|
namespace PepperDash.Essentials.Core.Queues
|
||||||
@@ -13,13 +9,3 @@ namespace PepperDash.Essentials.Core.Queues
|
|||||||
bool Disposed { get; }
|
bool Disposed { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace PepperDash_Essentials_Core.Queues
|
|
||||||
{
|
|
||||||
[Obsolete("Use PepperDash.Essentials.Core.Queues")]
|
|
||||||
public interface IQueue<T> : IKeyed, IDisposable where T : class
|
|
||||||
{
|
|
||||||
void Enqueue(T item);
|
|
||||||
bool Disposed { get; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,13 +6,4 @@ namespace PepperDash.Essentials.Core.Queues
|
|||||||
{
|
{
|
||||||
void Dispatch();
|
void Dispatch();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
namespace PepperDash_Essentials_Core.Queues
|
|
||||||
{
|
|
||||||
[Obsolete("Use PepperDash.Essentials.Core.Queues")]
|
|
||||||
public interface IQueueMessage
|
|
||||||
{
|
|
||||||
void Dispatch();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -42,47 +42,3 @@ namespace PepperDash.Essentials.Core.Queues
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace PepperDash_Essentials_Core.Queues
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Message class for processing strings via an IQueue
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Use PepperDash.Essentials.Core.Queues")]
|
|
||||||
public class ProcessStringMessage : IQueueMessage
|
|
||||||
{
|
|
||||||
private readonly Action<string> _action;
|
|
||||||
private readonly string _message;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="message">Message to be processed</param>
|
|
||||||
/// <param name="action">Action to invoke on the message</param>
|
|
||||||
public ProcessStringMessage(string message, Action<string> action)
|
|
||||||
{
|
|
||||||
_message = message;
|
|
||||||
_action = action;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Processes the string with the given action
|
|
||||||
/// </summary>
|
|
||||||
public void Dispatch()
|
|
||||||
{
|
|
||||||
if (_action == null || String.IsNullOrEmpty(_message))
|
|
||||||
return;
|
|
||||||
|
|
||||||
_action(_message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// To string
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>The current message</returns>
|
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return _message ?? String.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -104,107 +104,3 @@ namespace PepperDash.Essentials.Core.Queues
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace PepperDash_Essentials_Core.Queues
|
|
||||||
{
|
|
||||||
[Obsolete("Use PepperDash.Essentials.Core.Queues")]
|
|
||||||
public sealed class StringResponseProcessor : IKeyed, IDisposable
|
|
||||||
{
|
|
||||||
private readonly Action<string> _processStringAction;
|
|
||||||
private readonly IQueue<IQueueMessage> _queue;
|
|
||||||
private readonly IBasicCommunication _coms;
|
|
||||||
private readonly CommunicationGather _gather;
|
|
||||||
|
|
||||||
private StringResponseProcessor(string key, Action<string> processStringAction)
|
|
||||||
{
|
|
||||||
_processStringAction = processStringAction;
|
|
||||||
_queue = new GenericQueue(key);
|
|
||||||
|
|
||||||
CrestronEnvironment.ProgramStatusEventHandler += programEvent =>
|
|
||||||
{
|
|
||||||
if (programEvent != eProgramStatusEventType.Stopping)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Dispose();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor that builds an instance and subscribes to coms TextReceived for processing
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="coms">Com port to process strings from</param>
|
|
||||||
/// <param name="processStringAction">Action to process the incoming strings</param>
|
|
||||||
public StringResponseProcessor(IBasicCommunication coms, Action<string> processStringAction)
|
|
||||||
: this(coms.Key, processStringAction)
|
|
||||||
{
|
|
||||||
_coms = coms;
|
|
||||||
coms.TextReceived += OnResponseReceived;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Constructor that builds an instance and subscribes to gather Line Received for processing
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="gather">Gather to process strings from</param>
|
|
||||||
/// <param name="processStringAction">Action to process the incoming strings</param>
|
|
||||||
public StringResponseProcessor(CommunicationGather gather, Action<string> processStringAction)
|
|
||||||
: this(gather.Port.Key, processStringAction)
|
|
||||||
{
|
|
||||||
_gather = gather;
|
|
||||||
gather.LineReceived += OnResponseReceived;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnResponseReceived(object sender, GenericCommMethodReceiveTextArgs args)
|
|
||||||
{
|
|
||||||
_queue.Enqueue(new ProcessStringMessage(args.Text, _processStringAction));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Key
|
|
||||||
/// </summary>
|
|
||||||
public string Key
|
|
||||||
{
|
|
||||||
get { return _queue.Key; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Disposes the instance and cleans up resources.
|
|
||||||
/// </summary>
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Dispose(true);
|
|
||||||
CrestronEnvironment.GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (Disposed)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (disposing)
|
|
||||||
{
|
|
||||||
if (_coms != null)
|
|
||||||
_coms.TextReceived -= OnResponseReceived;
|
|
||||||
|
|
||||||
if (_gather != null)
|
|
||||||
{
|
|
||||||
_gather.LineReceived -= OnResponseReceived;
|
|
||||||
_gather.Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
_queue.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
Disposed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// If the instance has been disposed or not. If it has, you can not use it anymore
|
|
||||||
/// </summary>
|
|
||||||
public bool Disposed { get; private set; }
|
|
||||||
|
|
||||||
~StringResponseProcessor()
|
|
||||||
{
|
|
||||||
Dispose(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -55,15 +55,6 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// For fixed-source endpoint devices
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Please switch to IRoutingSink")]
|
|
||||||
public interface IRoutingSinkNoSwitching : IRoutingSink
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Endpoint device like a display, that selects inputs
|
/// Endpoint device like a display, that selects inputs
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Shades
|
namespace PepperDash.Essentials.Core.Shades
|
||||||
{
|
{
|
||||||
@@ -16,16 +11,6 @@ namespace PepperDash.Essentials.Core.Shades
|
|||||||
List<ShadeBase> Shades { get; }
|
List<ShadeBase> Shades { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Requirements for a device that implements basic Open/Close shade control
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Please use IShadesOpenCloseStop instead")]
|
|
||||||
public interface IShadesOpenClose
|
|
||||||
{
|
|
||||||
void Open();
|
|
||||||
void Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Requirements for a device that implements basic Open/Close/Stop shade control (Uses 3 relays)
|
/// Requirements for a device that implements basic Open/Close/Stop shade control (Uses 3 relays)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -45,15 +30,6 @@ namespace PepperDash.Essentials.Core.Shades
|
|||||||
event EventHandler PresetSaved;
|
event EventHandler PresetSaved;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Requirements for a shade that implements press/hold raise/lower functions
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Please use IShadesOpenCloseStop instead")]
|
|
||||||
public interface IShadesRaiseLower
|
|
||||||
{
|
|
||||||
void Raise(bool state);
|
|
||||||
void Lower(bool state);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Requirements for a shade device that provides raising/lowering feedback
|
/// Requirements for a shade device that provides raising/lowering feedback
|
||||||
@@ -73,15 +49,6 @@ namespace PepperDash.Essentials.Core.Shades
|
|||||||
BoolFeedback ShadeIsClosedFeedback { get; }
|
BoolFeedback ShadeIsClosedFeedback { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Please use IShadesOpenCloseStop instead")]
|
|
||||||
public interface IShadesStop
|
|
||||||
{
|
|
||||||
void Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used to implement raise/stop/lower/stop from single button
|
/// Used to implement raise/stop/lower/stop from single button
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -125,7 +92,7 @@ namespace PepperDash.Essentials.Core.Shades
|
|||||||
BoolFeedback AllAreAtSceneFeedback { get; }
|
BoolFeedback AllAreAtSceneFeedback { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface ICrestronBasicShade : IShadesOpenClosedFeedback, IShadesStop,
|
public interface ICrestronBasicShade : IShadesOpenClosedFeedback,
|
||||||
IShadesStopOrMove, IShadesFeedback, IShadesRaiseLowerFeedback
|
IShadesStopOrMove, IShadesFeedback, IShadesRaiseLowerFeedback
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ namespace PepperDash.Essentials.Devices.Common
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents and audio endpoint
|
/// Represents and audio endpoint
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GenericAudioOut : EssentialsDevice, IRoutingSinkNoSwitching
|
public class GenericAudioOut : EssentialsDevice, IRoutingSink
|
||||||
{
|
{
|
||||||
public event SourceInfoChangeHandler CurrentSourceChange;
|
public event SourceInfoChangeHandler CurrentSourceChange;
|
||||||
|
|
||||||
|
|||||||
@@ -38,12 +38,6 @@ namespace PepperDash.Essentials.Devices.Common.Codec
|
|||||||
void GetDirectoryParentFolderContents();
|
void GetDirectoryParentFolderContents();
|
||||||
|
|
||||||
BoolFeedback CurrentDirectoryResultIsNotDirectoryRoot { get; }
|
BoolFeedback CurrentDirectoryResultIsNotDirectoryRoot { get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Tracks the directory browse history when browsing beyond the root directory
|
|
||||||
/// </summary>
|
|
||||||
[Obsolete("Please use the Stack-based history instead")]
|
|
||||||
List<CodecDirectory> DirectoryBrowseHistory { get; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IHasDirectoryHistoryStack : IHasDirectory
|
public interface IHasDirectoryHistoryStack : IHasDirectory
|
||||||
|
|||||||
@@ -1,45 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro;
|
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core;
|
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Displays
|
|
||||||
{
|
|
||||||
[Obsolete("Please use TwoWayDisplayBase instead")]
|
|
||||||
public abstract class ComTcpDisplayBase : TwoWayDisplayBase
|
|
||||||
{
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// Sets the communication method for this - swaps out event handlers and output handlers
|
|
||||||
///// </summary>
|
|
||||||
//public IBasicCommunication CommunicationMethod
|
|
||||||
//{
|
|
||||||
// get { return _CommunicationMethod; }
|
|
||||||
// set
|
|
||||||
// {
|
|
||||||
// if (_CommunicationMethod != null)
|
|
||||||
// _CommunicationMethod.BytesReceived -= this.CommunicationMethod_BytesReceived;
|
|
||||||
// // Outputs???
|
|
||||||
// _CommunicationMethod = value;
|
|
||||||
// if (_CommunicationMethod != null)
|
|
||||||
// _CommunicationMethod.BytesReceived += this.CommunicationMethod_BytesReceived;
|
|
||||||
// // Outputs?
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//IBasicCommunication _CommunicationMethod;
|
|
||||||
|
|
||||||
public ComTcpDisplayBase(string key, string name)
|
|
||||||
: base(key, name)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//protected abstract void CommunicationMethod_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Common
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
public class DigitalLoggerPropertiesConfig
|
|
||||||
{
|
|
||||||
public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; }
|
|
||||||
|
|
||||||
public ControlPropertiesConfig Control { get; set; }
|
|
||||||
public string userName { get; set; }
|
|
||||||
public string password { get; set; }
|
|
||||||
public string address { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,356 +0,0 @@
|
|||||||
extern alias Full;
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using Crestron.SimplSharp.Net.Http;
|
|
||||||
using Full.Newtonsoft.Json;
|
|
||||||
using Full.Newtonsoft.Json.Linq;
|
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
|
||||||
using PepperDash.Essentials.Core.Config;
|
|
||||||
using PepperDash.Essentials;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Common
|
|
||||||
{
|
|
||||||
[Obsolete("This Device will be moved to a plugin in a future update")]
|
|
||||||
public class DigitalLogger : EssentialsBridgeableDevice
|
|
||||||
{
|
|
||||||
public IBasicCommunication Communication { get; private set; }
|
|
||||||
public CommunicationGather PortGather { get; private set; }
|
|
||||||
public StatusMonitorBase CommunicationMonitor { get; private set; }
|
|
||||||
|
|
||||||
private HttpClient WebClient;
|
|
||||||
public string userName;
|
|
||||||
public string password;
|
|
||||||
public string address;
|
|
||||||
private bool OnlineStatus;
|
|
||||||
public BoolFeedback OnlineFeedback;
|
|
||||||
//private ushort CurrentPreset;
|
|
||||||
public IntFeedback PresetFeedback;
|
|
||||||
|
|
||||||
public Dictionary<uint, DigitalLoggerCircuit> CircuitStatus;
|
|
||||||
public uint CircuitCount;
|
|
||||||
|
|
||||||
public Dictionary<uint, StringFeedback> CircuitNameFeedbacks { get; private set; }
|
|
||||||
public Dictionary<uint, BoolFeedback> CircuitIsCritical{ get; private set; }
|
|
||||||
public Dictionary<uint, BoolFeedback> CircuitState { get; private set; }
|
|
||||||
|
|
||||||
// new public Dictionary<string, QscDspLevelControl> LevelControlPoints { get; private set; }
|
|
||||||
// public List<QscDspPresets> PresetList = new List<QscDspPresets>();
|
|
||||||
|
|
||||||
public bool isSubscribed;
|
|
||||||
|
|
||||||
private CTimer SubscriptionTimer;
|
|
||||||
|
|
||||||
CrestronQueue CommandQueue;
|
|
||||||
|
|
||||||
bool CommandQueueInProgress = false;
|
|
||||||
|
|
||||||
//new public Dictionary<string, DspControlPoint> DialerControlPoints { get; private set; }
|
|
||||||
|
|
||||||
//new public Dictionary<string, DspControlPoint> SwitcherControlPoints { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Shows received lines as hex
|
|
||||||
/// </summary>
|
|
||||||
public bool ShowHexResponse { get; set; }
|
|
||||||
|
|
||||||
public DigitalLogger(string key, string name, DigitalLoggerPropertiesConfig props) :
|
|
||||||
base(key, name)
|
|
||||||
{
|
|
||||||
CircuitCount = 8;
|
|
||||||
this.userName = props.userName;
|
|
||||||
this.password = props.password;
|
|
||||||
CommandQueue = new CrestronQueue(100);
|
|
||||||
|
|
||||||
WebClient = new HttpClient();
|
|
||||||
WebClient.UserName = this.userName;
|
|
||||||
WebClient.Password = this.password;
|
|
||||||
this.address = props.address;
|
|
||||||
WebClient.HostAddress = props.address;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CustomActivate()
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
Communication.Connect();
|
|
||||||
CommunicationMonitor.StatusChange += (o, a) => { Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status); };
|
|
||||||
CommunicationMonitor.Start();
|
|
||||||
*/
|
|
||||||
|
|
||||||
OnlineFeedback = new BoolFeedback(() => { return OnlineStatus; });
|
|
||||||
CircuitStatus = new Dictionary<uint, DigitalLoggerCircuit>();
|
|
||||||
CircuitNameFeedbacks = new Dictionary<uint, StringFeedback>();
|
|
||||||
CircuitIsCritical = new Dictionary<uint, BoolFeedback>();
|
|
||||||
CircuitState = new Dictionary<uint, BoolFeedback>();
|
|
||||||
for (uint i = 0; i < CircuitCount; i++)
|
|
||||||
{
|
|
||||||
uint circuit = i;
|
|
||||||
CircuitStatus[circuit] = new DigitalLoggerCircuit();
|
|
||||||
CircuitNameFeedbacks[circuit] = new StringFeedback(() => {
|
|
||||||
if (CircuitStatus[circuit].name != null)
|
|
||||||
{
|
|
||||||
return CircuitStatus[circuit].name;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
CircuitIsCritical[circuit] = new BoolFeedback(() =>
|
|
||||||
{
|
|
||||||
if (CircuitStatus.ContainsKey(circuit))
|
|
||||||
{
|
|
||||||
return CircuitStatus[circuit].critical;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
CircuitState[circuit] = new BoolFeedback(() =>
|
|
||||||
{
|
|
||||||
if (CircuitStatus.ContainsKey(circuit))
|
|
||||||
{
|
|
||||||
return CircuitStatus[circuit].state;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
PollCircuit(circuit);
|
|
||||||
}
|
|
||||||
|
|
||||||
CrestronConsole.AddNewConsoleCommand(SendLine, "send" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
|
|
||||||
CrestronConsole.AddNewConsoleCommand(s => Communication.Connect(), "con" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
|
|
||||||
{
|
|
||||||
var joinMap = new DigitalLoggerJoinMap();
|
|
||||||
|
|
||||||
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
|
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(joinMapSerialized))
|
|
||||||
joinMap = JsonConvert.DeserializeObject<DigitalLoggerJoinMap>(joinMapSerialized);
|
|
||||||
|
|
||||||
joinMap.OffsetJoinNumbers(joinStart);
|
|
||||||
|
|
||||||
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
|
||||||
for (uint i = 1; i <= CircuitCount; i++)
|
|
||||||
{
|
|
||||||
var circuit = i;
|
|
||||||
CircuitNameFeedbacks[circuit - 1].LinkInputSig(trilist.StringInput[joinMap.CircuitNames + circuit]);
|
|
||||||
CircuitIsCritical[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitIsCritical + circuit]);
|
|
||||||
CircuitState[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitState + circuit]);
|
|
||||||
trilist.SetSigTrueAction(joinMap.CircuitCycle + circuit, () => CycleCircuit(circuit - 1));
|
|
||||||
trilist.SetSigTrueAction(joinMap.CircuitOnCmd + circuit, () => TurnOnCircuit(circuit - 1));
|
|
||||||
trilist.SetSigTrueAction(joinMap.CircuitOffCmd + circuit, () => TurnOffCircuit(circuit - 1));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)
|
|
||||||
{
|
|
||||||
Debug.Console(2, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString());
|
|
||||||
|
|
||||||
if (e.Client.IsConnected)
|
|
||||||
{
|
|
||||||
OnlineStatus = true;
|
|
||||||
OnlineFeedback.FireUpdate();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
OnlineStatus = false;
|
|
||||||
OnlineFeedback.FireUpdate();
|
|
||||||
if (SubscriptionTimer != null)
|
|
||||||
{
|
|
||||||
SubscriptionTimer.Stop();
|
|
||||||
SubscriptionTimer = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
isSubscribed = false;
|
|
||||||
CommandQueue.Clear();
|
|
||||||
CommandQueueInProgress = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PollCircuit(uint circuit)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
string PollCircuitResponse = SendRequest(String.Format("/restapi/relay/outlets/{0}/", circuit));
|
|
||||||
CircuitStatus[circuit] = JsonConvert.DeserializeObject<DigitalLoggerCircuit>(PollCircuitResponse);
|
|
||||||
DigitalLoggerCircuit temp = CircuitStatus[circuit];
|
|
||||||
Debug.Console(2, this, "DigitalLogger Circuit {0} Name: {1} State:{2}'", circuit, CircuitStatus[circuit].name, CircuitStatus[circuit].state);
|
|
||||||
CircuitNameFeedbacks[circuit].FireUpdate();
|
|
||||||
CircuitState[circuit].FireUpdate();
|
|
||||||
CircuitIsCritical[circuit].FireUpdate();
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
Debug.Console(0, this, "PollCircuit {0}", e);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void Port_LineReceived(string response, HTTP_CALLBACK_ERROR error)
|
|
||||||
{
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public string SendRequest(string s)
|
|
||||||
{
|
|
||||||
HttpClientRequest request = new HttpClientRequest();
|
|
||||||
string url = string.Format("http://{0}{1}", this.address, s);
|
|
||||||
request.Url = new UrlParser(url);
|
|
||||||
HttpClientResponse response = WebClient.Dispatch(request);
|
|
||||||
return response.ContentString;
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// Sends a command to the DSP (with delimiter appended)
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="s">Command to send</param>
|
|
||||||
///
|
|
||||||
public void SendLine(string s)
|
|
||||||
{
|
|
||||||
|
|
||||||
HttpClientRequest request = new HttpClientRequest();
|
|
||||||
string url = string.Format("http://{0}{1}", this.address, s);
|
|
||||||
request.Url = new UrlParser(url);
|
|
||||||
|
|
||||||
HttpClientResponse response = WebClient.Dispatch(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CycleCircuit(uint circuit)
|
|
||||||
{
|
|
||||||
SendLine(String.Format("/outlet?{0}=CCL", circuit));
|
|
||||||
//PollCircuit(circuit);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void TurnOnCircuit(uint circuit)
|
|
||||||
{
|
|
||||||
SendLine(String.Format("/outlet?{0}=ON", circuit));
|
|
||||||
//PollCircuit(circuit);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void TurnOffCircuit(uint circuit)
|
|
||||||
{
|
|
||||||
SendLine(String.Format("/outlet?{0}=Off", circuit));
|
|
||||||
//PollCircuit(circuit);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a command from a child module to the queue
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="command">Command object from child module</param>
|
|
||||||
public void EnqueueCommand(QueuedCommand commandToEnqueue)
|
|
||||||
{
|
|
||||||
CommandQueue.Enqueue(commandToEnqueue);
|
|
||||||
//Debug.Console(1, this, "Command (QueuedCommand) Enqueued '{0}'. CommandQueue has '{1}' Elements.", commandToEnqueue.Command, CommandQueue.Count);
|
|
||||||
|
|
||||||
if(!CommandQueueInProgress)
|
|
||||||
SendNextQueuedCommand();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Adds a raw string command to the queue
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="command"></param>
|
|
||||||
public void EnqueueCommand(string command)
|
|
||||||
{
|
|
||||||
CommandQueue.Enqueue(command);
|
|
||||||
//Debug.Console(1, this, "Command (string) Enqueued '{0}'. CommandQueue has '{1}' Elements.", command, CommandQueue.Count);
|
|
||||||
|
|
||||||
if (!CommandQueueInProgress)
|
|
||||||
SendNextQueuedCommand();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sends the next queued command to the DSP
|
|
||||||
/// </summary>
|
|
||||||
void SendNextQueuedCommand()
|
|
||||||
{
|
|
||||||
if (Communication.IsConnected && !CommandQueue.IsEmpty)
|
|
||||||
{
|
|
||||||
CommandQueueInProgress = true;
|
|
||||||
|
|
||||||
if (CommandQueue.Peek() is QueuedCommand)
|
|
||||||
{
|
|
||||||
QueuedCommand nextCommand = new QueuedCommand();
|
|
||||||
|
|
||||||
nextCommand = (QueuedCommand)CommandQueue.Peek();
|
|
||||||
|
|
||||||
SendLine(nextCommand.Command);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
string nextCommand = (string)CommandQueue.Peek();
|
|
||||||
|
|
||||||
SendLine(nextCommand);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void CallPreset(ushort presetNumber)
|
|
||||||
{
|
|
||||||
SendLine(string.Format("Preset.Take = {0}", presetNumber));
|
|
||||||
// SendLine("cgp 1");
|
|
||||||
}
|
|
||||||
|
|
||||||
public class QueuedCommand
|
|
||||||
{
|
|
||||||
public string Command { get; set; }
|
|
||||||
public string AttributeCode { get; set; }
|
|
||||||
// public QscDspControlPoint ControlPoint { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class DigitalLoggerCircuit
|
|
||||||
{
|
|
||||||
public string name;
|
|
||||||
public bool locked;
|
|
||||||
public bool critical;
|
|
||||||
public bool transient_state;
|
|
||||||
public bool physical_state;
|
|
||||||
//public int cycle_delay;
|
|
||||||
public bool state;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public class DigitalLoggerFactory : EssentialsDeviceFactory<DigitalLogger>
|
|
||||||
{
|
|
||||||
public DigitalLoggerFactory()
|
|
||||||
{
|
|
||||||
TypeNames = new List<string>() { "digitallogger" };
|
|
||||||
}
|
|
||||||
|
|
||||||
public override EssentialsDevice BuildDevice(DeviceConfig dc)
|
|
||||||
{
|
|
||||||
Debug.Console(1, "Factory Attempting to create new DigitalLogger Device");
|
|
||||||
var props = JsonConvert.DeserializeObject<DigitalLoggerPropertiesConfig>(
|
|
||||||
dc.Properties.ToString());
|
|
||||||
return new DigitalLogger(dc.Key, dc.Name, props);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,7 +13,7 @@ using PepperDash.Essentials.Core.Config;
|
|||||||
|
|
||||||
namespace PepperDash.Essentials.Devices.Common.SoftCodec
|
namespace PepperDash.Essentials.Devices.Common.SoftCodec
|
||||||
{
|
{
|
||||||
public class BlueJeansPc : InRoomPc, IRoutingInputs, IRunRouteAction, IRoutingSinkNoSwitching
|
public class BlueJeansPc : InRoomPc, IRoutingInputs, IRunRouteAction, IRoutingSink
|
||||||
{
|
{
|
||||||
|
|
||||||
public RoutingInputPort AnyVideoIn { get; private set; }
|
public RoutingInputPort AnyVideoIn { get; private set; }
|
||||||
@@ -93,9 +93,9 @@ namespace PepperDash.Essentials.Devices.Common.SoftCodec
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
bool DoRoute(SourceRouteListItem route)
|
bool DoRoute(SourceRouteListItem route)
|
||||||
{
|
{
|
||||||
IRoutingSinkNoSwitching dest = null;
|
IRoutingSink dest = null;
|
||||||
|
|
||||||
dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSinkNoSwitching;
|
dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSink;
|
||||||
|
|
||||||
if (dest == null)
|
if (dest == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,14 +4,11 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
using Crestron.SimplSharp.CrestronIO;
|
||||||
using Crestron.SimplSharp.Reflection;
|
using Crestron.SimplSharp.Reflection;
|
||||||
using Crestron.SimplSharp.Ssh;
|
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Core.Intersystem;
|
using PepperDash.Core.Intersystem;
|
||||||
using PepperDash.Core.Intersystem.Tokens;
|
using PepperDash.Core.Intersystem.Tokens;
|
||||||
using PepperDash.Core.WebApi.Presets;
|
|
||||||
using Crestron.SimplSharp.Reflection;
|
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
using PepperDash.Essentials.Core.Config;
|
using PepperDash.Essentials.Core.Config;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ using PepperDash.Essentials.Core.Routing;
|
|||||||
|
|
||||||
namespace PepperDash.Essentials
|
namespace PepperDash.Essentials
|
||||||
{
|
{
|
||||||
public class Amplifier : EssentialsDevice, IRoutingSinkNoSwitching
|
public class Amplifier : EssentialsDevice, IRoutingSink
|
||||||
{
|
{
|
||||||
public event SourceInfoChangeHandler CurrentSourceChange;
|
public event SourceInfoChangeHandler CurrentSourceChange;
|
||||||
|
|
||||||
|
|||||||
@@ -577,13 +577,13 @@ namespace PepperDash.Essentials
|
|||||||
IRoutingSink dest = null;
|
IRoutingSink dest = null;
|
||||||
|
|
||||||
if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase))
|
if (route.DestinationKey.Equals("$defaultaudio", StringComparison.OrdinalIgnoreCase))
|
||||||
dest = DefaultAudioDevice as IRoutingSinkNoSwitching;
|
dest = DefaultAudioDevice as IRoutingSink;
|
||||||
else if (route.DestinationKey.Equals(LeftDisplay.Key, StringComparison.OrdinalIgnoreCase))
|
else if (route.DestinationKey.Equals(LeftDisplay.Key, StringComparison.OrdinalIgnoreCase))
|
||||||
dest = LeftDisplay;
|
dest = LeftDisplay;
|
||||||
else if (route.DestinationKey.Equals(RightDisplay.Key, StringComparison.OrdinalIgnoreCase))
|
else if (route.DestinationKey.Equals(RightDisplay.Key, StringComparison.OrdinalIgnoreCase))
|
||||||
dest = RightDisplay;
|
dest = RightDisplay;
|
||||||
else
|
else
|
||||||
dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSinkNoSwitching;
|
dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSink;
|
||||||
|
|
||||||
if (dest == null)
|
if (dest == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ namespace PepperDash.Essentials
|
|||||||
{
|
{
|
||||||
if (ShadeDevice is IShadesOpenCloseStop)
|
if (ShadeDevice is IShadesOpenCloseStop)
|
||||||
DeviceType = eShadeDeviceType.OpenCloseStop;
|
DeviceType = eShadeDeviceType.OpenCloseStop;
|
||||||
else if (ShadeDevice is IShadesOpenClose)
|
else if (ShadeDevice is IShadesOpenCloseStop)
|
||||||
DeviceType = eShadeDeviceType.OpenClose;
|
DeviceType = eShadeDeviceType.OpenClose;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user