diff --git a/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs b/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs index 2f7cc084..787dc4bf 100644 --- a/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs +++ b/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs @@ -31,6 +31,8 @@ namespace PepperDash.Essentials.Core public UsageTracking() { + InUseTracker = new InUseTracking(); + InUseTracker.InUseFeedback.OutputChange +=new EventHandler(InUseFeedback_OutputChange); } diff --git a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo index ed841c4e..bc99d309 100644 Binary files a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo and b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo differ diff --git a/Essentials DM/Essentials_DM/Essentials_DM.projectinfo b/Essentials DM/Essentials_DM/Essentials_DM.projectinfo index ac557c07..93d8d457 100644 Binary files a/Essentials DM/Essentials_DM/Essentials_DM.projectinfo and b/Essentials DM/Essentials_DM/Essentials_DM.projectinfo differ diff --git a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo index 988b4159..e0c09169 100644 Binary files a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo and b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.projectinfo differ diff --git a/Essentials/PepperDashEssentials/Config/ConfigReader.cs b/Essentials/PepperDashEssentials/Config/ConfigReader.cs index b633f40d..e9ce8939 100644 --- a/Essentials/PepperDashEssentials/Config/ConfigReader.cs +++ b/Essentials/PepperDashEssentials/Config/ConfigReader.cs @@ -148,5 +148,11 @@ namespace PepperDash.Essentials return o1; } + public static string GetGroupForDeviceKey(string key) + { + var dev = ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(key, StringComparison.OrdinalIgnoreCase)); + return dev == null ? null : dev.Group; + } + } } \ No newline at end of file diff --git a/Essentials/PepperDashEssentials/ControlSystem.cs b/Essentials/PepperDashEssentials/ControlSystem.cs index 08ab826a..904d8d2b 100644 --- a/Essentials/PepperDashEssentials/ControlSystem.cs +++ b/Essentials/PepperDashEssentials/ControlSystem.cs @@ -29,8 +29,8 @@ namespace PepperDash.Essentials /// public override void InitializeSystem() { - //CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Reloads configuration file", - // ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Reloads configuration file", + ConsoleAccessLevelEnum.AccessOperator); //CrestronConsole.AddNewConsoleCommand(s => TearDown(), "ungo", "Reloads configuration file", // ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(s => @@ -40,7 +40,7 @@ namespace PepperDash.Essentials }, "listtielines", "Prints out all tie lines", ConsoleAccessLevelEnum.AccessOperator); - GoWithLoad(); + //GoWithLoad(); } /// diff --git a/Essentials/PepperDashEssentials/Fusion/FusionRviDataClasses.cs b/Essentials/PepperDashEssentials/Fusion/FusionRviDataClasses.cs index d2c43b41..c1ad5078 100644 --- a/Essentials/PepperDashEssentials/Fusion/FusionRviDataClasses.cs +++ b/Essentials/PepperDashEssentials/Fusion/FusionRviDataClasses.cs @@ -16,36 +16,36 @@ namespace PepperDash.Essentials.Fusion public string RoomName { get; set; } public uint IpId { get; set; } public string RoomGuid { get; set; } - public List StaticAssets { get; set; } + public List StaticAssets { get; set; } public FusionRoomGuids() { - StaticAssets = new List(); + StaticAssets = new List(); } - public FusionRoomGuids(string roomName, uint ipId, string roomGuid, List staticAssets) + public FusionRoomGuids(string roomName, uint ipId, string roomGuid, List staticAssets) { RoomName = roomName; IpId = ipId; RoomGuid = roomGuid; - StaticAssets = new List(staticAssets); + StaticAssets = new List(staticAssets); } } - public class StaticAsset + public class FusionAsset { public uint Number { get; set; } public string Name { get; set; } public string Type { get; set; } public string InstanceID { get; set; } - public StaticAsset() + public FusionAsset() { } - public StaticAsset(uint slotNum, string assetName, string type, string instanceID) + public FusionAsset(uint slotNum, string assetName, string type, string instanceID) { Number = slotNum; Name = assetName; diff --git a/Essentials/PepperDashEssentials/Fusion/FusionSystemController.cs b/Essentials/PepperDashEssentials/Fusion/FusionSystemController.cs index 49b8af1f..227f81f1 100644 --- a/Essentials/PepperDashEssentials/Fusion/FusionSystemController.cs +++ b/Essentials/PepperDashEssentials/Fusion/FusionSystemController.cs @@ -34,6 +34,10 @@ namespace PepperDash.Essentials.Fusion Dictionary SourceToFeedbackSigs = new Dictionary(); + FusionOccupancySensor OccSensor; + + BooleanSigData OccupancyStatusSig; + StatusMonitorCollection ErrorMessageRollUp; StringSigData SourceNameSig; @@ -85,7 +89,7 @@ namespace PepperDash.Essentials.Fusion public long PushNotificationTimeout = 5000; - List StaticAssets; + List FusionAssets; //ScheduleResponseEvent NextMeeting; @@ -97,7 +101,7 @@ namespace PepperDash.Essentials.Fusion IpId = ipId; - StaticAssets = new List(); + FusionAssets = new List(); GUIDs = new FusionRoomGuids(); @@ -127,33 +131,34 @@ namespace PepperDash.Essentials.Fusion SetUpCommunitcationMonitors(); SetUpDisplay(); SetUpError(); - + SetUpOccupancy(); + // test assets --- THESE ARE BOTH WIRED TO AssetUsage somewhere internally. - var tempAsset1 = new StaticAsset(); - var tempAsset2 = new StaticAsset(); + //var tempAsset1 = new StaticAsset(); + //var tempAsset2 = new StaticAsset(); - //Check for existing GUID - if (GuidFileExists) - { - tempAsset1 = StaticAssets.FirstOrDefault(a => a.Number.Equals(1)); + ////Check for existing GUID + //if (GuidFileExists) + //{ + // tempAsset1 = StaticAssets.FirstOrDefault(a => a.Number.Equals(1)); - tempAsset2 = StaticAssets.FirstOrDefault(a => a.Number.Equals(2)); - } - else - { - tempAsset1 = new StaticAsset(1, "Test Asset 1", "Test Asset 1", ""); - StaticAssets.Add(tempAsset1); + // tempAsset2 = StaticAssets.FirstOrDefault(a => a.Number.Equals(2)); + //} + //else + //{ + // tempAsset1 = new StaticAsset(1, "Test Asset 1", "Test Asset 1", ""); + // StaticAssets.Add(tempAsset1); - tempAsset2 = new StaticAsset(2, "Test Asset 2", "Test Asset 2", ""); - StaticAssets.Add(tempAsset2); - } + // tempAsset2 = new StaticAsset(2, "Test Asset 2", "Test Asset 2", ""); + // StaticAssets.Add(tempAsset2); + //} - var ta1 = FusionRoom.CreateStaticAsset(tempAsset1.Number, tempAsset1.Name, tempAsset1.Type, tempAsset1.InstanceID); - ta1.AssetError.InputSig.StringValue = "This should be error"; + //var ta1 = FusionRoom.CreateStaticAsset(tempAsset1.Number, tempAsset1.Name, tempAsset1.Type, tempAsset1.InstanceID); + //ta1.AssetError.InputSig.StringValue = "This should be error"; - var ta2 = FusionRoom.CreateStaticAsset(tempAsset2.Number, tempAsset2.Name, tempAsset2.Type, tempAsset2.InstanceID); - ta2.AssetUsage.InputSig.StringValue = "This should be usage"; + //var ta2 = FusionRoom.CreateStaticAsset(tempAsset2.Number, tempAsset2.Name, tempAsset2.Type, tempAsset2.InstanceID); + //ta2.AssetUsage.InputSig.StringValue = "This should be usage"; // Make it so! FusionRVI.GenerateFileForAllFusionDevices(); @@ -184,7 +189,7 @@ namespace PepperDash.Essentials.Fusion Debug.Console(1, this, "Writing GUIDs to file"); - GUIDs = new FusionRoomGuids(Room.Name, IpId, RoomGuid, StaticAssets); + GUIDs = new FusionRoomGuids(Room.Name, IpId, RoomGuid, FusionAssets); var JSON = JsonConvert.SerializeObject(GUIDs, Newtonsoft.Json.Formatting.Indented); @@ -237,7 +242,7 @@ namespace PepperDash.Essentials.Fusion IpId = GUIDs.IpId; - StaticAssets = GUIDs.StaticAssets; + FusionAssets = GUIDs.StaticAssets; } @@ -245,7 +250,7 @@ namespace PepperDash.Essentials.Fusion Debug.Console(1, this, "\nRoom Name: {0}\nIPID: {1:x}\n RoomGuid: {2}", Room.Name, IpId, RoomGuid); - foreach (StaticAsset asset in StaticAssets) + foreach (FusionAsset asset in FusionAssets) { Debug.Console(1, this, "\nAsset Name: {0}\nAsset No: {1}\n Guid: {2}", asset.Name, asset.Number, asset.InstanceID); } @@ -823,8 +828,8 @@ namespace PepperDash.Essentials.Fusion if (usageDevice != null) { usageDevice.UsageTracker = new UsageTracking(); - - usageDevice.UsageTracker.DeviceUsageEnded += new EventHandler(UsageTracker_SourceUsageEnded); + usageDevice.UsageTracker.UsageIsTracked = true; + usageDevice.UsageTracker.DeviceUsageEnded += new EventHandler(UsageTracker_DeviceUsageEnded); } } @@ -842,25 +847,29 @@ namespace PepperDash.Essentials.Fusion /// /// /// - void UsageTracker_SourceUsageEnded(object sender, DeviceUsageEventArgs e) + void UsageTracker_DeviceUsageEnded(object sender, DeviceUsageEventArgs e) { var device = sender as Device; var configDevice = ConfigReader.ConfigObject.Devices.Where(d => d.Key.Equals(device.Key)); - string group = ""; + string group = ConfigReader.GetGroupForDeviceKey(device.Key); -#warning Figure out how to get the group value from the device config + string currentMeetingId = ""; + if (CurrentMeeting != null) + currentMeetingId = CurrentMeeting.MeetingID; - //Double check my time and date formatting in the ToString() methods + //String Format: "USAGE||[Date YYYY-MM-DD]||[Time HH-mm-ss]||TIME||[Asset_Type]||[Asset_Name]||[Minutes_used]||[Asset_ID]||[Meeting_ID]" + // [Asset_ID] property does not appear to be used in Crestron SSI examples. They are sending "-" instead so that's what is replicated here string deviceUsage = string.Format("USAGE||{0}||{1}||TIME||{2}||{3}||{4}||{5}||{6})", e.UsageEndTime.ToString("YYYY-MM-DD"), e.UsageEndTime.ToString("HH-mm-ss"), - group, device.Name, e.MinutesUsed, "asset_id", CurrentMeeting.MeetingID); + group, device.Name, e.MinutesUsed, "-", currentMeetingId); FusionRoom.DeviceUsage.InputSig.StringValue = deviceUsage; } + void TryAddRouteActionSigs(string attrName, uint attrNum, string routeKey, Device pSrc) { Debug.Console(2, this, "Creating attribute '{0}' with join {1} for source {2}", @@ -963,44 +972,59 @@ namespace PepperDash.Essentials.Fusion { //Setup Display Usage Monitoring -#warning Somehow get list of room's displays and activate Usage tracking and subscribe to event + var displays = DeviceManager.AllDevices.Where(d => d is DisplayBase); - var display = Room.DefaultDisplay as DisplayBase; - if (display == null) +#warning should work for now in single room systems but will grab all devices regardless of room assignment. In multi-room systems, this will need to be handled differently. + + foreach (DisplayBase display in displays) + { + display.UsageTracker = new UsageTracking(); + display.UsageTracker.UsageIsTracked = true; + display.UsageTracker.DeviceUsageEnded += new EventHandler(UsageTracker_DeviceUsageEnded); + } + + var defaultDisplay = Room.DefaultDisplay as DisplayBase; + if (defaultDisplay == null) { Debug.Console(1, this, "Cannot link null display to Fusion"); return; } - var dispPowerOnAction = new Action(b => { if (!b) display.PowerOn(); }); - var dispPowerOffAction = new Action(b => { if (!b) display.PowerOff(); }); + var dispPowerOnAction = new Action(b => { if (!b) defaultDisplay.PowerOn(); }); + var dispPowerOffAction = new Action(b => { if (!b) defaultDisplay.PowerOff(); }); // Display to fusion room sigs FusionRoom.DisplayPowerOn.OutputSig.UserObject = dispPowerOnAction; FusionRoom.DisplayPowerOff.OutputSig.UserObject = dispPowerOffAction; - display.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig); - if (display is IDisplayUsage) - (display as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig); + defaultDisplay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig); + if (defaultDisplay is IDisplayUsage) + (defaultDisplay as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig); // static assets --------------- testing // Make a display asset string dispAssetInstanceId; //Check for existing GUID - var tempAsset = StaticAssets.FirstOrDefault(a => a.Number.Equals(3)); + var tempAsset = FusionAssets.FirstOrDefault(a => a.Name.Equals("Display")); if(tempAsset != null) dispAssetInstanceId = tempAsset.InstanceID; else - dispAssetInstanceId = ""; + { + var nextSlotNum = FusionAssets.Count + 1; - var dispAsset = FusionRoom.CreateStaticAsset(3, display.Name, "Display", dispAssetInstanceId); + tempAsset = new FusionAsset((uint)nextSlotNum, defaultDisplay.Name, "Display", ""); + FusionAssets.Add(tempAsset); + dispAssetInstanceId = tempAsset.InstanceID; + } + + var dispAsset = FusionRoom.CreateStaticAsset(3, defaultDisplay.Name, "Display", dispAssetInstanceId); dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction; dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction; - display.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig); + defaultDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig); // NO!! display.PowerIsOn.LinkComplementInputSig(dispAsset.PowerOff.InputSig); // Use extension methods - dispAsset.TrySetMakeModel(display); - dispAsset.TryLinkAssetErrorToCommunication(display); + dispAsset.TrySetMakeModel(defaultDisplay); + dispAsset.TryLinkAssetErrorToCommunication(defaultDisplay); } void SetUpError() @@ -1025,6 +1049,33 @@ namespace PepperDash.Essentials.Fusion } + + void SetUpOccupancy() + { +#warning Add actual object logic check here + //if (Room.OccupancyObj != null) + //{ + string occAssetId; + + var tempAsset = FusionAssets.FirstOrDefault(a => a.Type.Equals("Occupancy Sensor")); + + if(tempAsset != null) + occAssetId = tempAsset.InstanceID; + else + { + var nextAssetNum = FusionAssets.Count + 1; + + tempAsset = new FusionAsset((uint)nextAssetNum, "Occupancy Sensor", "Occupancy Sensor", ""); + FusionAssets.Add(tempAsset); + occAssetId = tempAsset.InstanceID; + } + + FusionRoom.AddAsset(eAssetType.OccupancySensor, tempAsset.Number, tempAsset.Name, tempAsset.Type, tempAsset.InstanceID); + + ((FusionOccupancySensor)FusionRoom.UserConfigurableAssetDetails[tempAsset.Number].Asset).RoomOccupied.InputSig = OccupancyStatusSig; + //} + } + /// /// Helper to get the number from the end of a device's key string /// diff --git a/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo b/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo index 53797766..9a443a5c 100644 Binary files a/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo and b/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo differ diff --git a/Release Package/PepperDashEssentials.cpz b/Release Package/PepperDashEssentials.cpz index 12d9c516..75245f1a 100644 Binary files a/Release Package/PepperDashEssentials.cpz and b/Release Package/PepperDashEssentials.cpz differ diff --git a/Release Package/PepperDashEssentials.dll b/Release Package/PepperDashEssentials.dll index ae0efbfe..a1f985b5 100644 Binary files a/Release Package/PepperDashEssentials.dll and b/Release Package/PepperDashEssentials.dll differ