Skip to content

Commit f80aa95

Browse files
ndorinCopilot
andcommitted
Refactor audio codec and display messaging interfaces
- Introduced IDialerCallStatus interface to streamline call status handling in audio codecs. - Updated AudioCodecBase to implement IDialerCallStatus, providing a common structure for call status events. - Added IDisplayCurrentInput interface for display devices to expose current input information. - Created corresponding messenger classes for IDialerCallStatus and IDisplayCurrentInput to facilitate communication. - Implemented CameraControlMessenger for camera devices to manage camera controls and presets. - Added IWarmingCoolingMessenger for warming and cooling devices to handle status updates. - Updated MessengerFactoryRegistry to register new messenger classes and ensure proper device messaging. - Cleaned up CameraBase and removed unnecessary comments and whitespace in various files. Co-authored-by: Copilot <copilot@github.com>
1 parent dfc1d2b commit f80aa95

14 files changed

Lines changed: 185 additions & 60 deletions

File tree

src/PepperDash.Essentials.Devices.Common/AudioCodec/AudioCodecBase.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@
66

77
namespace PepperDash.Essentials.Devices.Common.AudioCodec;
88

9-
public abstract class AudioCodecBase : EssentialsDevice, IHasDialer, IUsageTracking, IAudioCodecInfo
9+
/// <summary>
10+
/// Base class for audio codecs. Provides common properties and methods for audio codecs,
11+
/// as well as a common implementation of IDialerCallStatus to allow the AudioCodecBaseMessenger
12+
/// to get call status information without requiring the full AudioCodecBase class.
13+
/// This is useful for devices that have dialer call status information but do not need to implement
14+
/// the full AudioCodecBase class.
15+
/// </summary>
16+
public abstract class AudioCodecBase : EssentialsDevice, IDialerCallStatus, IUsageTracking, IAudioCodecInfo
1017
{
11-
18+
/// <inheritdoc />
1219
public event EventHandler<CodecCallStatusItemChangeEventArgs> CallStatusChange;
1320

21+
/// <inheritdoc />
1422
public AudioCodecInfo CodecInfo { get; protected set; }
1523

1624
#region IUsageTracking Members
@@ -41,8 +49,14 @@ public bool IsInCall
4149
}
4250

4351
// In most cases only a single call can be active
52+
/// <inheritdoc />
4453
public List<CodecActiveCallItem> ActiveCalls { get; set; }
4554

55+
/// <summary>
56+
/// Constructor
57+
/// </summary>
58+
/// <param name="key"></param>
59+
/// <param name="name"></param>
4660
public AudioCodecBase(string key, string name)
4761
: base(key, name)
4862
{
@@ -83,16 +97,22 @@ protected void OnCallStatusChange(CodecActiveCallItem item)
8397

8498
#region IHasDialer Members
8599

100+
/// <inheritdoc />
86101
public abstract void Dial(string number);
87102

103+
/// <inheritdoc />
88104
public abstract void EndCall(CodecActiveCallItem activeCall);
89105

106+
/// <inheritdoc />
90107
public abstract void EndAllCalls();
91108

109+
/// <inheritdoc />
92110
public abstract void AcceptCall(CodecActiveCallItem item);
93111

112+
94113
public abstract void RejectCall(CodecActiveCallItem item);
95114

115+
96116
public abstract void SendDtmf(string digit);
97117

98118
#endregion
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System.Collections.Generic;
2+
using PepperDash.Essentials.Devices.Common.Codec;
3+
4+
namespace PepperDash.Essentials.Devices.Common.AudioCodec;
5+
6+
/// <summary>
7+
/// Defines the contract for a device that has dialer call status information. This is used to provide a common interface for the AudioCodecBaseMessenger to get call status information without requiring the full AudioCodecBase class
8+
/// </summary>
9+
public interface IDialerCallStatus : IHasDialer
10+
{
11+
/// <summary>
12+
///
13+
/// </summary>
14+
AudioCodecInfo CodecInfo { get; }
15+
16+
/// <summary>
17+
/// Gets or sets the list of active calls for the device.
18+
/// </summary>
19+
List<CodecActiveCallItem> ActiveCalls { get; set; }
20+
}

src/PepperDash.Essentials.Devices.Common/Cameras/CameraBase.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-

2-
3-
using System;
1+
using System;
42
using System.Collections.Generic;
53
using System.Linq;
64
using Crestron.SimplSharpPro.DeviceSupport;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using PepperDash.Core;
2+
3+
namespace PepperDash.Essentials.Core.DeviceTypeInterfaces
4+
{
5+
/// <summary>
6+
/// Defines the contract for a display device that has current input information. This is used to provide a common interface for the TwoWayDisplayBaseMessenger to get current input information without requiring the full TwoWayDisplayBase class
7+
/// </summary>
8+
public interface IDisplayCurrentInput : IKeyName
9+
{
10+
/// <summary>
11+
/// Gets the Current Input feedback for the display device.
12+
/// </summary>
13+
StringFeedback CurrentInputFeedback { get; }
14+
}

src/PepperDash.Essentials.MobileControl.Messengers/DeviceTypeExtensions/DisplayBaseMessenger.cs renamed to src/PepperDash.Essentials.MobileControl.Messengers/DeviceTypeExtensions/IRoutingSinkWithSwitchingMessenger.cs

File renamed without changes.

src/PepperDash.Essentials.MobileControl.Messengers/Messengers/CameraBaseMessenger.cs renamed to src/PepperDash.Essentials.MobileControl.Messengers/Messengers/CameraControlMessenger.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
1111
/// <summary>
1212
/// Messenger for a CameraBase device
1313
/// </summary>
14-
public class CameraBaseMessenger<T> : MessengerBase where T : IKeyed
14+
public class CameraControlMessenger<T> : MessengerBase where T : IKeyed
1515
{
1616
/// <summary>
1717
/// Gets or sets the Camera
@@ -24,7 +24,7 @@ public class CameraBaseMessenger<T> : MessengerBase where T : IKeyed
2424
/// <param name="key"></param>
2525
/// <param name="camera"></param>
2626
/// <param name="messagePath"></param>
27-
public CameraBaseMessenger(string key, T camera, string messagePath)
27+
public CameraControlMessenger(string key, T camera, string messagePath)
2828
: base(key, messagePath, camera as IKeyName)
2929
{
3030
if (camera == null)

src/PepperDash.Essentials.MobileControl.Messengers/Messengers/AudioCodecBaseMessenger.cs renamed to src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IDialerCallStatusMessenger.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
11
using System;
22
using System.Linq;
33
using Newtonsoft.Json.Linq;
4+
using PepperDash.Core;
45
using PepperDash.Essentials.Devices.Common.AudioCodec;
56
using PepperDash.Essentials.Devices.Common.Codec;
67

78
namespace PepperDash.Essentials.AppServer.Messengers
89
{
910
/// <summary>
10-
/// Provides a messaging bridge for an AudioCodecBase device
11+
/// Provides a messaging bridge for an IDialerCallStatus device
1112
/// </summary>
12-
public class AudioCodecBaseMessenger : MessengerBase
13+
public class IDialerCallStatusMessenger : MessengerBase
1314
{
1415
/// <summary>
1516
/// Device being bridged
1617
/// </summary>
17-
public AudioCodecBase Codec { get; private set; }
18+
public IDialerCallStatus Codec { get; private set; }
1819

1920
/// <summary>
2021
/// Constuctor
2122
/// </summary>
2223
/// <param name="key"></param>
2324
/// <param name="codec"></param>
2425
/// <param name="messagePath"></param>
25-
public AudioCodecBaseMessenger(string key, AudioCodecBase codec, string messagePath)
26-
: base(key, messagePath, codec)
26+
public IDialerCallStatusMessenger(string key, IDialerCallStatus codec, string messagePath)
27+
: base(key, messagePath, codec as IKeyName)
2728
{
2829
Codec = codec ?? throw new ArgumentNullException("codec");
2930
codec.CallStatusChange += Codec_CallStatusChange;

src/PepperDash.Essentials.MobileControl.Messengers/Messengers/TwoWayDisplayBaseMessenger.cs renamed to src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IDisplayCurrentInputMessenger.cs

Lines changed: 11 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
using Newtonsoft.Json;
22
using Newtonsoft.Json.Linq;
3+
using PepperDash.Core;
34
using PepperDash.Essentials.Core;
5+
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
46
using PepperDash.Essentials.Devices.Common.Displays;
57

68
namespace PepperDash.Essentials.AppServer.Messengers
79
{
810
/// <summary>
9-
/// Represents a TwoWayDisplayBaseMessenger
11+
/// Represents a messenger for a display device that has current input information.
1012
/// </summary>
11-
public class TwoWayDisplayBaseMessenger : MessengerBase
13+
public class IDisplayCurrentInputMessenger : MessengerBase
1214
{
13-
private readonly TwoWayDisplayBase _display;
15+
private readonly IDisplayCurrentInput _display;
1416

1517
/// <summary>
16-
/// Initializes a new instance of the <see cref="TwoWayDisplayBaseMessenger"/> class.
18+
/// Initializes a new instance of the <see cref="IDisplayCurrentInputMessenger"/> class.
1719
/// </summary>
1820
/// <param name="key"></param>
1921
/// <param name="messagePath"></param>
2022
/// <param name="display"></param>
21-
public TwoWayDisplayBaseMessenger(string key, string messagePath, TwoWayDisplayBase display)
22-
: base(key, messagePath, display)
23+
public IDisplayCurrentInputMessenger(string key, string messagePath, IDisplayCurrentInput display)
24+
: base(key, messagePath, display as IKeyName)
2325
{
2426
_display = display;
2527
}
@@ -31,9 +33,8 @@ public TwoWayDisplayBaseMessenger(string key, string messagePath, TwoWayDisplayB
3133
/// </summary>
3234
public void SendFullStatus(string id = null)
3335
{
34-
var messageObj = new TwoWayDisplayBaseStateMessage
36+
var messageObj = new CurrentInputStateMessage
3537
{
36-
//PowerState = _display.PowerIsOnFeedback.BoolValue,
3738
CurrentInput = _display.CurrentInputFeedback.StringValue
3839
};
3940

@@ -47,11 +48,9 @@ protected override void RegisterActions()
4748

4849
AddAction("/fullStatus", (id, content) => SendFullStatus(id));
4950

50-
AddAction("/displayStatus", (id, content) => SendFullStatus(id));
51+
AddAction("/currentInputStatus", (id, content) => SendFullStatus(id));
5152

5253
_display.CurrentInputFeedback.OutputChange += CurrentInputFeedbackOnOutputChange;
53-
_display.IsCoolingDownFeedback.OutputChange += IsCoolingFeedbackOnOutputChange;
54-
_display.IsWarmingUpFeedback.OutputChange += IsWarmingFeedbackOnOutputChange;
5554
}
5655

5756
private void CurrentInputFeedbackOnOutputChange(object sender, FeedbackEventArgs feedbackEventArgs)
@@ -61,24 +60,6 @@ private void CurrentInputFeedbackOnOutputChange(object sender, FeedbackEventArgs
6160
currentInput = feedbackEventArgs.StringValue
6261
})
6362
);
64-
}
65-
66-
private void IsWarmingFeedbackOnOutputChange(object sender, FeedbackEventArgs feedbackEventArgs)
67-
{
68-
PostStatusMessage(JToken.FromObject(new
69-
{
70-
isWarming = feedbackEventArgs.BoolValue
71-
})
72-
);
73-
}
74-
75-
private void IsCoolingFeedbackOnOutputChange(object sender, FeedbackEventArgs feedbackEventArgs)
76-
{
77-
PostStatusMessage(JToken.FromObject(new
78-
{
79-
isCooling = feedbackEventArgs.BoolValue
80-
})
81-
);
8263

8364

8465
}
@@ -89,7 +70,7 @@ private void IsCoolingFeedbackOnOutputChange(object sender, FeedbackEventArgs fe
8970
/// <summary>
9071
/// Represents a TwoWayDisplayBaseStateMessage
9172
/// </summary>
92-
public class TwoWayDisplayBaseStateMessage : DeviceStateMessageBase
73+
public class CurrentInputStateMessage : DeviceStateMessageBase
9374
{
9475
//[JsonProperty("powerState", NullValueHandling = NullValueHandling.Ignore)]
9576
//public bool? PowerState { get; set; }

src/PepperDash.Essentials.MobileControl.Messengers/Messengers/LightingBaseMessenger.cs renamed to src/PepperDash.Essentials.MobileControl.Messengers/Messengers/ILightingScenesMessenger.cs

File renamed without changes.

src/PepperDash.Essentials.MobileControl.Messengers/Messengers/RoomEventScheduleMessenger.cs renamed to src/PepperDash.Essentials.MobileControl.Messengers/Messengers/IRoomEventScheduleMessenger.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ namespace PepperDash.Essentials.AppServer.Messengers;
1111
/// <summary>
1212
/// Represents a RoomEventScheduleMessenger
1313
/// </summary>
14-
public class RoomEventScheduleMessenger : MessengerBase
14+
public class IRoomEventScheduleMessenger : MessengerBase
1515
{
1616
private readonly IRoomEventSchedule _room;
1717

1818
/// <summary>
19-
/// Initializes a new instance of the <see cref="RoomEventScheduleMessenger"/> class.
19+
/// Initializes a new instance of the <see cref="IRoomEventScheduleMessenger"/> class.
2020
/// </summary>
2121
/// <param name="key"></param>
2222
/// <param name="messagePath"></param>
2323
/// <param name="room"></param>
24-
public RoomEventScheduleMessenger(string key, string messagePath, IRoomEventSchedule room)
24+
public IRoomEventScheduleMessenger(string key, string messagePath, IRoomEventSchedule room)
2525
: base(key, messagePath, room as IKeyName)
2626
{
2727
_room = room;

0 commit comments

Comments
 (0)