mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-09 01:35:02 +00:00
Preparing DDVCO1 cotija bridge to send configuration - incomplete
This commit is contained in:
@@ -22,7 +22,7 @@ namespace PepperDash.Essentials
|
||||
[JsonProperty("template_url")]
|
||||
public string TemplateUrl { get; set; }
|
||||
|
||||
public CotijaConfig Cotija { get; private set; }
|
||||
//public CotijaConfig Cotija { get; private set; }
|
||||
|
||||
public string SystemUuid
|
||||
{
|
||||
@@ -49,7 +49,7 @@ namespace PepperDash.Essentials
|
||||
}
|
||||
|
||||
[JsonProperty("rooms")]
|
||||
public List<EssentialsRoomConfig> Rooms { get; private set; }
|
||||
public List<EssentialsRoomConfig> Rooms { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -60,7 +60,5 @@ namespace PepperDash.Essentials
|
||||
public EssentialsConfig System { get; set; }
|
||||
|
||||
public EssentialsConfig Template { get; set; }
|
||||
|
||||
//public CotijaConfig Cotija { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,21 @@ namespace PepperDash.Essentials
|
||||
},
|
||||
"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();
|
||||
}
|
||||
|
||||
|
||||
@@ -134,11 +134,13 @@
|
||||
<Compile Include="OTHER\Fusion\EssentialsHuddleSpaceFusionSystemControllerBase.cs" />
|
||||
<Compile Include="HttpApiHandler.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Room\Config\DDVC01RoomPropertiesConfig.cs" />
|
||||
<Compile Include="Room\Config\EssentialsPresentationPropertiesConfig.cs" />
|
||||
<Compile Include="Room\Config\EssentialsHuddleRoomPropertiesConfig.cs" />
|
||||
<Compile Include="Room\Config\EssentialsHuddleVtc1PropertiesConfig.cs" />
|
||||
<Compile Include="Room\Config\EssentialsRoomEmergencyConfig.cs" />
|
||||
<Compile Include="Room\Cotija\CotijaConfig.cs" />
|
||||
<Compile Include="Room\Cotija\Interfaces.cs" />
|
||||
<Compile Include="Room\Cotija\RoomBridges\CotijaDdvc01RoomBridge.cs" />
|
||||
<Compile Include="Room\Cotija\RoomBridges\CotijaEssentialsHuddleSpaceRoomBridge.cs" />
|
||||
<Compile Include="Room\Cotija\DeviceTypeInterfaces\IChannelExtensions.cs" />
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
[assembly: AssemblyCompany("PepperDash Technology Corp")]
|
||||
[assembly: AssemblyProduct("PepperDashEssentials")]
|
||||
[assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2017")]
|
||||
[assembly: AssemblyVersion("1.0.34.*")]
|
||||
[assembly: AssemblyVersion("1.0.35.*")]
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace PepperDash.Essentials
|
||||
{
|
||||
GenericHttpSseClient SseClient;
|
||||
|
||||
CCriticalSection FileLock;
|
||||
//CCriticalSection FileLock;
|
||||
|
||||
/// <summary>
|
||||
/// Prevents post operations from stomping on each other and getting lost
|
||||
@@ -153,34 +153,37 @@ namespace PepperDash.Essentials
|
||||
/// <param name="url">URL of the server, including the port number, if not 80. Format: "serverUrlOrIp:port"</param>
|
||||
void RegisterSystemToServer()
|
||||
{
|
||||
#warning THIS SHOULD NOT GO until the config is ready - in cases of config populated from elsewhere (DDVC)
|
||||
try
|
||||
{
|
||||
string filePath = string.Format(@"\NVRAM\Program{0}\configurationFile.json", Global.ControlSystem.ProgramNumber);
|
||||
string postBody = null;
|
||||
var confObject = ConfigReader.ConfigObject;
|
||||
string postBody = JsonConvert.SerializeObject(confObject);
|
||||
SystemUuid = confObject.SystemUuid;
|
||||
|
||||
if (string.IsNullOrEmpty(filePath))
|
||||
{
|
||||
Debug.Console(0, this, "Error reading file. No path specified.");
|
||||
return;
|
||||
}
|
||||
//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
|
||||
// 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...");
|
||||
// if (FileLock.TryEnter())
|
||||
// {
|
||||
// Debug.Console(1, this, "Reading configuration file to extract system UUID...");
|
||||
|
||||
postBody = File.ReadToEnd(filePath, Encoding.ASCII);
|
||||
// postBody = File.ReadToEnd(filePath, Encoding.ASCII);
|
||||
|
||||
Debug.Console(2, this, "{0}", postBody);
|
||||
// Debug.Console(2, this, "{0}", postBody);
|
||||
|
||||
FileLock.Leave();
|
||||
}
|
||||
// FileLock.Leave();
|
||||
// }
|
||||
|
||||
if (string.IsNullOrEmpty(postBody))
|
||||
{
|
||||
Debug.Console(1, "Post Body is null or empty");
|
||||
Debug.Console(1, this, "ERROR: Config post body is empty. Cannot register with server.");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -188,11 +191,9 @@ namespace PepperDash.Essentials
|
||||
Client = new HttpClient();
|
||||
Client.Verbose = true;
|
||||
Client.KeepAlive = true;
|
||||
|
||||
SystemUuid = Essentials.ConfigReader.ConfigObject.SystemUuid;
|
||||
|
||||
string url = string.Format("http://{0}/api/system/join/{1}", Config.ServerUrl, SystemUuid);
|
||||
Debug.Console(1, this, "Sending config to {0}", url);
|
||||
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);
|
||||
@@ -206,7 +207,7 @@ namespace PepperDash.Essentials
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(0, this, "Error Initilizing Room: {0}", e);
|
||||
Debug.Console(0, this, "ERROR: Initilizing Room: {0}", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
13
Essentials/PepperDashEssentials/Room/Cotija/Interfaces.cs
Normal file
13
Essentials/PepperDashEssentials/Room/Cotija/Interfaces.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public interface IDelayedConfiguration
|
||||
{
|
||||
event EventHandler<EventArgs> ConfigurationIsReady;
|
||||
}
|
||||
}
|
||||
@@ -10,11 +10,13 @@ using Newtonsoft.Json.Linq;
|
||||
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
using PepperDash.Essentials.Room.Config;
|
||||
|
||||
|
||||
namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
public class CotijaDdvc01RoomBridge : Device
|
||||
public class CotijaDdvc01RoomBridge : Device, IDelayedConfiguration
|
||||
{
|
||||
public class BoolJoin
|
||||
{
|
||||
@@ -109,6 +111,10 @@ namespace PepperDash.Essentials.Room.Cotija
|
||||
public const uint ConfigRoomURI = 505;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires when the config is ready, to be used by the controller class to forward config to server
|
||||
/// </summary>
|
||||
public event EventHandler<EventArgs> ConfigurationIsReady;
|
||||
|
||||
public ThreeSeriesTcpIpEthernetIntersystemCommunications EISC { get; private set; }
|
||||
|
||||
@@ -277,7 +283,7 @@ namespace PepperDash.Essentials.Room.Cotija
|
||||
if (string.IsNullOrEmpty(num))
|
||||
break;
|
||||
var name = EISC.StringInput[i + 1].StringValue;
|
||||
rmProps.SpeedDials.Add(new DDVC01SpeedDial { Number = num, Name = name};
|
||||
rmProps.SpeedDials.Add(new DDVC01SpeedDial { Number = num, Name = name});
|
||||
}
|
||||
// volume control names
|
||||
var volCount = EISC.UShortInput[701].UShortValue;
|
||||
@@ -286,12 +292,40 @@ namespace PepperDash.Essentials.Room.Cotija
|
||||
{
|
||||
rmProps.VolumeSliderNames.Add(EISC.StringInput[i].StringValue);
|
||||
}
|
||||
|
||||
// There should be cotija devices in here, I think...
|
||||
if(co.Devices == null)
|
||||
co.Devices = new List<DeviceConfig>();
|
||||
|
||||
// Source list! This might be brutal!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
rmProps.SourceListKey = "default";
|
||||
co.SourceLists = new Dictionary<string,Dictionary<string,SourceListItem>>();
|
||||
var newSl = new Dictionary<string, SourceListItem>();
|
||||
// add sources...
|
||||
for (uint i = 0; i<= 19; i++)
|
||||
{
|
||||
var name = EISC.StringInput[601 + i].StringValue;
|
||||
if(string.IsNullOrEmpty(name))
|
||||
break;
|
||||
var icon = EISC.StringInput[651 + i].StringValue;
|
||||
var key = EISC.StringInput[671 + i].StringValue;
|
||||
var type = EISC.StringInput[701 + i].StringValue;
|
||||
var newSLI = new SourceListItem{
|
||||
Icon = icon,
|
||||
Name = name,
|
||||
Order = (int)i + 1,
|
||||
SourceKey = key,
|
||||
};
|
||||
|
||||
// add dev to devices list
|
||||
var devConf = new DeviceConfig {
|
||||
Group = "ddvc01",
|
||||
Key = key,
|
||||
Name = name,
|
||||
Type = type
|
||||
};
|
||||
co.Devices.Add(devConf);
|
||||
}
|
||||
|
||||
co.SourceLists.Add("default", newSl);
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user