diff --git a/Essentials/PepperDashEssentials/Config/DeviceFactory.cs b/Essentials/PepperDashEssentials/Config/DeviceFactory.cs
index 19fbf925..d0f81290 100644
--- a/Essentials/PepperDashEssentials/Config/DeviceFactory.cs
+++ b/Essentials/PepperDashEssentials/Config/DeviceFactory.cs
@@ -69,10 +69,24 @@ namespace PepperDash.Essentials
return new CotijaSystemController(key, name, props);
}
- else if (typeName == "cotijaddvc01room")
+ else if (typeName == "cotijaddvc01roombridge")
{
var comm = CommFactory.GetControlPropertiesConfig(dc);
- return new PepperDash.Essentials.Room.Cotija.CotijaDdvc01RoomBridge(key, name, comm.IpIdInt);
+
+ var bridge = new PepperDash.Essentials.Room.Cotija.CotijaDdvc01RoomBridge(key, name, comm.IpIdInt);
+ bridge.AddPreActivationAction(() =>
+ {
+ var parent = DeviceManager.AllDevices.FirstOrDefault(d => d.Key == "cotijaServer") 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.CotijaRooms.Add(bridge);
+ });
+
+ return bridge;
}
return null;
diff --git a/Essentials/PepperDashEssentials/ControlSystem.cs b/Essentials/PepperDashEssentials/ControlSystem.cs
index 537921c9..4663606e 100644
--- a/Essentials/PepperDashEssentials/ControlSystem.cs
+++ b/Essentials/PepperDashEssentials/ControlSystem.cs
@@ -10,6 +10,7 @@ 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
{
@@ -226,6 +227,12 @@ namespace PepperDash.Essentials
///
public void LoadRooms()
{
+ if (ConfigReader.ConfigObject.Rooms == null)
+ {
+ Debug.Console(0, "WARNING: Configuration contains no rooms");
+ return;
+ }
+
foreach (var roomConfig in ConfigReader.ConfigObject.Rooms)
{
var room = roomConfig.GetRoomObject();
@@ -238,12 +245,8 @@ namespace PepperDash.Essentials
Debug.Console(1, "Room is EssentialsHuddleSpaceRoom, attempting to add to DeviceManager with Fusion");
DeviceManager.AddDevice(new EssentialsHuddleSpaceFusionSystemControllerBase((EssentialsHuddleSpaceRoom)room, 0xf1));
- var cotija = DeviceManager.GetDeviceForKey("cotijaServer") as CotijaSystemController;
-
- if (cotija != null)
- {
- cotija.CotijaRooms.Add(new CotijaEssentialsHuddleSpaceRoomBridge(cotija, room as EssentialsHuddleSpaceRoom));
- }
+ var bridge = new CotijaEssentialsHuddleSpaceRoomBridge(room as EssentialsHuddleSpaceRoom);
+ AddBridgePostActivationHelper(bridge);
}
else if (room is EssentialsHuddleVtc1Room)
{
@@ -251,7 +254,7 @@ namespace PepperDash.Essentials
Debug.Console(1, "Room is EssentialsHuddleVtc1Room, attempting to add to DeviceManager with Fusion");
DeviceManager.AddDevice(new EssentialsHuddleVtc1FusionController((EssentialsHuddleVtc1Room)room, 0xf1));
- }
+ }
else
{
Debug.Console(1, "Room is NOT EssentialsHuddleSpaceRoom, attempting to add to DeviceManager w/o Fusion");
@@ -264,12 +267,30 @@ namespace PepperDash.Essentials
}
}
+ ///
+ /// Helps add the post activation steps that link bridges to main controller
+ ///
+ ///
+ void AddBridgePostActivationHelper(CotijaBridgeBase bridge)
+ {
+ bridge.AddPostActivationAction(() =>
+ {
+ var parent = DeviceManager.AllDevices.FirstOrDefault(d => d.Key == "cotijaServer") 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.CotijaRooms.Add(bridge);
+ });
+ }
+
///
/// Fires up a logo server if not already running
///
void LoadLogoServer()
{
-
try
{
LogoServer = new HttpLogoServer(8080, @"\html\logo");
diff --git a/Essentials/PepperDashEssentials/PepperDashEssentials.csproj b/Essentials/PepperDashEssentials/PepperDashEssentials.csproj
index 04050521..c422c5f3 100644
--- a/Essentials/PepperDashEssentials/PepperDashEssentials.csproj
+++ b/Essentials/PepperDashEssentials/PepperDashEssentials.csproj
@@ -141,6 +141,7 @@
+
diff --git a/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaBridgeBase.cs b/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaBridgeBase.cs
index 7f859497..0dee40de 100644
--- a/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaBridgeBase.cs
+++ b/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaBridgeBase.cs
@@ -4,16 +4,28 @@ using System.Linq;
using System.Text;
using Crestron.SimplSharp;
+using PepperDash.Core;
+using PepperDash.Essentials.Core;
+
namespace PepperDash.Essentials
{
///
///
///
- public abstract class CotijaBridgeBase
+ public abstract class CotijaBridgeBase: Device
{
public CotijaSystemController Parent { get; private set; }
- public CotijaBridgeBase(CotijaSystemController parent)
+ public CotijaBridgeBase(string key, string name)
+ : base(key, name)
+ {
+ }
+
+ ///
+ ///
+ ///
+ ///
+ public void AddParent(CotijaSystemController parent)
{
Parent = parent;
}
diff --git a/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs b/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs
index 356f57d2..0c4b7f46 100644
--- a/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs
+++ b/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs
@@ -118,10 +118,12 @@ namespace PepperDash.Essentials.Room.Cotija
public ThreeSeriesTcpIpEthernetIntersystemCommunications EISC { get; private set; }
- CotijaSystemController Parent;
-
+ ///
+ ///
+ ///
public bool ConfigIsLoaded { get; private set; }
+
///
///
///
@@ -131,7 +133,6 @@ namespace PepperDash.Essentials.Room.Cotija
public CotijaDdvc01RoomBridge(string key, string name, uint ipId)
: base(key, name)
{
- Key = key;
try
{
EISC = new ThreeSeriesTcpIpEthernetIntersystemCommunications(ipId, "127.0.0.2", Global.ControlSystem);
@@ -146,24 +147,17 @@ namespace PepperDash.Essentials.Room.Cotija
}
///
- /// Finish wiring up everything after all devices are created
+ /// Finish wiring up everything after all devices are created. The base class will hunt down the related
+ /// parent controller and link them up.
///
///
public override bool CustomActivate()
{
-
- Parent = DeviceManager.AllDevices.FirstOrDefault(d => d is CotijaSystemController) as CotijaSystemController;
- if (Parent == null)
- {
- Debug.Console(0, this, "ERROR: Cannot build CotijaDdvc01RoomBridge. System controller not present");
- return false;
- }
-
SetupFunctions();
SetupFeedbacks();
EISC.SigChange += EISC_SigChange;
// load config if it's already there
- if (EISC.BooleanInput[BoolJoin.ConfigIsReady].BoolValue)
+ if (EISC.IsOnline || EISC.BooleanInput[BoolJoin.ConfigIsReady].BoolValue)
LoadConfigValues();
return base.CustomActivate();
}
diff --git a/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaEssentialsHuddleSpaceRoomBridge.cs b/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaEssentialsHuddleSpaceRoomBridge.cs
index fa84ca66..a8e6338e 100644
--- a/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaEssentialsHuddleSpaceRoomBridge.cs
+++ b/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaEssentialsHuddleSpaceRoomBridge.cs
@@ -20,7 +20,8 @@ namespace PepperDash.Essentials
///
///
///
- public CotijaEssentialsHuddleSpaceRoomBridge(CotijaSystemController parent, EssentialsHuddleSpaceRoom room):base(parent)
+ public CotijaEssentialsHuddleSpaceRoomBridge(EssentialsHuddleSpaceRoom room):
+ base("cotijaController", "Cotija Controller")
{
Room = room;
diff --git a/Release Package/PepperDashEssentials.cpz b/Release Package/PepperDashEssentials.cpz
index 5acd33d3..896dd55d 100644
Binary files a/Release Package/PepperDashEssentials.cpz and b/Release Package/PepperDashEssentials.cpz differ