/// <summary> /// 执行对具体设备的数据更新 /// </summary> /// <param name="machine">设备的实例</param> /// <returns></returns> protected override async Task RunTask(IMachineProperty <string> machine) { try { var ans = await GetValue(machine); ReturnValues?.Invoke(new TaskReturnDef { MachineId = machine.Id, ReturnValues = ans }); } catch (Exception e) { if (!machine.IsConnected) { MoveMachineToUnlinked(machine.Id); } ReturnValues?.Invoke(new TaskReturnDef { MachineId = machine.Id, ReturnValues = null }); } }
/// <summary> /// 构造函数 /// </summary> /// <param name="machine">设备</param> /// <param name="taskFactory">任务工厂</param> public TaskMachine(IMachineProperty <TMachineKey> machine, TaskFactory taskFactory) { Machine = machine; _tasks = taskFactory; TasksWithTimer = new List <ITaskItem>(); }
public int GetHashCode(IMachineProperty <TKey> obj) { return(obj.GetHashCode()); }
public bool Equals(IMachineProperty <TKey> x, IMachineProperty <TKey> y) { return(x.Id.Equals(y.Id)); }
public bool Equals(IMachineProperty <TKey> x, IMachineProperty <TKey> y) { //1.3版本中需要修改这句话 return(x.Id.Equals(y.Id) || x.ConnectionToken == y.ConnectionToken); }