12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using System;
- using System.Collections.Concurrent;
- using System.Collections.Generic;
- using System.Configuration;
- using System.Data.Entity;
- using System.Linq;
- using System.Threading;
- using System.Threading.Tasks;
- using XdCxRhDW.Dto;
- using XdCxRhDW.Entity;
- using XdCxRhDW.Framework;
- using XdCxRhDW.Repostory;
- namespace XdCxRhDW.App
- {
- /// <summary>
- /// 两星一地定位取参考服务
- /// </summary>
- public class X2D1PosRefService
- {
- public static X2D1PosRefService Instance { get; private set; } = new X2D1PosRefService();
- readonly List<X2D1PosHandle> handles = new List<X2D1PosHandle>();
- public double TakeRefTime;
- public X2D1PosRefService()
- {
- TakeRefTime = AppConfigHelper.Get("TakeRefTime", 10);
- }
-
- public void AddPosDto(List<X2D1NoXlNoParlPosDto> dtos)
- {
- try
- {
- var dto = dtos.First();
- lock (this)
- {
- var firstDto = handles.FirstOrDefault(m => m.TaskId == dto.TaskID);
- if (firstDto == null)
- {
- firstDto = new X2D1PosHandle(dto.TaskID.Value, TakeRefTime);
- handles.Add(firstDto);
- }
- firstDto.Append(dtos);
- }
- }
- catch (Exception ex)
- {
- LogHelper.Error($"【任务{dtos.First().TaskID}】添加取参考信号流程异常,{ex.Message}", ex).GetAwaiter();
- }
- }
- public void Stop(int taskID)
- {
- try
- {
- lock (this)
- {
- var firstDto = handles.FirstOrDefault(m => m.TaskId == taskID);
- if (firstDto != null)
- {
- firstDto.Stop();
- handles.Remove(firstDto);
- }
- }
- }
- catch (Exception ex)
- {
- LogHelper.Error($"停止【任务{taskID}】取参考信号流程异常,{ex.Message}", ex).GetAwaiter();
- }
- }
- }
- }
|