Added initial filesystem set up that puts all folders in place on initial run

This commit is contained in:
Heath Volmer
2018-01-09 15:58:38 -07:00
parent 857d10f0b2
commit ac4ef972fe
9 changed files with 441 additions and 382 deletions

View File

@@ -16,13 +16,21 @@ namespace PepperDash.Essentials
{ {
public static EssentialsConfig ConfigObject { get; private set; } public static EssentialsConfig ConfigObject { get; private set; }
public static void LoadConfig2() public static bool LoadConfig2()
{ {
Debug.Console(0, "Using unmerged system/template configs."); Debug.Console(0, "Using unmerged system/template configs.");
try try
{ {
using (StreamReader fs = new StreamReader(string.Format(@"\NVRAM\program{0}\ConfigurationFile.json", var filePath = string.Format(@"\NVRAM\program{0}\ConfigurationFile.json",
InitialParametersClass.ApplicationNumber))) InitialParametersClass.ApplicationNumber);
if (!File.Exists(filePath))
{
Debug.Console(0,
"ERROR: Configuration file not present. Please load file to {0} and reset program", filePath);
return false;
}
using (StreamReader fs = new StreamReader(filePath))
{ {
var doubleObj = JObject.Parse(fs.ReadToEnd()); var doubleObj = JObject.Parse(fs.ReadToEnd());
ConfigObject = MergeConfigs(doubleObj).ToObject<EssentialsConfig>(); ConfigObject = MergeConfigs(doubleObj).ToObject<EssentialsConfig>();
@@ -38,13 +46,13 @@ namespace PepperDash.Essentials
{ {
ConfigObject.TemplateUrl= doubleObj["template_url"].Value<string>(); ConfigObject.TemplateUrl= doubleObj["template_url"].Value<string>();
} }
} }
return true;
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Console(0, "Config failed: \r{0}", e); Debug.Console(0, "ERROR: Config load failed: \r{0}", e);
return false;
} }
} }

View File

@@ -1,6 +1,7 @@
using System; using System;
using System.Linq; using System.Linq;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.CrestronThread; using Crestron.SimplSharpPro.CrestronThread;
using PepperDash.Core; using PepperDash.Core;
@@ -49,33 +50,82 @@ namespace PepperDash.Essentials
/// </summary> /// </summary>
public void GoWithLoad() public void GoWithLoad()
{ {
// var thread = new Thread(o => try
// { {
try CrestronConsole.AddNewConsoleCommand(EnablePortalSync, "portalsync", "Loads Portal Sync",
ConsoleAccessLevelEnum.AccessOperator);
//PortalSync = new PepperDashPortalSyncClient();
Debug.Console(0, "Starting Essentials load from configuration");
var filesReady = SetupFilesystem();
if (filesReady)
{ {
CrestronConsole.AddNewConsoleCommand(EnablePortalSync, "portalsync", "Loads Portal Sync", Debug.Console(0, "Folder structure verified. Loading config...");
ConsoleAccessLevelEnum.AccessOperator); if (!ConfigReader.LoadConfig2())
return;
//PortalSync = new PepperDashPortalSyncClient();
Debug.Console(0, "Starting Essentials load from configuration");
ConfigReader.LoadConfig2();
LoadDevices(); LoadDevices();
LoadTieLines(); LoadTieLines();
LoadRooms(); LoadRooms();
LogoServer = new HttpLogoServer(8080, @"\html\logo"); try
{
LogoServer = new HttpLogoServer(8080, @"\html\logo");
}
catch (Exception e)
{
Debug.Console(0, "WARNING: Logo server cannot be started on port 8080:\n{0}", e);
}
DeviceManager.ActivateAll(); DeviceManager.ActivateAll();
Debug.Console(0, "Essentials load complete\r" + Debug.Console(0, "Essentials load complete\r" +
"-------------------------------------------------------------"); "-------------------------------------------------------------");
}
catch (Exception e)
{
Debug.Console(0, "FATAL INITIALIZE ERROR. System is in an inconsistent state:\r{0}", e);
} }
// return null; else
// }, null); {
Debug.Console(0,
"------------------------------------------------\n" +
"------------------------------------------------\n" +
"------------------------------------------------\n" +
"Essentials file structure setup completed.\n" +
"Please load config, sgd and ir files and\n" +
"restart program.\n" +
"------------------------------------------------\n" +
"------------------------------------------------\n" +
"------------------------------------------------");
}
}
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 appNum = InitialParametersClass.ApplicationNumber;
var configDir = @"\NVRAM\Program" + appNum;
var configExists = Directory.Exists(configDir);
if (!configExists)
Directory.Create(configDir);
var irDir = string.Format(@"\NVRAM\Program{0}\ir", appNum);
if (!Directory.Exists(irDir))
Directory.Create(irDir);
var sgdDir = string.Format(@"\NVRAM\Program{0}\sgd", appNum);
if (!Directory.Exists(sgdDir))
Directory.Create(sgdDir);
return configExists;
} }
public void EnablePortalSync(string s) public void EnablePortalSync(string s)

View File

@@ -139,7 +139,7 @@
<Compile Include="Room\Config\EssentialsHuddleVtc1PropertiesConfig.cs" /> <Compile Include="Room\Config\EssentialsHuddleVtc1PropertiesConfig.cs" />
<Compile Include="Room\Config\EssentialsRoomEmergencyConfig.cs" /> <Compile Include="Room\Config\EssentialsRoomEmergencyConfig.cs" />
<Compile Include="Room\Cotija\CotijaConfig.cs" /> <Compile Include="Room\Cotija\CotijaConfig.cs" />
<Compile Include="Room\Cotija\CotijaRoomBridge.cs" /> <Compile Include="Room\Cotija\RoomBridges\CotijaEssentialsHuddleSpaceRoomBridge.cs" />
<Compile Include="Room\Cotija\DeviceTypeInterfaces\IChannelExtensions.cs" /> <Compile Include="Room\Cotija\DeviceTypeInterfaces\IChannelExtensions.cs" />
<Compile Include="Room\Cotija\DeviceTypeInterfaces\IColorExtensions.cs" /> <Compile Include="Room\Cotija\DeviceTypeInterfaces\IColorExtensions.cs" />
<Compile Include="Room\Cotija\DeviceTypeInterfaces\IDPadExtensions.cs" /> <Compile Include="Room\Cotija\DeviceTypeInterfaces\IDPadExtensions.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 2017")] [assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2017")]
[assembly: AssemblyVersion("1.0.15.*")] [assembly: AssemblyVersion("1.0.17.*")]

View File

@@ -53,6 +53,7 @@ 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;
Debug.Console(0, this, "Mobile UI controller initializing for server:{0}", config.ServerUrl);
CotijaRooms = new List<CotijaEssentialsHuddleSpaceRoomBridge>(); CotijaRooms = new List<CotijaEssentialsHuddleSpaceRoomBridge>();

View File

@@ -1,357 +1,357 @@
using System; using System;
using System.Collections.Generic; 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;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Essentials.Room.Cotija; using PepperDash.Essentials.Room.Cotija;
namespace PepperDash.Essentials namespace PepperDash.Essentials
{ {
public class CotijaEssentialsHuddleSpaceRoomBridge public class CotijaEssentialsHuddleSpaceRoomBridge
{ {
CotijaSystemController Parent; CotijaSystemController Parent;
public EssentialsHuddleSpaceRoom Room { get; private set; } public EssentialsHuddleSpaceRoom Room { get; private set; }
public CotijaEssentialsHuddleSpaceRoomBridge(CotijaSystemController parent, EssentialsHuddleSpaceRoom room) public CotijaEssentialsHuddleSpaceRoomBridge(CotijaSystemController parent, EssentialsHuddleSpaceRoom room)
{ {
Parent = parent; Parent = parent;
Room = room; Room = room;
// we add actions to the messaging system with a path, and a related action. Custom action // we add actions to the messaging system with a path, and a related action. Custom action
// content objects can be handled in the controller's LineReceived method - and perhaps other // content objects can be handled in the controller's LineReceived method - and perhaps other
// sub-controller parsing could be attached to these classes, so that the systemController // sub-controller parsing could be attached to these classes, so that the systemController
// doesn't need to know about everything. // doesn't need to know about everything.
// Source Changes and room off // Source Changes and room off
Parent.AddAction(string.Format(@"/room/{0}/status",Room.Key), new Action(() => Room_RoomFullStatus(Room))); Parent.AddAction(string.Format(@"/room/{0}/status",Room.Key), new Action(() => Room_RoomFullStatus(Room)));
Parent.AddAction(string.Format(@"/room/{0}/source", Room.Key), new Action<SourceSelectMessageContent>(c => room.RunRouteAction(c.SourceListItem))); Parent.AddAction(string.Format(@"/room/{0}/source", Room.Key), new Action<SourceSelectMessageContent>(c => room.RunRouteAction(c.SourceListItem)));
Parent.AddAction(string.Format(@"/room/{0}/defaultsource", Room.Key), new Action(Room.RunDefaultRoute)); Parent.AddAction(string.Format(@"/room/{0}/defaultsource", Room.Key), new Action(Room.RunDefaultRoute));
Parent.AddAction(string.Format(@"/room/{0}/masterVolumeLevel", Room.Key), new Action<ushort>(u => Parent.AddAction(string.Format(@"/room/{0}/masterVolumeLevel", Room.Key), new Action<ushort>(u =>
(room.CurrentVolumeControls as IBasicVolumeWithFeedback).SetVolume(u))); (room.CurrentVolumeControls as IBasicVolumeWithFeedback).SetVolume(u)));
Parent.AddAction(string.Format(@"/room/{0}/masterVolumeMuteToggle", Room.Key), new Action(() => room.CurrentVolumeControls.MuteToggle())); Parent.AddAction(string.Format(@"/room/{0}/masterVolumeMuteToggle", Room.Key), new Action(() => room.CurrentVolumeControls.MuteToggle()));
Parent.AddAction(string.Format(@"/room/{0}/shutdownStart", Room.Key), new Action(() => room.StartShutdown(eShutdownType.Manual))); Parent.AddAction(string.Format(@"/room/{0}/shutdownStart", Room.Key), new Action(() => room.StartShutdown(eShutdownType.Manual)));
Parent.AddAction(string.Format(@"/room/{0}/shutdownEnd", Room.Key), new Action(() => room.ShutdownPromptTimer.Finish())); Parent.AddAction(string.Format(@"/room/{0}/shutdownEnd", Room.Key), new Action(() => room.ShutdownPromptTimer.Finish()));
Parent.AddAction(string.Format(@"/room/{0}/shutdownCancel", Room.Key), new Action(() => room.ShutdownPromptTimer.Cancel())); Parent.AddAction(string.Format(@"/room/{0}/shutdownCancel", Room.Key), new Action(() => room.ShutdownPromptTimer.Cancel()));
Room.CurrentSingleSourceChange += new SourceInfoChangeHandler(Room_CurrentSingleSourceChange); Room.CurrentSingleSourceChange += new SourceInfoChangeHandler(Room_CurrentSingleSourceChange);
Room.CurrentVolumeDeviceChange += new EventHandler<VolumeDeviceChangeEventArgs>(Room_CurrentVolumeDeviceChange); Room.CurrentVolumeDeviceChange += new EventHandler<VolumeDeviceChangeEventArgs>(Room_CurrentVolumeDeviceChange);
Room.OnFeedback.OutputChange += new EventHandler<EventArgs>(OnFeedback_OutputChange); Room.OnFeedback.OutputChange += new EventHandler<EventArgs>(OnFeedback_OutputChange);
Room.IsCoolingDownFeedback.OutputChange += new EventHandler<EventArgs>(IsCoolingDownFeedback_OutputChange); Room.IsCoolingDownFeedback.OutputChange += new EventHandler<EventArgs>(IsCoolingDownFeedback_OutputChange);
Room.IsWarmingUpFeedback.OutputChange += new EventHandler<EventArgs>(IsWarmingUpFeedback_OutputChange); Room.IsWarmingUpFeedback.OutputChange += new EventHandler<EventArgs>(IsWarmingUpFeedback_OutputChange);
Room.ShutdownPromptTimer.HasStarted += new EventHandler<EventArgs>(ShutdownPromptTimer_HasStarted); Room.ShutdownPromptTimer.HasStarted += new EventHandler<EventArgs>(ShutdownPromptTimer_HasStarted);
Room.ShutdownPromptTimer.HasFinished += new EventHandler<EventArgs>(ShutdownPromptTimer_HasFinished); Room.ShutdownPromptTimer.HasFinished += new EventHandler<EventArgs>(ShutdownPromptTimer_HasFinished);
Room.ShutdownPromptTimer.WasCancelled += new EventHandler<EventArgs>(ShutdownPromptTimer_WasCancelled); Room.ShutdownPromptTimer.WasCancelled += new EventHandler<EventArgs>(ShutdownPromptTimer_WasCancelled);
// Registers for initial volume events, if possible // Registers for initial volume events, if possible
var currentVolumeDevice = Room.CurrentVolumeControls; var currentVolumeDevice = Room.CurrentVolumeControls;
if (currentVolumeDevice != null) if (currentVolumeDevice != null)
{ {
if (currentVolumeDevice is IBasicVolumeWithFeedback) if (currentVolumeDevice is IBasicVolumeWithFeedback)
{ {
var newDev = currentVolumeDevice as IBasicVolumeWithFeedback; var newDev = currentVolumeDevice as IBasicVolumeWithFeedback;
newDev.MuteFeedback.OutputChange += new EventHandler<EventArgs>(VolumeLevelFeedback_OutputChange); newDev.MuteFeedback.OutputChange += new EventHandler<EventArgs>(VolumeLevelFeedback_OutputChange);
newDev.VolumeLevelFeedback.OutputChange += new EventHandler<EventArgs>(VolumeLevelFeedback_OutputChange); newDev.VolumeLevelFeedback.OutputChange += new EventHandler<EventArgs>(VolumeLevelFeedback_OutputChange);
} }
} }
} }
/// <summary> /// <summary>
/// Handler for cancelled shutdown /// Handler for cancelled shutdown
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void ShutdownPromptTimer_WasCancelled(object sender, EventArgs e) void ShutdownPromptTimer_WasCancelled(object sender, EventArgs e)
{ {
JObject roomStatus = new JObject(); JObject roomStatus = new JObject();
roomStatus.Add("state", "wasCancelled"); roomStatus.Add("state", "wasCancelled");
JObject message = new JObject(); JObject message = new JObject();
message.Add("type", "/room/shutdown/"); message.Add("type", "/room/shutdown/");
message.Add("content", roomStatus); message.Add("content", roomStatus);
Parent.PostToServer(Room, message); Parent.PostToServer(Room, message);
} }
/// <summary> /// <summary>
/// Handler for when shutdown finishes /// Handler for when shutdown finishes
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void ShutdownPromptTimer_HasFinished(object sender, EventArgs e) void ShutdownPromptTimer_HasFinished(object sender, EventArgs e)
{ {
JObject roomStatus = new JObject(); JObject roomStatus = new JObject();
roomStatus.Add("state", "hasFinished"); roomStatus.Add("state", "hasFinished");
JObject message = new JObject(); JObject message = new JObject();
message.Add("type", "/room/shutdown/"); message.Add("type", "/room/shutdown/");
message.Add("content", roomStatus); message.Add("content", roomStatus);
Parent.PostToServer(Room, message); Parent.PostToServer(Room, message);
} }
/// <summary> /// <summary>
/// Handler for when shutdown starts /// Handler for when shutdown starts
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void ShutdownPromptTimer_HasStarted(object sender, EventArgs e) void ShutdownPromptTimer_HasStarted(object sender, EventArgs e)
{ {
JObject roomStatus = new JObject(); JObject roomStatus = new JObject();
roomStatus.Add("state", "hasStarted"); roomStatus.Add("state", "hasStarted");
roomStatus.Add("duration", Room.ShutdownPromptTimer.SecondsToCount); roomStatus.Add("duration", Room.ShutdownPromptTimer.SecondsToCount);
JObject message = new JObject(); JObject message = new JObject();
message.Add("type", "/room/shutdown/"); message.Add("type", "/room/shutdown/");
message.Add("content", roomStatus); message.Add("content", roomStatus);
Parent.PostToServer(Room, message); Parent.PostToServer(Room, message);
// equivalent JS message: // equivalent JS message:
// Post( { type: '/room/status/', content: { shutdown: 'hasStarted', duration: Room.ShutdownPromptTimer.SecondsToCount }) // Post( { type: '/room/status/', content: { shutdown: 'hasStarted', duration: Room.ShutdownPromptTimer.SecondsToCount })
} }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void IsWarmingUpFeedback_OutputChange(object sender, EventArgs e) void IsWarmingUpFeedback_OutputChange(object sender, EventArgs e)
{ {
JObject roomStatus = new JObject(); JObject roomStatus = new JObject();
roomStatus.Add("isWarmingUp", (sender as BoolFeedback).BoolValue); roomStatus.Add("isWarmingUp", (sender as BoolFeedback).BoolValue);
JObject message = new JObject(); JObject message = new JObject();
message.Add("type", "/room/status/"); message.Add("type", "/room/status/");
message.Add("content", roomStatus); message.Add("content", roomStatus);
Parent.PostToServer(Room, message); Parent.PostToServer(Room, message);
} }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void IsCoolingDownFeedback_OutputChange(object sender, EventArgs e) void IsCoolingDownFeedback_OutputChange(object sender, EventArgs e)
{ {
JObject roomStatus = new JObject(); JObject roomStatus = new JObject();
roomStatus.Add("isCoolingDown", (sender as BoolFeedback).BoolValue); roomStatus.Add("isCoolingDown", (sender as BoolFeedback).BoolValue);
JObject message = new JObject(); JObject message = new JObject();
message.Add("type", "/room/status/"); message.Add("type", "/room/status/");
message.Add("content", roomStatus); message.Add("content", roomStatus);
Parent.PostToServer(Room, message); Parent.PostToServer(Room, message);
} }
/// <summary> /// <summary>
/// ///
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void OnFeedback_OutputChange(object sender, EventArgs e) void OnFeedback_OutputChange(object sender, EventArgs e)
{ {
/* Example message /* Example message
* { * {
"type":"/room/status", "type":"/room/status",
"content": { "content": {
"isOn": false "isOn": false
} }
} }
*/ */
JObject roomStatus = new JObject(); JObject roomStatus = new JObject();
roomStatus.Add("isOn", (sender as BoolFeedback).BoolValue); roomStatus.Add("isOn", (sender as BoolFeedback).BoolValue);
JObject message = new JObject(); JObject message = new JObject();
message.Add("type", "/room/status/"); message.Add("type", "/room/status/");
message.Add("content", roomStatus); message.Add("content", roomStatus);
Parent.PostToServer(Room, message); Parent.PostToServer(Room, message);
} }
void Room_CurrentVolumeDeviceChange(object sender, VolumeDeviceChangeEventArgs e) void Room_CurrentVolumeDeviceChange(object sender, VolumeDeviceChangeEventArgs e)
{ {
if (e.OldDev is IBasicVolumeWithFeedback) if (e.OldDev is IBasicVolumeWithFeedback)
{ {
var oldDev = e.OldDev as IBasicVolumeWithFeedback; var oldDev = e.OldDev as IBasicVolumeWithFeedback;
oldDev.MuteFeedback.OutputChange -= VolumeLevelFeedback_OutputChange; oldDev.MuteFeedback.OutputChange -= VolumeLevelFeedback_OutputChange;
oldDev.VolumeLevelFeedback.OutputChange -= VolumeLevelFeedback_OutputChange; oldDev.VolumeLevelFeedback.OutputChange -= VolumeLevelFeedback_OutputChange;
} }
if (e.NewDev is IBasicVolumeWithFeedback) if (e.NewDev is IBasicVolumeWithFeedback)
{ {
var newDev = e.NewDev as IBasicVolumeWithFeedback; var newDev = e.NewDev as IBasicVolumeWithFeedback;
newDev.MuteFeedback.OutputChange += new EventHandler<EventArgs>(VolumeLevelFeedback_OutputChange); newDev.MuteFeedback.OutputChange += new EventHandler<EventArgs>(VolumeLevelFeedback_OutputChange);
newDev.VolumeLevelFeedback.OutputChange += new EventHandler<EventArgs>(VolumeLevelFeedback_OutputChange); newDev.VolumeLevelFeedback.OutputChange += new EventHandler<EventArgs>(VolumeLevelFeedback_OutputChange);
} }
} }
void VolumeLevelFeedback_OutputChange(object sender, EventArgs e) void VolumeLevelFeedback_OutputChange(object sender, EventArgs e)
{ {
/* Example message /* Example message
* { * {
"type":"/room/status", "type":"/room/status",
"content": { "content": {
"masterVolumeLevel": 12345, "masterVolumeLevel": 12345,
"masterVolumeMuteState": false "masterVolumeMuteState": false
} }
} }
*/ */
var huddleRoom = Room as EssentialsHuddleSpaceRoom; var huddleRoom = Room as EssentialsHuddleSpaceRoom;
if(huddleRoom.CurrentVolumeControls is IBasicVolumeWithFeedback) if(huddleRoom.CurrentVolumeControls is IBasicVolumeWithFeedback)
{ {
JObject roomStatus = new JObject(); JObject roomStatus = new JObject();
if (huddleRoom.CurrentVolumeControls is IBasicVolumeWithFeedback) if (huddleRoom.CurrentVolumeControls is IBasicVolumeWithFeedback)
{ {
var currentVolumeConstrols = huddleRoom.CurrentVolumeControls as IBasicVolumeWithFeedback; var currentVolumeConstrols = huddleRoom.CurrentVolumeControls as IBasicVolumeWithFeedback;
roomStatus.Add("masterVolumeLevel", currentVolumeConstrols.VolumeLevelFeedback.IntValue); roomStatus.Add("masterVolumeLevel", currentVolumeConstrols.VolumeLevelFeedback.IntValue);
roomStatus.Add("masterVolumeMuteState", currentVolumeConstrols.MuteFeedback.BoolValue); roomStatus.Add("masterVolumeMuteState", currentVolumeConstrols.MuteFeedback.BoolValue);
} }
JObject message = new JObject(); JObject message = new JObject();
message.Add("type", "/room/status/"); message.Add("type", "/room/status/");
message.Add("content", roomStatus); message.Add("content", roomStatus);
Parent.PostToServer(Room, message); Parent.PostToServer(Room, message);
} }
} }
void Room_CurrentSingleSourceChange(EssentialsRoomBase room, PepperDash.Essentials.Core.SourceListItem info, ChangeType type) void Room_CurrentSingleSourceChange(EssentialsRoomBase room, PepperDash.Essentials.Core.SourceListItem info, ChangeType type)
{ {
/* Example message /* Example message
* { * {
"type":"/room/status", "type":"/room/status",
"content": { "content": {
"selectedSourceKey": "off", "selectedSourceKey": "off",
} }
} }
*/ */
if (type == ChangeType.WillChange) if (type == ChangeType.WillChange)
{ {
// Disconnect from previous source // Disconnect from previous source
if (info != null) if (info != null)
{ {
var previousDev = info.SourceDevice; var previousDev = info.SourceDevice;
// device type interfaces // device type interfaces
if (previousDev is ISetTopBoxControls) if (previousDev is ISetTopBoxControls)
(previousDev as ISetTopBoxControls).UnlinkActions(Parent); (previousDev as ISetTopBoxControls).UnlinkActions(Parent);
// common interfaces // common interfaces
if (previousDev is IChannel) if (previousDev is IChannel)
(previousDev as IChannel).UnlinkActions(Parent); (previousDev as IChannel).UnlinkActions(Parent);
if (previousDev is IColor) if (previousDev is IColor)
(previousDev as IColor).UnlinkActions(Parent); (previousDev as IColor).UnlinkActions(Parent);
if (previousDev is IDPad) if (previousDev is IDPad)
(previousDev as IDPad).UnlinkActions(Parent); (previousDev as IDPad).UnlinkActions(Parent);
if (previousDev is IDvr) if (previousDev is IDvr)
(previousDev as IDvr).UnlinkActions(Parent); (previousDev as IDvr).UnlinkActions(Parent);
if (previousDev is INumericKeypad) if (previousDev is INumericKeypad)
(previousDev as INumericKeypad).UnlinkActions(Parent); (previousDev as INumericKeypad).UnlinkActions(Parent);
if (previousDev is IPower) if (previousDev is IPower)
(previousDev as IPower).UnlinkActions(Parent); (previousDev as IPower).UnlinkActions(Parent);
if (previousDev is ITransport) if (previousDev is ITransport)
(previousDev as ITransport).UnlinkActions(Parent); (previousDev as ITransport).UnlinkActions(Parent);
} }
JObject roomStatus = new JObject(); JObject roomStatus = new JObject();
var huddleRoom = room as EssentialsHuddleSpaceRoom; var huddleRoom = room as EssentialsHuddleSpaceRoom;
roomStatus.Add("selectedSourceKey", huddleRoom.CurrentSourceInfoKey); roomStatus.Add("selectedSourceKey", huddleRoom.CurrentSourceInfoKey);
JObject message = new JObject(); JObject message = new JObject();
message.Add("type", "/room/status/"); message.Add("type", "/room/status/");
message.Add("content", roomStatus); message.Add("content", roomStatus);
Parent.PostToServer(Room, message); Parent.PostToServer(Room, message);
} }
else else
{ {
if (info != null) if (info != null)
{ {
var dev = info.SourceDevice; var dev = info.SourceDevice;
if (dev is ISetTopBoxControls) if (dev is ISetTopBoxControls)
(dev as ISetTopBoxControls).LinkActions(Parent); (dev as ISetTopBoxControls).LinkActions(Parent);
if (dev is IChannel) if (dev is IChannel)
(dev as IChannel).LinkActions(Parent); (dev as IChannel).LinkActions(Parent);
if (dev is IColor) if (dev is IColor)
(dev as IColor).LinkActions(Parent); (dev as IColor).LinkActions(Parent);
if (dev is IDPad) if (dev is IDPad)
(dev as IDPad).LinkActions(Parent); (dev as IDPad).LinkActions(Parent);
if (dev is IDvr) if (dev is IDvr)
(dev as IDvr).LinkActions(Parent); (dev as IDvr).LinkActions(Parent);
if (dev is INumericKeypad) if (dev is INumericKeypad)
(dev as INumericKeypad).LinkActions(Parent); (dev as INumericKeypad).LinkActions(Parent);
if (dev is IPower) if (dev is IPower)
(dev as IPower).LinkActions(Parent); (dev as IPower).LinkActions(Parent);
if (dev is ITransport) if (dev is ITransport)
(dev as ITransport).LinkActions(Parent); (dev as ITransport).LinkActions(Parent);
} }
} }
} }
/// <summary> /// <summary>
/// Posts the full status of the room to the server /// Posts the full status of the room to the server
/// </summary> /// </summary>
/// <param name="room"></param> /// <param name="room"></param>
void Room_RoomFullStatus(EssentialsRoomBase room) void Room_RoomFullStatus(EssentialsRoomBase room)
{ {
/* Example message /* Example message
* { * {
"type":"/room/status", "type":"/room/status",
"content": { "content": {
"selectedSourceKey": "off", "selectedSourceKey": "off",
"isOn": false, "isOn": false,
"masterVolumeLevel": 50, "masterVolumeLevel": 50,
"masterVolumeMuteState": false "masterVolumeMuteState": false
} }
} }
*/ */
JObject roomStatus = new JObject(); JObject roomStatus = new JObject();
var huddleRoom = room as EssentialsHuddleSpaceRoom; var huddleRoom = room as EssentialsHuddleSpaceRoom;
roomStatus.Add("isOn", huddleRoom.OnFeedback.BoolValue); roomStatus.Add("isOn", huddleRoom.OnFeedback.BoolValue);
roomStatus.Add("selectedSourceKey", huddleRoom.CurrentSourceInfoKey); roomStatus.Add("selectedSourceKey", huddleRoom.CurrentSourceInfoKey);
if(huddleRoom.CurrentVolumeControls is IBasicVolumeWithFeedback) if(huddleRoom.CurrentVolumeControls is IBasicVolumeWithFeedback)
{ {
var currentVolumeConstrols = huddleRoom.CurrentVolumeControls as IBasicVolumeWithFeedback; var currentVolumeConstrols = huddleRoom.CurrentVolumeControls as IBasicVolumeWithFeedback;
roomStatus.Add("masterVolumeLevel", currentVolumeConstrols.VolumeLevelFeedback.IntValue); roomStatus.Add("masterVolumeLevel", currentVolumeConstrols.VolumeLevelFeedback.IntValue);
roomStatus.Add("masterVolumeMuteState", currentVolumeConstrols.MuteFeedback.BoolValue); roomStatus.Add("masterVolumeMuteState", currentVolumeConstrols.MuteFeedback.BoolValue);
} }
JObject message = new JObject(); JObject message = new JObject();
message.Add("type", "/room/status/"); message.Add("type", "/room/status/");
message.Add("content", roomStatus); message.Add("content", roomStatus);
Parent.PostToServer(Room, message); Parent.PostToServer(Room, message);
} }
} }
public class SourceSelectMessageContent public class SourceSelectMessageContent
{ {
public string SourceListItem { get; set; } public string SourceListItem { get; set; }
//public string Destination { get; set; } //public string Destination { get; set; }
//public string SourceSelect { get; set; } //public string SourceSelect { get; set; }
} }
public delegate void PressAndHoldAction(bool b); public delegate void PressAndHoldAction(bool b);
} }

View File

@@ -98,7 +98,7 @@ namespace PepperDash.Essentials
+ @"\sgd\" + props.SgdFile; + @"\sgd\" + props.SgdFile;
if (!File.Exists(sgdName)) if (!File.Exists(sgdName))
{ {
Debug.Console(0, this, "WARNING: Smart object file '{0}' not present. Exiting TSW load", sgdName); Debug.Console(0, this, "ERROR: Smart object file '{0}' not present. Exiting TSW load", sgdName);
return; return;
} }