예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }
예제 #4
0
 public virtual bool Oprate(ConcurrentDictionary <string, MachineInfo> MachineClients, MesCmd mesCmd, ClientManager clientManager)
 {
     return(true);
 }
예제 #5
0
        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);
        }