mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 13:15:03 +00:00
Preparing DDVCO1 cotija bridge to send configuration - incomplete
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user