// Spludlow Software // Copyright © Samuel P. Ludlow 2020 All Rights Reserved // Distributed under the terms of the GNU General Public License version 3 // Distributed WITHOUT ANY WARRANTY; without implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE // https://www.spludlow.co.uk/LICENCE.TXT // The Spludlow logo is a registered trademark of Samuel P. Ludlow and may not be used without permission // v1.14 using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Spludlow.Trains { public class TrainClient : ITrainServer { private string ServiceAppKey; public TrainClient() { this.ServiceAppKey = "TrainServerNetwork"; } public void ClearLog() { ITrainServer trains = TrainServer.MakeClient(ServiceAppKey); try { trains.ClearLog(); } finally { Spludlow.ServiceModels.Close(trains); } } public void Close() { ITrainServer trains = TrainServer.MakeClient(ServiceAppKey); try { trains.Close(); } finally { Spludlow.ServiceModels.Close(trains); } } public void Emergency() { ITrainServer trains = TrainServer.MakeClient(ServiceAppKey); try { trains.Emergency(); } finally { Spludlow.ServiceModels.Close(trains); } } public void Normal() { ITrainServer trains = TrainServer.MakeClient(ServiceAppKey); try { trains.Normal(); } finally { Spludlow.ServiceModels.Close(trains); } } public void Points(int address, bool direction) { ITrainServer trains = TrainServer.MakeClient(ServiceAppKey); try { trains.Points(address, direction); } finally { Spludlow.ServiceModels.Close(trains); } } public void PowerOff() { ITrainServer trains = TrainServer.MakeClient(ServiceAppKey); try { trains.PowerOff(); } finally { Spludlow.ServiceModels.Close(trains); } } public TrainsDataSet Query(bool includeLogs) { ITrainServer trains = TrainServer.MakeClient(ServiceAppKey); try { return trains.Query(includeLogs); } finally { Spludlow.ServiceModels.Close(trains); } } public void Send(string data) { ITrainServer trains = TrainServer.MakeClient(ServiceAppKey); try { trains.Send(data); } finally { Spludlow.ServiceModels.Close(trains); } } public void Speed(int address, int speed) { ITrainServer trains = TrainServer.MakeClient(ServiceAppKey); try { trains.Speed(address, speed); } finally { Spludlow.ServiceModels.Close(trains); } } } }