// 调度过来的命令 public void ReceiveCommand(RequestCommand command) { // TraceManagerForOPC.AppendInfo("PUMP-OPC子服务当前任务条目数:"+ this.queue.Count.ToString()); //写值操作 if (command.sonServerType == CommandServerType.Pump_OPC && command.operType == CommandOperType.Write) { TakeOutCollectCommand(); this.Append(PumpCommand.CreateWriteCommand(this.opcClientManager, command)); //命令记录 TraceManagerForCommand.AppendDebug(string.Format("命令ID:{0}开始执行JZID:{1},业务地址{2},设定值{3}操作", command.ID, command.jzID, command.fDBAddress, command.value)); return; } // OPC_Pump--重载请求 if (command.sonServerType == CommandServerType.Pump_OPC && command.operType == CommandOperType.ReLoadData) { TakeOutCollectCommand(); this.Append(PumpCommand.CreateReloadCommand(this.opcClientManager, command)); //命令记录 TraceManagerForCommand.AppendDebug(string.Format("命令ID:{0}开始执行PUMP-OPC重载机组数据操作:", command.ID)); return; } // 错误请求 CommandManager.MakeFail("错误的请求类型", ref command); CommandManager.CompleteCommand(command); TraceManagerForCommand.AppendErrMsg(command.message); return; }
public void Append(PumpCommand command) { if (!IsRuning) { return; } if (queue.IsAddingCompleted) { return; } if (queue.Count > 4096) { TraceManagerForOPC.AppendErrMsg("二供-命令消费队列到达上限无法插入"); return; } queue.Add(command); }
// 命令消费-设定超时功能 private void Excute(PumpCommand command) { command.Excute(); }
// 定时的执行体 private void Excute() { this.pumpCommandConsumer.Append(PumpCommand.CreateCollectCommand(this.opcClientManager)); }