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