tbf/GenesisCordonelTester/API/InterfaceOutsideToGCI.cs

124 lines
4.7 KiB
C#
Raw Permalink Normal View History

using System;
using System.Collections.Generic;
using Xylem.Common.Hardware.Interfaces.Ports.PortCore;
using Xylem.Common.Hardware.WaterMeter.WaterMeterCore;
using static Xylem.Common.Hardware.WaterMeter.Genesis.GenesisCore.GenesisMeter;
namespace GenesisCordonelInterface.API
{
/// <summary>
/// Outside-facing facade for Genesis Cordonel Interface.
/// Exposes only selected operations intended for external callers.
/// </summary>
public class InterfaceOutsideToGCI
{
private readonly InterfaceGCIToLaatzen _innerMeterAPI;
/// <summary>
/// Initializes a new instance of the <see cref="InterfaceOutsideToGCI"/> class.
/// </summary>
public InterfaceOutsideToGCI()
{
_innerMeterAPI = new InterfaceGCIToLaatzen();
}
/// <summary>
/// Gets a value indicating whether the meter is currently connected and logged on.
/// </summary>
public bool IsConnected
{
get
{
return _innerMeterAPI.IsConnected;
}
}
/// <summary>
/// Connects to the meter on the specified slot.
/// </summary>
/// <param name="slotNo">Slot number.</param>
/// <param name="usePasswordsSource">Specifies whether offline passwords should be used.</param>
/// <returns>Connect operation result.</returns>
public InterfaceGCIToLaatzen.InitResult InitOneMeterFromExtern(Int32 slotNo, ConfigSource useConfigSource, PasswordSource usePasswordSource, PortConfig? requestPort, PortConfig? streamingPort)
{
return _innerMeterAPI.InitOneMeterFromExtern(slotNo, useConfigSource, usePasswordSource, requestPort, streamingPort);
}
/// <summary>
/// Connects to the meter on the specified slot.
/// </summary>
/// <param name="slotNo">Slot number.</param>
/// <param name="usePasswordsSource">Specifies whether offline passwords should be used.</param>
/// <returns>Connect operation result.</returns>
public InterfaceGCIToLaatzen.ConnectResult ConnectOneMeter(int slotNo)
{
return _innerMeterAPI.ConnectOneMeter(slotNo);
}
/// <summary>
/// Connects to the meter on the specified slot.
/// </summary>
/// <param name="slotNo">Slot number.</param>
/// <param name="usePasswordsSource">Specifies whether offline passwords should be used.</param>
/// <returns>Connect operation result.</returns>
public InterfaceGCIToLaatzen.ConnectResult ConnectAllMeters(int slotNo)
{
return _innerMeterAPI.ConnectAllMeters(slotNo);
}
/// <summary>
/// Disconnects from the currently connected meter.
/// </summary>
public void Disconnect()
{
_innerMeterAPI.Disconnect();
}
/// <summary>
/// Reads PCB ID from the specified slot.
/// </summary>
/// <param name="slot">Slot number.</param>
/// <returns>PCB ID string.</returns>
public string GetPcbId(int slot)
{
return _innerMeterAPI.GetPcbId(slot);
}
/// <summary>
/// Reads a register by name.
/// </summary>
/// <param name="registerName">Register name.</param>
/// <returns>Register read result.</returns>
public InterfaceGCIToLaatzen.RegisterReadResult ReadRegister(string registerName)
{
return _innerMeterAPI.ReadRegister(registerName);
}
/// <summary>
/// Writes a value to a register.
/// </summary>
/// <param name="registerName">Register name.</param>
/// <param name="value">Value to write.</param>
/// <param name="storeToDevice">Specifies whether configuration should be stored after write.</param>
/// <param name="refreshSystemState">Specifies whether system state refresh should be triggered after write.</param>
/// <returns>Register write result.</returns>
public InterfaceGCIToLaatzen.RegisterWriteResult WriteRegister(
string registerName,
object value,
bool storeToDevice = false,
bool refreshSystemState = false)
{
return _innerMeterAPI.WriteRegister(registerName, value, storeToDevice, refreshSystemState);
}
/// <summary>
/// Sets meter password.
/// </summary>
/// <param name="password">Password value.</param>
/// <returns>True if operation succeeded; otherwise false.</returns>
public bool SetMeterPassword(string password)
{
return _innerMeterAPI.SetMeterPassword(password);
}
}
}