chore: miscellaeneous cleanup

This commit is contained in:
Andrew Welker
2025-03-25 22:46:41 -05:00
parent 789111cb9a
commit 277771d154
19 changed files with 289 additions and 496 deletions

View File

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

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

@@ -20,7 +20,7 @@ namespace PepperDash.Essentials.Core.Fusion
{ {
public class EssentialsHuddleSpaceFusionSystemControllerBase : Device, IOccupancyStatusProvider 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 const string RemoteOccupancyXml = "<Occupancy><Type>Local</Type><State>{0}</State></Occupancy>";
private readonly bool _guidFileExists; private readonly bool _guidFileExists;
@@ -30,15 +30,15 @@ namespace PepperDash.Essentials.Core.Fusion
protected StringSigData CurrentRoomSourceNameSig; protected StringSigData CurrentRoomSourceNameSig;
public FusionCustomPropertiesBridge CustomPropertiesBridge = new FusionCustomPropertiesBridge(); private readonly FusionCustomPropertiesBridge CustomPropertiesBridge = new FusionCustomPropertiesBridge();
protected FusionOccupancySensorAsset FusionOccSensor; protected FusionOccupancySensorAsset FusionOccSensor;
protected FusionRemoteOccupancySensor FusionRemoteOccSensor; private readonly FusionRemoteOccupancySensor FusionRemoteOccSensor;
protected FusionRoom FusionRoom; protected FusionRoom FusionRoom;
protected Dictionary<int, FusionAsset> FusionStaticAssets; protected Dictionary<int, FusionAsset> FusionStaticAssets;
public long PushNotificationTimeout = 5000; private readonly long PushNotificationTimeout = 5000;
protected IEssentialsRoom Room; private readonly IEssentialsRoom Room;
public long SchedulePollInterval = 300000; private readonly long SchedulePollInterval = 300000;
private Event _currentMeeting; private Event _currentMeeting;
private RoomSchedule _currentSchedule; private RoomSchedule _currentSchedule;
@@ -86,7 +86,7 @@ namespace PepperDash.Essentials.Core.Fusion
#region Default Display Source Sigs #region Default Display Source Sigs
private BooleanSigData[] _source = new BooleanSigData[10]; private readonly BooleanSigData[] _source = new BooleanSigData[10];
#endregion #endregion
@@ -152,9 +152,8 @@ namespace PepperDash.Essentials.Core.Fusion
ReadGuidFile(guidFilePath); ReadGuidFile(guidFilePath);
} }
var occupancyRoom = Room as IRoomOccupancy;
if (occupancyRoom != null) if (Room is IRoomOccupancy occupancyRoom)
{ {
if (occupancyRoom.RoomOccupancy != null) if (occupancyRoom.RoomOccupancy != null)
{ {
@@ -368,8 +367,7 @@ namespace PepperDash.Essentials.Core.Fusion
CurrentRoomSourceNameSig = FusionRoom.CreateOffsetStringSig(JoinMap.Display1CurrentSourceName.JoinNumber, JoinMap.Display1CurrentSourceName.AttributeName, CurrentRoomSourceNameSig = FusionRoom.CreateOffsetStringSig(JoinMap.Display1CurrentSourceName.JoinNumber, JoinMap.Display1CurrentSourceName.AttributeName,
eSigIoMask.InputSigOnly); eSigIoMask.InputSigOnly);
// Don't think we need to get current status of this as nothing should be alive yet. // Don't think we need to get current status of this as nothing should be alive yet.
var hasCurrentSourceInfoChange = Room as IHasCurrentSourceInfoChange; if (Room is IHasCurrentSourceInfoChange hasCurrentSourceInfoChange)
if (hasCurrentSourceInfoChange != null)
{ {
hasCurrentSourceInfoChange.CurrentSourceChange += Room_CurrentSourceInfoChange; hasCurrentSourceInfoChange.CurrentSourceChange += Room_CurrentSourceInfoChange;
} }
@@ -378,8 +376,7 @@ namespace PepperDash.Essentials.Core.Fusion
FusionRoom.SystemPowerOn.OutputSig.SetSigFalseAction(Room.PowerOnToDefaultOrLastSource); FusionRoom.SystemPowerOn.OutputSig.SetSigFalseAction(Room.PowerOnToDefaultOrLastSource);
FusionRoom.SystemPowerOff.OutputSig.SetSigFalseAction(() => FusionRoom.SystemPowerOff.OutputSig.SetSigFalseAction(() =>
{ {
var runRouteAction = Room as IRunRouteAction; if (Room is IRunRouteAction runRouteAction)
if (runRouteAction != null)
{ {
runRouteAction.RunRouteAction("roomOff", Room.SourceListKey); runRouteAction.RunRouteAction("roomOff", Room.SourceListKey);
} }
@@ -661,7 +658,7 @@ namespace PepperDash.Essentials.Core.Fusion
var extendTime = _currentMeeting.dtEnd - DateTime.Now; var extendTime = _currentMeeting.dtEnd - DateTime.Now;
var extendMinutesRaw = extendTime.TotalMinutes; var extendMinutesRaw = extendTime.TotalMinutes;
extendMinutes = extendMinutes + (int) Math.Round(extendMinutesRaw); extendMinutes += (int) Math.Round(extendMinutesRaw);
} }
@@ -902,12 +899,7 @@ namespace PepperDash.Essentials.Core.Fusion
} }
} }
} }
RoomInfoChange?.Invoke(this, new EventArgs());
var handler = RoomInfoChange;
if (handler != null)
{
handler(this, new EventArgs());
}
CustomPropertiesBridge.EvaluateRoomInfo(Room.Key, roomInformation); CustomPropertiesBridge.EvaluateRoomInfo(Room.Key, roomInformation);
} }
@@ -1015,12 +1007,7 @@ namespace PepperDash.Essentials.Core.Fusion
} }
// Fire Schedule Change Event // Fire Schedule Change Event
var handler = ScheduleChange; ScheduleChange?.Invoke(this, new ScheduleChangeEventArgs { Schedule = _currentSchedule });
if (handler != null)
{
handler(this, new ScheduleChangeEventArgs {Schedule = _currentSchedule});
}
} }
} }
} }
@@ -1092,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; i = 1;
foreach (var kvp in laptops) foreach (var kvp in laptops)
{ {
@@ -1124,9 +1111,7 @@ namespace PepperDash.Essentials.Core.Fusion
/// <param name="e"></param> /// <param name="e"></param>
protected void UsageTracker_DeviceUsageEnded(object sender, DeviceUsageEventArgs e) protected void UsageTracker_DeviceUsageEnded(object sender, DeviceUsageEventArgs e)
{ {
var deviceTracker = sender as UsageTracking; if (!(sender is UsageTracking deviceTracker))
if (deviceTracker == null)
{ {
return; return;
} }
@@ -1169,8 +1154,7 @@ namespace PepperDash.Essentials.Core.Fusion
// And respond to selection in Fusion // And respond to selection in Fusion
sigD.OutputSig.SetSigFalseAction(() => sigD.OutputSig.SetSigFalseAction(() =>
{ {
var runRouteAction = Room as IRunRouteAction; if (Room is IRunRouteAction runRouteAction)
if (runRouteAction != null)
{ {
runRouteAction.RunRouteAction(routeKey, Room.SourceListKey); runRouteAction.RunRouteAction(routeKey, Room.SourceListKey);
} }
@@ -1214,12 +1198,11 @@ namespace PepperDash.Essentials.Core.Fusion
//uint attrNum = Convert.ToUInt32(keyNum); //uint attrNum = Convert.ToUInt32(keyNum);
// Check for UI devices // Check for UI devices
var uiDev = dev as IHasBasicTriListWithSmartObject; if (dev is IHasBasicTriListWithSmartObject uiDev)
if (uiDev != null)
{ {
if (uiDev.Panel is Crestron.SimplSharpPro.UI.XpanelForSmartGraphics) if (uiDev.Panel is Crestron.SimplSharpPro.UI.XpanelForSmartGraphics)
{ {
attrNum = attrNum + touchpanelNum; attrNum += touchpanelNum;
if (attrNum > JoinMap.XpanelOnlineStart.JoinSpan) if (attrNum > JoinMap.XpanelOnlineStart.JoinSpan)
{ {
@@ -1232,7 +1215,7 @@ namespace PepperDash.Essentials.Core.Fusion
} }
else else
{ {
attrNum = attrNum + xpanelNum; attrNum += xpanelNum;
if (attrNum > JoinMap.TouchpanelOnlineStart.JoinSpan) if (attrNum > JoinMap.TouchpanelOnlineStart.JoinSpan)
{ {
@@ -1248,7 +1231,7 @@ namespace PepperDash.Essentials.Core.Fusion
//else //else
if (dev is IDisplay) if (dev is IDisplay)
{ {
attrNum = attrNum + displayNum; attrNum += displayNum;
if (attrNum > JoinMap.DisplayOnlineStart.JoinSpan) if (attrNum > JoinMap.DisplayOnlineStart.JoinSpan)
{ {
continue; continue;
@@ -1300,13 +1283,11 @@ namespace PepperDash.Essentials.Core.Fusion
display.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded; display.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded;
} }
var hasDefaultDisplay = Room as IHasDefaultDisplay; if (!(Room is IHasDefaultDisplay hasDefaultDisplay))
if (hasDefaultDisplay == null)
{ {
return; return;
} }
var defaultDisplay = hasDefaultDisplay.DefaultDisplay as IDisplay; if (!(hasDefaultDisplay.DefaultDisplay is IDisplay defaultDisplay))
if (defaultDisplay == null)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Cannot link null display to Fusion because default display is null"); Debug.LogMessage(LogEventLevel.Debug, this, "Cannot link null display to Fusion because default display is null");
return; return;
@@ -1358,8 +1339,7 @@ namespace PepperDash.Essentials.Core.Fusion
dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction; dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction;
dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction; dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction;
var defaultTwoWayDisplay = defaultDisplay as IHasPowerControlWithFeedback; if (defaultDisplay is IHasPowerControlWithFeedback defaultTwoWayDisplay)
if (defaultTwoWayDisplay != null)
{ {
defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig); defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig);
if (defaultDisplay is IDisplayUsage) if (defaultDisplay is IDisplayUsage)
@@ -1392,8 +1372,7 @@ namespace PepperDash.Essentials.Core.Fusion
var displayName = string.Format("Display {0} - ", displayIndex); var displayName = string.Format("Display {0} - ", displayIndex);
var hasDefaultDisplay = Room as IHasDefaultDisplay; if (!(Room is IHasDefaultDisplay hasDefaultDisplay) || display != hasDefaultDisplay.DefaultDisplay)
if (hasDefaultDisplay == null || display != hasDefaultDisplay.DefaultDisplay)
{ {
return; return;
} }
@@ -1402,8 +1381,7 @@ namespace PepperDash.Essentials.Core.Fusion
eSigIoMask.InputOutputSig); eSigIoMask.InputOutputSig);
defaultDisplayVolume.OutputSig.UserObject = new Action<ushort>(b => defaultDisplayVolume.OutputSig.UserObject = new Action<ushort>(b =>
{ {
var basicVolumeWithFeedback = display as IBasicVolumeWithFeedback; if (!(display is IBasicVolumeWithFeedback basicVolumeWithFeedback))
if (basicVolumeWithFeedback == null)
{ {
return; return;
} }
@@ -1436,8 +1414,7 @@ namespace PepperDash.Essentials.Core.Fusion
}); });
var defaultTwoWayDisplay = display as IHasPowerControlWithFeedback; if (display is IHasPowerControlWithFeedback defaultTwoWayDisplay)
if (defaultTwoWayDisplay != null)
{ {
defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig); defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig);
defaultTwoWayDisplay.PowerIsOnFeedback.LinkComplementInputSig(defaultDisplayPowerOff.InputSig); defaultTwoWayDisplay.PowerIsOnFeedback.LinkComplementInputSig(defaultDisplayPowerOff.InputSig);
@@ -1450,8 +1427,7 @@ namespace PepperDash.Essentials.Core.Fusion
{ {
if (!b) if (!b)
{ {
var runRouteAction = Room as IRunRouteAction; if (Room is IRunRouteAction runRouteAction)
if (runRouteAction != null)
{ {
runRouteAction.RunRouteAction("roomOff", Room.SourceListKey); runRouteAction.RunRouteAction("roomOff", Room.SourceListKey);
} }
@@ -1465,8 +1441,7 @@ namespace PepperDash.Essentials.Core.Fusion
_errorMessageRollUp = new StatusMonitorCollection(this); _errorMessageRollUp = new StatusMonitorCollection(this);
foreach (var dev in DeviceManager.GetDevices()) foreach (var dev in DeviceManager.GetDevices())
{ {
var md = dev as ICommunicationMonitor; if (dev is ICommunicationMonitor md)
if (md != null)
{ {
_errorMessageRollUp.AddMonitor(md.CommunicationMonitor); _errorMessageRollUp.AddMonitor(md.CommunicationMonitor);
Debug.LogMessage(LogEventLevel.Verbose, this, "Adding '{0}' to room's overall error monitor", Debug.LogMessage(LogEventLevel.Verbose, this, "Adding '{0}' to room's overall error monitor",
@@ -1532,9 +1507,8 @@ namespace PepperDash.Essentials.Core.Fusion
// Tie to method on occupancy object // Tie to method on occupancy object
//occSensorShutdownMinutes.OutputSig.UserObject(new Action(ushort)(b => Room.OccupancyObj.SetShutdownMinutes(b)); //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.LinkInputSig(occSensorAsset.RoomOccupied.InputSig);
occRoom.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += RoomIsOccupiedFeedback_OutputChange; occRoom.RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += RoomIsOccupiedFeedback_OutputChange;
@@ -1601,10 +1575,9 @@ namespace PepperDash.Essentials.Core.Fusion
// The sig/UO method: Need separate handlers for fixed and user sigs, all flavors, // The sig/UO method: Need separate handlers for fixed and user sigs, all flavors,
// even though they all contain sigs. // even though they all contain sigs.
var sigData = args.UserConfiguredSigDetail as BooleanSigDataFixedName;
BoolOutputSig outSig; BoolOutputSig outSig;
if (sigData != null) if (args.UserConfiguredSigDetail is BooleanSigDataFixedName sigData)
{ {
outSig = sigData.OutputSig; outSig = sigData.OutputSig;
if (outSig.UserObject is Action<bool>) if (outSig.UserObject is Action<bool>)
@@ -1760,8 +1733,7 @@ namespace PepperDash.Essentials.Core.Fusion
/// </summary> /// </summary>
public static void TrySetMakeModel(this FusionStaticAsset asset, Device device) public static void TrySetMakeModel(this FusionStaticAsset asset, Device device)
{ {
var mm = device as IMakeModel; if (device is IMakeModel mm)
if (mm != null)
{ {
asset.ParamMake.Value = mm.DeviceMake; asset.ParamMake.Value = mm.DeviceMake;
asset.ParamModel.Value = mm.DeviceModel; asset.ParamModel.Value = mm.DeviceModel;

View File

@@ -4,6 +4,7 @@ using System.Globalization;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Newtonsoft.Json; using Newtonsoft.Json;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Core.Logging;
using Serilog.Events; using Serilog.Events;
namespace PepperDash.Essentials.Core.Touchpanels namespace PepperDash.Essentials.Core.Touchpanels
@@ -34,9 +35,9 @@ namespace PepperDash.Essentials.Core.Touchpanels
Debug.LogMessage(LogEventLevel.Information, this, "touchpanel registration response: {0}", registrationResponse); Debug.LogMessage(LogEventLevel.Information, this, "touchpanel registration response: {0}", registrationResponse);
} }
_touchpanel.BaseEvent += _touchpanel_BaseEvent; _touchpanel.BaseEvent += Touchpanel_BaseEvent;
_touchpanel.ButtonStateChange += _touchpanel_ButtonStateChange; _touchpanel.ButtonStateChange += Touchpanel_ButtonStateChange;
_touchpanel.PanelStateChange += _touchpanel_PanelStateChange; _touchpanel.PanelStateChange += Touchpanel_PanelStateChange;
_buttons = buttons; _buttons = buttons;
if (_buttons == null) if (_buttons == null)
@@ -74,8 +75,7 @@ namespace PepperDash.Essentials.Core.Touchpanels
return; return;
} }
int buttonNumber; TryParseInt(key, out int buttonNumber);
TryParseInt(key, out buttonNumber);
var buttonEventTypes = config.EventTypes; var buttonEventTypes = config.EventTypes;
BoolOutputSig enabledFb = null; BoolOutputSig enabledFb = null;
@@ -161,8 +161,7 @@ namespace PepperDash.Essentials.Core.Touchpanels
return; return;
} }
int buttonNumber; TryParseInt(key, out int buttonNumber);
TryParseInt(key, out buttonNumber);
// Link up the button feedbacks to the specified device feedback // Link up the button feedbacks to the specified device feedback
var buttonFeedback = config.Feedback; var buttonFeedback = config.Feedback;
@@ -177,8 +176,7 @@ namespace PepperDash.Essentials.Core.Touchpanels
try try
{ {
var device = DeviceManager.GetDeviceForKey(buttonFeedback.DeviceKey) as Device; if (!(DeviceManager.GetDeviceForKey(buttonFeedback.DeviceKey) is Device device))
if (device == null)
{ {
Debug.LogMessage(LogEventLevel.Debug, this, "Button '{0}' feedback deviceKey '{1}' not found.", Debug.LogMessage(LogEventLevel.Debug, this, "Button '{0}' feedback deviceKey '{1}' not found.",
key, buttonFeedback.DeviceKey); key, buttonFeedback.DeviceKey);
@@ -224,20 +222,19 @@ namespace PepperDash.Essentials.Core.Touchpanels
} }
var boolFeedback = deviceFeedback as BoolFeedback; var boolFeedback = deviceFeedback as BoolFeedback;
var intFeedback = deviceFeedback as IntFeedback;
switch (key) switch (key)
{ {
case ("power"): case ("power"):
{ {
if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackPower); boolFeedback?.LinkCrestronFeedback(_touchpanel.FeedbackPower);
break; break;
} }
case ("volumeup"): case ("volumeup"):
case ("volumedown"): case ("volumedown"):
case ("volumefeedback"): case ("volumefeedback"):
{ {
if (intFeedback != null) if (deviceFeedback is IntFeedback intFeedback)
{ {
var volumeFeedback = intFeedback; var volumeFeedback = intFeedback;
volumeFeedback.LinkInputSig(_touchpanel.VolumeBargraph); volumeFeedback.LinkInputSig(_touchpanel.VolumeBargraph);
@@ -246,12 +243,12 @@ namespace PepperDash.Essentials.Core.Touchpanels
} }
case ("mute"): case ("mute"):
{ {
if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.FeedbackMute); boolFeedback?.LinkCrestronFeedback(_touchpanel.FeedbackMute);
break; break;
} }
default: default:
{ {
if (boolFeedback != null) boolFeedback.LinkCrestronFeedback(_touchpanel.Feedbacks[(uint)buttonNumber]); boolFeedback?.LinkCrestronFeedback(_touchpanel.Feedbacks[(uint)buttonNumber]);
break; break;
} }
} }
@@ -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); 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); 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(); 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); 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> /// <param name="type"></param>
public void Press(string buttonKey, string type) 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 // 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 // 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() public void ListButtons()
{ {
var line = new string('-', 35); this.LogVerbose("MPC3 Controller {0} - Available Buttons", Key);
Debug.Console(0, this, line);
Debug.Console(0, this, "MPC3 Controller {0} - Available Butons", Key);
foreach (var button in _buttons) 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,8 +119,7 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers
return; return;
} }
var device = DeviceManager.GetDeviceForKey(body.DeviceKey) as IStreamDebugging; if (!(DeviceManager.GetDeviceForKey(body.DeviceKey) is IStreamDebugging device))
if (device == null)
{ {
context.Response.StatusCode = 404; context.Response.StatusCode = 404;
context.Response.StatusDescription = "Not Found"; context.Response.StatusDescription = "Not Found";
@@ -136,6 +135,7 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.LogMessage(ex, "Exception handling set debug request");
context.Response.StatusCode = 500; context.Response.StatusCode = 500;
context.Response.StatusDescription = "Internal Server Error"; context.Response.StatusDescription = "Internal Server Error";
context.Response.End(); context.Response.End();
@@ -161,6 +161,7 @@ namespace PepperDash.Essentials.Core.Web.RequestHandlers
} }
catch (Exception ex) catch (Exception ex)
{ {
Debug.LogMessage(ex, "Exception handling set debug request");
context.Response.StatusCode = 500; context.Response.StatusCode = 500;
context.Response.StatusDescription = "Internal Server Error"; context.Response.StatusDescription = "Internal Server Error";
context.Response.End(); 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 public class CameraVisca : CameraBase, IHasCameraPtzControl, ICommunicationMonitor, IHasCameraPresets, IHasPowerControlWithFeedback, IBridgeAdvanced, IHasCameraFocusControl, IHasAutoFocusMode
{ {
CameraViscaPropertiesConfig PropertiesConfig; private readonly CameraViscaPropertiesConfig PropertiesConfig;
public IBasicCommunication Communication { get; private set; } public IBasicCommunication Communication { get; private set; }
@@ -30,7 +30,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras
/// <summary> /// <summary>
/// Used to store the actions to parse inquiry responses as the inquiries are sent /// Used to store the actions to parse inquiry responses as the inquiries are sent
/// </summary> /// </summary>
private CrestronQueue<Action<byte[]>> InquiryResponseQueue; private readonly CrestronQueue<Action<byte[]>> InquiryResponseQueue;
/// <summary> /// <summary>
/// Camera ID (Default 1) /// Camera ID (Default 1)
@@ -45,7 +45,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras
public byte PanSpeedFast = 0x13; public byte PanSpeedFast = 0x13;
public byte TiltSpeedFast = 0x13; public byte TiltSpeedFast = 0x13;
private bool IsMoving; // private bool IsMoving;
private bool IsZooming; private bool IsZooming;
bool _powerIsOn; bool _powerIsOn;
@@ -101,11 +101,10 @@ namespace PepperDash.Essentials.Devices.Common.Cameras
Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom | eCameraCapabilities.Focus; Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom | eCameraCapabilities.Focus;
Communication = comm; Communication = comm;
var socket = comm as ISocketStatus; if (comm is ISocketStatus socket)
if (socket != null)
{ {
// This instance uses IP control // This instance uses IP control
socket.ConnectionChange += new EventHandler<GenericSocketStatusChageEventArgs>(socket_ConnectionChange); socket.ConnectionChange += new EventHandler<GenericSocketStatusChageEventArgs>(Socket_ConnectionChange);
} }
else else
{ {
@@ -175,7 +174,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras
LinkCameraToApi(this, trilist, joinStart, joinMapKey, bridge); 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()); 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() public void PanLeft()
{ {
SendPanTiltCommand(new byte[] {0x01, 0x03}, false); SendPanTiltCommand(new byte[] {0x01, 0x03}, false);
IsMoving = true; // IsMoving = true;
} }
public void PanRight() public void PanRight()
{ {
SendPanTiltCommand(new byte[] { 0x02, 0x03 }, false); SendPanTiltCommand(new byte[] { 0x02, 0x03 }, false);
IsMoving = true; // IsMoving = true;
} }
public void PanStop() public void PanStop()
{ {
@@ -463,12 +462,12 @@ namespace PepperDash.Essentials.Devices.Common.Cameras
public void TiltDown() public void TiltDown()
{ {
SendPanTiltCommand(new byte[] { 0x03, 0x02 }, false); SendPanTiltCommand(new byte[] { 0x03, 0x02 }, false);
IsMoving = true; // IsMoving = true;
} }
public void TiltUp() public void TiltUp()
{ {
SendPanTiltCommand(new byte[] { 0x03, 0x01 }, false); SendPanTiltCommand(new byte[] { 0x03, 0x01 }, false);
IsMoving = true; // IsMoving = true;
} }
public void TiltStop() public void TiltStop()
{ {
@@ -507,7 +506,7 @@ namespace PepperDash.Essentials.Devices.Common.Cameras
{ {
StopSpeedTimer(); StopSpeedTimer();
SendPanTiltCommand(new byte[] { 0x03, 0x03 }, false); SendPanTiltCommand(new byte[] { 0x03, 0x03 }, false);
IsMoving = false; // IsMoving = false;
} }
} }
public void PositionHome() public void PositionHome()

View File

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

View File

@@ -31,9 +31,9 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
protected const int MaxParticipants = 50; protected const int MaxParticipants = 50;
private readonly byte[] _clearBytes = XSigHelpers.ClearOutputs(); private readonly byte[] _clearBytes = XSigHelpers.ClearOutputs();
private IHasDirectory _directoryCodec; private readonly IHasDirectory _directoryCodec;
private BasicTriList _directoryTrilist; private readonly BasicTriList _directoryTrilist;
private VideoCodecControllerJoinMap _directoryJoinmap; private readonly VideoCodecControllerJoinMap _directoryJoinmap;
protected string _timeFormatSpecifier; protected string _timeFormatSpecifier;
protected string _dateFormatSpecifier; protected string _dateFormatSpecifier;
@@ -216,11 +216,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
/// <param name="item"></param> /// <param name="item"></param>
protected virtual void OnCallStatusChange(CodecActiveCallItem item) protected virtual void OnCallStatusChange(CodecActiveCallItem item)
{ {
var handler = CallStatusChange; CallStatusChange?.Invoke(this, new CodecCallStatusItemChangeEventArgs(item));
if (handler != null)
{
handler(this, new CodecCallStatusItemChangeEventArgs(item));
}
PrivacyModeIsOnFeedback.FireUpdate(); PrivacyModeIsOnFeedback.FireUpdate();
@@ -252,11 +248,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
try try
{ {
IsReady = true; IsReady = true;
var h = IsReadyChange; IsReadyChange?.Invoke(this, new EventArgs());
if (h != null)
{
h(this, new EventArgs());
}
} }
catch (Exception e) catch (Exception e)
{ {
@@ -309,10 +301,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
joinMap.SetCustomJoinData(customJoins); joinMap.SetCustomJoinData(customJoins);
} }
if (bridge != null) bridge?.AddJoinMap(Key, joinMap);
{
bridge.AddJoinMap(Key, joinMap);
}
LinkVideoCodecToApi(codec, trilist, joinMap); LinkVideoCodecToApi(codec, trilist, joinMap);
@@ -530,9 +519,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false); 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); trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !autoCodec.CameraAutoModeIsOnFeedback.BoolValue);
@@ -548,9 +536,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false); 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); trilist.SetBool(joinMap.CameraModeManual.JoinNumber, !autoModeCodec.CameraAutoModeIsOnFeedback.BoolValue);
@@ -649,8 +636,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
var p = participant; var p = participant;
if (index > MaxParticipants) break; if (index > MaxParticipants) break;
var audioMuteCodec = this as IHasParticipantAudioMute; if (this is IHasParticipantAudioMute audioMuteCodec)
if (audioMuteCodec != null)
{ {
trilist.SetSigFalseAction(joinMap.ParticipantAudioMuteToggleStart.JoinNumber + index, trilist.SetSigFalseAction(joinMap.ParticipantAudioMuteToggleStart.JoinNumber + index,
() => audioMuteCodec.ToggleAudioForParticipant(p.UserId)); () => audioMuteCodec.ToggleAudioForParticipant(p.UserId));
@@ -659,8 +645,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
() => audioMuteCodec.ToggleVideoForParticipant(p.UserId)); () => audioMuteCodec.ToggleVideoForParticipant(p.UserId));
} }
var pinCodec = this as IHasParticipantPinUnpin; if (this is IHasParticipantPinUnpin pinCodec)
if (pinCodec != null)
{ {
trilist.SetSigFalseAction(joinMap.ParticipantPinToggleStart.JoinNumber + index, trilist.SetSigFalseAction(joinMap.ParticipantPinToggleStart.JoinNumber + index,
() => pinCodec.ToggleParticipantPinState(p.UserId, pinCodec.ScreenIndexToPinUserTo)); () => 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 // Allow auto dial of selected line. Always dials first contact method
if (!trilist.GetBool(joinMap.DirectoryDisableAutoDialSelectedLine.JoinNumber)) if (!trilist.GetBool(joinMap.DirectoryDisableAutoDialSelectedLine.JoinNumber))
{ {
var invitableEntry = _selectedDirectoryItem as IInvitableContact; if (_selectedDirectoryItem is IInvitableContact invitableEntry)
if (invitableEntry != null)
{ {
Dial(invitableEntry); Dial(invitableEntry);
return; return;
} }
var entryToDial = _selectedDirectoryItem as DirectoryContact;
trilist.SetString(joinMap.DirectoryEntrySelectedNumber.JoinNumber, trilist.SetString(joinMap.DirectoryEntrySelectedNumber.JoinNumber,
selectedContact != null ? selectedContact.ContactMethods[0].Number : string.Empty); selectedContact != null ? selectedContact.ContactMethods[0].Number : string.Empty);
if (entryToDial == null) return; if (!(_selectedDirectoryItem is DirectoryContact entryToDial)) return;
Dial(entryToDial.ContactMethods[0].Number); Dial(entryToDial.ContactMethods[0].Number);
} }
else else
{ {
// If auto dial is disabled... // 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 // Clear out values and actions from last selected item
trilist.SetUshort(joinMap.SelectedContactMethodCount.JoinNumber, 0); trilist.SetUshort(joinMap.SelectedContactMethodCount.JoinNumber, 0);
@@ -1296,8 +1277,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetUshort(joinMap.ConnectedCallCount.JoinNumber, (ushort)ActiveCalls.Count); trilist.SetUshort(joinMap.ConnectedCallCount.JoinNumber, (ushort)ActiveCalls.Count);
}; };
var joinCodec = this as IJoinCalls; if (this is IJoinCalls joinCodec)
if (joinCodec != null)
{ {
trilist.SetSigFalseAction(joinMap.JoinAllCalls.JoinNumber, () => joinCodec.JoinAllCalls()); trilist.SetSigFalseAction(joinMap.JoinAllCalls.JoinNumber, () => joinCodec.JoinAllCalls());
@@ -1318,8 +1298,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
} }
} }
var holdCodec = this as IHasCallHold; if (this is IHasCallHold holdCodec)
if (holdCodec != null)
{ {
trilist.SetSigFalseAction(joinMap.HoldAllCalls.JoinNumber, () => trilist.SetSigFalseAction(joinMap.HoldAllCalls.JoinNumber, () =>
{ {
@@ -1505,9 +1484,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
codec.CameraAutoModeIsOnFeedback.OutputChange += (o, a) => codec.CameraAutoModeIsOnFeedback.OutputChange += (o, a) =>
{ {
var offCodec = codec as IHasCameraOff; if (codec is IHasCameraOff offCodec)
if (offCodec != null)
{ {
if (offCodec.CameraIsOffFeedback.BoolValue) if (offCodec.CameraIsOffFeedback.BoolValue)
{ {
@@ -1528,9 +1505,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false); trilist.SetBool(joinMap.CameraModeOff.JoinNumber, false);
}; };
var offModeCodec = codec as IHasCameraOff;
if (offModeCodec != null) if (codec is IHasCameraOff offModeCodec)
{ {
if (offModeCodec.CameraIsOffFeedback.BoolValue) if (offModeCodec.CameraIsOffFeedback.BoolValue)
{ {
@@ -1565,9 +1541,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetBoolSigAction(joinMap.CameraTiltUp.JoinNumber, (b) => trilist.SetBoolSigAction(joinMap.CameraTiltUp.JoinNumber, (b) =>
{ {
if (codec.SelectedCamera == null) return; 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(); else camera.TiltStop();
@@ -1576,9 +1551,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetBoolSigAction(joinMap.CameraTiltDown.JoinNumber, (b) => trilist.SetBoolSigAction(joinMap.CameraTiltDown.JoinNumber, (b) =>
{ {
if (codec.SelectedCamera == null) return; 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(); else camera.TiltStop();
@@ -1586,9 +1560,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetBoolSigAction(joinMap.CameraPanLeft.JoinNumber, (b) => trilist.SetBoolSigAction(joinMap.CameraPanLeft.JoinNumber, (b) =>
{ {
if (codec.SelectedCamera == null) return; 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(); else camera.PanStop();
@@ -1596,9 +1569,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetBoolSigAction(joinMap.CameraPanRight.JoinNumber, (b) => trilist.SetBoolSigAction(joinMap.CameraPanRight.JoinNumber, (b) =>
{ {
if (codec.SelectedCamera == null) return; 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(); else camera.PanStop();
@@ -1607,9 +1579,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetBoolSigAction(joinMap.CameraZoomIn.JoinNumber, (b) => trilist.SetBoolSigAction(joinMap.CameraZoomIn.JoinNumber, (b) =>
{ {
if (codec.SelectedCamera == null) return; 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(); else camera.ZoomStop();
@@ -1618,9 +1589,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetBoolSigAction(joinMap.CameraZoomOut.JoinNumber, (b) => trilist.SetBoolSigAction(joinMap.CameraZoomOut.JoinNumber, (b) =>
{ {
if (codec.SelectedCamera == null) return; 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(); else camera.ZoomStop();
@@ -1630,9 +1600,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetBoolSigAction(joinMap.CameraFocusNear.JoinNumber, (b) => trilist.SetBoolSigAction(joinMap.CameraFocusNear.JoinNumber, (b) =>
{ {
if (codec.SelectedCamera == null) return; 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(); if (b) camera.FocusNear();
else camera.FocusStop(); else camera.FocusStop();
@@ -1641,9 +1610,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetBoolSigAction(joinMap.CameraFocusFar.JoinNumber, (b) => trilist.SetBoolSigAction(joinMap.CameraFocusFar.JoinNumber, (b) =>
{ {
if (codec.SelectedCamera == null) return; 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(); if (b) camera.FocusFar();
else camera.FocusStop(); else camera.FocusStop();
@@ -1652,9 +1620,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
trilist.SetSigFalseAction(joinMap.CameraFocusAuto.JoinNumber, () => trilist.SetSigFalseAction(joinMap.CameraFocusAuto.JoinNumber, () =>
{ {
if (codec.SelectedCamera == null) return; if (codec.SelectedCamera == null) return;
var camera = codec.SelectedCamera as IHasCameraFocusControl;
if (camera == null) return; if (!(codec.SelectedCamera is IHasCameraFocusControl camera)) return;
camera.TriggerAutoFocus(); camera.TriggerAutoFocus();
}); });
@@ -1773,7 +1740,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
// Following fields only used for Bridging // Following fields only used for Bridging
private int _selectedRecentCallItemIndex; private int _selectedRecentCallItemIndex;
private CodecCallHistory.CallHistoryEntry _selectedRecentCallItem;
private DirectoryItem _selectedDirectoryItem; private DirectoryItem _selectedDirectoryItem;
private void LinkVideoCodecCallHistoryToApi(IHasCallHistory codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap) private void LinkVideoCodecCallHistoryToApi(IHasCallHistory codec, BasicTriList trilist, VideoCodecControllerJoinMap joinMap)
@@ -1820,7 +1786,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
{ {
// Clear out selected item // Clear out selected item
_selectedRecentCallItemIndex = 0; _selectedRecentCallItemIndex = 0;
_selectedRecentCallItem = null;
trilist.SetUshort(joinMap.SelectRecentCallItem.JoinNumber, 0); trilist.SetUshort(joinMap.SelectRecentCallItem.JoinNumber, 0);
trilist.SetString(joinMap.SelectedRecentCallName.JoinNumber, string.Empty); trilist.SetString(joinMap.SelectedRecentCallName.JoinNumber, string.Empty);
trilist.SetString(joinMap.SelectedRecentCallNumber.JoinNumber, string.Empty); trilist.SetString(joinMap.SelectedRecentCallNumber.JoinNumber, string.Empty);
@@ -1929,11 +1895,7 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
{ {
if (value == true) if (value == true)
{ {
var handler = InitialSyncCompleted; InitialSyncCompleted?.Invoke(this, new EventArgs());
if (handler != null)
{
handler(this, new EventArgs());
}
} }
_InitialSyncComplete = value; _InitialSyncComplete = value;
} }

View File

@@ -1,5 +1,6 @@
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.AppServer; using PepperDash.Essentials.AppServer;
using PepperDash.Essentials.AppServer.Messengers; using PepperDash.Essentials.AppServer.Messengers;
using System.Linq; using System.Linq;
@@ -32,7 +33,7 @@ namespace PepperDash.Essentials.Room.MobileControl
if (inputPort == null) 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; return;
} }

View File

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

View File

@@ -1,6 +1,7 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -117,7 +118,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Console(0, this, "Error sending full status: {0}", e); this.LogException(e, "Error sending full status");
} }
} }

View File

@@ -1,5 +1,6 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using System; using System;
@@ -43,7 +44,6 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (!string.IsNullOrEmpty(c.SourceListKey)) if (!string.IsNullOrEmpty(c.SourceListKey))
{ {
// Check for source list in content of message // Check for source list in content of message
Debug.Console(1, this, "sourceListKey found in message");
sourceListKey = c.SourceListKey; sourceListKey = c.SourceListKey;
} }

View File

@@ -45,8 +45,6 @@ namespace PepperDash.Essentials.AppServer.Messengers
private void SendFullStatus() private void SendFullStatus()
{ {
Debug.Console(2, "LightingBaseMessenger GetFullStatus");
var state = new LightingBaseStateMessage var state = new LightingBaseStateMessage
{ {
Scenes = Device.LightingScenes, Scenes = Device.LightingScenes,

View File

@@ -1,5 +1,6 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Essentials.Room.Config; using PepperDash.Essentials.Room.Config;
using System; using System;
@@ -51,7 +52,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
} }
catch (Exception ex) 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

@@ -59,16 +59,14 @@ namespace PepperDash.Essentials.AppServer.Messengers
foreach (var p in systemMonitor.ProgramStatusFeedbackCollection) foreach (var p in systemMonitor.ProgramStatusFeedbackCollection)
{ {
PostStatusMessage(JToken.FromObject(p.Value.ProgramInfo) PostStatusMessage(JToken.FromObject(p.Value.ProgramInfo));
);
} }
} }
private void SendSystemMonitorStatusMessage() private void SendSystemMonitorStatusMessage()
{ {
Debug.Console(1, "Posting System Monitor Status Message.");
// This takes a while, launch a new thread // This takes a while, launch a new thread
Task.Run(() => PostStatusMessage(JToken.FromObject(new SystemMonitorStateMessage Task.Run(() => PostStatusMessage(JToken.FromObject(new SystemMonitorStateMessage
{ {

View File

@@ -2,6 +2,7 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Core.Logging;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.DeviceTypeInterfaces; using PepperDash.Essentials.Core.DeviceTypeInterfaces;
using PepperDash.Essentials.Devices.Common.Cameras; using PepperDash.Essentials.Devices.Common.Cameras;
@@ -111,7 +112,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (Codec is IHasDirectory dirCodec) 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 = PrefixDirectoryFolderItems(directory);
state.CurrentDirectory = directory; state.CurrentDirectory = directory;
@@ -238,7 +239,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
} }
if (Codec is IHasCodecCameras cameraCodec) if (Codec is IHasCodecCameras cameraCodec)
{ {
Debug.Console(2, this, "Adding IHasCodecCameras Actions"); this.LogVerbose("Adding IHasCodecCameras Actions");
cameraCodec.CameraSelected += CameraCodec_CameraSelected; cameraCodec.CameraSelected += CameraCodec_CameraSelected;
@@ -254,7 +255,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (Codec is IHasCodecRoomPresets presetsCodec) if (Codec is IHasCodecRoomPresets presetsCodec)
{ {
Debug.Console(2, this, "Adding IHasCodecRoomPresets Actions"); this.LogVerbose("Adding IHasCodecRoomPresets Actions");
presetsCodec.CodecRoomPresetsListHasChanged += PresetsCodec_CameraPresetsListHasChanged; presetsCodec.CodecRoomPresetsListHasChanged += PresetsCodec_CameraPresetsListHasChanged;
@@ -275,7 +276,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (Codec is IHasCameraAutoMode speakerTrackCodec) if (Codec is IHasCameraAutoMode speakerTrackCodec)
{ {
Debug.Console(2, this, "Adding IHasCameraAutoMode Actions"); this.LogVerbose("Adding IHasCameraAutoMode Actions");
speakerTrackCodec.CameraAutoModeIsOnFeedback.OutputChange += CameraAutoModeIsOnFeedback_OutputChange; speakerTrackCodec.CameraAutoModeIsOnFeedback.OutputChange += CameraAutoModeIsOnFeedback_OutputChange;
@@ -286,7 +287,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (Codec is IHasCameraOff cameraOffCodec) if (Codec is IHasCameraOff cameraOffCodec)
{ {
Debug.Console(2, this, "Adding IHasCameraOff Actions"); this.LogVerbose("Adding IHasCameraOff Actions");
cameraOffCodec.CameraIsOffFeedback.OutputChange += (CameraIsOffFeedback_OutputChange); cameraOffCodec.CameraIsOffFeedback.OutputChange += (CameraIsOffFeedback_OutputChange);
@@ -298,7 +299,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (Codec is IHasCodecSelfView selfViewCodec) if (Codec is IHasCodecSelfView selfViewCodec)
{ {
Debug.Console(2, this, "Adding IHasCodecSelfView Actions"); this.LogVerbose("Adding IHasCodecSelfView Actions");
AddAction("/cameraSelfView", (id, content) => selfViewCodec.SelfViewModeToggle()); AddAction("/cameraSelfView", (id, content) => selfViewCodec.SelfViewModeToggle());
@@ -308,7 +309,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (Codec is IHasCodecLayouts layoutsCodec) if (Codec is IHasCodecLayouts layoutsCodec)
{ {
Debug.Console(2, this, "Adding IHasCodecLayouts Actions"); this.LogVerbose("Adding IHasCodecLayouts Actions");
AddAction("/cameraRemoteView", (id, content) => layoutsCodec.LocalLayoutToggle()); AddAction("/cameraRemoteView", (id, content) => layoutsCodec.LocalLayoutToggle());
@@ -317,7 +318,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
if (Codec is IPasswordPrompt pwCodec) if (Codec is IPasswordPrompt pwCodec)
{ {
Debug.Console(2, this, "Adding IPasswordPrompt Actions"); this.LogVerbose("Adding IPasswordPrompt Actions");
AddAction("/password", (id, content) => AddAction("/password", (id, content) =>
{ {
@@ -334,7 +335,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
(sender, args) => PostReceivingContent(args.BoolValue); (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("/privacyModeOn", (id, content) => Codec.PrivacyModeOn());
AddAction("/privacyModeOff", (id, content) => Codec.PrivacyModeOff()); AddAction("/privacyModeOff", (id, content) => Codec.PrivacyModeOff());
@@ -346,7 +347,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Console(2, this, "Error: {0}", e); this.LogException(e, "Exception adding paths");
} }
} }

View File

@@ -26,6 +26,14 @@
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
<DefineConstants>$(DefineConstants);SERIES4</DefineConstants> <DefineConstants>$(DefineConstants);SERIES4</DefineConstants>
</PropertyGroup> </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> <ItemGroup>
<PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.21.90" /> <PackageReference Include="Crestron.SimplSharp.SDK.ProgramLibrary" Version="2.21.90" />
<PackageReference Include="PepperDashCore" Version="2.0.1" /> <PackageReference Include="PepperDashCore" Version="2.0.1" />

View File

@@ -31,54 +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)
{
bridge.LogInformation("ERROR: Cannot connect bridge. System controller not present");
return;
}
bridge.LogInformation("Linking to parent controller");
parent.AddDeviceMessenger(bridge);
});
return bridge;
}
private static MobileControlSystemController GetMobileControlDevice()
{
var mobileControlList = DeviceManager.AllDevices.OfType<MobileControlSystemController>().ToList();
if (mobileControlList.Count > 1)
{
Debug.LogMessage(LogEventLevel.Warning, "Multiple instances of Mobile Control Server found.");
return null;
}
if (mobileControlList.Count > 0)
{
return mobileControlList[0];
}
Debug.LogMessage(LogEventLevel.Warning, "Mobile Control not enabled for this system");
return null;
}
}
} }

View File

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