diff --git a/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs b/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs index 787dc4bf..1dbc123d 100644 --- a/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs +++ b/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; +using PepperDash.Core; namespace PepperDash.Essentials.Core { @@ -70,6 +71,7 @@ namespace PepperDash.Essentials.Core if (handler != null) { + Debug.Console(1, "Device Usage Ended at {1}. In use for {2} minutes.", UsageEndTime, timeUsed.Minutes); handler(this, new DeviceUsageEventArgs() { UsageEndTime = UsageEndTime, MinutesUsed = timeUsed.Minutes }); } } diff --git a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.projectinfo index ecc278b2..d9525b84 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 c4d11a27..15dcf81a 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 06c175c7..2ce48f02 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 Devices Common/Essentials Devices Common/Generic/GenericSource.cs b/Essentials Devices Common/Essentials Devices Common/Generic/GenericSource.cs index bb6d4300..145fd41c 100644 --- a/Essentials Devices Common/Essentials Devices Common/Generic/GenericSource.cs +++ b/Essentials Devices Common/Essentials Devices Common/Generic/GenericSource.cs @@ -1,36 +1,42 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using Crestron.SimplSharp; -using Crestron.SimplSharpPro; -using Crestron.SimplSharpPro.DeviceSupport; - -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Routing; - -namespace PepperDash.Essentials.Devices.Common -{ - public class GenericSource : Device, IUiDisplayInfo, IRoutingOutputs - { - - public uint DisplayUiType { get { return DisplayUiConstants.TypeNoControls; } } - - public GenericSource(string key, string name) - : base(key, name) - { - - AnyOut = new RoutingOutputPort(RoutingPortNames.AnyOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.Hdmi, null, this); - OutputPorts = new RoutingPortCollection { AnyOut }; - } - - #region IRoutingOutputs Members - - public RoutingOutputPort AnyOut { get; private set; } - public RoutingPortCollection OutputPorts { get; private set; } - - #endregion - } +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; + +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Routing; + +namespace PepperDash.Essentials.Devices.Common +{ + public class GenericSource : Device, IUiDisplayInfo, IRoutingOutputs, IUsageTracking + { + + public uint DisplayUiType { get { return DisplayUiConstants.TypeNoControls; } } + + public GenericSource(string key, string name) + : base(key, name) + { + + AnyOut = new RoutingOutputPort(RoutingPortNames.AnyOut, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.Hdmi, null, this); + OutputPorts = new RoutingPortCollection { AnyOut }; + } + + #region IRoutingOutputs Members + + public RoutingOutputPort AnyOut { get; private set; } + public RoutingPortCollection OutputPorts { get; private set; } + + #endregion + + #region IUsageTracking Members + + public UsageTracking UsageTracker { get; set; } + + #endregion + } } \ No newline at end of file diff --git a/Essentials Devices Common/Essentials Devices Common/PC/Laptop.cs b/Essentials Devices Common/Essentials Devices Common/PC/Laptop.cs index e8a67705..5250cc58 100644 --- a/Essentials Devices Common/Essentials Devices Common/PC/Laptop.cs +++ b/Essentials Devices Common/Essentials Devices Common/PC/Laptop.cs @@ -1,61 +1,61 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using Crestron.SimplSharpPro; - -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Routing; -using PepperDash.Core; - -namespace PepperDash.Essentials.Devices.Common -{ - /// - /// This DVD class should cover most IR, one-way DVD and Bluray fuctions - /// - public class Laptop : Device, IHasFeedback, IRoutingOutputs, IAttachVideoStatus, IUiDisplayInfo, IUsageTracking - { - public uint DisplayUiType { get { return DisplayUiConstants.TypeLaptop; } } - public string IconName { get; set; } - public BoolFeedback HasPowerOnFeedback { get; private set; } - - public RoutingOutputPort AnyVideoOut { get; private set; } - - #region IRoutingOutputs Members - - /// - /// Options: hdmi - /// - public RoutingPortCollection OutputPorts { get; private set; } - - #endregion - - public Laptop(string key, string name) - : base(key, name) - { - IconName = "Laptop"; - HasPowerOnFeedback = new BoolFeedback(CommonBoolCue.HasPowerFeedback, - () => this.GetVideoStatuses() != VideoStatusOutputs.NoStatus); - OutputPorts = new RoutingPortCollection(); - OutputPorts.Add(AnyVideoOut = new RoutingOutputPort(RoutingPortNames.AnyOut, eRoutingSignalType.AudioVideo, - eRoutingPortConnectionType.None, 0, this)); - } - - #region IHasFeedback Members - - /// - /// Passes through the VideoStatuses list - /// - public List Feedbacks - { - get { return this.GetVideoStatuses().ToList(); } - } - +using System; +using System.Collections.Generic; +using System.Linq; +using Crestron.SimplSharpPro; + +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Routing; +using PepperDash.Core; + +namespace PepperDash.Essentials.Devices.Common +{ + /// + /// This DVD class should cover most IR, one-way DVD and Bluray fuctions + /// + public class Laptop : Device, IHasFeedback, IRoutingOutputs, IAttachVideoStatus, IUiDisplayInfo, IUsageTracking + { + public uint DisplayUiType { get { return DisplayUiConstants.TypeLaptop; } } + public string IconName { get; set; } + public BoolFeedback HasPowerOnFeedback { get; private set; } + + public RoutingOutputPort AnyVideoOut { get; private set; } + + #region IRoutingOutputs Members + + /// + /// Options: hdmi + /// + public RoutingPortCollection OutputPorts { get; private set; } + + #endregion + + public Laptop(string key, string name) + : base(key, name) + { + IconName = "Laptop"; + HasPowerOnFeedback = new BoolFeedback(CommonBoolCue.HasPowerFeedback, + () => this.GetVideoStatuses() != VideoStatusOutputs.NoStatus); + OutputPorts = new RoutingPortCollection(); + OutputPorts.Add(AnyVideoOut = new RoutingOutputPort(RoutingPortNames.AnyOut, eRoutingSignalType.AudioVideo, + eRoutingPortConnectionType.None, 0, this)); + } + + #region IHasFeedback Members + + /// + /// Passes through the VideoStatuses list + /// + public List Feedbacks + { + get { return this.GetVideoStatuses().ToList(); } + } + #endregion #region IUsageTracking Members public UsageTracking UsageTracker { get; set; } - #endregion - } + #endregion + } } \ No newline at end of file diff --git a/Essentials/PepperDashEssentials/Fusion/FusionProcessorQueries.cs b/Essentials/PepperDashEssentials/Fusion/FusionProcessorQueries.cs new file mode 100644 index 00000000..9781fe08 --- /dev/null +++ b/Essentials/PepperDashEssentials/Fusion/FusionProcessorQueries.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using PepperDash.Core; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Fusion +{ + /// + /// When created, runs progcomments on every slot and stores the program names in a list + /// + public class ProcessorProgReg + { + //public static Dictionary Programs { get; private set; } + + public static Dictionary GetProcessorProgReg() + { + var programs = new Dictionary(); + for (int i = 1; i <= Global.ControlSystem.NumProgramsSupported; i++) + { + string response = null; + var success = CrestronConsole.SendControlSystemCommand("progcomments:" + i, ref response); + var item = new ProcessorProgramItem(); + if (!success) + item.Name = "Error: PROGCOMMENTS failed"; + else + { + if (response.ToLower().Contains("bad or incomplete")) + item.Name = ""; + else + { + var startPos = response.IndexOf("Program File"); + var colonPos = response.IndexOf(":", startPos) + 1; + var endPos = response.IndexOf(CrestronEnvironment.NewLine, colonPos); + item.Name = response.Substring(colonPos, endPos - colonPos).Trim(); + item.Exists = true; + if (item.Name.Contains(".dll")) + { + startPos = response.IndexOf("Compiler Revision"); + colonPos = response.IndexOf(":", startPos) + 1; + endPos = response.IndexOf(CrestronEnvironment.NewLine, colonPos); + item.Name = item.Name + "_v" + response.Substring(colonPos, endPos - colonPos).Trim(); + } + } + } + programs[i] = item; + Debug.Console(1, "Program {0}: {1}", i, item.Name); + } + return programs; + } + } + + /// + /// Used in ProcessorProgReg + /// + public class ProcessorProgramItem + { + public bool Exists { get; set; } + public string Name { get; set; } + } +} \ No newline at end of file diff --git a/Essentials/PepperDashEssentials/Fusion/FusionSystemController.cs b/Essentials/PepperDashEssentials/Fusion/FusionSystemController.cs index 9c871c07..895a4c04 100644 --- a/Essentials/PepperDashEssentials/Fusion/FusionSystemController.cs +++ b/Essentials/PepperDashEssentials/Fusion/FusionSystemController.cs @@ -38,10 +38,17 @@ namespace PepperDash.Essentials.Fusion StatusMonitorCollection ErrorMessageRollUp; - StringSigData SourceNameSig; + StringSigData CurrentRoomSourceNameSig; - //ProcessorEthernet Info -#region + #region System Info Sigs + StringSigData SystemName; + StringSigData Model; + StringSigData SerialNumber; + StringSigData Uptime; + #endregion + + + #region Processor Info Sigs StringSigData Ip1; StringSigData Ip2; StringSigData Gateway; @@ -53,7 +60,16 @@ namespace PepperDash.Essentials.Fusion StringSigData Mac2; StringSigData NetMask1; StringSigData NetMask2; -#endregion + StringSigData Firmware; + + StringSigData[] Program = new StringSigData[10]; + #endregion + + #region Default Display Source Sigs + + BooleanSigData[] Source = new BooleanSigData[10]; + + #endregion RoomSchedule CurrentSchedule; @@ -131,33 +147,6 @@ namespace PepperDash.Essentials.Fusion SetUpError(); SetUpOccupancy(); - // test assets --- THESE ARE BOTH WIRED TO AssetUsage somewhere internally. - //var tempAsset1 = new StaticAsset(); - //var tempAsset2 = new StaticAsset(); - - - ////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 = 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 ta2 = FusionRoom.CreateStaticAsset(tempAsset2.Number, tempAsset2.Name, tempAsset2.Type, tempAsset2.InstanceID); - //ta2.AssetUsage.InputSig.StringValue = "This should be usage"; - // Make it so! FusionRVI.GenerateFileForAllFusionDevices(); @@ -287,7 +276,9 @@ namespace PepperDash.Essentials.Fusion // Room to fusion room Room.OnFeedback.LinkInputSig(FusionRoom.SystemPowerOn.InputSig); - SourceNameSig = FusionRoom.CreateOffsetStringSig(84, "Source - Name", eSigIoMask.InputSigOnly); + + // Moved to + CurrentRoomSourceNameSig = FusionRoom.CreateOffsetStringSig(84, "Display 1 - Current Source", eSigIoMask.InputSigOnly); // Don't think we need to get current status of this as nothing should be alive yet. Room.CurrentSingleSourceChange += new SourceInfoChangeHandler(Room_CurrentSourceInfoChange); @@ -298,25 +289,9 @@ namespace PepperDash.Essentials.Fusion FusionRoom.ErrorMessage.InputSig.StringValue = "3: 7 Errors: This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;"; - // Processor Info + GetProcessorEthernetValues(); - FusionRoom.CreateOffsetStringSig(50, "Info - Processor - System Name", eSigIoMask.InputSigOnly); - FusionRoom.CreateOffsetStringSig(51, "Info - Processor - Model", eSigIoMask.InputSigOnly); - FusionRoom.CreateOffsetStringSig(52, "Info - Processor - Serial Number", eSigIoMask.InputSigOnly); - FusionRoom.CreateOffsetStringSig(53, "Info - Processor - Uptime", eSigIoMask.InputSigOnly); - Ip1 = FusionRoom.CreateOffsetStringSig(54, "Info - Processor - IP 1", eSigIoMask.InputSigOnly); - Ip2 = FusionRoom.CreateOffsetStringSig(55, "Info - Processor - IP 2", eSigIoMask.InputSigOnly); - Gateway = FusionRoom.CreateOffsetStringSig(56, "Info - Processor - Gateway", eSigIoMask.InputSigOnly); - Hostname = FusionRoom.CreateOffsetStringSig(57, "Info - Processor - Hostname", eSigIoMask.InputSigOnly); - Domain = FusionRoom.CreateOffsetStringSig(58, "Info - Processor - Domain", eSigIoMask.InputSigOnly); - Dns1 = FusionRoom.CreateOffsetStringSig(59, "Info - Processor - DNS 1", eSigIoMask.InputSigOnly); - Dns2 = FusionRoom.CreateOffsetStringSig(60, "Info - Processor - DNS 2", eSigIoMask.InputSigOnly); - Mac1 = FusionRoom.CreateOffsetStringSig(61, "Info - Processor - MAC 1", eSigIoMask.InputSigOnly); - Mac2 = FusionRoom.CreateOffsetStringSig(62, "Info - Processor - MAC 2", eSigIoMask.InputSigOnly); - NetMask1 = FusionRoom.CreateOffsetStringSig(63, "Info - Processor - Net Mask 1", eSigIoMask.InputSigOnly); - NetMask2 = FusionRoom.CreateOffsetStringSig(64, "Info - Processor - Net Mask 2", eSigIoMask.InputSigOnly); - - SetProcessorEthernetValues(); + GetProcessorInfo(); CrestronEnvironment.EthernetEventHandler += new EthernetEventHandler(CrestronEnvironment_EthernetEventHandler); } @@ -325,14 +300,33 @@ namespace PepperDash.Essentials.Fusion { if (ethernetEventArgs.EthernetEventType == eEthernetEventType.LinkUp) { - SetProcessorEthernetValues(); + GetProcessorEthernetValues(); } } - void SetProcessorEthernetValues() + void GetSystemInfo() { + SystemName.InputSig.StringValue = Room.Name; + Model.InputSig.StringValue = InitialParametersClass.ControllerPromptName; + //SerialNumber.InputSig.StringValue = InitialParametersClass. + } + + void GetProcessorEthernetValues() + { + Ip1 = FusionRoom.CreateOffsetStringSig(50, "Info - Processor - IP 1", eSigIoMask.InputSigOnly); + Ip2 = FusionRoom.CreateOffsetStringSig(51, "Info - Processor - IP 2", eSigIoMask.InputSigOnly); + Gateway = FusionRoom.CreateOffsetStringSig(52, "Info - Processor - Gateway", eSigIoMask.InputSigOnly); + Hostname = FusionRoom.CreateOffsetStringSig(53, "Info - Processor - Hostname", eSigIoMask.InputSigOnly); + Domain = FusionRoom.CreateOffsetStringSig(54, "Info - Processor - Domain", eSigIoMask.InputSigOnly); + Dns1 = FusionRoom.CreateOffsetStringSig(55, "Info - Processor - DNS 1", eSigIoMask.InputSigOnly); + Dns2 = FusionRoom.CreateOffsetStringSig(56, "Info - Processor - DNS 2", eSigIoMask.InputSigOnly); + Mac1 = FusionRoom.CreateOffsetStringSig(57, "Info - Processor - MAC 1", eSigIoMask.InputSigOnly); + Mac2 = FusionRoom.CreateOffsetStringSig(58, "Info - Processor - MAC 2", eSigIoMask.InputSigOnly); + NetMask1 = FusionRoom.CreateOffsetStringSig(59, "Info - Processor - Net Mask 1", eSigIoMask.InputSigOnly); + NetMask2 = FusionRoom.CreateOffsetStringSig(60, "Info - Processor - Net Mask 2", eSigIoMask.InputSigOnly); + + // Interface =0 Ip1.InputSig.StringValue = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 0); - Ip2.InputSig.StringValue = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 1); Gateway.InputSig.StringValue = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_ROUTER, 0); Hostname.InputSig.StringValue = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_HOSTNAME, 0); Domain.InputSig.StringValue = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_DOMAIN_NAME, 0); @@ -343,9 +337,51 @@ namespace PepperDash.Essentials.Fusion Dns2.InputSig.StringValue = dnsServers[1]; Mac1.InputSig.StringValue = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, 0); - Mac2.InputSig.StringValue = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, 1); NetMask1.InputSig.StringValue = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, 0); - NetMask2.InputSig.StringValue = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, 1); + + // Interface 1 + + if (InitialParametersClass.NumberOfEthernetInterfaces > 1) // Only get these values if the processor has more than 1 NIC + { + Ip2.InputSig.StringValue = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_ADDRESS, 1); + Mac2.InputSig.StringValue = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_MAC_ADDRESS, 1); + NetMask2.InputSig.StringValue = CrestronEthernetHelper.GetEthernetParameter(CrestronEthernetHelper.ETHERNET_PARAMETER_TO_GET.GET_CURRENT_IP_MASK, 1); + } + } + + void GetProcessorInfo() + { + //SystemName = FusionRoom.CreateOffsetStringSig(50, "Info - Processor - System Name", eSigIoMask.InputSigOnly); + //Model = FusionRoom.CreateOffsetStringSig(51, "Info - Processor - Model", eSigIoMask.InputSigOnly); + //SerialNumber = FusionRoom.CreateOffsetStringSig(52, "Info - Processor - Serial Number", eSigIoMask.InputSigOnly); + //Uptime = FusionRoom.CreateOffsetStringSig(53, "Info - Processor - Uptime", eSigIoMask.InputSigOnly); + + Firmware = FusionRoom.CreateOffsetStringSig(61, "Info - Processor - Firmware", eSigIoMask.InputSigOnly); + + for (int i = 0; i < Global.ControlSystem.NumProgramsSupported; i++) + { + var join = 62 + i; + var progNum = i + 1; + Program[i] = FusionRoom.CreateOffsetStringSig((uint)join, string.Format("Info - Processor - Program {0}", progNum), eSigIoMask.InputSigOnly); + } + + Firmware.InputSig.StringValue = InitialParametersClass.FirmwareVersion; + + var programs = ProcessorProgReg.GetProcessorProgReg(); + + for (int i = 1; i < Global.ControlSystem.NumProgramsSupported; i++) + { + var join = 62 + i; + var progNum = i + 1; + if (programs[i].Exists) + Program[i].InputSig.StringValue = programs[i].Name; + } + + } + + void GetTouchpanelInfo() + { + // TODO Get IP and Project Name from TP } void FusionRoom_OnlineStatusChange(GenericBase currentDevice, OnlineOfflineEventArgs args) @@ -818,7 +854,6 @@ namespace PepperDash.Essentials.Fusion break; } - foreach (var kvp in dict) { var usageDevice = kvp.Value.SourceDevice as IUsageTracking; @@ -839,7 +874,6 @@ namespace PepperDash.Essentials.Fusion } } - /// /// Collects usage data from source and sends to Fusion /// @@ -861,8 +895,9 @@ namespace PepperDash.Essentials.Fusion //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, "-", currentMeetingId); + group, device.Name, e.MinutesUsed, "-", currentMeetingId); + Debug.Console(1, this, "Device usage for: {0} ended at {1}. In use for {2} minutes", device.Name, e.UsageEndTime, e.MinutesUsed); FusionRoom.DeviceUsage.InputSig.StringValue = deviceUsage; } @@ -926,7 +961,7 @@ namespace PepperDash.Essentials.Fusion { if (attrNum > 10) continue; - attrName = "Online - Touch Panel " + attrNum; + attrName = "Online - XPanel " + attrNum; attrNum += 160; #warning should this be 160 } @@ -998,6 +1033,12 @@ namespace PepperDash.Essentials.Fusion if (defaultDisplay is IDisplayUsage) (defaultDisplay as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig); + + + MapDisplayToRoomJoins(1, 158, defaultDisplay); + + //Room.CurrentSingleSourceChange += new SourceInfoChangeHandler(Room_CurrentSingleSourceChange); + // static assets --------------- testing // Make a display asset string dispAssetInstanceId; @@ -1008,14 +1049,14 @@ namespace PepperDash.Essentials.Fusion dispAssetInstanceId = tempAsset.InstanceID; else { - var nextSlotNum = FusionAssets.Count + 1; + var nextSlotNum = FusionAssets.Count + 3; //Account for slot number offset tempAsset = new FusionAsset((uint)nextSlotNum, defaultDisplay.Name, "Display", ""); FusionAssets.Add(tempAsset); dispAssetInstanceId = tempAsset.InstanceID; } - var dispAsset = FusionRoom.CreateStaticAsset(3, defaultDisplay.Name, "Display", dispAssetInstanceId); + var dispAsset = FusionRoom.CreateStaticAsset(tempAsset.Number, defaultDisplay.Name, "Display", dispAssetInstanceId); dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction; dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction; defaultDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig); @@ -1023,8 +1064,63 @@ namespace PepperDash.Essentials.Fusion // Use extension methods dispAsset.TrySetMakeModel(defaultDisplay); dispAsset.TryLinkAssetErrorToCommunication(defaultDisplay); + + } + /// + /// Maps room attributes to a display at a specified index + /// + /// + /// + void MapDisplayToRoomJoins(int displayIndex, int joinOffset, DisplayBase display) + { + string displayName = string.Format("Display {0} - ", displayIndex); + + var defaultDisplayPowerOn = FusionRoom.CreateOffsetBoolSig((uint)joinOffset, displayIndex + "Power On", eSigIoMask.InputOutputSig); + defaultDisplayPowerOn.OutputSig.UserObject = new Action(b => { if (!b) display.PowerOn(); }); + display.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig); + + var defaultDisplayPowerOff = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 1, displayIndex + "Power Off", eSigIoMask.InputOutputSig); + defaultDisplayPowerOn.OutputSig.UserObject = new Action(b => { if (!b) display.PowerOff(); }); ; + display.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig); + + if(display == Room.DefaultDisplay) + { + var defaultDisplaySourceNone = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 8, displayIndex + "Source None", eSigIoMask.InputOutputSig); + defaultDisplaySourceNone.OutputSig.UserObject = new Action(b => { if (!b) Room.RunRouteAction("$off"); }); ; + display.PowerIsOnFeedback.LinkInputSig(defaultDisplaySourceNone.InputSig); + + var dict = ConfigReader.ConfigObject.GetSourceListForKey(Room.SourceListKey); + + foreach (var item in dict) + { + if(item.Key != "roomOff") + { + var defaultDisplaySource = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + (uint)item.Value.Order + 9 , string.Format("{0}Source {1}", displayIndex, item.Value.Order), eSigIoMask.InputOutputSig); + defaultDisplaySource.OutputSig.UserObject = new Action(b => { if (!b) Room.RunRouteAction(item.Value.SourceKey); }); ; + +#warning Figure out how to link these sigs together + //defaultDisplaySource.InputSig = Source[item.Value.Order].InputSig; + } + + } + } + } + + //void Room_CurrentSingleSourceChange(EssentialsRoomBase room, SourceListItem info, ChangeType type) + //{ + // for (int i = 1; i <= Source.Length; i++) + // { + // Source[i].InputSig.BoolValue = false; + // } + + // Source[info.Order].InputSig.BoolValue = true; + + // // Need to check for current source key against source list and update Source[] BooleanSigData as appropriate + + //} + void SetUpError() { // Roll up ALL device errors @@ -1047,12 +1143,12 @@ 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")); @@ -1061,16 +1157,19 @@ namespace PepperDash.Essentials.Fusion occAssetId = tempAsset.InstanceID; else { - var nextAssetNum = FusionAssets.Count + 1; + var nextAssetNum = FusionAssets.Count + 3; //Account for slot number offset 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); + var occSensorAsset = FusionRoom.CreateOccupancySensorAsset(tempAsset.Number, tempAsset.Name, tempAsset.Type, occAssetId); + //FusionRoom.AddAsset(eAssetType.OccupancySensor, tempAsset.Number, tempAsset.Name, tempAsset.Type, tempAsset.InstanceID); - ((FusionOccupancySensor)FusionRoom.UserConfigurableAssetDetails[tempAsset.Number].Asset).RoomOccupied.InputSig.BoolValue = OccupancyStatusSig.InputSig.BoolValue; + occSensorAsset.RoomOccupied.AddSigToRVIFile = true; + + // use Room.OccObject.RoomOccupiedFeedback.LinkInputSig(occSensorAsset.InputSig); //} } @@ -1106,7 +1205,7 @@ namespace PepperDash.Essentials.Fusion if (SourceToFeedbackSigs.ContainsKey(dev)) SourceToFeedbackSigs[dev].BoolValue = true; var name = (room == null ? "" : room.Name); - SourceNameSig.InputSig.StringValue = name; + CurrentRoomSourceNameSig.InputSig.StringValue = info.SourceDevice.Name; } } @@ -1196,14 +1295,19 @@ namespace PepperDash.Essentials.Fusion /// the new asset public static FusionStaticAsset CreateStaticAsset(this FusionRoom fr, uint number, string name, string type, string instanceId) { - //if(string.IsNullOrEmpty(instanceId)) - // instanceId = Guid.NewGuid().ToString(); - - Debug.Console(0, "Creating Fusion Static Asset '{0}' with GUID: '{1}'", name, instanceId); + Debug.Console(0, "Adding Fusion Static Asset '{0}' to slot {1} with GUID: '{2}'", name, number, instanceId); fr.AddAsset(eAssetType.StaticAsset, number, name, type, instanceId); return fr.UserConfigurableAssetDetails[number].Asset as FusionStaticAsset; } + + public static FusionOccupancySensor CreateOccupancySensorAsset(this FusionRoom fr, uint number, string name, string type, string instanceId) + { + Debug.Console(0, "Adding Fusion Occupancy Sensor Asset '{0}' to slot {1} with GUID: '{2}'", name, number, instanceId); + + fr.AddAsset(eAssetType.OccupancySensor, number, name, type, instanceId); + return fr.UserConfigurableAssetDetails[number].Asset as FusionOccupancySensor; + } } //************************************************************************************************ diff --git a/Essentials/PepperDashEssentials/PepperDashEssentials.csproj b/Essentials/PepperDashEssentials/PepperDashEssentials.csproj index fc5a780d..3a68cb03 100644 --- a/Essentials/PepperDashEssentials/PepperDashEssentials.csproj +++ b/Essentials/PepperDashEssentials/PepperDashEssentials.csproj @@ -135,6 +135,7 @@ + diff --git a/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo b/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo index 55a574dd..0b015bec 100644 Binary files a/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo and b/Essentials/PepperDashEssentials/PepperDashEssentials.projectinfo differ diff --git a/Essentials/PepperDashEssentials/Room/EssentialsHuddleSpaceRoom.cs b/Essentials/PepperDashEssentials/Room/EssentialsHuddleSpaceRoom.cs index 4900992f..372c6cbf 100644 --- a/Essentials/PepperDashEssentials/Room/EssentialsHuddleSpaceRoom.cs +++ b/Essentials/PepperDashEssentials/Room/EssentialsHuddleSpaceRoom.cs @@ -191,6 +191,15 @@ namespace PepperDash.Essentials Debug.Console(2, this, "Action {0} has {1} steps", item.SourceKey, item.RouteList.Count); + // End usage timer on last source + if (!string.IsNullOrEmpty(LastSourceKey)) + { + var lastSource = dict[LastSourceKey].SourceDevice; + + if (lastSource != null && lastSource is IUsageTracking) + (lastSource as IUsageTracking).UsageTracker.EndDeviceUsage(); + } + // Let's run it if (routeKey.ToLower() != "roomoff") { @@ -227,6 +236,13 @@ namespace PepperDash.Essentials DoRoute(route); } + // Start usage timer on routed source + if (item.SourceDevice is IUsageTracking) + { + (item.SourceDevice as IUsageTracking).UsageTracker.StartDeviceUsage(); + } + + // Set volume control on room, using default if non provided IBasicVolumeControls volDev = null; // Handle special cases for volume control diff --git a/Release Package/PepperDashEssentials.cpz b/Release Package/PepperDashEssentials.cpz index 8e4d7c9e..36989beb 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 32965362..81fd25d7 100644 Binary files a/Release Package/PepperDashEssentials.dll and b/Release Package/PepperDashEssentials.dll differ