mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-17 05:35:03 +00:00
Added IPad Extension methods to link actions between Cotija server and devices for proof of concept
This commit is contained in:
@@ -34,6 +34,8 @@ namespace PepperDash.Essentials.Core
|
||||
protected override Func<bool> IsCoolingDownFeedbackFunc { get { return () => _IsCoolingDown; } }
|
||||
protected override Func<bool> IsWarmingUpFeedbackFunc { get { return () => _IsWarmingUp; } }
|
||||
|
||||
int VolumeHeldRepeatInterval = 200;
|
||||
ushort VolumeInterval = 655;
|
||||
ushort _FakeVolumeLevel = 31768;
|
||||
bool _IsMuted;
|
||||
|
||||
@@ -138,22 +140,30 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public void VolumeUp(bool pressRelease)
|
||||
{
|
||||
//while (pressRelease)
|
||||
//{
|
||||
Debug.Console(2, this, "Volume Down {0}", pressRelease);
|
||||
if (pressRelease)
|
||||
{
|
||||
var newLevel = _FakeVolumeLevel + 655;
|
||||
var newLevel = _FakeVolumeLevel + VolumeInterval;
|
||||
SetVolume((ushort)newLevel);
|
||||
CrestronEnvironment.Sleep(VolumeHeldRepeatInterval);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
public void VolumeDown(bool pressRelease)
|
||||
{
|
||||
//while (pressRelease)
|
||||
//{
|
||||
Debug.Console(2, this, "Volume Up {0}", pressRelease);
|
||||
if (pressRelease)
|
||||
{
|
||||
var newLevel = _FakeVolumeLevel - 655;
|
||||
var newLevel = _FakeVolumeLevel - VolumeInterval;
|
||||
SetVolume((ushort)newLevel);
|
||||
CrestronEnvironment.Sleep(VolumeHeldRepeatInterval);
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
||||
public void MuteToggle()
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -142,6 +142,7 @@
|
||||
<Compile Include="FOR REFERENCE Room\EssentialsRoom.cs" />
|
||||
<Compile Include="Room\Cotija\CotijaConfig.cs" />
|
||||
<Compile Include="Room\Cotija\CotijaRoomBridge.cs" />
|
||||
<Compile Include="Room\Cotija\DeviceTypeInterfaces\IDPadExtensions.cs" />
|
||||
<Compile Include="Room\EssentialsPresentationRoom.cs" />
|
||||
<Compile Include="Room\EssentialsRoomBase.cs" />
|
||||
<Compile Include="Room\EssentialsRoomConfig.cs" />
|
||||
|
||||
Binary file not shown.
@@ -135,9 +135,33 @@ namespace PepperDash.Essentials
|
||||
}
|
||||
}
|
||||
*/
|
||||
if (type == ChangeType.WillChange)
|
||||
{
|
||||
// Disconnect from previous source
|
||||
|
||||
if (type != ChangeType.DidChange)
|
||||
return;
|
||||
if (info != null)
|
||||
{
|
||||
var previousDev = info.SourceDevice;
|
||||
|
||||
// device type interfaces
|
||||
//if (previousDev is ISetTopBoxControls)
|
||||
// (previousDev as ISetTopBoxControls).UnlinkButtons(TriList);
|
||||
//// common interfaces
|
||||
//if (previousDev is IChannel)
|
||||
// (previousDev as IChannel).UnlinkButtons(TriList);
|
||||
//if (previousDev is IColor)
|
||||
// (previousDev as IColor).UnlinkButtons(TriList);
|
||||
if (previousDev is IDPad)
|
||||
(previousDev as IDPad).UnlinkActions(Parent);
|
||||
//if (previousDev is IDvr)
|
||||
// (previousDev as IDvr).UnlinkButtons(TriList);
|
||||
//if (previousDev is INumericKeypad)
|
||||
// (previousDev as INumericKeypad).UnlinkButtons(TriList);
|
||||
//if (previousDev is IPower)
|
||||
// (previousDev as IPower).UnlinkButtons(TriList);
|
||||
//if (previousDev is ITransport)
|
||||
// (previousDev as ITransport).UnlinkButtons(TriList);
|
||||
}
|
||||
|
||||
JObject roomStatus = new JObject();
|
||||
|
||||
@@ -152,6 +176,33 @@ namespace PepperDash.Essentials
|
||||
|
||||
Parent.PostToServer(Room, message);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (info != null)
|
||||
{
|
||||
var dev = info.SourceDevice;
|
||||
|
||||
//if (dev is ISetTopBoxControls)
|
||||
// (dev as ISetTopBoxControls).LinkButtons(TriList);
|
||||
//if (dev is IChannel)
|
||||
// (dev as IChannel).LinkButtons(TriList);
|
||||
//if (dev is IColor)
|
||||
// (dev as IColor).LinkButtons(TriList);
|
||||
if (dev is IDPad)
|
||||
(dev as IDPad).LinkActions(Parent);
|
||||
//if (dev is IDvr)
|
||||
// (dev as IDvr).LinkButtons(TriList);
|
||||
//if (dev is INumericKeypad)
|
||||
// (dev as INumericKeypad).LinkButtons(TriList);
|
||||
//if (dev is IPower)
|
||||
// (dev as IPower).LinkButtons(TriList);
|
||||
//if (dev is ITransport)
|
||||
// (dev as ITransport).LinkButtons(TriList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Posts the full status of the room to the server
|
||||
|
||||
@@ -107,7 +107,7 @@ namespace PepperDash.Essentials
|
||||
|
||||
if (FileLock.TryEnter())
|
||||
{
|
||||
Debug.Console(1, this, "Reading Configuration File");
|
||||
Debug.Console(1, this, "Reading configuration file to extract system UUID...");
|
||||
|
||||
postBody = File.ReadToEnd(filePath, Encoding.ASCII);
|
||||
|
||||
@@ -268,6 +268,20 @@ namespace PepperDash.Essentials
|
||||
ServerReconnect.Reset(dueTime, repeatTime);
|
||||
}
|
||||
|
||||
void StartHearbeatTimer(long dueTime, long repeatTime)
|
||||
{
|
||||
if (ServerHeartbeat == null)
|
||||
{
|
||||
ServerHeartbeat = new CTimer(HeartbeatExpired, null, dueTime, repeatTime);
|
||||
|
||||
Debug.Console(2, this, "Heartbeat Timer Started.");
|
||||
}
|
||||
|
||||
ServerHeartbeat.Reset(dueTime, repeatTime);
|
||||
|
||||
Debug.Console(2, this, "Heartbeat Timer Reset.");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Connects the SSE Client
|
||||
@@ -319,17 +333,11 @@ namespace PepperDash.Essentials
|
||||
|
||||
if (type == "hello")
|
||||
{
|
||||
ServerHeartbeat = new CTimer(HeartbeatExpired, null, ServerHeartbeatInterval, ServerHeartbeatInterval);
|
||||
|
||||
Debug.Console(2, this, "Heartbeat Timer Started.");
|
||||
|
||||
ServerHeartbeat.Reset(ServerHeartbeatInterval, ServerHeartbeatInterval);
|
||||
StartHearbeatTimer(ServerHeartbeatInterval, ServerHeartbeatInterval);
|
||||
}
|
||||
else if (type == "/system/heartbeat")
|
||||
{
|
||||
ServerHeartbeat.Reset(ServerHeartbeatInterval, ServerHeartbeatInterval);
|
||||
|
||||
Debug.Console(2, this, "Heartbeat Timer Reset.");
|
||||
StartHearbeatTimer(ServerHeartbeatInterval, ServerHeartbeatInterval);
|
||||
}
|
||||
else if (type == "close")
|
||||
{
|
||||
@@ -366,7 +374,7 @@ namespace PepperDash.Essentials
|
||||
{
|
||||
PushedActions.Add(type, new CTimer(o =>
|
||||
{
|
||||
(action as Action<bool>)(false);
|
||||
(action as PressAndHoldAction)(false);
|
||||
PushedActions.Remove(type);
|
||||
}, null, ButtonHeartbeatInterval, ButtonHeartbeatInterval));
|
||||
}
|
||||
@@ -383,7 +391,7 @@ namespace PepperDash.Essentials
|
||||
}
|
||||
case "false":
|
||||
{
|
||||
if (!PushedActions.ContainsKey(type))
|
||||
if (PushedActions.ContainsKey(type))
|
||||
{
|
||||
PushedActions[type].Stop();
|
||||
PushedActions.Remove(type);
|
||||
@@ -392,7 +400,7 @@ namespace PepperDash.Essentials
|
||||
}
|
||||
}
|
||||
|
||||
(action as Action<bool>)(stateString == "true");
|
||||
(action as PressAndHoldAction)(stateString == "true");
|
||||
}
|
||||
}
|
||||
else if (action is Action<bool>)
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
{
|
||||
public static class IDPadExtensions
|
||||
{
|
||||
public static void LinkActions(this IDPad dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.AddAction(prefix + "up", new Action<bool>(dev.Up));
|
||||
controller.AddAction(prefix + "down", new Action<bool>(dev.Down));
|
||||
controller.AddAction(prefix + "left", new Action<bool>(dev.Left));
|
||||
controller.AddAction(prefix + "right", new Action<bool>(dev.Right));
|
||||
controller.AddAction(prefix + "select", new Action<bool>(dev.Select));
|
||||
controller.AddAction(prefix + "menu", new Action<bool>(dev.Menu));
|
||||
controller.AddAction(prefix + "exit", new Action<bool>(dev.Exit));
|
||||
}
|
||||
|
||||
public static void UnlinkActions(this IDPad dev, CotijaSystemController controller)
|
||||
{
|
||||
var prefix = string.Format(@"/device/{0}/", (dev as IKeyed).Key);
|
||||
|
||||
controller.RemoveAction(prefix + "up");
|
||||
controller.RemoveAction(prefix + "down");
|
||||
controller.RemoveAction(prefix + "left");
|
||||
controller.RemoveAction(prefix + "right");
|
||||
controller.RemoveAction(prefix + "select");
|
||||
controller.RemoveAction(prefix + "menu");
|
||||
controller.RemoveAction(prefix + "exit");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user