mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 20:54:55 +00:00
DDVC bridge
This commit is contained in:
@@ -23,6 +23,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class SourceListItem
|
public class SourceListItem
|
||||||
{
|
{
|
||||||
|
[JsonProperty("sourceKey")]
|
||||||
public string SourceKey { get; set; }
|
public string SourceKey { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the source Device for this, if it exists in DeviceManager
|
/// Returns the source Device for this, if it exists in DeviceManager
|
||||||
@@ -43,6 +44,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// Gets either the source's Name or this AlternateName property, if
|
/// Gets either the source's Name or this AlternateName property, if
|
||||||
/// defined. If source doesn't exist, returns "Missing source"
|
/// defined. If source doesn't exist, returns "Missing source"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonProperty("preferredName")]
|
||||||
public string PreferredName
|
public string PreferredName
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -60,15 +62,34 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A name that will override the source's name on the UI
|
/// A name that will override the source's name on the UI
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[JsonProperty("name")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("icon")]
|
||||||
public string Icon { get; set; }
|
public string Icon { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("altIcon")]
|
||||||
public string AltIcon { get; set; }
|
public string AltIcon { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("includeInSourceList")]
|
||||||
public bool IncludeInSourceList { get; set; }
|
public bool IncludeInSourceList { get; set; }
|
||||||
public int Order { get; set; }
|
|
||||||
|
[JsonProperty("order")]
|
||||||
|
public int Order { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("volumeControlKey")]
|
||||||
public string VolumeControlKey { get; set; }
|
public string VolumeControlKey { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("type")]
|
||||||
public eSourceListItemType Type { get; set; }
|
public eSourceListItemType Type { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("routeList")]
|
||||||
public List<SourceRouteListItem> RouteList { get; set; }
|
public List<SourceRouteListItem> RouteList { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("disableCodecSharing")]
|
||||||
public bool DisableCodecSharing { get; set; }
|
public bool DisableCodecSharing { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("disableRoutedSharing")]
|
||||||
public bool DisableRoutedSharing { get; set; }
|
public bool DisableRoutedSharing { get; set; }
|
||||||
|
|
||||||
public SourceListItem()
|
public SourceListItem()
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ namespace PepperDash.Essentials
|
|||||||
}
|
}
|
||||||
Debug.Console(0, bridge, "Linking to parent controller");
|
Debug.Console(0, bridge, "Linking to parent controller");
|
||||||
bridge.AddParent(parent);
|
bridge.AddParent(parent);
|
||||||
parent.CotijaRooms.Add(bridge);
|
parent.AddBridge(bridge);
|
||||||
});
|
});
|
||||||
|
|
||||||
return bridge;
|
return bridge;
|
||||||
|
|||||||
@@ -283,7 +283,7 @@ namespace PepperDash.Essentials
|
|||||||
}
|
}
|
||||||
Debug.Console(0, bridge, "Linking to parent controller");
|
Debug.Console(0, bridge, "Linking to parent controller");
|
||||||
bridge.AddParent(parent);
|
bridge.AddParent(parent);
|
||||||
parent.CotijaRooms.Add(bridge);
|
parent.AddBridge(bridge);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,19 +4,27 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Room.Config
|
namespace PepperDash.Essentials.Room.Config
|
||||||
{
|
{
|
||||||
public class DDVC01RoomPropertiesConfig : EssentialsHuddleVtc1PropertiesConfig
|
public class DDVC01RoomPropertiesConfig : EssentialsHuddleVtc1PropertiesConfig
|
||||||
{
|
{
|
||||||
|
[JsonProperty("roomPhoneNumber")]
|
||||||
public string RoomPhoneNumber { get; set; }
|
public string RoomPhoneNumber { get; set; }
|
||||||
|
[JsonProperty("roomURI")]
|
||||||
public string RoomURI { get; set; }
|
public string RoomURI { get; set; }
|
||||||
|
[JsonProperty("speedDials")]
|
||||||
public List<DDVC01SpeedDial> SpeedDials { get; set; }
|
public List<DDVC01SpeedDial> SpeedDials { get; set; }
|
||||||
|
[JsonProperty("volumeSliderNames")]
|
||||||
public List<string> VolumeSliderNames { get; set; }
|
public List<string> VolumeSliderNames { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DDVC01SpeedDial
|
public class DDVC01SpeedDial
|
||||||
{
|
{
|
||||||
|
[JsonProperty("name")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
[JsonProperty("number")]
|
||||||
public string Number { get; set; }
|
public string Number { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,16 +3,22 @@ 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;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Room.Config
|
namespace PepperDash.Essentials.Room.Config
|
||||||
{
|
{
|
||||||
|
|
||||||
public class EssentialsHuddleVtc1PropertiesConfig : EssentialsRoomPropertiesConfig
|
public class EssentialsHuddleVtc1PropertiesConfig : EssentialsRoomPropertiesConfig
|
||||||
{
|
{
|
||||||
public string DefaultDisplayKey { get; set; }
|
[JsonProperty("defaultDisplayKey")]
|
||||||
public string DefaultAudioKey { get; set; }
|
public string DefaultDisplayKey { get; set; }
|
||||||
public string SourceListKey { get; set; }
|
[JsonProperty("defaultAudioKey")]
|
||||||
public string DefaultSourceItem { get; set; }
|
public string DefaultAudioKey { get; set; }
|
||||||
public string VideoCodecKey { get; set; }
|
[JsonProperty("sourceListKey")]
|
||||||
|
public string SourceListKey { get; set; }
|
||||||
|
[JsonProperty("defaultSourceItem")]
|
||||||
|
public string DefaultSourceItem { get; set; }
|
||||||
|
[JsonProperty("videoCodecKey")]
|
||||||
|
public string VideoCodecKey { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,26 +179,56 @@ namespace PepperDash.Essentials.Room.Config
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class EssentialsRoomPropertiesConfig
|
public class EssentialsRoomPropertiesConfig
|
||||||
{
|
{
|
||||||
public EssentialsRoomEmergencyConfig Emergency { get; set; }
|
[JsonProperty("emergency")]
|
||||||
public EssentialsRoomMicrophonePrivacyConfig MicrophonePrivacy {get; set;}
|
public EssentialsRoomEmergencyConfig Emergency { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("microphonePrivacy")]
|
||||||
|
public EssentialsRoomMicrophonePrivacyConfig MicrophonePrivacy { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("helpMessage")]
|
||||||
public string HelpMessage { get; set; }
|
public string HelpMessage { get; set; }
|
||||||
public string Description { get; set; }
|
|
||||||
public int ShutdownVacancySeconds { get; set; }
|
[JsonProperty("description")]
|
||||||
public int ShutdownPromptSeconds { get; set; }
|
public string Description { get; set; }
|
||||||
public EssentialsHelpPropertiesConfig Help { get; set; }
|
|
||||||
public EssentialsOneButtonMeetingPropertiesConfig OneButtonMeeting { get; set; }
|
[JsonProperty("shutdownVacancySeconds")]
|
||||||
public EssentialsRoomAddressPropertiesConfig Addresses { get; set; }
|
public int ShutdownVacancySeconds { get; set; }
|
||||||
public EssentialsRoomOccSensorConfig Occupancy { get; set; }
|
|
||||||
public EssentialsLogoPropertiesConfig Logo { get; set; }
|
[JsonProperty("shutdownPromptSeconds")]
|
||||||
|
public int ShutdownPromptSeconds { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("help")]
|
||||||
|
public EssentialsHelpPropertiesConfig Help { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("oneButtonMeeting")]
|
||||||
|
public EssentialsOneButtonMeetingPropertiesConfig OneButtonMeeting { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("addresses")]
|
||||||
|
public EssentialsRoomAddressPropertiesConfig Addresses { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("occupancy")]
|
||||||
|
public EssentialsRoomOccSensorConfig Occupancy { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("logo")]
|
||||||
|
public EssentialsLogoPropertiesConfig Logo { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("tech")]
|
||||||
public EssentialsRoomTechConfig Tech { get; set; }
|
public EssentialsRoomTechConfig Tech { get; set; }
|
||||||
public EssentialsRoomVolumesConfig Volumes { get; set; }
|
|
||||||
|
[JsonProperty("volumes")]
|
||||||
|
public EssentialsRoomVolumesConfig Volumes { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("zeroVolumeWhenSwtichingVolumeDevices")]
|
||||||
public bool ZeroVolumeWhenSwtichingVolumeDevices { get; set; }
|
public bool ZeroVolumeWhenSwtichingVolumeDevices { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EssentialsRoomMicrophonePrivacyConfig
|
public class EssentialsRoomMicrophonePrivacyConfig
|
||||||
{
|
{
|
||||||
public string DeviceKey { get; set; }
|
[JsonProperty("deviceKey")]
|
||||||
public string Behaviour { get; set; }
|
public string DeviceKey { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("behaviour")]
|
||||||
|
public string Behaviour { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -206,12 +236,17 @@ namespace PepperDash.Essentials.Room.Config
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class EssentialsHelpPropertiesConfig
|
public class EssentialsHelpPropertiesConfig
|
||||||
{
|
{
|
||||||
public string Message { get; set; }
|
[JsonProperty("message")]
|
||||||
public bool ShowCallButton { get; set; }
|
public string Message { get; set; }
|
||||||
/// <summary>
|
|
||||||
|
[JsonProperty("showCallButton")]
|
||||||
|
public bool ShowCallButton { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
/// Defaults to "Call Help Desk"
|
/// Defaults to "Call Help Desk"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string CallButtonText { get; set; }
|
[JsonProperty("callButtonText")]
|
||||||
|
public string CallButtonText { get; set; }
|
||||||
|
|
||||||
public EssentialsHelpPropertiesConfig()
|
public EssentialsHelpPropertiesConfig()
|
||||||
{
|
{
|
||||||
@@ -224,13 +259,17 @@ namespace PepperDash.Essentials.Room.Config
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class EssentialsOneButtonMeetingPropertiesConfig
|
public class EssentialsOneButtonMeetingPropertiesConfig
|
||||||
{
|
{
|
||||||
public bool Enable { get; set; }
|
[JsonProperty("enable")]
|
||||||
|
public bool Enable { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EssentialsRoomAddressPropertiesConfig
|
public class EssentialsRoomAddressPropertiesConfig
|
||||||
{
|
{
|
||||||
public string PhoneNumber { get; set; }
|
[JsonProperty("phoneNumber")]
|
||||||
public string SipAddress { get; set; }
|
public string PhoneNumber { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("sipAddress")]
|
||||||
|
public string SipAddress { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -239,8 +278,11 @@ namespace PepperDash.Essentials.Room.Config
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class EssentialsLogoPropertiesConfig
|
public class EssentialsLogoPropertiesConfig
|
||||||
{
|
{
|
||||||
public string Type { get; set; }
|
[JsonProperty("type")]
|
||||||
public string Url { get; set; }
|
public string Type { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("url")]
|
||||||
|
public string Url { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets either the custom URL, a local-to-processor URL, or null if it's a default logo
|
/// Gets either the custom URL, a local-to-processor URL, or null if it's a default logo
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -260,13 +302,16 @@ namespace PepperDash.Essentials.Room.Config
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class EssentialsRoomOccSensorConfig
|
public class EssentialsRoomOccSensorConfig
|
||||||
{
|
{
|
||||||
public string DeviceKey { get; set; }
|
[JsonProperty("deviceKey")]
|
||||||
public int TimoutMinutes { get; set; }
|
public string DeviceKey { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("timoutMinutes")]
|
||||||
|
public int TimoutMinutes { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class EssentialsRoomTechConfig
|
public class EssentialsRoomTechConfig
|
||||||
{
|
{
|
||||||
|
[JsonProperty("password")]
|
||||||
public string Password { get; set; }
|
public string Password { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -10,8 +10,10 @@ using Crestron.SimplSharpPro;
|
|||||||
using Crestron.SimplSharp.Net.Http;
|
using Crestron.SimplSharp.Net.Http;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
|
using PepperDash.Essentials.Room.Cotija;
|
||||||
|
|
||||||
namespace PepperDash.Essentials
|
namespace PepperDash.Essentials
|
||||||
{
|
{
|
||||||
@@ -19,8 +21,6 @@ namespace PepperDash.Essentials
|
|||||||
{
|
{
|
||||||
GenericHttpSseClient SseClient;
|
GenericHttpSseClient SseClient;
|
||||||
|
|
||||||
//CCriticalSection FileLock;
|
|
||||||
|
|
||||||
/// <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>
|
||||||
@@ -44,7 +44,7 @@ namespace PepperDash.Essentials
|
|||||||
|
|
||||||
string SystemUuid;
|
string SystemUuid;
|
||||||
|
|
||||||
public List<CotijaBridgeBase> CotijaRooms { get; private set; }
|
List<CotijaBridgeBase> RoomBridges = new List<CotijaBridgeBase>();
|
||||||
|
|
||||||
long ButtonHeartbeatInterval = 1000;
|
long ButtonHeartbeatInterval = 1000;
|
||||||
|
|
||||||
@@ -54,23 +54,24 @@ namespace PepperDash.Essentials
|
|||||||
/// Used to count retries in PostToServer
|
/// Used to count retries in PostToServer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
int RetryCounter;
|
int RetryCounter;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key"></param>
|
||||||
|
/// <param name="name"></param>
|
||||||
|
/// <param name="config"></param>
|
||||||
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;
|
||||||
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);
|
||||||
|
|
||||||
CotijaRooms = new List<CotijaBridgeBase>();
|
|
||||||
|
|
||||||
//CrestronConsole.AddNewConsoleCommand(s => RegisterSystemToServer(),
|
|
||||||
// "CotiInitializeHttpClient", "Initializes a new HTTP client connection to a specified URL", ConsoleAccessLevelEnum.AccessOperator);
|
|
||||||
CrestronConsole.AddNewConsoleCommand(DisconnectSseClient,
|
CrestronConsole.AddNewConsoleCommand(DisconnectSseClient,
|
||||||
"CloseHttpClient", "Closes the active HTTP client", ConsoleAccessLevelEnum.AccessOperator);
|
"CloseHttpClient", "Closes the active HTTP client", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
CrestronConsole.AddNewConsoleCommand(AuthorizeSystem,
|
CrestronConsole.AddNewConsoleCommand(AuthorizeSystem,
|
||||||
"cotijaauth", "Authorizes system to talk to cotija server", ConsoleAccessLevelEnum.AccessOperator);
|
"cotijaauth", "Authorizes system to talk to cotija server", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
AddPostActivationAction(() => RegisterSystemToServer());
|
//AddPostActivationAction(() => RegisterSystemToServer());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -100,6 +101,40 @@ namespace PepperDash.Essentials
|
|||||||
ActionDictionary.Remove(key);
|
ActionDictionary.Remove(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bridge"></param>
|
||||||
|
public void AddBridge(CotijaBridgeBase bridge)
|
||||||
|
{
|
||||||
|
RoomBridges.Add(bridge);
|
||||||
|
var b = bridge as IDelayedConfiguration;
|
||||||
|
if (b != null)
|
||||||
|
{
|
||||||
|
b.ConfigurationIsReady += new EventHandler<EventArgs>(bridge_ConfigurationIsReady);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RegisterSystemToServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
void bridge_ConfigurationIsReady(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "Bridge ready. Registering");
|
||||||
|
// send the configuration object to the server
|
||||||
|
RegisterSystemToServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="o"></param>
|
||||||
void ReconnectToServerTimerCallback(object o)
|
void ReconnectToServerTimerCallback(object o)
|
||||||
{
|
{
|
||||||
RegisterSystemToServer();
|
RegisterSystemToServer();
|
||||||
@@ -153,42 +188,19 @@ 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()
|
||||||
{
|
{
|
||||||
#warning THIS SHOULD NOT GO until the config is ready - in cases of config populated from elsewhere (DDVC)
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
string filePath = string.Format(@"\NVRAM\Program{0}\configurationFile.json", Global.ControlSystem.ProgramNumber);
|
|
||||||
var confObject = ConfigReader.ConfigObject;
|
var confObject = ConfigReader.ConfigObject;
|
||||||
string postBody = JsonConvert.SerializeObject(confObject);
|
string postBody = JsonConvert.SerializeObject(confObject);
|
||||||
SystemUuid = confObject.SystemUuid;
|
SystemUuid = confObject.SystemUuid;
|
||||||
|
|
||||||
//if (string.IsNullOrEmpty(filePath))
|
|
||||||
//{
|
|
||||||
// Debug.Console(0, this, "Error reading file. No path specified.");
|
|
||||||
// return;
|
|
||||||
//}
|
|
||||||
|
|
||||||
// FileLock = new CCriticalSection();
|
|
||||||
//#warning NEIL I think we need to review this usage. Don't think it ever blocks
|
|
||||||
|
|
||||||
// if (FileLock.TryEnter())
|
|
||||||
// {
|
|
||||||
// Debug.Console(1, this, "Reading configuration file to extract system UUID...");
|
|
||||||
|
|
||||||
// postBody = File.ReadToEnd(filePath, Encoding.ASCII);
|
|
||||||
|
|
||||||
// Debug.Console(2, this, "{0}", postBody);
|
|
||||||
|
|
||||||
// FileLock.Leave();
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(postBody))
|
if (string.IsNullOrEmpty(postBody))
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "ERROR: Config post body is empty. Cannot register with server.");
|
Debug.Console(1, this, "ERROR: Config post body is empty. Cannot register with server.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(Client == null || NeedNewClient)
|
Client = new HttpClient();
|
||||||
Client = new HttpClient();
|
|
||||||
Client.Verbose = true;
|
Client.Verbose = true;
|
||||||
Client.KeepAlive = true;
|
Client.KeepAlive = true;
|
||||||
|
|
||||||
@@ -221,6 +233,11 @@ namespace PepperDash.Essentials
|
|||||||
{
|
{
|
||||||
CrestronInvoke.BeginInvoke(oo =>
|
CrestronInvoke.BeginInvoke(oo =>
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(SystemUuid))
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "Status post attempt before UUID is set. Ignoring.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
var ready = PostLockEvent.Wait(2000);
|
var ready = PostLockEvent.Wait(2000);
|
||||||
if (!ready)
|
if (!ready)
|
||||||
{
|
{
|
||||||
@@ -546,9 +563,7 @@ namespace PepperDash.Essentials
|
|||||||
{
|
{
|
||||||
Debug.Console(1, this, "-- Warning: Incoming message has no registered handler");
|
Debug.Console(1, this, "-- Warning: Incoming message has no registered handler");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception err)
|
catch (Exception err)
|
||||||
{
|
{
|
||||||
@@ -557,6 +572,4 @@ namespace PepperDash.Essentials
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -21,7 +21,7 @@ namespace PepperDash.Essentials.Room.Cotija
|
|||||||
public class BoolJoin
|
public class BoolJoin
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 2
|
/// 301
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const uint RoomIsOn = 301;
|
public const uint RoomIsOn = 301;
|
||||||
|
|
||||||
@@ -39,11 +39,11 @@ namespace PepperDash.Essentials.Room.Cotija
|
|||||||
public const uint ActivityVideoCallPress = 53;
|
public const uint ActivityVideoCallPress = 53;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 4
|
/// 1
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const uint MasterVolumeIsMuted = 1;
|
public const uint MasterVolumeIsMuted = 1;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 4
|
/// 1
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const uint MasterVolumeMuteToggle = 1;
|
public const uint MasterVolumeMuteToggle = 1;
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ namespace PepperDash.Essentials.Room.Cotija
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 71
|
/// 72
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const uint SourceHasChanged = 72;
|
public const uint SourceHasChanged = 72;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -75,19 +75,22 @@ namespace PepperDash.Essentials.Room.Cotija
|
|||||||
public class UshortJoin
|
public class UshortJoin
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// 1
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const uint MasterVolumeLevel = 1;
|
public const uint MasterVolumeLevel = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 61
|
||||||
|
/// </summary>
|
||||||
public const uint ShutdownPromptDuration = 61;
|
public const uint ShutdownPromptDuration = 61;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class StringJoin
|
public class StringJoin
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
/// 71
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const uint SelectedSourceKey = 3;
|
public const uint SelectedSourceKey = 71;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 501
|
/// 501
|
||||||
@@ -112,7 +115,7 @@ namespace PepperDash.Essentials.Room.Cotija
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fires when the config is ready, to be used by the controller class to forward config to server
|
/// Fires when config is ready to go
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public event EventHandler<EventArgs> ConfigurationIsReady;
|
public event EventHandler<EventArgs> ConfigurationIsReady;
|
||||||
|
|
||||||
@@ -153,17 +156,49 @@ namespace PepperDash.Essentials.Room.Cotija
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public override bool CustomActivate()
|
public override bool CustomActivate()
|
||||||
{
|
{
|
||||||
|
Debug.Console(0, this, "Final activation. Setting up actions and feedbacks");
|
||||||
SetupFunctions();
|
SetupFunctions();
|
||||||
SetupFeedbacks();
|
SetupFeedbacks();
|
||||||
|
|
||||||
|
|
||||||
|
//**** RE-ADD THESE WHEN IT MAKES SENSE
|
||||||
|
|
||||||
EISC.SigChange += EISC_SigChange;
|
EISC.SigChange += EISC_SigChange;
|
||||||
EISC.OnlineStatusChange += (o, a) =>
|
EISC.OnlineStatusChange += (o, a) =>
|
||||||
{
|
{
|
||||||
if (a.DeviceOnLine)
|
Debug.Console(1, this, "DDVC EISC online={0}. Config is ready={1}", a.DeviceOnLine, EISC.BooleanOutput[BoolJoin.ConfigIsReady].BoolValue);
|
||||||
|
if (a.DeviceOnLine && EISC.BooleanOutput[BoolJoin.ConfigIsReady].BoolValue)
|
||||||
LoadConfigValues();
|
LoadConfigValues();
|
||||||
};
|
};
|
||||||
// load config if it's already there
|
// load config if it's already there
|
||||||
if (EISC.IsOnline) // || EISC.BooleanInput[BoolJoin.ConfigIsReady].BoolValue)
|
if (EISC.IsOnline && EISC.BooleanOutput[BoolJoin.ConfigIsReady].BoolValue) // || EISC.BooleanInput[BoolJoin.ConfigIsReady].BoolValue)
|
||||||
LoadConfigValues();
|
LoadConfigValues();
|
||||||
|
|
||||||
|
|
||||||
|
CrestronConsole.AddNewConsoleCommand(s =>
|
||||||
|
{
|
||||||
|
for (uint i = 1; i < 1000; i++)
|
||||||
|
{
|
||||||
|
if (s.ToLower().Equals("b"))
|
||||||
|
{
|
||||||
|
CrestronConsole.ConsoleCommandResponse("D{0,6} {1} - ", i, EISC.BooleanOutput[i].BoolValue);
|
||||||
|
}
|
||||||
|
else if (s.ToLower().Equals("u"))
|
||||||
|
{
|
||||||
|
CrestronConsole.ConsoleCommandResponse("U{0,6} {1,8} - ", i, EISC.UShortOutput[i].UShortValue);
|
||||||
|
}
|
||||||
|
else if (s.ToLower().Equals("s"))
|
||||||
|
{
|
||||||
|
var val = EISC.StringOutput[i].StringValue;
|
||||||
|
if(!string.IsNullOrEmpty(val))
|
||||||
|
CrestronConsole.ConsoleCommandResponse("S{0,6} {1}\r", i, EISC.StringOutput[i].StringValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}, "cotijabridgedump", "Dumps DDVC01 bridge EISC data b,u,s", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
|
CrestronConsole.AddNewConsoleCommand(s => LoadConfigValues(), "loadddvc", "", ConsoleAccessLevelEnum.AccessOperator);
|
||||||
|
|
||||||
return base.CustomActivate();
|
return base.CustomActivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -173,6 +208,7 @@ namespace PepperDash.Essentials.Room.Cotija
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
void SetupFunctions()
|
void SetupFunctions()
|
||||||
{
|
{
|
||||||
|
|
||||||
Parent.AddAction(@"/room/room1/status", new Action(SendFullStatus));
|
Parent.AddAction(@"/room/room1/status", new Action(SendFullStatus));
|
||||||
|
|
||||||
Parent.AddAction(@"/room/room1/source", new Action<SourceSelectMessageContent>(c =>
|
Parent.AddAction(@"/room/room1/source", new Action<SourceSelectMessageContent>(c =>
|
||||||
@@ -181,7 +217,8 @@ namespace PepperDash.Essentials.Room.Cotija
|
|||||||
EISC.PulseBool(BoolJoin.SourceHasChanged);
|
EISC.PulseBool(BoolJoin.SourceHasChanged);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
Parent.AddAction(@"/room/room1/activityshare", new Action(() =>
|
#warning CHANGE to activityshare. Perhaps
|
||||||
|
Parent.AddAction(@"/room/room1/defaultsource", new Action(() =>
|
||||||
EISC.PulseBool(BoolJoin.ActivitySharePress)));
|
EISC.PulseBool(BoolJoin.ActivitySharePress)));
|
||||||
|
|
||||||
Parent.AddAction(@"/room/room1/masterVolumeLevel", new Action<ushort>(u =>
|
Parent.AddAction(@"/room/room1/masterVolumeLevel", new Action<ushort>(u =>
|
||||||
@@ -231,17 +268,17 @@ namespace PepperDash.Essentials.Room.Cotija
|
|||||||
|
|
||||||
// shutdown things
|
// shutdown things
|
||||||
EISC.SetSigTrueAction(BoolJoin.ShutdownCancel, new Action(() =>
|
EISC.SetSigTrueAction(BoolJoin.ShutdownCancel, new Action(() =>
|
||||||
PostStatusMessage(new
|
PostMessage("/room/shutdown/", new
|
||||||
{
|
{
|
||||||
state = "wasCancelled"
|
state = "wasCancelled"
|
||||||
})));
|
})));
|
||||||
EISC.SetSigTrueAction(BoolJoin.ShutdownEnd, new Action(() =>
|
EISC.SetSigTrueAction(BoolJoin.ShutdownEnd, new Action(() =>
|
||||||
PostStatusMessage(new
|
PostMessage("/room/shutdown/", new
|
||||||
{
|
{
|
||||||
state = "hasFinished"
|
state = "hasFinished"
|
||||||
})));
|
})));
|
||||||
EISC.SetSigTrueAction(BoolJoin.ShutdownStart, new Action(() =>
|
EISC.SetSigTrueAction(BoolJoin.ShutdownStart, new Action(() =>
|
||||||
PostStatusMessage(new
|
PostMessage("/room/shutdown/", new
|
||||||
{
|
{
|
||||||
state = "hasStarted",
|
state = "hasStarted",
|
||||||
duration = EISC.UShortOutput[UshortJoin.ShutdownPromptDuration].UShortValue
|
duration = EISC.UShortOutput[UshortJoin.ShutdownPromptDuration].UShortValue
|
||||||
@@ -256,7 +293,6 @@ namespace PepperDash.Essentials.Room.Cotija
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
void LoadConfigValues()
|
void LoadConfigValues()
|
||||||
{
|
{
|
||||||
|
|
||||||
Debug.Console(1, this, "Loading configuration from DDVC01 EISC bridge");
|
Debug.Console(1, this, "Loading configuration from DDVC01 EISC bridge");
|
||||||
ConfigIsLoaded = false;
|
ConfigIsLoaded = false;
|
||||||
|
|
||||||
@@ -265,10 +301,13 @@ namespace PepperDash.Essentials.Room.Cotija
|
|||||||
//Room
|
//Room
|
||||||
if (co.Rooms == null)
|
if (co.Rooms == null)
|
||||||
co.Rooms = new List<EssentialsRoomConfig>();
|
co.Rooms = new List<EssentialsRoomConfig>();
|
||||||
|
var rm = new EssentialsRoomConfig();
|
||||||
if (co.Rooms.Count == 0)
|
if (co.Rooms.Count == 0)
|
||||||
co.Rooms.Add(new EssentialsRoomConfig());
|
{
|
||||||
var rm = co.Rooms[0];
|
Debug.Console(0, this, "Adding room to config");
|
||||||
rm.Name = EISC.StringInput[501].StringValue;
|
co.Rooms.Add(rm);
|
||||||
|
}
|
||||||
|
rm.Name = EISC.StringOutput[501].StringValue;
|
||||||
rm.Key = "room1";
|
rm.Key = "room1";
|
||||||
rm.Type = "ddvc01";
|
rm.Type = "ddvc01";
|
||||||
|
|
||||||
@@ -279,22 +318,22 @@ namespace PepperDash.Essentials.Room.Cotija
|
|||||||
rmProps = JsonConvert.DeserializeObject<DDVC01RoomPropertiesConfig>(rm.Properties.ToString());
|
rmProps = JsonConvert.DeserializeObject<DDVC01RoomPropertiesConfig>(rm.Properties.ToString());
|
||||||
|
|
||||||
rmProps.Help = new EssentialsHelpPropertiesConfig();
|
rmProps.Help = new EssentialsHelpPropertiesConfig();
|
||||||
rmProps.Help.Message = EISC.StringInput[502].StringValue;
|
rmProps.Help.Message = EISC.StringOutput[502].StringValue;
|
||||||
rmProps.Help.CallButtonText = EISC.StringInput[503].StringValue;
|
rmProps.Help.CallButtonText = EISC.StringOutput[503].StringValue;
|
||||||
rmProps.RoomPhoneNumber = EISC.StringInput[504].StringValue;
|
rmProps.RoomPhoneNumber = EISC.StringOutput[504].StringValue;
|
||||||
rmProps.RoomURI = EISC.StringInput[505].StringValue;
|
rmProps.RoomURI = EISC.StringOutput[505].StringValue;
|
||||||
rmProps.SpeedDials = new List<DDVC01SpeedDial>();
|
rmProps.SpeedDials = new List<DDVC01SpeedDial>();
|
||||||
// add speed dials as long as there are more - up to 4
|
// add speed dials as long as there are more - up to 4
|
||||||
for (uint i = 512; i <= 519; i = i + 2)
|
for (uint i = 512; i <= 519; i = i + 2)
|
||||||
{
|
{
|
||||||
var num = EISC.StringInput[i].StringValue;
|
var num = EISC.StringOutput[i].StringValue;
|
||||||
if (string.IsNullOrEmpty(num))
|
if (string.IsNullOrEmpty(num))
|
||||||
break;
|
break;
|
||||||
var name = EISC.StringInput[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});
|
||||||
}
|
}
|
||||||
// volume control names
|
// volume control names
|
||||||
var volCount = EISC.UShortInput[701].UShortValue;
|
var volCount = EISC.UShortOutput[701].UShortValue;
|
||||||
rmProps.VolumeSliderNames = new List<string>();
|
rmProps.VolumeSliderNames = new List<string>();
|
||||||
for(uint i = 701; i <= 700 + volCount; i++)
|
for(uint i = 701; i <= 700 + volCount; i++)
|
||||||
{
|
{
|
||||||
@@ -305,29 +344,43 @@ namespace PepperDash.Essentials.Room.Cotija
|
|||||||
if(co.Devices == null)
|
if(co.Devices == null)
|
||||||
co.Devices = new List<DeviceConfig>();
|
co.Devices = new List<DeviceConfig>();
|
||||||
|
|
||||||
// Source list! This might be brutal!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
||||||
rmProps.SourceListKey = "default";
|
rmProps.SourceListKey = "default";
|
||||||
|
rm.Properties = JToken.FromObject(rmProps);
|
||||||
|
|
||||||
|
// Source list! This might be brutal!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
|
|
||||||
|
var groupMap = GetSourceGroupDictionary();
|
||||||
|
|
||||||
co.SourceLists = new Dictionary<string,Dictionary<string,SourceListItem>>();
|
co.SourceLists = new Dictionary<string,Dictionary<string,SourceListItem>>();
|
||||||
var newSl = new Dictionary<string, SourceListItem>();
|
var newSl = new Dictionary<string, SourceListItem>();
|
||||||
// add sources...
|
// add sources...
|
||||||
for (uint i = 0; i<= 19; i++)
|
for (uint i = 0; i<= 19; i++)
|
||||||
{
|
{
|
||||||
var name = EISC.StringInput[601 + i].StringValue;
|
var name = EISC.StringOutput[601 + i].StringValue;
|
||||||
if(string.IsNullOrEmpty(name))
|
if(string.IsNullOrEmpty(name))
|
||||||
break;
|
break;
|
||||||
var icon = EISC.StringInput[651 + i].StringValue;
|
var icon = EISC.StringOutput[651 + i].StringValue;
|
||||||
var key = EISC.StringInput[671 + i].StringValue;
|
var key = EISC.StringOutput[671 + i].StringValue;
|
||||||
var type = EISC.StringInput[701 + i].StringValue;
|
var type = EISC.StringOutput[701 + i].StringValue;
|
||||||
|
|
||||||
|
Debug.Console(0, this, "Adding source {0} '{1}'", key, name);
|
||||||
var newSLI = new SourceListItem{
|
var newSLI = new SourceListItem{
|
||||||
Icon = icon,
|
Icon = icon,
|
||||||
Name = name,
|
Name = name,
|
||||||
Order = (int)i + 1,
|
Order = (int)i + 1,
|
||||||
SourceKey = key,
|
SourceKey = key,
|
||||||
};
|
};
|
||||||
|
newSl.Add(key, newSLI);
|
||||||
|
|
||||||
|
string group = "genericsource";
|
||||||
|
if (groupMap.ContainsKey(type))
|
||||||
|
{
|
||||||
|
group = groupMap[type];
|
||||||
|
}
|
||||||
|
|
||||||
// add dev to devices list
|
// add dev to devices list
|
||||||
var devConf = new DeviceConfig {
|
var devConf = new DeviceConfig {
|
||||||
Group = "ddvc01",
|
Group = group,
|
||||||
Key = key,
|
Key = key,
|
||||||
Name = name,
|
Name = name,
|
||||||
Type = type
|
Type = type
|
||||||
@@ -339,9 +392,13 @@ namespace PepperDash.Essentials.Room.Cotija
|
|||||||
|
|
||||||
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));
|
||||||
|
|
||||||
ConfigIsLoaded = true;
|
var handler = ConfigurationIsReady;
|
||||||
|
if (handler != null)
|
||||||
|
{
|
||||||
|
handler(this, new EventArgs());
|
||||||
|
}
|
||||||
|
|
||||||
// send config changed status???
|
ConfigIsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendFullStatus()
|
void SendFullStatus()
|
||||||
@@ -380,6 +437,20 @@ namespace PepperDash.Essentials.Room.Cotija
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="messageType"></param>
|
||||||
|
/// <param name="contentObject"></param>
|
||||||
|
void PostMessage(string messageType, object contentObject)
|
||||||
|
{
|
||||||
|
Parent.PostToServer(JObject.FromObject(new
|
||||||
|
{
|
||||||
|
type = messageType,
|
||||||
|
content = contentObject
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
@@ -398,5 +469,23 @@ namespace PepperDash.Essentials.Room.Cotija
|
|||||||
else if (uo is Action<string>)
|
else if (uo is Action<string>)
|
||||||
(uo as Action<string>)(args.Sig.StringValue);
|
(uo as Action<string>)(args.Sig.StringValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the mapping of types to groups, for setting up devices.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
Dictionary<string, string> GetSourceGroupDictionary()
|
||||||
|
{
|
||||||
|
//type, group
|
||||||
|
var d = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
|
||||||
|
{
|
||||||
|
{ "laptop", "pc" },
|
||||||
|
{ "wireless", "genericsource" },
|
||||||
|
{ "iptv", "settopbox" }
|
||||||
|
|
||||||
|
};
|
||||||
|
return d;
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user