Skip to content

Commit

Permalink
feat: adds IMobileControlTouchpanelController to MobileControlTouchpa…
Browse files Browse the repository at this point in the history
…nelController. Adds IShutdownPromptTimer
  • Loading branch information
ndorin committed Apr 26, 2024
1 parent a56f4ce commit bd78380
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 7 deletions.
8 changes: 8 additions & 0 deletions 3-series/MobileControlSystemController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,14 @@ private void SetupDefaultRoomMessengers()

AddDefaultDeviceMessenger(techPasswordMessenger);
}

if (room is IShutdownPromptTimer)
{
var shutdownPromptTimerMessenger = new IShutdownPromptTimerMessenger($"{room.Key}-shutdownPromptTimer-{Key}",
string.Format("/room/{0}", room.Key), room as IShutdownPromptTimer);

AddDefaultDeviceMessenger(shutdownPromptTimerMessenger);
}
}
}

Expand Down
3 changes: 0 additions & 3 deletions 3-series/RoomBridges/MobileControlEssentialsRoomBridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
using PepperDash.Essentials.Core.Shades;





#if SERIES4
using PepperDash.Essentials.AppServer;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@

namespace PepperDash.Essentials.Devices.Common.TouchPanel
{
public class MobileControlTouchpanelController : TouchpanelBase, IHasFeedback, ITswAppControl, ITswZoomControl, IDeviceInfoProvider
//public interface IMobileControlTouchpanelController
//{
// StringFeedback AppUrlFeedback { get; }
// string DefaultRoomKey { get; }
// string DeviceKey { get; }
//}


public class MobileControlTouchpanelController : TouchpanelBase, IHasFeedback, ITswAppControl, ITswZoomControl, IDeviceInfoProvider, IMobileControlTouchpanelController
{
private readonly MobileControlTouchpanelProperties localConfig;
private IMobileControlRoomMessenger _bridge;

private readonly StringFeedback AppUrlFeedback;
public StringFeedback AppUrlFeedback { get; private set; }
private readonly StringFeedback QrCodeUrlFeedback;
private readonly StringFeedback McServerUrlFeedback;
private readonly StringFeedback UserCodeFeedback;
Expand All @@ -47,6 +55,8 @@ public class MobileControlTouchpanelController : TouchpanelBase, IHasFeedback, I

public string DefaultRoomKey => _config.DefaultRoomKey;

public string DeviceKey => localConfig.DeviceKey;

public bool UseDirectServer => localConfig.UseDirectServer;

public bool ZoomRoomController => localConfig.ZoomRoomController;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,12 @@ public class MobileControlTouchpanelProperties : CrestronTouchpanelPropertiesCon

[JsonProperty("zoomRoomController")]
public bool ZoomRoomController { get; set; } = false;


/// <summary>
/// Key of the device that this UI client will be running on. For example the key of a Cisco codec whose Navigator panel runs this UI client.
/// </summary>
[JsonProperty("deviceKey", NullValueHandling = NullValueHandling.Ignore)]
public string DeviceKey { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<DefineConstants>TRACE;SERIES4</DefineConstants>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="PepperDashEssentials" Version="2.0.0-alpha-2441" />
<PackageReference Include="PepperDashEssentials" Version="2.0.0-alpha-2446" />
<PackageReference Include="WebSocketSharp-netstandard" Version="1.0.1" />
</ItemGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using PepperDash.Core;
using PepperDash.Essentials.Core;

namespace PepperDash.Essentials.AppServer.Messengers
{
public class IShutdownPromptTimerMessenger : MessengerBase
{
private readonly IShutdownPromptTimer _room;

public IShutdownPromptTimerMessenger(string key, string messagePath, IShutdownPromptTimer room)
: base(key, messagePath, room as Device)
{
_room = room;
}

protected override void RegisterActions()
{
AddAction("/status", (id, content) =>
{
SendFullStatus();
});

AddAction("/setShutdownPromptSeconds", (id, content) =>
{
var response = content.ToObject<int>();

_room.SetShutdownPromptSeconds(response);
});

_room.ShutdownPromptTimer.HasStarted += (sender, args) =>
{
var status = new IShutdownPromptTimerEventMessage
{
TimerStarted = true
};

PostEventMessage(status);
};

_room.ShutdownPromptTimer.HasFinished += (sender, args) =>
{
var status = new IShutdownPromptTimerEventMessage
{
TimerFinished = true
};

PostEventMessage(status);
};

_room.ShutdownPromptTimer.WasCancelled += (sender, args) =>
{
var status = new IShutdownPromptTimerEventMessage
{
TimerCancelled = true
};

PostEventMessage(status);
};

_room.ShutdownPromptTimer.TimeRemainingFeedback.OutputChange += (sender, args) =>
{
var status = new
{
timeRemaining = _room.ShutdownPromptTimer.TimeRemainingFeedback.StringValue
};
};
}

private void SendFullStatus()
{
var status = new IShutdownPromptTimerStateMessage
{
ShutdownPromptSeconds = _room.ShutdownPromptTimer.SecondsToCount,
TimeRemaining = _room.ShutdownPromptTimer.TimeRemainingFeedback.StringValue,
};

PostStatusMessage(status);
}
}


public class IShutdownPromptTimerStateMessage : DeviceStateMessageBase
{
[JsonProperty("secondsRemaining")]
public string TimeRemaining { get; set; }

[JsonProperty("shutdownPromptSeconds")]
public int ShutdownPromptSeconds { get; set; }
}

public class IShutdownPromptTimerEventMessage : DeviceEventMessageBase
{
[JsonProperty("timerFinished")]
public bool TimerFinished { get; set; }

[JsonProperty("timerStarted")]
public bool TimerStarted { get; set; }

[JsonProperty("timerCancelled")]
public bool TimerCancelled { get; set; }
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@
<Folder Include="SIMPLJoinMaps\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="PepperDashEssentials" Version="2.0.0-alpha-2441" />
<PackageReference Include="PepperDashEssentials" Version="2.0.0-alpha-2446" />
</ItemGroup>
</Project>

0 comments on commit bd78380

Please sign in to comment.