public MesCmdAnswer CheckCMD(MesCmd mesCmd, MachineState machineState, bool Skip = false) { if (Skip) { return(null); } string strCode = mesCmd.GenCmdCode(); if (mesCmd.CmdOpreateType == EOprate.写入) { if (WriteStateFlags.ContainsKey(strCode)) { if (WriteStateFlags[strCode] == machineState) { return(new SetStateAnswer()); } } } return(null); }
public override bool Oprate(ConcurrentDictionary <string, MachineInfo> MachineClients, MesCmd mesCmd, ClientManager Client) { SetStateAnswer CmdAnswer = new SetStateAnswer(); CmdAnswer.strCodeFromCmd = mesCmd.strCmdCode; MachineInfo machineInfoNew = new MachineInfo(); if (MachineClients.TryGetValue(sendor, out machineInfoNew)) { machineInfoNew.machineFeedState2 = machineState; MachineClients.AddOrUpdate(sendor, machineInfoNew, (key, value) => { return(value = machineInfoNew); }); CmdAnswer.cmdResult = CmdResult.OK; } else { MachineInfo machineInfo = new MachineInfo(); machineInfo.machineFeedState2 = machineState; machineInfo.MachineName = sendor; MachineClients.AddOrUpdate(sendor, machineInfo, (key, value) => { return(value = machineInfo); }); CmdAnswer.cmdResult = CmdResult.OK; } String strJson = JsonConvert.SerializeObject(CmdAnswer) + MesCmdAnswer.LineEndChars; Client.WriteData(strJson); log.Info($"{Client.ClientName} Oprate {sendor} {CmdName}"); return(true); }
public override bool Oprate(ConcurrentDictionary <string, MachineInfo> MachineClients, MesCmd mesCmd, ClientManager Client) { GetStateCmdAnswer CmdAnswer = new GetStateCmdAnswer(); CmdAnswer.strCodeFromCmd = mesCmd.strCmdCode; MachineInfo machineInfo = null; if (MachineClients.TryGetValue(Other, out machineInfo)) { CmdAnswer.machineState = machineInfo.machineOutState2; CmdAnswer.cmdResult = CmdResult.OK; } else { } String strJson = JsonConvert.SerializeObject(CmdAnswer) + MesCmdAnswer.LineEndChars; // Client.SendCommand(strJson); Client.WriteData(strJson); log.Info($"{Client.ClientName} Oprate {sendor} {CmdName}"); return(true); }
public virtual bool Oprate(ConcurrentDictionary <string, MachineInfo> MachineClients, MesCmd mesCmd, ClientManager clientManager) { return(true); }
public override bool Oprate(ConcurrentDictionary <string, MachineInfo> MachineClients, MesCmd mesCmd, ClientManager Client) { HeartBeepCmdAnswer CmdAnswer = new HeartBeepCmdAnswer(); CmdAnswer.strCodeFromCmd = mesCmd.strCmdCode; String strJson = JsonConvert.SerializeObject(CmdAnswer) + MesCmdAnswer.LineEndChars; // Client.SendCommand(strJson); Client.WriteData(strJson); return(true); }