mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-29 04:15:00 +00:00
In order to solve some dependency issues that keep cropping up, MC should be moved back into the Essentials repo and loaded automatically on startup. This will allow for all plugins that use the MC Messengers library to use the same version without fear of overwriting a dll due to loading of plugin libraries.
102 lines
3.3 KiB
C#
102 lines
3.3 KiB
C#
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using PepperDash.Essentials.Core;
|
|
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
|
using TwoWayDisplayBase = PepperDash.Essentials.Devices.Common.Displays.TwoWayDisplayBase;
|
|
|
|
namespace PepperDash.Essentials.AppServer.Messengers
|
|
{
|
|
public class TwoWayDisplayBaseMessenger : MessengerBase
|
|
{
|
|
private readonly TwoWayDisplayBase _display;
|
|
|
|
public TwoWayDisplayBaseMessenger(string key, string messagePath) : base(key, messagePath)
|
|
{
|
|
}
|
|
|
|
public TwoWayDisplayBaseMessenger(string key, string messagePath, TwoWayDisplayBase display)
|
|
: this(key, messagePath)
|
|
{
|
|
_display = display;
|
|
}
|
|
|
|
#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();
|
|
|
|
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
|
|
}
|
|
|
|
public class TwoWayDisplayBaseStateMessage : DeviceStateMessageBase
|
|
{
|
|
//[JsonProperty("powerState", NullValueHandling = NullValueHandling.Ignore)]
|
|
//public bool? PowerState { get; set; }
|
|
|
|
[JsonProperty("currentInput", NullValueHandling = NullValueHandling.Ignore)]
|
|
public string CurrentInput { get; set; }
|
|
}
|
|
} |