mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-08-31 19:08:29 +00:00
Enhance logging and mobile control functionality
- Added error log level change notification in Debug.cs. - Updated appdebug command usage to include sink options and timeout parameters in Debug.cs. - Implemented AddDefaultMessengersForDevice method in IMobileControl interface for better messenger registration. - Modified EssentialsDevice to create mobile control messengers based on available interfaces. - Introduced MessengerFactoryRegistry to streamline messenger creation for various device types. - Refactored MobileControlSystemController to utilize the new messenger registration system and removed redundant setup methods. Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
parent
b0525b0f97
commit
bc70aa629c
5 changed files with 445 additions and 799 deletions
|
|
@ -1,6 +1,8 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
||||
|
||||
|
|
@ -68,4 +70,19 @@ public interface IMobileControl : IKeyed
|
|||
/// <param name="key">messenger key to find</param>
|
||||
/// <returns>Messenger if found, null otherwise</returns>
|
||||
IMobileControlRoomMessenger GetRoomMessenger(string key);
|
||||
|
||||
/// <summary>
|
||||
/// Registers default mobile-control messengers for the given device based on the
|
||||
/// interfaces it implements. When <paramref name="interfaces"/> is <c>null</c> all
|
||||
/// applicable messengers are added; when a list is supplied only messengers whose
|
||||
/// registry entry type appears in that list are added.
|
||||
/// </summary>
|
||||
/// <param name="device">The device to add messengers for.</param>
|
||||
/// <param name="interfaces">
|
||||
/// Optional filter. Pass <c>typeof(IBasicVolumeControls)</c>,
|
||||
/// <c>typeof(IHasInputs<string>)</c>, etc. to restrict which messengers are
|
||||
/// created. Pass <c>null</c> (or omit the argument) to add all applicable messengers.
|
||||
/// </param>
|
||||
void AddDefaultMessengersForDevice(EssentialsDevice device, IEnumerable<Type> interfaces = null);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
||||
using Serilog.Events;
|
||||
|
||||
namespace PepperDash.Essentials.Core;
|
||||
|
|
@ -84,7 +86,10 @@ public abstract class EssentialsDevice : Device
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Override this method to perform any initialization that requires all devices to be activated. This method is called automatically after the DeviceManager.AllDevicesActivated event is fired, and should not be called directly.
|
||||
/// Override this method to perform any initialization that requires all devices to be activated.
|
||||
/// This method is called automatically after the DeviceManager.AllDevicesActivated event is fired,
|
||||
/// and should not be called directly.
|
||||
/// If this is not called then no Mobile Control messengers will be created.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected override bool CustomActivate()
|
||||
|
|
@ -99,7 +104,21 @@ public abstract class EssentialsDevice : Device
|
|||
/// </summary>
|
||||
protected virtual void CreateMobileControlMessengers()
|
||||
{
|
||||
var controller = DeviceManager.AllDevices
|
||||
.OfType<IMobileControl>()
|
||||
.FirstOrDefault();
|
||||
|
||||
if (controller == null)
|
||||
{
|
||||
Debug.LogMessage(
|
||||
LogEventLevel.Warning,
|
||||
this,
|
||||
"No IMobileControl controller found; default messengers will not be registered for {key}",
|
||||
Key);
|
||||
return;
|
||||
}
|
||||
|
||||
controller.AddDefaultMessengersForDevice(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue