Merged in JTA and about 1000 other things! (pull request #5)

JTA
This commit is contained in:
Jason Alborough
2019-01-21 18:20:55 +00:00
committed by Heath Volmer
57 changed files with 9285 additions and 7018 deletions

View File

@@ -24,6 +24,8 @@ namespace PepperDash.Essentials
{ {
WebSocketClient WSClient; WebSocketClient WSClient;
//bool LinkUp;
/// <summary> /// <summary>
/// Prevents post operations from stomping on each other and getting lost /// Prevents post operations from stomping on each other and getting lost
/// </summary> /// </summary>
@@ -45,6 +47,8 @@ namespace PepperDash.Essentials
long ServerReconnectInterval = 5000; long ServerReconnectInterval = 5000;
DateTime LastAckMessage;
string SystemUuid; string SystemUuid;
List<CotijaBridgeBase> RoomBridges = new List<CotijaBridgeBase>(); List<CotijaBridgeBase> RoomBridges = new List<CotijaBridgeBase>();
@@ -65,6 +69,9 @@ namespace PepperDash.Essentials
public CotijaSystemController(string key, string name, CotijaConfig config) : base(key, name) public CotijaSystemController(string key, string name, CotijaConfig config) : base(key, name)
{ {
Config = config; Config = config;
SystemUuid = ConfigReader.ConfigObject.SystemUuid;
Debug.Console(0, this, "Mobile UI controller initializing for server:{0}", config.ServerUrl); Debug.Console(0, this, "Mobile UI controller initializing for server:{0}", config.ServerUrl);
CrestronConsole.AddNewConsoleCommand(AuthorizeSystem, CrestronConsole.AddNewConsoleCommand(AuthorizeSystem,
@@ -83,10 +90,46 @@ namespace PepperDash.Essentials
CrestronConsole.AddNewConsoleCommand(TestHttpRequest, CrestronConsole.AddNewConsoleCommand(TestHttpRequest,
"mobilehttprequest", "Tests an HTTP get to URL given", ConsoleAccessLevelEnum.AccessOperator); "mobilehttprequest", "Tests an HTTP get to URL given", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(PrintActionDictionaryPaths, "showactionpaths", "Prints the paths in teh Action Dictionary", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(PrintActionDictionaryPaths, "mobileshowactionpaths",
"Prints the paths in the Action Dictionary", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s => ConnectWebsocketClient(), "mobileconnect",
"Forces connect of websocket", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s => CleanUpWebsocketClient(), "mobiledisco",
"Disconnects websocket", ConsoleAccessLevelEnum.AccessOperator);
CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler); CrestronEnvironment.ProgramStatusEventHandler += new ProgramStatusEventHandler(CrestronEnvironment_ProgramStatusEventHandler);
CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler);
}
/// <summary>
/// If config rooms is empty or null then go
/// </summary>
/// <returns></returns>
public override bool CustomActivate()
{
if (ConfigReader.ConfigObject.Rooms == null || ConfigReader.ConfigObject.Rooms.Count == 0)
{
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Config contains no rooms. Registering with Server.");
RegisterSystemToServer();
}
return base.CustomActivate();
}
/// <summary>
///
/// </summary>
/// <param name="ethernetEventArgs"></param>
void CrestronEnvironment_EthernetEventHandler(EthernetEventArgs args)
{
Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Ethernet status change, port {0}: {1}",
args.EthernetAdapter, args.EthernetEventType);
if (args.EthernetEventType == eEthernetEventType.LinkDown && WSClient != null && args.EthernetAdapter == WSClient.EthernetAdapter)
{
CleanUpWebsocketClient();
}
} }
/// <summary> /// <summary>
@@ -97,11 +140,7 @@ namespace PepperDash.Essentials
{ {
if (programEventType == eProgramStatusEventType.Stopping && WSClient.Connected) if (programEventType == eProgramStatusEventType.Stopping && WSClient.Connected)
{ {
SendMessageToServer(JObject.FromObject( new CleanUpWebsocketClient();
{
type = "/system/close"
}));
} }
} }
@@ -158,6 +197,7 @@ namespace PepperDash.Essentials
else else
{ {
Debug.Console(0, this, "Adding room bridge and sending configuration"); Debug.Console(0, this, "Adding room bridge and sending configuration");
//SystemUuid = ConfigReader.ConfigObject.SystemUuid;
RegisterSystemToServer(); RegisterSystemToServer();
} }
} }
@@ -170,6 +210,7 @@ namespace PepperDash.Essentials
void bridge_ConfigurationIsReady(object sender, EventArgs e) void bridge_ConfigurationIsReady(object sender, EventArgs e)
{ {
Debug.Console(1, this, "Bridge ready. Registering"); Debug.Console(1, this, "Bridge ready. Registering");
//SystemUuid = ConfigReader.ConfigObject.SystemUuid;
// send the configuration object to the server // send the configuration object to the server
RegisterSystemToServer(); RegisterSystemToServer();
} }
@@ -189,6 +230,8 @@ namespace PepperDash.Essentials
/// <param name="command"></param> /// <param name="command"></param>
void AuthorizeSystem(string code) void AuthorizeSystem(string code)
{ {
//SystemUuid = ConfigReader.ConfigObject.SystemUuid;
if (string.IsNullOrEmpty(SystemUuid)) if (string.IsNullOrEmpty(SystemUuid))
{ {
CrestronConsole.ConsoleCommandResponse("System does not have a UUID. Please ensure proper portal-format configuration is loaded and restart."); CrestronConsole.ConsoleCommandResponse("System does not have a UUID. Please ensure proper portal-format configuration is loaded and restart.");
@@ -221,6 +264,7 @@ namespace PepperDash.Essentials
if (r.Code == 200) if (r.Code == 200)
{ {
Debug.Console(0, "System authorized, sending config."); Debug.Console(0, "System authorized, sending config.");
#warning This registration may need to wait for config ready. Maybe.
RegisterSystemToServer(); RegisterSystemToServer();
} }
else if (r.Code == 404) else if (r.Code == 404)
@@ -265,14 +309,17 @@ namespace PepperDash.Essentials
code = "Not available"; code = "Not available";
} }
var conn = WSClient == null ? "No client" : (WSClient.Connected ? "Yes" : "No"); var conn = WSClient == null ? "No client" : (WSClient.Connected ? "Yes" : "No");
var secSinceLastAck = DateTime.Now - LastAckMessage;
CrestronConsole.ConsoleCommandResponse(@"Mobile Control Information: CrestronConsole.ConsoleCommandResponse(@"Mobile Control Information:
Server address: {0} Server address: {0}
System Name: {1} System Name: {1}
System UUID: {2} System UUID: {2}
System User code: {3} System User code: {3}
Connected?: {4}", url, name, SystemUuid, Connected?: {4}
code, conn); Seconds Since Last Ack: {5}", url, name, SystemUuid,
code, conn, secSinceLastAck.Seconds);
} }
/// <summary> /// <summary>
@@ -281,56 +328,101 @@ namespace PepperDash.Essentials
/// <param name="url">URL of the server, including the port number, if not 80. Format: "serverUrlOrIp:port"</param> /// <param name="url">URL of the server, including the port number, if not 80. Format: "serverUrlOrIp:port"</param>
void RegisterSystemToServer() void RegisterSystemToServer()
{ {
ConnectWebsocketClient();
var ready = RegisterLockEvent.Wait(20000);
if (!ready)
{
Debug.Console(1, this, "RegisterSystemToServer failed to enter after 20 seconds. Ignoring");
return;
} }
RegisterLockEvent.Reset();
try /// <summary>
/// Connects the Websocket Client
/// </summary>
/// <param name="o"></param>
void ConnectWebsocketClient()
{ {
Debug.Console(1, this, "Initializing Stream client to server.");
if (WSClient != null)
{
Debug.Console(1, this, "Cleaning up previous socket");
CleanUpWebsocketClient();
}
WSClient = new WebSocketClient();
WSClient.URL = string.Format("wss://{0}/system/join/{1}", Config.ServerUrl, this.SystemUuid);
WSClient.ConnectionCallBack = Websocket_ConnectCallback;
WSClient.ConnectAsync();
}
/// <summary>
///
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
int Websocket_ConnectCallback(WebSocketClient.WEBSOCKET_RESULT_CODES code)
{
if (code == WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
{
StopServerReconnectTimer();
Debug.Console(1, this, "Websocket connected");
WSClient.DisconnectCallBack = Websocket_DisconnectCallback;
WSClient.SendCallBack = Websocket_SendCallback;
WSClient.ReceiveCallBack = Websocket_ReceiveCallback;
WSClient.ReceiveAsync();
SendMessageObjectToServer(new
{
type = "hello"
});
}
else
{
if (code == WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_HTTP_HANDSHAKE_TOKEN_ERROR)
{
// This is the case when app server is running behind a websever and app server is down
Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Web socket connection failed. Check that app server is running behind web server");
}
else if (code == WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SOCKET_CONNECTION_FAILED)
{
// this will be the case when webserver is unreachable
Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Web socket connection failed");
}
else
{
Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Web socket connection failure: {0}", code);
}
StartServerReconnectTimer();
}
return 0;
}
/// <summary>
/// After a "hello" from the server, sends config and stuff
/// </summary>
void SendInitialMessage()
{
Debug.Console(1, this, "Sending initial join message");
var confObject = ConfigReader.ConfigObject; var confObject = ConfigReader.ConfigObject;
confObject.Info.RuntimeInfo.AppName = Assembly.GetExecutingAssembly().GetName().Name; confObject.Info.RuntimeInfo.AppName = Assembly.GetExecutingAssembly().GetName().Name;
var version = Assembly.GetExecutingAssembly().GetName().Version; var version = Assembly.GetExecutingAssembly().GetName().Version;
confObject.Info.RuntimeInfo.AssemblyVersion = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build); confObject.Info.RuntimeInfo.AssemblyVersion = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build);
string postBody = JsonConvert.SerializeObject(confObject); var msg = new
SystemUuid = confObject.SystemUuid;
if (string.IsNullOrEmpty(postBody))
{ {
Debug.Console(1, this, "ERROR: Config body is empty. Cannot register with server."); type = "join",
} content = new
else
{ {
var regClient = new HttpClient(); config = confObject
regClient.Verbose = true; }
regClient.KeepAlive = true; };
SendMessageObjectToServer(msg);
string url = string.Format("http://{0}/api/system/join/{1}", Config.ServerUrl, SystemUuid);
Debug.Console(1, this, "Joining server at {0}", url);
HttpClientRequest request = new HttpClientRequest();
request.Url.Parse(url);
request.RequestType = RequestType.Post;
request.Header.SetHeaderValue("Content-Type", "application/json");
request.ContentString = postBody;
var err = regClient.DispatchAsync(request, RegistrationConnectionCallback);
} }
} /// <summary>
catch (Exception e) /// Sends any object type to server
/// </summary>
/// <param name="o"></param>
public void SendMessageObjectToServer(object o)
{ {
Debug.Console(0, this, "ERROR: Initilizing Room: {0}", e); SendMessageToServer(JObject.FromObject(o));
RegisterLockEvent.Set();
StartReconnectTimer();
}
} }
/// <summary> /// <summary>
@@ -340,77 +432,71 @@ namespace PepperDash.Essentials
/// <param name="o">object to be serialized and sent in post body</param> /// <param name="o">object to be serialized and sent in post body</param>
public void SendMessageToServer(JObject o) public void SendMessageToServer(JObject o)
{ {
if (WSClient != null && WSClient.Connected) if (WSClient != null && WSClient.Connected)
{ {
string message = JsonConvert.SerializeObject(o, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); string message = JsonConvert.SerializeObject(o, Formatting.None, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore });
Debug.Console(1, this, "Message TX: {0}", message);
var messageBytes = System.Text.Encoding.UTF8.GetBytes(message);
WSClient.Send(messageBytes, (uint)messageBytes.Length, WebSocketClient.WEBSOCKET_PACKET_TYPES.LWS_WS_OPCODE_07__TEXT_FRAME);
//WSClient.SendAsync(messageBytes, (uint)messageBytes.Length, WebSocketClient.WEBSOCKET_PACKET_TYPES.LWS_WS_OPCODE_07__TEXT_FRAME);
}
if (!message.Contains("/system/heartbeat"))
Debug.Console(1, this, "Message TX: {0}", message);
//else
// Debug.Console(1, this, "TX messages contains /system/heartbeat");
var messageBytes = System.Text.Encoding.UTF8.GetBytes(message);
var result = WSClient.Send(messageBytes, (uint)messageBytes.Length, WebSocketClient.WEBSOCKET_PACKET_TYPES.LWS_WS_OPCODE_07__TEXT_FRAME);
if (result != WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
{
Debug.Console(1, this, "Socket send result error: {0}", result);
}
}
else if (!WSClient.Connected)
{
Debug.Console(1, this, "Cannot send. Not connected {0}");
}
} }
/// <summary> /// <summary>
/// Disconnects the SSE Client and stops the heartbeat timer /// Disconnects the SSE Client and stops the heartbeat timer
/// </summary> /// </summary>
/// <param name="command"></param> /// <param name="command"></param>
void DisconnectStreamClient(string command) void CleanUpWebsocketClient()
{
Debug.Console(1, this, "Disconnecting websocket");
if (WSClient != null)
{
WSClient.SendCallBack = null;
WSClient.ReceiveCallBack = null;
WSClient.ConnectionCallBack = null;
WSClient.DisconnectCallBack = null;
if (WSClient.Connected)
{ {
//if(SseClient != null)
// SseClient.Disconnect();
if (WSClient != null && WSClient.Connected)
WSClient.Disconnect(); WSClient.Disconnect();
}
if (ServerHeartbeatCheckTimer != null) WSClient = null;
{
ServerHeartbeatCheckTimer.Stop();
ServerHeartbeatCheckTimer = null;
} }
} }
/// <summary> /// <summary>
/// The callback that fires when we get a response from our registration attempt ///
/// </summary> /// </summary>
/// <param name="resp"></param> /// <param name="dueTime"></param>
/// <param name="err"></param> /// <param name="repeatTime"></param>
void RegistrationConnectionCallback(HttpClientResponse resp, HTTP_CALLBACK_ERROR err) void StartServerReconnectTimer()
{ {
CheckHttpDebug(resp, err); StopServerReconnectTimer();
Debug.Console(1, this, "RegistrationConnectionCallback: {0}", err); ServerReconnectTimer = new CTimer(ReconnectToServerTimerCallback, ServerReconnectInterval);
try Debug.Console(1, this, "Reconnect Timer Started.");
{ }
if (resp != null && resp.Code == 200)
/// <summary>
/// Does what it says
/// </summary>
void StopServerReconnectTimer()
{ {
if (ServerReconnectTimer != null) if (ServerReconnectTimer != null)
{ {
ServerReconnectTimer.Stop(); ServerReconnectTimer.Stop();
ServerReconnectTimer = null; ServerReconnectTimer = null;
} }
// Success here!
ConnectStreamClient();
}
else
{
if (resp != null)
Debug.Console(1, this, "Response from server: {0}\n{1}", resp.Code, err);
else
{
Debug.Console(1, this, "Null response received from server.");
}
StartReconnectTimer();
}
}
catch (Exception e)
{
Debug.Console(1, this, "Error Initializing Stream Client: {0}", e);
StartReconnectTimer();
}
RegisterLockEvent.Set();
} }
/// <summary> /// <summary>
@@ -425,23 +511,8 @@ namespace PepperDash.Essentials
ServerHeartbeatCheckTimer.Stop(); ServerHeartbeatCheckTimer.Stop();
ServerHeartbeatCheckTimer = null; ServerHeartbeatCheckTimer = null;
} }
StartReconnectTimer(); CleanUpWebsocketClient();
} StartServerReconnectTimer();
/// <summary>
///
/// </summary>
/// <param name="dueTime"></param>
/// <param name="repeatTime"></param>
void StartReconnectTimer()
{
// Start the reconnect timer
if (ServerReconnectTimer == null)
{
ServerReconnectTimer = new CTimer(ReconnectToServerTimerCallback, null, ServerReconnectInterval, ServerReconnectInterval);
Debug.Console(1, this, "Reconnect Timer Started.");
}
ServerReconnectTimer.Reset(ServerReconnectInterval, ServerReconnectInterval);
} }
/// <summary> /// <summary>
@@ -454,34 +525,39 @@ namespace PepperDash.Essentials
if (ServerHeartbeatCheckTimer == null) if (ServerHeartbeatCheckTimer == null)
{ {
ServerHeartbeatCheckTimer = new CTimer(HeartbeatExpiredTimerCallback, null, ServerHeartbeatInterval, ServerHeartbeatInterval); ServerHeartbeatCheckTimer = new CTimer(HeartbeatExpiredTimerCallback, null, ServerHeartbeatInterval, ServerHeartbeatInterval);
Debug.Console(1, this, "Heartbeat Timer Started."); Debug.Console(1, this, "Heartbeat Timer Started.");
} }
else
{
ServerHeartbeatCheckTimer.Reset(ServerHeartbeatInterval, ServerHeartbeatInterval); ServerHeartbeatCheckTimer.Reset(ServerHeartbeatInterval, ServerHeartbeatInterval);
} }
}
/// <summary> /// <summary>
/// Connects the SSE Client /// Waits two and goes again
/// </summary> /// </summary>
/// <param name="o"></param> void ReconnectStreamClient()
void ConnectStreamClient()
{ {
Debug.Console(0, this, "Initializing Stream client to server."); new CTimer(o => ConnectWebsocketClient(), 2000);
}
if (WSClient == null) /// <summary>
///
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
int Websocket_DisconnectCallback(WebSocketClient.WEBSOCKET_RESULT_CODES code, object o)
{ {
WSClient = new WebSocketClient(); Debug.Console(1, this, Debug.ErrorLogLevel.Warning, "Websocket disconnected with code: {0}", code);
}
WSClient.URL = string.Format("wss://{0}/system/join/{1}", Config.ServerUrl, this.SystemUuid); if (ServerHeartbeatCheckTimer != null)
WSClient.Connect(); ServerHeartbeatCheckTimer.Stop();
Debug.Console(0, this, "Websocket connected"); // Start the reconnect timer
WSClient.ReceiveCallBack = WebsocketReceiveCallback; StartServerReconnectTimer();
//WSClient.SendCallBack = WebsocketSendCallback; return 0;
WSClient.ReceiveAsync();
} }
/// <summary> /// <summary>
/// Resets reconnect timer and updates usercode /// Resets reconnect timer and updates usercode
/// </summary> /// </summary>
@@ -513,14 +589,28 @@ namespace PepperDash.Essentials
void CheckHttpDebug(HttpClientResponse r, HTTP_CALLBACK_ERROR e) void CheckHttpDebug(HttpClientResponse r, HTTP_CALLBACK_ERROR e)
{ {
if (HttpDebugEnabled) if (HttpDebugEnabled)
{
try
{ {
Debug.Console(0, this, "------ Begin HTTP Debug ---------------------------------------"); Debug.Console(0, this, "------ Begin HTTP Debug ---------------------------------------");
Debug.Console(0, this, "HTTP Response URL: {0}", r.ResponseUrl.ToString()); if (r != null)
Debug.Console(0, this, "HTTP Response 'error' {0}", e); {
Debug.Console(0, this, "HTTP Response URL: {0}", r.ResponseUrl != null ? r.ResponseUrl.ToString() : "NONE");
Debug.Console(0, this, "HTTP Response code: {0}", r.Code); Debug.Console(0, this, "HTTP Response code: {0}", r.Code);
Debug.Console(0, this, "HTTP Response content: \r{0}", r.ContentString); Debug.Console(0, this, "HTTP Response content: \r{0}", r.ContentString);
}
else
{
Debug.Console(0, this, "No HTTP response");
}
Debug.Console(0, this, "HTTP Response 'error' {0}", e);
Debug.Console(0, this, "------ End HTTP Debug -----------------------------------------"); Debug.Console(0, this, "------ End HTTP Debug -----------------------------------------");
} }
catch (Exception ex)
{
Debug.Console(0, this, "HttpDebugError: {0}", ex);
}
}
} }
/// <summary> /// <summary>
@@ -530,14 +620,28 @@ namespace PepperDash.Essentials
/// <param name="length"></param> /// <param name="length"></param>
/// <param name="opcode"></param> /// <param name="opcode"></param>
/// <param name="err"></param> /// <param name="err"></param>
int WebsocketReceiveCallback(byte[] data, uint length, WebSocketClient.WEBSOCKET_PACKET_TYPES opcode, int Websocket_ReceiveCallback(byte[] data, uint length, WebSocketClient.WEBSOCKET_PACKET_TYPES opcode,
WebSocketClient.WEBSOCKET_RESULT_CODES err) WebSocketClient.WEBSOCKET_RESULT_CODES err)
{
if (opcode == WebSocketClient.WEBSOCKET_PACKET_TYPES.LWS_WS_OPCODE_07__TEXT_FRAME)
{ {
var rx = System.Text.Encoding.UTF8.GetString(data, 0, (int)length); var rx = System.Text.Encoding.UTF8.GetString(data, 0, (int)length);
if (rx.Length > 0) if (rx.Length > 0)
ParseStreamRx(rx); ParseStreamRx(rx);
WSClient.ReceiveAsync(); WSClient.ReceiveAsync();
return 1; }
else if (opcode == WebSocketClient.WEBSOCKET_PACKET_TYPES.LWS_WS_OPCODE_07__CLOSE)
{
Debug.Console(1, this, "Websocket disconnect received from remote");
CleanUpWebsocketClient();
}
else
{
Debug.Console(1, this, "websocket rx opcode/err {0}/{1}", opcode, err);
WSClient.ReceiveAsync();
}
return 0;
} }
/// <summary> /// <summary>
@@ -545,10 +649,10 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
/// <param name="result"></param> /// <param name="result"></param>
/// <returns></returns> /// <returns></returns>
int WebsocketSendCallback(Crestron.SimplSharp.CrestronWebSocketClient.WebSocketClient.WEBSOCKET_RESULT_CODES result) int Websocket_SendCallback(Crestron.SimplSharp.CrestronWebSocketClient.WebSocketClient.WEBSOCKET_RESULT_CODES result)
{ {
Debug.Console(1, this, "SendCallback result: {0}", result); if(result != WebSocketClient.WEBSOCKET_RESULT_CODES.WEBSOCKET_CLIENT_SUCCESS)
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "SendCallback questionable result: {0}", result);
return 1; return 1;
} }
@@ -562,7 +666,14 @@ namespace PepperDash.Essentials
if(string.IsNullOrEmpty(message)) if(string.IsNullOrEmpty(message))
return; return;
Debug.Console(1, this, "Message RX: '{0}'", message); if (!message.Contains("/system/heartbeat"))
Debug.Console(1, this, "Message RX: {0}", message);
else
{
LastAckMessage = DateTime.Now;
//Debug.Console(1, this, "RX message contains /system/heartbeat");
}
try try
{ {
var messageObj = JObject.Parse(message); var messageObj = JObject.Parse(message);
@@ -571,6 +682,7 @@ namespace PepperDash.Essentials
if (type == "hello") if (type == "hello")
{ {
SendInitialMessage();
ResetOrStartHearbeatTimer(); ResetOrStartHearbeatTimer();
} }
else if (type == "/system/heartbeat") else if (type == "/system/heartbeat")
@@ -579,11 +691,11 @@ namespace PepperDash.Essentials
} }
else if (type == "close") else if (type == "close")
{ {
WSClient.Disconnect(); Debug.Console(1, this, "Received close message from server.");
// DisconnectWebsocketClient();
if (ServerHeartbeatCheckTimer != null)
ServerHeartbeatCheckTimer.Stop(); ServerHeartbeatCheckTimer.Stop();
// Start the reconnect timer
StartReconnectTimer();
} }
else else
{ {
@@ -620,7 +732,7 @@ namespace PepperDash.Essentials
} }
case "held": case "held":
{ {
if (!PushedActions.ContainsKey(type)) if (PushedActions.ContainsKey(type))
{ {
PushedActions[type].Reset(ButtonHeartbeatInterval, ButtonHeartbeatInterval); PushedActions[type].Reset(ButtonHeartbeatInterval, ButtonHeartbeatInterval);
} }

View File

@@ -0,0 +1,187 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.EthernetCommunication;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common.Codec;
namespace PepperDash.Essentials.AppServer.Messengers
{
public class Ddvc01AtcMessenger : MessengerBase
{
BasicTriList EISC;
const uint BDialHangup = 221;
const uint BIncomingAnswer = 251;
const uint BIncomingReject = 252;
const uint BSpeedDial1 = 241;
const uint BSpeedDial2 = 242;
const uint BSpeedDial3 = 243;
const uint BSpeedDial4 = 244;
/// <summary>
/// 201
/// </summary>
const uint SCurrentDialString = 201;
/// <summary>
/// 211
/// </summary>
const uint SCurrentCallNumber = 211;
/// <summary>
/// 212
/// </summary>
const uint SCurrentCallName = 212;
/// <summary>
/// 221
/// </summary>
const uint SHookState = 221;
/// <summary>
/// 222
/// </summary>
const uint SCallDirection = 222;
/// <summary>
///
/// </summary>
Dictionary<string, uint> DTMFMap = new Dictionary<string, uint>
{
{ "1", 201 },
{ "2", 202 },
{ "3", 203 },
{ "4", 204 },
{ "5", 205 },
{ "6", 206 },
{ "7", 207 },
{ "8", 208 },
{ "9", 209 },
{ "0", 210 },
{ "*", 211 },
{ "#", 212 },
};
CodecActiveCallItem CurrentCallItem;
/// <summary>
///
/// </summary>
/// <param name="eisc"></param>
/// <param name="messagePath"></param>
public Ddvc01AtcMessenger(string key, BasicTriList eisc, string messagePath)
: base(key, messagePath)
{
EISC = eisc;
CurrentCallItem = new CodecActiveCallItem();
CurrentCallItem.Type = eCodecCallType.Audio;
CurrentCallItem.Id = "-audio-";
}
/// <summary>
///
/// </summary>
void SendFullStatus()
{
this.PostStatusMessage(new
{
calls = GetCurrentCallList(),
currentCallString = EISC.GetString(SCurrentCallNumber),
currentDialString = EISC.GetString(SCurrentDialString),
isInCall = EISC.GetString(SHookState) == "Connected"
});
}
/// <summary>
///
/// </summary>
/// <param name="appServerController"></param>
protected override void CustomRegisterWithAppServer(CotijaSystemController appServerController)
{
//EISC.SetStringSigAction(SCurrentDialString, s => PostStatusMessage(new { currentDialString = s }));
EISC.SetStringSigAction(SHookState, s =>
{
CurrentCallItem.Status = (eCodecCallStatus)Enum.Parse(typeof(eCodecCallStatus), s, true);
//GetCurrentCallList();
SendCallsList();
});
EISC.SetStringSigAction(SCurrentCallNumber, s =>
{
CurrentCallItem.Number = s;
SendCallsList();
});
EISC.SetStringSigAction(SCurrentCallName, s =>
{
CurrentCallItem.Name = s;
SendCallsList();
});
EISC.SetStringSigAction(SCallDirection, s =>
{
CurrentCallItem.Direction = (eCodecCallDirection)Enum.Parse(typeof(eCodecCallDirection), s, true);
SendCallsList();
});
// Add press and holds using helper
Action<string, uint> addPHAction = (s, u) =>
AppServerController.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b)));
// Add straight pulse calls
Action<string, uint> addAction = (s, u) =>
AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100)));
addAction("/endCallById", BDialHangup);
addAction("/acceptById", BIncomingAnswer);
addAction("/rejectById", BIncomingReject);
addAction("/speedDial1", BSpeedDial1);
addAction("/speedDial2", BSpeedDial2);
addAction("/speedDial3", BSpeedDial3);
addAction("/speedDial4", BSpeedDial4);
// Get status
AppServerController.AddAction(MessagePath + "/fullStatus", new Action(SendFullStatus));
// Dial on string
AppServerController.AddAction(MessagePath + "/dial", new Action<string>(s => EISC.SetString(SCurrentDialString, s)));
// Pulse DTMF
AppServerController.AddAction(MessagePath + "/dtmf", new Action<string>(s =>
{
if (DTMFMap.ContainsKey(s))
{
EISC.PulseBool(DTMFMap[s], 100);
}
}));
}
void SendCallsList()
{
PostStatusMessage(new
{
calls = GetCurrentCallList(),
});
}
/// <summary>
/// Turns the
/// </summary>
/// <returns></returns>
List<CodecActiveCallItem> GetCurrentCallList()
{
if (CurrentCallItem.Status == eCodecCallStatus.Disconnected)
{
return new List<CodecActiveCallItem>();
}
else
{
return new List<CodecActiveCallItem>() { CurrentCallItem };
}
}
}
}

View File

@@ -0,0 +1,102 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Essentials.Devices.Common.Codec;
using PepperDash.Essentials.Devices.Common.AudioCodec;
namespace PepperDash.Essentials.AppServer.Messengers
{
/// <summary>
/// Provides a messaging bridge for an AudioCodecBase device
/// </summary>
public class AudioCodecBaseMessenger : MessengerBase
{
/// <summary>
/// Device being bridged
/// </summary>
public AudioCodecBase Codec { get; set; }
/// <summary>
/// Constuctor
/// </summary>
/// <param name="key"></param>
/// <param name="codec"></param>
/// <param name="messagePath"></param>
public AudioCodecBaseMessenger(string key, AudioCodecBase codec, string messagePath)
: base(key, messagePath)
{
if (codec == null)
throw new ArgumentNullException("codec");
Codec = codec;
codec.CallStatusChange += new EventHandler<CodecCallStatusItemChangeEventArgs>(codec_CallStatusChange);
}
protected override void CustomRegisterWithAppServer(CotijaSystemController appServerController)
{
appServerController.AddAction(MessagePath + "/fullStatus", new Action(SendAtcFullMessageObject));
appServerController.AddAction(MessagePath + "/dial", new Action<string>(s => Codec.Dial(s)));
appServerController.AddAction(MessagePath + "/endCallById", new Action<string>(s =>
{
var call = GetCallWithId(s);
if (call != null)
Codec.EndCall(call);
}));
appServerController.AddAction(MessagePath + "/endAllCalls", new Action(Codec.EndAllCalls));
appServerController.AddAction(MessagePath + "/dtmf", new Action<string>(s => Codec.SendDtmf(s)));
appServerController.AddAction(MessagePath + "/rejectById", new Action<string>(s =>
{
var call = GetCallWithId(s);
if (call != null)
Codec.RejectCall(call);
}));
appServerController.AddAction(MessagePath + "/acceptById", new Action<string>(s =>
{
var call = GetCallWithId(s);
if (call != null)
Codec.AcceptCall(call);
}));
}
/// <summary>
/// Helper to grab a call with string ID
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
CodecActiveCallItem GetCallWithId(string id)
{
return Codec.ActiveCalls.FirstOrDefault(c => c.Id == id);
}
void codec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e)
{
SendAtcFullMessageObject();
}
/// <summary>
/// Helper method to build call status for vtc
/// </summary>
/// <returns></returns>
void SendAtcFullMessageObject()
{
var info = Codec.CodecInfo;
PostStatusMessage(new
{
isInCall = Codec.IsInCall,
calls = Codec.ActiveCalls,
info = new
{
phoneNumber = info.PhoneNumber
}
});
}
}
}

View File

@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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;
namespace PepperDash.Essentials.AppServer.Messengers
{
/// <summary>
/// Provides a messaging bridge for a VideoCodecBase
/// </summary>
public abstract class MessengerBase : IKeyed
{
public string Key { get; private set; }
/// <summary>
///
/// </summary>
public CotijaSystemController AppServerController { get; private set; }
public string MessagePath { get; private set; }
/// <summary>
///
/// </summary>
/// <param name="codec"></param>
public MessengerBase(string key, string messagePath)
{
Key = key;
if (string.IsNullOrEmpty(messagePath))
throw new ArgumentException("messagePath must not be empty or null");
MessagePath = messagePath;
}
/// <summary>
/// Registers this messenger with appserver controller
/// </summary>
/// <param name="appServerController"></param>
public void RegisterWithAppServer(CotijaSystemController appServerController)
{
if (appServerController == null)
throw new ArgumentNullException("appServerController");
AppServerController = appServerController;
CustomRegisterWithAppServer(AppServerController);
}
/// <summary>
/// Implemented in extending classes. Wire up API calls and feedback here
/// </summary>
/// <param name="appServerController"></param>
abstract protected void CustomRegisterWithAppServer(CotijaSystemController appServerController);
/// <summary>
/// Helper for posting status message
/// </summary>
/// <param name="contentObject">The contents of the content object</param>
protected void PostStatusMessage(object contentObject)
{
if (AppServerController != null)
{
AppServerController.SendMessageToServer(JObject.FromObject(new
{
type = MessagePath,
content = contentObject
}));
}
}
}
}

View File

@@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json;
using PepperDash.Core;
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.ProgramInfoChanged += new EventHandler<ProgramInfoEventArgs>(ProgramInfoChanged);
}
CrestronConsole.AddNewConsoleCommand(s => SendFullStatusMessage(), "SendFullSysMonStatus", "Sends the full System Monitor Status", ConsoleAccessLevelEnum.AccessOperator);
}
/// <summary>
/// Posts the program information message
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void ProgramInfoChanged(object sender, ProgramInfoEventArgs e)
{
Debug.Console(1, "Posting Status Message: {0}", e.ProgramInfo.ToString());
PostStatusMessage(e.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)
{
PostStatusMessage(p.Value.ProgramInfo);
}
}
void SendSystemMonitorStatusMessage()
{
Debug.Console(1, "Posting System Monitor Status Message.");
// 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

@@ -13,31 +13,25 @@ using PepperDash.Essentials.Devices.Common.VideoCodec;
namespace PepperDash.Essentials.AppServer.Messengers namespace PepperDash.Essentials.AppServer.Messengers
{ {
/// <summary> /// <summary>
/// Provides a messaging bridge for a VideoCodecBase /// Provides a messaging bridge for a VideoCodecBase device
/// </summary> /// </summary>
public class VideoCodecBaseMessenger public class VideoCodecBaseMessenger : MessengerBase
{ {
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public VideoCodecBase Codec { get; private set; } public VideoCodecBase Codec { get; private set; }
public CotijaSystemController AppServerController { get; private set; }
public string MessagePath { get; private set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="codec"></param> /// <param name="codec"></param>
public VideoCodecBaseMessenger(VideoCodecBase codec, string messagePath) public VideoCodecBaseMessenger(string key, VideoCodecBase codec, string messagePath)
: base(key, messagePath)
{ {
if (codec == null) if (codec == null)
throw new ArgumentNullException("codec"); throw new ArgumentNullException("codec");
if (string.IsNullOrEmpty(messagePath))
throw new ArgumentException("messagePath must not be empty or null");
MessagePath = messagePath;
Codec = codec; Codec = codec;
codec.CallStatusChange += new EventHandler<CodecCallStatusItemChangeEventArgs>(codec_CallStatusChange); codec.CallStatusChange += new EventHandler<CodecCallStatusItemChangeEventArgs>(codec_CallStatusChange);
codec.IsReadyChange += new EventHandler<EventArgs>(codec_IsReadyChange); codec.IsReadyChange += new EventHandler<EventArgs>(codec_IsReadyChange);
@@ -47,6 +41,30 @@ namespace PepperDash.Essentials.AppServer.Messengers
{ {
dirCodec.DirectoryResultReturned += new EventHandler<DirectoryEventArgs>(dirCodec_DirectoryResultReturned); dirCodec.DirectoryResultReturned += new EventHandler<DirectoryEventArgs>(dirCodec_DirectoryResultReturned);
} }
var recCodec = codec as IHasCallHistory;
if (recCodec != null)
{
recCodec.CallHistory.RecentCallsListHasChanged += new EventHandler<EventArgs>(CallHistory_RecentCallsListHasChanged);
}
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void CallHistory_RecentCallsListHasChanged(object sender, EventArgs e)
{
var recents = (sender as CodecCallHistory).RecentCalls;
if (recents != null)
{
PostStatusMessage(new
{
recentCalls = recents
});
}
} }
/// <summary> /// <summary>
@@ -56,7 +74,6 @@ namespace PepperDash.Essentials.AppServer.Messengers
/// <param name="e"></param> /// <param name="e"></param>
void dirCodec_DirectoryResultReturned(object sender, DirectoryEventArgs e) void dirCodec_DirectoryResultReturned(object sender, DirectoryEventArgs e)
{ {
var dir = e.Directory;
PostStatusMessage(new PostStatusMessage(new
{ {
currentDirectory = e.Directory currentDirectory = e.Directory
@@ -77,16 +94,11 @@ namespace PepperDash.Essentials.AppServer.Messengers
} }
/// <summary> /// <summary>
/// Registers this codec's messaging with an app server controller /// Called from base's RegisterWithAppServer method
/// </summary> /// </summary>
/// <param name="appServerController"></param> /// <param name="appServerController"></param>
public void RegisterWithAppServer(CotijaSystemController appServerController) protected override void CustomRegisterWithAppServer(CotijaSystemController appServerController)
{ {
if (appServerController == null)
throw new ArgumentNullException("appServerController");
AppServerController = appServerController;
appServerController.AddAction("/device/videoCodec/isReady", new Action(SendIsReady)); appServerController.AddAction("/device/videoCodec/isReady", new Action(SendIsReady));
appServerController.AddAction("/device/videoCodec/fullStatus", new Action(SendVtcFullMessageObject)); appServerController.AddAction("/device/videoCodec/fullStatus", new Action(SendVtcFullMessageObject));
appServerController.AddAction("/device/videoCodec/dial", new Action<string>(s => Codec.Dial(s))); appServerController.AddAction("/device/videoCodec/dial", new Action<string>(s => Codec.Dial(s)));
@@ -113,6 +125,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
appServerController.AddAction(MessagePath + "/directoryRoot", new Action(GetDirectoryRoot)); appServerController.AddAction(MessagePath + "/directoryRoot", new Action(GetDirectoryRoot));
appServerController.AddAction(MessagePath + "/directoryById", new Action<string>(s => GetDirectory(s))); appServerController.AddAction(MessagePath + "/directoryById", new Action<string>(s => GetDirectory(s)));
appServerController.AddAction(MessagePath + "/directorySearch", new Action<string>(s => DirectorySearch(s))); appServerController.AddAction(MessagePath + "/directorySearch", new Action<string>(s => DirectorySearch(s)));
appServerController.AddAction(MessagePath + "/getCallHistory", new Action(GetCallHistory));
appServerController.AddAction(MessagePath + "/privacyModeOn", new Action(Codec.PrivacyModeOn)); appServerController.AddAction(MessagePath + "/privacyModeOn", new Action(Codec.PrivacyModeOn));
appServerController.AddAction(MessagePath + "/privacyModeOff", new Action(Codec.PrivacyModeOff)); appServerController.AddAction(MessagePath + "/privacyModeOff", new Action(Codec.PrivacyModeOff));
appServerController.AddAction(MessagePath + "/privacyModeToggle", new Action(Codec.PrivacyModeToggle)); appServerController.AddAction(MessagePath + "/privacyModeToggle", new Action(Codec.PrivacyModeToggle));
@@ -122,6 +135,24 @@ namespace PepperDash.Essentials.AppServer.Messengers
appServerController.AddAction(MessagePath + "/standbyOff", new Action(Codec.StandbyDeactivate)); appServerController.AddAction(MessagePath + "/standbyOff", new Action(Codec.StandbyDeactivate));
} }
void GetCallHistory()
{
var codec = (Codec as IHasCallHistory);
if (codec != null)
{
var recents = codec.CallHistory.RecentCalls;
if (recents != null)
{
PostStatusMessage(new
{
recentCalls = recents
});
}
}
}
public void GetFullStatusMessage() public void GetFullStatusMessage()
{ {
@@ -239,21 +270,10 @@ namespace PepperDash.Essentials.AppServer.Messengers
sipURI = info.SipUri sipURI = info.SipUri
}, },
showSelfViewByDefault = Codec.ShowSelfViewByDefault, showSelfViewByDefault = Codec.ShowSelfViewByDefault,
hasDirectory = Codec is IHasDirectory hasDirectory = Codec is IHasDirectory,
hasRecents = Codec is IHasCallHistory,
hasCameras = Codec is IHasCameraControl
}); });
} }
/// <summary>
/// Helper for posting status message
/// </summary>
/// <param name="contentObject">The contents of the content object</param>
void PostStatusMessage(object contentObject)
{
AppServerController.SendMessageToServer(JObject.FromObject(new
{
type = MessagePath,
content = contentObject
}));
}
} }
} }

View File

@@ -10,6 +10,7 @@ using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.AppServer.Messengers;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Room.Config; using PepperDash.Essentials.Room.Config;
@@ -26,6 +27,14 @@ namespace PepperDash.Essentials.Room.Cotija
/// </summary> /// </summary>
public const uint RoomIsOn = 301; public const uint RoomIsOn = 301;
/// <summary>
/// 41
/// </summary>
public const uint PromptForCode = 41;
/// <summary>
/// 42
/// </summary>
public const uint ClientJoined = 42;
/// <summary> /// <summary>
/// 51 /// 51
/// </summary> /// </summary>
@@ -60,14 +69,15 @@ namespace PepperDash.Essentials.Room.Cotija
/// 63 /// 63
/// </summary> /// </summary>
public const uint ShutdownStart = 63; public const uint ShutdownStart = 63;
/// <summary> /// <summary>
/// 72 /// 72
/// </summary> /// </summary>
public const uint SourceHasChanged = 72; public const uint SourceHasChanged = 72;
/// <summary> /// <summary>
/// 261 - The start of the range of speed dial visibles
/// </summary>
public const uint SpeedDialVisibleStartJoin = 261;
/// <summary>
/// 501 /// 501
/// </summary> /// </summary>
public const uint ConfigIsReady = 501; public const uint ConfigIsReady = 501;
@@ -93,6 +103,16 @@ namespace PepperDash.Essentials.Room.Cotija
/// </summary> /// </summary>
public const uint SelectedSourceKey = 71; public const uint SelectedSourceKey = 71;
/// <summary>
/// 241
/// </summary>
public const uint SpeedDialNameStartJoin = 241;
/// <summary>
/// 251
/// </summary>
public const uint SpeedDialNumberStartJoin = 251;
/// <summary> /// <summary>
/// 501 /// 501
/// </summary> /// </summary>
@@ -145,6 +165,8 @@ namespace PepperDash.Essentials.Room.Cotija
CotijaDdvc01DeviceBridge SourceBridge; CotijaDdvc01DeviceBridge SourceBridge;
Ddvc01AtcMessenger AtcMessenger;
/// <summary> /// <summary>
/// ///
@@ -182,6 +204,10 @@ namespace PepperDash.Essentials.Room.Cotija
SetupFunctions(); SetupFunctions();
SetupFeedbacks(); SetupFeedbacks();
var key = this.Key + "-" + Parent.Key;
AtcMessenger = new Ddvc01AtcMessenger(key, EISC, "/device/audioCodec");
AtcMessenger.RegisterWithAppServer(Parent);
EISC.SigChange += EISC_SigChange; EISC.SigChange += EISC_SigChange;
EISC.OnlineStatusChange += (o, a) => EISC.OnlineStatusChange += (o, a) =>
{ {
@@ -216,8 +242,6 @@ namespace PepperDash.Essentials.Room.Cotija
} }
}, "mobilebridgedump", "Dumps DDVC01 bridge EISC data b,u,s", ConsoleAccessLevelEnum.AccessOperator); }, "mobilebridgedump", "Dumps DDVC01 bridge EISC data b,u,s", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s => LoadConfigValues(), "loadddvc", "", ConsoleAccessLevelEnum.AccessOperator);
return base.CustomActivate(); return base.CustomActivate();
} }
@@ -227,6 +251,9 @@ namespace PepperDash.Essentials.Room.Cotija
/// </summary> /// </summary>
void SetupFunctions() void SetupFunctions()
{ {
#warning need join numbers for these
Parent.AddAction(@"/room/room1/promptForCode", new Action(() => EISC.PulseBool(BoolJoin.PromptForCode)));
Parent.AddAction(@"/room/room1/clientJoined", new Action(() => EISC.PulseBool(BoolJoin.ClientJoined)));
Parent.AddAction(@"/room/room1/status", new Action(SendFullStatus)); Parent.AddAction(@"/room/room1/status", new Action(SendFullStatus));
@@ -238,6 +265,10 @@ namespace PepperDash.Essentials.Room.Cotija
Parent.AddAction(@"/room/room1/defaultsource", new Action(() => Parent.AddAction(@"/room/room1/defaultsource", new Action(() =>
EISC.PulseBool(BoolJoin.ActivitySharePress))); EISC.PulseBool(BoolJoin.ActivitySharePress)));
Parent.AddAction(@"/room/room1/activityVideo", new Action(() =>
EISC.PulseBool(BoolJoin.ActivityVideoCallPress)));
Parent.AddAction(@"/room/room1/activityPhone", new Action(() =>
EISC.PulseBool(BoolJoin.ActivityPhoneCallPress)));
Parent.AddAction(@"/room/room1/volumes/master/level", new Action<ushort>(u => Parent.AddAction(@"/room/room1/volumes/master/level", new Action<ushort>(u =>
EISC.SetUshort(UshortJoin.MasterVolumeLevel, u))); EISC.SetUshort(UshortJoin.MasterVolumeLevel, u)));
@@ -250,20 +281,26 @@ namespace PepperDash.Essentials.Room.Cotija
EISC.PulseBool(BoolJoin.ShutdownEnd))); EISC.PulseBool(BoolJoin.ShutdownEnd)));
Parent.AddAction(@"/room/room1/shutdownCancel", new Action(() => Parent.AddAction(@"/room/room1/shutdownCancel", new Action(() =>
EISC.PulseBool(BoolJoin.ShutdownCancel))); EISC.PulseBool(BoolJoin.ShutdownCancel)));
}
/// <summary>
// Source Device (Current Source)' ///
/// </summary>
/// <param name="devKey"></param>
void SetupSourceFunctions(string devKey)
{
SourceDeviceMapDictionary sourceJoinMap = new SourceDeviceMapDictionary(); SourceDeviceMapDictionary sourceJoinMap = new SourceDeviceMapDictionary();
var prefix = @"/device/currentSource/"; var prefix = string.Format("/device/{0}/", devKey);
foreach (var item in sourceJoinMap) foreach (var item in sourceJoinMap)
{ {
Parent.AddAction(string.Format("{0}{1}", prefix, item.Key), new PressAndHoldAction(b => EISC.SetBool(item.Value, b))); var join = item.Value;
Parent.AddAction(string.Format("{0}{1}", prefix, item.Key), new PressAndHoldAction(b => EISC.SetBool(join, b)));
} }
} }
/// <summary> /// <summary>
/// Links feedbacks to whatever is gonna happen! /// Links feedbacks to whatever is gonna happen!
/// </summary> /// </summary>
@@ -345,9 +382,9 @@ namespace PepperDash.Essentials.Room.Cotija
var version = Assembly.GetExecutingAssembly().GetName().Version; var version = Assembly.GetExecutingAssembly().GetName().Version;
co.Info.RuntimeInfo.AssemblyVersion = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build); co.Info.RuntimeInfo.AssemblyVersion = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build);
//Room //Room
if (co.Rooms == null) //if (co.Rooms == null)
// always start fresh in case simpl changed
co.Rooms = new List<DeviceConfig>(); co.Rooms = new List<DeviceConfig>();
var rm = new DeviceConfig(); var rm = new DeviceConfig();
if (co.Rooms.Count == 0) if (co.Rooms.Count == 0)
@@ -388,6 +425,11 @@ namespace PepperDash.Essentials.Room.Cotija
var name = EISC.StringOutput[i + 1].StringValue; var name = EISC.StringOutput[i + 1].StringValue;
rmProps.SpeedDials.Add(new DDVC01SpeedDial { Number = num, Name = name}); rmProps.SpeedDials.Add(new DDVC01SpeedDial { Number = num, Name = name});
} }
// This MAY need a check
rmProps.AudioCodecKey = "audioCodec";
rmProps.VideoCodecKey = null; // "videoCodec";
// volume control names // volume control names
var volCount = EISC.UShortOutput[701].UShortValue; var volCount = EISC.UShortOutput[701].UShortValue;
@@ -403,7 +445,10 @@ namespace PepperDash.Essentials.Room.Cotija
co.Devices = new List<DeviceConfig>(); co.Devices = new List<DeviceConfig>();
// clear out previous DDVC devices // clear out previous DDVC devices
co.Devices.RemoveAll(d => d.Key.StartsWith("source-", StringComparison.OrdinalIgnoreCase)); co.Devices.RemoveAll(d =>
d.Key.StartsWith("source-", StringComparison.OrdinalIgnoreCase)
|| d.Key.Equals("audioCodec", StringComparison.OrdinalIgnoreCase)
|| d.Key.Equals("videoCodec", StringComparison.OrdinalIgnoreCase));
rmProps.SourceListKey = "default"; rmProps.SourceListKey = "default";
rm.Properties = JToken.FromObject(rmProps); rm.Properties = JToken.FromObject(rmProps);
@@ -422,6 +467,7 @@ namespace PepperDash.Essentials.Room.Cotija
break; break;
var icon = EISC.StringOutput[651 + i].StringValue; var icon = EISC.StringOutput[651 + i].StringValue;
var key = EISC.StringOutput[671 + i].StringValue; var key = EISC.StringOutput[671 + i].StringValue;
var type = EISC.StringOutput[701 + i].StringValue; var type = EISC.StringOutput[701 + i].StringValue;
Debug.Console(0, this, "Adding source {0} '{1}'", key, name); Debug.Console(0, this, "Adding source {0} '{1}'", key, name);
@@ -430,6 +476,7 @@ namespace PepperDash.Essentials.Room.Cotija
Name = name, Name = name,
Order = (int)i + 1, Order = (int)i + 1,
SourceKey = key, SourceKey = key,
Type = eSourceListItemType.Route
}; };
newSl.Add(key, newSLI); newSl.Add(key, newSLI);
@@ -447,10 +494,50 @@ namespace PepperDash.Essentials.Room.Cotija
Type = type Type = type
}; };
co.Devices.Add(devConf); co.Devices.Add(devConf);
if (group.ToLower().StartsWith("settopbox")) // Add others here as needed
{
SetupSourceFunctions(key);
}
} }
co.SourceLists.Add("default", newSl); co.SourceLists.Add("default", newSl);
// build "audioCodec" config if we need
if (!string.IsNullOrEmpty(rmProps.AudioCodecKey))
{
var acFavs = new List<PepperDash.Essentials.Devices.Common.Codec.CodecActiveCallItem>();
for (uint i = 0; i < 4; i++)
{
if (!EISC.GetBool(BoolJoin.SpeedDialVisibleStartJoin + i))
{
break;
}
acFavs.Add(new PepperDash.Essentials.Devices.Common.Codec.CodecActiveCallItem()
{
Name = EISC.GetString(StringJoin.SpeedDialNameStartJoin + i),
Number = EISC.GetString(StringJoin.SpeedDialNumberStartJoin + i),
Type = PepperDash.Essentials.Devices.Common.Codec.eCodecCallType.Audio
});
}
var acProps = new
{
favorites = acFavs
};
var acStr = "audioCodec";
var acConf = new DeviceConfig()
{
Group = acStr,
Key = acStr,
Name = acStr,
Type = acStr,
Properties = JToken.FromObject(acProps)
};
co.Devices.Add(acConf);
}
Debug.Console(0, this, "******* CONFIG FROM DDVC: \r{0}", JsonConvert.SerializeObject(ConfigReader.ConfigObject, Formatting.Indented)); Debug.Console(0, this, "******* CONFIG FROM DDVC: \r{0}", JsonConvert.SerializeObject(ConfigReader.ConfigObject, Formatting.Indented));
var handler = ConfigurationIsReady; var handler = ConfigurationIsReady;
@@ -462,6 +549,9 @@ namespace PepperDash.Essentials.Room.Cotija
ConfigIsLoaded = true; ConfigIsLoaded = true;
} }
/// <summary>
///
/// </summary>
void SendFullStatus() void SendFullStatus()
{ {
if (ConfigIsLoaded) if (ConfigIsLoaded)
@@ -585,86 +675,5 @@ namespace PepperDash.Essentials.Room.Cotija
EISC.StringInput[StringJoin.UserCodeToSystem].StringValue = UserCode; EISC.StringInput[StringJoin.UserCodeToSystem].StringValue = UserCode;
EISC.StringInput[StringJoin.ServerUrl].StringValue = Parent.Config.ClientAppUrl; EISC.StringInput[StringJoin.ServerUrl].StringValue = Parent.Config.ClientAppUrl;
} }
/// <summary>
///
/// </summary>
/// <param name="oldKey"></param>
/// <param name="newKey"></param>
void SourceChange(string oldKey, string newKey)
{
/* Example message
* {
"type":"/room/status",
"content": {
"selectedSourceKey": "off",
}
}
*/
//if (type == ChangeType.WillChange)
//{
// // Disconnect from previous source
// if (info != null)
// {
// var previousDev = info.SourceDevice;
// // device type interfaces
// if (previousDev is ISetTopBoxControls)
// (previousDev as ISetTopBoxControls).UnlinkActions(Parent);
// // common interfaces
// if (previousDev is IChannel)
// (previousDev as IChannel).UnlinkActions(Parent);
// if (previousDev is IColor)
// (previousDev as IColor).UnlinkActions(Parent);
// if (previousDev is IDPad)
// (previousDev as IDPad).UnlinkActions(Parent);
// if (previousDev is IDvr)
// (previousDev as IDvr).UnlinkActions(Parent);
// if (previousDev is INumericKeypad)
// (previousDev as INumericKeypad).UnlinkActions(Parent);
// if (previousDev is IPower)
// (previousDev as IPower).UnlinkActions(Parent);
// if (previousDev is ITransport)
// (previousDev as ITransport).UnlinkActions(Parent);
// }
// var huddleRoom = room as EssentialsHuddleSpaceRoom;
// JObject roomStatus = new JObject();
// roomStatus.Add("selectedSourceKey", huddleRoom.CurrentSourceInfoKey);
// JObject message = new JObject();
// message.Add("type", "/room/status/");
// message.Add("content", roomStatus);
// Parent.PostToServer(message);
//}
//else
//{
// if (info != null)
// {
// var dev = info.SourceDevice;
// if (dev is ISetTopBoxControls)
// (dev as ISetTopBoxControls).LinkActions(Parent);
// if (dev is IChannel)
// (dev as IChannel).LinkActions(Parent);
// if (dev is IColor)
// (dev as IColor).LinkActions(Parent);
// if (dev is IDPad)
// (dev as IDPad).LinkActions(Parent);
// if (dev is IDvr)
// (dev as IDvr).LinkActions(Parent);
// if (dev is INumericKeypad)
// (dev as INumericKeypad).LinkActions(Parent);
// if (dev is IPower)
// (dev as IPower).LinkActions(Parent);
// if (dev is ITransport)
// (dev as ITransport).LinkActions(Parent);
// }
//}
}
} }
} }

View File

@@ -12,6 +12,7 @@ using PepperDash.Essentials.Core;
using PepperDash.Essentials.Room.Cotija; using PepperDash.Essentials.Room.Cotija;
using PepperDash.Essentials.Devices.Common.Codec; using PepperDash.Essentials.Devices.Common.Codec;
using PepperDash.Essentials.Devices.Common.VideoCodec; using PepperDash.Essentials.Devices.Common.VideoCodec;
using PepperDash.Essentials.Devices.Common.AudioCodec;
namespace PepperDash.Essentials namespace PepperDash.Essentials
{ {
@@ -22,6 +23,8 @@ namespace PepperDash.Essentials
public VideoCodecBaseMessenger VCMessenger { get; private set; } public VideoCodecBaseMessenger VCMessenger { get; private set; }
public AudioCodecBaseMessenger ACMessenger { get; private set; }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@@ -74,7 +77,7 @@ namespace PepperDash.Essentials
{ {
Parent.AddAction(string.Format(@"/room/{0}/volumes/master/level", Room.Key), new Action<ushort>(u => Parent.AddAction(string.Format(@"/room/{0}/volumes/master/level", Room.Key), new Action<ushort>(u =>
(volumeRoom.CurrentVolumeControls as IBasicVolumeWithFeedback).SetVolume(u))); (volumeRoom.CurrentVolumeControls as IBasicVolumeWithFeedback).SetVolume(u)));
Parent.AddAction(string.Format(@"/room/{0}/volumes/master/mute", Room.Key), new Action(() => Parent.AddAction(string.Format(@"/room/{0}/volumes/master/muteToggle", Room.Key), new Action(() =>
volumeRoom.CurrentVolumeControls.MuteToggle())); volumeRoom.CurrentVolumeControls.MuteToggle()));
volumeRoom.CurrentVolumeDeviceChange += new EventHandler<VolumeDeviceChangeEventArgs>(Room_CurrentVolumeDeviceChange); volumeRoom.CurrentVolumeDeviceChange += new EventHandler<VolumeDeviceChangeEventArgs>(Room_CurrentVolumeDeviceChange);
@@ -82,7 +85,7 @@ namespace PepperDash.Essentials
var currentVolumeDevice = volumeRoom.CurrentVolumeControls as IBasicVolumeWithFeedback; var currentVolumeDevice = volumeRoom.CurrentVolumeControls as IBasicVolumeWithFeedback;
if (currentVolumeDevice != null) if (currentVolumeDevice != null)
{ {
currentVolumeDevice.MuteFeedback.OutputChange += VolumeLevelFeedback_OutputChange; currentVolumeDevice.MuteFeedback.OutputChange += MuteFeedback_OutputChange;
currentVolumeDevice.VolumeLevelFeedback.OutputChange += VolumeLevelFeedback_OutputChange; currentVolumeDevice.VolumeLevelFeedback.OutputChange += VolumeLevelFeedback_OutputChange;
} }
} }
@@ -92,27 +95,23 @@ namespace PepperDash.Essentials
sscRoom.CurrentSingleSourceChange += new SourceInfoChangeHandler(Room_CurrentSingleSourceChange); sscRoom.CurrentSingleSourceChange += new SourceInfoChangeHandler(Room_CurrentSingleSourceChange);
var vcRoom = Room as IHasVideoCodec; var vcRoom = Room as IHasVideoCodec;
if (vcRoom != null) if (vcRoom != null && vcRoom.VideoCodec != null)
{ {
var codec = vcRoom.VideoCodec; 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); VCMessenger.RegisterWithAppServer(Parent);
// May need to move this or remove this
codec.CallStatusChange += new EventHandler<CodecCallStatusItemChangeEventArgs>(codec_CallStatusChange);
vcRoom.IsSharingFeedback.OutputChange += new EventHandler<FeedbackEventArgs>(IsSharingFeedback_OutputChange); vcRoom.IsSharingFeedback.OutputChange += new EventHandler<FeedbackEventArgs>(IsSharingFeedback_OutputChange);
}
//Parent.AddAction("/device/videoCodec/dial", new Action<string>(s => codec.Dial(s))); var acRoom = Room as IHasAudioCodec;
//Parent.AddAction("/device/videoCodec/endCall", new Action<string>(s => if (acRoom != null && acRoom.AudioCodec != null)
//{ {
// var call = codec.ActiveCalls.FirstOrDefault(c => c.Id == s); var codec = acRoom.AudioCodec;
// if (call != null) var key = acRoom.AudioCodec.Key + "-" + parent.Key;
// { ACMessenger = new AudioCodecBaseMessenger(key, acRoom.AudioCodec, "/device/audioCodec");
// codec.EndCall(call); ACMessenger.RegisterWithAppServer(Parent);
// }
//}));
//Parent.AddAction("/device/videoCodec/endAllCalls", new Action(() => codec.EndAllCalls()));
} }
var defCallRm = Room as IRunDefaultCallRoute; var defCallRm = Room as IRunDefaultCallRoute;
@@ -169,18 +168,18 @@ namespace PepperDash.Essentials
}); });
} }
/// <summary> ///// <summary>
/// Handler for codec changes ///// Handler for codec changes
/// </summary> ///// </summary>
void codec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e) //void codec_CallStatusChange(object sender, CodecCallStatusItemChangeEventArgs e)
{ //{
PostStatusMessage(new // PostStatusMessage(new
{ // {
calls = GetCallsMessageObject(), // calls = GetCallsMessageObject(),
//vtc = GetVtcCallsMessageObject() // //vtc = GetVtcCallsMessageObject()
}); // });
} //}
/// <summary> /// <summary>
/// Helper for posting status message /// Helper for posting status message
@@ -425,53 +424,52 @@ namespace PepperDash.Essentials
PostStatusMessage(new PostStatusMessage(new
{ {
calls = GetCallsMessageObject(), //calls = GetCallsMessageObject(),
isOn = room.OnFeedback.BoolValue, isOn = room.OnFeedback.BoolValue,
selectedSourceKey = sourceKey, selectedSourceKey = sourceKey,
vtc = GetVtcCallsMessageObject(), //vtc = GetVtcCallsMessageObject(),
volumes = volumes volumes = volumes
}); });
} }
/// <summary> ///// <summary>
/// Helper to return a anonymous object with the call data for JSON message ///// Helper to return a anonymous object with the call data for JSON message
/// </summary> ///// </summary>
/// <returns></returns> ///// <returns></returns>
object GetCallsMessageObject() //object GetCallsMessageObject()
{ //{
var callRm = Room as IHasVideoCodec; // var callRm = Room as IHasVideoCodec;
if (callRm == null) // if (callRm == null)
return null; // return null;
return new // return new
{ // {
activeCalls = callRm.VideoCodec.ActiveCalls, // activeCalls = callRm.VideoCodec.ActiveCalls,
callType = callRm.CallTypeFeedback.IntValue, // callType = callRm.CallTypeFeedback.IntValue,
inCall = callRm.InCallFeedback.BoolValue, // inCall = callRm.InCallFeedback.BoolValue,
isSharing = callRm.IsSharingFeedback.BoolValue, // isSharing = callRm.IsSharingFeedback.BoolValue,
privacyModeIsOn = callRm.PrivacyModeIsOnFeedback.BoolValue // privacyModeIsOn = callRm.PrivacyModeIsOnFeedback.BoolValue
}; // };
} //}
/// <summary>
/// Helper method to build call status for vtc
/// </summary>
/// <returns></returns>
object GetVtcCallsMessageObject()
{
var callRm = Room as IHasVideoCodec;
object vtc = null;
if (callRm != null)
{
var codec = callRm.VideoCodec;
vtc = new
{
isInCall = codec.IsInCall,
calls = codec.ActiveCalls
};
}
return vtc;
}
///// <summary>
///// Helper method to build call status for vtc
///// </summary>
///// <returns></returns>
//object GetVtcCallsMessageObject()
//{
// var callRm = Room as IHasVideoCodec;
// object vtc = null;
// if (callRm != null)
// {
// var codec = callRm.VideoCodec;
// vtc = new
// {
// isInCall = codec.IsInCall,
// calls = codec.ActiveCalls
// };
// }
// return vtc;
//}
} }
/// <summary> /// <summary>

View File

@@ -5,9 +5,17 @@ using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharpPro.EthernetCommunication; using Crestron.SimplSharpPro.EthernetCommunication;
using Newtonsoft.Json;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Lighting;
using PepperDash.Essentials.Core.Devices; using PepperDash.Essentials.Core.Devices;
using PepperDash.Essentials.Devices.Common;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.CrestronIO;
using PepperDash.Essentials.DM;
using PepperDash.Essentials.Devices.Common.Cameras;
namespace PepperDash.Essentials.Bridges namespace PepperDash.Essentials.Bridges
{ {
@@ -44,17 +52,93 @@ namespace PepperDash.Essentials.Bridges
/// </summary> /// </summary>
public class EiscApi : BridgeApi public class EiscApi : BridgeApi
{ {
public EiscApiPropertiesConfig PropertiesConfig { get; private set; }
public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; } public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc { get; private set; }
public EiscApi(string key, uint ipid, string hostname) : public EiscApi(DeviceConfig dc) :
base(key) base(dc.Key)
{ {
Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(ipid, hostname, Global.ControlSystem); PropertiesConfig = JsonConvert.DeserializeObject<EiscApiPropertiesConfig>(dc.Properties.ToString());
Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(PropertiesConfig.Control.IpIdInt, PropertiesConfig.Control.TcpSshProperties.Address, Global.ControlSystem);
Eisc.SigChange += new Crestron.SimplSharpPro.DeviceSupport.SigEventHandler(Eisc_SigChange); Eisc.SigChange += new Crestron.SimplSharpPro.DeviceSupport.SigEventHandler(Eisc_SigChange);
Eisc.Register(); Eisc.Register();
AddPostActivationAction( () =>
{
Debug.Console(1, this, "Linking Devices...");
foreach (var d in PropertiesConfig.Devices)
{
var device = DeviceManager.GetDeviceForKey(d.DeviceKey);
if (device != null)
{
if (device is PepperDash.Essentials.Core.Monitoring.SystemMonitorController)
{
(device as PepperDash.Essentials.Core.Monitoring.SystemMonitorController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is GenericComm)
{
(device as GenericComm).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is CameraBase)
{
(device as CameraBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is PepperDash.Essentials.Core.TwoWayDisplayBase)
{
(device as TwoWayDisplayBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is DmChassisController)
{
(device as DmChassisController).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is DmTxControllerBase)
{
(device as DmTxControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is DmRmcControllerBase)
{
(device as DmRmcControllerBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is GenericRelayDevice)
{
(device as GenericRelayDevice).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is IDigitalInput)
{
(device as IDigitalInput).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is LightingBase)
{
(device as LightingBase).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
else if (device is DigitalLogger)
{
(device as DigitalLogger).LinkToApi(Eisc, d.JoinStart, d.JoinMapKey);
continue;
}
}
}
Debug.Console(1, this, "Devices Linked.");
});
} }
/// <summary> /// <summary>
@@ -65,7 +149,7 @@ namespace PepperDash.Essentials.Bridges
void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args) void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args)
{ {
if (Debug.Level >= 1) if (Debug.Level >= 1)
Debug.Console(1, this, "BridgeApi EISC change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue); Debug.Console(1, this, "EiscApi change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
var uo = args.Sig.UserObject; var uo = args.Sig.UserObject;
if (uo is Action<bool>) if (uo is Action<bool>)
(uo as Action<bool>)(args.Sig.BoolValue); (uo as Action<bool>)(args.Sig.BoolValue);
@@ -76,138 +160,27 @@ namespace PepperDash.Essentials.Bridges
} }
} }
public class EiscApiPropertiesConfig
/// <summary>
/// Defines each type and it's matching API type
/// </summary>
public static class DeviceApiFactory
{ {
public static Dictionary<Type, Type> TypeMap = new Dictionary<Type, Type> [JsonProperty("control")]
public EssentialsControlPropertiesConfig Control { get; set; }
[JsonProperty("devices")]
public List<ApiDevice> Devices { get; set; }
public class ApiDevice
{ {
{ typeof(DmChassisController), typeof(DmChassisControllerApi) }, [JsonProperty("deviceKey")]
{ typeof(IBasicCommunication), typeof(IBasicCommunicationApi) } public string DeviceKey { get; set; }
//{ typeof(SomeShittyDisplayController), typeof(SomeShittyDisplayControllerApi) }
}; [JsonProperty("joinStart")]
public uint JoinStart { get; set; }
[JsonProperty("joinMapKey")]
public string JoinMapKey { get; set; }
} }
/// <summary>
/// API class for IBasicCommunication devices
/// </summary>
public class IBasicCommunicationApi : DeviceApiBase
{
public IBasicCommunication Device { get; set; }
SerialFeedback TextReceivedFeedback;
public IBasicCommunicationApi(IBasicCommunication dev)
{
TextReceivedFeedback = new SerialFeedback();
Device = dev;
SetupFeedbacks();
ActionApi = new Dictionary<string, Object>
{
{ "connect", new Action(Device.Connect) },
{ "disconnect", new Action(Device.Disconnect) },
{ "connectstate", new Action<bool>( b => ConnectByState(b) ) },
{ "sendtext", new Action<string>( s => Device.SendText(s) ) }
};
FeedbackApi = new Dictionary<string, Feedback>
{
{ "isconnected", new BoolFeedback( () => Device.IsConnected ) },
{ "textrecieved", TextReceivedFeedback }
};
}
/// <summary>
/// Controls connection based on state of input
/// </summary>
/// <param name="state"></param>
void ConnectByState(bool state)
{
if (state)
Device.Connect();
else
Device.Disconnect();
}
void SetupFeedbacks()
{
Device.TextReceived += new EventHandler<GenericCommMethodReceiveTextArgs>(Device_TextReceived);
if(Device is ISocketStatus)
(Device as ISocketStatus).ConnectionChange += new EventHandler<GenericSocketStatusChageEventArgs>(IBasicCommunicationApi_ConnectionChange);
}
void IBasicCommunicationApi_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e)
{
FeedbackApi["isconnected"].FireUpdate();
}
void Device_TextReceived(object sender, GenericCommMethodReceiveTextArgs e)
{
TextReceivedFeedback.FireUpdate(e.Text);
}
}
public class DmChassisController : Device
{
public DmChassisController(string key)
: base(key)
{
}
public void SetInput(int input)
{
Debug.Console(2, this, "Dm Chassis {0}, input {1}", Key, input);
}
}
/// <summary>
/// Each flavor of API is a static class with static properties and a static constructor that
/// links up the things to do.
/// </summary>
public class DmChassisControllerApi : DeviceApiBase
{
IntFeedback Output1Feedback;
IntFeedback Output2Feedback;
public DmChassisControllerApi(DmChassisController dev)
{
Output1Feedback = new IntFeedback( new Func<int>(() => 1));
Output2Feedback = new IntFeedback( new Func<int>(() => 2));
ActionApi = new Dictionary<string, Object>
{
};
FeedbackApi = new Dictionary<string, Feedback>
{
{ "Output-1/fb", Output1Feedback },
{ "Output-2/fb", Output2Feedback }
};
}
/// <summary>
/// Factory method
/// </summary>
/// <param name="dev"></param>
/// <returns></returns>
public static DmChassisControllerApi GetActionApiForDevice(DmChassisController dev)
{
return new DmChassisControllerApi(dev);
}
} }

View File

@@ -9,14 +9,16 @@ using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core.Routing; using PepperDash.Essentials.Core.Routing;
using PepperDash.Essentials.Bridges;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.EthernetCommunication; using Crestron.SimplSharpPro.EthernetCommunication;
namespace PepperDash.Essentials namespace PepperDash.Essentials
{ {
public class BridgeFactory public class BridgeFactory
{ {
public static IKeyed GetDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc) public static IKeyed GetDevice(DeviceConfig dc)
{ {
// ? why is this static JTA 2018-06-13? // ? why is this static JTA 2018-06-13?
@@ -25,67 +27,21 @@ namespace PepperDash.Essentials
var type = dc.Type; var type = dc.Type;
var properties = dc.Properties; var properties = dc.Properties;
var propAnon = new { }; var propAnon = new { };
JsonConvert.DeserializeAnonymousType(dc.Properties.ToString(), propAnon);
var typeName = dc.Type.ToLower(); var typeName = dc.Type.ToLower();
var groupName = dc.Group.ToLower(); var groupName = dc.Group.ToLower();
Debug.Console(0, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString()); //Debug.Console(2, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString());
if (typeName == "dm")
if (typeName == "eiscapi")
{ {
return new DmBridge(key, name, properties); return new EiscApi(dc);
} }
else if (typeName == "comm")
{
return new CommBridge(key, name, properties);
}
else
return null; return null;
} }
} }
public class DmBridge : Device
{
public EiscBridgeProperties Properties { get; private set; }
public PepperDash.Essentials.DM.DmChassisController DmSwitch { get; private set; }
public DmBridge(string key, string name, JToken properties) : base(key, name)
{
Properties = JsonConvert.DeserializeObject<EiscBridgeProperties>(properties.ToString());
}
public override bool CustomActivate()
{
// Create EiscApis
if (Properties.Eiscs != null)
{
foreach (var eisc in Properties.Eiscs)
{
var ApiEisc = new BridgeApiEisc(eisc.IpId, eisc.Hostname);
ApiEisc.Eisc.SetUShortSigAction(101, u => DmSwitch.ExecuteSwitch(u,1, eRoutingSignalType.Video));
ApiEisc.Eisc.SetUShortSigAction(102, u => DmSwitch.ExecuteSwitch(u,2, eRoutingSignalType.Video));
}
}
foreach (var device in DeviceManager.AllDevices)
{
if (device.Key == this.Properties.ParentDeviceKey)
{
Debug.Console(0, "deviceKey {0} Matches", device.Key);
DmSwitch = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.DM.DmChassisController;
}
else
{
Debug.Console(0, "deviceKey {0} doesn't match", device.Key);
}
}
Debug.Console(0, "Bridge {0} Activated", this.Name);
return true;
}
}
public class CommBridge : Device public class CommBridge : Device
{ {
@@ -182,3 +138,4 @@ namespace PepperDash.Essentials
} }
} }
} }

View File

@@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Core;
using PepperDash.Essentials.Core.Routing;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.EthernetCommunication;
using PepperDash.Essentials.Bridges;
namespace PepperDash.Essentials {
public class BridgeFactory {
public static IKeyed GetDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc) {
// ? why is this static JTA 2018-06-13?
var key = dc.Key;
var name = dc.Name;
var type = dc.Type;
var properties = dc.Properties;
var propAnon = new { };
JsonConvert.DeserializeAnonymousType(dc.Properties.ToString(), propAnon);
var typeName = dc.Type.ToLower();
var groupName = dc.Group.ToLower();
Debug.Console(2, "Name {0}, Key {1}, Type {2}, Properties {3}", name, key, type, properties.ToString());
if (typeName == "essentialdm")
{
return new EssentialDM(key, name, properties);
}
else if (typeName == "essentialcomm")
{
Debug.Console(2, "Launch Essential Comm");
return new EssentialComm(key, name, properties);
}
else if (typeName == "essentialdsp")
{
Debug.Console(2, "Launch EssentialDsp");
return new EssentialDsp(key, name, properties);
}
else if (typeName == "essentialstvone")
{
Debug.Console(2, "Launch essentialstvone");
return new EssentialsTVOne(key, name, properties);
}
else if (typeName == "essentialslighting")
{
Debug.Console(2, "Launch essentialslighting");
return new EssentialsLightsBridge(key, name, properties);
}
else if (typeName == "eiscapi")
{
return new EiscApi(dc);
}
return null;
}
}
public class BridgeApiEisc {
public uint Ipid;
public ThreeSeriesTcpIpEthernetIntersystemCommunications Eisc;
public BridgeApiEisc(string ipid) {
Ipid = (UInt32)int.Parse(ipid, System.Globalization.NumberStyles.HexNumber);
Eisc = new ThreeSeriesTcpIpEthernetIntersystemCommunications(Ipid, "127.0.0.2", Global.ControlSystem);
Eisc.Register();
Eisc.SigChange += Eisc_SigChange;
Debug.Console(2, "BridgeApiEisc Created at Ipid {0}", ipid);
}
void Eisc_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args) {
if (Debug.Level >= 1)
Debug.Console(2, "DDVC EISC change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
var uo = args.Sig.UserObject;
if (uo is Action<bool>)
(uo as Action<bool>)(args.Sig.BoolValue);
else if (uo is Action<ushort>)
(uo as Action<ushort>)(args.Sig.UShortValue);
else if (uo is Action<string>)
(uo as Action<string>)(args.Sig.StringValue);
}
}
}

View File

@@ -0,0 +1,187 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common;
namespace PepperDash.Essentials.Bridges
{
public static class CameraControllerApiExtensions
{
public static BasicTriList _TriList;
public static CameraControllerJoinMap JoinMap;
public static void LinkToApi(this PepperDash.Essentials.Devices.Common.Cameras.CameraBase cameraDevice, BasicTriList trilist, uint joinStart, string joinMapKey)
{
JoinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as CameraControllerJoinMap;
_TriList = trilist;
if (JoinMap == null)
{
JoinMap = new CameraControllerJoinMap();
}
JoinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(0, "Linking to Bridge Type {0}", cameraDevice.GetType().Name.ToString());
var commMonitor = cameraDevice as ICommunicationMonitor;
commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[JoinMap.IsOnline]);
trilist.SetBoolSigAction(JoinMap.Left, (b) =>
{
if (b)
{
cameraDevice.PanLeft();
}
else
{
cameraDevice.Stop();
}
});
trilist.SetBoolSigAction(JoinMap.Right, (b) =>
{
if (b)
{
cameraDevice.PanRight();
}
else
{
cameraDevice.Stop();
}
});
trilist.SetBoolSigAction(JoinMap.Up, (b) =>
{
if (b)
{
cameraDevice.TiltUp();
}
else
{
cameraDevice.Stop();
}
});
trilist.SetBoolSigAction(JoinMap.Down, (b) =>
{
if (b)
{
cameraDevice.TiltDown();
}
else
{
cameraDevice.Stop();
}
});
trilist.SetBoolSigAction(JoinMap.ZoomIn, (b) =>
{
if (b)
{
cameraDevice.ZoomIn();
}
else
{
cameraDevice.Stop();
}
});
trilist.SetBoolSigAction(JoinMap.ZoomOut, (b) =>
{
if (b)
{
cameraDevice.ZoomOut();
}
else
{
cameraDevice.Stop();
}
});
if (cameraDevice.GetType().Name.ToString().ToLower() == "cameravisca")
{
var viscaCamera = cameraDevice as PepperDash.Essentials.Devices.Common.Cameras.CameraVisca;
trilist.SetSigTrueAction(JoinMap.PowerOn, () => viscaCamera.PowerOn());
trilist.SetSigTrueAction(JoinMap.PowerOff, () => viscaCamera.PowerOff());
viscaCamera.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[JoinMap.PowerOn]);
viscaCamera.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[JoinMap.PowerOff]);
viscaCamera.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[JoinMap.IsOnline]);
for (int i = 0; i < JoinMap.NumberOfPresets; i++)
{
int tempNum = i;
trilist.SetSigTrueAction((ushort)(JoinMap.PresetRecallOffset + tempNum), () =>
{
viscaCamera.RecallPreset(tempNum);
});
trilist.SetSigTrueAction((ushort)(JoinMap.PresetSaveOffset + tempNum), () =>
{
viscaCamera.SavePreset(tempNum);
});
}
}
}
}
public class CameraControllerJoinMap : JoinMapBase
{
public uint IsOnline { get; set; }
public uint PowerOff { get; set; }
public uint PowerOn { get; set; }
public uint Up { get; set; }
public uint Down { get; set; }
public uint Left { get; set; }
public uint Right { get; set; }
public uint ZoomIn { get; set; }
public uint ZoomOut { get; set; }
public uint PresetRecallOffset { get; set; }
public uint PresetSaveOffset { get; set; }
public uint NumberOfPresets { get; set; }
public CameraControllerJoinMap()
{
// Digital
IsOnline = 9;
PowerOff = 8;
PowerOn = 7;
Up = 1;
Down = 2;
Left = 3;
Right = 4;
ZoomIn = 5;
ZoomOut = 6;
PresetRecallOffset = 10;
PresetSaveOffset = 30;
NumberOfPresets = 5;
// Analog
}
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
IsOnline = IsOnline + joinOffset;
PowerOff = PowerOff + joinOffset;
PowerOn = PowerOn + joinOffset;
Up = Up + joinOffset;
Down = Down + joinOffset;
Left = Left + joinOffset;
Right = Right + joinOffset;
ZoomIn = ZoomIn + joinOffset;
ZoomOut = ZoomOut + joinOffset;
PresetRecallOffset = PresetRecallOffset + joinOffset;
PresetSaveOffset = PresetSaveOffset + joinOffset;
}
}
}

View File

@@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common;
namespace PepperDash.Essentials.Bridges
{
public static class DigitalLoggerApiExtensions
{
public static void LinkToApi(this DigitalLogger DigitalLogger, BasicTriList trilist, uint joinStart, string joinMapKey)
{
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DigitalLoggerJoinMap;
if (joinMap == null)
joinMap = new DigitalLoggerJoinMap();
joinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, DigitalLogger, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
for (uint i = 1; i <= DigitalLogger.CircuitCount; i++)
{
var circuit = i;
DigitalLogger.CircuitNameFeedbacks[circuit - 1].LinkInputSig(trilist.StringInput[joinMap.CircuitNames + circuit]);
DigitalLogger.CircuitIsCritical[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitIsCritical + circuit]);
DigitalLogger.CircuitState[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitState + circuit]);
trilist.SetSigTrueAction(joinMap.CircuitCycle + circuit, () => DigitalLogger.CycleCircuit(circuit - 1));
trilist.SetSigTrueAction(joinMap.CircuitOnCmd + circuit, () => DigitalLogger.TurnOnCircuit(circuit - 1));
trilist.SetSigTrueAction(joinMap.CircuitOffCmd + circuit, () => DigitalLogger.TurnOffCircuit(circuit - 1));
}
}
}
public class DigitalLoggerJoinMap : JoinMapBase
{
public uint IsOnline { get; set; }
public uint CircuitNames { get; set; }
public uint CircuitState { get; set; }
public uint CircuitCycle { get; set; }
public uint CircuitIsCritical { get; set; }
public uint CircuitOnCmd { get; set; }
public uint CircuitOffCmd { get; set; }
public DigitalLoggerJoinMap()
{
// Digital
IsOnline = 9;
CircuitState = 0;
CircuitCycle = 0;
CircuitIsCritical = 10;
CircuitOnCmd = 10;
CircuitOffCmd = 20;
// Serial
CircuitNames = 0;
// Analog
}
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
IsOnline = IsOnline + joinOffset;
CircuitNames = CircuitNames + joinOffset;
CircuitState = CircuitState + joinOffset;
CircuitCycle = CircuitCycle + joinOffset;
CircuitIsCritical = CircuitIsCritical + joinOffset;
CircuitOnCmd = CircuitOnCmd + joinOffset;
CircuitOffCmd = CircuitOffCmd + joinOffset;
}
}
}

View File

@@ -0,0 +1,171 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common;
namespace PepperDash.Essentials.Bridges
{
public static class DisplayControllerApiExtensions
{
public static BasicTriList _TriList;
public static DisplayControllerJoinMap JoinMap;
public static int InputNumber;
public static IntFeedback InputNumberFeedback;
public static List<string> InputKeys = new List<string>();
public static void LinkToApi(this PepperDash.Essentials.Core.TwoWayDisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey)
{
JoinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DisplayControllerJoinMap;
_TriList = trilist;
if (JoinMap == null)
{
JoinMap = new DisplayControllerJoinMap();
}
JoinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(0, "Linking to Bridge Type {0}", displayDevice.GetType().Name.ToString());
trilist.StringInput[JoinMap.Name].StringValue = displayDevice.GetType().Name.ToString();
InputNumberFeedback = new IntFeedback(() => { return InputNumber;});
InputNumberFeedback.LinkInputSig(trilist.UShortInput[JoinMap.InputSelect]);
var commMonitor = displayDevice as ICommunicationMonitor;
commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[JoinMap.IsOnline]);
// Poewer Off
trilist.SetSigTrueAction(JoinMap.PowerOff, () =>
{
InputNumber = 102;
InputNumberFeedback.FireUpdate();
displayDevice.PowerOff();
});
displayDevice.PowerIsOnFeedback.OutputChange += new EventHandler<FeedbackEventArgs>(PowerIsOnFeedback_OutputChange);
displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[JoinMap.PowerOff]);
// Poewer On
trilist.SetSigTrueAction(JoinMap.PowerOn, () =>
{
InputNumber = 0;
InputNumberFeedback.FireUpdate();
displayDevice.PowerOn();
});
displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[JoinMap.PowerOn]);
int count = 1;
foreach (var input in displayDevice.InputPorts)
{
InputKeys.Add(input.Key.ToString());
var tempKey = InputKeys.ElementAt(count - 1);
trilist.SetSigTrueAction((ushort)(JoinMap.InputSelectOffset + count), () => { displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector); });
trilist.StringInput[(ushort)(JoinMap.InputNamesOffset + count)].StringValue = input.Key.ToString();
count++;
}
displayDevice.CurrentInputFeedback.OutputChange += new EventHandler<FeedbackEventArgs>(CurrentInputFeedback_OutputChange);
trilist.SetUShortSigAction(JoinMap.InputSelect, (a) =>
{
if (a == 0)
{
displayDevice.PowerOff();
InputNumber = 0;
}
else if (a > 0 && a < displayDevice.InputPorts.Count && a != InputNumber)
{
displayDevice.ExecuteSwitch(displayDevice.InputPorts.ElementAt(a - 1).Selector);
InputNumber = a;
}
else if (a == 102)
{
displayDevice.PowerToggle();
}
InputNumberFeedback.FireUpdate();
});
}
static void CurrentInputFeedback_OutputChange(object sender, FeedbackEventArgs e)
{
Debug.Console(0, "CurrentInputFeedback_OutputChange {0}", e.StringValue);
}
static void PowerIsOnFeedback_OutputChange(object sender, FeedbackEventArgs e)
{
// Debug.Console(0, "PowerIsOnFeedback_OutputChange {0}", e.BoolValue);
if (!e.BoolValue)
{
InputNumber = 102;
InputNumberFeedback.FireUpdate();
}
else
{
InputNumber = 0;
InputNumberFeedback.FireUpdate();
}
}
}
public class DisplayControllerJoinMap : JoinMapBase
{
public uint Name { get; set; }
public uint InputNamesOffset { get; set; }
public uint InputSelectOffset { get; set; }
public uint IsOnline { get; set; }
public uint PowerOff { get; set; }
public uint InputSelect { get; set; }
public uint PowerOn { get; set; }
public uint SelectScene { get; set; }
public uint LightingSceneOffset { get; set; }
public uint ButtonVisibilityOffset { get; set; }
public uint IntegrationIdSet { get; set; }
public DisplayControllerJoinMap()
{
// Digital
IsOnline = 50;
PowerOff = 1;
PowerOn = 2;
InputSelect = 4;
IntegrationIdSet = 1;
LightingSceneOffset = 10;
ButtonVisibilityOffset = 40;
Name = 1;
InputNamesOffset = 10;
InputSelectOffset = 4;
// Analog
}
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
IsOnline = IsOnline + joinOffset;
PowerOff = PowerOff + joinOffset;
PowerOn = PowerOn + joinOffset;
SelectScene = SelectScene + joinOffset;
LightingSceneOffset = LightingSceneOffset + joinOffset;
ButtonVisibilityOffset = ButtonVisibilityOffset + joinOffset;
Name = Name + joinOffset;
InputNamesOffset = InputNamesOffset + joinOffset;
InputSelectOffset = InputSelectOffset + joinOffset;
}
}
}

View File

@@ -0,0 +1,130 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.DM;
namespace PepperDash.Essentials.Bridges
{
public static class DmChassisControllerApiExtentions
{
public static void LinkToApi(this DmChassisController dmChassis, BasicTriList trilist, uint joinStart, string joinMapKey)
{
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DmChassisControllerJoinMap;
if (joinMap == null)
joinMap = new DmChassisControllerJoinMap();
joinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, dmChassis, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
dmChassis.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
// Link up outputs
for (uint i = 1; i <= dmChassis.Chassis.NumberOfOutputs - 1; i++)
{
var ioSlot = i;
// Control
trilist.SetUShortSigAction(joinMap.OutputVideo + ioSlot, new Action<ushort>(o => dmChassis.ExecuteSwitch(o, ioSlot, eRoutingSignalType.Video)));
trilist.SetUShortSigAction(joinMap.OutputAudio + ioSlot, new Action<ushort>(o => dmChassis.ExecuteSwitch(o, ioSlot, eRoutingSignalType.Audio)));
if (dmChassis.TxDictionary.ContainsKey(ioSlot))
{
Debug.Console(2, "Creating Tx Feedbacks {0}", ioSlot);
var TxKey = dmChassis.TxDictionary[ioSlot];
var TxDevice = DeviceManager.GetDeviceForKey(TxKey) as DmTxControllerBase;
TxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]);
// TxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]);
// trilist.SetUShortSigAction((ApiMap.HdcpSupport[ioSlot]), u => TxDevice.SetHdcpSupportAll((ePdtHdcpSupport)(u)));
// TxDevice.HdcpSupportAllFeedback.LinkInputSig(trilist.UShortInput[joinMap. + ioSlot]);
// trilist.UShortInput[ApiMap.HdcpSupportCapability[ioSlot]].UShortValue = TxDevice.HdcpSupportCapability;
}
else
{
// dmChassis.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[ApiMap.TxVideoSyncStatus[ioSlot]]);
}
if (dmChassis.RxDictionary.ContainsKey(ioSlot))
{
Debug.Console(2, "Creating Rx Feedbacks {0}", ioSlot);
var RxKey = dmChassis.RxDictionary[ioSlot];
var RxDevice = DeviceManager.GetDeviceForKey(RxKey) as DmRmcControllerBase;
RxDevice.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]);
}
// Feedback
dmChassis.VideoOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputVideo + ioSlot]);
dmChassis.AudioOutputFeedbacks[ioSlot].LinkInputSig(trilist.UShortInput[joinMap.OutputAudio + ioSlot]);
dmChassis.VideoInputSyncFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus + ioSlot]);
dmChassis.OutputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputNames + ioSlot]);
dmChassis.InputNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.InputNames + ioSlot]);
dmChassis.OutputVideoRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentVideoInputNames + ioSlot]);
dmChassis.OutputAudioRouteNameFeedbacks[ioSlot].LinkInputSig(trilist.StringInput[joinMap.OutputCurrentAudioInputNames + ioSlot]);
// dmChassis.InputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.InputEndpointOnline + ioSlot]);
// dmChassis.OutputEndpointOnlineFeedbacks[ioSlot].LinkInputSig(trilist.BooleanInput[joinMap.OutputEndpointOnline + ioSlot]);
}
}
public class DmChassisControllerJoinMap : JoinMapBase
{
public uint IsOnline { get; set; }
public uint OutputVideo { get; set; }
public uint OutputAudio { get; set; }
public uint VideoSyncStatus { get; set; }
public uint InputNames { get; set; }
public uint OutputNames { get; set; }
public uint OutputCurrentVideoInputNames { get; set; }
public uint OutputCurrentAudioInputNames { get; set; }
public uint InputCurrentResolution { get; set; }
public uint InputEndpointOnline { get; set; }
public uint OutputEndpointOnline { get; set; }
//public uint HdcpSupport { get; set; }
//public uint HdcpSupportCapability { get; set; }
public DmChassisControllerJoinMap()
{
IsOnline = 11;
OutputVideo = 100; //101-299
OutputAudio = 300; //301-499
VideoSyncStatus = 100; //101-299
InputNames = 100; //101-299
OutputNames = 300; //301-499
OutputCurrentVideoInputNames = 2000; //2001-2199
OutputCurrentAudioInputNames = 2200; //2201-2399
InputCurrentResolution = 2400; // 2401-2599
InputEndpointOnline = 500;
OutputEndpointOnline = 700;
//HdcpSupport = 1000; //1001-1199
//HdcpSupportCapability = 1200; //1201-1399
}
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
IsOnline = IsOnline + joinOffset;
OutputVideo = OutputVideo + joinOffset;
OutputAudio = OutputAudio + joinOffset;
VideoSyncStatus = VideoSyncStatus + joinOffset;
InputNames = InputNames + joinOffset;
OutputNames = OutputNames + joinOffset;
OutputCurrentVideoInputNames = OutputCurrentVideoInputNames + joinOffset;
OutputCurrentAudioInputNames = OutputCurrentAudioInputNames + joinOffset;
InputCurrentResolution = InputCurrentResolution + joinOffset;
InputEndpointOnline = InputEndpointOnline + joinOffset;
OutputEndpointOnline = OutputEndpointOnline + joinOffset;
//HdcpSupport = HdcpSupport + joinOffset;
//HdcpSupportCapability = HdcpSupportCapability + joinOffset;
}
}
}
}

View File

@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.DM;
namespace PepperDash.Essentials.Bridges
{
public static class DmRmcControllerApiExtensions
{
public static void LinkToApi(this DmRmcControllerBase rmc, BasicTriList trilist, uint joinStart, string joinMapKey)
{
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DmRmcControllerJoinMap;
if (joinMap == null)
joinMap = new DmRmcControllerJoinMap();
joinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, rmc, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
rmc.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
if(rmc.VideoOutputResolutionFeedback != null)
rmc.VideoOutputResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentOutputResolution]);
if(rmc.EdidManufacturerFeedback != null)
rmc.EdidManufacturerFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidManufacturer]);
if(rmc.EdidNameFeedback != null)
rmc.EdidNameFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidName]);
if(rmc.EdidPreferredTimingFeedback != null)
rmc.EdidPreferredTimingFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidPrefferedTiming]);
if(rmc.EdidSerialNumberFeedback != null)
rmc.EdidSerialNumberFeedback.LinkInputSig(trilist.StringInput[joinMap.EdidSerialNumber]);
}
public class DmRmcControllerJoinMap : JoinMapBase
{
public uint IsOnline { get; set; }
public uint CurrentOutputResolution { get; set; }
public uint EdidManufacturer { get; set; }
public uint EdidName { get; set; }
public uint EdidPrefferedTiming { get; set; }
public uint EdidSerialNumber { get; set; }
public DmRmcControllerJoinMap()
{
// Digital
IsOnline = 1;
// Serial
CurrentOutputResolution = 1;
EdidManufacturer = 2;
EdidName = 3;
EdidPrefferedTiming = 4;
EdidSerialNumber = 5;
}
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
IsOnline = IsOnline + joinOffset;
CurrentOutputResolution = CurrentOutputResolution + joinOffset;
EdidManufacturer = EdidManufacturer + joinOffset;
EdidName = EdidName + joinOffset;
EdidPrefferedTiming = EdidPrefferedTiming + joinOffset;
EdidSerialNumber = EdidSerialNumber + joinOffset;
}
}
}
}

View File

@@ -0,0 +1,173 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DM;
using Crestron.SimplSharpPro.DM.Endpoints;
using Crestron.SimplSharpPro.DM.Endpoints.Transmitters;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.DM;
namespace PepperDash.Essentials.Bridges
{
public static class DmTxControllerApiExtensions
{
public static void LinkToApi(this DmTxControllerBase tx, BasicTriList trilist, uint joinStart, string joinMapKey)
{
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DmTxControllerJoinMap;
if (joinMap == null)
joinMap = new DmTxControllerJoinMap();
joinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, tx, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
tx.IsOnline.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
tx.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VideoSyncStatus]);
tx.AnyVideoInput.VideoStatus.VideoResolutionFeedback.LinkInputSig(trilist.StringInput[joinMap.CurrentInputResolution]);
//tx.HdcpSupportAllFeedback.LinkInputSig(trilist.UShortInput[joinMap.HdcpSupportCapability]);
bool hdcpTypeSimple;
if (tx.Hardware is DmTx4kX02CBase || tx.Hardware is DmTx4kzX02CBase)
hdcpTypeSimple = false;
else
hdcpTypeSimple = true;
if (tx is ITxRouting)
{
var txR = tx as ITxRouting;
trilist.SetUShortSigAction(joinMap.VideoInput,
new Action<ushort>(i => txR.ExecuteNumericSwitch(i, 0, eRoutingSignalType.Video)));
trilist.SetUShortSigAction(joinMap.AudioInput,
new Action<ushort>(i => txR.ExecuteNumericSwitch(i, 0, eRoutingSignalType.Audio)));
txR.VideoSourceNumericFeedback.LinkInputSig(trilist.UShortInput[joinMap.VideoInput]);
txR.AudioSourceNumericFeedback.LinkInputSig(trilist.UShortInput[joinMap.AudioInput]);
trilist.UShortInput[joinMap.HdcpSupportCapability].UShortValue = (ushort)tx.HdcpSupportCapability;
if(txR.InputPorts[DmPortName.HdmiIn] != null)
{
var inputPort = txR.InputPorts[DmPortName.HdmiIn];
if (tx.Feedbacks["HdmiInHdcpCapability"] != null)
(tx.Feedbacks["HdmiInHdcpCapability"] as IntFeedback).LinkInputSig(trilist.UShortInput[joinMap.Port1HdcpState]);
if (inputPort.ConnectionType == eRoutingPortConnectionType.Hdmi && inputPort.Port != null)
{
var port = inputPort.Port as EndpointHdmiInput;
SetHdcpCapabilityAction(hdcpTypeSimple, port, joinMap.Port1HdcpState, trilist);
}
}
if (txR.InputPorts[DmPortName.HdmiIn1] != null)
{
var inputPort = txR.InputPorts[DmPortName.HdmiIn1];
if (tx.Feedbacks["HdmiIn1HdcpCapability"] != null)
(tx.Feedbacks["HdmiIn1HdcpCapability"] as IntFeedback).LinkInputSig(trilist.UShortInput[joinMap.Port1HdcpState]);
if (inputPort.ConnectionType == eRoutingPortConnectionType.Hdmi && inputPort.Port != null)
{
var port = inputPort.Port as EndpointHdmiInput;
SetHdcpCapabilityAction(hdcpTypeSimple, port, joinMap.Port1HdcpState, trilist);
}
}
if (txR.InputPorts[DmPortName.HdmiIn2] != null)
{
var inputPort = txR.InputPorts[DmPortName.HdmiIn2];
if (tx.Feedbacks["HdmiIn2HdcpCapability"] != null)
(tx.Feedbacks["HdmiIn2HdcpCapability"] as IntFeedback).LinkInputSig(trilist.UShortInput[joinMap.Port1HdcpState]);
if (inputPort.ConnectionType == eRoutingPortConnectionType.Hdmi && inputPort.Port != null)
{
var port = inputPort.Port as EndpointHdmiInput;
SetHdcpCapabilityAction(hdcpTypeSimple, port, joinMap.Port2HdcpState, trilist);
}
}
}
}
static void SetHdcpCapabilityAction(bool hdcpTypeSimple, EndpointHdmiInput port, uint join, BasicTriList trilist)
{
if (hdcpTypeSimple)
{
trilist.SetUShortSigAction(join,
new Action<ushort>(s =>
{
if (s == 0)
{
port.HdcpSupportOff();
}
else if (s > 0)
{
port.HdcpSupportOn();
}
}));
}
else
{
trilist.SetUShortSigAction(join,
new Action<ushort>(s =>
{
port.HdcpCapability = (eHdcpCapabilityType)s;
}));
}
}
public class DmTxControllerJoinMap : JoinMapBase
{
public uint IsOnline { get; set; }
public uint VideoSyncStatus { get; set; }
public uint CurrentInputResolution { get; set; }
public uint HdcpSupportCapability { get; set; }
public uint VideoInput { get; set; }
public uint AudioInput { get; set; }
public uint Port1HdcpState { get; set; }
public uint Port2HdcpState { get; set; }
public DmTxControllerJoinMap()
{
// Digital
IsOnline = 1;
VideoSyncStatus = 2;
// Serial
CurrentInputResolution = 1;
// Analog
VideoInput = 1;
AudioInput = 2;
HdcpSupportCapability = 3;
Port1HdcpState = 4;
Port2HdcpState = 5;
}
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
IsOnline = IsOnline + joinOffset;
VideoSyncStatus = VideoSyncStatus + joinOffset;
CurrentInputResolution = CurrentInputResolution + joinOffset;
VideoInput = VideoInput + joinOffset;
AudioInput = AudioInput + joinOffset;
HdcpSupportCapability = HdcpSupportCapability + joinOffset;
Port1HdcpState = Port1HdcpState + joinOffset;
Port2HdcpState = Port2HdcpState + joinOffset;
}
}
}
}

View File

@@ -0,0 +1,120 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common;
namespace PepperDash.Essentials.Bridges
{
public static class SamsungDisplayControllerApiExtensions
{
public static void LinkToApi(this PepperDash.Essentials.Core.TwoWayDisplayBase displayDevice, BasicTriList trilist, uint joinStart, string joinMapKey)
{
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as DisplayControllerJoinMap;
if (joinMap == null)
{
joinMap = new DisplayControllerJoinMap();
}
joinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(0, "Linking to lighting Type {0}", displayDevice.GetType().Name.ToString());
var commMonitor = displayDevice as ICommunicationMonitor;
commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
// Poewer Off
trilist.SetSigTrueAction(joinMap.PowerOff, () => displayDevice.PowerOff());
displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff]);
// Poewer On
trilist.SetSigTrueAction(joinMap.PowerOn, () => displayDevice.PowerOn());
displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn]);
// GenericLighitng Actions & FeedBack
// int sceneIndex = 1;
/*
foreach (var scene in displayDevice.LightingScenes)
{
var tempIndex = sceneIndex - 1;
//trilist.SetSigTrueAction((uint)(joinMap.LightingSceneOffset + sceneIndex), () => displayDevice.SelectScene(displayDevice.LightingScenes[tempIndex]));
scene.IsActiveFeedback.LinkInputSig(trilist.BooleanInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)]);
trilist.StringInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)].StringValue = scene.Name;
trilist.BooleanInput[(uint)(joinMap.ButtonVisibilityOffset + sceneIndex)].BoolValue = true;
sceneIndex++;
}
if (displayDevice.GetType().Name.ToString() == "LutronQuantumArea")
{
var lutronDevice = displayDevice as PepperDash.Essentials.Devices.Common.Environment.Lutron.LutronQuantumArea;
lutronDevice.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
trilist.SetStringSigAction(joinMap.IntegrationIdSet, s => lutronDevice.IntegrationId = s);
}
*/
//ApiEisc.Eisc.SetStringSigAction(ApiMap.integrationID, (s) => { lutronLights.IntegrationId = s; });
/*
var lutronLights = displayDevice as PepperDash.Essentials.Devices.Common.Environment.Lutron.LutronQuantumArea;
for (uint i = 1; i <= lightingBase.CircuitCount; i++)
{
var circuit = i;
lightingBase.CircuitNameFeedbacks[circuit - 1].LinkInputSig(trilist.StringInput[joinMap.CircuitNames + circuit]);
lightingBase.CircuitIsCritical[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitIsCritical + circuit]);
lightingBase.CircuitState[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitState + circuit]);
trilist.SetSigTrueAction(joinMap.CircuitCycle + circuit, () => lightingBase.CycleCircuit(circuit - 1));
trilist.SetSigTrueAction(joinMap.CircuitOnCmd + circuit, () => lightingBase.TurnOnCircuit(circuit - 1));
trilist.SetSigTrueAction(joinMap.CircuitOffCmd + circuit, () => lightingBase.TurnOffCircuit(circuit - 1));
}
*/
}
}
public class DisplayControllerJoinMap : JoinMapBase
{
public uint IsOnline { get; set; }
public uint PowerOff { get; set; }
public uint PowerOn { get; set; }
public uint SelectScene { get; set; }
public uint LightingSceneOffset { get; set; }
public uint ButtonVisibilityOffset { get; set; }
public uint IntegrationIdSet { get; set; }
public DisplayControllerJoinMap()
{
// Digital
IsOnline = 1;
PowerOff = 1;
PowerOn = 2;
SelectScene = 1;
IntegrationIdSet = 1;
LightingSceneOffset = 10;
ButtonVisibilityOffset = 40;
// Analog
}
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
IsOnline = IsOnline + joinOffset;
PowerOff = PowerOff + joinOffset;
PowerOn = PowerOn + joinOffset;
SelectScene = SelectScene + joinOffset;
LightingSceneOffset = LightingSceneOffset + joinOffset;
ButtonVisibilityOffset = ButtonVisibilityOffset + joinOffset;
}
}
}

View File

@@ -0,0 +1,144 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Core;
using PepperDash.Essentials.Core.Routing;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.EthernetCommunication;
using Crestron.SimplSharpPro.CrestronThread;
namespace PepperDash.Essentials {
public class EssentialCommConfig {
public string[] EiscApiIpids;
public EssentialCommCommConnectionConfigs[] CommConnections;
}
public class EssentialCommCommConnectionConfigs {
public uint joinNumber {get; set; }
public EssentialsControlPropertiesConfig control { get; set; }
}
public class EssentialCommsPort {
public IBasicCommunication Comm;
public IntFeedback StatusFeedback;
public BoolFeedback ConnectedFeedback;
public List<EssentialComApiMap> Outputs = new List<EssentialComApiMap>();
public String RxBuffer;
public EssentialCommsPort(EssentialsControlPropertiesConfig config, string keyPrefix) {
Comm = CommFactory.CreateCommForConfig(config, keyPrefix);
// var PortGather = new CommunicationGather(Comm, config.EndOfLineChar);
Comm.TextReceived += new EventHandler<GenericCommMethodReceiveTextArgs>(Communication_TextReceived);
var socket = Comm as ISocketStatus;
StatusFeedback = new IntFeedback(() => { return (int)socket.ClientStatus; });
ConnectedFeedback = new BoolFeedback(() => { return Comm.IsConnected; });
if (socket != null) {
socket.ConnectionChange += new EventHandler<GenericSocketStatusChageEventArgs>(socket_ConnectionChange);
} else {
}
}
void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs e) {
StatusFeedback.FireUpdate();
ConnectedFeedback.FireUpdate();
if (e.Client.IsConnected) {
// Tasks on connect
} else {
// Cleanup items from this session
}
}
void Communication_TextReceived(object sender, GenericCommMethodReceiveTextArgs args) {
try {
foreach (var Output in Outputs) {
Output.Api.Eisc.StringInput[Output.Join].StringValue = args.Text;
}
}
catch (Exception) {
throw new FormatException(string.Format("ERROR:{0}"));
}
}
}
public class EssentialComm : Device {
public EssentialCommConfig Properties;
public CommunicationGather PortGather { get; private set; }
public List<BridgeApiEisc> Apis {get; set;}
public Dictionary<string, StringFeedback> CommFeedbacks {get; private set; }
public StatusMonitorBase CommunicationMonitor { get; private set; }
public Dictionary<uint, EssentialCommsPort> CommDictionary { get; private set; }
public EssentialComm(string key, string name, JToken properties) : base(key, name) {
Properties = JsonConvert.DeserializeObject<EssentialCommConfig>(properties.ToString());
CommFeedbacks = new Dictionary<string, StringFeedback>();
CommDictionary = new Dictionary<uint, EssentialCommsPort>();
Apis = new List<BridgeApiEisc>();
int commNumber = 1;
foreach (var commConfig in Properties.CommConnections) {
var commPort = new EssentialCommsPort(commConfig.control, string.Format("{0}-{1}", this.Key, commConfig.joinNumber));
CommDictionary.Add(commConfig.joinNumber, commPort);
commNumber++;
}
foreach (var Ipid in Properties.EiscApiIpids) {
var ApiEisc = new BridgeApiEisc(Ipid);
Apis.Add(ApiEisc);
foreach (var commConnection in CommDictionary) {
Debug.Console(2, "Joining Api{0} to comm {1}", Ipid, commConnection.Key);
var tempComm = commConnection.Value;
var tempJoin = (uint)commConnection.Key;
EssentialComApiMap ApiMap = new EssentialComApiMap(ApiEisc, (uint)tempJoin);
tempComm.Outputs.Add(ApiMap);
// Check for ApiMap Overide Values here
ApiEisc.Eisc.SetBoolSigAction(tempJoin, b => {if (b) { tempComm.Comm.Connect(); } else { tempComm.Comm.Disconnect(); }});
ApiEisc.Eisc.SetStringSigAction(tempJoin, s => tempComm.Comm.SendText(s));
tempComm.StatusFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[tempJoin]);
tempComm.ConnectedFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[tempJoin]);
}
ApiEisc.Eisc.Register();
}
}
public override bool CustomActivate()
{
try {
Debug.Console(2, "Name {0} Activated", this.Name);
return true;
}
catch (Exception e) {
Debug.Console(0, "Bridge {0}", e);
return false;
}
}
}
public class EssentialComApiMap {
public uint Join;
public BridgeApiEisc Api;
public uint connectJoin;
public EssentialComApiMap(BridgeApiEisc api, uint join) {
Join = join;
Api = api;
}
}
}

View File

@@ -0,0 +1,150 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.DM;
using PepperDash.Core;
using PepperDash.Essentials.Core.Routing;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.EthernetCommunication;
using Crestron.SimplSharpPro.DM;
namespace PepperDash.Essentials {
public class EssentialDM : PepperDash.Core.Device {
public EssentialDMProperties Properties;
public List<BridgeApiEisc> BridgeApiEiscs;
private PepperDash.Essentials.DM.DmChassisController DmSwitch;
private EssentialDMApiMap ApiMap = new EssentialDMApiMap();
public EssentialDM(string key, string name, JToken properties)
: base(key, name) {
Properties = JsonConvert.DeserializeObject<EssentialDMProperties>(properties.ToString());
}
public override bool CustomActivate() {
// Create EiscApis
try {
foreach (var device in DeviceManager.AllDevices) {
if (device.Key == this.Properties.connectionDeviceKey) {
Debug.Console(2, "deviceKey {0} Matches", device.Key);
DmSwitch = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.DM.DmChassisController;
}
else {
Debug.Console(2, "deviceKey {0} doesn't match", device.Key);
}
}
if (Properties.EiscApiIpids != null) {
foreach (string Ipid in Properties.EiscApiIpids) {
var ApiEisc = new BridgeApiEisc(Ipid);
for (uint x = 1; x <= DmSwitch.Chassis.NumberOfInputs;x++ ) {
uint tempX = x;
Debug.Console(2, "Creating EiscActions {0}", tempX);
ApiEisc.Eisc.SetUShortSigAction(ApiMap.OutputVideoRoutes[tempX], u => DmSwitch.ExecuteSwitch(u, tempX, eRoutingSignalType.Video));
ApiEisc.Eisc.SetUShortSigAction(ApiMap.OutputAudioRoutes[tempX], u => DmSwitch.ExecuteSwitch(u, tempX, eRoutingSignalType.Audio));
if (DmSwitch.TxDictionary.ContainsKey(tempX)) {
Debug.Console(2, "Creating Tx Feedbacks {0}", tempX);
var TxKey = DmSwitch.TxDictionary[tempX];
var TxDevice = DeviceManager.GetDeviceForKey(TxKey) as DmTxControllerBase;
TxDevice.IsOnline.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.TxOnlineStatus[tempX]]);
TxDevice.AnyVideoInput.VideoStatus.VideoSyncFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.TxVideoSyncStatus[tempX]]);
ApiEisc.Eisc.SetUShortSigAction((ApiMap.HdcpSupport[tempX]), u => TxDevice.SetHdcpSupportAll((ePdtHdcpSupport)(u)));
TxDevice.HdcpSupportAllFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.HdcpSupport[tempX]]);
ApiEisc.Eisc.UShortInput[ApiMap.HdcpSupportCapability[tempX]].UShortValue = TxDevice.HdcpSupportCapability;
}
else {
DmSwitch.VideoInputSyncFeedbacks[tempX].LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.TxVideoSyncStatus[tempX]]);
}
if (DmSwitch.RxDictionary.ContainsKey(tempX)) {
Debug.Console(2, "Creating Rx Feedbacks {0}", tempX);
var RxKey = DmSwitch.RxDictionary[tempX];
var RxDevice = DeviceManager.GetDeviceForKey(RxKey) as DmRmcControllerBase;
RxDevice.IsOnline.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.RxOnlineStatus[tempX]]);
}
// DmSwitch.InputEndpointOnlineFeedbacks[(ushort)tempOutputNum].LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.OutputVideoRoutes[tempOutputNum]]);
DmSwitch.VideoOutputFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.OutputVideoRoutes[tempX]]);
DmSwitch.AudioOutputFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.OutputAudioRoutes[tempX]]);
DmSwitch.InputNameFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.InputNames[tempX]]);
DmSwitch.OutputNameFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.OutputNames[tempX]]);
DmSwitch.OutputRouteNameFeedbacks[(ushort)tempX].LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.OutputRouteNames[tempX]]);
}
DmSwitch.IsOnline.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.ChassisOnline]);
ApiEisc.Eisc.Register();
}
}
Debug.Console(2, "Name {0} Activated", this.Name);
return true;
}
catch (Exception e) {
Debug.Console(2, "BRidge {0}", e);
return false;
}
}
}
public class EssentialDMProperties {
public string connectionDeviceKey;
public string[] EiscApiIpids;
}
public class EssentialDMApiMap {
public ushort ChassisOnline = 11;
public Dictionary<uint, ushort> OutputVideoRoutes;
public Dictionary<uint, ushort> OutputAudioRoutes;
public Dictionary<uint, ushort> TxOnlineStatus;
public Dictionary<uint, ushort> RxOnlineStatus;
public Dictionary<uint, ushort> TxVideoSyncStatus;
public Dictionary<uint, ushort> InputNames;
public Dictionary<uint, ushort> OutputNames;
public Dictionary<uint, ushort> OutputRouteNames;
public Dictionary<uint, ushort> HdcpSupport;
public Dictionary<uint, ushort> HdcpSupportCapability;
public EssentialDMApiMap() {
OutputVideoRoutes = new Dictionary<uint, ushort>();
OutputAudioRoutes = new Dictionary<uint, ushort>();
TxOnlineStatus = new Dictionary<uint, ushort>();
RxOnlineStatus = new Dictionary<uint, ushort>();
TxVideoSyncStatus = new Dictionary<uint, ushort>();
InputNames = new Dictionary<uint, ushort>();
OutputNames = new Dictionary<uint, ushort>();
OutputRouteNames = new Dictionary<uint, ushort>();
HdcpSupport = new Dictionary<uint, ushort>();
HdcpSupportCapability = new Dictionary<uint, ushort>();
for (uint x = 1; x <= 200; x++) {
// Debug.Console(0, "Init Value {0}", x);
uint tempNum = x;
HdcpSupportCapability[tempNum] = (ushort)(tempNum + 1200);
HdcpSupport[tempNum] = (ushort)(tempNum + 1000);
OutputVideoRoutes[tempNum] = (ushort)(tempNum + 100);
OutputAudioRoutes[tempNum] = (ushort)(tempNum + 300);
TxOnlineStatus[tempNum] = (ushort)(tempNum + 500);
RxOnlineStatus[tempNum] = (ushort)(tempNum + 700);
TxVideoSyncStatus[tempNum] = (ushort)(tempNum + 100);
InputNames[tempNum] = (ushort)(tempNum + 100);
OutputNames[tempNum] = (ushort)(tempNum + 300);
OutputRouteNames[tempNum] = (ushort)(tempNum + 2000);
}
}
}
}

View File

@@ -0,0 +1,217 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.DM;
using PepperDash.Core;
using PepperDash.Essentials.Core.Routing;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.EthernetCommunication;
using Crestron.SimplSharpPro.DM;
namespace PepperDash.Essentials {
public class EssentialDsp : PepperDash.Core.Device {
public EssentialDspProperties Properties;
public List<BridgeApiEisc> BridgeApiEiscs;
private PepperDash.Essentials.Devices.Common.DSP.QscDsp Dsp;
private EssentialDspApiMap ApiMap = new EssentialDspApiMap();
public EssentialDsp(string key, string name, JToken properties)
: base(key, name) {
Properties = JsonConvert.DeserializeObject<EssentialDspProperties>(properties.ToString());
}
public override bool CustomActivate() {
// Create EiscApis
try
{
ICommunicationMonitor comm = null;
foreach (var device in DeviceManager.AllDevices)
{
if (device.Key == this.Properties.connectionDeviceKey)
{
if (!(device is ICommunicationMonitor))
{
comm = device as ICommunicationMonitor;
}
Debug.Console(2, "deviceKey {0} Matches", device.Key);
Dsp = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.Devices.Common.DSP.QscDsp;
break;
}
else
{
Debug.Console(2, "deviceKey {0} doesn't match", device.Key);
}
}
if (Properties.EiscApiIpids != null && Dsp != null)
{
foreach (string Ipid in Properties.EiscApiIpids)
{
var ApiEisc = new BridgeApiEisc(Ipid);
Debug.Console(2, "Connecting EiscApi {0} to {1}", ApiEisc.Ipid, Dsp.Name);
ushort x = 1;
if (comm != null)
{
comm.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.Online]);
}
foreach (var channel in Dsp.LevelControlPoints)
{
//var QscChannel = channel.Value as PepperDash.Essentials.Devices.Common.DSP.QscDspLevelControl;
Debug.Console(2, "QscChannel {0} connect", x);
var genericChannel = channel.Value as IBasicVolumeWithFeedback;
if (channel.Value.Enabled)
{
ApiEisc.Eisc.StringInput[ApiMap.channelName[x]].StringValue = channel.Value.LevelCustomName;
ApiEisc.Eisc.UShortInput[ApiMap.channelType[x]].UShortValue = (ushort)channel.Value.Type;
genericChannel.MuteFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.channelMuteToggle[x]]);
genericChannel.VolumeLevelFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.channelVolume[x]]);
ApiEisc.Eisc.SetSigTrueAction(ApiMap.channelMuteToggle[x], () => genericChannel.MuteToggle());
ApiEisc.Eisc.SetSigTrueAction(ApiMap.channelMuteOn[x], () => genericChannel.MuteOn());
ApiEisc.Eisc.SetSigTrueAction(ApiMap.channelMuteOff[x], () => genericChannel.MuteOff());
ApiEisc.Eisc.SetBoolSigAction(ApiMap.channelVolumeUp[x], b => genericChannel.VolumeUp(b));
ApiEisc.Eisc.SetBoolSigAction(ApiMap.channelVolumeDown[x], b => genericChannel.VolumeDown(b));
ApiEisc.Eisc.SetUShortSigAction(ApiMap.channelVolume[x], u => genericChannel.SetVolume(u));
ApiEisc.Eisc.SetStringSigAction(ApiMap.presetString, s => Dsp.RunPreset(s));
}
x++;
}
x = 1;
foreach (var preset in Dsp.PresetList)
{
ApiEisc.Eisc.StringInput[ApiMap.presets[x]].StringValue = preset.label;
ApiEisc.Eisc.SetSigTrueAction(ApiMap.presets[x], () => Dsp.RunPresetNumber(x));
x++;
}
foreach (var dialer in Dsp.Dialers)
{
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad0, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num0));
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad1, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num1));
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad2, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num2));
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad3, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num3));
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad4, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num4));
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad5, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num5));
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad6, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num6));
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad7, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num7));
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad8, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num8));
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Keypad9, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Num9));
ApiEisc.Eisc.SetSigTrueAction(ApiMap.KeypadStar, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Star));
ApiEisc.Eisc.SetSigTrueAction(ApiMap.KeypadPound, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Pound));
ApiEisc.Eisc.SetSigTrueAction(ApiMap.KeypadClear, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Clear));
ApiEisc.Eisc.SetSigTrueAction(ApiMap.KeypadBackspace, () => dialer.Value.SendKeypad(PepperDash.Essentials.Devices.Common.DSP.QscDspDialer.eKeypadKeys.Backspace));
ApiEisc.Eisc.SetSigTrueAction(ApiMap.Dial, () => dialer.Value.Dial());
ApiEisc.Eisc.SetSigTrueAction(ApiMap.DoNotDisturbToggle, () => dialer.Value.DoNotDisturbToggle());
ApiEisc.Eisc.SetSigTrueAction(ApiMap.DoNotDisturbOn, () => dialer.Value.DoNotDisturbOn());
ApiEisc.Eisc.SetSigTrueAction(ApiMap.DoNotDisturbOff, () => dialer.Value.DoNotDisturbOff());
ApiEisc.Eisc.SetSigTrueAction(ApiMap.AutoAnswerToggle, () => dialer.Value.AutoAnswerToggle());
ApiEisc.Eisc.SetSigTrueAction(ApiMap.AutoAnswerOn, () => dialer.Value.AutoAnswerOn());
ApiEisc.Eisc.SetSigTrueAction(ApiMap.AutoAnswerOff, () => dialer.Value.AutoAnswerOff());
dialer.Value.DoNotDisturbFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.DoNotDisturbToggle]);
dialer.Value.DoNotDisturbFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.DoNotDisturbOn]);
dialer.Value.DoNotDisturbFeedback.LinkComplementInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.DoNotDisturbOff]);
dialer.Value.AutoAnswerFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.AutoAnswerToggle]);
dialer.Value.AutoAnswerFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.AutoAnswerOn]);
dialer.Value.AutoAnswerFeedback.LinkComplementInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.AutoAnswerOff]);
dialer.Value.OffHookFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.Dial]);
dialer.Value.DialStringFeedback.LinkInputSig(ApiEisc.Eisc.StringInput[ApiMap.DialString]);
}
}
}
Debug.Console(2, "Name {0} Activated", this.Name);
return true;
}
catch (Exception e) {
Debug.Console(0, "Bridge {0}", e);
return false;
}
}
}
public class EssentialDspProperties {
public string connectionDeviceKey;
public string[] EiscApiIpids;
}
public class EssentialDspApiMap {
public ushort Online = 1;
public ushort presetString = 2000;
public Dictionary<uint, ushort> channelMuteToggle;
public Dictionary<uint, ushort> channelMuteOn;
public Dictionary<uint, ushort> channelMuteOff;
public Dictionary<uint, ushort> channelVolume;
public Dictionary<uint, ushort> channelType;
public Dictionary<uint, ushort> channelName;
public Dictionary<uint, ushort> channelVolumeUp;
public Dictionary<uint, ushort> channelVolumeDown;
public Dictionary<uint, ushort> presets;
public ushort DialString = 3100;
public ushort Keypad0 = 3110;
public ushort Keypad1 = 3111;
public ushort Keypad2 = 3112;
public ushort Keypad3 = 3113;
public ushort Keypad4 = 3114;
public ushort Keypad5 = 3115;
public ushort Keypad6 = 3116;
public ushort Keypad7 = 3117;
public ushort Keypad8 = 3118;
public ushort Keypad9 = 3119;
public ushort KeypadStar = 3120;
public ushort KeypadPound = 3121;
public ushort KeypadClear = 3122;
public ushort KeypadBackspace = 3123;
public ushort Dial = 3124;
public ushort DoNotDisturbToggle = 3132;
public ushort DoNotDisturbOn = 3133;
public ushort DoNotDisturbOff = 3134;
public ushort AutoAnswerToggle = 3127;
public ushort AutoAnswerOn = 3125;
public ushort AutoAnswerOff = 3126;
public EssentialDspApiMap() {
channelMuteToggle = new Dictionary<uint, ushort>();
channelMuteOn = new Dictionary<uint, ushort>();
channelMuteOff = new Dictionary<uint, ushort>();
channelVolume = new Dictionary<uint, ushort>();
channelName = new Dictionary<uint, ushort>();
channelType = new Dictionary<uint, ushort>();
presets = new Dictionary<uint, ushort>();
channelVolumeUp = new Dictionary<uint, ushort>();
channelVolumeDown = new Dictionary<uint, ushort>();
for (uint x = 1; x <= 100; x++) {
uint tempNum = x;
presets[tempNum] = (ushort)(tempNum + 100);
channelMuteToggle[tempNum] = (ushort)(tempNum + 400);
channelMuteOn[tempNum] = (ushort)(tempNum + 600);
channelMuteOff[tempNum] = (ushort)(tempNum + 800);
channelVolume[tempNum] = (ushort)(tempNum + 200);
channelName[tempNum] = (ushort)(tempNum + 200);
channelType[tempNum] = (ushort)(tempNum + 400);
channelVolumeUp[tempNum] = (ushort)(tempNum + 1000);
channelVolumeDown[tempNum] = (ushort)(tempNum + 1200);
}
}
}
}

View File

@@ -0,0 +1,98 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.DM;
using PepperDash.Core;
using PepperDash.Essentials.Core.Routing;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.EthernetCommunication;
using Crestron.SimplSharpPro.DM;
namespace PepperDash.Essentials
{
public class EssentialsTVOne : PepperDash.Core.Device
{
public EssentialTVOneProperties Properties;
public List<BridgeApiEisc> BridgeApiEiscs;
private PepperDash.Essentials.Devices.Common.TVOneCorio TVOneCorio;
private EssentialsTVOneApiMap ApiMap = new EssentialsTVOneApiMap();
public EssentialsTVOne(string key, string name, JToken properties)
: base(key, name)
{
Properties = JsonConvert.DeserializeObject<EssentialTVOneProperties>(properties.ToString());
}
public override bool CustomActivate() {
// Create EiscApis
try
{
foreach (var device in DeviceManager.AllDevices)
{
if (device.Key == this.Properties.connectionDeviceKey)
{
Debug.Console(2, "deviceKey {0} Matches", device.Key);
TVOneCorio = DeviceManager.GetDeviceForKey(device.Key) as PepperDash.Essentials.Devices.Common.TVOneCorio;
break;
}
else
{
Debug.Console(2, "deviceKey {0} doesn't match", device.Key);
}
}
if (Properties.EiscApiIpids != null && TVOneCorio != null)
{
foreach (string Ipid in Properties.EiscApiIpids)
{
var ApiEisc = new BridgeApiEisc(Ipid);
Debug.Console(2, "Connecting EiscApi {0} to {1}", ApiEisc.Ipid, TVOneCorio.Name);
ushort x = 1;
TVOneCorio.OnlineFeedback.LinkInputSig(ApiEisc.Eisc.BooleanInput[ApiMap.Online]);
ApiEisc.Eisc.SetUShortSigAction(ApiMap.CallPreset, u => TVOneCorio.CallPreset(u));
TVOneCorio.PresetFeedback.LinkInputSig(ApiEisc.Eisc.UShortInput[ApiMap.PresetFeedback]);
}
}
Debug.Console(2, "Name {0} Activated", this.Name);
return true;
}
catch (Exception e) {
Debug.Console(0, "Bridge {0}", e);
return false;
}
}
}
public class EssentialTVOneProperties
{
public string connectionDeviceKey;
public string[] EiscApiIpids;
}
public class EssentialsTVOneApiMap
{
public ushort CallPreset = 1;
public ushort PresetFeedback = 1;
public ushort Online = 1;
public EssentialsTVOneApiMap()
{
}
}
}

View File

@@ -0,0 +1,103 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common;
namespace PepperDash.Essentials.Bridges
{
public static class GenericLightingApiExtensions
{
public static void LinkToApi(this PepperDash.Essentials.Core.Lighting.LightingBase lightingDevice, BasicTriList trilist, uint joinStart, string joinMapKey)
{
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as GenericLightingJoinMap;
if (joinMap == null)
joinMap = new GenericLightingJoinMap();
joinMap.OffsetJoinNumbers(joinStart);
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
Debug.Console(0, "Linking to lighting Type {0}", lightingDevice.GetType().Name.ToString());
// GenericLighitng Actions & FeedBack
trilist.SetUShortSigAction(joinMap.SelectScene, u => lightingDevice.SelectScene(lightingDevice.LightingScenes[u]));
int sceneIndex = 1;
foreach (var scene in lightingDevice.LightingScenes)
{
var tempIndex = sceneIndex - 1;
trilist.SetSigTrueAction((uint)(joinMap.LightingSceneOffset + sceneIndex), () => lightingDevice.SelectScene(lightingDevice.LightingScenes[tempIndex]));
scene.IsActiveFeedback.LinkInputSig(trilist.BooleanInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)]);
trilist.StringInput[(uint)(joinMap.LightingSceneOffset + sceneIndex)].StringValue = scene.Name;
trilist.BooleanInput[(uint)(joinMap.ButtonVisibilityOffset + sceneIndex)].BoolValue = true;
sceneIndex++;
}
if (lightingDevice.GetType().Name.ToString() == "LutronQuantumArea")
{
var lutronDevice = lightingDevice as PepperDash.Essentials.Devices.Common.Environment.Lutron.LutronQuantumArea;
lutronDevice.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
trilist.SetStringSigAction(joinMap.IntegrationIdSet, s => lutronDevice.IntegrationId = s);
}
//ApiEisc.Eisc.SetStringSigAction(ApiMap.integrationID, (s) => { lutronLights.IntegrationId = s; });
/*
var lutronLights = lightingDevice as PepperDash.Essentials.Devices.Common.Environment.Lutron.LutronQuantumArea;
for (uint i = 1; i <= lightingBase.CircuitCount; i++)
{
var circuit = i;
lightingBase.CircuitNameFeedbacks[circuit - 1].LinkInputSig(trilist.StringInput[joinMap.CircuitNames + circuit]);
lightingBase.CircuitIsCritical[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitIsCritical + circuit]);
lightingBase.CircuitState[circuit - 1].LinkInputSig(trilist.BooleanInput[joinMap.CircuitState + circuit]);
trilist.SetSigTrueAction(joinMap.CircuitCycle + circuit, () => lightingBase.CycleCircuit(circuit - 1));
trilist.SetSigTrueAction(joinMap.CircuitOnCmd + circuit, () => lightingBase.TurnOnCircuit(circuit - 1));
trilist.SetSigTrueAction(joinMap.CircuitOffCmd + circuit, () => lightingBase.TurnOffCircuit(circuit - 1));
}
*/
}
}
public class GenericLightingJoinMap : JoinMapBase
{
public uint IsOnline { get; set; }
public uint SelectScene { get; set; }
public uint LightingSceneOffset { get; set; }
public uint ButtonVisibilityOffset { get; set; }
public uint IntegrationIdSet { get; set; }
public GenericLightingJoinMap()
{
// Digital
IsOnline = 1;
SelectScene = 1;
IntegrationIdSet = 1;
LightingSceneOffset = 10;
ButtonVisibilityOffset = 40;
// Analog
}
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
IsOnline = IsOnline + joinOffset;
SelectScene = SelectScene + joinOffset;
LightingSceneOffset = LightingSceneOffset + joinOffset;
ButtonVisibilityOffset = ButtonVisibilityOffset + joinOffset;
}
}
}

View File

@@ -0,0 +1,66 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.CrestronIO;
namespace PepperDash.Essentials.Bridges
{
public static class GenericRelayDeviceApiExtensions
{
public static void LinkToApi(this GenericRelayDevice relay, BasicTriList trilist, uint joinStart, string joinMapKey)
{
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as GenericRelayControllerJoinMap;
if (joinMap == null)
joinMap = new GenericRelayControllerJoinMap();
joinMap.OffsetJoinNumbers(joinStart);
if (relay.RelayOutput == null)
{
Debug.Console(1, relay, "Unable to link device '{0}'. Relay is null", relay.Key);
return;
}
Debug.Console(1, relay, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
trilist.SetBoolSigAction(joinMap.Relay, new Action<bool>(b =>
{
if (b)
relay.CloseRelay();
else
relay.OpenRelay();
}));
// feedback for relay state
relay.OutputIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Relay]);
}
}
public class GenericRelayControllerJoinMap : JoinMapBase
{
//Digital
public uint Relay { get; set; }
public GenericRelayControllerJoinMap()
{
Relay = 1;
}
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
Relay = Relay + joinOffset;
}
}
}

View File

@@ -0,0 +1,103 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core;
namespace PepperDash.Essentials.Bridges
{
public static class IBasicCommunicationApiExtensions
{
public static void LinkToApi(this GenericComm comm, BasicTriList trilist, uint joinStart, string joinMapKey)
{
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as IBasicCommunicationJoinMap;
if (joinMap == null)
joinMap = new IBasicCommunicationJoinMap();
joinMap.OffsetJoinNumbers(joinStart);
if (comm.CommPort == null)
{
Debug.Console(1, comm, "Unable to link device '{0}'. CommPort is null", comm.Key);
return;
}
Debug.Console(1, comm, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
// this is a permanent event handler. This cannot be -= from event
comm.CommPort.TextReceived += (s, a) => trilist.SetString(joinMap.TextReceived, a.Text);
trilist.SetStringSigAction(joinMap.SendText, new Action<string>(s => comm.CommPort.SendText(s)));
trilist.SetStringSigAction(joinMap.SetPortConfig + 1, new Action<string>(s => comm.SetPortConfig(s)));
var sComm = comm.CommPort as ISocketStatus;
if (sComm != null)
{
sComm.ConnectionChange += (s, a) =>
{
trilist.SetUshort(joinMap.Status, (ushort)(a.Client.ClientStatus));
trilist.SetBool(joinMap.Connected, a.Client.ClientStatus ==
Crestron.SimplSharp.CrestronSockets.SocketStatus.SOCKET_STATUS_CONNECTED);
};
trilist.SetBoolSigAction(joinMap.Connect, new Action<bool>(b =>
{
if (b)
{
sComm.Connect();
}
else
{
sComm.Disconnect();
}
}));
}
}
public class IBasicCommunicationJoinMap : JoinMapBase
{
//Digital
public uint Connect { get; set; }
public uint Connected { get; set; }
//Analog
public uint Status { get; set; }
// Serial
public uint TextReceived { get; set; }
public uint SendText { get; set; }
public uint SetPortConfig { get; set; }
public IBasicCommunicationJoinMap()
{
TextReceived = 1;
SendText = 1;
SetPortConfig = 2;
Connect = 1;
Connected = 1;
Status = 1;
}
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
TextReceived = TextReceived + joinOffset;
SendText = SendText + joinOffset;
SetPortConfig = SetPortConfig + joinOffset;
Connect = Connect + joinOffset;
Connected = Connected + joinOffset;
Status = Status + joinOffset;
}
}
}
}

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using PepperDash.Core;
using PepperDash.Essentials.Core.CrestronIO;
namespace PepperDash.Essentials.Bridges
{
public static class IDigitalInputApiExtenstions
{
public static void LinkToApi(this IDigitalInput input, BasicTriList trilist, uint joinStart, string joinMapKey)
{
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as IDigitalInputApiJoinMap;
if (joinMap == null)
joinMap = new IDigitalInputApiJoinMap();
joinMap.OffsetJoinNumbers(joinStart);
try
{
Debug.Console(1, input as Device, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
// Link feedback for input state
input.InputStateFeedback.LinkInputSig(trilist.BooleanInput[joinMap.InputState]);
}
catch (Exception e)
{
Debug.Console(1, input as Device, "Unable to link device '{0}'. Input is null", (input as Device).Key);
Debug.Console(1, input as Device, "Error: {0}", e);
return;
}
}
}
public class IDigitalInputApiJoinMap : JoinMapBase
{
//Digital
public uint InputState { get; set; }
public IDigitalInputApiJoinMap()
{
InputState = 1;
}
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
InputState = InputState + joinOffset;
}
}
}

View File

@@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Bridges
{
public static class JoinMapHelper
{
/// <summary>
/// Attempts to get the join map from config
/// </summary>
/// <param name="joinMapKey"></param>
/// <returns></returns>
public static JoinMapBase GetJoinMapForDevice(string joinMapKey)
{
if (!string.IsNullOrEmpty(joinMapKey))
return null;
// FUTURE TODO: Get the join map from the ConfigReader.ConfigObject
return null;
}
}
public abstract class JoinMapBase
{
/// <summary>
/// Modifies all the join numbers by adding the offset. This should never be called twice
/// </summary>
/// <param name="joinStart"></param>
public abstract void OffsetJoinNumbers(uint joinStart);
}
}

View File

@@ -0,0 +1,150 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.Diagnostics;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Monitoring;
namespace PepperDash.Essentials.Bridges
{
public static class SystemMonitorBridge
{
public static void LinkToApi(this SystemMonitorController systemMonitorController, BasicTriList trilist, uint joinStart, string joinMapKey)
{
var joinMap = JoinMapHelper.GetJoinMapForDevice(joinMapKey) as SystemMonitorJoinMap;
if (joinMap == null)
joinMap = new SystemMonitorJoinMap();
joinMap.OffsetJoinNumbers(joinStart);
//Debug.Console(1, systemMonitorController, "Linking API starting at join: {0}", joinStart);
systemMonitorController.TimeZoneFeedback.LinkInputSig(trilist.UShortInput[joinMap.TimeZone]);
//trilist.SetUShortSigAction(joinMap.TimeZone, new Action<ushort>(u => systemMonitorController.SetTimeZone(u)));
systemMonitorController.TimeZoneTextFeedback.LinkInputSig(trilist.StringInput[joinMap.TimeZoneName]);
systemMonitorController.IOControllerVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.IOControllerVersion]);
systemMonitorController.SnmpVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.SnmpAppVersion]);
systemMonitorController.BACnetAppVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.BACnetAppVersion]);
systemMonitorController.ControllerVersionFeedback.LinkInputSig(trilist.StringInput[joinMap.ControllerVersion]);
// iterate the program status feedback collection and map all the joins
var programSlotJoinStart = joinMap.ProgramStartJoin;
foreach (var p in systemMonitorController.ProgramStatusFeedbackCollection)
{
// TODO: link feedbacks for each program slot
var programNumber = p.Value.Program.Number;
//Debug.Console(1, systemMonitorController, "Linking API for Program Slot: {0} starting at join: {1}", programNumber, programSlotJoinStart);
trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramStart, new Action<bool>
(b => SystemMonitor.ProgramCollection[programNumber].OperatingState = eProgramOperatingState.Start));
p.Value.ProgramStartedFeedback.LinkInputSig(trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramStart]);
trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramStop, new Action<bool>
(b => SystemMonitor.ProgramCollection[programNumber].OperatingState = eProgramOperatingState.Stop));
p.Value.ProgramStoppedFeedback.LinkInputSig(trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramStop]);
trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramRegister, new Action<bool>
(b => SystemMonitor.ProgramCollection[programNumber].RegistrationState = eProgramRegistrationState.Register));
p.Value.ProgramRegisteredFeedback.LinkInputSig(trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramRegister]);
trilist.SetBoolSigAction(programSlotJoinStart + joinMap.ProgramUnregister, new Action<bool>
(b => SystemMonitor.ProgramCollection[programNumber].RegistrationState = eProgramRegistrationState.Unregister));
p.Value.ProgramUnregisteredFeedback.LinkInputSig(trilist.BooleanInput[programSlotJoinStart + joinMap.ProgramUnregister]);
programSlotJoinStart = programSlotJoinStart + joinMap.ProgramOffsetJoin;
}
}
}
public class SystemMonitorJoinMap : JoinMapBase
{
/// <summary>
/// Offset to indicate where the range of iterated program joins will start
/// </summary>
public uint ProgramStartJoin { get; set; }
/// <summary>
/// Offset between each program join set
/// </summary>
public uint ProgramOffsetJoin { get; set; }
//Digital
public uint ProgramStart { get; set; }
public uint ProgramStop { get; set; }
public uint ProgramRegister { get; set; }
public uint ProgramUnregister { get; set; }
//Analog
public uint TimeZone { get; set; }
//Serial
public uint TimeZoneName { get; set; }
public uint IOControllerVersion { get; set; }
public uint SnmpAppVersion { get; set; }
public uint BACnetAppVersion { get; set; }
public uint ControllerVersion { get; set; }
public uint ProgramName { get; set; }
public uint ProgramCompiledTime { get; set; }
public uint ProgramCrestronDatabaseVersion { get; set; }
public uint ProgramEnvironmentVersion { get; set; }
public uint AggregatedProgramInfo { get; set; }
public SystemMonitorJoinMap()
{
TimeZone = 1;
TimeZoneName = 1;
IOControllerVersion = 2;
SnmpAppVersion = 3;
BACnetAppVersion = 4;
ControllerVersion = 5;
ProgramStartJoin = 10;
ProgramOffsetJoin = 5;
// Offset in groups of 5 joins
ProgramStart = 1;
ProgramStop = 2;
ProgramRegister = 3;
ProgramUnregister = 4;
ProgramName = 1;
ProgramCompiledTime = 2;
ProgramCrestronDatabaseVersion = 3;
ProgramEnvironmentVersion = 4;
AggregatedProgramInfo = 5;
}
public override void OffsetJoinNumbers(uint joinStart)
{
var joinOffset = joinStart - 1;
TimeZone = TimeZone + joinOffset;
TimeZoneName = TimeZoneName + joinOffset;
IOControllerVersion = IOControllerVersion + joinOffset;
SnmpAppVersion = SnmpAppVersion + joinOffset;
BACnetAppVersion = BACnetAppVersion + joinOffset;
ControllerVersion = ControllerVersion + joinOffset;
// Sets the initial join value where the iterated program joins will begin
ProgramStartJoin = ProgramStartJoin + joinOffset;
}
}
}

View File

@@ -80,6 +80,16 @@ namespace PepperDash.Essentials
var dm = new DmMd8x8(ipId, Global.ControlSystem); var dm = new DmMd8x8(ipId, Global.ControlSystem);
//dev = new DmChassisController(devKey, devName, dm); //dev = new DmChassisController(devKey, devName, dm);
} }
else if (devType.Equals("dmmd16x16", StringComparison.OrdinalIgnoreCase))
{
var dm = new DmMd16x16(ipId, Global.ControlSystem);
//dev = new DmChassisController(devKey, devName, dm);
}
else if (devType.Equals("dmmd32x32", StringComparison.OrdinalIgnoreCase))
{
var dm = new DmMd32x32(ipId, Global.ControlSystem);
//dev = new DmChassisController(devKey, devName, dm);
}
} }
catch (Exception e) catch (Exception e)
{ {

View File

@@ -4,6 +4,8 @@ using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.CrestronThread; using Crestron.SimplSharpPro.CrestronThread;
using Crestron.SimplSharpPro.Diagnostics;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
@@ -32,12 +34,18 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
public override void InitializeSystem() public override void InitializeSystem()
{ {
SystemMonitor.ProgramInitialization.ProgramInitializationUnderUserControl = true;
DeterminePlatform(); DeterminePlatform();
//CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Loads configuration file", //CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Loads configuration file",
// ConsoleAccessLevelEnum.AccessOperator); // ConsoleAccessLevelEnum.AccessOperator);
// CrestronConsole.AddNewConsoleCommand(S => { ConfigWriter.WriteConfigFile(null); }, "writeconfig", "writes the current config to a file", ConsoleAccessLevelEnum.AccessOperator); // CrestronConsole.AddNewConsoleCommand(S => { ConfigWriter.WriteConfigFile(null); }, "writeconfig", "writes the current config to a file", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s =>
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "CONSOLE MESSAGE: {0}", s);
}, "appdebugmessage", "Writes message to log", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s => CrestronConsole.AddNewConsoleCommand(s =>
{ {
@@ -141,12 +149,18 @@ namespace PepperDash.Essentials
"------------------------------------------------\r" + "------------------------------------------------\r" +
"------------------------------------------------"); "------------------------------------------------");
} }
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Console(0, "FATAL INITIALIZE ERROR. System is in an inconsistent state:\r{0}", e); Debug.Console(0, "FATAL INITIALIZE ERROR. System is in an inconsistent state:\r{0}", e);
} }
// Notify the
SystemMonitor.ProgramInitialization.ProgramInitializationComplete = true;
} }
/// <summary> /// <summary>
@@ -203,16 +217,40 @@ namespace PepperDash.Essentials
LoadLogoServer(); LoadLogoServer();
DeviceManager.ActivateAll(); DeviceManager.ActivateAll();
LinkSystemMonitorToAppServer();
} }
void LinkSystemMonitorToAppServer()
{
var sysMon = DeviceManager.GetDeviceForKey("systemMonitor") as PepperDash.Essentials.Core.Monitoring.SystemMonitorController;
var appServer = DeviceManager.GetDeviceForKey("appServer") as CotijaSystemController;
if (sysMon != null && appServer != null)
{
var key = sysMon.Key + "-" + appServer.Key;
var messenger = new PepperDash.Essentials.AppServer.Messengers.SystemMonitorMessenger
(key, sysMon, "/device/systemMonitor");
messenger.RegisterWithAppServer(appServer);
DeviceManager.AddDevice(messenger);
}
}
/// <summary> /// <summary>
/// Reads all devices from config and adds them to DeviceManager /// Reads all devices from config and adds them to DeviceManager
/// </summary> /// </summary>
public void LoadDevices() public void LoadDevices()
{ {
# warning Missing PepperDash.Essentials.Core.Devices.CrestronProcessor("processor"));
// Build the processor wrapper class // Build the processor wrapper class
DeviceManager.AddDevice(new PepperDash.Essentials.Core.Devices.CrestronProcessor("processor")); // DeviceManager.AddDevice(new PepperDash.Essentials.Core.Devices.CrestronProcessor("processor"));
// Add global System Monitor device
DeviceManager.AddDevice(new PepperDash.Essentials.Core.Monitoring.SystemMonitorController("systemMonitor"));
foreach (var devConf in ConfigReader.ConfigObject.Devices) foreach (var devConf in ConfigReader.ConfigObject.Devices)
{ {
@@ -231,17 +269,23 @@ namespace PepperDash.Essentials
continue; continue;
} }
// Try local factory first // Try local factories first
var newDev = DeviceFactory.GetDevice(devConf); var newDev = DeviceFactory.GetDevice(devConf);
if (newDev == null)
newDev = BridgeFactory.GetDevice(devConf);
// Then associated library factories // Then associated library factories
if (newDev == null)
newDev = PepperDash.Essentials.Core.DeviceFactory.GetDevice(devConf);
if (newDev == null) if (newDev == null)
newDev = PepperDash.Essentials.Devices.Common.DeviceFactory.GetDevice(devConf); newDev = PepperDash.Essentials.Devices.Common.DeviceFactory.GetDevice(devConf);
if (newDev == null) if (newDev == null)
newDev = PepperDash.Essentials.DM.DeviceFactory.GetDevice(devConf); newDev = PepperDash.Essentials.DM.DeviceFactory.GetDevice(devConf);
if (newDev == null) if (newDev == null)
newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf); newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf);
if (newDev == null)
newDev = PepperDash.Essentials.BridgeFactory.GetDevice(devConf);
if (newDev != null) if (newDev != null)
DeviceManager.AddDevice(newDev); DeviceManager.AddDevice(newDev);
else else
@@ -256,6 +300,7 @@ namespace PepperDash.Essentials
} }
/// <summary> /// <summary>
/// Helper method to load tie lines. This should run after devices have loaded /// Helper method to load tie lines. This should run after devices have loaded
/// </summary> /// </summary>

View File

@@ -1,367 +0,0 @@
using System;
using System.Linq;
using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.CrestronThread;
using PepperDash.Core;
using PepperDash.Core.PortalSync;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Devices.Common;
using PepperDash.Essentials.DM;
using PepperDash.Essentials.Fusion;
using PepperDash.Essentials.Room.Cotija;
namespace PepperDash.Essentials
{
public class ControlSystem : CrestronControlSystem
{
PepperDashPortalSyncClient PortalSync;
HttpLogoServer LogoServer;
public ControlSystem()
: base()
{
Thread.MaxNumberOfUserThreads = 400;
Global.ControlSystem = this;
DeviceManager.Initialize(this);
}
/// <summary>
/// Git 'er goin'
/// </summary>
public override void InitializeSystem()
{
<<<<<<< HEAD
DeterminePlatform();
//CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Loads configuration file",
// ConsoleAccessLevelEnum.AccessOperator);
=======
CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Loads configuration file",
ConsoleAccessLevelEnum.AccessOperator);
>>>>>>> 600b9f11ff1bbc186f7c2a2945955731b3523b3c
CrestronConsole.AddNewConsoleCommand(s =>
{
foreach (var tl in TieLineCollection.Default)
CrestronConsole.ConsoleCommandResponse(" {0}\r", tl);
},
"listtielines", "Prints out all tie lines", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s =>
{
CrestronConsole.ConsoleCommandResponse
("Current running configuration. This is the merged system and template configuration");
CrestronConsole.ConsoleCommandResponse(Newtonsoft.Json.JsonConvert.SerializeObject
(ConfigReader.ConfigObject, Newtonsoft.Json.Formatting.Indented));
}, "showconfig", "Shows the current running merged config", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s =>
{
CrestronConsole.ConsoleCommandResponse("This system can be found at the following URLs:\r" +
"System URL: {0}\r" +
"Template URL: {1}", ConfigReader.ConfigObject.SystemUrl, ConfigReader.ConfigObject.TemplateUrl);
}, "portalinfo", "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator);
//GoWithLoad();
}
/// <summary>
/// Determines if the program is running on a processor (appliance) or server (XiO Edge).
///
/// Sets Global.FilePathPrefix based on platform
/// </summary>
public void DeterminePlatform()
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Determining Platform....");
string filePathPrefix;
var dirSeparator = Global.DirectorySeparator;
var version = Crestron.SimplSharp.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
var versionString = string.Format("{0}.{1}.{2}", version.Major, version.Minor, version.Build);
string directoryPrefix;
//directoryPrefix = Crestron.SimplSharp.CrestronIO.Directory.GetApplicationRootDirectory();
#warning ^ For use with beta Include4.dat for XiO Edge
directoryPrefix = "";
if (CrestronEnvironment.DevicePlatform != eDevicePlatform.Server)
{
filePathPrefix = directoryPrefix + dirSeparator + "NVRAM"
+ dirSeparator + string.Format("program{0}", InitialParametersClass.ApplicationNumber) + dirSeparator;
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on 3-series Appliance", versionString);
}
else
{
filePathPrefix = directoryPrefix + dirSeparator + "User" + dirSeparator;
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on XiO Edge Server", versionString);
}
Global.SetFilePathPrefix(filePathPrefix);
}
/// <summary>
/// Do it, yo
/// </summary>
public void GoWithLoad()
{
try
{
CrestronConsole.AddNewConsoleCommand(EnablePortalSync, "portalsync", "Loads Portal Sync",
ConsoleAccessLevelEnum.AccessOperator);
//PortalSync = new PepperDashPortalSyncClient();
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials load from configuration");
var filesReady = SetupFilesystem();
if (filesReady)
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Folder structure verified. Loading config...");
if (!ConfigReader.LoadConfig2())
return;
Load();
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Essentials load complete\r" +
"-------------------------------------------------------------");
}
else
{
Debug.Console(0,
"------------------------------------------------\r" +
"------------------------------------------------\r" +
"------------------------------------------------\r" +
"Essentials file structure setup completed.\r" +
"Please load config, sgd and ir files and\r" +
"restart program.\r" +
"------------------------------------------------\r" +
"------------------------------------------------\r" +
"------------------------------------------------");
}
}
catch (Exception e)
{
Debug.Console(0, "FATAL INITIALIZE ERROR. System is in an inconsistent state:\r{0}", e);
}
}
/// <summary>
/// Verifies filesystem is set up. IR, SGD, and program1 folders
/// </summary>
bool SetupFilesystem()
{
Debug.Console(0, "Verifying and/or creating folder structure");
var configDir = Global.FilePathPrefix;
var configExists = Directory.Exists(configDir);
if (!configExists)
Directory.Create(configDir);
var irDir = Global.FilePathPrefix + "ir";
if (!Directory.Exists(irDir))
Directory.Create(irDir);
var sgdDir = Global.FilePathPrefix + "sgd";
if (!Directory.Exists(sgdDir))
Directory.Create(sgdDir);
return configExists;
}
public void EnablePortalSync(string s)
{
if (s.ToLower() == "enable")
{
CrestronConsole.ConsoleCommandResponse("Portal Sync features enabled");
PortalSync = new PepperDashPortalSyncClient();
}
}
public void TearDown()
{
Debug.Console(0, "Tearing down existing system");
DeviceManager.DeactivateAll();
TieLineCollection.Default.Clear();
foreach (var key in DeviceManager.GetDevices())
DeviceManager.RemoveDevice(key);
Debug.Console(0, "Tear down COMPLETE");
}
/// <summary>
///
/// </summary>
void Load()
{
LoadDevices();
LoadTieLines();
LoadRooms();
LoadLogoServer();
DeviceManager.ActivateAll();
}
/// <summary>
/// Reads all devices from config and adds them to DeviceManager
/// </summary>
public void LoadDevices()
{
foreach (var devConf in ConfigReader.ConfigObject.Devices)
{
try
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Creating device '{0}'", devConf.Key);
// Skip this to prevent unnecessary warnings
if (devConf.Key == "processor")
continue;
// Try local factory first
var newDev = DeviceFactory.GetDevice(devConf);
// Then associated library factories
if (newDev == null)
newDev = PepperDash.Essentials.Devices.Common.DeviceFactory.GetDevice(devConf);
if (newDev == null)
newDev = PepperDash.Essentials.DM.DeviceFactory.GetDevice(devConf);
if (newDev == null)
newDev = PepperDash.Essentials.Devices.Displays.DisplayDeviceFactory.GetDevice(devConf);
if (newDev != null)
DeviceManager.AddDevice(newDev);
else
Debug.Console(0, Debug.ErrorLogLevel.Notice, "ERROR: Cannot load unknown device type '{0}', key '{1}'.", devConf.Type, devConf.Key);
}
catch (Exception e)
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "ERROR: Creating device {0}. Skipping device. \r{1}", devConf.Key, e);
}
}
Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Devices Loaded.");
}
/// <summary>
/// Helper method to load tie lines. This should run after devices have loaded
/// </summary>
public void LoadTieLines()
{
// In the future, we can't necessarily just clear here because devices
// might be making their own internal sources/tie lines
var tlc = TieLineCollection.Default;
//tlc.Clear();
if (ConfigReader.ConfigObject.TieLines == null)
{
return;
}
foreach (var tieLineConfig in ConfigReader.ConfigObject.TieLines)
{
var newTL = tieLineConfig.GetTieLine();
if (newTL != null)
tlc.Add(newTL);
}
Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Tie Lines Loaded.");
}
/// <summary>
/// Reads all rooms from config and adds them to DeviceManager
/// </summary>
public void LoadRooms()
{
if (ConfigReader.ConfigObject.Rooms == null)
{
Debug.Console(0, Debug.ErrorLogLevel.Warning, "WARNING: Configuration contains no rooms");
return;
}
foreach (var roomConfig in ConfigReader.ConfigObject.Rooms)
{
var room = roomConfig.GetRoomObject();
if (room != null)
{
if (room is EssentialsHuddleSpaceRoom)
{
DeviceManager.AddDevice(room);
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is EssentialsHuddleSpaceRoom, attempting to add to DeviceManager with Fusion");
DeviceManager.AddDevice(new EssentialsHuddleSpaceFusionSystemControllerBase((EssentialsHuddleSpaceRoom)room, 0xf1));
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to build Cotija Bridge...");
// Cotija bridge
var bridge = new CotijaEssentialsHuddleSpaceRoomBridge(room as EssentialsHuddleSpaceRoom);
AddBridgePostActivationHelper(bridge); // Lets things happen later when all devices are present
DeviceManager.AddDevice(bridge);
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Cotija Bridge Added...");
}
else if (room is EssentialsHuddleVtc1Room)
{
DeviceManager.AddDevice(room);
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is EssentialsHuddleVtc1Room, attempting to add to DeviceManager with Fusion");
DeviceManager.AddDevice(new EssentialsHuddleVtc1FusionController((EssentialsHuddleVtc1Room)room, 0xf1));
}
else
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Room is NOT EssentialsHuddleSpaceRoom, attempting to add to DeviceManager w/o Fusion");
DeviceManager.AddDevice(room);
}
}
else
Debug.Console(0, Debug.ErrorLogLevel.Notice, "WARNING: Cannot create room from config, key '{0}'", roomConfig.Key);
}
Debug.Console(0, Debug.ErrorLogLevel.Notice, "All Rooms Loaded.");
}
/// <summary>
/// Helps add the post activation steps that link bridges to main controller
/// </summary>
/// <param name="bridge"></param>
void AddBridgePostActivationHelper(CotijaBridgeBase bridge)
{
bridge.AddPostActivationAction(() =>
{
var parent = DeviceManager.AllDevices.FirstOrDefault(d => d.Key == "appServer") as CotijaSystemController;
if (parent == null)
{
Debug.Console(0, bridge, "ERROR: Cannot connect bridge. System controller not present");
}
Debug.Console(0, bridge, "Linking to parent controller");
bridge.AddParent(parent);
parent.AddBridge(bridge);
});
}
/// <summary>
/// Fires up a logo server if not already running
/// </summary>
void LoadLogoServer()
{
try
{
LogoServer = new HttpLogoServer(8080, Global.FilePathPrefix + "html" + Global.DirectorySeparator + "logo");
}
catch (Exception)
{
Debug.Console(0, Debug.ErrorLogLevel.Notice, "NOTICE: Logo server cannot be started. Likely already running in another program");
}
}
}
}

View File

@@ -774,7 +774,7 @@ namespace PepperDash.Essentials.Fusion
string roomConfigResponseArgs = args.Sig.StringValue.Replace("&", "and"); string roomConfigResponseArgs = args.Sig.StringValue.Replace("&", "and");
Debug.Console(1, this, "Fusion Response: \n {0}", roomConfigResponseArgs); Debug.Console(2, this, "Fusion Response: \n {0}", roomConfigResponseArgs);
try try
{ {

View File

@@ -3,10 +3,13 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Devices;
using PepperDash.Essentials.Room.Behaviours; using PepperDash.Essentials.Room.Behaviours;
namespace PepperDash.Essentials.Fusion namespace PepperDash.Essentials.Fusion
@@ -23,75 +26,89 @@ namespace PepperDash.Essentials.Fusion
/// <param name="roomInfo"></param> /// <param name="roomInfo"></param>
public void EvaluateRoomInfo(string roomKey, RoomInformation roomInfo) public void EvaluateRoomInfo(string roomKey, RoomInformation roomInfo)
{ {
var runtimeConfigurableDevices = DeviceManager.AllDevices.Where(d => d is IRuntimeConfigurableDevice);
try try
{ {
foreach (var device in runtimeConfigurableDevices) var reconfigurableDevices = DeviceManager.AllDevices.Where(d => d is ReconfigurableDevice);
foreach (var device in reconfigurableDevices)
{ {
// Get the current device config so new values can be overwritten over existing // Get the current device config so new values can be overwritten over existing
var deviceConfig = (device as IRuntimeConfigurableDevice).GetDeviceConfig(); var deviceConfig = (device as ReconfigurableDevice).Config;
if (device is RoomOnToDefaultSourceWhenOccupied) if (device is RoomOnToDefaultSourceWhenOccupied)
{ {
var devConfig = (deviceConfig as RoomOnToDefaultSourceWhenOccupiedConfig); Debug.Console(1, "Mapping Room on via Occupancy values from Fusion");
var devProps = JsonConvert.DeserializeObject<RoomOnToDefaultSourceWhenOccupiedConfig>(deviceConfig.Properties.ToString());
var enableFeature = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupied")); var enableFeature = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupied"));
if (enableFeature != null) if (enableFeature != null)
devConfig.EnableRoomOnWhenOccupied = bool.Parse(enableFeature.CustomFieldValue); devProps.EnableRoomOnWhenOccupied = bool.Parse(enableFeature.CustomFieldValue);
var enableTime = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomOnWhenOccupiedStartTime")); var enableTime = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomOnWhenOccupiedStartTime"));
if (enableTime != null) if (enableTime != null)
devConfig.OccupancyStartTime = enableTime.CustomFieldValue; devProps.OccupancyStartTime = enableTime.CustomFieldValue;
var disableTime = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomOnWhenOccupiedEndTime")); var disableTime = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomOnWhenOccupiedEndTime"));
if (disableTime != null) if (disableTime != null)
devConfig.OccupancyEndTime = disableTime.CustomFieldValue; devProps.OccupancyEndTime = disableTime.CustomFieldValue;
var enableSunday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedSun")); var enableSunday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedSun"));
if (enableSunday != null) if (enableSunday != null)
devConfig.EnableSunday = bool.Parse(enableSunday.CustomFieldValue); devProps.EnableSunday = bool.Parse(enableSunday.CustomFieldValue);
var enableMonday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedMon")); var enableMonday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedMon"));
if (enableMonday != null) if (enableMonday != null)
devConfig.EnableMonday = bool.Parse(enableMonday.CustomFieldValue); devProps.EnableMonday = bool.Parse(enableMonday.CustomFieldValue);
var enableTuesday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedTue")); var enableTuesday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedTue"));
if (enableTuesday != null) if (enableTuesday != null)
devConfig.EnableTuesday = bool.Parse(enableTuesday.CustomFieldValue); devProps.EnableTuesday = bool.Parse(enableTuesday.CustomFieldValue);
var enableWednesday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedWed")); var enableWednesday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedWed"));
if (enableWednesday != null) if (enableWednesday != null)
devConfig.EnableWednesday = bool.Parse(enableWednesday.CustomFieldValue); devProps.EnableWednesday = bool.Parse(enableWednesday.CustomFieldValue);
var enableThursday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedThu")); var enableThursday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedThu"));
if (enableThursday != null) if (enableThursday != null)
devConfig.EnableThursday = bool.Parse(enableThursday.CustomFieldValue); devProps.EnableThursday = bool.Parse(enableThursday.CustomFieldValue);
var enableFriday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedFri")); var enableFriday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedFri"));
if (enableFriday != null) if (enableFriday != null)
devConfig.EnableFriday = bool.Parse(enableFriday.CustomFieldValue); devProps.EnableFriday = bool.Parse(enableFriday.CustomFieldValue);
var enableSaturday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedSat")); var enableSaturday = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("EnRoomOnWhenOccupiedSat"));
if (enableSaturday != null) if (enableSaturday != null)
devConfig.EnableSaturday = bool.Parse(enableSaturday.CustomFieldValue); devProps.EnableSaturday = bool.Parse(enableSaturday.CustomFieldValue);
deviceConfig = devConfig; deviceConfig.Properties = JToken.FromObject(devProps);
}
else if (device is EssentialsRoomBase)
{
// Set the room name
if (!string.IsNullOrEmpty(roomInfo.Name))
{
Debug.Console(1, "Current Room Name: {0}. New Room Name: {1}", deviceConfig.Name, roomInfo.Name);
// Set the name in config
deviceConfig.Name = roomInfo.Name;
Debug.Console(1, "Room Name Successfully Changed.");
}
// Set the help message
var helpMessage = roomInfo.FusionCustomProperties.FirstOrDefault(p => p.ID.Equals("RoomHelpMessage"));
if (helpMessage != null)
{
//Debug.Console(1, "Current Help Message: {0}. New Help Message: {1}", deviceConfig.Properties["help"]["message"].Value<string>(ToString()), helpMessage.CustomFieldValue);
deviceConfig.Properties["helpMessage"] = (string)helpMessage.CustomFieldValue;
}
} }
// Set the config on the device // Set the config on the device
(device as IRuntimeConfigurableDevice).SetDeviceConfig(deviceConfig); (device as ReconfigurableDevice).SetConfig(deviceConfig);
} }
//var roomConfig = ConfigReader.ConfigObject.Rooms.FirstOrDefault(r => r.Key.Equals(roomKey);
//if(roomConfig != null)
//{
// roomConfig.Name = roomInfo.Name;
// // Update HelpMessage in room properties
// roomConfig.Properties.
//}
} }
catch (Exception e) catch (Exception e)
{ {

View File

@@ -87,9 +87,7 @@ namespace PepperDash.Essentials
else if (typeName == "roomonwhenoccupancydetectedfeature") else if (typeName == "roomonwhenoccupancydetectedfeature")
{ {
var props = JsonConvert.DeserializeObject<Room.Behaviours.RoomOnToDefaultSourceWhenOccupiedConfig>(properties.ToString()); return new Room.Behaviours.RoomOnToDefaultSourceWhenOccupied(dc);
return new Room.Behaviours.RoomOnToDefaultSourceWhenOccupied(key, props);
} }
return null; return null;

View File

@@ -49,12 +49,12 @@ namespace PepperDash.Essentials
avDriver.CurrentRoom = room as EssentialsHuddleSpaceRoom; avDriver.CurrentRoom = room as EssentialsHuddleSpaceRoom;
// Environment Driver // Environment Driver
if (avDriver.CurrentRoom.Config.Environment != null && avDriver.CurrentRoom.Config.Environment.DeviceKeys.Count > 0) if (avDriver.CurrentRoom.PropertiesConfig.Environment != null && avDriver.CurrentRoom.PropertiesConfig.Environment.DeviceKeys.Count > 0)
{ {
Debug.Console(0, panelController, "Adding environment driver"); Debug.Console(0, panelController, "Adding environment driver");
mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props); mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props);
mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.Config.Environment); mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.PropertiesConfig.Environment);
} }
mainDriver.HeaderDriver.SetupHeaderButtons(avDriver, avDriver.CurrentRoom); mainDriver.HeaderDriver.SetupHeaderButtons(avDriver, avDriver.CurrentRoom);
@@ -118,12 +118,12 @@ namespace PepperDash.Essentials
avDriver.CurrentRoom = room as EssentialsHuddleVtc1Room; avDriver.CurrentRoom = room as EssentialsHuddleVtc1Room;
// Environment Driver // Environment Driver
if (avDriver.CurrentRoom.Config.Environment != null && avDriver.CurrentRoom.Config.Environment.DeviceKeys.Count > 0) if (avDriver.CurrentRoom.PropertiesConfig.Environment != null && avDriver.CurrentRoom.PropertiesConfig.Environment.DeviceKeys.Count > 0)
{ {
Debug.Console(0, panelController, "Adding environment driver"); Debug.Console(0, panelController, "Adding environment driver");
mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props); mainDriver.EnvironmentDriver = new EssentialsEnvironmentDriver(mainDriver, props);
mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.Config.Environment); mainDriver.EnvironmentDriver.GetDevicesFromConfig(avDriver.CurrentRoom.PropertiesConfig.Environment);
} }
mainDriver.HeaderDriver.SetupHeaderButtons(avDriver, avDriver.CurrentRoom); mainDriver.HeaderDriver.SetupHeaderButtons(avDriver, avDriver.CurrentRoom);

View File

@@ -101,17 +101,33 @@
</Reference> </Reference>
<Reference Include="SimplSharpTimerEventInterface, Version=1.0.6197.20052, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL"> <Reference Include="SimplSharpTimerEventInterface, Version=1.0.6197.20052, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpTimerEventInterface.dll</HintPath> <HintPath>..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpTimerEventInterface.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Data" /> <Reference Include="System.Data" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="AppServer\Messengers\AtcDdvc01Messenger.cs" />
<Compile Include="AppServer\Messengers\AudioCodecBaseMessenger.cs" />
<Compile Include="AppServer\Messengers\MessengerBase.cs" />
<Compile Include="AppServer\Messengers\SystemMonitorMessenger.cs" />
<Compile Include="AppServer\Messengers\VideoCodecBaseMessenger.cs" /> <Compile Include="AppServer\Messengers\VideoCodecBaseMessenger.cs" />
<Compile Include="Audio\EssentialsVolumeLevelConfig.cs" /> <Compile Include="Audio\EssentialsVolumeLevelConfig.cs" />
<Compile Include="Bridges\BridgeBase.cs" /> <Compile Include="Bridges\BridgeBase.cs" />
<Compile Include="Bridges\BridgeFactory.cs" /> <Compile Include="Bridges\BridgeFactory.cs" />
<Compile Include="Bridges\CameraControllerBridge.cs" />
<Compile Include="Bridges\DisplayControllerBridge.cs" />
<Compile Include="Bridges\DigitalLoggerBridge.cs" />
<Compile Include="Bridges\DmChassisControllerBridge.cs" />
<Compile Include="Bridges\DmTxControllerBridge.cs" />
<Compile Include="Bridges\GenericLightingBridge.cs" />
<Compile Include="Bridges\GenericRelayDeviceBridge.cs" />
<Compile Include="Bridges\IBasicCommunicationBridge.cs" />
<Compile Include="Bridges\DmRmcControllerBridge.cs" />
<Compile Include="Bridges\IDigitalInputBridge.cs" />
<Compile Include="Bridges\JoinMapBase.cs" />
<Compile Include="Bridges\SystemMonitorBridge.cs" />
<Compile Include="Configuration ORIGINAL\Builders\TPConfig.cs" /> <Compile Include="Configuration ORIGINAL\Builders\TPConfig.cs" />
<Compile Include="Configuration ORIGINAL\Configuration.cs" /> <Compile Include="Configuration ORIGINAL\Configuration.cs" />
<Compile Include="Configuration ORIGINAL\ConfigurationHelpers.cs" /> <Compile Include="Configuration ORIGINAL\ConfigurationHelpers.cs" />
@@ -132,13 +148,13 @@
<Compile Include="Devices\NUMERIC AppleTV.cs" /> <Compile Include="Devices\NUMERIC AppleTV.cs" />
<Compile Include="ControlSystem.cs" /> <Compile Include="ControlSystem.cs" />
<Compile Include="Factory\UiDeviceFactory.cs" /> <Compile Include="Factory\UiDeviceFactory.cs" />
<Compile Include="OTHER\Fusion\EssentialsHuddleVtc1FusionController.cs" /> <Compile Include="FOR REFERENCE UI\OTHER\Fusion\EssentialsHuddleVtc1FusionController.cs" />
<Compile Include="OTHER\Fusion\FusionCustomPropertiesBridge.cs" /> <Compile Include="FOR REFERENCE UI\OTHER\Fusion\FusionCustomPropertiesBridge.cs" />
<Compile Include="OTHER\Fusion\FusionEventHandlers.cs" /> <Compile Include="FOR REFERENCE UI\OTHER\Fusion\FusionEventHandlers.cs" />
<Compile Include="OTHER\Fusion\FusionProcessorQueries.cs" /> <Compile Include="FOR REFERENCE UI\OTHER\Fusion\FusionProcessorQueries.cs" />
<Compile Include="OTHER\Fusion\FusionRviDataClasses.cs" /> <Compile Include="FOR REFERENCE UI\OTHER\Fusion\FusionRviDataClasses.cs" />
<Compile Include="REMOVE EssentialsApp.cs" /> <Compile Include="REMOVE EssentialsApp.cs" />
<Compile Include="OTHER\Fusion\EssentialsHuddleSpaceFusionSystemControllerBase.cs" /> <Compile Include="FOR REFERENCE UI\OTHER\Fusion\EssentialsHuddleSpaceFusionSystemControllerBase.cs" />
<Compile Include="HttpApiHandler.cs" /> <Compile Include="HttpApiHandler.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Room\Behaviours\RoomOnToDefaultSourceWhenOccupied.cs" /> <Compile Include="Room\Behaviours\RoomOnToDefaultSourceWhenOccupied.cs" />

View File

@@ -4,5 +4,5 @@
[assembly: AssemblyCompany("PepperDash Technology Corp")] [assembly: AssemblyCompany("PepperDash Technology Corp")]
[assembly: AssemblyProduct("PepperDashEssentials")] [assembly: AssemblyProduct("PepperDashEssentials")]
[assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2018")] [assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2018")]
[assembly: AssemblyVersion("1.2.6.*")] [assembly: AssemblyVersion("1.3.1.*")]

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ControlSystem> <ControlSystem>
<Name>Test RMC3</Name> <Name>192.168.10.1</Name>
<Address>auto 192.168.1.40</Address> <Address>auto 192.168.10.1</Address>
<ProgramSlot>Program01</ProgramSlot> <ProgramSlot>Program01</ProgramSlot>
<Storage>Internal Flash</Storage> <Storage>Internal Flash</Storage>
</ControlSystem> </ControlSystem>

View File

@@ -11,6 +11,7 @@ using Newtonsoft.Json.Linq;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Devices;
using PepperDash.Essentials.Devices.Common.Occupancy; using PepperDash.Essentials.Devices.Common.Occupancy;
namespace PepperDash.Essentials.Room.Behaviours namespace PepperDash.Essentials.Room.Behaviours
@@ -18,9 +19,9 @@ namespace PepperDash.Essentials.Room.Behaviours
/// <summary> /// <summary>
/// A device that when linked to a room can power the room on when enabled during scheduled hours. /// A device that when linked to a room can power the room on when enabled during scheduled hours.
/// </summary> /// </summary>
public class RoomOnToDefaultSourceWhenOccupied : Device, IRuntimeConfigurableDevice public class RoomOnToDefaultSourceWhenOccupied : ReconfigurableDevice
{ {
RoomOnToDefaultSourceWhenOccupiedConfig Config; RoomOnToDefaultSourceWhenOccupiedConfig PropertiesConfig;
public bool FeatureEnabled { get; private set; } public bool FeatureEnabled { get; private set; }
@@ -42,10 +43,10 @@ namespace PepperDash.Essentials.Room.Behaviours
private Fusion.EssentialsHuddleSpaceFusionSystemControllerBase FusionRoom; private Fusion.EssentialsHuddleSpaceFusionSystemControllerBase FusionRoom;
public RoomOnToDefaultSourceWhenOccupied(string key, RoomOnToDefaultSourceWhenOccupiedConfig config) public RoomOnToDefaultSourceWhenOccupied(DeviceConfig config) :
: base(key) base (config)
{ {
Config = config; PropertiesConfig = JsonConvert.DeserializeObject<RoomOnToDefaultSourceWhenOccupiedConfig>(config.Properties.ToString());
FeatureEventGroup = new ScheduledEventGroup(this.Key); FeatureEventGroup = new ScheduledEventGroup(this.Key);
@@ -63,7 +64,7 @@ namespace PepperDash.Essentials.Room.Behaviours
else else
Debug.Console(1, this, "Room has no RoomOccupancy object set"); Debug.Console(1, this, "Room has no RoomOccupancy object set");
var fusionRoomKey = Config.RoomKey + "-fusion"; var fusionRoomKey = PropertiesConfig.RoomKey + "-fusion";
FusionRoom = DeviceManager.GetDeviceForKey(fusionRoomKey) as Fusion.EssentialsHuddleSpaceFusionSystemControllerBase; FusionRoom = DeviceManager.GetDeviceForKey(fusionRoomKey) as Fusion.EssentialsHuddleSpaceFusionSystemControllerBase;
@@ -79,45 +80,48 @@ namespace PepperDash.Essentials.Room.Behaviours
return base.CustomActivate(); return base.CustomActivate();
} }
/// <summary>
/// Sets up device based on config values
/// </summary>
void SetUpDevice() void SetUpDevice()
{ {
Room = DeviceManager.GetDeviceForKey(Config.RoomKey) as EssentialsRoomBase; Room = DeviceManager.GetDeviceForKey(PropertiesConfig.RoomKey) as EssentialsRoomBase;
if (Room != null) if (Room != null)
{ {
try try
{ {
FeatureEnabledTime = DateTime.Parse(Config.OccupancyStartTime); FeatureEnabledTime = DateTime.Parse(PropertiesConfig.OccupancyStartTime);
if (FeatureEnabledTime != null) if (FeatureEnabledTime != null)
{ {
Debug.Console(1, this, "Enabled Time: {0}", FeatureEnabledTime.ToString()); Debug.Console(1, this, "Enabled Time: {0}", FeatureEnabledTime.ToString());
} }
else else
Debug.Console(1, this, "Unable to parse {0} to DateTime", Config.OccupancyStartTime); Debug.Console(1, this, "Unable to parse {0} to DateTime", PropertiesConfig.OccupancyStartTime);
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Console(1, this, "Unable to parse OccupancyStartTime property: {0} \n Error: {1}", Config.OccupancyStartTime, e); Debug.Console(1, this, "Unable to parse OccupancyStartTime property: {0} \n Error: {1}", PropertiesConfig.OccupancyStartTime, e);
} }
try try
{ {
FeatureDisabledTime = DateTime.Parse(Config.OccupancyEndTime); FeatureDisabledTime = DateTime.Parse(PropertiesConfig.OccupancyEndTime);
if (FeatureDisabledTime != null) if (FeatureDisabledTime != null)
{ {
Debug.Console(1, this, "Disabled Time: {0}", FeatureDisabledTime.ToString()); Debug.Console(1, this, "Disabled Time: {0}", FeatureDisabledTime.ToString());
} }
else else
Debug.Console(1, this, "Unable to parse {0} to DateTime", Config.OccupancyEndTime); Debug.Console(1, this, "Unable to parse {0} to DateTime", PropertiesConfig.OccupancyEndTime);
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Console(1, this, "Unable to parse a DateTime config value \n Error: {1}", e); Debug.Console(1, this, "Unable to parse a DateTime config value \n Error: {1}", e);
} }
if (!Config.EnableRoomOnWhenOccupied) if (!PropertiesConfig.EnableRoomOnWhenOccupied)
FeatureEventGroup.ClearAllEvents(); FeatureEventGroup.ClearAllEvents();
else else
{ {
@@ -133,30 +137,18 @@ namespace PepperDash.Essentials.Room.Behaviours
FeatureEnabled = CheckIfFeatureShouldBeEnabled(); FeatureEnabled = CheckIfFeatureShouldBeEnabled();
} }
else else
Debug.Console(1, this, "Unable to get room from Device Manager with key: {0}", Config.RoomKey); Debug.Console(1, this, "Unable to get room from Device Manager with key: {0}", PropertiesConfig.RoomKey);
} }
/// <summary>
/// Returns a JObject of the device config properties as they currently exist at runtime protected override void CustomSetConfig(DeviceConfig config)
/// </summary>
/// <returns></returns>
public JToken GetLocalConfigProperties()
{ {
return JToken.FromObject(Config); var newPropertiesConfig = JsonConvert.DeserializeObject<RoomOnToDefaultSourceWhenOccupiedConfig>(config.Properties.ToString());
}
public object GetDeviceConfig() if(newPropertiesConfig != null)
{ PropertiesConfig = newPropertiesConfig;
return Config;
}
public void SetDeviceConfig(object config) ConfigWriter.UpdateDeviceConfig(config);
{
var newConfig = config as RoomOnToDefaultSourceWhenOccupiedConfig;
Config = newConfig;
ConfigWriter.UpdateDeviceProperties(this.Key, GetLocalConfigProperties());
SetUpDevice(); SetUpDevice();
} }
@@ -182,7 +174,7 @@ namespace PepperDash.Essentials.Room.Behaviours
{ {
if (SchEvent.Name == FeatureEnableEventName) if (SchEvent.Name == FeatureEnableEventName)
{ {
if (Config.EnableRoomOnWhenOccupied) if (PropertiesConfig.EnableRoomOnWhenOccupied)
FeatureEnabled = true; FeatureEnabled = true;
Debug.Console(1, this, "*****Feature Enabled by event.*****"); Debug.Console(1, this, "*****Feature Enabled by event.*****");
@@ -204,7 +196,7 @@ namespace PepperDash.Essentials.Room.Behaviours
{ {
bool enabled = false; bool enabled = false;
if(Config.EnableRoomOnWhenOccupied) if(PropertiesConfig.EnableRoomOnWhenOccupied)
{ {
Debug.Console(1, this, "Current Time: {0} \n FeatureEnabledTime: {1} \n FeatureDisabledTime: {2}", DateTime.Now, FeatureEnabledTime, FeatureDisabledTime); Debug.Console(1, this, "Current Time: {0} \n FeatureEnabledTime: {1} \n FeatureDisabledTime: {2}", DateTime.Now, FeatureEnabledTime, FeatureDisabledTime);
@@ -446,19 +438,19 @@ namespace PepperDash.Essentials.Room.Behaviours
{ {
ScheduledEventCommon.eWeekDays value = new ScheduledEventCommon.eWeekDays(); ScheduledEventCommon.eWeekDays value = new ScheduledEventCommon.eWeekDays();
if (Config.EnableSunday) if (PropertiesConfig.EnableSunday)
value = value | ScheduledEventCommon.eWeekDays.Sunday; value = value | ScheduledEventCommon.eWeekDays.Sunday;
if (Config.EnableMonday) if (PropertiesConfig.EnableMonday)
value = value | ScheduledEventCommon.eWeekDays.Monday; value = value | ScheduledEventCommon.eWeekDays.Monday;
if (Config.EnableTuesday) if (PropertiesConfig.EnableTuesday)
value = value | ScheduledEventCommon.eWeekDays.Tuesday; value = value | ScheduledEventCommon.eWeekDays.Tuesday;
if (Config.EnableWednesday) if (PropertiesConfig.EnableWednesday)
value = value | ScheduledEventCommon.eWeekDays.Wednesday; value = value | ScheduledEventCommon.eWeekDays.Wednesday;
if (Config.EnableThursday) if (PropertiesConfig.EnableThursday)
value = value | ScheduledEventCommon.eWeekDays.Thursday; value = value | ScheduledEventCommon.eWeekDays.Thursday;
if (Config.EnableFriday) if (PropertiesConfig.EnableFriday)
value = value | ScheduledEventCommon.eWeekDays.Friday; value = value | ScheduledEventCommon.eWeekDays.Friday;
if (Config.EnableSaturday) if (PropertiesConfig.EnableSaturday)
value = value | ScheduledEventCommon.eWeekDays.Saturday; value = value | ScheduledEventCommon.eWeekDays.Saturday;
return value; return value;
@@ -473,7 +465,7 @@ namespace PepperDash.Essentials.Room.Behaviours
{ {
if (type == ScheduledEventCommon.eCallbackReason.NormalExpiration) if (type == ScheduledEventCommon.eCallbackReason.NormalExpiration)
{ {
if(Config.EnableRoomOnWhenOccupied) if(PropertiesConfig.EnableRoomOnWhenOccupied)
FeatureEnabled = true; FeatureEnabled = true;
Debug.Console(1, this, "RoomOnToDefaultSourceWhenOccupied Feature Enabled."); Debug.Console(1, this, "RoomOnToDefaultSourceWhenOccupied Feature Enabled.");

View File

@@ -20,5 +20,7 @@ namespace PepperDash.Essentials.Room.Config
public string DefaultSourceItem { get; set; } public string DefaultSourceItem { get; set; }
[JsonProperty("videoCodecKey")] [JsonProperty("videoCodecKey")]
public string VideoCodecKey { get; set; } public string VideoCodecKey { get; set; }
[JsonProperty("audioCodecKey")]
public string AudioCodecKey { get; set; }
} }
} }

View File

@@ -24,63 +24,13 @@ namespace PepperDash.Essentials.Room.Config
var typeName = roomConfig.Type.ToLower(); var typeName = roomConfig.Type.ToLower();
if (typeName == "huddle") if (typeName == "huddle")
{ {
var props = JsonConvert.DeserializeObject<EssentialsHuddleRoomPropertiesConfig> var huddle = new EssentialsHuddleSpaceRoom(roomConfig);
(roomConfig.Properties.ToString());
var disp = DeviceManager.GetDeviceForKey(props.DefaultDisplayKey) as IRoutingSinkWithSwitching;
var audio = DeviceManager.GetDeviceForKey(props.DefaultAudioKey) as IRoutingSinkNoSwitching;
var huddle = new EssentialsHuddleSpaceRoom(roomConfig.Key, roomConfig.Name, disp, audio, props);
if (props.Occupancy != null)
huddle.SetRoomOccupancy(DeviceManager.GetDeviceForKey(props.Occupancy.DeviceKey) as
PepperDash.Essentials.Devices.Common.Occupancy.IOccupancyStatusProvider, props.Occupancy.TimoutMinutes);
huddle.LogoUrl = props.Logo.GetUrl();
huddle.SourceListKey = props.SourceListKey;
huddle.DefaultSourceItem = props.DefaultSourceItem;
huddle.DefaultVolume = (ushort)(props.Volumes.Master.Level * 65535 / 100);
return huddle; return huddle;
} }
//else if (typeName == "presentation")
//{
// var props = JsonConvert.DeserializeObject<EssentialsPresentationRoomPropertiesConfig>
// (this.Properties.ToString());
// var displaysDict = new Dictionary<uint, IRoutingSinkNoSwitching>();
// uint i = 1;
// foreach (var dispKey in props.DisplayKeys) // read in the ordered displays list
// {
// var disp = DeviceManager.GetDeviceForKey(dispKey) as IRoutingSinkWithSwitching;
// displaysDict.Add(i++, disp);
// }
// // Get the master volume control
// IBasicVolumeWithFeedback masterVolumeControlDev = props.Volumes.Master.GetDevice();
// var presRoom = new EssentialsPresentationRoom(Key, Name, displaysDict, masterVolumeControlDev, props);
// return presRoom;
//}
else if (typeName == "huddlevtc1") else if (typeName == "huddlevtc1")
{ {
var props = JsonConvert.DeserializeObject<EssentialsHuddleVtc1PropertiesConfig> var rm = new EssentialsHuddleVtc1Room(roomConfig);
(roomConfig.Properties.ToString());
var disp = DeviceManager.GetDeviceForKey(props.DefaultDisplayKey) as IRoutingSinkWithSwitching;
var codec = DeviceManager.GetDeviceForKey(props.VideoCodecKey) as
PepperDash.Essentials.Devices.Common.VideoCodec.VideoCodecBase;
var rm = new EssentialsHuddleVtc1Room(roomConfig.Key, roomConfig.Name, disp, codec, codec, props);
// Add Occupancy object from config
if (props.Occupancy != null)
rm.SetRoomOccupancy(DeviceManager.GetDeviceForKey(props.Occupancy.DeviceKey) as
PepperDash.Essentials.Devices.Common.Occupancy.IOccupancyStatusProvider, props.Occupancy.TimoutMinutes);
rm.LogoUrl = props.Logo.GetUrl();
rm.SourceListKey = props.SourceListKey;
rm.DefaultSourceItem = props.DefaultSourceItem;
rm.DefaultVolume = (ushort)(props.Volumes.Master.Level * 65535 / 100);
rm.MicrophonePrivacy = GetMicrophonePrivacy(props, rm); // Get Microphone Privacy object, if any
rm.Emergency = GetEmergency(props, rm); // Get emergency object, if any
return rm; return rm;
} }
@@ -96,7 +46,7 @@ namespace PepperDash.Essentials.Room.Config
/// Gets and operating, standalone emergegncy object that can be plugged into a room. /// Gets and operating, standalone emergegncy object that can be plugged into a room.
/// Returns null if there is no emergency defined /// Returns null if there is no emergency defined
/// </summary> /// </summary>
static EssentialsRoomEmergencyBase GetEmergency(EssentialsRoomPropertiesConfig props, EssentialsRoomBase room) public static EssentialsRoomEmergencyBase GetEmergency(EssentialsRoomPropertiesConfig props, EssentialsRoomBase room)
{ {
// This emergency // This emergency
var emergency = props.Emergency; var emergency = props.Emergency;
@@ -115,7 +65,7 @@ namespace PepperDash.Essentials.Room.Config
/// <param name="props"></param> /// <param name="props"></param>
/// <param name="room"></param> /// <param name="room"></param>
/// <returns></returns> /// <returns></returns>
static PepperDash.Essentials.Devices.Common.Microphones.MicrophonePrivacyController GetMicrophonePrivacy( public static PepperDash.Essentials.Devices.Common.Microphones.MicrophonePrivacyController GetMicrophonePrivacy(
EssentialsRoomPropertiesConfig props, EssentialsHuddleVtc1Room room) EssentialsRoomPropertiesConfig props, EssentialsHuddleVtc1Room room)
{ {
var microphonePrivacy = props.MicrophonePrivacy; var microphonePrivacy = props.MicrophonePrivacy;
@@ -322,8 +272,8 @@ namespace PepperDash.Essentials.Room.Config
[JsonProperty("deviceKey")] [JsonProperty("deviceKey")]
public string DeviceKey { get; set; } public string DeviceKey { get; set; }
[JsonProperty("timoutMinutes")] [JsonProperty("timeoutMinutes")]
public int TimoutMinutes { get; set; } public int TimeoutMinutes { get; set; }
} }
public class EssentialsRoomTechConfig public class EssentialsRoomTechConfig

View File

@@ -4,6 +4,8 @@ using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Newtonsoft.Json;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
@@ -66,7 +68,7 @@ namespace PepperDash.Essentials
} }
} }
public EssentialsRoomPropertiesConfig Config { get; private set; } public EssentialsHuddleRoomPropertiesConfig PropertiesConfig { get; private set; }
public IRoutingSinkWithSwitching DefaultDisplay { get; private set; } public IRoutingSinkWithSwitching DefaultDisplay { get; private set; }
public IRoutingSinkNoSwitching DefaultAudioDevice { get; private set; } public IRoutingSinkNoSwitching DefaultAudioDevice { get; private set; }
@@ -147,22 +149,32 @@ namespace PepperDash.Essentials
public string CurrentSourceInfoKey { get; private set; } public string CurrentSourceInfoKey { get; private set; }
/// <summary> public EssentialsHuddleSpaceRoom(DeviceConfig config)
/// : base(config)
/// </summary>
/// <param name="key"></param>
/// <param name="name"></param>
public EssentialsHuddleSpaceRoom(string key, string name, IRoutingSinkWithSwitching defaultDisplay,
IRoutingSinkNoSwitching defaultAudio, EssentialsRoomPropertiesConfig config)
: base(key, name)
{ {
Config = config; try
DefaultDisplay = defaultDisplay; {
DefaultAudioDevice = defaultAudio; PropertiesConfig = JsonConvert.DeserializeObject<EssentialsHuddleRoomPropertiesConfig>
if (defaultAudio is IBasicVolumeControls) (config.Properties.ToString());
DefaultVolumeControls = defaultAudio as IBasicVolumeControls; DefaultDisplay = DeviceManager.GetDeviceForKey(PropertiesConfig.DefaultDisplayKey) as IRoutingSinkWithSwitching;
else if (defaultAudio is IHasVolumeDevice)
DefaultVolumeControls = (defaultAudio as IHasVolumeDevice).VolumeDevice;
DefaultAudioDevice = DeviceManager.GetDeviceForKey(PropertiesConfig.DefaultAudioKey) as IRoutingSinkWithSwitching;
Initialize();
}
catch (Exception e)
{
Debug.Console(1, this, "Error building room: \n{0}", e);
}
}
void Initialize()
{
if (DefaultAudioDevice is IBasicVolumeControls)
DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls;
else if (DefaultAudioDevice is IHasVolumeDevice)
DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice;
CurrentVolumeControls = DefaultVolumeControls; CurrentVolumeControls = DefaultVolumeControls;
var disp = DefaultDisplay as DisplayBase; var disp = DefaultDisplay as DisplayBase;
@@ -195,6 +207,15 @@ namespace PepperDash.Essentials
EnablePowerOnToLastSource = true; EnablePowerOnToLastSource = true;
} }
protected override void CustomSetConfig(DeviceConfig config)
{
var newPropertiesConfig = JsonConvert.DeserializeObject<EssentialsHuddleRoomPropertiesConfig>(config.Properties.ToString());
if (newPropertiesConfig != null)
PropertiesConfig = newPropertiesConfig;
ConfigWriter.UpdateRoomConfig(config);
}
/// <summary> /// <summary>
/// ///
@@ -225,6 +246,21 @@ namespace PepperDash.Essentials
return true; return true;
} }
public override bool CustomActivate()
{
// Add Occupancy object from config
if (PropertiesConfig.Occupancy != null)
this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as
PepperDash.Essentials.Devices.Common.Occupancy.IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes);
this.LogoUrl = PropertiesConfig.Logo.GetUrl();
this.SourceListKey = PropertiesConfig.SourceListKey;
this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem;
this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100);
return base.CustomActivate();
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>

View File

@@ -4,17 +4,20 @@ using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Newtonsoft.Json;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Room.Config; using PepperDash.Essentials.Room.Config;
using PepperDash.Essentials.Devices.Common.Codec; using PepperDash.Essentials.Devices.Common.Codec;
using PepperDash.Essentials.Devices.Common.VideoCodec; using PepperDash.Essentials.Devices.Common.VideoCodec;
using PepperDash.Essentials.Devices.Common.AudioCodec;
namespace PepperDash.Essentials namespace PepperDash.Essentials
{ {
public class EssentialsHuddleVtc1Room : EssentialsRoomBase, IHasCurrentSourceInfoChange, public class EssentialsHuddleVtc1Room : EssentialsRoomBase, IHasCurrentSourceInfoChange,
IPrivacy, IHasCurrentVolumeControls, IRunRouteAction, IRunDefaultCallRoute, IHasVideoCodec IPrivacy, IHasCurrentVolumeControls, IRunRouteAction, IRunDefaultCallRoute, IHasVideoCodec, IHasAudioCodec
{ {
public event EventHandler<VolumeDeviceChangeEventArgs> CurrentVolumeDeviceChange; public event EventHandler<VolumeDeviceChangeEventArgs> CurrentVolumeDeviceChange;
public event SourceInfoChangeHandler CurrentSingleSourceChange; public event SourceInfoChangeHandler CurrentSingleSourceChange;
@@ -25,10 +28,10 @@ namespace PepperDash.Essentials
public BoolFeedback InCallFeedback { get; private set; } public BoolFeedback InCallFeedback { get; private set; }
/// <summary> ///// <summary>
/// Make this more specific ///// Make this more specific
/// </summary> ///// </summary>
public List<CodecActiveCallItem> ActiveCalls { get; private set; } //public List<CodecActiveCallItem> ActiveCalls { get; private set; }
/// <summary> /// <summary>
/// States: 0 for on hook, 1 for video, 2 for audio, 3 for telekenesis /// States: 0 for on hook, 1 for video, 2 for audio, 3 for telekenesis
@@ -98,7 +101,7 @@ namespace PepperDash.Essentials
} }
} }
public EssentialsHuddleVtc1PropertiesConfig Config { get; private set; } public EssentialsHuddleVtc1PropertiesConfig PropertiesConfig { get; private set; }
public IRoutingSinkWithSwitching DefaultDisplay { get; private set; } public IRoutingSinkWithSwitching DefaultDisplay { get; private set; }
public IBasicVolumeControls DefaultAudioDevice { get; private set; } public IBasicVolumeControls DefaultAudioDevice { get; private set; }
@@ -106,6 +109,8 @@ namespace PepperDash.Essentials
public VideoCodecBase VideoCodec { get; private set; } public VideoCodecBase VideoCodec { get; private set; }
public AudioCodecBase AudioCodec { get; private set; }
public bool ExcludeFromGlobalFunctions { get; set; } public bool ExcludeFromGlobalFunctions { get; set; }
/// <summary> /// <summary>
@@ -195,26 +200,41 @@ namespace PepperDash.Essentials
CCriticalSection SourceSelectLock = new CCriticalSection(); CCriticalSection SourceSelectLock = new CCriticalSection();
/// <summary> public EssentialsHuddleVtc1Room(DeviceConfig config)
/// : base(config)
/// </summary>
/// <param name="key"></param>
/// <param name="name"></param>
public EssentialsHuddleVtc1Room(string key, string name, IRoutingSinkWithSwitching defaultDisplay,
IBasicVolumeControls defaultAudio, VideoCodecBase codec, EssentialsHuddleVtc1PropertiesConfig config)
: base(key, name)
{ {
if (codec == null) try
throw new ArgumentNullException("codec cannot be null"); {
Config = config; PropertiesConfig = JsonConvert.DeserializeObject<EssentialsHuddleVtc1PropertiesConfig>
DefaultDisplay = defaultDisplay; (config.Properties.ToString());
VideoCodec = codec; DefaultDisplay = DeviceManager.GetDeviceForKey(PropertiesConfig.DefaultDisplayKey) as IRoutingSinkWithSwitching;
DefaultAudioDevice = defaultAudio;
if (defaultAudio is IBasicVolumeControls) VideoCodec = DeviceManager.GetDeviceForKey(PropertiesConfig.VideoCodecKey) as
DefaultVolumeControls = defaultAudio as IBasicVolumeControls; PepperDash.Essentials.Devices.Common.VideoCodec.VideoCodecBase;
else if (defaultAudio is IHasVolumeDevice) if (VideoCodec == null)
DefaultVolumeControls = (defaultAudio as IHasVolumeDevice).VolumeDevice; throw new ArgumentNullException("codec cannot be null");
AudioCodec = DeviceManager.GetDeviceForKey(PropertiesConfig.AudioCodecKey) as
PepperDash.Essentials.Devices.Common.AudioCodec.AudioCodecBase;
if (AudioCodec == null)
Debug.Console(0, this, "No Audio Codec Found");
DefaultAudioDevice = DeviceManager.GetDeviceForKey(PropertiesConfig.DefaultAudioKey) as IBasicVolumeControls;
Initialize();
}
catch (Exception e)
{
Debug.Console(1, this, "Error building room: \n{0}", e);
}
}
void Initialize()
{
if (DefaultAudioDevice is IBasicVolumeControls)
DefaultVolumeControls = DefaultAudioDevice as IBasicVolumeControls;
else if (DefaultAudioDevice is IHasVolumeDevice)
DefaultVolumeControls = (DefaultAudioDevice as IHasVolumeDevice).VolumeDevice;
CurrentVolumeControls = DefaultVolumeControls; CurrentVolumeControls = DefaultVolumeControls;
@@ -248,9 +268,30 @@ namespace PepperDash.Essentials
}; };
} }
InCallFeedback = new BoolFeedback(() => VideoCodec.IsInCall);
// Combines call feedback from both codecs if available
InCallFeedback = new BoolFeedback(() =>
{
bool inAudioCall = false;
bool inVideoCall = false;
if(AudioCodec != null)
inAudioCall = AudioCodec.IsInCall;
if(VideoCodec != null)
inVideoCall = AudioCodec.IsInCall;
if (inAudioCall || inVideoCall)
return true;
else
return false;
});
VideoCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate(); VideoCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate();
if (AudioCodec != null)
AudioCodec.CallStatusChange += (o, a) => this.InCallFeedback.FireUpdate();
IsSharingFeedback = new BoolFeedback(() => VideoCodec.SharingContentIsOnFeedback.BoolValue); IsSharingFeedback = new BoolFeedback(() => VideoCodec.SharingContentIsOnFeedback.BoolValue);
VideoCodec.SharingContentIsOnFeedback.OutputChange += (o, a) => this.IsSharingFeedback.FireUpdate(); VideoCodec.SharingContentIsOnFeedback.OutputChange += (o, a) => this.IsSharingFeedback.FireUpdate();
@@ -264,6 +305,37 @@ namespace PepperDash.Essentials
EnablePowerOnToLastSource = true; EnablePowerOnToLastSource = true;
} }
protected override void CustomSetConfig(DeviceConfig config)
{
var newPropertiesConfig = JsonConvert.DeserializeObject<EssentialsHuddleVtc1PropertiesConfig>(config.Properties.ToString());
if (newPropertiesConfig != null)
PropertiesConfig = newPropertiesConfig;
ConfigWriter.UpdateRoomConfig(config);
}
public override bool CustomActivate()
{
// Add Occupancy object from config
if (PropertiesConfig.Occupancy != null)
this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as
PepperDash.Essentials.Devices.Common.Occupancy.IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes);
this.LogoUrl = PropertiesConfig.Logo.GetUrl();
this.SourceListKey = PropertiesConfig.SourceListKey;
this.DefaultSourceItem = PropertiesConfig.DefaultSourceItem;
this.DefaultVolume = (ushort)(PropertiesConfig.Volumes.Master.Level * 65535 / 100);
// Get Microphone Privacy object, if any
this.MicrophonePrivacy = EssentialsRoomConfigHelper.GetMicrophonePrivacy(PropertiesConfig, this);
// Get emergency object, if any
this.Emergency = EssentialsRoomConfigHelper.GetEmergency(PropertiesConfig, this);
return base.CustomActivate();
}
/// <summary> /// <summary>
/// ///

View File

@@ -7,6 +7,8 @@ using Crestron.SimplSharp.Scheduler;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Core.Devices;
using PepperDash.Essentials.Devices.Common.Occupancy; using PepperDash.Essentials.Devices.Common.Occupancy;
namespace PepperDash.Essentials namespace PepperDash.Essentials
@@ -14,7 +16,7 @@ namespace PepperDash.Essentials
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
public abstract class EssentialsRoomBase : Device public abstract class EssentialsRoomBase : ReconfigurableDevice
{ {
/// <summary> /// <summary>
/// ///
@@ -80,12 +82,9 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
public bool ZeroVolumeWhenSwtichingVolumeDevices { get; private set; } public bool ZeroVolumeWhenSwtichingVolumeDevices { get; private set; }
/// <summary>
/// public EssentialsRoomBase(DeviceConfig config)
/// </summary> : base(config)
/// <param name="key"></param>
/// <param name="name"></param>
public EssentialsRoomBase(string key, string name) : base(key, name)
{ {
// Setup the ShutdownPromptTimer // Setup the ShutdownPromptTimer
ShutdownPromptTimer = new SecondsCountdownTimer(Key + "-offTimer"); ShutdownPromptTimer = new SecondsCountdownTimer(Key + "-offTimer");
@@ -159,6 +158,8 @@ namespace PepperDash.Essentials
ShutdownPromptTimer.SecondsToCount = ShutdownVacancySeconds; ShutdownPromptTimer.SecondsToCount = ShutdownVacancySeconds;
ShutdownType = type; ShutdownType = type;
ShutdownPromptTimer.Start(); ShutdownPromptTimer.Start();
Debug.Console(0, this, "ShutdwonPromptTimer Started. Type: {0}. Seconds: {1}", ShutdownType, ShutdownPromptTimer.SecondsToCount);
} }
public void StartRoomVacancyTimer(eVacancyMode mode) public void StartRoomVacancyTimer(eVacancyMode mode)
@@ -170,7 +171,7 @@ namespace PepperDash.Essentials
VacancyMode = mode; VacancyMode = mode;
RoomVacancyShutdownTimer.Start(); RoomVacancyShutdownTimer.Start();
Debug.Console(0, this, "Vacancy Timer Started."); Debug.Console(0, this, "Vacancy Timer Started. Mode: {0}. Seconds: {1}", VacancyMode, RoomVacancyShutdownTimer.SecondsToCount);
} }
/// <summary> /// <summary>
@@ -213,6 +214,8 @@ namespace PepperDash.Essentials
if(timeoutMinutes > 0) if(timeoutMinutes > 0)
RoomVacancyShutdownSeconds = timeoutMinutes * 60; RoomVacancyShutdownSeconds = timeoutMinutes * 60;
Debug.Console(1, this, "RoomVacancyShutdownSeconds set to {0}", RoomVacancyShutdownSeconds);
RoomOccupancy = statusProvider; RoomOccupancy = statusProvider;
OnRoomOccupancyIsSet(); OnRoomOccupancyIsSet();

View File

@@ -76,7 +76,7 @@ namespace PepperDash.Essentials
avDriver.PopupInterlock.HideAndClear()); avDriver.PopupInterlock.HideAndClear());
} }
void SetUpHelpButton(EssentialsRoomPropertiesConfig roomConf) public void SetUpHelpButton(EssentialsRoomPropertiesConfig roomConf)
{ {
// Help roomConf and popup // Help roomConf and popup
if (roomConf.Help != null) if (roomConf.Help != null)
@@ -107,7 +107,7 @@ namespace PepperDash.Essentials
var room = DeviceManager.GetDeviceForKey(Config.DefaultRoomKey) var room = DeviceManager.GetDeviceForKey(Config.DefaultRoomKey)
as EssentialsHuddleSpaceRoom; as EssentialsHuddleSpaceRoom;
if (room != null) if (room != null)
message = room.Config.HelpMessage; message = room.PropertiesConfig.HelpMessage;
else else
message = "Sorry, no help message available. No room connected."; message = "Sorry, no help message available. No room connected.";
//TriList.StringInput[UIStringJoin.HelpMessage].StringValue = message; //TriList.StringInput[UIStringJoin.HelpMessage].StringValue = message;
@@ -227,7 +227,7 @@ namespace PepperDash.Essentials
TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, true); TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, true);
var roomConf = currentRoom.Config; var roomConf = currentRoom.PropertiesConfig;
// Register for the PopupInterlock IsShowsFeedback event to tie the header carets subpage visiblity to it // Register for the PopupInterlock IsShowsFeedback event to tie the header carets subpage visiblity to it
Parent.AvDriver.PopupInterlock.StatusChanged -= PopupInterlock_StatusChanged; Parent.AvDriver.PopupInterlock.StatusChanged -= PopupInterlock_StatusChanged;
@@ -289,7 +289,7 @@ namespace PepperDash.Essentials
TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, true); TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, true);
var roomConf = currentRoom.Config; var roomConf = currentRoom.PropertiesConfig;
// Register for the PopupInterlock IsShowsFeedback event to tie the header carets subpage visiblity to it // Register for the PopupInterlock IsShowsFeedback event to tie the header carets subpage visiblity to it
Parent.AvDriver.PopupInterlock.StatusChanged -= PopupInterlock_StatusChanged; Parent.AvDriver.PopupInterlock.StatusChanged -= PopupInterlock_StatusChanged;

View File

@@ -164,7 +164,7 @@ namespace PepperDash.Essentials
get get
{ {
if (_TechDriver == null) if (_TechDriver == null)
_TechDriver = new PepperDash.Essentials.UIDrivers.EssentialsHuddleTechPageDriver(TriList, CurrentRoom.Config.Tech); _TechDriver = new PepperDash.Essentials.UIDrivers.EssentialsHuddleTechPageDriver(TriList, CurrentRoom.PropertiesConfig.Tech);
return _TechDriver; return _TechDriver;
} }
} }
@@ -220,9 +220,7 @@ namespace PepperDash.Essentials
return; return;
} }
var roomConf = CurrentRoom.Config; var roomConf = CurrentRoom.PropertiesConfig;
TriList.SetString(UIStringJoin.CurrentRoomName, CurrentRoom.Name);
if (Config.HeaderStyle.ToLower() == CrestronTouchpanelPropertiesConfig.Habanero) if (Config.HeaderStyle.ToLower() == CrestronTouchpanelPropertiesConfig.Habanero)
{ {
@@ -724,13 +722,12 @@ namespace PepperDash.Essentials
CurrentRoom.CurrentVolumeControls.VolumeDown(state); CurrentRoom.CurrentVolumeControls.VolumeDown(state);
} }
/// <summary> /// <summary>
/// Helper for property setter. Sets the panel to the given room, latching up all functionality /// Helper for property setter. Sets the panel to the given room, latching up all functionality
/// </summary> /// </summary>
void SetCurrentRoom(EssentialsHuddleSpaceRoom room) public void RefreshCurrentRoom(EssentialsHuddleSpaceRoom room)
{ {
if (_CurrentRoom == room) return;
// Disconnect current (probably never called)
if (_CurrentRoom != null) if (_CurrentRoom != null)
{ {
// Disconnect current room // Disconnect current room
@@ -742,7 +739,7 @@ namespace PepperDash.Essentials
_CurrentRoom.ShutdownPromptTimer.HasFinished -= ShutdownPromptTimer_HasFinished; _CurrentRoom.ShutdownPromptTimer.HasFinished -= ShutdownPromptTimer_HasFinished;
_CurrentRoom.ShutdownPromptTimer.WasCancelled -= ShutdownPromptTimer_WasCancelled; _CurrentRoom.ShutdownPromptTimer.WasCancelled -= ShutdownPromptTimer_WasCancelled;
_CurrentRoom.OnFeedback.OutputChange += CurrentRoom_OnFeedback_OutputChange; _CurrentRoom.OnFeedback.OutputChange -= CurrentRoom_OnFeedback_OutputChange;
_CurrentRoom.IsWarmingUpFeedback.OutputChange -= CurrentRoom_IsWarmingFeedback_OutputChange; _CurrentRoom.IsWarmingUpFeedback.OutputChange -= CurrentRoom_IsWarmingFeedback_OutputChange;
_CurrentRoom.IsCoolingDownFeedback.OutputChange -= IsCoolingDownFeedback_OutputChange; _CurrentRoom.IsCoolingDownFeedback.OutputChange -= IsCoolingDownFeedback_OutputChange;
} }
@@ -818,83 +815,26 @@ namespace PepperDash.Essentials
} }
} }
//void SetupHeaderButtons() void SetCurrentRoom(EssentialsHuddleSpaceRoom room)
//{ {
// HeaderButtonsAreSetUp = false; if (_CurrentRoom == room) return;
// Disconnect current (probably never called)
// TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, true); room.ConfigChanged -= room_ConfigChanged;
room.ConfigChanged += room_ConfigChanged;
// var roomConf = CurrentRoom.Config; RefreshCurrentRoom(room);
}
// // Gear
// TriList.SetString(UIStringJoin.HeaderButtonIcon5, "Gear");
// TriList.SetSigHeldAction(UIBoolJoin.HeaderIcon5Press, 2000,
// ShowTech,
// null,
// () =>
// {
// if (CurrentRoom.OnFeedback.BoolValue)
// PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.VolumesPageVisible);
// else
// PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.VolumesPagePowerOffVisible);
// });
// TriList.SetSigFalseAction(UIBoolJoin.TechExitButton, () =>
// PopupInterlock.HideAndClear());
// // Help button and popup
// if (CurrentRoom.Config.Help != null)
// {
// TriList.SetString(UIStringJoin.HelpMessage, roomConf.Help.Message);
// TriList.SetBool(UIBoolJoin.HelpPageShowCallButtonVisible, roomConf.Help.ShowCallButton);
// TriList.SetString(UIStringJoin.HelpPageCallButtonText, roomConf.Help.CallButtonText);
// if (roomConf.Help.ShowCallButton)
// TriList.SetSigFalseAction(UIBoolJoin.HelpPageShowCallButtonPress, () => { }); // ************ FILL IN
// else
// TriList.ClearBoolSigAction(UIBoolJoin.HelpPageShowCallButtonPress);
// }
// else // older config
// {
// TriList.SetString(UIStringJoin.HelpMessage, CurrentRoom.Config.HelpMessage);
// TriList.SetBool(UIBoolJoin.HelpPageShowCallButtonVisible, false);
// TriList.SetString(UIStringJoin.HelpPageCallButtonText, null);
// TriList.ClearBoolSigAction(UIBoolJoin.HelpPageShowCallButtonPress);
// }
// TriList.SetString(UIStringJoin.HeaderButtonIcon4, "Help");
// TriList.SetSigFalseAction(UIBoolJoin.HeaderIcon4Press, () =>
// {
// string message = null;
// var room = DeviceManager.GetDeviceForKey(Config.DefaultRoomKey)
// as EssentialsHuddleSpaceRoom;
// if (room != null)
// message = room.Config.HelpMessage;
// else
// message = "Sorry, no help message available. No room connected.";
// //TriList.StringInput[UIStringJoin.HelpMessage].StringValue = message;
// PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.HelpPageVisible);
// });
// uint nextJoin = 3953;
// //// Calendar button
// //if (_CurrentRoom.ScheduleSource != null)
// //{
// // TriList.SetString(nextJoin, "Calendar");
// // TriList.SetSigFalseAction(nextJoin, CalendarPress);
// // nextJoin--;
// //}
// //nextJoin--;
// // blank any that remain
// for (var i = nextJoin; i > 3950; i--)
// {
// TriList.SetString(i, "Blank");
// TriList.SetSigFalseAction(i, () => { });
// }
// HeaderButtonsAreSetUp = true;
//}
/// <summary>
/// Fires when room config of current room has changed. Meant to refresh room values to propegate any updates to UI
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void room_ConfigChanged(object sender, EventArgs e)
{
RefreshCurrentRoom(_CurrentRoom);
}
/// <summary> /// <summary>
/// For room on/off changes /// For room on/off changes

View File

@@ -155,7 +155,7 @@ namespace PepperDash.Essentials
get get
{ {
if (_TechDriver == null) if (_TechDriver == null)
_TechDriver = new PepperDash.Essentials.UIDrivers.EssentialsHuddleTechPageDriver(TriList, CurrentRoom.Config.Tech); _TechDriver = new PepperDash.Essentials.UIDrivers.EssentialsHuddleTechPageDriver(TriList, CurrentRoom.PropertiesConfig.Tech);
return _TechDriver; return _TechDriver;
} }
} }
@@ -235,9 +235,7 @@ namespace PepperDash.Essentials
return; return;
} }
var roomConf = CurrentRoom.Config; var roomConf = CurrentRoom.PropertiesConfig;
TriList.SetString(UIStringJoin.CurrentRoomName, CurrentRoom.Name);
if (Config.HeaderStyle.ToLower() == CrestronTouchpanelPropertiesConfig.Habanero) if (Config.HeaderStyle.ToLower() == CrestronTouchpanelPropertiesConfig.Habanero)
{ {
@@ -879,10 +877,9 @@ namespace PepperDash.Essentials
/// <summary> /// <summary>
/// Helper for property setter. Sets the panel to the given room, latching up all functionality /// Helper for property setter. Sets the panel to the given room, latching up all functionality
/// </summary> /// </summary>
void SetCurrentRoom(EssentialsHuddleVtc1Room room) void RefreshCurrentRoom(EssentialsHuddleVtc1Room room)
{ {
if (_CurrentRoom == room) return;
// Disconnect current (probably never called)
if (_CurrentRoom != null) if (_CurrentRoom != null)
{ {
// Disconnect current room // Disconnect current room
@@ -894,7 +891,7 @@ namespace PepperDash.Essentials
_CurrentRoom.ShutdownPromptTimer.HasFinished -= ShutdownPromptTimer_HasFinished; _CurrentRoom.ShutdownPromptTimer.HasFinished -= ShutdownPromptTimer_HasFinished;
_CurrentRoom.ShutdownPromptTimer.WasCancelled -= ShutdownPromptTimer_WasCancelled; _CurrentRoom.ShutdownPromptTimer.WasCancelled -= ShutdownPromptTimer_WasCancelled;
_CurrentRoom.OnFeedback.OutputChange += CurrentRoom_OnFeedback_OutputChange; _CurrentRoom.OnFeedback.OutputChange -= CurrentRoom_OnFeedback_OutputChange;
_CurrentRoom.IsWarmingUpFeedback.OutputChange -= CurrentRoom_IsWarmingFeedback_OutputChange; _CurrentRoom.IsWarmingUpFeedback.OutputChange -= CurrentRoom_IsWarmingFeedback_OutputChange;
_CurrentRoom.IsCoolingDownFeedback.OutputChange -= CurrentRoom_IsCoolingDownFeedback_OutputChange; _CurrentRoom.IsCoolingDownFeedback.OutputChange -= CurrentRoom_IsCoolingDownFeedback_OutputChange;
_CurrentRoom.InCallFeedback.OutputChange -= CurrentRoom_InCallFeedback_OutputChange; _CurrentRoom.InCallFeedback.OutputChange -= CurrentRoom_InCallFeedback_OutputChange;
@@ -952,6 +949,27 @@ namespace PepperDash.Essentials
} }
} }
void SetCurrentRoom(EssentialsHuddleVtc1Room room)
{
if (_CurrentRoom == room) return;
// Disconnect current (probably never called)
room.ConfigChanged -= room_ConfigChanged;
room.ConfigChanged += room_ConfigChanged;
RefreshCurrentRoom(room);
}
/// <summary>
/// Fires when room config of current room has changed. Meant to refresh room values to propegate any updates to UI
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void room_ConfigChanged(object sender, EventArgs e)
{
RefreshCurrentRoom(_CurrentRoom);
}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
@@ -1066,155 +1084,6 @@ namespace PepperDash.Essentials
TriList.StringInput[UIStringJoin.CallSharedSourceNameText].StringValue = callListSharedSourceLabel; TriList.StringInput[UIStringJoin.CallSharedSourceNameText].StringValue = callListSharedSourceLabel;
} }
///// <summary>
/////
///// </summary>
//void SetupHeaderButtons()
//{
// HeaderButtonsAreSetUp = false;
// TriList.SetBool(UIBoolJoin.TopBarHabaneroDynamicVisible, true);
// var roomConf = CurrentRoom.Config;
// // Gear
// TriList.SetString(UIStringJoin.HeaderButtonIcon5, "Gear");
// TriList.SetSigHeldAction(UIBoolJoin.HeaderIcon5Press, 2000,
// ShowTech,
// null,
// () =>
// {
// if (CurrentRoom.OnFeedback.BoolValue)
// PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.VolumesPageVisible);
// else
// PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.VolumesPagePowerOffVisible);
// });
// TriList.SetSigFalseAction(UIBoolJoin.TechExitButton, () =>
// PopupInterlock.HideAndClear());
// // Help button and popup
// if (CurrentRoom.Config.Help != null)
// {
// TriList.SetString(UIStringJoin.HelpMessage, roomConf.Help.Message);
// TriList.SetBool(UIBoolJoin.HelpPageShowCallButtonVisible, roomConf.Help.ShowCallButton);
// TriList.SetString(UIStringJoin.HelpPageCallButtonText, roomConf.Help.CallButtonText);
// if (roomConf.Help.ShowCallButton)
// TriList.SetSigFalseAction(UIBoolJoin.HelpPageShowCallButtonPress, () => { }); // ************ FILL IN
// else
// TriList.ClearBoolSigAction(UIBoolJoin.HelpPageShowCallButtonPress);
// }
// else // older config
// {
// TriList.SetString(UIStringJoin.HelpMessage, CurrentRoom.Config.HelpMessage);
// TriList.SetBool(UIBoolJoin.HelpPageShowCallButtonVisible, false);
// TriList.SetString(UIStringJoin.HelpPageCallButtonText, null);
// TriList.ClearBoolSigAction(UIBoolJoin.HelpPageShowCallButtonPress);
// }
// TriList.SetString(UIStringJoin.HeaderButtonIcon4, "Help");
// TriList.SetSigFalseAction(UIBoolJoin.HeaderIcon4Press, () =>
// {
// string message = null;
// var room = DeviceManager.GetDeviceForKey(Config.DefaultRoomKey)
// as EssentialsHuddleSpaceRoom;
// if (room != null)
// message = room.Config.HelpMessage;
// else
// message = "Sorry, no help message available. No room connected.";
// //TriList.StringInput[UIStringJoin.HelpMessage].StringValue = message;
// PopupInterlock.ShowInterlockedWithToggle(UIBoolJoin.HelpPageVisible);
// });
// uint nextJoin = 3953;
// // Calendar button
// if (_CurrentRoom.ScheduleSource != null)
// {
// TriList.SetString(nextJoin, "Calendar");
// TriList.SetSigFalseAction(nextJoin, CalendarPress);
// nextJoin--;
// }
// // Call button
// TriList.SetString(nextJoin, "DND");
// TriList.SetSigFalseAction(nextJoin, ShowActiveCallsList);
// HeaderCallButtonIconSig = TriList.StringInput[nextJoin];
// nextJoin--;
// // blank any that remain
// for (var i = nextJoin; i > 3950; i--)
// {
// TriList.SetString(i, "Blank");
// TriList.SetSigFalseAction(i, () => { });
// }
// TriList.SetSigFalseAction(UIBoolJoin.HeaderCallStatusLabelPress, ShowActiveCallsList);
// // Set Call Status Subpage Position
// if (nextJoin == 3951)
// {
// // Set to right position
// TriList.SetBool(UIBoolJoin.HeaderCallStatusLeftPositionVisible, false);
// TriList.SetBool(UIBoolJoin.HeaderCallStatusRightPositionVisible, true);
// }
// else if (nextJoin == 3950)
// {
// // Set to left position
// TriList.SetBool(UIBoolJoin.HeaderCallStatusLeftPositionVisible, true);
// TriList.SetBool(UIBoolJoin.HeaderCallStatusRightPositionVisible, false);
// }
// HeaderButtonsAreSetUp = true;
// ComputeHeaderCallStatus(CurrentRoom.VideoCodec);
//}
///// <summary>
///// Evaluates the call status and sets the icon mode and text label
///// </summary>
//public void ComputeHeaderCallStatus(VideoCodecBase codec)
//{
// if (codec == null)
// {
// Debug.Console(1, "ComputeHeaderCallStatus() cannot execute. codec is null");
// return;
// }
// if (HeaderCallButtonIconSig == null)
// {
// Debug.Console(1, "ComputeHeaderCallStatus() cannot execute. HeaderCallButtonIconSig is null");
// return;
// }
// // Set mode of header button
// if (!codec.IsInCall)
// {
// HeaderCallButtonIconSig.StringValue = "DND";
// //HeaderCallButton.SetIcon(HeaderListButton.OnHook);
// }
// else if (codec.ActiveCalls.Any(c => c.Type == eCodecCallType.Video))
// HeaderCallButtonIconSig.StringValue = "Misc-06_Dark";
// //HeaderCallButton.SetIcon(HeaderListButton.Camera);
// //TriList.SetUshort(UIUshortJoin.CallHeaderButtonMode, 2);
// else
// HeaderCallButtonIconSig.StringValue = "Misc-09_Dark";
// //HeaderCallButton.SetIcon(HeaderListButton.Phone);
// //TriList.SetUshort(UIUshortJoin.CallHeaderButtonMode, 1);
// // Set the call status text
// if (codec.ActiveCalls.Count > 0)
// {
// if (codec.ActiveCalls.Count == 1)
// TriList.SetString(UIStringJoin.HeaderCallStatusLabel, "1 Active Call");
// else if (codec.ActiveCalls.Count > 1)
// TriList.SetString(UIStringJoin.HeaderCallStatusLabel, string.Format("{0} Active Calls", codec.ActiveCalls.Count));
// }
// else
// TriList.SetString(UIStringJoin.HeaderCallStatusLabel, "No Active Calls");
//}
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>

View File

@@ -484,9 +484,9 @@ namespace PepperDash.Essentials.UIDrivers.VC
TriList.SetString(timeTextOffset + i, timeText); TriList.SetString(timeTextOffset + i, timeText);
string iconName = null; string iconName = null;
if (c.OccurenceType == eCodecOccurrenceType.Received) if (c.OccurrenceType == eCodecOccurrenceType.Received)
iconName = "Misc-18_Light"; iconName = "Misc-18_Light";
else if (c.OccurenceType == eCodecOccurrenceType.Placed) else if (c.OccurrenceType == eCodecOccurrenceType.Placed)
iconName = "Misc-17_Light"; iconName = "Misc-17_Light";
else else
iconName = "Delete"; iconName = "Delete";