mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-06 08:16:11 +00:00
feat: remove DisplayBase from Core
This commit is contained in:
@@ -1,61 +0,0 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.AppServer;
|
||||
using PepperDash.Essentials.AppServer.Messengers;
|
||||
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using DisplayBase = PepperDash.Essentials.Core.DisplayBase;
|
||||
|
||||
namespace PepperDash.Essentials.Room.MobileControl
|
||||
{
|
||||
public class CoreDisplayBaseMessenger: MessengerBase
|
||||
{
|
||||
private readonly DisplayBase display;
|
||||
|
||||
public CoreDisplayBaseMessenger(string key, string messagePath, DisplayBase device) : base(key, messagePath, device)
|
||||
{
|
||||
display = device;
|
||||
}
|
||||
|
||||
protected override void RegisterActions()
|
||||
{
|
||||
base.RegisterActions();
|
||||
|
||||
/* AddAction("/powerOn", (id, content) => display.PowerOn());
|
||||
AddAction("/powerOff", (id, content) => display.PowerOff());
|
||||
AddAction("/powerToggle", (id, content) => display.PowerToggle());*/
|
||||
|
||||
AddAction("/inputSelect", (id, content) =>
|
||||
{
|
||||
var s = content.ToObject<MobileControlSimpleContent<string>>();
|
||||
|
||||
var inputPort = display.InputPorts.FirstOrDefault(i => i.Key == s.Value);
|
||||
|
||||
if (inputPort == null)
|
||||
{
|
||||
Debug.Console(1, "No input named {0} found for device {1}", s, display.Key);
|
||||
return;
|
||||
}
|
||||
|
||||
display.ExecuteSwitch(inputPort.Selector);
|
||||
});
|
||||
|
||||
AddAction("/inputs", (id, content) =>
|
||||
{
|
||||
var inputsList = display.InputPorts.Select(p => p.Key).ToList();
|
||||
|
||||
var messageObject = new MobileControlMessage
|
||||
{
|
||||
Type = MessagePath + "/inputs",
|
||||
Content = JToken.FromObject(new
|
||||
{
|
||||
inputKeys = inputsList,
|
||||
})
|
||||
};
|
||||
|
||||
AppServerController.SendMessageObject(messageObject);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
|
||||
|
||||
namespace PepperDash.Essentials.AppServer.Messengers
|
||||
{
|
||||
public class CoreTwoWayDisplayBaseMessenger : MessengerBase
|
||||
{
|
||||
private readonly TwoWayDisplayBase _display;
|
||||
|
||||
public CoreTwoWayDisplayBaseMessenger(string key, string messagePath, Device display)
|
||||
: base(key, messagePath, display)
|
||||
{
|
||||
_display = display as TwoWayDisplayBase;
|
||||
}
|
||||
|
||||
#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();
|
||||
if (_display == null)
|
||||
{
|
||||
Debug.Console(0, this, $"Unable to register TwoWayDisplayBase messenger {Key}");
|
||||
return;
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@
|
||||
<RootNamespace>PepperDash.Essentials.AppServer</RootNamespace>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<AssemblyTitle>mobile-control-messengers</AssemblyTitle>
|
||||
<AssemblyName>mobile-control-messengers</AssemblyName>
|
||||
<Product>mobile-control-messengers</Product>
|
||||
<Copyright>Copyright © 2024</Copyright>
|
||||
<OutputPath>bin\$(Configuration)\</OutputPath>
|
||||
|
||||
Reference in New Issue
Block a user