56 lines
1.2 KiB
C#
56 lines
1.2 KiB
C#
|
using Microsoft.Extensions.Logging;
|
|||
|
using Seyounth.Extensions.Plc;
|
|||
|
|
|||
|
namespace Seyounth.Auto.Hs.Runtime.Plc;
|
|||
|
|
|||
|
public class PlcService : IPlcService
|
|||
|
{
|
|||
|
private readonly ILogger<PlcService> _logger;
|
|||
|
|
|||
|
private readonly IPlc _plc;
|
|||
|
|
|||
|
public PlcService(ILogger<PlcService> logger)
|
|||
|
{
|
|||
|
_logger = logger;
|
|||
|
//todo:此处创建PLC对象
|
|||
|
}
|
|||
|
|
|||
|
public async Task StartAsync()
|
|||
|
{
|
|||
|
await _plc.ConnectAsync();
|
|||
|
}
|
|||
|
|
|||
|
public async Task StopAsync()
|
|||
|
{
|
|||
|
await _plc.DisconnectAsync();
|
|||
|
}
|
|||
|
|
|||
|
public async Task<short> GetTemperatureAsync()
|
|||
|
{
|
|||
|
return (await _plc.ReadAsync<short>("D1000", 1))[0];
|
|||
|
}
|
|||
|
|
|||
|
public async Task QueryWarningInfo()
|
|||
|
{
|
|||
|
var flags = await _plc.ReadAsync<short>("D1003", 2);
|
|||
|
if (flags.Any(f => f != 0))
|
|||
|
OnWarning?.Invoke(Tuple.Create(flags[0], flags[1]));
|
|||
|
}
|
|||
|
|
|||
|
public event Func<Tuple<short, short>, Task> OnWarning;
|
|||
|
|
|||
|
public Task<short> GetJackingFlagAsync()
|
|||
|
{
|
|||
|
throw new NotImplementedException();
|
|||
|
}
|
|||
|
|
|||
|
public Task WriteBoxLabelPrintResult(short rs)
|
|||
|
{
|
|||
|
throw new NotImplementedException();
|
|||
|
}
|
|||
|
|
|||
|
public Task WriteFilmLabelPrintResult(short rs)
|
|||
|
{
|
|||
|
throw new NotImplementedException();
|
|||
|
}
|
|||
|
}
|