mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-07 00:35:07 +00:00
Fixed volume up/down; Working on linking display power fb to room on fb
This commit is contained in:
@@ -40,8 +40,8 @@ namespace PepperDash.Essentials.Core
|
||||
{
|
||||
if (pollTime > warningTime || pollTime > errorTime)
|
||||
throw new ArgumentException("pollTime must be less than warning or errorTime");
|
||||
if (pollTime < 5000)
|
||||
throw new ArgumentException("pollTime cannot be less than 5000 ms");
|
||||
//if (pollTime < 5000)
|
||||
// throw new ArgumentException("pollTime cannot be less than 5000 ms");
|
||||
|
||||
Client = client;
|
||||
PollTime = pollTime;
|
||||
@@ -63,8 +63,8 @@ namespace PepperDash.Essentials.Core
|
||||
{
|
||||
if (pollTime > warningTime || pollTime > errorTime)
|
||||
throw new ArgumentException("pollTime must be less than warning or errorTime");
|
||||
if (pollTime < 5000)
|
||||
throw new ArgumentException("pollTime cannot be less than 5000 ms");
|
||||
//if (pollTime < 5000)
|
||||
// throw new ArgumentException("pollTime cannot be less than 5000 ms");
|
||||
|
||||
Client = client;
|
||||
PollTime = pollTime;
|
||||
@@ -112,7 +112,7 @@ namespace PepperDash.Essentials.Core
|
||||
StartErrorTimers();
|
||||
if (Client.IsConnected)
|
||||
{
|
||||
Debug.Console(2, Client, "Monitor, Polling");
|
||||
Debug.Console(2, this, "Polling");
|
||||
if(PollAction != null)
|
||||
PollAction.Invoke();
|
||||
else
|
||||
@@ -120,7 +120,7 @@ namespace PepperDash.Essentials.Core
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(2, Client, "Monitor, Comm not connected");
|
||||
Debug.Console(2, this, "Comm not connected");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ namespace PepperDash.Essentials.Core
|
||||
if (Client.IsConnected)
|
||||
{
|
||||
//Client.IsConnected -= OneTimeConnectHandler;
|
||||
Debug.Console(2, Client, "Monitor, Comm connected");
|
||||
Debug.Console(2, this, "Comm connected");
|
||||
Poll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@
|
||||
<Reference Include="System.Data" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Ramps and Increments\ActionIncrementer.cs" />
|
||||
<Compile Include="Comm and IR\CommFactory.cs" />
|
||||
<Compile Include="Comm and IR\CommunicationExtras.cs" />
|
||||
<Compile Include="Comm and IR\REMOVE ComPortConfig.cs" />
|
||||
@@ -132,6 +133,7 @@
|
||||
<Compile Include="Devices\IVolumeAndAudioInterfaces.cs" />
|
||||
<Compile Include="Display\BasicIrDisplay.cs" />
|
||||
<Compile Include="Feedbacks\BoolFeedbackOneShot.cs" />
|
||||
<Compile Include="Ramps and Increments\UshortSigIncrementer.cs" />
|
||||
<Compile Include="Routing\ICardPortsDevice.cs" />
|
||||
<Compile Include="InUseTracking\IInUseTracking.cs" />
|
||||
<Compile Include="InUseTracking\InUseTracking.cs" />
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,120 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// An incrementer that can use the values of some other object/primitive value to do its thing.
|
||||
/// It uses an Action to set the value and a Func to get the value from whatever this is
|
||||
/// attached to.
|
||||
/// </summary>
|
||||
public class ActionIncrementer
|
||||
{
|
||||
public int ChangeAmount { get; set; }
|
||||
public int MaxValue { get; set; }
|
||||
public int MinValue { get; set; }
|
||||
public uint RepeatDelay { get; set; }
|
||||
public uint RepeatTime { get; set; }
|
||||
|
||||
Action<int> SetAction;
|
||||
Func<int> GetFunc;
|
||||
CTimer Timer;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="changeAmount"></param>
|
||||
/// <param name="minValue"></param>
|
||||
/// <param name="maxValue"></param>
|
||||
/// <param name="repeatDelay"></param>
|
||||
/// <param name="repeatTime"></param>
|
||||
/// <param name="setAction">Action that will be called when this needs to set the destination value</param>
|
||||
/// <param name="getFunc">Func that is called to get the current value</param>
|
||||
public ActionIncrementer(int changeAmount, int minValue, int maxValue, uint repeatDelay, uint repeatTime, Action<int> setAction, Func<int> getFunc)
|
||||
{
|
||||
SetAction = setAction;
|
||||
GetFunc = getFunc;
|
||||
ChangeAmount = changeAmount;
|
||||
MaxValue = maxValue;
|
||||
MinValue = minValue;
|
||||
RepeatDelay = repeatDelay;
|
||||
RepeatTime = repeatTime;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts incrementing cycle
|
||||
/// </summary>
|
||||
public void StartUp()
|
||||
{
|
||||
if (Timer != null) return;
|
||||
Go(ChangeAmount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Starts decrementing cycle
|
||||
/// </summary>
|
||||
public void StartDown()
|
||||
{
|
||||
if (Timer != null) return;
|
||||
Go(-ChangeAmount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops the repeat
|
||||
/// </summary>
|
||||
public void Stop()
|
||||
{
|
||||
if (Timer != null)
|
||||
Timer.Stop();
|
||||
Timer = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper that does the work of setting new level, and starting repeat loop, checking against bounds first.
|
||||
/// </summary>
|
||||
/// <param name="change"></param>
|
||||
void Go(int change)
|
||||
{
|
||||
int currentLevel = GetFunc();
|
||||
// Fire once then pause
|
||||
int newLevel = currentLevel + change;
|
||||
bool atLimit = CheckLevel(newLevel, out newLevel);
|
||||
SetAction(newLevel);
|
||||
|
||||
if (atLimit) // Don't go past end
|
||||
Stop();
|
||||
else if (Timer == null) // Only enter the timer if it's not already running
|
||||
Timer = new CTimer(o => { Go(change); }, null, RepeatDelay, RepeatTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper to check a new level against min/max. Returns revised level if new level
|
||||
/// will go out of bounds
|
||||
/// </summary>
|
||||
/// <param name="levelIn">The level to check against bounds</param>
|
||||
/// <param name="levelOut">Revised level if bounds are exceeded. Min or max</param>
|
||||
/// <returns>true if new level is at or past bounds</returns>
|
||||
bool CheckLevel(int levelIn, out int levelOut)
|
||||
{
|
||||
bool isAtLimit = false;
|
||||
if (levelIn > MaxValue)
|
||||
{
|
||||
levelOut = MaxValue;
|
||||
isAtLimit = true;
|
||||
}
|
||||
else if (levelIn < MinValue)
|
||||
{
|
||||
levelOut = MinValue;
|
||||
isAtLimit = true;
|
||||
}
|
||||
else
|
||||
levelOut = levelIn;
|
||||
return isAtLimit;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Attaches to UShortInputSig and does incremental ramping of the signal
|
||||
/// </summary>
|
||||
public class UshortSigIncrementer
|
||||
{
|
||||
UShortInputSig TheSig;
|
||||
public ushort ChangeAmount { get; set; }
|
||||
public int MaxValue { get; set; }
|
||||
public int MinValue { get; set; }
|
||||
public uint RepeatDelay { get; set; }
|
||||
public uint RepeatTime { get; set; }
|
||||
bool SignedMode;
|
||||
CTimer Timer;
|
||||
|
||||
public UshortSigIncrementer(UShortInputSig sig, ushort changeAmount, int minValue, int maxValue, uint repeatDelay, uint repeatTime)
|
||||
{
|
||||
TheSig = sig;
|
||||
ChangeAmount = changeAmount;
|
||||
MaxValue = maxValue;
|
||||
MinValue = minValue;
|
||||
if (MinValue < 0 || MaxValue < 0) SignedMode = true;
|
||||
RepeatDelay = repeatDelay;
|
||||
RepeatTime = repeatTime;
|
||||
if (SignedMode && (MinValue < -32768 || MaxValue > 32767))
|
||||
Debug.Console(1, "UshortSigIncrementer has signed values that exceed range of -32768, 32767");
|
||||
}
|
||||
|
||||
public void StartUp()
|
||||
{
|
||||
if (Timer != null) return;
|
||||
Go(ChangeAmount);
|
||||
}
|
||||
|
||||
public void StartDown()
|
||||
{
|
||||
if (Timer != null) return;
|
||||
Go(-ChangeAmount);
|
||||
}
|
||||
|
||||
void Go(int change)
|
||||
{
|
||||
int level;
|
||||
if (SignedMode) level = TheSig.ShortValue;
|
||||
else level = TheSig.UShortValue;
|
||||
|
||||
// Fire once then pause
|
||||
int newLevel = level + change;
|
||||
bool atLimit = CheckLevel(newLevel, out newLevel);
|
||||
SetValue((ushort)newLevel);
|
||||
|
||||
|
||||
if (atLimit) // Don't go past end
|
||||
Stop();
|
||||
else if (Timer == null) // Only enter the timer if it's not already running
|
||||
Timer = new CTimer(o => { Go(change); }, null, RepeatDelay, RepeatTime);
|
||||
}
|
||||
|
||||
bool CheckLevel(int levelIn, out int levelOut)
|
||||
{
|
||||
bool IsAtLimit = false;
|
||||
if (levelIn > MaxValue)
|
||||
{
|
||||
levelOut = MaxValue;
|
||||
IsAtLimit = true;
|
||||
}
|
||||
else if (levelIn < MinValue)
|
||||
{
|
||||
levelOut = MinValue;
|
||||
IsAtLimit = true;
|
||||
}
|
||||
else
|
||||
levelOut = levelIn;
|
||||
return IsAtLimit;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (Timer != null)
|
||||
Timer.Stop();
|
||||
Timer = null;
|
||||
}
|
||||
|
||||
void SetValue(ushort value)
|
||||
{
|
||||
//CrestronConsole.PrintLine("Increment level:{0} / {1}", value, (short)value);
|
||||
TheSig.UShortValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -69,93 +69,4 @@ namespace PepperDash.Essentials.Core
|
||||
sig.CreateRamp(level, time / 10);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attaches to UShortInputSig and does incremental ramping of the signal
|
||||
/// </summary>
|
||||
public class UshortSigIncrementer
|
||||
{
|
||||
UShortInputSig TheSig;
|
||||
public ushort ChangeAmount { get; set; }
|
||||
public int MaxValue { get; set; }
|
||||
public int MinValue { get; set; }
|
||||
public uint RepeatDelay { get; set; }
|
||||
public uint RepeatTime { get; set; }
|
||||
bool SignedMode;
|
||||
CTimer Timer;
|
||||
|
||||
public UshortSigIncrementer(UShortInputSig sig, ushort changeAmount, int minValue, int maxValue, uint repeatDelay, uint repeatTime)
|
||||
{
|
||||
TheSig = sig;
|
||||
ChangeAmount = changeAmount;
|
||||
MaxValue = maxValue;
|
||||
MinValue = minValue;
|
||||
if (MinValue < 0 || MaxValue < 0) SignedMode = true;
|
||||
RepeatDelay = repeatDelay;
|
||||
RepeatTime = repeatTime;
|
||||
if (SignedMode && (MinValue < -32768 || MaxValue > 32767))
|
||||
Debug.Console(1, "UshortSigIncrementer has signed values that exceed range of -32768, 32767");
|
||||
}
|
||||
|
||||
public void StartUp()
|
||||
{
|
||||
if (Timer != null) return;
|
||||
Go(ChangeAmount);
|
||||
}
|
||||
|
||||
public void StartDown()
|
||||
{
|
||||
if (Timer != null) return;
|
||||
Go(-ChangeAmount);
|
||||
}
|
||||
|
||||
void Go(int change)
|
||||
{
|
||||
int level;
|
||||
if (SignedMode) level = TheSig.ShortValue;
|
||||
else level = TheSig.UShortValue;
|
||||
|
||||
// Fire once then pause
|
||||
int newLevel = level + change;
|
||||
bool atLimit = CheckLevel(newLevel, out newLevel);
|
||||
SetValue((ushort)newLevel);
|
||||
|
||||
|
||||
if (atLimit) // Don't go past end
|
||||
Stop();
|
||||
else if (Timer == null) // Only enter the timer if it's not already running
|
||||
Timer = new CTimer(o => { Go(change); }, null, RepeatDelay, RepeatTime);
|
||||
}
|
||||
|
||||
bool CheckLevel(int levelIn, out int levelOut)
|
||||
{
|
||||
bool IsAtLimit = false;
|
||||
if (levelIn > MaxValue)
|
||||
{
|
||||
levelOut = MaxValue;
|
||||
IsAtLimit = true;
|
||||
}
|
||||
else if (levelIn < MinValue)
|
||||
{
|
||||
levelOut = MinValue;
|
||||
IsAtLimit = true;
|
||||
}
|
||||
else
|
||||
levelOut = levelIn;
|
||||
return IsAtLimit;
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
if (Timer != null)
|
||||
Timer.Stop();
|
||||
Timer = null;
|
||||
}
|
||||
|
||||
void SetValue(ushort value)
|
||||
{
|
||||
//CrestronConsole.PrintLine("Increment level:{0} / {1}", value, (short)value);
|
||||
TheSig.UShortValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user