mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 20:54:55 +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> IsCoolingDownFeedbackFunc { get { return () => _IsCoolingDown; } }
|
||||||
protected override Func<bool> IsWarmingUpFeedbackFunc { get { return () => _IsWarmingUp; } }
|
protected override Func<bool> IsWarmingUpFeedbackFunc { get { return () => _IsWarmingUp; } }
|
||||||
|
|
||||||
|
int VolumeHeldRepeatInterval = 200;
|
||||||
|
ushort VolumeInterval = 655;
|
||||||
ushort _FakeVolumeLevel = 31768;
|
ushort _FakeVolumeLevel = 31768;
|
||||||
bool _IsMuted;
|
bool _IsMuted;
|
||||||
|
|
||||||
@@ -138,22 +140,30 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public void VolumeUp(bool pressRelease)
|
public void VolumeUp(bool pressRelease)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Volume Down {0}", pressRelease);
|
//while (pressRelease)
|
||||||
if (pressRelease)
|
//{
|
||||||
{
|
Debug.Console(2, this, "Volume Down {0}", pressRelease);
|
||||||
var newLevel = _FakeVolumeLevel + 655;
|
if (pressRelease)
|
||||||
SetVolume((ushort)newLevel);
|
{
|
||||||
}
|
var newLevel = _FakeVolumeLevel + VolumeInterval;
|
||||||
|
SetVolume((ushort)newLevel);
|
||||||
|
CrestronEnvironment.Sleep(VolumeHeldRepeatInterval);
|
||||||
|
}
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void VolumeDown(bool pressRelease)
|
public void VolumeDown(bool pressRelease)
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Volume Up {0}", pressRelease);
|
//while (pressRelease)
|
||||||
if (pressRelease)
|
//{
|
||||||
{
|
Debug.Console(2, this, "Volume Up {0}", pressRelease);
|
||||||
var newLevel = _FakeVolumeLevel - 655;
|
if (pressRelease)
|
||||||
SetVolume((ushort)newLevel);
|
{
|
||||||
}
|
var newLevel = _FakeVolumeLevel - VolumeInterval;
|
||||||
|
SetVolume((ushort)newLevel);
|
||||||
|
CrestronEnvironment.Sleep(VolumeHeldRepeatInterval);
|
||||||
|
}
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MuteToggle()
|
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="FOR REFERENCE Room\EssentialsRoom.cs" />
|
||||||
<Compile Include="Room\Cotija\CotijaConfig.cs" />
|
<Compile Include="Room\Cotija\CotijaConfig.cs" />
|
||||||
<Compile Include="Room\Cotija\CotijaRoomBridge.cs" />
|
<Compile Include="Room\Cotija\CotijaRoomBridge.cs" />
|
||||||
|
<Compile Include="Room\Cotija\DeviceTypeInterfaces\IDPadExtensions.cs" />
|
||||||
<Compile Include="Room\EssentialsPresentationRoom.cs" />
|
<Compile Include="Room\EssentialsPresentationRoom.cs" />
|
||||||
<Compile Include="Room\EssentialsRoomBase.cs" />
|
<Compile Include="Room\EssentialsRoomBase.cs" />
|
||||||
<Compile Include="Room\EssentialsRoomConfig.cs" />
|
<Compile Include="Room\EssentialsRoomConfig.cs" />
|
||||||
|
|||||||
Binary file not shown.
@@ -135,22 +135,73 @@ namespace PepperDash.Essentials
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
if (type == ChangeType.WillChange)
|
||||||
|
{
|
||||||
|
// Disconnect from previous source
|
||||||
|
|
||||||
if (type != ChangeType.DidChange)
|
if (info != null)
|
||||||
return;
|
{
|
||||||
|
var previousDev = info.SourceDevice;
|
||||||
|
|
||||||
JObject roomStatus = new JObject();
|
// 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);
|
||||||
|
}
|
||||||
|
|
||||||
var huddleRoom = room as EssentialsHuddleSpaceRoom;
|
JObject roomStatus = new JObject();
|
||||||
//roomStatus.Add("isOn", huddleRoom.OnFeedback.BoolValue);
|
|
||||||
roomStatus.Add("selectedSourceKey", huddleRoom.CurrentSourceInfoKey);
|
|
||||||
|
|
||||||
JObject message = new JObject();
|
var huddleRoom = room as EssentialsHuddleSpaceRoom;
|
||||||
|
//roomStatus.Add("isOn", huddleRoom.OnFeedback.BoolValue);
|
||||||
|
roomStatus.Add("selectedSourceKey", huddleRoom.CurrentSourceInfoKey);
|
||||||
|
|
||||||
|
JObject message = new JObject();
|
||||||
|
|
||||||
|
message.Add("type", "/room/status/");
|
||||||
|
message.Add("content", roomStatus);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
message.Add("type", "/room/status/");
|
|
||||||
message.Add("content", roomStatus);
|
|
||||||
|
|
||||||
Parent.PostToServer(Room, message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ namespace PepperDash.Essentials
|
|||||||
|
|
||||||
if (FileLock.TryEnter())
|
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);
|
postBody = File.ReadToEnd(filePath, Encoding.ASCII);
|
||||||
|
|
||||||
@@ -268,6 +268,20 @@ namespace PepperDash.Essentials
|
|||||||
ServerReconnect.Reset(dueTime, repeatTime);
|
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>
|
/// <summary>
|
||||||
/// Connects the SSE Client
|
/// Connects the SSE Client
|
||||||
@@ -319,17 +333,11 @@ namespace PepperDash.Essentials
|
|||||||
|
|
||||||
if (type == "hello")
|
if (type == "hello")
|
||||||
{
|
{
|
||||||
ServerHeartbeat = new CTimer(HeartbeatExpired, null, ServerHeartbeatInterval, ServerHeartbeatInterval);
|
StartHearbeatTimer(ServerHeartbeatInterval, ServerHeartbeatInterval);
|
||||||
|
|
||||||
Debug.Console(2, this, "Heartbeat Timer Started.");
|
|
||||||
|
|
||||||
ServerHeartbeat.Reset(ServerHeartbeatInterval, ServerHeartbeatInterval);
|
|
||||||
}
|
}
|
||||||
else if (type == "/system/heartbeat")
|
else if (type == "/system/heartbeat")
|
||||||
{
|
{
|
||||||
ServerHeartbeat.Reset(ServerHeartbeatInterval, ServerHeartbeatInterval);
|
StartHearbeatTimer(ServerHeartbeatInterval, ServerHeartbeatInterval);
|
||||||
|
|
||||||
Debug.Console(2, this, "Heartbeat Timer Reset.");
|
|
||||||
}
|
}
|
||||||
else if (type == "close")
|
else if (type == "close")
|
||||||
{
|
{
|
||||||
@@ -366,7 +374,7 @@ namespace PepperDash.Essentials
|
|||||||
{
|
{
|
||||||
PushedActions.Add(type, new CTimer(o =>
|
PushedActions.Add(type, new CTimer(o =>
|
||||||
{
|
{
|
||||||
(action as Action<bool>)(false);
|
(action as PressAndHoldAction)(false);
|
||||||
PushedActions.Remove(type);
|
PushedActions.Remove(type);
|
||||||
}, null, ButtonHeartbeatInterval, ButtonHeartbeatInterval));
|
}, null, ButtonHeartbeatInterval, ButtonHeartbeatInterval));
|
||||||
}
|
}
|
||||||
@@ -383,7 +391,7 @@ namespace PepperDash.Essentials
|
|||||||
}
|
}
|
||||||
case "false":
|
case "false":
|
||||||
{
|
{
|
||||||
if (!PushedActions.ContainsKey(type))
|
if (PushedActions.ContainsKey(type))
|
||||||
{
|
{
|
||||||
PushedActions[type].Stop();
|
PushedActions[type].Stop();
|
||||||
PushedActions.Remove(type);
|
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>)
|
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