From cb5087527a65515ef861c07034a21b6871428227 Mon Sep 17 00:00:00 2001 From: Andrew Welker Date: Fri, 26 Jul 2024 07:01:47 -0500 Subject: [PATCH] chore(force-patch): modify log statements and remove print of all devices in device manager --- .../CiscoCodecUserInterface.cs | 68 ++-- .../McVideoCodecTouchpanelController.cs | 290 +++++++++--------- 2 files changed, 174 insertions(+), 184 deletions(-) diff --git a/src/UserInterface/CiscoCodecUserInterface/CiscoCodecUserInterface.cs b/src/UserInterface/CiscoCodecUserInterface/CiscoCodecUserInterface.cs index ffc0c6d..62b3dbb 100644 --- a/src/UserInterface/CiscoCodecUserInterface/CiscoCodecUserInterface.cs +++ b/src/UserInterface/CiscoCodecUserInterface/CiscoCodecUserInterface.cs @@ -4,18 +4,14 @@ using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Devices; -using PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces; using Serilog.Events; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace epi_videoCodec_ciscoExtended.UserInterface.CiscoCodecUserInterface { public class CiscoCodecUserInterface : ReconfigurableDevice, ICiscoCodecUserInterface - { + { public CiscoCodec UisCiscoCodec { get; private set; } public CiscoCodecUserInterfaceConfig ConfigProps { get; } public ICiscoCodecUiExtensionsHandler CiscoCodecUiExtensionsHandler { get; set; } @@ -26,51 +22,51 @@ public class CiscoCodecUserInterface : ReconfigurableDevice, ICiscoCodecUserInte public bool EnableLockoutPoll { get; set; } = false; - public bool LockedOut { get; set; } = false; + public bool LockedOut { get; set; } = false; - #region ParseConfigProps - public T ParseConfigProps(DeviceConfig config) + #region ParseConfigProps + public T ParseConfigProps(DeviceConfig config) { return JsonConvert.DeserializeObject(config.Properties.ToString()); } - #endregion - - #region Custom Activate - private List CustomActivateActions = new List(); - - public override bool CustomActivate() - { - foreach (var action in CustomActivateActions) - { - action(); - } - return base.CustomActivate(); - } - - public void AddCustomActivationAction(Action a) - { - CustomActivateActions.Add(a); - } - #endregion + #endregion + + #region Custom Activate + private List CustomActivateActions = new List(); + + public override bool CustomActivate() + { + foreach (var action in CustomActivateActions) + { + action(); + } + return base.CustomActivate(); + } + + public void AddCustomActivationAction(Action a) + { + CustomActivateActions.Add(a); + } + #endregion public virtual void BuildRoomCombinerHandler() { - RoomCombinerHandler = new RoomCombiner.RoomCombinerHandler(this); - } + RoomCombinerHandler = new RoomCombiner.RoomCombinerHandler(this); + } - public CiscoCodecUserInterface(DeviceConfig config) : base(config) + public CiscoCodecUserInterface(DeviceConfig config) : base(config) { ConfigProps = ParseConfigProps(config); EnableLockoutPoll = ConfigProps.EnableLockoutPoll ?? false; - AddPreActivationAction(PreActivateAction); + AddPreActivationAction(PreActivateAction); BuildRoomCombinerHandler(); - } + } public void PreActivateAction() { - Debug.LogMessage(LogEventLevel.Debug, "[DEBUG] Activating Video Codec UI Extensions", this); - UisCiscoCodec = DeviceManager.GetDeviceForKey(ConfigProps.VideoCodecKey) as CiscoCodec; + Debug.LogMessage(LogEventLevel.Debug, "Activating Video Codec UI Extensions", this); + UisCiscoCodec = DeviceManager.GetDeviceForKey(ConfigProps.VideoCodecKey) as CiscoCodec; if (UisCiscoCodec == null) { @@ -91,10 +87,10 @@ public void PreActivateAction() UisCiscoCodec.IsReadyChange += (s, a) => { if (!UisCiscoCodec.IsReady) return; - var msg = UiExtensions != null ? "[DEBUG] Initializing Video Codec UI Extensions" : "[DEBUG] No Ui Extensions in config"; + var msg = UiExtensions != null ? "Initializing Video Codec UI Extensions" : "No Ui Extensions in config"; Debug.LogMessage(LogEventLevel.Debug, msg, this); UiExtensions.Initialize(this, UisCiscoCodec.EnqueueCommand); - Debug.LogMessage(LogEventLevel.Debug, "[DEBUG] Video Codec UI Extensions Handler Initilizing", this); + Debug.LogMessage(LogEventLevel.Debug, "Video Codec UI Extensions Handler Initilizing", this); }; //return base.CustomActivate(); return; diff --git a/src/UserInterface/CiscoCodecUserInterface/MobileControl/McVideoCodecTouchpanelController.cs b/src/UserInterface/CiscoCodecUserInterface/MobileControl/McVideoCodecTouchpanelController.cs index bcd66a9..df321c6 100644 --- a/src/UserInterface/CiscoCodecUserInterface/MobileControl/McVideoCodecTouchpanelController.cs +++ b/src/UserInterface/CiscoCodecUserInterface/MobileControl/McVideoCodecTouchpanelController.cs @@ -1,10 +1,7 @@ -using Crestron.SimplSharpPro.UI; -using epi_videoCodec_ciscoExtended.UserInterface.CiscoCodecUserInterface; -using PepperDash.Core; +using PepperDash.Core; using PepperDash.Essentials.Core; using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.DeviceTypeInterfaces; -using PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces; using PepperDash.Essentials.Touchpanel; using Serilog.Events; using System; @@ -13,150 +10,147 @@ namespace epi_videoCodec_ciscoExtended.UserInterface.CiscoCodecUserInterface.MobileControl { - public class McVideoCodecTouchpanelController : CiscoCodecUserInterface, IMcCiscoCodecUserInterfaceAppControl, IMobileControlTouchpanelController - { - private readonly McVideoCodecUserInterfaceConfig _props; - private IMobileControlRoomMessenger _bridge; - private IMobileControl Mc; - private string _appUrl; - - public StringFeedback AppUrlFeedback { get; private set; } - private readonly StringFeedback QrCodeUrlFeedback; - private readonly StringFeedback McServerUrlFeedback; - private readonly StringFeedback UserCodeFeedback; - - public FeedbackCollection Feedbacks { get; private set; } - - public string DefaultRoomKey => _props.DefaultRoomKey; - - public bool UseDirectServer => _props.UseDirectServer; - - bool IMobileControlTouchpanelController.ZoomRoomController => false; - - //public BoolFeedback WebViewOpenFeedback => throw new NotImplementedException(); - - private McVideoCodecUserInterfaceRouter _router; - - public McVideoCodecTouchpanelController(DeviceConfig config) : base(config) - { - Debug.LogMessage(LogEventLevel.Debug, "McTouchpanelController Constructor", this); - _props = ParseConfigProps(config); - - AddPostActivationAction(PostActivateSubscribeForMobileControlUpdates); - - AppUrlFeedback = new StringFeedback(() => _appUrl); - QrCodeUrlFeedback = new StringFeedback(() => _bridge?.QrCodeUrl); - McServerUrlFeedback = new StringFeedback(() => _bridge?.McServerUrl); - UserCodeFeedback = new StringFeedback(() => _bridge?.UserCode); - - Feedbacks = new FeedbackCollection - { - AppUrlFeedback, QrCodeUrlFeedback, McServerUrlFeedback, UserCodeFeedback - }; - } - public override bool CustomActivate() - { - Debug.LogMessage(LogEventLevel.Debug, "[McTouchpanelController] Activate", this); - Mc = DeviceManager.AllDevices.OfType().FirstOrDefault(); - - if (Mc == null) - { - return base.CustomActivate(); - } - - var messenger = new McVideoCodecUserInterfaceControlMessenger(string.Format("appControlMessenger-{0}", Key), string.Format("/device/{0}", Key), this); - - Mc.AddDeviceMessenger(messenger); - - //Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, $"mc.ClientAppUrl: {Mc.ClientAppUrl.MaskQParamTokenInUrl()}", this); - - return base.CustomActivate(); - } - - private void PostActivateSubscribeForMobileControlUpdates() - { - try - { - - Debug.LogMessage(LogEventLevel.Debug, "[McTouchpanelController] SubscribeForMobileControlUpdates", this); - foreach (var dev in DeviceManager.AllDevices) - { - Debug.Console(0, this, $"{dev.Key}:{dev.GetType().Name}"); - } - - Debug.LogMessage(LogEventLevel.Debug, $"[McTouchpanelController] GetBridge. DefaultRoomKey: {_props.DefaultRoomKey}", this); - if (Mc == null) - { - Debug.LogMessage(LogEventLevel.Debug, "[McTouchpanelController] Mc is null", this); - return; - } - var bridge = Mc.GetRoomMessenger(_props.DefaultRoomKey); - if (bridge == null) - { - Debug.LogMessage(LogEventLevel.Debug, $"[McTouchpanelController] No Mobile Control bridge for {_props.DefaultRoomKey} found ", this); - return; - } - Debug.LogMessage(LogEventLevel.Debug, $"[McTouchpanelController] Got Bridge: {bridge.RoomName}", this); + public class McVideoCodecTouchpanelController : CiscoCodecUserInterface, IMcCiscoCodecUserInterfaceAppControl, IMobileControlTouchpanelController + { + private readonly McVideoCodecUserInterfaceConfig _props; + private IMobileControlRoomMessenger _bridge; + private IMobileControl Mc; + private string _appUrl; + + public StringFeedback AppUrlFeedback { get; private set; } + private readonly StringFeedback QrCodeUrlFeedback; + private readonly StringFeedback McServerUrlFeedback; + private readonly StringFeedback UserCodeFeedback; + + public FeedbackCollection Feedbacks { get; private set; } + + public string DefaultRoomKey => _props.DefaultRoomKey; + + public bool UseDirectServer => _props.UseDirectServer; + + bool IMobileControlTouchpanelController.ZoomRoomController => false; + + //public BoolFeedback WebViewOpenFeedback => throw new NotImplementedException(); + + private McVideoCodecUserInterfaceRouter _router; + + public McVideoCodecTouchpanelController(DeviceConfig config) : base(config) + { + Debug.LogMessage(LogEventLevel.Debug, "McTouchpanelController Constructor", this); + _props = ParseConfigProps(config); + + AddPostActivationAction(PostActivateSubscribeForMobileControlUpdates); + + AppUrlFeedback = new StringFeedback(() => _appUrl); + QrCodeUrlFeedback = new StringFeedback(() => _bridge?.QrCodeUrl); + McServerUrlFeedback = new StringFeedback(() => _bridge?.McServerUrl); + UserCodeFeedback = new StringFeedback(() => _bridge?.UserCode); + + Feedbacks = new FeedbackCollection + { + AppUrlFeedback, QrCodeUrlFeedback, McServerUrlFeedback, UserCodeFeedback + }; + } + public override bool CustomActivate() + { + Debug.LogMessage(LogEventLevel.Debug, "Activate", this); + Mc = DeviceManager.AllDevices.OfType().FirstOrDefault(); + + if (Mc == null) + { + return base.CustomActivate(); + } + + var messenger = new McVideoCodecUserInterfaceControlMessenger(string.Format("appControlMessenger-{0}", Key), string.Format("/device/{0}", Key), this); + + Mc.AddDeviceMessenger(messenger); + + //Debug.LogMessage(Serilog.Events.LogEventLevel.Debug, $"mc.ClientAppUrl: {Mc.ClientAppUrl.MaskQParamTokenInUrl()}", this); + + return base.CustomActivate(); + } + + private void PostActivateSubscribeForMobileControlUpdates() + { + try + { + + Debug.LogMessage(LogEventLevel.Debug, "SubscribeForMobileControlUpdates", this); + + Debug.LogMessage(LogEventLevel.Debug, "GetBridge. DefaultRoomKey: {defaultRoomKey}", this, _props.DefaultRoomKey); + if (Mc == null) + { + Debug.LogMessage(LogEventLevel.Debug, "Mc is null", this); + return; + } + var bridge = Mc.GetRoomMessenger(_props.DefaultRoomKey); + if (bridge == null) + { + Debug.LogMessage(LogEventLevel.Debug, "No Mobile Control bridge for {defaultRoomKey} found ", this, _props.DefaultRoomKey); + return; + } + Debug.LogMessage(LogEventLevel.Debug, "Got Bridge: {roomName}", this, bridge.RoomName); _bridge = bridge; - Debug.LogMessage(LogEventLevel.Debug, $"[McTouchpanelController] Setting AppUrl", this); - - Debug.LogMessage(LogEventLevel.Debug, $"[McTouchpanelController] Mobile Control Room Bridge Found {_bridge.Key}", this); - - Debug.LogMessage(LogEventLevel.Debug, "[McTouchpanelController] Subscribing to Mobile Control Events: UserCodeChanged", this); - _bridge.UserCodeChanged += UpdateFeedbacks; - - Debug.LogMessage(LogEventLevel.Debug, "[McTouchpanelController] Subscribing to Mobile Control Events: AppUrlChanged", this); - - //SetAppUrl here fixing AppUrlFeedback.StringValue null after initial event - _bridge.AppUrlChanged += (s, a) => { Debug.Console(0, this, "[McTouchpanelController] AppURL changed"); UpdateFeedbacks(s, a); - SetAppUrl(_bridge.AppUrl); - }; - - Debug.LogMessage(LogEventLevel.Debug, "[McTouchpanelController] Building McVideoCodecUserInterfaceRouter", this); - _router = new McVideoCodecUserInterfaceRouter(this, _bridge, _props); - _router.Activate(this); - Debug.LogMessage(LogEventLevel.Debug, "[McTouchpanelController] SubscribeForMobileControlUpdates success", this); - } - catch (Exception e) - { - Debug.LogMessage(e, "SubscribeForMobileControlUpdates Error", this); - Debug.LogMessage(LogEventLevel.Debug, e.StackTrace, this); - } - } - - public void SetAppUrl(string url) - { - try - { - Debug.LogMessage(LogEventLevel.Debug, $"Setting AppUrl to: {url}", this); - _appUrl = url; - AppUrlFeedback.FireUpdate(); - } - catch (Exception e) - { - Debug.LogMessage(e, "SetAppUrl Error", this); - } - } - - private void UpdateFeedbacks(object sender, EventArgs args) - { - UpdateFeedbacks(); - } - - private void UpdateFeedbacks() - { - foreach (var feedback in Feedbacks) { feedback.FireUpdate(); } - } - - public void CloseWebViewController() - { - _router.ClearCiscoCodecUiWebViewController(); - } - - public void CloseWebViewOsd() - { - _router.ClearCiscoCodecUiWebViewOsd(); - } - } + Debug.LogMessage(LogEventLevel.Debug, "Setting AppUrl", this); + + Debug.LogMessage(LogEventLevel.Debug, "Mobile Control Room Bridge Found {bridgeKey}", this, _bridge?.Key); + + Debug.LogMessage(LogEventLevel.Debug, "Subscribing to Mobile Control Events: UserCodeChanged", this); + _bridge.UserCodeChanged += UpdateFeedbacks; + + Debug.LogMessage(LogEventLevel.Debug, "Subscribing to Mobile Control Events: AppUrlChanged", this); + + //SetAppUrl here fixing AppUrlFeedback.StringValue null after initial event + _bridge.AppUrlChanged += (s, a) => + { + Debug.LogMessage(LogEventLevel.Information, "AppURL changed", this); UpdateFeedbacks(s, a); + SetAppUrl(_bridge.AppUrl); + }; + + Debug.LogMessage(LogEventLevel.Debug, "Building McVideoCodecUserInterfaceRouter", this); + _router = new McVideoCodecUserInterfaceRouter(this, _bridge, _props); + _router.Activate(this); + Debug.LogMessage(LogEventLevel.Debug, "SubscribeForMobileControlUpdates success", this); + } + catch (Exception e) + { + Debug.LogMessage(e, "SubscribeForMobileControlUpdates Error", this); + } + } + + public void SetAppUrl(string url) + { + try + { + Debug.LogMessage(LogEventLevel.Debug, "Setting AppUrl to: {url}", this, url); + _appUrl = url; + AppUrlFeedback.FireUpdate(); + } + catch (Exception e) + { + Debug.LogMessage(e, "SetAppUrl Error", this); + } + } + + private void UpdateFeedbacks(object sender, EventArgs args) + { + UpdateFeedbacks(); + } + + private void UpdateFeedbacks() + { + foreach (var feedback in Feedbacks) { feedback.FireUpdate(); } + } + + public void CloseWebViewController() + { + _router.ClearCiscoCodecUiWebViewController(); + } + + public void CloseWebViewOsd() + { + _router.ClearCiscoCodecUiWebViewOsd(); + } + } }