Started working on Room Occupancy

This commit is contained in:
Neil Dorin
2017-10-03 23:34:23 -06:00
parent e6eafdaf14
commit c3c7948990
9 changed files with 157 additions and 7 deletions

View File

@@ -142,6 +142,7 @@
<Compile Include="Feedbacks\BoolFeedbackOneShot.cs" />
<Compile Include="Ramps and Increments\NumericalHelpers.cs" />
<Compile Include="Ramps and Increments\UshortSigIncrementer.cs" />
<Compile Include="Room\iHasOccupancyAwareness.cs" />
<Compile Include="Routing\ICardPortsDevice.cs" />
<Compile Include="InUseTracking\IInUseTracking.cs" />
<Compile Include="InUseTracking\InUseTracking.cs" />

View File

@@ -16,7 +16,7 @@ namespace PepperDash.Essentials.Core
{
public abstract BoolFeedback RoomIsOnFeedback { get; protected set; }
public abstract BoolFeedback IsCoolingDownFeedback { get; protected set; }
public abstract BoolFeedback IsWarmingUpFeedback { get; protected set; }
public abstract BoolFeedback IsWarmingUpFeedback { get; protected set; }
// In concrete classes, these should be computed from the relevant devices
public virtual uint CooldownTime { get { return 10000; } }

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.GeneralIO;
namespace PepperDash.Essentials.Core.Room
{
public interface IHasOccupancyAwareness
{
OccupancyStatus RoomOccupancy { get; }
}
public class OccupancyStatus
{
BoolFeedback RoomIsOccupied { get; }
}
}

View File

@@ -6,6 +6,15 @@ using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.Codec
{
public enum eMeetingEventChangeType
{
Unkown = 0,
MeetingStartWarning,
MeetingStart,
MeetingEndWarning,
MeetingEnd
}
public interface IHasScheduleAwareness
{
CodecScheduleAwareness CodecSchedule { get; }
@@ -13,11 +22,70 @@ namespace PepperDash.Essentials.Devices.Common.Codec
public class CodecScheduleAwareness
{
public List<Meeting> Meetings { get; set; }
List<Meeting> _Meetings;
public event EventHandler<MeetingEventArgs> MeetingEventChange;
public event EventHandler<EventArgs> MeetingsListHasChanged;
public List<Meeting> Meetings
{
get
{
return _Meetings;
}
set
{
_Meetings = value;
var handler = MeetingsListHasChanged;
if (handler != null)
{
handler(this, new EventArgs());
}
}
}
private CTimer ScheduleChecker;
public CodecScheduleAwareness()
{
Meetings = new List<Meeting>();
ScheduleChecker = new CTimer(CheckSchedule, null, 1000, 1000);
}
private void OnMeetingChange(eMeetingEventChangeType changeType, Meeting meeting)
{
var handler = MeetingEventChange;
if (handler != null)
{
handler(this, new MeetingEventArgs() { ChangeType = changeType, Meeting = meeting });
}
}
private void CheckSchedule(object o)
{
// Iterate the meeting list and check if any meeting need to do anythingk
foreach (Meeting m in Meetings)
{
eMeetingEventChangeType changeType = eMeetingEventChangeType.Unkown;
if (m.TimeToMeetingStart.TotalMinutes == m.MeetingWarningMinutes.TotalMinutes) // Meeting is about to start
changeType = eMeetingEventChangeType.MeetingStartWarning;
else if (m.TimeToMeetingStart.TotalMinutes == 0) // Meeting Start
changeType = eMeetingEventChangeType.MeetingStart;
else if (m.TimeToMeetingEnd.TotalMinutes == m.MeetingWarningMinutes.TotalMinutes) // Meeting is about to end
changeType = eMeetingEventChangeType.MeetingEndWarning;
else if (m.TimeToMeetingEnd.TotalMinutes == 0) // Meeting has ended
changeType = eMeetingEventChangeType.MeetingEnd;
if (changeType != eMeetingEventChangeType.Unkown)
OnMeetingChange(changeType, m);
}
}
}
@@ -26,10 +94,26 @@ namespace PepperDash.Essentials.Devices.Common.Codec
/// </summary>
public class Meeting
{
public TimeSpan MeetingWarningMinutes = TimeSpan.FromMinutes(5);
public string Id { get; set; }
public string Organizer { get; set; }
public string Title { get; set; }
public string Agenda { get; set; }
public TimeSpan TimeToMeetingStart
{
get
{
return StartTime - DateTime.Now;
}
}
public TimeSpan TimeToMeetingEnd
{
get
{
return EndTime - DateTime.Now;
}
}
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public TimeSpan Duration
@@ -44,11 +128,18 @@ namespace PepperDash.Essentials.Devices.Common.Codec
{
get
{
return StartTime.AddMinutes(-5) <= DateTime.Now
&& DateTime.Now <= EndTime.AddMinutes(-5);
return StartTime.AddMinutes(-5) <= DateTime.Now
&& DateTime.Now <= EndTime.AddMinutes(-5);
}
}
public string ConferenceNumberToDial { get; set; }
public string ConferencePassword { get; set; }
}
}
public class MeetingEventArgs : EventArgs
{
public eMeetingEventChangeType ChangeType { get; set; }
public Meeting Meeting { get; set; }
}
}

View File

@@ -130,6 +130,8 @@
<Compile Include="DSP\PolycomSoundStructure\SoundStructureBasics.cs" />
<Compile Include="Factory\DeviceFactory.cs" />
<Compile Include="Generic\GenericSource.cs" />
<Compile Include="Occupancy\GlsOirCsmExBatt.cs" />
<Compile Include="Occupancy\iOccupancyStatusProvider.cs" />
<Compile Include="PC\InRoomPc.cs" />
<Compile Include="PC\Laptop.cs" />
<Compile Include="SetTopBox\SetTopBoxPropertiesConfig.cs" />

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro.GeneralIO;
namespace PepperDash.Essentials.Devices.Common.Occupancy
{
public class EssentialsGlsOirCsmExBatt : GlsOccupancySensorBase, IOccupancyStatusProvider
{
public GlsOirCsmExBatt OccSensor { get; set; }
}
}

View File

@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Devices.Common.Occupancy
{
public interface IOccupancyStatusProvider
{
// Need to define a common interface that can be applied to Crestron Occ sensor as well as 3rd party devices. How to accomplish?
}
}

View File

@@ -288,8 +288,6 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec
meetings.OrderBy(m => m.StartTime);
return meetings;
}
}

View File

@@ -6,6 +6,7 @@ using Crestron.SimplSharp;
using Crestron.SimplSharp.Net.Https;
using Crestron.SimplSharp.CrestronXml;
using Crestron.SimplSharp.CrestronXml.Serialization;
//using Crestron.SimplSharpPro;
using Newtonsoft.Json;
using Cisco_One_Button_To_Push;
using Cisco_SX80_Corporate_Phone_Book;
@@ -34,6 +35,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
public BoolFeedback RoomIsOccupiedFeedback { get; private set; }
//public BoolOutputSig OccupancyDetectedFeedback { get; private set; }
public IntFeedback PeopleCountFeedback { get; private set; }
public BoolFeedback SpeakerTrackIsOnFeedback { get; private set; }
@@ -628,6 +631,8 @@ namespace PepperDash.Essentials.Devices.Common.VideoCodec.Cisco
JsonConvert.PopulateObject(response, codecBookings);
CodecSchedule.Meetings = CiscoCodecBookings.GetGenericMeetingsFromBookingResult(codecBookings.CommandResponse.BookingsListResult.Booking);
}
}