using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Team.Communicate.Client; namespace LogoForceTestApp.Services { public class ScanService : IScanService { private TeamTcpClient _teamTcpClient; public event EventHandler ScanCompleted; public ScanService() { } public async Task InitAsync(string ip, int port) { _teamTcpClient?.Dispose(); _teamTcpClient = new TeamTcpClient(ip, port) { IsAutoConnect = true }; return await _teamTcpClient.ConnectAsync(); } public string Read(string command) { return _teamTcpClient.SendAndReceiveString(command); } public Task ReadAsync(string command) { return _teamTcpClient.SendAndReceiveStringAsync(command); } public void Close() { try { _teamTcpClient?.DisConnect(); _teamTcpClient?.Dispose(); } catch (Exception) { } } } }