public void addInstruction2Sent(string code, CInstruction instruction) { lock (lockInstructions) { registry2RDC(code); if (!this.dcInstrunctionSent.ContainsKey(code)) { this.dcInstrunctionSent.Add(code, new Dictionary <long, CInstruction>()); } this.dcInstrunctionSent[code].Add(instruction.id, instruction); } }
public bool addInstruction2Wating(string code, CInstruction instruction) { decimal range = Limit.getInstance().getLimitRange(code); if (range != 0.10m) { string info = ""; if (range == 0.05m) { info = "ST stock"; } else if (range == 0m) { info = "unkown object"; } Console.Write("Error-addInstruction2Wating: " + info + " (" + code + ")"); return(false); } lock (lockInstructions) { registry2RDC(code); if (instruction.id == 0) { instruction.id = --idNoneDB; } if (!this.dcInstrunctionWaiting.ContainsKey(code)) { this.dcInstrunctionWaiting.Add(code, new Dictionary <long, CInstruction>()); } this.dcInstrunctionWaiting[code].Add(instruction.id, instruction); } return(true); }
private IEnumerable <Instruction> EninstrFromSrc(string src, Dictionary <string, int> syt) { const string rxLabel = "^\\((?<symbol>[a-zA-Z_$:\\.][0-9a-zA-Z_$:\\.]*)\\)$"; int istm = 0; foreach (var stLineX in src.ToLines()) { var stLine = stLineX.Replace(" ", "").Replace("\t", "").SkipComment(); if (string.IsNullOrWhiteSpace(stLine)) { continue; } var matchLabel = Regex.Match(stLine, rxLabel); if (matchLabel.Success) { syt.Add(matchLabel.Groups["symbol"].Value, istm); continue; } istm++; var instr = AInstructionWithSymbol.Parse(stLine) ?? (Instruction)AInstructionWithConstant.Parse(stLine) ?? CInstruction.Parse(stLine); if (instr == null) { throw new Ufer(stLineX); } yield return(instr); } }
public void CInstruction_InstantiateWithValidInputs2_BinaryInstructionIsCorrect() { CInstruction cInstruction = new CInstruction("AM", "D&M", "JLE"); Assert.AreEqual("1111000000101110", cInstruction.GetInstructionAsMachineCode()); }