Compare commits

..

3 Commits

Author SHA1 Message Date
Aviv Cohn
68301503bb fix: move items to correct places 2025-04-30 14:05:54 -04:00
Aviv Cohn
639c74489d fix: Move button visibility to online status change 2025-04-30 13:13:44 -04:00
Aviv Cohn
ab97e8140c fix: move RegisterForExtenders method to panel online event 2025-04-30 12:54:08 -04:00
6 changed files with 49 additions and 67 deletions

View File

@@ -38,49 +38,16 @@ namespace PepperDash.Essentials.Core
ReleaseAndMakeRoute(destination, source, signalType, inputPort, outputPort);
}
/// <summary>
/// Will release the existing route to the destination, if a route is found. This does not CLEAR the route, only stop counting usage time on any output ports that have a usage tracker set
/// </summary>
/// <param name="destination">destination to clear</param>
public static void ReleaseRoute(this IRoutingInputs destination)
{
routeRequestQueue.Enqueue(new ReleaseRouteQueueItem(ReleaseRouteInternal, destination, string.Empty, false));
routeRequestQueue.Enqueue(new ReleaseRouteQueueItem(ReleaseRouteInternal, destination, string.Empty));
}
/// <summary>
/// Will release the existing route to the destination, if a route is found. This does not CLEAR the route, only stop counting usage time on any output ports that have a usage tracker set
/// </summary>
/// <param name="destination">destination to clear</param>
/// <param name="inputPortKey">Input to use to find existing route</param>
public static void ReleaseRoute(this IRoutingInputs destination, string inputPortKey)
{
routeRequestQueue.Enqueue(new ReleaseRouteQueueItem(ReleaseRouteInternal, destination, inputPortKey, false));
routeRequestQueue.Enqueue(new ReleaseRouteQueueItem(ReleaseRouteInternal, destination, inputPortKey));
}
/// <summary>
/// Clears the route on the destination. This will remove any routes that are currently in use
/// </summary>
/// <param name="destination">Destination</param>
public static void ClearRoute(this IRoutingInputs destination)
{
routeRequestQueue.Enqueue(new ReleaseRouteQueueItem(ReleaseRouteInternal, destination, string.Empty, true));
}
/// <summary>
/// Clears the route on the destination. This will remove any routes that are currently in use
/// </summary>
/// <param name="destination">destination</param>
/// <param name="inputPortKey">input to use to find existing route</param>
public static void ClearRoute(this IRoutingInputs destination, string inputPortKey)
{
routeRequestQueue.Enqueue(new ReleaseRouteQueueItem(ReleaseRouteInternal, destination, inputPortKey, true));
}
/// <summary>
/// Removes the route request for the destination. This will remove any routes that are currently in use
/// </summary>
/// <param name="destinationKey">destination device key</param>
public static void RemoveRouteRequestForDestination(string destinationKey)
{
Debug.LogMessage(LogEventLevel.Information, "Removing route request for {destination}", null, destinationKey);
@@ -217,7 +184,7 @@ namespace PepperDash.Essentials.Core
Debug.LogMessage(LogEventLevel.Information, "Device: {destination} is NOT cooling down. Removing stored route request and routing to source key: {sourceKey}", null, destination.Key, routeRequest.Source.Key);
}
routeRequestQueue.Enqueue(new ReleaseRouteQueueItem(ReleaseRouteInternal, destination,destinationPort?.Key ?? string.Empty, false));
routeRequestQueue.Enqueue(new ReleaseRouteQueueItem(ReleaseRouteInternal, destination,destinationPort?.Key ?? string.Empty));
routeRequestQueue.Enqueue(new RouteRequestQueueItem(RunRouteRequest, routeRequest));
}
@@ -249,15 +216,14 @@ namespace PepperDash.Essentials.Core
{
Debug.LogMessage(ex, "Exception Running Route Request {request}", null, request);
}
}
}
/// <summary>
/// Will release the existing route on the destination, if it is found in RouteDescriptorCollection.DefaultCollection
/// Will release the existing route on the destination, if it is found in
/// RouteDescriptorCollection.DefaultCollection
/// </summary>
/// <param name="destination"></param>
/// <param name="inputPortKey"> The input port key to use to find the route. If empty, will use the first available input port</param>
/// <param name="clearRoute"> If true, will clear the route on the destination. This will remove any routes that are currently in use</param>
private static void ReleaseRouteInternal(IRoutingInputs destination, string inputPortKey, bool clearRoute)
/// <param name="destination"></param>
private static void ReleaseRouteInternal(IRoutingInputs destination, string inputPortKey)
{
try
{
@@ -276,7 +242,7 @@ namespace PepperDash.Essentials.Core
if (current != null)
{
Debug.LogMessage(LogEventLevel.Information, "Releasing current route: {0}", destination, current.Source.Key);
current.ReleaseRoutes(clearRoute);
current.ReleaseRoutes();
}
} catch (Exception ex)
{

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using Crestron.SimplSharpPro;
@@ -67,25 +66,12 @@ namespace PepperDash.Essentials.Core
/// Releases all routes in this collection. Typically called via
/// extension method IRoutingInputs.ReleaseAndMakeRoute()
/// </summary>
/// <param name="clearRoute">True to clear the route. Clearing sends `null` as the input selector to the ExecuteSwitch method</param>
public void ReleaseRoutes(bool clearRoute = false)
public void ReleaseRoutes()
{
foreach (var route in Routes.Where(r => r.SwitchingDevice is IRouting))
{
if (route.SwitchingDevice is IRouting switchingDevice)
{
if(clearRoute)
{
try
{
switchingDevice.ExecuteSwitch(null, route.OutputPort.Selector, SignalType);
}
catch (Exception e)
{
Debug.LogError("Error executing switch: {exception}", e.Message);
}
}
if (route.OutputPort == null)
{
continue;

View File

@@ -25,23 +25,21 @@ namespace PepperDash.Essentials.Core.Routing
public class ReleaseRouteQueueItem : IQueueMessage
{
private readonly Action<IRoutingInputs, string, bool> action;
private readonly Action<IRoutingInputs, string> action;
private readonly IRoutingInputs destination;
private readonly string inputPortKey;
private readonly bool clearRoute;
public ReleaseRouteQueueItem(Action<IRoutingInputs, string, bool> action, IRoutingInputs destination, string inputPortKey, bool clearRoute)
public ReleaseRouteQueueItem(Action<IRoutingInputs, string> action, IRoutingInputs destination, string inputPortKey)
{
this.action = action;
this.destination = destination;
this.inputPortKey = inputPortKey;
this.clearRoute = clearRoute;
}
public void Dispatch()
{
Debug.LogMessage(LogEventLevel.Information, "Dispatching release route request for {destination}:{inputPortKey}", null, destination?.Key ?? "no destination", string.IsNullOrEmpty(inputPortKey) ? "auto" : inputPortKey);
action(destination, inputPortKey, clearRoute);
action(destination, inputPortKey);
}
}
}

View File

@@ -7,7 +7,7 @@ using System.Collections.Generic;
namespace PepperDash.Essentials.Devices.Common.Generic
{
public class GenericSink : EssentialsDevice, IRoutingSinkWithInputPort
public class GenericSink : EssentialsDevice, IRoutingSink
{
public GenericSink(string key, string name) : base(key, name)
{

View File

@@ -8,10 +8,9 @@ using System.Linq;
namespace PepperDash.Essentials.Devices.Common.SoftCodec
{
public class GenericSoftCodec : EssentialsDevice, IRoutingSource, IRoutingSinkWithSwitchingWithInputPort
public class GenericSoftCodec : EssentialsDevice, IRoutingSource, IRoutingOutputs, IRoutingSinkWithSwitching
{
private RoutingInputPort _currentInputPort;
public RoutingInputPort CurrentInputPort {
get => _currentInputPort;
set

View File

@@ -174,6 +174,8 @@ namespace PepperDash.Essentials.Touchpanel
x70Panel.ExtenderButtonToolbarReservedSigs.HideButtonToolbar();
x70Panel.ExtenderButtonToolbarReservedSigs.Button2Off();
}
};
@@ -271,6 +273,31 @@ namespace PepperDash.Essentials.Touchpanel
}
}
private void UpdatePanelHardButtons()
{
if(Panel is TswX70Base x70Panel)
{
x70Panel.ExtenderButtonToolbarReservedSigs.Button1Off();
x70Panel.ExtenderButtonToolbarReservedSigs.Button3Off();
x70Panel.ExtenderButtonToolbarReservedSigs.Button4Off();
x70Panel.ExtenderButtonToolbarReservedSigs.Button5Off();
x70Panel.ExtenderButtonToolbarReservedSigs.Button6Off();
if (!x70Panel.ExtenderApplicationControlReservedSigs.HideOpenedApplicationFeedback.BoolValue)
{
x70Panel.ExtenderButtonToolbarReservedSigs.ShowButtonToolbar();
x70Panel.ExtenderButtonToolbarReservedSigs.Button2On();
}
else
{
x70Panel.ExtenderButtonToolbarReservedSigs.HideButtonToolbar();
x70Panel.ExtenderButtonToolbarReservedSigs.Button2Off();
}
}
}
public override bool CustomActivate()
{
var appMessenger = new ITswAppControlMessenger($"appControlMessenger-{Key}", $"/device/{Key}", this);
@@ -323,6 +350,12 @@ namespace PepperDash.Essentials.Touchpanel
Panel.StringInput[2].StringValue = QrCodeUrlFeedback.StringValue;
Panel.StringInput[3].StringValue = McServerUrlFeedback.StringValue;
Panel.StringInput[4].StringValue = UserCodeFeedback.StringValue;
this.LogInformation("Updating button feedbacks from Panel online status change");
UpdatePanelHardButtons();
};
}