Adds SystemMonitroMessenger to bridge between SystemMonitorController and AppServer (untested)

This commit is contained in:
Neil Dorin
2018-12-12 16:23:17 -07:00
parent 676526ed48
commit f6136a8c77
17 changed files with 1853 additions and 1728 deletions

View File

@@ -15,6 +15,7 @@ using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Room.Cotija;
namespace PepperDash.Essentials

View File

@@ -64,8 +64,8 @@ namespace PepperDash.Essentials.AppServer.Messengers
/// </summary>
/// <param name="eisc"></param>
/// <param name="messagePath"></param>
public Ddvc01AtcMessenger(BasicTriList eisc, string messagePath)
: base(messagePath)
public Ddvc01AtcMessenger(string key, BasicTriList eisc, string messagePath)
: base(key, messagePath)
{
EISC = eisc;

View File

@@ -7,6 +7,8 @@ using Crestron.SimplSharp;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core;
using PepperDash.Essentials.Devices.Common.Codec;
using PepperDash.Essentials.Devices.Common.VideoCodec;
@@ -15,8 +17,10 @@ namespace PepperDash.Essentials.AppServer.Messengers
/// <summary>
/// Provides a messaging bridge for a VideoCodecBase
/// </summary>
public abstract class MessengerBase
public abstract class MessengerBase : IKeyed
{
public string Key { get; private set; }
/// <summary>
///
/// </summary>
@@ -28,8 +32,10 @@ namespace PepperDash.Essentials.AppServer.Messengers
///
/// </summary>
/// <param name="codec"></param>
public MessengerBase(string messagePath)
public MessengerBase(string key, string messagePath)
{
Key = key;
if (string.IsNullOrEmpty(messagePath))
throw new ArgumentException("messagePath must not be empty or null");

View File

@@ -0,0 +1,94 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json;
using PepperDash.Essentials.Core.Monitoring;
namespace PepperDash.Essentials.AppServer.Messengers
{
public class SystemMonitorMessenger : MessengerBase
{
public SystemMonitorController SysMon { get; private set; }
public SystemMonitorMessenger(string key, SystemMonitorController sysMon, string messagePath)
: base(key, messagePath)
{
if (sysMon == null)
throw new ArgumentNullException("sysMon");
SysMon = sysMon;
SysMon.SystemMonitorPropertiesChanged += new EventHandler<EventArgs>(SysMon_SystemMonitorPropertiesChanged);
foreach (var p in SysMon.ProgramStatusFeedbackCollection)
{
p.Value.AggregatedProgramInfoFeedback.OutputChange += new EventHandler<PepperDash.Essentials.Core.FeedbackEventArgs>(AggregatedProgramInfoFeedback_OutputChange);
}
}
/// <summary>
/// Posts the program information message
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void AggregatedProgramInfoFeedback_OutputChange(object sender, PepperDash.Essentials.Core.FeedbackEventArgs e)
{
SendProgramInfoStatusMessage(e.StringValue);
}
// Deserializes the program info into an object that can be setn in a status message
void SendProgramInfoStatusMessage(string serializedProgramInfo)
{
var programInfo = JsonConvert.DeserializeObject<ProgramInfo>(serializedProgramInfo);
PostStatusMessage(programInfo);
}
/// <summary>
/// Posts the system monitor properties
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void SysMon_SystemMonitorPropertiesChanged(object sender, EventArgs e)
{
SendSystemMonitorStatusMessage();
}
void SendFullStatusMessage()
{
SendSystemMonitorStatusMessage();
foreach (var p in SysMon.ProgramStatusFeedbackCollection)
{
SendProgramInfoStatusMessage(p.Value.AggregatedProgramInfoFeedback.StringValue);
}
}
void SendSystemMonitorStatusMessage()
{
// This takes a while, launch a new thread
CrestronInvoke.BeginInvoke((o) =>
{
PostStatusMessage(new
{
timeZone = SysMon.TimeZoneFeedback.IntValue,
timeZoneName = SysMon.TimeZoneTextFeedback.StringValue,
ioControllerVersion = SysMon.IOControllerVersionFeedback.StringValue,
snmpVersion = SysMon.SnmpVersionFeedback.StringValue,
bacnetVersion = SysMon.BACnetAppVersionFeedback.StringValue,
controllerVersion = SysMon.ControllerVersionFeedback.StringValue
});
});
}
protected override void CustomRegisterWithAppServer(CotijaSystemController appServerController)
{
AppServerController.AddAction(MessagePath + "/fullStatus", new Action(SendFullStatusMessage));
}
}
}

View File

@@ -26,7 +26,8 @@ namespace PepperDash.Essentials.AppServer.Messengers
///
/// </summary>
/// <param name="codec"></param>
public VideoCodecBaseMessenger(VideoCodecBase codec, string messagePath) : base(messagePath)
public VideoCodecBaseMessenger(string key, VideoCodecBase codec, string messagePath)
: base(key, messagePath)
{
if (codec == null)
throw new ArgumentNullException("codec");

View File

@@ -204,7 +204,8 @@ namespace PepperDash.Essentials.Room.Cotija
SetupFunctions();
SetupFeedbacks();
AtcMessenger = new Ddvc01AtcMessenger(EISC, "/device/audioCodec");
var key = this.Key + "-" + Parent.Key;
AtcMessenger = new Ddvc01AtcMessenger(key, EISC, "/device/audioCodec");
AtcMessenger.RegisterWithAppServer(Parent);
EISC.SigChange += EISC_SigChange;
@@ -384,8 +385,8 @@ namespace PepperDash.Essentials.Room.Cotija
//Room
//if (co.Rooms == null)
// always start fresh in case simpl changed
co.Rooms = new List<EssentialsRoomConfig>();
var rm = new EssentialsRoomConfig();
co.Rooms = new List<DeviceConfig>();
var rm = new DeviceConfig();
if (co.Rooms.Count == 0)
{
Debug.Console(0, this, "Adding room to config");

View File

@@ -95,7 +95,8 @@ namespace PepperDash.Essentials
if (vcRoom != null)
{
var codec = vcRoom.VideoCodec;
VCMessenger = new VideoCodecBaseMessenger(vcRoom.VideoCodec, "/device/videoCodec");
var key = vcRoom.VideoCodec.Key + "-" + parent.Key;
VCMessenger = new VideoCodecBaseMessenger(key, vcRoom.VideoCodec, "/device/videoCodec");
VCMessenger.RegisterWithAppServer(Parent);
// May need to move this or remove this