public static void InitAutomata(XMLReader input, NetworkUDP UDPinterface_i, FSFB2DataFlow FSFB2_DataFlow_i, string[] inputArray_i, TextWriter logFile_i, ref object lockInputState_i, string version) { lockInputState = lockInputState_i; logFile = logFile_i; inputArray = inputArray_i; automataInput = input; UDPinterface = UDPinterface_i; myFSFB2_DataFlow = FSFB2_DataFlow_i; initDisplay(version); Timer myTimer = new Timer(); myTimer.Elapsed += new ElapsedEventHandler(ComputeStatus); myTimer.Interval = cycleTime; myTimer.Start(); // Management of key pressed - Q for quitting, O for displaying output to SIO, I for displaying input from SIO, R redraw the whole Console (if resized) bool Qpressed = false; while (!Qpressed) { var keyPressed = Console.ReadKey(true).Key; if (keyPressed == ConsoleKey.Q) { Qpressed = true; } else if (keyPressed == ConsoleKey.R) { initDisplay(version); } else if ((keyPressed == ConsoleKey.O) && (outputDisplay == false)) { outputDisplay = true; } else if ((keyPressed == ConsoleKey.O) && (outputDisplay == true)) { outputDisplay = false; } else if ((keyPressed == ConsoleKey.I) && (inputDisplay == false)) { inputDisplay = true; } else if ((keyPressed == ConsoleKey.I) && (inputDisplay == true)) { inputDisplay = false; } } logFile.Close(); UDPinterface.Quit(); }
static void Main(string[] args) { NetworkUDP myUDPinterface; TextWriter logFile; Object lockFileLog = new object(); Object lockInputState = new object(); if (args.Length != 3) { Console.WriteLine("Please provide (1) the address of the multisim engine, (2) the name of the XML configuration file, (3) the name of the log file"); Console.WriteLine("E.g: MSIMAutomate 127.0.0.1 TSW_config.xml log.txt"); return; } logFile = new StreamWriter(args[2], true); XMLReader myReader = new XMLReader(args[1]); string IPDst = args[0]; FSFB2Node myFSFB2Node = new FSFB2Node(); FSFB2DataFlow myFSFB2_DataFlow = new FSFB2DataFlow(); myFSFB2Node.NameHost = myReader.ZC_NAME; if (myFSFB2Node.InitListNotes() != ERRORS.NO_ERROR) { string[] listOfNodes = myFSFB2Node.getListNodes(); } if (myFSFB2_DataFlow.InitFSFB2DataFlow(myReader.SIO_NAME, myFSFB2Node) == ERRORS.NO_ERROR) { Console.WriteLine("FSFB2 data structure initialised"); } else { Console.WriteLine("Error encountered while attempting to initialised {0} FSFB2 data structure", myFSFB2Node.NameHost); return; } myUDPinterface = new NetworkUDP(); List <string> inputList = new List <string>(); foreach (TrkObject trkObj in myReader.trkObjectList) { foreach (TrkInterface trkInt in trkObj.listTrkInterface) { inputList.Add(trkInt.inputId); } } string[] inputArray = inputList.ToArray(); myUDPinterface.InitUDP(IPDst, myFSFB2_DataFlow.GetIndex(inputArray, "RX"), myReader.SrcAddr, myReader.DstAddr, ref lockInputState); Automata.InitAutomata(myReader, myUDPinterface, myFSFB2_DataFlow, inputArray, logFile, ref lockInputState, version); }