mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 05:05:00 +00:00
Added Async fire to Feedbacks; fixed mock display to use async feedback
This commit is contained in:
@@ -64,14 +64,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
if (!PowerIsOnFeedback.BoolValue && !_IsWarmingUp && !_IsCoolingDown)
|
if (!PowerIsOnFeedback.BoolValue && !_IsWarmingUp && !_IsCoolingDown)
|
||||||
{
|
{
|
||||||
_IsWarmingUp = true;
|
_IsWarmingUp = true;
|
||||||
IsWarmingUpFeedback.FireUpdate();
|
IsWarmingUpFeedback.InvokeFireUpdate();
|
||||||
// Fake power-up cycle
|
// Fake power-up cycle
|
||||||
WarmupTimer = new CTimer(o =>
|
WarmupTimer = new CTimer(o =>
|
||||||
{
|
{
|
||||||
_IsWarmingUp = false;
|
_IsWarmingUp = false;
|
||||||
_PowerIsOn = true;
|
_PowerIsOn = true;
|
||||||
IsWarmingUpFeedback.FireUpdate();
|
IsWarmingUpFeedback.InvokeFireUpdate();
|
||||||
PowerIsOnFeedback.FireUpdate();
|
PowerIsOnFeedback.InvokeFireUpdate();
|
||||||
}, WarmupTime);
|
}, WarmupTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -84,14 +84,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
_IsCoolingDown = true;
|
_IsCoolingDown = true;
|
||||||
_PowerIsOn = false;
|
_PowerIsOn = false;
|
||||||
PowerIsOnFeedback.FireUpdate();
|
PowerIsOnFeedback.InvokeFireUpdate();
|
||||||
IsCoolingDownFeedback.FireUpdate();
|
IsCoolingDownFeedback.InvokeFireUpdate();
|
||||||
// Fake cool-down cycle
|
// Fake cool-down cycle
|
||||||
CooldownTimer = new CTimer(o =>
|
CooldownTimer = new CTimer(o =>
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Cooldown timer ending");
|
Debug.Console(2, this, "Cooldown timer ending");
|
||||||
_IsCoolingDown = false;
|
_IsCoolingDown = false;
|
||||||
IsCoolingDownFeedback.FireUpdate();
|
IsCoolingDownFeedback.InvokeFireUpdate();
|
||||||
}, CooldownTime);
|
}, CooldownTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -118,19 +118,19 @@ namespace PepperDash.Essentials.Core
|
|||||||
public void SetVolume(ushort level)
|
public void SetVolume(ushort level)
|
||||||
{
|
{
|
||||||
_FakeVolumeLevel = level;
|
_FakeVolumeLevel = level;
|
||||||
VolumeLevelFeedback.FireUpdate();
|
VolumeLevelFeedback.InvokeFireUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MuteOn()
|
public void MuteOn()
|
||||||
{
|
{
|
||||||
_IsMuted = true;
|
_IsMuted = true;
|
||||||
MuteFeedback.FireUpdate();
|
MuteFeedback.InvokeFireUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MuteOff()
|
public void MuteOff()
|
||||||
{
|
{
|
||||||
_IsMuted = false;
|
_IsMuted = false;
|
||||||
MuteFeedback.FireUpdate();
|
MuteFeedback.InvokeFireUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BoolFeedback MuteFeedback { get; private set; }
|
public BoolFeedback MuteFeedback { get; private set; }
|
||||||
@@ -170,7 +170,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
public void MuteToggle()
|
public void MuteToggle()
|
||||||
{
|
{
|
||||||
_IsMuted = !_IsMuted;
|
_IsMuted = !_IsMuted;
|
||||||
MuteFeedback.FireUpdate();
|
MuteFeedback.InvokeFireUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -28,8 +28,19 @@ namespace PepperDash.Essentials.Core
|
|||||||
Cue = cue;
|
Cue = cue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fires an update synchronously
|
||||||
|
/// </summary>
|
||||||
public abstract void FireUpdate();
|
public abstract void FireUpdate();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fires the update asynchronously within a CrestronInvoke
|
||||||
|
/// </summary>
|
||||||
|
public void InvokeFireUpdate()
|
||||||
|
{
|
||||||
|
CrestronInvoke.BeginInvoke(o => FireUpdate());
|
||||||
|
}
|
||||||
|
|
||||||
protected void OnOutputChange()
|
protected void OnOutputChange()
|
||||||
{
|
{
|
||||||
if (OutputChange != null) OutputChange(this, EventArgs.Empty);
|
if (OutputChange != null) OutputChange(this, EventArgs.Empty);
|
||||||
|
|||||||
@@ -4,5 +4,5 @@
|
|||||||
[assembly: AssemblyCompany("PepperDash Technology Corp")]
|
[assembly: AssemblyCompany("PepperDash Technology Corp")]
|
||||||
[assembly: AssemblyProduct("PepperDashEssentials")]
|
[assembly: AssemblyProduct("PepperDashEssentials")]
|
||||||
[assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2017")]
|
[assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2017")]
|
||||||
[assembly: AssemblyVersion("1.0.11.*")]
|
[assembly: AssemblyVersion("1.0.12.*")]
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Text;
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
using Crestron.SimplSharp.CrestronIO;
|
||||||
|
using Crestron.SimplSharpPro.CrestronThread;
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
using Crestron.SimplSharp.Net.Http;
|
using Crestron.SimplSharp.Net.Http;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
@@ -25,6 +26,8 @@ namespace PepperDash.Essentials
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
CEvent PostLockEvent = new CEvent(true, true);
|
CEvent PostLockEvent = new CEvent(true, true);
|
||||||
|
|
||||||
|
Thread SseWorkerThread;
|
||||||
|
|
||||||
CotijaConfig Config;
|
CotijaConfig Config;
|
||||||
|
|
||||||
HttpClient Client;
|
HttpClient Client;
|
||||||
@@ -210,6 +213,8 @@ namespace PepperDash.Essentials
|
|||||||
/// <param name="room">room from which the message originates</param>
|
/// <param name="room">room from which the message originates</param>
|
||||||
/// <param name="o">object to be serialized and sent in post body</param>
|
/// <param name="o">object to be serialized and sent in post body</param>
|
||||||
public void PostToServer(EssentialsRoomBase room, JObject o)
|
public void PostToServer(EssentialsRoomBase room, JObject o)
|
||||||
|
{
|
||||||
|
CrestronInvoke.BeginInvoke(oo =>
|
||||||
{
|
{
|
||||||
var ready = PostLockEvent.Wait(2000);
|
var ready = PostLockEvent.Wait(2000);
|
||||||
if (!ready)
|
if (!ready)
|
||||||
@@ -240,7 +245,8 @@ namespace PepperDash.Essentials
|
|||||||
Debug.Console(1, this, "Posting to '{0}':\n{1}", url, ignored);
|
Debug.Console(1, this, "Posting to '{0}':\n{1}", url, ignored);
|
||||||
request.ContentString = ignored;
|
request.ContentString = ignored;
|
||||||
request.FinalizeHeader();
|
request.FinalizeHeader();
|
||||||
Client.DispatchAsync(request, (r, err) => {
|
Client.DispatchAsync(request, (r, err) =>
|
||||||
|
{
|
||||||
Debug.Console(1, this, "POST result: {0}", err);
|
Debug.Console(1, this, "POST result: {0}", err);
|
||||||
|
|
||||||
if (err == HTTP_CALLBACK_ERROR.COMPLETED)
|
if (err == HTTP_CALLBACK_ERROR.COMPLETED)
|
||||||
@@ -262,6 +268,9 @@ namespace PepperDash.Essentials
|
|||||||
Debug.Console(1, this, "Error Posting to Server: {0}", e);
|
Debug.Console(1, this, "Error Posting to Server: {0}", e);
|
||||||
PostLockEvent.Set();
|
PostLockEvent.Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -406,13 +415,11 @@ namespace PepperDash.Essentials
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
void SSEClient_LineReceived(object sender, GenericCommMethodReceiveTextArgs e)
|
void SSEClient_LineReceived(object sender, GenericCommMethodReceiveTextArgs e)
|
||||||
{
|
{
|
||||||
//Debug.Console(1, this, "Received from Server: '{0}'", e.Text);
|
|
||||||
|
|
||||||
if(e.Text.IndexOf("data:") > -1)
|
if(e.Text.IndexOf("data:") > -1)
|
||||||
{
|
{
|
||||||
var message = e.Text.Substring(6);
|
var message = e.Text.Substring(6);
|
||||||
|
|
||||||
Debug.Console(1, this, "Message: '{0}'", message);
|
Debug.Console(1, this, "Message RX: '{0}'", message);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user