41 lines
1.8 KiB
C#
41 lines
1.8 KiB
C#
using System;
|
|
using CordonelPreadjustmentUi;
|
|
using Xylem.Common.Hardware.Interfaces.Ports.PortCore;
|
|
|
|
namespace GenesisCordonelInterface.API
|
|
{
|
|
/// <summary>
|
|
/// Compatibility for the delivered Laatzen runtime predating its dedicated
|
|
/// streaming-port hand-off API. Instance methods from a newer runtime take
|
|
/// precedence over these extensions automatically.
|
|
/// </summary>
|
|
internal static class LegacyLaatzenCompatibility
|
|
{
|
|
public static void ConnectStreamingPort(this ZeroFlowGenesisMeter meter, PortConfig requestedPort)
|
|
{
|
|
if (meter == null) throw new ArgumentNullException(nameof(meter));
|
|
if (meter.StreamingPort == null)
|
|
throw new InvalidOperationException(
|
|
"The installed Laatzen runtime has no configured streaming port. Configure it before initializing the slot.");
|
|
|
|
var configuredPort = meter.StreamingPort.GetPortName();
|
|
if (!string.Equals(configuredPort, requestedPort.PortName, StringComparison.OrdinalIgnoreCase))
|
|
throw new NotSupportedException(
|
|
"The installed Laatzen runtime cannot replace a streaming port at runtime. " +
|
|
"Initialize the slot with the requested streaming port or install the updated Laatzen runtime.");
|
|
|
|
if (!meter.CheckStreamingPort())
|
|
throw new InvalidOperationException("Unable to open configured streaming port " + configuredPort + ".");
|
|
}
|
|
|
|
public static void DisconnectStreamingPort(this ZeroFlowGenesisMeter meter)
|
|
{
|
|
if (meter == null) return;
|
|
|
|
// The legacy API has no streaming-only disconnect. Keeping its
|
|
// configured port open avoids disposing the request-session graph.
|
|
meter.StopRecordData();
|
|
}
|
|
}
|
|
}
|