mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-09 01:35:02 +00:00
Some constructors for messengers were taking Device rather than the specific type they needed.
59 lines
1.4 KiB
C#
59 lines
1.4 KiB
C#
using Newtonsoft.Json;
|
|
using PepperDash.Core;
|
|
using PepperDash.Essentials.Core.CrestronIO;
|
|
using System;
|
|
|
|
namespace PepperDash.Essentials.AppServer.Messengers
|
|
{
|
|
public class ISwitchedOutputMessenger : MessengerBase
|
|
{
|
|
|
|
private readonly ISwitchedOutput device;
|
|
|
|
public ISwitchedOutputMessenger(string key, ISwitchedOutput device, string messagePath)
|
|
: base(key, messagePath, device as IKeyName)
|
|
{
|
|
this.device = device;
|
|
}
|
|
|
|
protected override void RegisterActions()
|
|
{
|
|
base.RegisterActions();
|
|
|
|
AddAction("/fullStatus", (id, content) => SendFullStatus());
|
|
|
|
AddAction("/on", (id, content) =>
|
|
{
|
|
|
|
device.On();
|
|
|
|
});
|
|
|
|
AddAction("/off", (id, content) =>
|
|
{
|
|
|
|
device.Off();
|
|
|
|
});
|
|
|
|
device.OutputIsOnFeedback.OutputChange += new EventHandler<Core.FeedbackEventArgs>((o, a) => SendFullStatus());
|
|
}
|
|
|
|
private void SendFullStatus()
|
|
{
|
|
var state = new ISwitchedOutputStateMessage
|
|
{
|
|
IsOn = device.OutputIsOnFeedback.BoolValue
|
|
};
|
|
|
|
PostStatusMessage(state);
|
|
}
|
|
}
|
|
|
|
public class ISwitchedOutputStateMessage : DeviceStateMessageBase
|
|
{
|
|
[JsonProperty("isOn")]
|
|
public bool IsOn { get; set; }
|
|
}
|
|
}
|