|
|
|
@ -46,13 +46,15 @@ public class Worker : BackgroundService
|
|
|
|
|
// var operateResult = await S7.ConnectServerAsync();
|
|
|
|
|
// if (!operateResult.IsSuccess) XTrace.WriteLine("连接失败");
|
|
|
|
|
|
|
|
|
|
DateTime timeNow = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
var list = await dbClient.Queryable<EEquipmentStateEntity>().ToListAsync(stoppingToken);
|
|
|
|
|
foreach (var e in list)
|
|
|
|
|
{
|
|
|
|
|
var a = await S7.ReadBoolAsync(e.Point);
|
|
|
|
|
if (a.IsSuccess)
|
|
|
|
|
{
|
|
|
|
|
e.UpdateTime = DateTime.Now;
|
|
|
|
|
e.UpdateTime = timeNow;
|
|
|
|
|
e.PValue = a.Content;
|
|
|
|
|
await dbClient.Updateable(e).UpdateColumns(x => new { x.UpdateTime, x.PValue })
|
|
|
|
|
.ExecuteCommandAsync(stoppingToken);
|
|
|
|
@ -76,7 +78,7 @@ public class Worker : BackgroundService
|
|
|
|
|
{
|
|
|
|
|
ID = Guid.NewGuid().ToString(),
|
|
|
|
|
PID = e.ID,
|
|
|
|
|
CreateTime = DateTime.Now,
|
|
|
|
|
CreateTime = timeNow,
|
|
|
|
|
Data = Math.Round(Convert.ToDecimal(a.Content), 2)
|
|
|
|
|
};
|
|
|
|
|
XTrace.WriteLine("Point:{0}, Value:{1}", e.Point, listd.Data);
|
|
|
|
|