Compare commits

..

16 Commits

Author SHA1 Message Date
Andrew Welker
cdafaf7586 build(force-patch): remove cplz generation
CPLZs are not required for using Essentials as a dependency, and just
adds noise that's not required.
2025-03-25 22:54:47 -05:00
Andrew Welker
222c2f6fe2 chore: more miscellaneous cleanup 2025-03-25 22:52:32 -05:00
Andrew Welker
19d0bc73c8 fix: remove LightingBase from core 2025-03-25 22:50:31 -05:00
Andrew Welker
277771d154 chore: miscellaeneous cleanup 2025-03-25 22:46:41 -05:00
Andrew Welker
789111cb9a style: run code cleanup & apply VS suggestions 2025-03-25 22:14:15 -05:00
Andrew Welker
4d98191fa7 chore: remove obsolete log methods 2025-03-25 21:55:37 -05:00
Andrew Welker
f6f731b470 chore: remove 4SERIES compiler directive 2025-03-25 10:21:17 -05:00
Andrew Welker
8316ee22b6 build(force-patch): change names of MC packages
In order to prevent eventual version collision and confusion, and to
allow for deprecation of existing packages, the names of the MC packages
are now reflective of the fact that they are no longer
pluginsbuild(force-patch): change names of MC packages

In order to prevent eventual version collision and confusion, and to
allow for deprecation of existing packages, the names of the MC packages
are now reflective of the fact that they are no longer plugins.
2025-03-25 00:20:56 -05:00
Andrew Welker
aebc694da7 build(force-patch): use version in directory.build.props 2025-03-25 00:16:23 -05:00
Andrew Welker
fe2cd573e5 feat: remove DisplayBase from Core 2025-03-25 00:10:22 -05:00
Andrew Welker
af0855cea3 build(force-patch): publish mc messenger package 2025-03-24 23:36:17 -05:00
Andrew Welker
5ac9efb1fb Merge branch 'development' into feature/move-mc 2025-03-24 22:43:59 -05:00
Andrew Welker
7318dbb04e ci(force-patch): add skip package check prop 2025-03-24 22:39:52 -05:00
Andrew Welker
7046205e57 Merge pull request #1224 from PepperDash/feature/inclusive-poll 2025-03-24 14:50:26 -05:00
Jonathan Arndt
d7499662de fix: revise 4-series-caller.yml to include bypassPackageCheck bool. 2025-03-24 11:01:12 -07:00
Jonathan Arndt
fdb04286d6 fix: correct event subscription logic in GenericCommunicationMonitor and poll inclusively. 2025-03-23 16:36:41 -07:00
96 changed files with 1023 additions and 2615 deletions

View File

@@ -18,4 +18,5 @@ jobs:
newVersion: ${{ needs.getVersion.outputs.newVersion }}
version: ${{ needs.getVersion.outputs.version }}
tag: ${{ needs.getVersion.outputs.tag }}
channel: ${{ needs.getVersion.outputs.channel }}
channel: ${{ needs.getVersion.outputs.channel }}
bypassPackageCheck: true

View File

@@ -2,10 +2,10 @@
<PropertyGroup>
<Version>2.0.0-local</Version>
<InformationalVersion>$(Version)</InformationalVersion>
<Authors>PepperDash Technologies</Authors>
<Company>PepperDash Technologies</Company>
<Authors>PepperDash Technology</Authors>
<Company>PepperDash Technology</Company>
<Product>PepperDash Essentials</Product>
<Copyright>Copyright © 2023</Copyright>
<Copyright>Copyright © 2025</Copyright>
<RepositoryUrl>https://github.com/PepperDash/Essentials</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>Crestron; 4series</PackageTags>

View File

@@ -7,17 +7,19 @@ namespace PepperDash.Essentials.Core
[Obsolete("Please use the builtin HttpClient class instead: https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient-guidelines")]
public class GenericHttpClient : Device, IBasicCommunication
{
public HttpClient Client;
private readonly HttpClient Client;
public event EventHandler<GenericHttpClientEventArgs> ResponseRecived;
public GenericHttpClient(string key, string name, string hostname)
: base(key, name)
{
Client = new HttpClient();
Client.HostName = hostname;
}
Client = new HttpClient
{
HostName = hostname
};
}
/// <summary>
///
@@ -54,9 +56,8 @@ namespace PepperDash.Essentials.Core
if (responseReceived.ContentString.Length > 0)
{
if (ResponseRecived != null)
ResponseRecived(this, new GenericHttpClientEventArgs(responseReceived.ContentString, (request as HttpClientRequest).Url.ToString(), error));
}
ResponseRecived?.Invoke(this, new GenericHttpClientEventArgs(responseReceived.ContentString, (request as HttpClientRequest).Url.ToString(), error));
}
}
}

View File

@@ -0,0 +1,8 @@
using PepperDash.Core;
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
{
public interface IDisplay: IHasFeedback, IRoutingSinkWithSwitching, IHasPowerControl, IWarmingCooling, IUsageTracking, IKeyName
{
}
}

View File

@@ -1,12 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
@@ -16,22 +8,6 @@ namespace PepperDash.Essentials.Core
BoolFeedback IsOnline { get; }
}
///// <summary>
///// ** WANT THIS AND ALL ITS FRIENDS TO GO AWAY **
///// Defines a class that has a list of CueAction objects, typically
///// for linking functions to user interfaces or API calls
///// </summary>
//public interface IHasCueActionList
//{
// List<CueActionPair> CueActionList { get; }
//}
//public interface IHasComPortsHardware
//{
// IComPorts ComPortsDevice { get; }
//}
/// <summary>
/// Describes a device that can have a video sync providing device attached to it
/// </summary>

View File

@@ -1,81 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Crestron.SimplSharpPro;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Core;
using Serilog.Events;
namespace PepperDash.Essentials.Core.Devices
{
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")]
public class Laptop : EssentialsDevice, IHasFeedback, IRoutingOutputs, IAttachVideoStatus, IUiDisplayInfo, IUsageTracking
{
public uint DisplayUiType { get { return DisplayUiConstants.TypeLaptop; } }
public string IconName { get; set; }
public BoolFeedback HasPowerOnFeedback { get; private set; }
public RoutingOutputPort AnyVideoOut { get; private set; }
#region IRoutingOutputs Members
/// <summary>
/// Options: hdmi
/// </summary>
public RoutingPortCollection<RoutingOutputPort> OutputPorts { get; private set; }
#endregion
public Laptop(string key, string name)
: base(key, name)
{
IconName = "Laptop";
HasPowerOnFeedback = new BoolFeedback("HasPowerFeedback",
() => this.GetVideoStatuses() != VideoStatusOutputs.NoStatus);
OutputPorts = new RoutingPortCollection<RoutingOutputPort>();
OutputPorts.Add(AnyVideoOut = new RoutingOutputPort(RoutingPortNames.AnyOut, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.None, 0, this));
}
#region IHasFeedback Members
/// <summary>
/// Passes through the VideoStatuses list
/// </summary>
public FeedbackCollection<Feedback> Feedbacks
{
get
{
var newList = new FeedbackCollection<Feedback>();
newList.AddRange(this.GetVideoStatuses().ToList());
return newList;
}
}
#endregion
#region IUsageTracking Members
public UsageTracking UsageTracker { get; set; }
#endregion
}
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")]
public class LaptopFactory : EssentialsDeviceFactory<Laptop>
{
public LaptopFactory()
{
TypeNames = new List<string>() { "deprecated" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new Laptop Device");
return new Core.Devices.Laptop(dc.Key, dc.Name);
}
}
}

View File

@@ -1,229 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Bridges;
using Serilog.Events;
namespace PepperDash.Essentials.Core
{
[Obsolete("Please use PepperDash.Essentials.Device.Common, this will be removed in 2.1")]
public class BasicIrDisplay : DisplayBase, IBasicVolumeControls, IBridgeAdvanced
{
public IrOutputPortController IrPort { get; private set; }
public ushort IrPulseTime { get; set; }
protected Func<bool> PowerIsOnFeedbackFunc
{
get { return () => _PowerIsOn; }
}
protected override Func<bool> IsCoolingDownFeedbackFunc
{
get { return () => _IsCoolingDown; }
}
protected override Func<bool> IsWarmingUpFeedbackFunc
{
get { return () => _IsWarmingUp; }
}
bool _PowerIsOn;
bool _IsWarmingUp;
bool _IsCoolingDown;
public BasicIrDisplay(string key, string name, IROutputPort port, string irDriverFilepath)
: base(key, name)
{
IrPort = new IrOutputPortController(key + "-ir", port, irDriverFilepath);
DeviceManager.AddDevice(IrPort);
IsWarmingUpFeedback.OutputChange += (o, a) => Debug.LogMessage(LogEventLevel.Verbose, this, "Warming up={0}", _IsWarmingUp);
IsCoolingDownFeedback.OutputChange += (o, a) => Debug.LogMessage(LogEventLevel.Verbose, this, "Cooling down={0}", _IsCoolingDown);
InputPorts.AddRange(new RoutingPortCollection<RoutingInputPort>
{
new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Hdmi, new Action(Hdmi1), this, false),
new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Hdmi, new Action(Hdmi2), this, false),
new RoutingInputPort(RoutingPortNames.HdmiIn3, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Hdmi, new Action(Hdmi3), this, false),
new RoutingInputPort(RoutingPortNames.HdmiIn4, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Hdmi, new Action(Hdmi4), this, false),
new RoutingInputPort(RoutingPortNames.ComponentIn, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Hdmi, new Action(Component1), this, false),
new RoutingInputPort(RoutingPortNames.CompositeIn, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Hdmi, new Action(Video1), this, false),
new RoutingInputPort(RoutingPortNames.AntennaIn, eRoutingSignalType.Audio | eRoutingSignalType.Video,
eRoutingPortConnectionType.Hdmi, new Action(Antenna), this, false),
});
}
public void Hdmi1()
{
IrPort.Pulse(IROutputStandardCommands.IROut_HDMI_1, IrPulseTime);
}
public void Hdmi2()
{
IrPort.Pulse(IROutputStandardCommands.IROut_HDMI_2, IrPulseTime);
}
public void Hdmi3()
{
IrPort.Pulse(IROutputStandardCommands.IROut_HDMI_3, IrPulseTime);
}
public void Hdmi4()
{
IrPort.Pulse(IROutputStandardCommands.IROut_HDMI_4, IrPulseTime);
}
public void Component1()
{
IrPort.Pulse(IROutputStandardCommands.IROut_COMPONENT_1, IrPulseTime);
}
public void Video1()
{
IrPort.Pulse(IROutputStandardCommands.IROut_VIDEO_1, IrPulseTime);
}
public void Antenna()
{
IrPort.Pulse(IROutputStandardCommands.IROut_ANTENNA, IrPulseTime);
}
#region IPower Members
public override void PowerOn()
{
IrPort.Pulse(IROutputStandardCommands.IROut_POWER_ON, IrPulseTime);
_PowerIsOn = true;
}
public override void PowerOff()
{
_PowerIsOn = false;
IrPort.Pulse(IROutputStandardCommands.IROut_POWER_OFF, IrPulseTime);
}
public override void PowerToggle()
{
_PowerIsOn = false;
IrPort.Pulse(IROutputStandardCommands.IROut_POWER, IrPulseTime);
}
#endregion
#region IBasicVolumeControls Members
public void VolumeUp(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_VOL_PLUS, pressRelease);
}
public void VolumeDown(bool pressRelease)
{
IrPort.PressRelease(IROutputStandardCommands.IROut_VOL_MINUS, pressRelease);
}
public void MuteToggle()
{
IrPort.Pulse(IROutputStandardCommands.IROut_MUTE, 200);
}
#endregion
void StartWarmingTimer()
{
_IsWarmingUp = true;
IsWarmingUpFeedback.FireUpdate();
new CTimer(o => {
_IsWarmingUp = false;
IsWarmingUpFeedback.FireUpdate();
}, 10000);
}
void StartCoolingTimer()
{
_IsCoolingDown = true;
IsCoolingDownFeedback.FireUpdate();
new CTimer(o =>
{
_IsCoolingDown = false;
IsCoolingDownFeedback.FireUpdate();
}, 7000);
}
#region IRoutingSink Members
/// <summary>
/// Typically called by the discovery routing algorithm.
/// </summary>
/// <param name="inputSelector">A delegate containing the input selector method to call</param>
public override void ExecuteSwitch(object inputSelector)
{
Debug.LogMessage(LogEventLevel.Verbose, this, "Switching to input '{0}'", (inputSelector as Action).ToString());
Action finishSwitch = () =>
{
var action = inputSelector as Action;
if (action != null)
action();
};
if (!_PowerIsOn)
{
PowerOn();
EventHandler<FeedbackEventArgs> oneTimer = null;
oneTimer = (o, a) =>
{
if (IsWarmingUpFeedback.BoolValue) return; // Only catch done warming
IsWarmingUpFeedback.OutputChange -= oneTimer;
finishSwitch();
};
IsWarmingUpFeedback.OutputChange += oneTimer;
}
else // Do it!
finishSwitch();
}
#endregion
public void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
{
LinkDisplayToApi(this, trilist, joinStart, joinMapKey, bridge);
}
}
[Obsolete("Please use PepperDash.Essentials.Device.Common, this will be removed in 2.1")]
public class BasicIrDisplayFactory : EssentialsDeviceFactory<BasicIrDisplay>
{
public BasicIrDisplayFactory()
{
TypeNames = new List<string>() { "basicirdisplay" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
Debug.LogMessage(LogEventLevel.Debug, "Factory Attempting to create new BasicIrDisplay Device");
var ir = IRPortHelper.GetIrPort(dc.Properties);
if (ir != null)
{
var display = new BasicIrDisplay(dc.Key, dc.Name, ir.Port, ir.FileName);
display.IrPulseTime = 200; // Set default pulse time for IR commands.
return display;
}
return null;
}
}
}

View File

@@ -1,320 +0,0 @@
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core.Bridges;
using Serilog.Events;
using System;
using System.Collections.Generic;
using System.Linq;
namespace PepperDash.Essentials.Core
{
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")]
public abstract class DisplayBase : EssentialsDevice, IHasFeedback, IRoutingSinkWithSwitching, IHasPowerControl, IWarmingCooling, IUsageTracking
{
public event SourceInfoChangeHandler CurrentSourceChange;
public event InputChangedEventHandler InputChanged;
public string CurrentSourceInfoKey { get; set; }
public SourceListItem CurrentSourceInfo
{
get
{
return _CurrentSourceInfo;
}
set
{
if (value == _CurrentSourceInfo) return;
var handler = CurrentSourceChange;
if (handler != null)
handler(_CurrentSourceInfo, ChangeType.WillChange);
_CurrentSourceInfo = value;
if (handler != null)
handler(_CurrentSourceInfo, ChangeType.DidChange);
}
}
SourceListItem _CurrentSourceInfo;
public BoolFeedback IsCoolingDownFeedback { get; protected set; }
public BoolFeedback IsWarmingUpFeedback { get; private set; }
public UsageTracking UsageTracker { get; set; }
public uint WarmupTime { get; set; }
public uint CooldownTime { get; set; }
/// <summary>
/// Bool Func that will provide a value for the PowerIsOn Output. Must be implemented
/// by concrete sub-classes
/// </summary>
abstract protected Func<bool> IsCoolingDownFeedbackFunc { get; }
abstract protected Func<bool> IsWarmingUpFeedbackFunc { get; }
protected CTimer WarmupTimer;
protected CTimer CooldownTimer;
#region IRoutingInputs Members
public RoutingPortCollection<RoutingInputPort> InputPorts { get; private set; }
#endregion
protected DisplayBase(string key, string name)
: base(key, name)
{
IsCoolingDownFeedback = new BoolFeedback("IsCoolingDown", IsCoolingDownFeedbackFunc);
IsWarmingUpFeedback = new BoolFeedback("IsWarmingUp", IsWarmingUpFeedbackFunc);
InputPorts = new RoutingPortCollection<RoutingInputPort>();
}
public abstract void PowerOn();
public abstract void PowerOff();
public abstract void PowerToggle();
public virtual FeedbackCollection<Feedback> Feedbacks
{
get
{
return new FeedbackCollection<Feedback>
{
IsCoolingDownFeedback,
IsWarmingUpFeedback
};
}
}
public RoutingInputPort CurrentInputPort => throw new NotImplementedException();
public abstract void ExecuteSwitch(object selector);
protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey,
EiscApiAdvanced bridge)
{
var joinMap = new DisplayControllerJoinMap(joinStart);
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<DisplayControllerJoinMap>(joinMapSerialized);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.LogMessage(LogEventLevel.Information,this,"Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
LinkDisplayToApi(displayDevice, trilist, joinMap);
}
protected void LinkDisplayToApi(DisplayBase displayDevice, BasicTriList trilist, DisplayControllerJoinMap joinMap)
{
Debug.LogMessage(LogEventLevel.Debug, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.LogMessage(LogEventLevel.Information, "Linking to Display: {0}", displayDevice.Name);
trilist.StringInput[joinMap.Name.JoinNumber].StringValue = displayDevice.Name;
var commMonitor = displayDevice as ICommunicationMonitor;
if (commMonitor != null)
{
commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);
}
var inputNumber = 0;
var inputKeys = new List<string>();
var inputNumberFeedback = new IntFeedback(() => inputNumber);
// Two way feedbacks
var twoWayDisplay = displayDevice as TwoWayDisplayBase;
if (twoWayDisplay != null)
{
trilist.SetBool(joinMap.IsTwoWayDisplay.JoinNumber, true);
twoWayDisplay.CurrentInputFeedback.OutputChange += (o, a) => Debug.LogMessage(LogEventLevel.Information, "CurrentInputFeedback_OutputChange {0}", a.StringValue);
inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect.JoinNumber]);
}
// Power Off
trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, () =>
{
inputNumber = 102;
inputNumberFeedback.FireUpdate();
displayDevice.PowerOff();
});
var twoWayDisplayDevice = displayDevice as TwoWayDisplayBase;
if (twoWayDisplayDevice != null)
{
twoWayDisplayDevice.PowerIsOnFeedback.OutputChange += (o, a) =>
{
if (!a.BoolValue)
{
inputNumber = 102;
inputNumberFeedback.FireUpdate();
}
else
{
inputNumber = 0;
inputNumberFeedback.FireUpdate();
}
};
twoWayDisplayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff.JoinNumber]);
twoWayDisplayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]);
}
// PowerOn
trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, () =>
{
inputNumber = 0;
inputNumberFeedback.FireUpdate();
displayDevice.PowerOn();
});
for (int i = 0; i < displayDevice.InputPorts.Count; i++)
{
if (i < joinMap.InputNamesOffset.JoinSpan)
{
inputKeys.Add(displayDevice.InputPorts[i].Key);
var tempKey = inputKeys.ElementAt(i);
trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset.JoinNumber + i),
() => displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector));
Debug.LogMessage(LogEventLevel.Verbose, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}",
joinMap.InputSelectOffset.JoinNumber + i, displayDevice.InputPorts[tempKey].Key.ToString());
trilist.StringInput[(ushort)(joinMap.InputNamesOffset.JoinNumber + i)].StringValue = displayDevice.InputPorts[i].Key.ToString();
}
else
Debug.LogMessage(LogEventLevel.Information, displayDevice, "Device has {0} inputs. The Join Map allows up to {1} inputs. Discarding inputs {2} - {3} from bridge.",
displayDevice.InputPorts.Count, joinMap.InputNamesOffset.JoinSpan, i + 1, displayDevice.InputPorts.Count);
}
Debug.LogMessage(LogEventLevel.Verbose, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect);
trilist.SetUShortSigAction(joinMap.InputSelect.JoinNumber, (a) =>
{
if (a == 0)
{
displayDevice.PowerOff();
inputNumber = 0;
}
else if (a > 0 && a < displayDevice.InputPorts.Count && a != inputNumber)
{
displayDevice.ExecuteSwitch(displayDevice.InputPorts.ElementAt(a - 1).Selector);
inputNumber = a;
}
else if (a == 102)
{
displayDevice.PowerToggle();
}
if (twoWayDisplay != null)
inputNumberFeedback.FireUpdate();
});
var volumeDisplay = displayDevice as IBasicVolumeControls;
if (volumeDisplay == null) return;
trilist.SetBoolSigAction(joinMap.VolumeUp.JoinNumber, volumeDisplay.VolumeUp);
trilist.SetBoolSigAction(joinMap.VolumeDown.JoinNumber, volumeDisplay.VolumeDown);
trilist.SetSigTrueAction(joinMap.VolumeMute.JoinNumber, volumeDisplay.MuteToggle);
var volumeDisplayWithFeedback = volumeDisplay as IBasicVolumeWithFeedback;
if (volumeDisplayWithFeedback == null) return;
trilist.SetSigTrueAction(joinMap.VolumeMuteOn.JoinNumber, volumeDisplayWithFeedback.MuteOn);
trilist.SetSigTrueAction(joinMap.VolumeMuteOff.JoinNumber, volumeDisplayWithFeedback.MuteOff);
trilist.SetUShortSigAction(joinMap.VolumeLevel.JoinNumber, volumeDisplayWithFeedback.SetVolume);
volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevel.JoinNumber]);
volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute.JoinNumber]);
volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMuteOn.JoinNumber]);
volumeDisplayWithFeedback.MuteFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.VolumeMuteOff.JoinNumber]);
}
}
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")]
public abstract class TwoWayDisplayBase : DisplayBase, IRoutingFeedback, IHasPowerControlWithFeedback
{
public StringFeedback CurrentInputFeedback { get; private set; }
abstract protected Func<string> CurrentInputFeedbackFunc { get; }
public BoolFeedback PowerIsOnFeedback { get; protected set; }
abstract protected Func<bool> PowerIsOnFeedbackFunc { get; }
// public static MockDisplay DefaultDisplay
// {
// get
// {
// if (_DefaultDisplay == null)
// _DefaultDisplay = new MockDisplay("default", "Default Display");
// return _DefaultDisplay;
// }
//}
//static MockDisplay _DefaultDisplay;
public TwoWayDisplayBase(string key, string name)
: base(key, name)
{
CurrentInputFeedback = new StringFeedback(CurrentInputFeedbackFunc);
WarmupTime = 7000;
CooldownTime = 15000;
PowerIsOnFeedback = new BoolFeedback("PowerOnFeedback", PowerIsOnFeedbackFunc);
Feedbacks.Add(CurrentInputFeedback);
Feedbacks.Add(PowerIsOnFeedback);
PowerIsOnFeedback.OutputChange += PowerIsOnFeedback_OutputChange;
}
void PowerIsOnFeedback_OutputChange(object sender, EventArgs e)
{
if (UsageTracker != null)
{
if (PowerIsOnFeedback.BoolValue)
UsageTracker.StartDeviceUsage();
else
UsageTracker.EndDeviceUsage();
}
}
public event EventHandler<RoutingNumericEventArgs> NumericSwitchChange;
/// <summary>
/// Raise an event when the status of a switch object changes.
/// </summary>
/// <param name="e">Arguments defined as IKeyName sender, output, input, and eRoutingSignalType</param>
protected void OnSwitchChange(RoutingNumericEventArgs e)
{
var newEvent = NumericSwitchChange;
if (newEvent != null) newEvent(this, e);
}
}
}

View File

@@ -9,6 +9,7 @@ using Crestron.SimplSharpPro.Fusion;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using Serilog.Events;
using System;
using System.Collections.Generic;
@@ -19,7 +20,7 @@ namespace PepperDash.Essentials.Core.Fusion
{
public class EssentialsHuddleSpaceFusionSystemControllerBase : Device, IOccupancyStatusProvider
{
protected EssentialsHuddleSpaceRoomFusionRoomJoinMap JoinMap;
private readonly EssentialsHuddleSpaceRoomFusionRoomJoinMap JoinMap;
private const string RemoteOccupancyXml = "<Occupancy><Type>Local</Type><State>{0}</State></Occupancy>";
private readonly bool _guidFileExists;
@@ -29,15 +30,15 @@ namespace PepperDash.Essentials.Core.Fusion
protected StringSigData CurrentRoomSourceNameSig;
public FusionCustomPropertiesBridge CustomPropertiesBridge = new FusionCustomPropertiesBridge();
private readonly FusionCustomPropertiesBridge CustomPropertiesBridge = new FusionCustomPropertiesBridge();
protected FusionOccupancySensorAsset FusionOccSensor;
protected FusionRemoteOccupancySensor FusionRemoteOccSensor;
private readonly FusionRemoteOccupancySensor FusionRemoteOccSensor;
protected FusionRoom FusionRoom;
protected Dictionary<int, FusionAsset> FusionStaticAssets;
public long PushNotificationTimeout = 5000;
protected IEssentialsRoom Room;
public long SchedulePollInterval = 300000;
private readonly long PushNotificationTimeout = 5000;
private readonly IEssentialsRoom Room;
private readonly long SchedulePollInterval = 300000;
private Event _currentMeeting;
private RoomSchedule _currentSchedule;
@@ -85,7 +86,7 @@ namespace PepperDash.Essentials.Core.Fusion
#region Default Display Source Sigs
private BooleanSigData[] _source = new BooleanSigData[10];
private readonly BooleanSigData[] _source = new BooleanSigData[10];
#endregion
@@ -151,9 +152,8 @@ namespace PepperDash.Essentials.Core.Fusion
ReadGuidFile(guidFilePath);
}
var occupancyRoom = Room as IRoomOccupancy;
if (occupancyRoom != null)
if (Room is IRoomOccupancy occupancyRoom)
{
if (occupancyRoom.RoomOccupancy != null)
{
@@ -367,8 +367,7 @@ namespace PepperDash.Essentials.Core.Fusion
CurrentRoomSourceNameSig = FusionRoom.CreateOffsetStringSig(JoinMap.Display1CurrentSourceName.JoinNumber, JoinMap.Display1CurrentSourceName.AttributeName,
eSigIoMask.InputSigOnly);
// Don't think we need to get current status of this as nothing should be alive yet.
var hasCurrentSourceInfoChange = Room as IHasCurrentSourceInfoChange;
if (hasCurrentSourceInfoChange != null)
if (Room is IHasCurrentSourceInfoChange hasCurrentSourceInfoChange)
{
hasCurrentSourceInfoChange.CurrentSourceChange += Room_CurrentSourceInfoChange;
}
@@ -377,8 +376,7 @@ namespace PepperDash.Essentials.Core.Fusion
FusionRoom.SystemPowerOn.OutputSig.SetSigFalseAction(Room.PowerOnToDefaultOrLastSource);
FusionRoom.SystemPowerOff.OutputSig.SetSigFalseAction(() =>
{
var runRouteAction = Room as IRunRouteAction;
if (runRouteAction != null)
if (Room is IRunRouteAction runRouteAction)
{
runRouteAction.RunRouteAction("roomOff", Room.SourceListKey);
}
@@ -660,7 +658,7 @@ namespace PepperDash.Essentials.Core.Fusion
var extendTime = _currentMeeting.dtEnd - DateTime.Now;
var extendMinutesRaw = extendTime.TotalMinutes;
extendMinutes = extendMinutes + (int) Math.Round(extendMinutesRaw);
extendMinutes += (int) Math.Round(extendMinutesRaw);
}
@@ -901,12 +899,7 @@ namespace PepperDash.Essentials.Core.Fusion
}
}
}
var handler = RoomInfoChange;
if (handler != null)
{
handler(this, new EventArgs());
}
RoomInfoChange?.Invoke(this, new EventArgs());
CustomPropertiesBridge.EvaluateRoomInfo(Room.Key, roomInformation);
}
@@ -1014,12 +1007,7 @@ namespace PepperDash.Essentials.Core.Fusion
}
// Fire Schedule Change Event
var handler = ScheduleChange;
if (handler != null)
{
handler(this, new ScheduleChangeEventArgs {Schedule = _currentSchedule});
}
ScheduleChange?.Invoke(this, new ScheduleChangeEventArgs { Schedule = _currentSchedule });
}
}
}
@@ -1091,7 +1079,7 @@ namespace PepperDash.Essentials.Core.Fusion
}
}
var laptops = dict.Where(d => d.Value.SourceDevice is Devices.Laptop);
var laptops = dict.Where(d => d.Value.SourceDevice is IRoutingSource);
i = 1;
foreach (var kvp in laptops)
{
@@ -1123,9 +1111,7 @@ namespace PepperDash.Essentials.Core.Fusion
/// <param name="e"></param>
protected void UsageTracker_DeviceUsageEnded(object sender, DeviceUsageEventArgs e)
{
var deviceTracker = sender as UsageTracking;
if (deviceTracker == null)
if (!(sender is UsageTracking deviceTracker))
{
return;
}
@@ -1168,8 +1154,7 @@ namespace PepperDash.Essentials.Core.Fusion
// And respond to selection in Fusion
sigD.OutputSig.SetSigFalseAction(() =>
{
var runRouteAction = Room as IRunRouteAction;
if (runRouteAction != null)
if (Room is IRunRouteAction runRouteAction)
{
runRouteAction.RunRouteAction(routeKey, Room.SourceListKey);
}
@@ -1213,12 +1198,11 @@ namespace PepperDash.Essentials.Core.Fusion
//uint attrNum = Convert.ToUInt32(keyNum);
// Check for UI devices
var uiDev = dev as IHasBasicTriListWithSmartObject;
if (uiDev != null)
if (dev is IHasBasicTriListWithSmartObject uiDev)
{
if (uiDev.Panel is Crestron.SimplSharpPro.UI.XpanelForSmartGraphics)
{
attrNum = attrNum + touchpanelNum;
attrNum += touchpanelNum;
if (attrNum > JoinMap.XpanelOnlineStart.JoinSpan)
{
@@ -1231,7 +1215,7 @@ namespace PepperDash.Essentials.Core.Fusion
}
else
{
attrNum = attrNum + xpanelNum;
attrNum += xpanelNum;
if (attrNum > JoinMap.TouchpanelOnlineStart.JoinSpan)
{
@@ -1245,9 +1229,9 @@ namespace PepperDash.Essentials.Core.Fusion
}
//else
if (dev is DisplayBase)
if (dev is IDisplay)
{
attrNum = attrNum + displayNum;
attrNum += displayNum;
if (attrNum > JoinMap.DisplayOnlineStart.JoinSpan)
{
continue;
@@ -1289,23 +1273,21 @@ namespace PepperDash.Essentials.Core.Fusion
{
//Setup Display Usage Monitoring
var displays = DeviceManager.AllDevices.Where(d => d is DisplayBase);
var displays = DeviceManager.AllDevices.Where(d => d is IDisplay);
// Consider updating this in multiple display systems
foreach (var display in displays.Cast<DisplayBase>())
foreach (var display in displays.Cast<IDisplay>())
{
display.UsageTracker = new UsageTracking(display) {UsageIsTracked = true};
display.UsageTracker = new UsageTracking(display as Device) {UsageIsTracked = true};
display.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded;
}
var hasDefaultDisplay = Room as IHasDefaultDisplay;
if (hasDefaultDisplay == null)
if (!(Room is IHasDefaultDisplay hasDefaultDisplay))
{
return;
}
var defaultDisplay = hasDefaultDisplay.DefaultDisplay as DisplayBase;
if (defaultDisplay == null)
if (!(hasDefaultDisplay.DefaultDisplay is IDisplay defaultDisplay))
{
Debug.LogMessage(LogEventLevel.Debug, this, "Cannot link null display to Fusion because default display is null");
return;
@@ -1357,8 +1339,7 @@ namespace PepperDash.Essentials.Core.Fusion
dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction;
dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction;
var defaultTwoWayDisplay = defaultDisplay as IHasPowerControlWithFeedback;
if (defaultTwoWayDisplay != null)
if (defaultDisplay is IHasPowerControlWithFeedback defaultTwoWayDisplay)
{
defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig);
if (defaultDisplay is IDisplayUsage)
@@ -1370,8 +1351,8 @@ namespace PepperDash.Essentials.Core.Fusion
}
// Use extension methods
dispAsset.TrySetMakeModel(defaultDisplay);
dispAsset.TryLinkAssetErrorToCommunication(defaultDisplay);
dispAsset.TrySetMakeModel(defaultDisplay as Device);
dispAsset.TryLinkAssetErrorToCommunication(defaultDisplay as Device);
}
catch (Exception e)
{
@@ -1386,13 +1367,12 @@ namespace PepperDash.Essentials.Core.Fusion
/// <param name="display"></param>
/// <param name="displayIndex"></param>
/// a
protected virtual void MapDisplayToRoomJoins(int displayIndex, uint joinOffset, DisplayBase display)
protected virtual void MapDisplayToRoomJoins(int displayIndex, uint joinOffset, IDisplay display)
{
var displayName = string.Format("Display {0} - ", displayIndex);
var hasDefaultDisplay = Room as IHasDefaultDisplay;
if (hasDefaultDisplay == null || display != hasDefaultDisplay.DefaultDisplay)
if (!(Room is IHasDefaultDisplay hasDefaultDisplay) || display != hasDefaultDisplay.DefaultDisplay)
{
return;
}
@@ -1401,8 +1381,7 @@ namespace PepperDash.Essentials.Core.Fusion
eSigIoMask.InputOutputSig);
defaultDisplayVolume.OutputSig.UserObject = new Action<ushort>(b =>
{
var basicVolumeWithFeedback = display as IBasicVolumeWithFeedback;
if (basicVolumeWithFeedback == null)
if (!(display is IBasicVolumeWithFeedback basicVolumeWithFeedback))
{
return;
}
@@ -1435,8 +1414,7 @@ namespace PepperDash.Essentials.Core.Fusion
});
var defaultTwoWayDisplay = display as IHasPowerControlWithFeedback;
if (defaultTwoWayDisplay != null)
if (display is IHasPowerControlWithFeedback defaultTwoWayDisplay)
{
defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig);
defaultTwoWayDisplay.PowerIsOnFeedback.LinkComplementInputSig(defaultDisplayPowerOff.InputSig);
@@ -1449,8 +1427,7 @@ namespace PepperDash.Essentials.Core.Fusion
{
if (!b)
{
var runRouteAction = Room as IRunRouteAction;
if (runRouteAction != null)
if (Room is IRunRouteAction runRouteAction)
{
runRouteAction.RunRouteAction("roomOff", Room.SourceListKey);
}
@@ -1464,8 +1441,7 @@ namespace PepperDash.Essentials.Core.Fusion
_errorMessageRollUp = new StatusMonitorCollection(this);
foreach (var dev in DeviceManager.GetDevices())
{
var md = dev as ICommunicationMonitor;
if (md != null)
if (dev is ICommunicationMonitor md)
{
_errorMessageRollUp.AddMonitor(md.CommunicationMonitor);
Debug.LogMessage(LogEventLevel.Verbose, this, "Adding '{0}' to room's overall error monitor",
@@ -1531,9 +1507,8 @@ namespace PepperDash.Essentials.Core.Fusion
// Tie to method on occupancy object
//occSensorShutdownMinutes.OutputSig.UserObject(new Action(ushort)(b => Room.OccupancyObj.SetShutdownMinutes(b));
var occRoom = Room as IRoomOccupancy;
if (occRoom != null)
if (Room is IRoomOccupancy occRoom)
{
occRoom.RoomOccupancy.RoomIsOccupiedFeedback.LinkInputSig(occSensorAsset.RoomOccupied.InputSig);
occRoom.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += RoomIsOccupiedFeedback_OutputChange;
@@ -1600,10 +1575,9 @@ namespace PepperDash.Essentials.Core.Fusion
// The sig/UO method: Need separate handlers for fixed and user sigs, all flavors,
// even though they all contain sigs.
var sigData = args.UserConfiguredSigDetail as BooleanSigDataFixedName;
BoolOutputSig outSig;
if (sigData != null)
if (args.UserConfiguredSigDetail is BooleanSigDataFixedName sigData)
{
outSig = sigData.OutputSig;
if (outSig.UserObject is Action<bool>)
@@ -1759,8 +1733,7 @@ namespace PepperDash.Essentials.Core.Fusion
/// </summary>
public static void TrySetMakeModel(this FusionStaticAsset asset, Device device)
{
var mm = device as IMakeModel;
if (mm != null)
if (device is IMakeModel mm)
{
asset.ParamMake.Value = mm.DeviceMake;
asset.ParamModel.Value = mm.DeviceModel;

View File

@@ -1,171 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core.Bridges;
using Serilog.Events;
namespace PepperDash.Essentials.Core.Lighting
{
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")]
public abstract class LightingBase : EssentialsBridgeableDevice, ILightingScenes
{
#region ILightingScenes Members
public event EventHandler<LightingSceneChangeEventArgs> LightingSceneChange;
public List<LightingScene> LightingScenes { get; protected set; }
public LightingScene CurrentLightingScene { get; protected set; }
public IntFeedback CurrentLightingSceneFeedback { get; protected set; }
#endregion
protected LightingBase(string key, string name)
: base(key, name)
{
LightingScenes = new List<LightingScene>();
CurrentLightingScene = new LightingScene();
//CurrentLightingSceneFeedback = new IntFeedback(() => { return int.Parse(this.CurrentLightingScene.ID); });
}
public abstract void SelectScene(LightingScene scene);
public void SimulateSceneSelect(string sceneName)
{
Debug.LogMessage(LogEventLevel.Debug, this, "Simulating selection of scene '{0}'", sceneName);
var scene = LightingScenes.FirstOrDefault(s => s.Name.Equals(sceneName));
if (scene != null)
{
CurrentLightingScene = scene;
OnLightingSceneChange();
}
}
/// <summary>
/// Sets the IsActive property on each scene and fires the LightingSceneChange event
/// </summary>
protected void OnLightingSceneChange()
{
foreach (var scene in LightingScenes)
{
if (scene == CurrentLightingScene)
scene.IsActive = true;
else
scene.IsActive = false;
}
var handler = LightingSceneChange;
if (handler != null)
{
handler(this, new LightingSceneChangeEventArgs(CurrentLightingScene));
}
}
protected GenericLightingJoinMap LinkLightingToApi(LightingBase lightingDevice, BasicTriList trilist, uint joinStart,
string joinMapKey, EiscApiAdvanced bridge)
{
var joinMap = new GenericLightingJoinMap(joinStart);
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
if (!string.IsNullOrEmpty(joinMapSerialized))
joinMap = JsonConvert.DeserializeObject<GenericLightingJoinMap>(joinMapSerialized);
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
else
{
Debug.LogMessage(LogEventLevel.Information, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
}
return LinkLightingToApi(lightingDevice, trilist, joinMap);
}
protected GenericLightingJoinMap LinkLightingToApi(LightingBase lightingDevice, BasicTriList trilist, GenericLightingJoinMap joinMap)
{
Debug.LogMessage(LogEventLevel.Debug, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.LogMessage(LogEventLevel.Information, "Linking to Lighting Type {0}", lightingDevice.GetType().Name.ToString());
// GenericLighitng Actions & FeedBack
trilist.SetUShortSigAction(joinMap.SelectScene.JoinNumber, u => lightingDevice.SelectScene(lightingDevice.LightingScenes[u]));
var sceneIndex = 0;
foreach (var scene in lightingDevice.LightingScenes)
{
var index = sceneIndex;
trilist.SetSigTrueAction((uint)(joinMap.SelectSceneDirect.JoinNumber + index), () => lightingDevice.SelectScene(lightingDevice.LightingScenes[index]));
scene.IsActiveFeedback.LinkInputSig(trilist.BooleanInput[(uint)(joinMap.SelectSceneDirect.JoinNumber + index)]);
trilist.StringInput[(uint)(joinMap.SelectSceneDirect.JoinNumber + index)].StringValue = scene.Name;
trilist.BooleanInput[(uint)(joinMap.ButtonVisibility.JoinNumber + index)].BoolValue = true;
sceneIndex++;
}
trilist.OnlineStatusChange += (sender, args) =>
{
if (!args.DeviceOnLine) return;
sceneIndex = 0;
foreach (var scene in lightingDevice.LightingScenes)
{
var index = sceneIndex;
trilist.StringInput[(uint) (joinMap.SelectSceneDirect.JoinNumber + index)].StringValue = scene.Name;
trilist.BooleanInput[(uint) (joinMap.ButtonVisibility.JoinNumber + index)].BoolValue = true;
scene.IsActiveFeedback.FireUpdate();
sceneIndex++;
}
};
return joinMap;
}
}
public class LightingScene
{
[JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)]
public string Name { get; set; }
[JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)]
public string ID { get; set; }
bool _IsActive;
[JsonProperty("isActive", NullValueHandling = NullValueHandling.Ignore)]
public bool IsActive
{
get
{
return _IsActive;
}
set
{
_IsActive = value;
IsActiveFeedback.FireUpdate();
}
}
[JsonIgnore]
public BoolFeedback IsActiveFeedback { get; set; }
public LightingScene()
{
IsActiveFeedback = new BoolFeedback(new Func<bool>(() => IsActive));
}
}
}

View File

@@ -0,0 +1,37 @@
using System;
using Newtonsoft.Json;
namespace PepperDash.Essentials.Core.Lighting
{
public class LightingScene
{
[JsonProperty("name", NullValueHandling = NullValueHandling.Ignore)]
public string Name { get; set; }
[JsonProperty("id", NullValueHandling = NullValueHandling.Ignore)]
public string ID { get; set; }
bool _IsActive;
[JsonProperty("isActive", NullValueHandling = NullValueHandling.Ignore)]
public bool IsActive
{
get
{
return _IsActive;
}
set
{
_IsActive = value;
IsActiveFeedback.FireUpdate();
}
}
[JsonIgnore]
public BoolFeedback IsActiveFeedback { get; set; }
public LightingScene()
{
IsActiveFeedback = new BoolFeedback(new Func<bool>(() => IsActive));
}
}
}

View File

@@ -151,17 +151,16 @@ namespace PepperDash.Essentials.Core
{
if (MonitorBytesReceived)
{
Client.BytesReceived += Client_BytesReceived;
Client.BytesReceived -= Client_BytesReceived;
Client.BytesReceived += Client_BytesReceived;
}
else
{
Client.TextReceived -= Client_TextReceived;
Client.TextReceived += Client_TextReceived;
}
if (!IsSocket)
{
BeginPolling();
}
BeginPolling();
}
void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)

View File

@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectType>ProgramLibrary</ProjectType>
<Configurations>Debug;Release;Debug 4.7.2</Configurations>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<OutputPath>bin\$(Configuration)\</OutputPath>
<AssemblyName>PepperDash_Essentials_Core</AssemblyName>
<RootNamespace>PepperDash.Essentials.Core</RootNamespace>
@@ -13,7 +13,6 @@
<PackageId>PepperDash.Essentials.Core</PackageId>
<InformationalVersion>$(Version)</InformationalVersion>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Version>2.0.0-local</Version>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugType>full</DebugType>
@@ -31,4 +30,7 @@
<ItemGroup>
<None Include="Crestron\CrestronGenericBaseDevice.cs.orig" />
</ItemGroup>
<ItemGroup>
<Folder Include="Display\" />
</ItemGroup>
</Project>

View File

@@ -4,6 +4,7 @@ using System.Globalization;
using Crestron.SimplSharpPro;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Core.Logging;
using Serilog.Events;
namespace PepperDash.Essentials.Core.Touchpanels
@@ -34,9 +35,9 @@ namespace PepperDash.Essentials.Core.Touchpanels
Debug.LogMessage(LogEventLevel.Information, this, "touchpanel registration response: {0}", registrationResponse);
}
_touchpanel.BaseEvent += _touchpanel_BaseEvent;
_touchpanel.ButtonStateChange += _touchpanel_ButtonStateChange;
_touchpanel.PanelStateChange += _touchpanel_PanelStateChange;
_touchpanel.BaseEvent += Touchpanel_BaseEvent;
_touchpanel.ButtonStateChange += Touchpanel_ButtonStateChange;
_touchpanel.PanelStateChange += Touchpanel_PanelStateChange;
_buttons = buttons;
if (_buttons == null)
@@ -74,10 +75,9 @@ namespace PepperDash.Essentials.Core.Touchpanels
return;
}
int buttonNumber;
TryParseInt(key, out buttonNumber);
TryParseInt(key, out int buttonNumber);
var buttonEventTypes = config.EventTypes;
var buttonEventTypes = config.EventTypes;
BoolOutputSig enabledFb = null;
BoolOutputSig disabledFb = null;
@@ -161,11 +161,10 @@ namespace PepperDash.Essentials.Core.Touchpanels
return;
}
int buttonNumber;
TryParseInt(key, out buttonNumber);
TryParseInt(key, out int buttonNumber);
// Link up the button feedbacks to the specified device feedback
var buttonFeedback = config.Feedback;
// Link up the button feedbacks to the specified device feedback
var buttonFeedback = config.Feedback;
if (buttonFeedback == null || string.IsNullOrEmpty(buttonFeedback.DeviceKey))
{
Debug.LogMessage(LogEventLevel.Debug, this, "Button '{0}' feedback not configured, skipping.",
@@ -177,15 +176,14 @@ namespace PepperDash.Essentials.Core.Touchpanels
try
{
var device = DeviceManager.GetDeviceForKey(buttonFeedback.DeviceKey) as Device;
if (device == null)
{
Debug.LogMessage(LogEventLevel.Debug, this, "Button '{0}' feedback deviceKey '{1}' not found.",
key, buttonFeedback.DeviceKey);
return;
}
if (!(DeviceManager.GetDeviceForKey(buttonFeedback.DeviceKey) is Device device))
{
Debug.LogMessage(LogEventLevel.Debug, this, "Button '{0}' feedback deviceKey '{1}' not found.",
key, buttonFeedback.DeviceKey);
return;
}
deviceFeedback = device.GetFeedbackProperty(buttonFeedback.FeedbackName);
deviceFeedback = device.GetFeedbackProperty(buttonFeedback.FeedbackName);
if (deviceFeedback == null)
{
Debug.LogMessage(LogEventLevel.Debug, this, "Button '{0}' feedbackName property '{1}' not found.",
@@ -224,38 +222,37 @@ namespace PepperDash.Essentials.Core.Touchpanels
}
var boolFeedback = deviceFeedback as BoolFeedback;
var intFeedback = deviceFeedback as IntFeedback;
switch (key)
{
case ("power"):
{
if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackPower);
break;
}
case ("volumeup"):
case ("volumedown"):
case ("volumefeedback"):
{
if (intFeedback != null)
{
var volumeFeedback = intFeedback;
volumeFeedback.LinkInputSig(_touchpanel.VolumeBargraph);
}
break;
}
case ("mute"):
{
if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackMute);
break;
}
default:
{
if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.Feedbacks[(uint)buttonNumber]);
break;
}
}
}
switch (key)
{
case ("power"):
{
boolFeedback?.LinkCrestronFeedback(_touchpanel.FeedbackPower);
break;
}
case ("volumeup"):
case ("volumedown"):
case ("volumefeedback"):
{
if (deviceFeedback is IntFeedback intFeedback)
{
var volumeFeedback = intFeedback;
volumeFeedback.LinkInputSig(_touchpanel.VolumeBargraph);
}
break;
}
case ("mute"):
{
boolFeedback?.LinkCrestronFeedback(_touchpanel.FeedbackMute);
break;
}
default:
{
boolFeedback?.LinkCrestronFeedback(_touchpanel.Feedbacks[(uint)buttonNumber]);
break;
}
}
}
/// <summary>
/// Try parse int helper method
@@ -277,12 +274,12 @@ namespace PepperDash.Essentials.Core.Touchpanels
}
}
private void _touchpanel_BaseEvent(GenericBase device, BaseEventArgs args)
private void Touchpanel_BaseEvent(GenericBase device, BaseEventArgs args)
{
Debug.LogMessage(LogEventLevel.Debug, this, "BaseEvent: eventId-'{0}', index-'{1}'", args.EventId, args.Index);
}
private void _touchpanel_ButtonStateChange(GenericBase device, Crestron.SimplSharpPro.DeviceSupport.ButtonEventArgs args)
private void Touchpanel_ButtonStateChange(GenericBase device, Crestron.SimplSharpPro.DeviceSupport.ButtonEventArgs args)
{
Debug.LogMessage(LogEventLevel.Debug, this, "ButtonStateChange: buttonNumber-'{0}' buttonName-'{1}', buttonState-'{2}'", args.Button.Number, args.Button.Name, args.NewButtonState);
var type = args.NewButtonState.ToString();
@@ -297,7 +294,7 @@ namespace PepperDash.Essentials.Core.Touchpanels
}
}
private void _touchpanel_PanelStateChange(GenericBase device, BaseEventArgs args)
private void Touchpanel_PanelStateChange(GenericBase device, BaseEventArgs args)
{
Debug.LogMessage(LogEventLevel.Debug, this, "PanelStateChange: eventId-'{0}', index-'{1}'", args.EventId, args.Index);
}
@@ -310,7 +307,7 @@ namespace PepperDash.Essentials.Core.Touchpanels
/// <param name="type"></param>
public void Press(string buttonKey, string type)
{
Debug.LogMessage(LogEventLevel.Verbose, this, "Press: buttonKey-'{0}', type-'{1}'", buttonKey, type);
this.LogVerbose("Press: buttonKey-'{buttonKey}', type-'{type}'", buttonKey, type);
// TODO: In future, consider modifying this to generate actions at device activation time
// to prevent the need to dynamically call the method via reflection on each button press
@@ -325,18 +322,12 @@ namespace PepperDash.Essentials.Core.Touchpanels
public void ListButtons()
{
var line = new string('-', 35);
Debug.Console(0, this, line);
Debug.Console(0, this, "MPC3 Controller {0} - Available Butons", Key);
this.LogVerbose("MPC3 Controller {0} - Available Buttons", Key);
foreach (var button in _buttons)
{
Debug.Console(0, this, "Key: {0}", button.Key);
this.LogVerbose("Key: {key}", button.Key);
}
Debug.Console(0, this, line);
}
}

View File

@@ -119,23 +119,23 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers
return;
}
var device = DeviceManager.GetDeviceForKey(body.DeviceKey) as IStreamDebugging;
if (device == null)
{
context.Response.StatusCode = 404;
context.Response.StatusDescription = "Not Found";
context.Response.End();
if (!(DeviceManager.GetDeviceForKey(body.DeviceKey) is IStreamDebugging device))
{
context.Response.StatusCode = 404;
context.Response.StatusDescription = "Not Found";
context.Response.End();
return;
}
eStreamDebuggingSetting debugSetting;
return;
}
eStreamDebuggingSetting debugSetting;
try
{
debugSetting = (eStreamDebuggingSetting) Enum.Parse(typeof (eStreamDebuggingSetting), body.Setting, true);
}
catch (Exception ex)
{
Debug.LogMessage(ex, "Exception handling set debug request");
context.Response.StatusCode = 500;
context.Response.StatusDescription = "Internal Server Error";
context.Response.End();
@@ -161,6 +161,7 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers
}
catch (Exception ex)
{
Debug.LogMessage(ex, "Exception handling set debug request");
context.Response.StatusCode = 500;
context.Response.StatusDescription = "Internal Server Error";
context.Response.End();

View File

@@ -21,7 +21,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras
{
public class CameraVisca : CameraBase, IHasCameraPtzControl, ICommunicationMonitor, IHasCameraPresets, IHasPowerControlWithFeedback, IBridgeAdvanced, IHasCameraFocusControl, IHasAutoFocusMode
{
CameraViscaPropertiesConfig PropertiesConfig;
private readonly CameraViscaPropertiesConfig PropertiesConfig;
public IBasicCommunication Communication { get; private set; }
@@ -30,7 +30,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras
/// <summary>
/// Used to store the actions to parse inquiry responses as the inquiries are sent
/// </summary>
private CrestronQueue<Action<byte[]>> InquiryResponseQueue;
private readonly CrestronQueue<Action<byte[]>> InquiryResponseQueue;
/// <summary>
/// Camera ID (Default 1)
@@ -45,7 +45,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras
public byte PanSpeedFast = 0x13;
public byte TiltSpeedFast = 0x13;
private bool IsMoving;
// private bool IsMoving;
private bool IsZooming;
bool _powerIsOn;
@@ -101,18 +101,17 @@ namespace PepperDash.Essentials.Devices.Common.Cameras
Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom | eCameraCapabilities.Focus;
Communication = comm;
var socket = comm as ISocketStatus;
if (socket != null)
{
// This instance uses IP control
socket.ConnectionChange += new EventHandler<GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
}
else
{
// This instance uses RS-232 control
}
if (comm is ISocketStatus socket)
{
// This instance uses IP control
socket.ConnectionChange += new EventHandler<GenericSocketStatusChageEventArgs>(Socket_ConnectionChange);
}
else
{
// This instance uses RS-232 control
}
Communication.BytesReceived += new EventHandler<GenericCommMethodReceiveBytesArgs>(Communication_BytesReceived);
Communication.BytesReceived += new EventHandler<GenericCommMethodReceiveBytesArgs>(Communication_BytesReceived);
PowerIsOnFeedback = new BoolFeedback(() => { return PowerIsOn; });
CameraIsOffFeedback = new BoolFeedback(() => { return !PowerIsOn; });
@@ -175,7 +174,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras
LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge);
}
void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)
void Socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)
{
Debug.LogMessage(LogEventLevel.Verbose, this, "Socket Status Change: {0}", e.Client.ClientStatus.ToString());
@@ -449,12 +448,12 @@ namespace PepperDash.Essentials.Devices.Common.Cameras
public void PanLeft()
{
SendPanTiltCommand(new byte[] {0x01, 0x03}, false);
IsMoving = true;
// IsMoving = true;
}
public void PanRight()
{
SendPanTiltCommand(new byte[] { 0x02, 0x03 }, false);
IsMoving = true;
// IsMoving = true;
}
public void PanStop()
{
@@ -463,12 +462,12 @@ namespace PepperDash.Essentials.Devices.Common.Cameras
public void TiltDown()
{
SendPanTiltCommand(new byte[] { 0x03, 0x02 }, false);
IsMoving = true;
// IsMoving = true;
}
public void TiltUp()
{
SendPanTiltCommand(new byte[] { 0x03, 0x01 }, false);
IsMoving = true;
// IsMoving = true;
}
public void TiltStop()
{
@@ -507,7 +506,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras
{
StopSpeedTimer();
SendPanTiltCommand(new byte[] { 0x03, 0x03 }, false);
IsMoving = false;
// IsMoving = false;
}
}
public void PositionHome()

View File

@@ -40,9 +40,9 @@ namespace PepperDash.Essentials.Devices.Common.Codec
private int _meetingWarningMinutes = 5;
private Meeting _previousChangedMeeting;
//private Meeting _previousChangedMeeting;
private eMeetingEventChangeType _previousChangeType = eMeetingEventChangeType.Unknown;
//private eMeetingEventChangeType _previousChangeType = eMeetingEventChangeType.Unknown;
public int MeetingWarningMinutes
{
@@ -62,16 +62,11 @@ namespace PepperDash.Essentials.Devices.Common.Codec
set
{
_meetings = value;
var handler = MeetingsListHasChanged;
if (handler != null)
{
handler(this, new EventArgs());
}
MeetingsListHasChanged?.Invoke(this, new EventArgs());
}
}
private CTimer _scheduleChecker;
private readonly CTimer _scheduleChecker;
public CodecScheduleAwareness()
{
@@ -99,12 +94,7 @@ namespace PepperDash.Essentials.Devices.Common.Codec
{
// Add this change type to the NotifiedChangeTypes
meeting.NotifiedChangeTypes |= changeType;
var handler = MeetingEventChange;
if (handler != null)
{
handler(this, new MeetingEventArgs() { ChangeType = changeType, Meeting = meeting });
}
MeetingEventChange?.Invoke(this, new MeetingEventArgs() { ChangeType = changeType, Meeting = meeting });
}
else
{

View File

@@ -4,6 +4,7 @@ using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Bridges;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using Serilog.Events;
using System;
using System.Collections.Generic;
@@ -12,12 +13,7 @@ using Feedback = PepperDash.Essentials.Core.Feedback;
namespace PepperDash.Essentials.Devices.Common.Displays
{
public abstract class DisplayBase : EssentialsDevice
, IHasFeedback
, IRoutingSinkWithSwitching
, IHasPowerControl
, IWarmingCooling
, IUsageTracking
public abstract class DisplayBase : EssentialsDevice, IDisplay
{
private RoutingInputPort _currentInputPort;
public RoutingInputPort CurrentInputPort

View File

@@ -12,7 +12,7 @@ using Serilog.Events;
namespace PepperDash.Essentials.Devices.Common.Displays
{
public class MockDisplay : TwoWayDisplayBase, IBasicVolumeWithFeedback, IBridgeAdvanced, IHasInputs<string, string>, IRoutingSinkWithSwitchingWithInputPort, IHasPowerControlWithFeedback
public class MockDisplay : TwoWayDisplayBase, IBasicVolumeWithFeedback, IBridgeAdvanced, IHasInputs<string>, IRoutingSinkWithSwitchingWithInputPort, IHasPowerControlWithFeedback
{
public ISelectableItems<string> Inputs { get; private set; }

View File

@@ -16,7 +16,6 @@ using Serilog.Events;
namespace PepperDash.Essentials.Devices.Common.Lighting
{
[Obsolete("Please use PepperDash.Essentials.Devices.Common, this will be removed in 2.1")]
public abstract class LightingBase : EssentialsBridgeableDevice, ILightingScenes
{
#region ILightingScenes Members
@@ -68,12 +67,7 @@ namespace PepperDash.Essentials.Devices.Common.Lighting
else
scene.IsActive = false;
}
var handler = LightingSceneChange;
if (handler != null)
{
handler(this, new LightingSceneChangeEventArgs(CurrentLightingScene));
}
LightingSceneChange?.Invoke(this, new LightingSceneChangeEventArgs(CurrentLightingScene));
}
protected GenericLightingJoinMap LinkLightingToApi(LightingBase lightingDevice, BasicTriList trilist, uint joinStart,

View File

@@ -1,6 +1,5 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectType>ProgramLibrary</ProjectType>
<Configurations>Debug;Release;Debug 4.7.2</Configurations>
</PropertyGroup>
<PropertyGroup>
@@ -9,10 +8,9 @@
<OutputPath>bin\$(Configuration)\</OutputPath>
<AssemblyName>Essentials Devices Common</AssemblyName>
<RootNamespace>PepperDash.Essentials.Devices.Common</RootNamespace>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Title>PepperDash Essentials Devices Common</Title>
<PackageId>PepperDash.Essentials.Devices.Common</PackageId>
<Version>2.0.0-local</Version>
<InformationalVersion>$(Version)</InformationalVersion>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>

View File

@@ -31,9 +31,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
protected const int MaxParticipants = 50;
private readonly byte[] _clearBytes = XSigHelpers.ClearOutputs();
private IHasDirectory _directoryCodec;
private BasicTriList _directoryTrilist;
private VideoCodecControllerJoinMap _directoryJoinmap;
private readonly IHasDirectory _directoryCodec;
private readonly BasicTriList _directoryTrilist;
private readonly VideoCodecControllerJoinMap _directoryJoinmap;
protected string _timeFormatSpecifier;
protected string _dateFormatSpecifier;
@@ -216,11 +216,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
/// <param name="item"></param>
protected virtual void OnCallStatusChange(CodecActiveCallItem item)
{
var handler = CallStatusChange;
if (handler != null)
{
handler(this, new CodecCallStatusItemChangeEventArgs(item));
}
CallStatusChange?.Invoke(this, new CodecCallStatusItemChangeEventArgs(item));
PrivacyModeIsOnFeedback.FireUpdate();
@@ -252,12 +248,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
try
{
IsReady = true;
var h = IsReadyChange;
if (h != null)
{
h(this, new EventArgs());
}
}
IsReadyChange?.Invoke(this, new EventArgs());
}
catch (Exception e)
{
Debug.LogMessage(LogEventLevel.Verbose, this, "Error in SetIsReady() : {0}", e);
@@ -309,10 +301,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
joinMap.SetCustomJoinData(customJoins);
}
if (bridge != null)
{
bridge.AddJoinMap(Key, joinMap);
}
bridge?.AddJoinMap(Key, joinMap);
LinkVideoCodecToApi(codec, trilist, joinMap);
@@ -530,11 +519,10 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false);
var autoCodec = codec as IHasCameraAutoMode;
if (autoCodec == null) return;
if (!(codec is IHasCameraAutoMode autoCodec)) return;
trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, autoCodec.CameraAutoModeIsOnFeedback.BoolValue);
trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, autoCodec.CameraAutoModeIsOnFeedback.BoolValue);
trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !autoCodec.CameraAutoModeIsOnFeedback.BoolValue);
};
@@ -548,11 +536,10 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false);
var autoModeCodec = codec as IHasCameraAutoMode;
if (autoModeCodec == null) return;
if (!(codec is IHasCameraAutoMode autoModeCodec)) return;
trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, autoModeCodec.CameraAutoModeIsOnFeedback.BoolValue);
trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, autoModeCodec.CameraAutoModeIsOnFeedback.BoolValue);
trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !autoModeCodec.CameraAutoModeIsOnFeedback.BoolValue);
}
@@ -649,8 +636,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
var p = participant;
if (index > MaxParticipants) break;
var audioMuteCodec = this as IHasParticipantAudioMute;
if (audioMuteCodec != null)
if (this is IHasParticipantAudioMute audioMuteCodec)
{
trilist.SetSigFalseAction(joinMap.ParticipantAudioMuteToggleStart.JoinNumber + index,
() => audioMuteCodec.ToggleAudioForParticipant(p.UserId));
@@ -659,8 +645,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
() => audioMuteCodec.ToggleVideoForParticipant(p.UserId));
}
var pinCodec = this as IHasParticipantPinUnpin;
if (pinCodec != null)
if (this is IHasParticipantPinUnpin pinCodec)
{
trilist.SetSigFalseAction(joinMap.ParticipantPinToggleStart.JoinNumber + index,
() => pinCodec.ToggleParticipantPinState(p.UserId, pinCodec.ScreenIndexToPinUserTo));
@@ -1089,29 +1074,25 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
// Allow auto dial of selected line. Always dials first contact method
if (!trilist.GetBool(joinMap.DirectoryDisableAutoDialSelectedLine.JoinNumber))
{
var invitableEntry = _selectedDirectoryItem as IInvitableContact;
if (invitableEntry != null)
if (_selectedDirectoryItem is IInvitableContact invitableEntry)
{
Dial(invitableEntry);
return;
}
var entryToDial = _selectedDirectoryItem as DirectoryContact;
trilist.SetString(joinMap.DirectoryEntrySelectedNumber.JoinNumber,
trilist.SetString(joinMap.DirectoryEntrySelectedNumber.JoinNumber,
selectedContact != null ? selectedContact.ContactMethods[0].Number : string.Empty);
if (entryToDial == null) return;
if (!(_selectedDirectoryItem is DirectoryContact entryToDial)) return;
Dial(entryToDial.ContactMethods[0].Number);
}
else
{
// If auto dial is disabled...
var entryToDial = _selectedDirectoryItem as DirectoryContact;
if (entryToDial == null)
if (!(_selectedDirectoryItem is DirectoryContact entryToDial))
{
// Clear out values and actions from last selected item
trilist.SetUshort(joinMap.SelectedContactMethodCount.JoinNumber, 0);
@@ -1296,78 +1277,76 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetUshort(joinMap.ConnectedCallCount.JoinNumber, (ushort)ActiveCalls.Count);
};
var joinCodec = this as IJoinCalls;
if (joinCodec != null)
{
trilist.SetSigFalseAction(joinMap.JoinAllCalls.JoinNumber, () => joinCodec.JoinAllCalls());
if (this is IJoinCalls joinCodec)
{
trilist.SetSigFalseAction(joinMap.JoinAllCalls.JoinNumber, () => joinCodec.JoinAllCalls());
for (int i = 0; i < joinMap.JoinCallStart.JoinSpan; i++)
{
trilist.SetSigFalseAction((uint)(joinMap.JoinCallStart.JoinNumber + i), () =>
{
var call = ActiveCalls[i];
if (call != null)
{
joinCodec.JoinCall(call);
}
else
{
Debug.LogMessage(LogEventLevel.Information, this, "[Join Call] Unable to find call at index '{0}'", i);
}
});
}
}
for (int i = 0; i < joinMap.JoinCallStart.JoinSpan; i++)
{
trilist.SetSigFalseAction((uint)(joinMap.JoinCallStart.JoinNumber + i), () =>
{
var call = ActiveCalls[i];
if (call != null)
{
joinCodec.JoinCall(call);
}
else
{
Debug.LogMessage(LogEventLevel.Information, this, "[Join Call] Unable to find call at index '{0}'", i);
}
});
}
}
var holdCodec = this as IHasCallHold;
if (holdCodec != null)
{
trilist.SetSigFalseAction(joinMap.HoldAllCalls.JoinNumber, () =>
{
foreach (var call in ActiveCalls)
{
holdCodec.HoldCall(call);
}
});
if (this is IHasCallHold holdCodec)
{
trilist.SetSigFalseAction(joinMap.HoldAllCalls.JoinNumber, () =>
{
foreach (var call in ActiveCalls)
{
holdCodec.HoldCall(call);
}
});
for (int i = 0; i < joinMap.HoldCallsStart.JoinSpan; i++)
{
var index = i;
for (int i = 0; i < joinMap.HoldCallsStart.JoinSpan; i++)
{
var index = i;
trilist.SetSigFalseAction((uint)(joinMap.HoldCallsStart.JoinNumber + index), () =>
{
if (index < 0 || index >= ActiveCalls.Count) return;
trilist.SetSigFalseAction((uint)(joinMap.HoldCallsStart.JoinNumber + index), () =>
{
if (index < 0 || index >= ActiveCalls.Count) return;
var call = ActiveCalls[index];
if (call != null)
{
holdCodec.HoldCall(call);
}
else
{
Debug.LogMessage(LogEventLevel.Information, this, "[Hold Call] Unable to find call at index '{0}'", i);
}
});
var call = ActiveCalls[index];
if (call != null)
{
holdCodec.HoldCall(call);
}
else
{
Debug.LogMessage(LogEventLevel.Information, this, "[Hold Call] Unable to find call at index '{0}'", i);
}
});
trilist.SetSigFalseAction((uint)(joinMap.ResumeCallsStart.JoinNumber + index), () =>
{
if (index < 0 || index >= ActiveCalls.Count) return;
trilist.SetSigFalseAction((uint)(joinMap.ResumeCallsStart.JoinNumber + index), () =>
{
if (index < 0 || index >= ActiveCalls.Count) return;
var call = ActiveCalls[index];
if (call != null)
{
holdCodec.ResumeCall(call);
}
else
{
Debug.LogMessage(LogEventLevel.Information, this, "[Resume Call] Unable to find call at index '{0}'", i);
}
});
}
}
var call = ActiveCalls[index];
if (call != null)
{
holdCodec.ResumeCall(call);
}
else
{
Debug.LogMessage(LogEventLevel.Information, this, "[Resume Call] Unable to find call at index '{0}'", i);
}
});
}
}
trilist.OnlineStatusChange += (device, args) =>
trilist.OnlineStatusChange += (device, args) =>
{
if (!args.DeviceOnLine) return;
@@ -1505,48 +1484,45 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
codec.CameraAutoModeIsOnFeedback.OutputChange += (o, a) =>
{
var offCodec = codec as IHasCameraOff;
if (codec is IHasCameraOff offCodec)
{
if (offCodec.CameraIsOffFeedback.BoolValue)
{
trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, false);
trilist.SetBool(joinMap.CameraModeManual.JoinNumber, false);
trilist.SetBool(joinMap.CameraModeOff.JoinNumber, true);
return;
}
if (offCodec != null)
{
if (offCodec.CameraIsOffFeedback.BoolValue)
{
trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, false);
trilist.SetBool(joinMap.CameraModeManual.JoinNumber, false);
trilist.SetBool(joinMap.CameraModeOff.JoinNumber, true);
return;
}
trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, a.BoolValue);
trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !a.BoolValue);
trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false);
return;
}
trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, a.BoolValue);
trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !a.BoolValue);
trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false);
return;
}
trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, a.BoolValue);
trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, a.BoolValue);
trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !a.BoolValue);
trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false);
};
var offModeCodec = codec as IHasCameraOff;
if (offModeCodec != null)
{
if (offModeCodec.CameraIsOffFeedback.BoolValue)
{
trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, false);
trilist.SetBool(joinMap.CameraModeManual.JoinNumber, false);
trilist.SetBool(joinMap.CameraModeOff.JoinNumber, true);
return;
}
if (codec is IHasCameraOff offModeCodec)
{
if (offModeCodec.CameraIsOffFeedback.BoolValue)
{
trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, false);
trilist.SetBool(joinMap.CameraModeManual.JoinNumber, false);
trilist.SetBool(joinMap.CameraModeOff.JoinNumber, true);
return;
}
trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, codec.CameraAutoModeIsOnFeedback.BoolValue);
trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !codec.CameraAutoModeIsOnFeedback.BoolValue);
trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false);
return;
}
trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, codec.CameraAutoModeIsOnFeedback.BoolValue);
trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !codec.CameraAutoModeIsOnFeedback.BoolValue);
trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false);
return;
}
trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, codec.CameraAutoModeIsOnFeedback.BoolValue);
trilist.SetBool(joinMap.CameraModeAuto.JoinNumber, codec.CameraAutoModeIsOnFeedback.BoolValue);
trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !codec.CameraAutoModeIsOnFeedback.BoolValue);
trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false);
}
@@ -1565,64 +1541,58 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetBoolSigAction(joinMap.CameraTiltUp.JoinNumber, (b) =>
{
if (codec.SelectedCamera == null) return;
var camera = codec.SelectedCamera as IHasCameraPtzControl;
if (camera == null) return;
if (!(codec.SelectedCamera is IHasCameraPtzControl camera)) return;
if (b) camera.TiltUp();
if (b) camera.TiltUp();
else camera.TiltStop();
});
trilist.SetBoolSigAction(joinMap.CameraTiltDown.JoinNumber, (b) =>
{
if (codec.SelectedCamera == null) return;
var camera = codec.SelectedCamera as IHasCameraPtzControl;
if (camera == null) return;
if (!(codec.SelectedCamera is IHasCameraPtzControl camera)) return;
if (b) camera.TiltDown();
if (b) camera.TiltDown();
else camera.TiltStop();
});
trilist.SetBoolSigAction(joinMap.CameraPanLeft.JoinNumber, (b) =>
{
if (codec.SelectedCamera == null) return;
var camera = codec.SelectedCamera as IHasCameraPtzControl;
if (camera == null) return;
if (!(codec.SelectedCamera is IHasCameraPtzControl camera)) return;
if (b) camera.PanLeft();
if (b) camera.PanLeft();
else camera.PanStop();
});
trilist.SetBoolSigAction(joinMap.CameraPanRight.JoinNumber, (b) =>
{
if (codec.SelectedCamera == null) return;
var camera = codec.SelectedCamera as IHasCameraPtzControl;
if (camera == null) return;
if (!(codec.SelectedCamera is IHasCameraPtzControl camera)) return;
if (b) camera.PanRight();
if (b) camera.PanRight();
else camera.PanStop();
});
trilist.SetBoolSigAction(joinMap.CameraZoomIn.JoinNumber, (b) =>
{
if (codec.SelectedCamera == null) return;
var camera = codec.SelectedCamera as IHasCameraPtzControl;
if (camera == null) return;
if (!(codec.SelectedCamera is IHasCameraPtzControl camera)) return;
if (b) camera.ZoomIn();
if (b) camera.ZoomIn();
else camera.ZoomStop();
});
trilist.SetBoolSigAction(joinMap.CameraZoomOut.JoinNumber, (b) =>
{
if (codec.SelectedCamera == null) return;
var camera = codec.SelectedCamera as IHasCameraPtzControl;
if (camera == null) return;
if (!(codec.SelectedCamera is IHasCameraPtzControl camera)) return;
if (b) camera.ZoomOut();
if (b) camera.ZoomOut();
else camera.ZoomStop();
});
@@ -1630,9 +1600,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetBoolSigAction(joinMap.CameraFocusNear.JoinNumber, (b) =>
{
if (codec.SelectedCamera == null) return;
var camera = codec.SelectedCamera as IHasCameraFocusControl;
if (camera == null) return;
if (!(codec.SelectedCamera is IHasCameraFocusControl camera)) return;
if (b) camera.FocusNear();
else camera.FocusStop();
@@ -1641,9 +1610,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetBoolSigAction(joinMap.CameraFocusFar.JoinNumber, (b) =>
{
if (codec.SelectedCamera == null) return;
var camera = codec.SelectedCamera as IHasCameraFocusControl;
if (camera == null) return;
if (!(codec.SelectedCamera is IHasCameraFocusControl camera)) return;
if (b) camera.FocusFar();
else camera.FocusStop();
@@ -1652,9 +1620,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetSigFalseAction(joinMap.CameraFocusAuto.JoinNumber, () =>
{
if (codec.SelectedCamera == null) return;
var camera = codec.SelectedCamera as IHasCameraFocusControl;
if (camera == null) return;
if (!(codec.SelectedCamera is IHasCameraFocusControl camera)) return;
camera.TriggerAutoFocus();
});
@@ -1773,7 +1740,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
// Following fields only used for Bridging
private int _selectedRecentCallItemIndex;
private CodecCallHistory.CallHistoryEntry _selectedRecentCallItem;
private DirectoryItem _selectedDirectoryItem;
private void LinkVideoCodecCallHistoryToApi(IHasCallHistory codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap)
@@ -1820,7 +1786,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
// Clear out selected item
_selectedRecentCallItemIndex = 0;
_selectedRecentCallItem = null;
trilist.SetUshort(joinMap.SelectRecentCallItem.JoinNumber, 0);
trilist.SetString(joinMap.SelectedRecentCallName.JoinNumber, string.Empty);
trilist.SetString(joinMap.SelectedRecentCallNumber.JoinNumber, string.Empty);
@@ -1929,12 +1895,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
{
if (value == true)
{
var handler = InitialSyncCompleted;
if (handler != null)
{
handler(this, new EventArgs());
}
}
InitialSyncCompleted?.Invoke(this, new EventArgs());
}
_InitialSyncComplete = value;
}
}

View File

@@ -5,7 +5,7 @@ namespace PepperDash.Essentials.AppServer
{
public class SourceSelectMessageContent
{
[JsonProperty("sourceListItemKey")]
public string SourceListItemKey { get; set; }
[JsonProperty("sourceListKey")]

View File

@@ -1,15 +1,14 @@
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.AppServer;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using System;
using System.Linq;
using DisplayBase = PepperDash.Essentials.Devices.Common.Displays.DisplayBase;
namespace PepperDash.Essentials.Room.MobileControl
{
public class DisplayBaseMessenger: MessengerBase
public class DisplayBaseMessenger : MessengerBase
{
private readonly DisplayBase display;
@@ -20,7 +19,7 @@ namespace PepperDash.Essentials.Room.MobileControl
protected override void RegisterActions()
{
base.RegisterActions();
base.RegisterActions();
/*AddAction("/powerOn", (id, content) => display.PowerOn());
AddAction("/powerOff", (id, content) => display.PowerOff());
@@ -34,7 +33,7 @@ namespace PepperDash.Essentials.Room.MobileControl
if (inputPort == null)
{
Debug.Console(1, "No input named {0} found for device {1}", s, display.Key);
this.LogWarning("No input named {inputName} found for {deviceKey}", s, display.Key);
return;
}

View File

@@ -1,12 +1,10 @@
using PepperDash.Core;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
#if SERIES4
#endif
namespace PepperDash.Essentials.Room.MobileControl
{
public class IChannelMessenger:MessengerBase
public class IChannelMessenger : MessengerBase
{
private readonly IChannel channelDevice;
@@ -17,14 +15,14 @@ namespace PepperDash.Essentials.Room.MobileControl
protected override void RegisterActions()
{
base.RegisterActions();
base.RegisterActions();
AddAction("/chanUp", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => channelDevice?.ChannelUp(b)));
AddAction("/chanDown", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => channelDevice?.ChannelDown(b)));
AddAction("/lastChan", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => channelDevice?.LastChannel(b)));
AddAction("/guide", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => channelDevice?.Guide(b)));
AddAction("/info", (id, content) => PressAndHoldHandler.HandlePressAndHold (DeviceKey, content, (b) => channelDevice?.Info(b)));
AddAction("/info", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => channelDevice?.Info(b)));
AddAction("/exit", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => channelDevice?.Exit(b)));
}
}

View File

@@ -1,11 +1,10 @@
using PepperDash.Core;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
namespace PepperDash.Essentials.Room.MobileControl
{
public class IColorMessenger:MessengerBase
public class IColorMessenger : MessengerBase
{
private readonly IColor colorDevice;
public IColorMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
@@ -15,12 +14,12 @@ namespace PepperDash.Essentials.Room.MobileControl
protected override void RegisterActions()
{
base.RegisterActions();
base.RegisterActions();
AddAction("/red", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => colorDevice?.Red(b)));
AddAction("/green", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => colorDevice?.Green(b)));
AddAction("/yellow", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => colorDevice?.Yellow(b)));
AddAction("/blue", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => colorDevice?.Blue(b)));
AddAction("/blue", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => colorDevice?.Blue(b)));
}
}
}

View File

@@ -1,12 +1,10 @@
using PepperDash.Core;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
#if SERIES4
#endif
namespace PepperDash.Essentials.Room.MobileControl
{
public class IDPadMessenger:MessengerBase
public class IDPadMessenger : MessengerBase
{
private readonly IDPad dpadDevice;
public IDPadMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
@@ -17,7 +15,7 @@ namespace PepperDash.Essentials.Room.MobileControl
protected override void RegisterActions()
{
base.RegisterActions();
base.RegisterActions();
AddAction("/up", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => dpadDevice?.Up(b)));
AddAction("/down", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => dpadDevice?.Down(b)));

View File

@@ -1,12 +1,10 @@
using PepperDash.Core;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
#if SERIES4
#endif
namespace PepperDash.Essentials.Room.MobileControl
{
public class IDvrMessenger: MessengerBase
public class IDvrMessenger : MessengerBase
{
private readonly IDvr dvrDevice;
public IDvrMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
@@ -16,7 +14,7 @@ namespace PepperDash.Essentials.Room.MobileControl
protected override void RegisterActions()
{
base.RegisterActions();
base.RegisterActions();
AddAction("/dvrlist", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => dvrDevice?.DvrList(b)));
AddAction("/record", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => dvrDevice?.Record(b)));

View File

@@ -1,11 +1,10 @@
using PepperDash.Core;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
namespace PepperDash.Essentials.Room.MobileControl
{
public class IHasPowerMessenger:MessengerBase
public class IHasPowerMessenger : MessengerBase
{
private readonly IHasPowerControl powerDevice;
public IHasPowerMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)

View File

@@ -1,12 +1,10 @@
using PepperDash.Core;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
#if SERIES4
#endif
namespace PepperDash.Essentials.Room.MobileControl
{
public class INumericKeypadMessenger:MessengerBase
public class INumericKeypadMessenger : MessengerBase
{
private readonly INumericKeypad keypadDevice;
public INumericKeypadMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
@@ -16,7 +14,7 @@ namespace PepperDash.Essentials.Room.MobileControl
protected override void RegisterActions()
{
base.RegisterActions();
base.RegisterActions();
AddAction("/num0", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => keypadDevice?.Digit0(b)));
AddAction("/num1", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => keypadDevice?.Digit1(b)));

View File

@@ -1,12 +1,10 @@
using PepperDash.Core;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
#if SERIES4
#endif
namespace PepperDash.Essentials.Room.MobileControl
{
public class ISetTopBoxControlsMessenger:MessengerBase
public class ISetTopBoxControlsMessenger : MessengerBase
{
private readonly ISetTopBoxControls stbDevice;
public ISetTopBoxControlsMessenger(string key, string messagePath, IKeyName device) : base(key, messagePath, device)
@@ -20,15 +18,15 @@ namespace PepperDash.Essentials.Room.MobileControl
AddAction("/fullStatus", (id, content) => SendISetTopBoxControlsFullMessageObject());
AddAction("/dvrList", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => stbDevice?.DvrList(b)));
AddAction("/replay", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => stbDevice?.Replay(b)));
}
/// <summary>
}
/// <summary>
/// Helper method to build call status for vtc
/// </summary>
/// <returns></returns>
private void SendISetTopBoxControlsFullMessageObject()
{
PostStatusMessage( new SetTopBoxControlsState());
PostStatusMessage(new SetTopBoxControlsState());
}

View File

@@ -0,0 +1,30 @@
using PepperDash.Core;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Room.MobileControl
{
public class ITransportMessenger : MessengerBase
{
private readonly ITransport transportDevice;
public ITransportMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
{
transportDevice = device as ITransport;
}
protected override void RegisterActions()
{
base.RegisterActions();
AddAction("/play", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => transportDevice?.Play(b)));
AddAction("/pause", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => transportDevice?.Pause(b)));
AddAction("/stop", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => transportDevice?.Stop(b)));
AddAction("/prevTrack", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => transportDevice?.ChapPlus(b)));
AddAction("/nextTrack", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => transportDevice?.ChapMinus(b)));
AddAction("/rewind", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => transportDevice?.Rewind(b)));
AddAction("/ffwd", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => transportDevice?.FFwd(b)));
AddAction("/record", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => transportDevice?.Record(b)));
}
}
}

View File

@@ -1,61 +0,0 @@
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.AppServer;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using System;
using System.Linq;
using DisplayBase = PepperDash.Essentials.Core.DisplayBase;
namespace PepperDash.Essentials.Room.MobileControl
{
public class CoreDisplayBaseMessenger: MessengerBase
{
private readonly DisplayBase display;
public CoreDisplayBaseMessenger(string key, string messagePath, DisplayBase device) : base(key, messagePath, device)
{
display = device;
}
protected override void RegisterActions()
{
base.RegisterActions();
/* AddAction("/powerOn", (id, content) => display.PowerOn());
AddAction("/powerOff", (id, content) => display.PowerOff());
AddAction("/powerToggle", (id, content) => display.PowerToggle());*/
AddAction("/inputSelect", (id, content) =>
{
var s = content.ToObject<MobileControlSimpleContent<string>>();
var inputPort = display.InputPorts.FirstOrDefault(i => i.Key == s.Value);
if (inputPort == null)
{
Debug.Console(1, "No input named {0} found for device {1}", s, display.Key);
return;
}
display.ExecuteSwitch(inputPort.Selector);
});
AddAction("/inputs", (id, content) =>
{
var inputsList = display.InputPorts.Select(p => p.Key).ToList();
var messageObject = new MobileControlMessage
{
Type = MessagePath + "/inputs",
Content = JToken.FromObject(new
{
inputKeys = inputsList,
})
};
AppServerController.SendMessageObject(messageObject);
});
}
}
}

View File

@@ -1,32 +0,0 @@
using PepperDash.Core;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
#if SERIES4
#endif
namespace PepperDash.Essentials.Room.MobileControl
{
public class ITransportMessenger:MessengerBase
{
private readonly ITransport transportDevice;
public ITransportMessenger(string key, string messagePath, Device device) : base(key, messagePath, device)
{
transportDevice = device as ITransport;
}
protected override void RegisterActions()
{
base.RegisterActions();
AddAction("/play", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => transportDevice?.Play(b)));
AddAction("/pause", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => transportDevice?.Pause(b)));
AddAction("/stop", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => transportDevice?.Stop(b)));
AddAction("/prevTrack", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => transportDevice?.ChapPlus(b)));
AddAction("/nextTrack", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => transportDevice?.ChapMinus(b)));
AddAction("/rewind", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => transportDevice?.Rewind(b)));
AddAction("/ffwd", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => transportDevice?.FFwd(b)));
AddAction("/record", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) => transportDevice?.Record(b)));
}
}
}

View File

@@ -1,5 +1,4 @@
using Newtonsoft.Json.Linq;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Devices.Common.AudioCodec;
using PepperDash.Essentials.Devices.Common.Codec;
using System;
@@ -30,11 +29,8 @@ namespace PepperDash.Essentials.AppServer.Messengers
codec.CallStatusChange += Codec_CallStatusChange;
}
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
base.RegisterActions();
@@ -106,14 +102,14 @@ namespace PepperDash.Essentials.AppServer.Messengers
var info = Codec.CodecInfo;
PostStatusMessage(JToken.FromObject(new
{
isInCall = Codec.IsInCall,
calls = Codec.ActiveCalls,
info = new
{
isInCall = Codec.IsInCall,
calls = Codec.ActiveCalls,
info = new
{
phoneNumber = info.PhoneNumber
}
})
phoneNumber = info.PhoneNumber
}
})
);
}
}

View File

@@ -1,6 +1,5 @@
using Newtonsoft.Json.Linq;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Devices.Common.Cameras;
using System;
using System.Collections.Generic;
@@ -40,17 +39,13 @@ namespace PepperDash.Essentials.AppServer.Messengers
presetList = presetsCamera.Presets;
PostStatusMessage(JToken.FromObject(new
{
presets = presetList
})
{
presets = presetList
})
);
}
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
base.RegisterActions();
@@ -179,14 +174,14 @@ namespace PepperDash.Essentials.AppServer.Messengers
presetList = presetsCamera.Presets;
PostStatusMessage(JToken.FromObject(new
{
cameraManualSupported = Camera is IHasCameraControls,
cameraAutoSupported = Camera is IHasCameraAutoMode,
cameraOffSupported = Camera is IHasCameraOff,
cameraMode = GetCameraMode(),
hasPresets = Camera is IHasCameraPresets,
presets = presetList
})
{
cameraManualSupported = Camera is IHasCameraControls,
cameraAutoSupported = Camera is IHasCameraAutoMode,
cameraOffSupported = Camera is IHasCameraOff,
cameraMode = GetCameraMode(),
hasPresets = Camera is IHasCameraPresets,
presets = presetList
})
);
}

View File

@@ -1,91 +0,0 @@
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
namespace PepperDash.Essentials.AppServer.Messengers
{
public class CoreTwoWayDisplayBaseMessenger : MessengerBase
{
private readonly TwoWayDisplayBase _display;
public CoreTwoWayDisplayBaseMessenger(string key, string messagePath, Device display)
: base(key, messagePath, display)
{
_display = display as TwoWayDisplayBase;
}
#region Overrides of MessengerBase
public void SendFullStatus()
{
var messageObj = new TwoWayDisplayBaseStateMessage
{
//PowerState = _display.PowerIsOnFeedback.BoolValue,
CurrentInput = _display.CurrentInputFeedback.StringValue
};
PostStatusMessage(messageObj);
}
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
base.RegisterActions();
if (_display == null)
{
Debug.Console(0, this, $"Unable to register TwoWayDisplayBase messenger {Key}");
return;
}
AddAction("/fullStatus", (id, content) => SendFullStatus());
_display.PowerIsOnFeedback.OutputChange += PowerIsOnFeedbackOnOutputChange;
_display.CurrentInputFeedback.OutputChange += CurrentInputFeedbackOnOutputChange;
_display.IsCoolingDownFeedback.OutputChange += IsCoolingFeedbackOnOutputChange;
_display.IsWarmingUpFeedback.OutputChange += IsWarmingFeedbackOnOutputChange;
}
private void CurrentInputFeedbackOnOutputChange(object sender, FeedbackEventArgs feedbackEventArgs)
{
PostStatusMessage(JToken.FromObject(new
{
currentInput = feedbackEventArgs.StringValue
}));
}
private void PowerIsOnFeedbackOnOutputChange(object sender, FeedbackEventArgs feedbackEventArgs)
{
PostStatusMessage(JToken.FromObject(new
{
powerState = feedbackEventArgs.BoolValue
})
);
}
private void IsWarmingFeedbackOnOutputChange(object sender, FeedbackEventArgs feedbackEventArgs)
{
PostStatusMessage(JToken.FromObject(new
{
isWarming = feedbackEventArgs.BoolValue
})
);
}
private void IsCoolingFeedbackOnOutputChange(object sender, FeedbackEventArgs feedbackEventArgs)
{
PostStatusMessage(JToken.FromObject(new
{
isCooling = feedbackEventArgs.BoolValue
})
);
}
#endregion
}
}

View File

@@ -2,11 +2,6 @@
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core.DeviceInfo;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PepperDash.Essentials.AppServer.Messengers
{

View File

@@ -40,18 +40,17 @@ namespace PepperDash.Essentials.AppServer.Messengers
#region Overrides of MessengerBase
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
AddAction("/presets/fullStatus", (id, content) => {
AddAction("/presets/fullStatus", (id, content) =>
{
this.LogInformation("getting full status for client {id}", id);
try
{
SendPresets();
} catch(Exception ex)
}
catch (Exception ex)
{
Debug.LogMessage(ex, "Exception sending preset full status", this);
}

View File

@@ -2,7 +2,6 @@
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.Core;
using System;
@@ -39,7 +38,8 @@ namespace PepperDash.Essentials.AppServer.Messengers
}
PostStatusMessage(messageObj);
} catch(Exception ex)
}
catch (Exception ex)
{
Debug.LogMessage(ex, "Exception sending full status", this);
}
@@ -47,11 +47,8 @@ namespace PepperDash.Essentials.AppServer.Messengers
#region Overrides of MessengerBase
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
AddAction("/fullStatus", (id, content) => SendStatus());
@@ -63,7 +60,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
});
AddAction("/muteToggle", (id, content) =>
{
{
_localDevice.MuteToggle();
});
@@ -77,21 +74,22 @@ namespace PepperDash.Essentials.AppServer.Messengers
_localDevice.MuteOff();
});
AddAction("/volumeUp", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) =>
AddAction("/volumeUp", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) =>
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Calling {localDevice} volume up with {value}", DeviceKey, b);
try
{
_localDevice.VolumeUp(b);
} catch (Exception ex)
}
catch (Exception ex)
{
Debug.LogMessage(ex, "Got exception during volume up: {Exception}", null, ex);
}
}));
}));
AddAction("/volumeDown", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) =>
AddAction("/volumeDown", (id, content) => PressAndHoldHandler.HandlePressAndHold(DeviceKey, content, (b) =>
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Calling {localDevice} volume down with {value}", DeviceKey, b);
@@ -135,7 +133,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
}
};
PostStatusMessage(JToken.FromObject(message));
PostStatusMessage(JToken.FromObject(message));
};

View File

@@ -1,6 +1,4 @@
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using System;
namespace PepperDash.Essentials.AppServer.Messengers
{
@@ -10,11 +8,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
{
}
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
base.RegisterActions();

View File

@@ -3,11 +3,6 @@ using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PepperDash.Essentials.AppServer.Messengers
{
@@ -24,7 +19,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
{
base.RegisterActions();
AddAction("/fullStatus", (id, content) =>
AddAction("/fullStatus", (id, content) =>
{
PostStatusMessage(new CommunicationMonitorState
{
@@ -33,7 +28,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
IsOnline = _communicationMonitor.CommunicationMonitor.IsOnline,
Status = _communicationMonitor.CommunicationMonitor.Status
}
});
});
});
_communicationMonitor.CommunicationMonitor.StatusChange += (sender, args) =>

View File

@@ -7,12 +7,12 @@ namespace PepperDash.Essentials.AppServer.Messengers
{
public class IDspPresetsMessenger : MessengerBase
{
private IDspPresets _device;
private readonly IDspPresets device;
public IDspPresetsMessenger(string key, string messagePath, IDspPresets device)
: base(key, messagePath, device as Device)
: base(key, messagePath, device as IKeyName)
{
_device = device;
this.device = device;
}
protected override void RegisterActions()
@@ -23,7 +23,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
{
var message = new IHasDspPresetsStateMessage
{
Presets = _device.Presets
Presets = device.Presets
};
PostStatusMessage(message);
@@ -36,7 +36,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (!string.IsNullOrEmpty(presetKey))
{
_device.RecallPreset(presetKey);
device.RecallPreset(presetKey);
}
});
}

View File

@@ -1,6 +1,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.Core;
using System;
using System.Collections.Generic;
@@ -79,7 +80,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
PostStatusMessage(JToken.FromObject(message));
};
foreach(var partition in _roomCombiner.Partitions)
foreach (var partition in _roomCombiner.Partitions)
{
partition.PartitionPresentFeedback.OutputChange += (sender, args) =>
{
@@ -101,7 +102,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
foreach (var room in _roomCombiner.Rooms)
{
rooms.Add(new RoomCombinerRoom{ Key = room.Key, Name = room.Name });
rooms.Add(new RoomCombinerRoom { Key = room.Key, Name = room.Name });
}
var message = new IEssentialsRoomCombinerStateMessage
@@ -117,7 +118,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
}
catch (Exception e)
{
Debug.Console(0, this, "Error sending full status: {0}", e);
this.LogException(e, "Error sending full status");
}
}

View File

@@ -2,7 +2,6 @@
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Routing;
namespace PepperDash.Essentials.AppServer.Messengers
{
@@ -29,7 +28,8 @@ namespace PepperDash.Essentials.AppServer.Messengers
PostStatusMessage(message);
});
sourceDevice.CurrentSourceChange += (sender, e) => {
sourceDevice.CurrentSourceChange += (sender, e) =>
{
switch (e)
{
case ChangeType.DidChange:
@@ -42,11 +42,11 @@ namespace PepperDash.Essentials.AppServer.Messengers
break;
}
}
};
};
}
}
public class CurrentSourceStateMessage: DeviceStateMessageBase
public class CurrentSourceStateMessage : DeviceStateMessageBase
{
[JsonProperty("currentSourceKey", NullValueHandling = NullValueHandling.Ignore)]
public string CurrentSourceKey { get; set; }

View File

@@ -1,20 +1,15 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Essentials.Core;
using PepperDash.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.AppServer.Messengers
{
public class IHasPowerControlWithFeedbackMessenger: MessengerBase
public class IHasPowerControlWithFeedbackMessenger : MessengerBase
{
private readonly IHasPowerControlWithFeedback _powerControl;
public IHasPowerControlWithFeedbackMessenger(string key, string messagePath, IHasPowerControlWithFeedback powerControl)
public IHasPowerControlWithFeedbackMessenger(string key, string messagePath, IHasPowerControlWithFeedback powerControl)
: base(key, messagePath, powerControl as Device)
{
_powerControl = powerControl;
@@ -42,9 +37,9 @@ namespace PepperDash.Essentials.AppServer.Messengers
private void PowerIsOnFeedback_OutputChange(object sender, FeedbackEventArgs args)
{
PostStatusMessage(JToken.FromObject(new
{
powerState = args.BoolValue
})
{
powerState = args.BoolValue
})
);
}
}

View File

@@ -1,7 +1,6 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Devices.Common.Codec;
using System;
using System.Collections.Generic;
@@ -20,11 +19,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
ScheduleSource.CodecSchedule.MeetingEventChange += new EventHandler<MeetingEventArgs>(CodecSchedule_MeetingEventChange);
}
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
AddAction("/schedule/fullStatus", (id, content) => SendFullScheduleObject());
}
@@ -32,13 +27,13 @@ namespace PepperDash.Essentials.AppServer.Messengers
private void CodecSchedule_MeetingEventChange(object sender, MeetingEventArgs e)
{
PostStatusMessage(JToken.FromObject(new MeetingChangeMessage
{
MeetingChange = new MeetingChange
{
MeetingChange = new MeetingChange
{
ChangeType = e.ChangeType.ToString(),
Meeting = e.Meeting
}
})
ChangeType = e.ChangeType.ToString(),
Meeting = e.Meeting
}
})
);
}

View File

@@ -1,13 +1,9 @@
using Independentsoft.Exchange;
using Newtonsoft.Json;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PepperDash.Essentials.AppServer.Messengers
{
@@ -33,7 +29,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
PostStatusMessage(message);
});
foreach(var levelControl in levelControlsDevice.LevelControlPoints)
foreach (var levelControl in levelControlsDevice.LevelControlPoints)
{
// reassigning here just in case of lambda closure issues
var key = levelControl.Key;
@@ -78,7 +74,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
}
}
public class LevelControlStateMessage:DeviceStateMessageBase
public class LevelControlStateMessage : DeviceStateMessageBase
{
[JsonProperty("levelControls")]
public Dictionary<string, Volume> Levels { get; set; }

View File

@@ -3,10 +3,10 @@ using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Routing;
using System.Collections.Generic;
using System.Linq;
using Serilog.Events;
using System;
using System.Collections.Generic;
using System.Linq;
namespace PepperDash.Essentials.AppServer.Messengers
{
@@ -36,7 +36,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
Inputs = matrixDevice.InputSlots.ToDictionary(kvp => kvp.Key, kvp => new RoutingInput(kvp.Value)),
};
PostStatusMessage(message);
}
catch (Exception e)
@@ -52,7 +52,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
matrixDevice.Route(request.InputKey, request.OutputKey, request.RouteType);
});
foreach(var output in matrixDevice.OutputSlots)
foreach (var output in matrixDevice.OutputSlots)
{
var key = output.Key;
var outputSlot = output.Value;
@@ -66,7 +66,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
};
}
foreach(var input in matrixDevice.InputSlots)
foreach (var input in matrixDevice.InputSlots)
{
var key = input.Key;
var inputSlot = input.Value;
@@ -82,7 +82,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
}
}
public class MatrixStateMessage : DeviceStateMessageBase
public class MatrixStateMessage : DeviceStateMessageBase
{
[JsonProperty("outputs")]
public Dictionary<string, RoutingOutput> Outputs;
@@ -113,13 +113,13 @@ namespace PepperDash.Essentials.AppServer.Messengers
[JsonProperty("videoSyncDetected", NullValueHandling = NullValueHandling.Ignore)]
public bool? VideoSyncDetected => _input?.VideoSyncDetected;
public bool? VideoSyncDetected => _input?.VideoSyncDetected;
[JsonProperty("key", NullValueHandling = NullValueHandling.Ignore)]
public string Key => _input?.Key;
public RoutingInput(IRoutingInputSlot input)
{
{
_input = input;
}
}

View File

@@ -7,7 +7,7 @@ using System;
namespace PepperDash.Essentials.AppServer.Messengers
{
public class IProjectorScreenLiftControlMessenger: MessengerBase
public class IProjectorScreenLiftControlMessenger : MessengerBase
{
private readonly IProjectorScreenLiftControl device;

View File

@@ -1,7 +1,7 @@
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using System;
@@ -31,11 +31,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
SendRoutingFullMessageObject();
}
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
AddAction("/fullStatus", (id, content) => SendRoutingFullMessageObject());
@@ -48,7 +44,6 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (!string.IsNullOrEmpty(c.SourceListKey))
{
// Check for source list in content of message
Debug.Console(1, this, "sourceListKey found in message");
sourceListKey = c.SourceListKey;
}

View File

@@ -1,13 +1,8 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json.Converters;
namespace PepperDash.Essentials.AppServer.Messengers
{
@@ -45,7 +40,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
foreach (var input in itemDevice.Items)
{
var key = input.Key;
var localItem = input.Value;
var localItem = input.Value;
AddAction($"/{key}", (id, content) =>
{

View File

@@ -1,12 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using PepperDash.Essentials.Core.CrestronIO;
using PepperDash.Essentials.Core.Shades;
using Newtonsoft.Json;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core.CrestronIO;
using System;
namespace PepperDash.Essentials.AppServer.Messengers
{
@@ -21,11 +16,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
this.device = device;
}
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
base.RegisterActions();
@@ -45,7 +36,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
});
device.OutputIsOnFeedback.OutputChange += new EventHandler<Core.FeedbackEventArgs>((o, a) => SendFullStatus());
device.OutputIsOnFeedback.OutputChange += new EventHandler<Core.FeedbackEventArgs>((o, a) => SendFullStatus());
}
private void SendFullStatus()

View File

@@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Independentsoft.Json.Parser;
using Newtonsoft.Json;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core;
@@ -82,8 +75,8 @@ namespace PepperDash.Essentials.AppServer.Messengers
[JsonProperty("isValid", NullValueHandling = NullValueHandling.Ignore)]
public bool? IsValid { get; set; }
}
class SetTechPasswordContent
internal class SetTechPasswordContent
{
[JsonProperty("oldPassword")]
public string OldPassword { get; set; }

View File

@@ -1,6 +1,5 @@
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Core.Lighting;
using System;
using System.Collections.Generic;
@@ -30,11 +29,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
PostStatusMessage(state);
}
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
base.RegisterActions();
@@ -50,8 +45,6 @@ namespace PepperDash.Essentials.AppServer.Messengers
private void SendFullStatus()
{
Debug.Console(2, "LightingBaseMessenger GetFullStatus");
var state = new LightingBaseStateMessage
{
Scenes = Device.LightingScenes,

View File

@@ -1,5 +1,4 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
@@ -13,11 +12,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
/// <summary>
/// Provides a messaging bridge
/// </summary>
#if SERIES4
public abstract class MessengerBase : EssentialsDevice, IMobileControlMessenger
#else
public abstract class MessengerBase: EssentialsDevice
#endif
{
protected IKeyName _device;
@@ -30,11 +25,8 @@ namespace PepperDash.Essentials.AppServer.Messengers
/// <summary>
///
/// </summary>
#if SERIES4
public IMobileControl AppServerController { get; private set; }
#else
public MobileControlSystemController AppServerController { get; private set; }
#endif
public string MessagePath { get; private set; }
@@ -76,11 +68,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
/// Registers this messenger with appserver controller
/// </summary>
/// <param name="appServerController"></param>
#if SERIES4
public void RegisterWithAppServer(IMobileControl appServerController)
#else
public void RegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
AppServerController = appServerController ?? throw new ArgumentNullException("appServerController");
@@ -92,9 +80,10 @@ namespace PepperDash.Essentials.AppServer.Messengers
private void HandleMessage(string path, string id, JToken content)
{
// replace base path with empty string. Should leave something like /fullStatus
var route = path.Replace(MessagePath, string.Empty);
var route = path.Replace(MessagePath, string.Empty);
if(!_actions.TryGetValue(route, out var action)) {
if (!_actions.TryGetValue(route, out var action))
{
return;
}
@@ -133,11 +122,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
/// Implemented in extending classes. Wire up API calls and feedback here
/// </summary>
/// <param name="appServerController"></param>
#if SERIES4
protected virtual void RegisterActions()
#else
protected virtual void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
}
@@ -151,12 +136,12 @@ namespace PepperDash.Essentials.AppServer.Messengers
{
try
{
if(message == null)
if (message == null)
{
throw new ArgumentNullException("message");
}
if(_device == null)
if (_device == null)
{
throw new ArgumentNullException("device");
}
@@ -169,12 +154,12 @@ namespace PepperDash.Essentials.AppServer.Messengers
PostStatusMessage(JToken.FromObject(message), MessagePath, clientId);
}
catch (Exception ex) {
catch (Exception ex)
{
Debug.LogMessage(ex, "Exception posting status message", this);
}
}
#if SERIES4
protected void PostStatusMessage(string type, DeviceStateMessageBase deviceState, string clientId = null)
{
try
@@ -195,7 +180,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
Debug.LogMessage(ex, "Exception posting status message", this);
}
}
#endif
protected void PostStatusMessage(JToken content, string type = "", string clientId = null)
{
try
@@ -218,17 +203,17 @@ namespace PepperDash.Essentials.AppServer.Messengers
{
Type = $"/event{MessagePath}/{message.EventType}",
Content = JToken.FromObject(message),
});
});
}
protected void PostEventMessage(DeviceEventMessageBase message, string eventType)
{
{
message.Key = _device.Key;
message.Name = _device.Name;
message.EventType = eventType;
AppServerController?.SendMessageObject(new MobileControlMessage
{
Type = $"/event{MessagePath}/{eventType}",

View File

@@ -3,12 +3,11 @@ using Newtonsoft.Json.Linq;
using PepperDash.Core;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
namespace PepperDash.Essentials.AppServer.Messengers
{
public static class PressAndHoldHandler
{
{
private const long ButtonHeartbeatInterval = 1000;
private static readonly Dictionary<string, CTimer> _pushedActions = new Dictionary<string, CTimer>();
@@ -54,7 +53,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
private static void ResetTimer(string deviceKey, Action<bool> action)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "Attempting to reset timer for {deviceKey}", deviceKey);
if (!_pushedActions.TryGetValue(deviceKey, out CTimer cancelTimer))
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "Timer for {deviceKey} not found", deviceKey);
@@ -70,7 +69,8 @@ namespace PepperDash.Essentials.AppServer.Messengers
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "Attempting to stop timer for {deviceKey}", deviceKey);
if (!_pushedActions.TryGetValue(deviceKey, out CTimer cancelTimer)) {
if (!_pushedActions.TryGetValue(deviceKey, out CTimer cancelTimer))
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "Timer for {deviceKey} not found", deviceKey);
return;
}
@@ -110,7 +110,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
return;
}
timerHandler(deviceKey, action);
timerHandler(deviceKey, action);
}
}
}

View File

@@ -1,7 +1,7 @@
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Room.Config;
using System;
using System.Collections.Generic;
@@ -21,11 +21,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
#region Overrides of MessengerBase
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
AddAction("/saveScheduledEvents", (id, content) => SaveScheduledEvents(content.ToObject<List<ScheduledEventConfig>>()));
AddAction("/status", (id, content) =>
@@ -56,7 +52,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
}
catch (Exception ex)
{
Debug.Console(0, this, "Exception saving event: {0}\r\n{1}", ex.Message, ex.StackTrace);
this.LogException(ex,"Exception saving event");
}
}

View File

@@ -1,7 +1,6 @@
using Crestron.SimplSharpPro.DeviceSupport;
using Newtonsoft.Json.Linq;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Devices.Common.Codec;
using System;
using System.Collections.Generic;
@@ -44,12 +43,12 @@ namespace PepperDash.Essentials.AppServer.Messengers
private void SendFullStatus()
{
PostStatusMessage(JToken.FromObject(new
{
calls = GetCurrentCallList(),
currentCallString = _eisc.GetString(JoinMap.CurrentCallName.JoinNumber),
currentDialString = _eisc.GetString(JoinMap.CurrentDialString.JoinNumber),
isInCall = _eisc.GetString(JoinMap.HookState.JoinNumber) == "Connected"
})
{
calls = GetCurrentCallList(),
currentCallString = _eisc.GetString(JoinMap.CurrentCallName.JoinNumber),
currentDialString = _eisc.GetString(JoinMap.CurrentDialString.JoinNumber),
isInCall = _eisc.GetString(JoinMap.HookState.JoinNumber) == "Connected"
})
);
}
@@ -57,11 +56,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
///
/// </summary>
/// <param name="appServerController"></param>
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
//EISC.SetStringSigAction(SCurrentDialString, s => PostStatusMessage(new { currentDialString = s }));
@@ -143,9 +138,9 @@ namespace PepperDash.Essentials.AppServer.Messengers
private void SendCallsList()
{
PostStatusMessage(JToken.FromObject(new
{
calls = GetCurrentCallList(),
})
{
calls = GetCurrentCallList(),
})
);
}

View File

@@ -32,11 +32,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
}
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
AddAction("/fullStatus", (id, content) => SendCameraFullMessageObject());
@@ -84,11 +80,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
cameraAction(state.Value.Equals("true", StringComparison.InvariantCultureIgnoreCase));
}
#if SERIES4
public void CustomUnregsiterWithAppServer(IMobileControl appServerController)
#else
public void CustomUnregsiterWithAppServer(MobileControlSystemController appServerController)
#endif
public void CustomUnregisterWithAppServer(IMobileControl appServerController)
{
appServerController.RemoveAction(MessagePath + "/fullStatus");
@@ -133,11 +125,11 @@ namespace PepperDash.Essentials.AppServer.Messengers
}
PostStatusMessage(JToken.FromObject(new
{
cameraMode = GetCameraMode(),
hasPresets = _eisc.GetBool(_joinMap.SupportsPresets.JoinNumber),
presets = presetList
})
{
cameraMode = GetCameraMode(),
hasPresets = _eisc.GetBool(_joinMap.SupportsPresets.JoinNumber),
presets = presetList
})
);
}

View File

@@ -2,7 +2,6 @@
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using System.Collections.Generic;
namespace PepperDash.Essentials.AppServer.Messengers
@@ -26,11 +25,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
#region Overrides of MessengerBase
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController controller)
#endif
{
Debug.Console(2, "********** Direct Route Messenger CustomRegisterWithAppServer **********");

View File

@@ -30,11 +30,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
_eisc.SetStringSigAction(_joinStart + StringJoin.CurrentSource, SendRoutingFullMessageObject);
}
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
AddAction("/fullStatus",
(id, content) => SendRoutingFullMessageObject(_eisc.GetString(_joinStart + StringJoin.CurrentSource)));
@@ -47,11 +43,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
});
}
#if SERIES4
public void CustomUnregsiterWithAppServer(IMobileControl appServerController)
#else
public void CustomUnregsiterWithAppServer(MobileControlSystemController appServerController)
#endif
public void CustomUnregisterWithAppServer(IMobileControl appServerController)
{
appServerController.RemoveAction(MessagePath + "/fullStatus");
appServerController.RemoveAction(MessagePath + "/source");
@@ -68,9 +60,9 @@ namespace PepperDash.Essentials.AppServer.Messengers
sourceKey = "none";
PostStatusMessage(JToken.FromObject(new
{
selectedSourceKey = sourceKey
})
{
selectedSourceKey = sourceKey
})
);
}
}

View File

@@ -2,7 +2,6 @@
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Devices.Common.Cameras;
using PepperDash.Essentials.Devices.Common.Codec;
using System;
@@ -43,12 +42,8 @@ namespace PepperDash.Essentials.AppServer.Messengers
///
/// </summary>
/// <param name="appServerController"></param>
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
{
_eisc.SetStringSigAction(JoinMap.HookState.JoinNumber, s =>
{
_currentCallItem.Status = (eCodecCallStatus)Enum.Parse(typeof(eCodecCallStatus), s, true);

View File

@@ -1,6 +1,5 @@
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Core.Shades;
using System;
@@ -16,11 +15,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
device = shades;
}
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
base.RegisterActions();

View File

@@ -2,7 +2,6 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Core.Monitoring;
using System;
using System.Threading.Tasks;
@@ -60,34 +59,28 @@ namespace PepperDash.Essentials.AppServer.Messengers
foreach (var p in systemMonitor.ProgramStatusFeedbackCollection)
{
PostStatusMessage(JToken.FromObject(p.Value.ProgramInfo)
);
PostStatusMessage(JToken.FromObject(p.Value.ProgramInfo));
}
}
private void SendSystemMonitorStatusMessage()
{
Debug.Console(1, "Posting System Monitor Status Message.");
// This takes a while, launch a new thread
Task.Run(() => PostStatusMessage(JToken.FromObject(new SystemMonitorStateMessage
{
{
TimeZone = systemMonitor.TimeZoneFeedback.IntValue,
TimeZoneName = systemMonitor.TimeZoneTextFeedback.StringValue,
IoControllerVersion = systemMonitor.IoControllerVersionFeedback.StringValue,
SnmpVersion = systemMonitor.SnmpVersionFeedback.StringValue,
BacnetVersion = systemMonitor.BaCnetAppVersionFeedback.StringValue,
ControllerVersion = systemMonitor.ControllerVersionFeedback.StringValue
})
TimeZone = systemMonitor.TimeZoneFeedback.IntValue,
TimeZoneName = systemMonitor.TimeZoneTextFeedback.StringValue,
IoControllerVersion = systemMonitor.IoControllerVersionFeedback.StringValue,
SnmpVersion = systemMonitor.SnmpVersionFeedback.StringValue,
BacnetVersion = systemMonitor.BaCnetAppVersionFeedback.StringValue,
ControllerVersion = systemMonitor.ControllerVersionFeedback.StringValue
})
));
}
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
AddAction("/fullStatus", (id, content) => SendFullStatusMessage());
}

View File

@@ -1,8 +1,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using TwoWayDisplayBase = PepperDash.Essentials.Devices.Common.Displays.TwoWayDisplayBase;
using PepperDash.Essentials.Devices.Common.Displays;
namespace PepperDash.Essentials.AppServer.Messengers
{
@@ -33,11 +32,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
PostStatusMessage(messageObj);
}
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
base.RegisterActions();
@@ -52,10 +47,10 @@ namespace PepperDash.Essentials.AppServer.Messengers
private void CurrentInputFeedbackOnOutputChange(object sender, FeedbackEventArgs feedbackEventArgs)
{
PostStatusMessage(JToken.FromObject(new
{
currentInput = feedbackEventArgs.StringValue
})
);
{
currentInput = feedbackEventArgs.StringValue
})
);
}
@@ -71,21 +66,21 @@ namespace PepperDash.Essentials.AppServer.Messengers
private void IsWarmingFeedbackOnOutputChange(object sender, FeedbackEventArgs feedbackEventArgs)
{
PostStatusMessage(JToken.FromObject(new
{
isWarming = feedbackEventArgs.BoolValue
})
);
{
isWarming = feedbackEventArgs.BoolValue
})
);
}
private void IsCoolingFeedbackOnOutputChange(object sender, FeedbackEventArgs feedbackEventArgs)
{
PostStatusMessage(JToken.FromObject(new
{
isCooling = feedbackEventArgs.BoolValue
})
{
isCooling = feedbackEventArgs.BoolValue
})
);
}
#endregion

View File

@@ -2,6 +2,7 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Devices.Common.Cameras;
@@ -111,7 +112,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (Codec is IHasDirectory dirCodec)
{
Debug.Console(2, this, "Sending Directory. Directory Item Count: {0}", directory.CurrentDirectoryResults.Count);
this.LogVerbose("Sending Directory. Directory Item Count: {directoryItemCount}", directory.CurrentDirectoryResults.Count);
//state.CurrentDirectory = PrefixDirectoryFolderItems(directory);
state.CurrentDirectory = directory;
@@ -152,11 +153,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
/// Called from base's RegisterWithAppServer method
/// </summary>
/// <param name="appServerController"></param>
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
try
{
@@ -242,7 +239,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
}
if (Codec is IHasCodecCameras cameraCodec)
{
Debug.Console(2, this, "Adding IHasCodecCameras Actions");
this.LogVerbose("Adding IHasCodecCameras Actions");
cameraCodec.CameraSelected += CameraCodec_CameraSelected;
@@ -258,7 +255,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (Codec is IHasCodecRoomPresets presetsCodec)
{
Debug.Console(2, this, "Adding IHasCodecRoomPresets Actions");
this.LogVerbose("Adding IHasCodecRoomPresets Actions");
presetsCodec.CodecRoomPresetsListHasChanged += PresetsCodec_CameraPresetsListHasChanged;
@@ -279,7 +276,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (Codec is IHasCameraAutoMode speakerTrackCodec)
{
Debug.Console(2, this, "Adding IHasCameraAutoMode Actions");
this.LogVerbose("Adding IHasCameraAutoMode Actions");
speakerTrackCodec.CameraAutoModeIsOnFeedback.OutputChange += CameraAutoModeIsOnFeedback_OutputChange;
@@ -290,7 +287,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (Codec is IHasCameraOff cameraOffCodec)
{
Debug.Console(2, this, "Adding IHasCameraOff Actions");
this.LogVerbose("Adding IHasCameraOff Actions");
cameraOffCodec.CameraIsOffFeedback.OutputChange += (CameraIsOffFeedback_OutputChange);
@@ -302,7 +299,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (Codec is IHasCodecSelfView selfViewCodec)
{
Debug.Console(2, this, "Adding IHasCodecSelfView Actions");
this.LogVerbose("Adding IHasCodecSelfView Actions");
AddAction("/cameraSelfView", (id, content) => selfViewCodec.SelfViewModeToggle());
@@ -312,7 +309,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (Codec is IHasCodecLayouts layoutsCodec)
{
Debug.Console(2, this, "Adding IHasCodecLayouts Actions");
this.LogVerbose("Adding IHasCodecLayouts Actions");
AddAction("/cameraRemoteView", (id, content) => layoutsCodec.LocalLayoutToggle());
@@ -321,7 +318,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (Codec is IPasswordPrompt pwCodec)
{
Debug.Console(2, this, "Adding IPasswordPrompt Actions");
this.LogVerbose("Adding IPasswordPrompt Actions");
AddAction("/password", (id, content) =>
{
@@ -338,7 +335,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
(sender, args) => PostReceivingContent(args.BoolValue);
}
Debug.Console(2, this, "Adding Privacy & Standby Actions");
this.LogVerbose("Adding Privacy & Standby Actions");
AddAction("/privacyModeOn", (id, content) => Codec.PrivacyModeOn());
AddAction("/privacyModeOff", (id, content) => Codec.PrivacyModeOff());
@@ -350,7 +347,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
}
catch (Exception e)
{
Debug.Console(2, this, "Error: {0}", e);
this.LogException(e, "Exception adding paths");
}
}

View File

@@ -4,12 +4,7 @@ using PepperDash.Essentials.Core.DeviceTypeInterfaces;
namespace PepperDash.Essentials.AppServer.Messengers
{
#if SERIES4
public class MobileControlMessage : IMobileControlMessage
#else
public class MobileControlMessage
#endif
{
[JsonProperty("type")]
public string Type { get; set; }

View File

@@ -1,21 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectType>ProgramLibrary</ProjectType>
</PropertyGroup>
<PropertyGroup>
<RootNamespace>PepperDash.Essentials.AppServer</RootNamespace>
<TargetFramework>net472</TargetFramework>
<AssemblyTitle>mobile-control-messengers</AssemblyTitle>
<AssemblyName>mobile-control-messengers</AssemblyName>
<Product>mobile-control-messengers</Product>
<Copyright>Copyright © 2024</Copyright>
<OutputPath>bin\$(Configuration)\</OutputPath>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<InformationalVersion>$(Version)</InformationalVersion>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<Authors>PepperDash Technology</Authors>
<PackageId>PepperDash.Essentials.Plugin.MobileControl.Messengers</PackageId>
<PackageProjectUrl>https://github.com/PepperDash/Essentials</PackageProjectUrl>
<PackageId>PepperDash.Essentials.MobileControl.Messengers</PackageId>
<PackageTags>crestron 4series</PackageTags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -26,16 +23,24 @@
<DebugType>pdbonly</DebugType>
<DefineConstants>$(DefineConstants);SERIES4</DefineConstants>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Messengers\SIMPLAtcMessenger.cs" />
<Compile Remove="Messengers\SIMPLCameraMessenger.cs" />
<Compile Remove="Messengers\SIMPLDirectRouteMessenger.cs" />
<Compile Remove="Messengers\SimplMessengerPropertiesConfig.cs" />
<Compile Remove="Messengers\SIMPLRouteMessenger.cs" />
<Compile Remove="Messengers\SIMPLVtcMessenger.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.21.90" />
<PackageReference Include="PepperDashCore" Version="2.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PepperDash.Essentials.Core\PepperDash.Essentials.Core.csproj" >
<ProjectReference Include="..\PepperDash.Essentials.Core\PepperDash.Essentials.Core.csproj">
<Private>false</Private>
<ExcludeAssets>runtime</ExcludeAssets>
</ProjectReference>
<ProjectReference Include="..\PepperDash.Essentials.Devices.Common\PepperDash.Essentials.Devices.Common.csproj" >
<ProjectReference Include="..\PepperDash.Essentials.Devices.Common\PepperDash.Essentials.Devices.Common.csproj">
<Private>false</Private>
<ExcludeAssets>runtime</ExcludeAssets>
</ProjectReference>

View File

@@ -1,6 +1,6 @@
using System;
namespace PepperDash.Essentials.Room.MobileControl
namespace PepperDash.Essentials
{
/// <summary>
/// Represents a room whose configuration is derived from runtime data,
@@ -10,7 +10,7 @@ namespace PepperDash.Essentials.Room.MobileControl
public interface IDelayedConfiguration
{
event EventHandler<EventArgs> ConfigurationIsReady;
}
}

View File

@@ -1,11 +1,6 @@
using Newtonsoft.Json.Linq;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Core.Web.RequestHandlers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PepperDash.Essentials
{
@@ -13,9 +8,10 @@ namespace PepperDash.Essentials
{
public IMobileControlMessenger Messenger { get; private set; }
public Action<string, string, JToken> Action {get; private set; }
public Action<string, string, JToken> Action { get; private set; }
public MobileControlAction(IMobileControlMessenger messenger, Action<string,string, JToken> handler) {
public MobileControlAction(IMobileControlMessenger messenger, Action<string, string, JToken> handler)
{
Messenger = messenger;
Action = handler;
}

View File

@@ -1,6 +1,5 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
namespace PepperDash.Essentials
@@ -16,30 +15,14 @@ namespace PepperDash.Essentials
[JsonProperty("clientAppUrl")]
public string ClientAppUrl { get; set; }
#if SERIES4
[JsonProperty("directServer")]
public MobileControlDirectServerPropertiesConfig DirectServer { get; set; }
[JsonProperty("applicationConfig")]
public MobileControlApplicationConfig ApplicationConfig { get; set; }
public MobileControlApplicationConfig ApplicationConfig { get; set; } = null;
[JsonProperty("enableApiServer")]
public bool EnableApiServer { get; set; }
#endif
[JsonProperty("roomBridges")]
[Obsolete("No longer necessary")]
public List<MobileControlRoomBridgePropertiesConfig> RoomBridges { get; set; }
public MobileControlConfig()
{
RoomBridges = new List<MobileControlRoomBridgePropertiesConfig>();
#if SERIES4
EnableApiServer = true; // default to true
ApplicationConfig = null;
#endif
}
public bool EnableApiServer { get; set; } = true;
}
public class MobileControlDirectServerPropertiesConfig
@@ -73,7 +56,7 @@ namespace PepperDash.Essentials
[JsonProperty("port")]
public int Port { get; set; }
}

View File

@@ -1,7 +1,8 @@
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Room.MobileControl;
using Serilog.Events;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -12,7 +13,7 @@ namespace PepperDash.Essentials
public class MobileControlDeviceFactory : EssentialsDeviceFactory<MobileControlSystemController>
{
public MobileControlDeviceFactory()
{
{
TypeNames = new List<string> { "appserver", "mobilecontrol", "webserver" };
}
@@ -30,58 +31,4 @@ namespace PepperDash.Essentials
}
}
}
public class MobileControlSimplFactory : EssentialsDeviceFactory<MobileControlSIMPLRoomBridge>
{
public MobileControlSimplFactory()
{
TypeNames = new List<string> { "mobilecontrolbridge-ddvc01", "mobilecontrolbridge-simpl" };
}
public override EssentialsDevice BuildDevice(DeviceConfig dc)
{
var comm = CommFactory.GetControlPropertiesConfig(dc);
var bridge = new MobileControlSIMPLRoomBridge(dc.Key, dc.Name, comm.IpIdInt);
bridge.AddPreActivationAction(() =>
{
var parent = GetMobileControlDevice();
if (parent == null)
{
Debug.Console(0, bridge, "ERROR: Cannot connect bridge. System controller not present");
return;
}
Debug.Console(0, bridge, "Linking to parent controller");
/*bridge.AddParent(parent);
parent.AddBridge(bridge);*/
parent.AddDeviceMessenger(bridge);
});
return bridge;
}
private static MobileControlSystemController GetMobileControlDevice()
{
var mobileControlList = DeviceManager.AllDevices.OfType<MobileControlSystemController>().ToList();
if (mobileControlList.Count > 1)
{
Debug.Console(0, Debug.ErrorLogLevel.Warning,
"Multiple instances of Mobile Control Server found.");
return null;
}
if (mobileControlList.Count > 0)
{
return mobileControlList[0];
}
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Mobile Control not enabled for this system");
return null;
}
}
}

View File

@@ -1,24 +1,22 @@
using PepperDash.Core;
using PepperDash.Essentials.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace PepperDash.Essentials.MobileControl
namespace PepperDash.Essentials
{
public class MobileControlFactory
{
public MobileControlFactory() {
public MobileControlFactory()
{
var assembly = Assembly.GetExecutingAssembly();
PluginLoader.SetEssentialsAssembly(assembly.GetName().Name, assembly);
var types = assembly.GetTypes().Where(t => typeof(IDeviceFactory).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract);
if(types == null)
if (types == null)
{
return;
}

View File

@@ -1,25 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<ProjectType>ProgramLibrary</ProjectType>
</PropertyGroup>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<RootNamespace>PepperDash.Essentials</RootNamespace>
<TargetFramework>net472</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
<Deterministic>false</Deterministic>
<AssemblyTitle>epi-essentials-mobile-control</AssemblyTitle>
<AssemblyName>epi-essentials-mobile-control</AssemblyName>
<Company>PepperDash Technologies</Company>
<Product>epi-essentials-mobile-control</Product>
<Description>This software is a plugin designed to work as a part of PepperDash Essentials for Crestron control processors. This plugin allows for connection to a PepperDash Mobile Control server.</Description>
<Copyright>Copyright 2020</Copyright>
<Version>4.0.0-local</Version>
<GenerateAssemblyInfo>true</GenerateAssemblyInfo>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<InformationalVersion>$(Version)</InformationalVersion>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<OutputPath>bin\$(Configuration)\</OutputPath>
<Authors>PepperDash Technologies</Authors>
<PackageId>PepperDash.Essentials.4Series.Plugin.MobileControl</PackageId>
<PackageProjectUrl>https://github.com/PepperDash/Essentials</PackageProjectUrl>
<PackageId>PepperDash.Essentials.MobileControl</PackageId>
<PackageTags>crestron 4series</PackageTags>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
@@ -33,6 +30,11 @@
<Compile Remove="bin\**" />
<EmbeddedResource Remove="bin\**" />
<None Remove="bin\**" />
</ItemGroup>
<ItemGroup>
<Compile Remove="MobileControlSimplDeviceBridge.cs" />
<Compile Remove="RoomBridges\MobileControlSIMPLRoomBridge.cs" />
<Compile Remove="RoomBridges\SourceDeviceMapDictionary.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.21.90" />
@@ -51,15 +53,15 @@
<None Remove="C:\Users\awelker\source\Essentials\Essentials\src\PepperDash.Essentials.MobileControl\bin\Debug\net472\PepperDash.Essentials.MobileControl.4.0.0-local.net472.cplz" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PepperDash.Essentials.Core\PepperDash.Essentials.Core.csproj" >
<ProjectReference Include="..\PepperDash.Essentials.Core\PepperDash.Essentials.Core.csproj">
<Private>false</Private>
<ExcludeAssets>runtime</ExcludeAssets>
</ProjectReference>
<ProjectReference Include="..\PepperDash.Essentials.Devices.Common\PepperDash.Essentials.Devices.Common.csproj" >
<ProjectReference Include="..\PepperDash.Essentials.Devices.Common\PepperDash.Essentials.Devices.Common.csproj">
<Private>false</Private>
<ExcludeAssets>runtime</ExcludeAssets>
</ProjectReference>
<ProjectReference Include="..\PepperDash.Essentials.MobileControl.Messengers\PepperDash.Essentials.MobileControl.Messengers.csproj" >
<ProjectReference Include="..\PepperDash.Essentials.MobileControl.Messengers\PepperDash.Essentials.MobileControl.Messengers.csproj">
<Private>false</Private>
<ExcludeAssets>runtime</ExcludeAssets>
</ProjectReference>

View File

@@ -1,10 +1,11 @@
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using System;
namespace PepperDash.Essentials
namespace PepperDash.Essentials.RoomBridges
{
/// <summary>
///
@@ -102,12 +103,12 @@ namespace PepperDash.Essentials
/// </summary>
protected virtual void UserCodeChange()
{
Debug.Console(1, this, "Server user code changed: {0}", UserCode);
this.LogDebug("Server user code changed: {userCode}", UserCode);
var qrUrl = string.Format($"{Parent.Host}/api/rooms/{Parent.SystemUuid}/{RoomKey}/qr?x={new Random().Next()}");
QrCodeUrl = qrUrl;
Debug.Console(1, this, "Server user code changed: {0} - {1}", UserCode, qrUrl);
this.LogDebug("Server user code changed: {userCode} - {qrCodeUrl}", UserCode, qrUrl);
OnUserCodeChanged();
}

View File

@@ -1,38 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.AppServer;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Room.MobileControl;
using PepperDash.Essentials.Room.Config;
using PepperDash.Essentials.Devices.Common.VideoCodec;
using PepperDash.Essentials.Devices.Common.AudioCodec;
using PepperDash.Essentials.Devices.Common.Cameras;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using PepperDash.Essentials.Devices.Common.Room;
using IShades = PepperDash.Essentials.Core.Shades.IShades;
using ShadeBase = PepperDash.Essentials.Devices.Common.Shades.ShadeBase;
using PepperDash.Essentials.Devices.Common.TouchPanel;
using Crestron.SimplSharp;
using Volume = PepperDash.Essentials.Room.MobileControl.Volume;
using PepperDash.Essentials.Core.CrestronIO;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Core.Lighting;
using PepperDash.Essentials.Core.Shades;
using PepperDash.Core.Logging;
using PepperDash.Essentials.Devices.Common.AudioCodec;
using PepperDash.Essentials.Devices.Common.Cameras;
using PepperDash.Essentials.Devices.Common.Room;
using PepperDash.Essentials.Devices.Common.VideoCodec;
using PepperDash.Essentials.Room.Config;
using PepperDash.Essentials.WebSocketServer;
using System;
using System.Collections.Generic;
using System.Linq;
using IShades = PepperDash.Essentials.Core.Shades.IShades;
using ShadeBase = PepperDash.Essentials.Devices.Common.Shades.ShadeBase;
#if SERIES4
using PepperDash.Essentials.AppServer;
#endif
namespace PepperDash.Essentials
namespace PepperDash.Essentials.RoomBridges
{
public class MobileControlEssentialsRoomBridge : MobileControlBridgeBase
{
@@ -66,11 +57,8 @@ namespace PepperDash.Essentials
AddPreActivationAction(GetRoom);
}
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
// we add actions to the messaging system with a path, and a related action. Custom action
// content objects can be handled in the controller's LineReceived method - and perhaps other
@@ -351,7 +339,7 @@ namespace PepperDash.Essentials
string shareText;
bool isSharing;
if (Room is IHasCurrentSourceInfoChange srcInfoRoom && (Room is IHasVideoCodec vcRoom && (vcRoom.VideoCodec.SharingContentIsOnFeedback.BoolValue && srcInfoRoom.CurrentSourceInfo != null)))
if (Room is IHasCurrentSourceInfoChange srcInfoRoom && Room is IHasVideoCodec vcRoom && vcRoom.VideoCodec.SharingContentIsOnFeedback.BoolValue && srcInfoRoom.CurrentSourceInfo != null)
{
shareText = srcInfoRoom.CurrentSourceInfo.PreferredName;
isSharing = true;
@@ -544,7 +532,8 @@ namespace PepperDash.Essentials
}
return state;
} catch (Exception ex)
}
catch (Exception ex)
{
Debug.LogMessage(ex, "Error getting full status", this);
return null;
@@ -572,7 +561,7 @@ namespace PepperDash.Essentials
{
var zrcTp = DeviceManager.AllDevices.OfType<IMobileControlTouchpanelController>().SingleOrDefault((tp) => tp.ZoomRoomController);
configuration.ZoomRoomControllerKey = zrcTp != null ? zrcTp.Key : null;
configuration.ZoomRoomControllerKey = zrcTp?.Key;
}
catch
{
@@ -590,7 +579,7 @@ namespace PepperDash.Essentials
// find the room combiner for this room by checking if the room is in the list of rooms for the room combiner
var roomCombiner = DeviceManager.AllDevices.OfType<IEssentialsRoomCombiner>().FirstOrDefault();
configuration.RoomCombinerKey = roomCombiner != null ? roomCombiner.Key : null;
configuration.RoomCombinerKey = roomCombiner?.Key;
if (room is IEssentialsRoomPropertiesConfig propertiesConfig)
@@ -632,7 +621,8 @@ namespace PepperDash.Essentials
configuration.VideoCodecKey = vcRoom.VideoCodec.Key;
configuration.VideoCodecIsZoomRoom = type.Name.Equals("ZoomRoom", StringComparison.InvariantCultureIgnoreCase);
}
};
}
;
if (room is IHasAudioCodec acRoom)
{
@@ -667,7 +657,7 @@ namespace PepperDash.Essentials
eEnvironmentalDeviceTypes type = eEnvironmentalDeviceTypes.None;
if (dev is ILightingScenes || dev is Devices.Common.Lighting.LightingBase)
if (dev is ILightingScenes)
{
type = eEnvironmentalDeviceTypes.Lighting;
}
@@ -883,7 +873,7 @@ namespace PepperDash.Essentials
public Dictionary<string, SourceListItem> SourceList { get; set; }
[JsonProperty("destinationList", NullValueHandling = NullValueHandling.Ignore)]
public Dictionary<string, DestinationListItem> DestinationList { get; set;}
public Dictionary<string, DestinationListItem> DestinationList { get; set; }
[JsonProperty("audioControlPointList", NullValueHandling = NullValueHandling.Ignore)]
public AudioControlPointListItem AudioControlPointList { get; set; }

View File

@@ -5,6 +5,7 @@ using Crestron.SimplSharpPro.EthernetCommunication;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.AppServer;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core;
@@ -175,11 +176,8 @@ namespace PepperDash.Essentials.Room.MobileControl
ConfigIsLoaded = true;
}
#if SERIES4
protected override void RegisterActions()
#else
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
#endif
{
SetupFunctions();
SetupFeedbacks();
@@ -595,7 +593,7 @@ namespace PepperDash.Essentials.Room.MobileControl
if (!Eisc.BooleanOutput[JoinMap.UseSourceEnabled.JoinNumber].BoolValue && string.IsNullOrEmpty(name))
{
Debug.Console(1, "Source at join {0} does not have a name", JoinMap.SourceNameJoinStart.JoinNumber + i);
this.LogDebug("Source at join {join} does not have a name", JoinMap.SourceNameJoinStart.JoinNumber + i);
break;
}

View File

@@ -66,7 +66,8 @@ namespace PepperDash.Essentials.Services
}
return authResponse;
} catch(Exception ex)
}
catch (Exception ex)
{
Debug.LogMessage(ex, "Error authorizing with Mobile Control");
return new AuthorizationResponse { Authorized = false, Reason = ex.Message };

View File

@@ -1,15 +1,9 @@
using PepperDash.Core;
using PepperDash.Essentials.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PepperDash.Essentials.Touchpanel
{
public interface ITheme:IKeyed
{
public interface ITheme : IKeyed
{
string Theme { get; }
void UpdateTheme(string theme);

View File

@@ -1,8 +1,8 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
namespace PepperDash.Essentials.Touchpanel
{
@@ -19,7 +19,7 @@ namespace PepperDash.Essentials.Touchpanel
{
if (_appControl == null)
{
Debug.Console(0, this, $"{_device.Key} does not implement ITswAppControl");
this.LogInformation("{deviceKey} does not implement ITswAppControl", _device.Key);
return;
}

View File

@@ -1,8 +1,8 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
namespace PepperDash.Essentials.Touchpanel
@@ -20,7 +20,7 @@ namespace PepperDash.Essentials.Touchpanel
{
if (_zoomControl == null)
{
Debug.Console(0, this, $"{_device.Key} does not implement ITswZoomControl");
this.LogInformation("{deviceKey} does not implement ITswZoomControl", _device.Key);
return;
}
@@ -40,7 +40,7 @@ namespace PepperDash.Essentials.Touchpanel
_zoomControl.ZoomInCallFeedback.OutputChange += (s, a) =>
{
{
PostStatusMessage(JToken.FromObject(
new
{

View File

@@ -10,13 +10,12 @@ using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.DeviceInfo;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Core.UI;
using PepperDash.Essentials.Touchpanel;
using System;
using System.Collections.Generic;
using System.Linq;
using Feedback = PepperDash.Essentials.Core.Feedback;
namespace PepperDash.Essentials.Devices.Common.TouchPanel
namespace PepperDash.Essentials.Touchpanel
{
//public interface IMobileControlTouchpanelController
//{
@@ -75,7 +74,7 @@ namespace PepperDash.Essentials.Devices.Common.TouchPanel
AddPostActivationAction(SubscribeForMobileControlUpdates);
ThemeFeedback = new StringFeedback($"{Key}-theme",() => Theme);
ThemeFeedback = new StringFeedback($"{Key}-theme", () => Theme);
AppUrlFeedback = new StringFeedback($"{Key}-appUrl", () => _appUrl);
QrCodeUrlFeedback = new StringFeedback($"{Key}-qrCodeUrl", () => _bridge?.QrCodeUrl);
McServerUrlFeedback = new StringFeedback($"{Key}-mcServerUrl", () => _bridge?.McServerUrl);
@@ -357,10 +356,11 @@ namespace PepperDash.Essentials.Devices.Common.TouchPanel
_bridge = bridge;
_bridge.UserCodeChanged += UpdateFeedbacks;
_bridge.AppUrlChanged += (s, a) => {
this.LogInformation("AppURL changed");
_bridge.AppUrlChanged += (s, a) =>
{
this.LogInformation("AppURL changed");
SetAppUrl(_bridge.AppUrl);
UpdateFeedbacks(s, a);
UpdateFeedbacks(s, a);
};
SetAppUrl(_bridge.AppUrl);

View File

@@ -1,7 +1,7 @@
using Newtonsoft.Json;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Devices.Common.TouchPanel
namespace PepperDash.Essentials.Touchpanel
{
public class MobileControlTouchpanelProperties : CrestronTouchpanelPropertiesConfig
{

View File

@@ -27,14 +27,14 @@ namespace PepperDash.Essentials.Touchpanel
var theme = content.ToObject<MobileControlSimpleContent<string>>();
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "Setting theme to {theme}", this, theme.Value);
_tpDevice.UpdateTheme(theme.Value);
_tpDevice.UpdateTheme(theme.Value);
PostStatusMessage(JToken.FromObject(new {theme = theme.Value}));
PostStatusMessage(JToken.FromObject(new { theme = theme.Value }));
});
}
}
public class ThemeUpdateMessage:DeviceStateMessageBase
public class ThemeUpdateMessage : DeviceStateMessageBase
{
[JsonProperty("theme")]
public string Theme { get; set; }

View File

@@ -1,8 +1,11 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core.Queues;
using PepperDash.Essentials.WebSocketServer;
using Serilog.Events;
using System;
using System.Threading;
using WebSocketSharp;
@@ -32,46 +35,38 @@ namespace PepperDash.Essentials
{
try
{
//Debug.Console(2, "Dispatching message type: {0}", msgToSend.GetType());
//Debug.Console(2, "Message: {0}", msgToSend.ToString());
//var messageToSend = JObject.FromObject(msgToSend);
if (_ws != null && _ws.IsAlive)
if (_ws == null)
{
var message = JsonConvert.SerializeObject(msgToSend, Formatting.None,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Converters = { new IsoDateTimeConverter() } });
Debug.Console(2, "Message TX: {0}", message);
_ws.Send(message);
Debug.LogMessage(LogEventLevel.Warning, "Cannot send message. Websocket client is null");
return;
}
else if (_ws == null)
if (!_ws.IsAlive)
{
Debug.Console(1, "Cannot send. No client.");
Debug.LogMessage(LogEventLevel.Warning, "Cannot send message. Websocket client is not connected");
return;
}
var message = JsonConvert.SerializeObject(msgToSend, Formatting.None,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Converters = { new IsoDateTimeConverter() } });
Debug.LogMessage(LogEventLevel.Verbose, "Message TX: {0}", null, message);
_ws.Send(message);
}
catch (Exception ex)
{
Debug.Console(0, Debug.ErrorLogLevel.Error, "Caught an exception in the Transmit Processor {0}\r{1}\r{2}", ex.Message, ex.InnerException, ex.StackTrace);
Debug.Console(2, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.StackTrace);
if (ex.InnerException != null)
{
Debug.Console(0, Debug.ErrorLogLevel.Error, "Inner Exception: {0}", ex.InnerException.Message);
Debug.Console(2, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.InnerException.StackTrace);
}
Debug.LogMessage(ex, "Caught an exception in the Transmit Processor");
}
}
#endregion
}
#if SERIES4
public class MessageToClients : IQueueMessage
{
private readonly MobileControlWebsocketServer _server;
@@ -95,35 +90,33 @@ namespace PepperDash.Essentials
{
try
{
//Debug.Console(2, "Message: {0}", msgToSend.ToString());
if (_server != null)
if (_server == null)
{
Debug.Console(2, _server, Debug.ErrorLogLevel.Notice, "Dispatching message type: {0}", msgToSend.GetType());
var message = JsonConvert.SerializeObject(msgToSend, Formatting.None,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Converters = { new IsoDateTimeConverter() } });
var clientSpecificMessage = msgToSend as MobileControlMessage;
if (clientSpecificMessage.ClientId != null)
{
var clientId = clientSpecificMessage.ClientId;
Debug.Console(2, _server, "Message TX To Client ID: {0} Message: {1}", clientId, message);
_server.SendMessageToClient(clientId, message);
}
else
{
_server.SendMessageToAllClients(message);
Debug.Console(2, "Message TX To Clients: {0}", message);
}
Debug.LogMessage(LogEventLevel.Warning, "Cannot send message. Server is null");
return;
}
else if (_server == null)
var message = JsonConvert.SerializeObject(msgToSend, Formatting.None,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Converters = { new IsoDateTimeConverter() } });
var clientSpecificMessage = msgToSend as MobileControlMessage;
if (clientSpecificMessage.ClientId != null)
{
Debug.Console(1, "Cannot send. No server.");
var clientId = clientSpecificMessage.ClientId;
_server.LogVerbose("Message TX To client {clientId} Message: {message}", clientId, message);
_server.SendMessageToClient(clientId, message);
return;
}
_server.SendMessageToAllClients(message);
_server.LogVerbose("Message TX To all clients: {message}", null, message);
}
catch (ThreadAbortException)
{
@@ -131,14 +124,7 @@ namespace PepperDash.Essentials
}
catch (Exception ex)
{
Debug.Console(0, Debug.ErrorLogLevel.Error, "Caught an exception in the Transmit Processor {0}", ex.Message);
Debug.Console(2, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.StackTrace);
if (ex.InnerException != null)
{
Debug.Console(0, Debug.ErrorLogLevel.Error, "----\r\n{0}", ex.InnerException.Message);
Debug.Console(2, Debug.ErrorLogLevel.Error, "Stack Trace: {0}", ex.InnerException.StackTrace);
}
Debug.LogMessage(ex, "Caught an exception in the Transmit Processor");
}
@@ -146,5 +132,4 @@ namespace PepperDash.Essentials
#endregion
}
#endif
}

View File

@@ -1,6 +1,6 @@
using Newtonsoft.Json;
namespace PepperDash.Essentials.AppServer
namespace PepperDash.Essentials
{
public class UserCodeChangedContent
{

View File

@@ -1,7 +1,7 @@
using Newtonsoft.Json;
using System.Collections.Generic;
namespace PepperDash.Essentials.Room.MobileControl
namespace PepperDash.Essentials
{
public class Volumes
{

View File

@@ -1,7 +1,6 @@
using Crestron.SimplSharp.WebScripting;
using Newtonsoft.Json;
using PepperDash.Core.Web.RequestHandlers;
using PepperDash.Essentials.AppServer.Messengers;
using System.Collections.Generic;
using System.Linq;
@@ -33,7 +32,7 @@ namespace PepperDash.Essentials.WebApiHandlers
private readonly MobileControlSystemController mcController;
[JsonProperty("actionPaths")]
public List<ActionPath> ActionPaths => mcController.GetActionDictionaryPaths().Select((path) => new ActionPath { MessengerKey = path.Item1, Path = path.Item2}).ToList();
public List<ActionPath> ActionPaths => mcController.GetActionDictionaryPaths().Select((path) => new ActionPath { MessengerKey = path.Item1, Path = path.Item2 }).ToList();
public ActionPathsResponse(MobileControlSystemController mcController)
{

View File

@@ -3,6 +3,7 @@ using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Core.Web.RequestHandlers;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.WebSocketServer;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -30,8 +31,7 @@ namespace PepperDash.Essentials.WebApiHandlers
}
catch (Exception ex)
{
Debug.Console(1, $"exception showing mobile info: {ex.Message}");
Debug.Console(2, $"stack trace: {ex.StackTrace}");
Debug.LogMessage(ex, "exception showing mobile info");
context.Response.StatusCode = 500;
context.Response.End();
@@ -143,7 +143,7 @@ namespace PepperDash.Essentials.WebApiHandlers
public string Token => Key;
[JsonProperty("connected")]
public bool Connected => context.Client == null ? false : context.Client.Context.WebSocket.IsAlive;
public bool Connected => context.Client != null && context.Client.Context.WebSocket.IsAlive;
[JsonProperty("duration")]
public double Duration => context.Client == null ? 0 : context.Client.ConnectedDuration.TotalSeconds;

View File

@@ -3,6 +3,8 @@ using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Core.Web.RequestHandlers;
using PepperDash.Essentials.Core.Web;
using PepperDash.Essentials.WebSocketServer;
using Serilog.Events;
namespace PepperDash.Essentials.WebApiHandlers
{
@@ -113,7 +115,7 @@ namespace PepperDash.Essentials.WebApiHandlers
if (!server.Server.RemoveWebSocketService(path))
{
Debug.Console(0, $"Unable to remove client with token {request.Token}");
Debug.LogMessage(LogEventLevel.Warning, "Unable to remove client with token {token}", request.Token);
var response = new ClientResponse
{

View File

@@ -3,11 +3,14 @@ using Crestron.SimplSharp.WebScripting;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Core.Web;
using PepperDash.Essentials.RoomBridges;
using PepperDash.Essentials.WebApiHandlers;
using Serilog.Events;
using System;
using System.Collections.Generic;
using System.IO;
@@ -21,7 +24,7 @@ using WebSocketSharp.Server;
using ErrorEventArgs = WebSocketSharp.ErrorEventArgs;
namespace PepperDash.Essentials
namespace PepperDash.Essentials.WebSocketServer
{
/// <summary>
/// Represents the behaviour to associate with a UiClient for WebSocket communication
@@ -61,7 +64,7 @@ namespace PepperDash.Essentials
base.OnOpen();
var url = Context.WebSocket.Url;
Debug.Console(2, Debug.ErrorLogLevel.Notice, "New WebSocket Connection from: {0}", url);
Debug.LogMessage(LogEventLevel.Verbose, "New WebSocket Connection from: {0}", null, url);
var match = Regex.Match(url.AbsoluteUri, "(?:ws|wss):\\/\\/.*(?:\\/mc\\/api\\/ui\\/join\\/)(.*)");
@@ -76,7 +79,7 @@ namespace PepperDash.Essentials
if (Controller == null)
{
Debug.Console(2, "WebSocket UiClient Controller is null");
Debug.LogMessage(LogEventLevel.Verbose, "WebSocket UiClient Controller is null");
_connectionTime = DateTime.Now;
}
@@ -91,37 +94,6 @@ namespace PepperDash.Essentials
};
Controller.HandleClientMessage(JsonConvert.SerializeObject(clientJoinedMessage));
// Inform controller of client joining
/*
var clientJoined = new MobileControlMessage
{
Type = "/system/roomKey",
ClientId = clientId,
Content = RoomKey,
};
Controller.SendMessageObjectToDirectClient(clientJoined);
if (Controller.Config.EnableUiMirroring)
{
var uiMirrorEnabled = new MobileControlMessage
{
Type = "/system/uiMirrorEnabled",
ClientId = clientId,
Content = JToken.FromObject(new MobileControlSimpleContent<bool> { Value = Controller.Config.EnableUiMirroring }),
};
var uiState = new MobileControlMessage
{
Type = "/system/uiMirrorState",
ClientId = clientId,
Content = Controller.LastUiState,
};
Controller.SendMessageObjectToDirectClient(uiMirrorEnabled);
Controller.SendMessageObjectToDirectClient(uiState);
}*/
var bridge = Controller.GetRoomBridge(RoomKey);
@@ -173,15 +145,14 @@ namespace PepperDash.Essentials
{
base.OnClose(e);
Debug.Console(2, Debug.ErrorLogLevel.Notice, "WebSocket UiClient Closing: {0} reason: {1}", e.Code, e.Reason);
Debug.LogMessage(LogEventLevel.Verbose, "WebSocket UiClient Closing: {0} reason: {1}", null, e.Code, e.Reason);
}
protected override void OnError(ErrorEventArgs e)
{
base.OnError(e);
Debug.Console(2, Debug.ErrorLogLevel.Notice, "WebSocket UiClient Error: {0} message: {1}", e.Exception, e.Message);
Debug.LogMessage(LogEventLevel.Verbose, "WebSocket UiClient Error: {exception} message: {message}", e.Exception, e.Message);
}
}
@@ -285,14 +256,14 @@ namespace PepperDash.Essentials
Port = customPort;
}
if(parent.Config.DirectServer.AutomaticallyForwardPortToCSLAN == true)
if (parent.Config.DirectServer.AutomaticallyForwardPortToCSLAN == true)
{
try
{
CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetCSAdapter);
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "Automatically forwarding port {0} to CS LAN", Port);
Debug.LogMessage(LogEventLevel.Information, "Automatically forwarding port {0} to CS LAN", Port);
var csAdapterId = CrestronEthernetHelper.GetAdapterdIdForSpecifiedAdapterType(EthernetAdapterType.EthernetCSAdapter);
var csIp = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, csAdapterId);
@@ -301,12 +272,12 @@ namespace PepperDash.Essentials
if (result != CrestronEthernetHelper.PortForwardingUserPatRetCodes.NoErr)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Error, "Error adding port forwarding: {0}", result);
Debug.LogMessage(LogEventLevel.Error, "Error adding port forwarding: {0}", result);
}
}
catch (ArgumentException)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "This processor does not have a CS LAN", this);
Debug.LogMessage(LogEventLevel.Information, "This processor does not have a CS LAN", this);
}
catch (Exception ex)
{
@@ -333,7 +304,7 @@ namespace PepperDash.Essentials
if (apiServer == null)
{
Debug.Console(0, this, "No API Server available");
this.LogInformation("No API Server available");
return;
}
@@ -381,7 +352,7 @@ namespace PepperDash.Essentials
if (_server.IsListening)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "Mobile Control WebSocket Server listening on port {port}", this, _server.Port);
Debug.LogMessage(LogEventLevel.Information, "Mobile Control WebSocket Server listening on port {port}", this, _server.Port);
}
CrestronEnvironment.ProgramStatusEventHandler += OnProgramStop;
@@ -423,7 +394,7 @@ namespace PepperDash.Essentials
if (bridge == null)
{
Debug.Console(0, this, $"Unable to find room with key: {client.DefaultRoomKey}");
this.LogWarning("Unable to find room with key: {defaultRoomKey}", client.DefaultRoomKey);
return;
}
@@ -431,7 +402,7 @@ namespace PepperDash.Essentials
if (key == null)
{
Debug.Console(0, this, $"Unable to generate a client for {client.Key}");
this.LogWarning("Unable to generate a client for {clientKey}", client.Key);
continue;
}
}
@@ -440,7 +411,7 @@ namespace PepperDash.Essentials
var processorIp = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, lanAdapterId);
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, $"Processor IP: {processorIp}", this);
this.LogVerbose("Processor IP: {processorIp}", processorIp);
foreach (var touchpanel in touchpanels.Select(tp =>
{
@@ -453,19 +424,19 @@ namespace PepperDash.Essentials
{
if (touchpanel.Key == null)
{
Debug.Console(0, this, $"Token for touchpanel {touchpanel.Touchpanel.Key} not found");
this.LogWarning("Token for touchpanel {touchpanelKey} not found", touchpanel.Touchpanel.Key);
continue;
}
if (touchpanel.Messenger == null)
{
Debug.Console(2, this, $"Unable to find room messenger for {touchpanel.Touchpanel.DefaultRoomKey}");
this.LogWarning("Unable to find room messenger for {defaultRoomKey}", touchpanel.Touchpanel.DefaultRoomKey);
continue;
}
var appUrl = $"http://{processorIp}:{_parent.Config.DirectServer.Port}/mc/app?token={touchpanel.Key}";
Debug.Console(2, this, $"Sending URL {appUrl}");
this.LogVerbose("Sending URL {appUrl}", appUrl);
touchpanel.Messenger.UpdateAppUrl($"http://{processorIp}:{_parent.Config.DirectServer.Port}/mc/app?token={touchpanel.Key}");
}
@@ -567,7 +538,7 @@ namespace PepperDash.Essentials
{
Debug.LogMessage(ex, "Error getting application configuration", this);
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Config Object: {config} from {parentConfig}", this, config, _parent.Config);
Debug.LogMessage(LogEventLevel.Verbose, "Config Object: {config} from {parentConfig}", this, config, _parent.Config);
}
return config;
@@ -588,9 +559,9 @@ namespace PepperDash.Essentials
if (secret != null)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "Secret successfully retrieved", this);
Debug.LogMessage(LogEventLevel.Information, "Secret successfully retrieved", this);
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "Secret: {0}", this, secret.Value.ToString());
Debug.LogMessage(LogEventLevel.Debug, "Secret: {0}", this, secret.Value.ToString());
// populate the local secrets object
@@ -601,27 +572,27 @@ namespace PepperDash.Essentials
// populate the _uiClient collection
foreach (var token in _secret.Tokens)
{
if(token.Value == null)
if (token.Value == null)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Warning, "Token value is null", this);
Debug.LogMessage(LogEventLevel.Warning, "Token value is null", this);
continue;
}
}
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "Adding token: {0} for room: {1}", this, token.Key, token.Value.RoomKey);
if(UiClients == null)
Debug.LogMessage(LogEventLevel.Information, "Adding token: {0} for room: {1}", this, token.Key, token.Value.RoomKey);
if (UiClients == null)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Warning, "UiClients is null", this);
Debug.LogMessage(LogEventLevel.Warning, "UiClients is null", this);
UiClients = new Dictionary<string, UiClientContext>();
}
UiClients.Add(token.Key, new UiClientContext(token.Value));
}
}
if (UiClients.Count > 0)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "Restored {uiClientCount} UiClients from secrets data", this, UiClients.Count);
Debug.LogMessage(LogEventLevel.Information, "Restored {uiClientCount} UiClients from secrets data", this, UiClients.Count);
foreach (var client in UiClients)
{
@@ -632,7 +603,7 @@ namespace PepperDash.Essentials
_server.AddWebSocketService(path, () =>
{
var c = new UiClient();
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "Constructing UiClient with id: {key}", this, key);
Debug.LogMessage(LogEventLevel.Debug, "Constructing UiClient with id: {key}", this, key);
c.Controller = _parent;
c.RoomKey = roomKey;
@@ -653,10 +624,10 @@ namespace PepperDash.Essentials
}
else
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Warning, "No secret found");
Debug.LogMessage(LogEventLevel.Warning, "No secret found");
}
Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, "{uiClientCount} UiClients restored from secrets data", this, UiClients.Count);
Debug.LogMessage(LogEventLevel.Debug, "{uiClientCount} UiClients restored from secrets data", this, UiClients.Count);
}
catch (Exception ex)
{
@@ -673,7 +644,7 @@ namespace PepperDash.Essentials
{
if (_secret == null)
{
Debug.LogMessage(Serilog.Events.LogEventLevel.Error, "Secret is null", this);
Debug.LogMessage(LogEventLevel.Error, "Secret is null", this);
_secret = new ServerTokenSecrets(string.Empty);
}
@@ -737,7 +708,7 @@ namespace PepperDash.Essentials
if (bridge == null)
{
Debug.Console(0, this, $"Unable to find room with key: {roomKey}");
this.LogWarning("Unable to find room with key: {roomKey}", roomKey);
return (null, null);
}
@@ -778,17 +749,17 @@ namespace PepperDash.Essentials
_server.AddWebSocketService(path, () =>
{
var c = new UiClient();
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Constructing UiClient with id: {0}", this, key);
Debug.LogMessage(LogEventLevel.Verbose, "Constructing UiClient with id: {0}", this, key);
c.Controller = _parent;
c.RoomKey = bridge.RoomKey;
UiClients[key].SetClient(c);
return c;
});
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "Added new WebSocket UiClient service at path: {path}", this, path);
Debug.LogMessage(Serilog.Events.LogEventLevel.Information, "Token: {@token}", this, token);
Debug.LogMessage(LogEventLevel.Information, "Added new WebSocket UiClient service at path: {path}", this, path);
Debug.LogMessage(LogEventLevel.Information, "Token: {@token}", this, token);
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "{serviceCount} websocket services present", this, _server.WebSocketServices.Count);
Debug.LogMessage(LogEventLevel.Verbose, "{serviceCount} websocket services present", this, _server.WebSocketServices.Count);
UpdateSecret();
@@ -926,7 +897,7 @@ namespace PepperDash.Essentials
var path = req.RawUrl;
Debug.Console(2, this, "GET Request received at path: {0}", path);
this.LogVerbose("GET Request received at path: {path}", path);
// Call for user app to join the room with a token
if (path.StartsWith("/mc/api/ui/joinroom"))
@@ -972,9 +943,9 @@ namespace PepperDash.Essentials
var path = req.RawUrl;
var ip = req.RemoteEndPoint.Address.ToString();
Debug.Console(2, this, "POST Request received at path: {0} from host {1}", path, ip);
this.LogVerbose("POST Request received at path: {path} from host {host}", path, ip);
var body = new System.IO.StreamReader(req.InputStream).ReadToEnd();
var body = new StreamReader(req.InputStream).ReadToEnd();
if (path.StartsWith("/mc/api/log"))
{
@@ -990,7 +961,7 @@ namespace PepperDash.Essentials
await LogClient.SendAsync(logRequest);
Debug.Console(2, this, "Log data sent to {0}:{1}", _parent.Config.DirectServer.Logging.Host, _parent.Config.DirectServer.Logging.Port);
this.LogVerbose("Log data sent to {host}:{port}", _parent.Config.DirectServer.Logging.Host, _parent.Config.DirectServer.Logging.Port);
}
else
{
@@ -1000,7 +971,7 @@ namespace PepperDash.Essentials
}
catch (Exception ex)
{
Debug.LogMessage(ex, "Caught an exception in the OnPost handler", this);
this.LogException(ex, "Caught an exception in the OnPost handler");
}
}
@@ -1033,7 +1004,7 @@ namespace PepperDash.Essentials
var qp = req.QueryString;
var token = qp["token"];
Debug.Console(2, this, "Join Room Request with token: {0}", token);
this.LogVerbose("Join Room Request with token: {token}", token);
if (UiClients.TryGetValue(token, out UiClientContext clientContext))
@@ -1074,10 +1045,11 @@ namespace PepperDash.Essentials
var message = string.Format("Unable to find bridge with key: {0}", clientContext.Token.RoomKey);
res.StatusCode = 404;
res.ContentType = "application/json";
this.LogVerbose("{message}", message);
var body = Encoding.UTF8.GetBytes(message);
res.ContentLength64 = body.LongLength;
res.Close(body, true);
Debug.Console(2, this, "{0}", message);
}
}
else
@@ -1085,7 +1057,7 @@ namespace PepperDash.Essentials
var message = "Token invalid or has expired";
res.StatusCode = 401;
res.ContentType = "application/json";
Debug.Console(2, this, "{0}", message);
this.LogVerbose("{message}", message);
var body = Encoding.UTF8.GetBytes(message);
res.ContentLength64 = body.LongLength;
res.Close(body, true);
@@ -1102,7 +1074,7 @@ namespace PepperDash.Essentials
res.ContentType = "application/json";
var version = new Version() { ServerVersion = _parent.GetConfigWithPluginVersion().RuntimeInfo.PluginVersion };
var message = JsonConvert.SerializeObject(version);
Debug.Console(2, this, "{0}", message);
this.LogVerbose("{message}", message);
var body = Encoding.UTF8.GetBytes(message);
res.ContentLength64 = body.LongLength;
@@ -1118,7 +1090,7 @@ namespace PepperDash.Essentials
{
var path = req.RawUrl;
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Requesting Image: {0}", this, path);
Debug.LogMessage(LogEventLevel.Verbose, "Requesting Image: {0}", this, path);
var imageBasePath = Global.DirectorySeparator + "html" + Global.DirectorySeparator + "logo" + Global.DirectorySeparator;
@@ -1126,27 +1098,27 @@ namespace PepperDash.Essentials
var filePath = imageBasePath + image;
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, "Retrieving Image: {0}", this, filePath);
Debug.LogMessage(LogEventLevel.Verbose, "Retrieving Image: {0}", this, filePath);
if (System.IO.File.Exists(filePath))
if (File.Exists(filePath))
{
if(filePath.EndsWith(".png"))
{
if (filePath.EndsWith(".png"))
{
res.ContentType = "image/png";
}
else if(filePath.EndsWith(".jpg"))
else if (filePath.EndsWith(".jpg"))
{
res.ContentType = "image/jpeg";
}
else if(filePath.EndsWith(".gif"))
else if (filePath.EndsWith(".gif"))
{
res.ContentType = "image/gif";
}
else if(filePath.EndsWith(".svg"))
else if (filePath.EndsWith(".svg"))
{
res.ContentType = "image/svg+xml";
}
byte[] contents = System.IO.File.ReadAllBytes(filePath);
byte[] contents = File.ReadAllBytes(filePath);
res.ContentLength64 = contents.LongLength;
res.Close(contents, true);
}
@@ -1155,7 +1127,7 @@ namespace PepperDash.Essentials
res.StatusCode = (int)HttpStatusCode.NotFound;
res.Close();
}
}
}
/// <summary>
/// Handles requests to serve files for the Angular single page app
@@ -1165,10 +1137,7 @@ namespace PepperDash.Essentials
/// <param name="path"></param>
private void HandleUserAppRequest(HttpListenerRequest req, HttpListenerResponse res, string path)
{
Debug.Console(2, this, "Requesting User app file...");
var qp = req.QueryString;
var token = qp["token"];
this.LogVerbose("Requesting User app file");
string filePath = path.Split('?')[0];
@@ -1189,7 +1158,7 @@ namespace PepperDash.Essentials
// swap the base href prefix for the file path prefix
filePath = filePath.Replace(_userAppBaseHref, _appPath);
Debug.Console(2, this, "filepath: {0}", filePath);
this.LogVerbose("filepath: {filePath}", filePath);
// append index.html if no specific file is specified
@@ -1208,7 +1177,7 @@ namespace PepperDash.Essentials
// Set ContentType based on file type
if (filePath.EndsWith(".html"))
{
Debug.Console(2, this, "Client requesting User App...");
this.LogVerbose("Client requesting User App");
res.ContentType = "text/html";
}
@@ -1228,17 +1197,17 @@ namespace PepperDash.Essentials
}
}
Debug.Console(2, this, "Attempting to serve file: {0}", filePath);
this.LogVerbose("Attempting to serve file: {filePath}", filePath);
byte[] contents;
if (System.IO.File.Exists(filePath))
if (File.Exists(filePath))
{
Debug.Console(2, this, "File found");
contents = System.IO.File.ReadAllBytes(filePath);
this.LogVerbose("File found: {filePath}", filePath);
contents = File.ReadAllBytes(filePath);
}
else
{
Debug.Console(2, this, "File not found: {0}", filePath);
this.LogVerbose("File not found: {filePath}", filePath);
res.StatusCode = (int)HttpStatusCode.NotFound;
res.Close();
return;
@@ -1250,7 +1219,7 @@ namespace PepperDash.Essentials
public void StopServer()
{
Debug.Console(2, this, "Stopping WebSocket Server");
this.LogVerbose("Stopping WebSocket Server");
_server.Stop(CloseStatusCode.Normal, "Server Shutting Down");
}
@@ -1295,7 +1264,7 @@ namespace PepperDash.Essentials
}
else
{
Debug.Console(0, this, "Unable to find client with ID: {0}", clientId);
this.LogWarning("Unable to find client with ID: {clientId}", clientId);
}
}
}

View File

@@ -1,7 +1,7 @@
using Newtonsoft.Json;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials
namespace PepperDash.Essentials.WebSocketServer
{
internal class WebSocketServerSecretProvider : CrestronLocalSecretsProvider
{

View File

@@ -261,7 +261,7 @@ namespace PepperDash.Essentials
_ = new DeviceFactory();
_ = new ProcessorExtensionDeviceFactory();
_ = new MobileControl.MobileControlFactory();
_ = new MobileControlFactory();
Debug.LogMessage(LogEventLevel.Information, "Starting Essentials load from configuration");

View File

@@ -11,7 +11,6 @@
<OutputPath>bin\$(Configuration)\</OutputPath>
<Title>PepperDash Essentials</Title>
<PackageId>PepperDashEssentials</PackageId>
<Version>2.0.0-local</Version>
<InformationalVersion>$(Version)</InformationalVersion>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
</PropertyGroup>