Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            Atom x2 = new Atom("x2");
             Atom x1 = new Atom("x1");
             OperatorEquals f1 = new OperatorEquals(x2, new Constant("ElephantUpgrade"));
             OperatorNot f2 = new OperatorNot();
             f2.setOperand(f1);

             FOForAll fo = new FOForAll();
             fo.setOperand(f2);
             fo.setQuantifiedVariable(x2);
             fo.setQualifier("/event/name");
             OperatorG f3 = new OperatorG();
             f3.setOperand(fo);
             OperatorX secondPart = new OperatorX();
             secondPart.setOperand(f3);
             OperatorEquals f4 = new OperatorEquals(new Atom(x1), new Constant("ElephantUpgrade"));
             FOForAll fo2 = new FOForAll();
             fo2.setOperand(f4);
             //fo2.setOperand(secondPart);
             fo2.setQuantifiedVariable(x1);
             fo2.setQualifier("/event/name");

             OperatorImplies f5 = new OperatorImplies(fo2,secondPart);
             OperatorG formula = new OperatorG();
             formula.setOperand(f5);

            OperatorImplies oi = new OperatorImplies();
            oi.setLeftOperand(Constant.m_trueAtom);
            oi.setRightOperand (fo);

            SymbolicWatcher w = new SymbolicWatcher();
            w.setFormula(oi);
            w.reset();
            w.update ("<event><name>ElephantUpgrade</name></event>");
            w.update ("<event><name>ElephantUpgrade</name></event>");
        }
	/**
	 * @param args
	 */
	#pragma warning disable 219
	public static void main(string[] args)
	{
		FileStream fs = null;
		BufferedStream bs = null;
		BinaryReader br = null;
		long heapsize = 0;
		
		// Prints credits
		System.Console.WriteLine("BeepBeep Trace Validator, version 0.9.3");
		System.Console.WriteLine("(C) 2007-2012 Sylvain Halle, UQAM/UCSB");
		
		if (args.Length < 2)
		{
			System.Console.Error.WriteLine("ERROR: wrong command line parameters");
			
			return;
		}
		
		// Parses arguments
		string inputFilename = args[0];
		string queryFilename = args[1];
		
		// Gets property to check
		string formula = readProperty(queryFilename);
		
		if (formula == null)
		{
			System.Console.Error.WriteLine("ERROR: cannot open " + queryFilename);
			
			return;
		}
		
		// Parses property to check
		Operator property = LTLStringParser.parseFromString(formula);
		
		if (property == null)
		{
			System.Console.Error.WriteLine("ERROR: invalid property");
			
			return;
		}
		
		// Opens file
		//StreamReader traceFile = File.OpenText(inputFilename);
		
		try
		{
			//fs = new FileStream(traceFile, FileAccess.ReadWrite);
			fs = new FileStream(inputFilename, FileMode.Open);
			bs = new BufferedStream(fs);
			br = new BinaryReader(bs);
		}
		
		catch (FileNotFoundException e)
		{
			System.Console.Error.WriteLine("ERROR: cannot open " + inputFilename);
			
			return;
		}
		
		// A: here, br points to a valid, opened trace file
		// Start stopwatch
		long timeBegin = Stopwatch.GetTimestamp();
		SymbolicWatcher w = new SymbolicWatcher();
		
		w.setFormula(property);
		
		// Start processing the trace
		long numMessages = 0;
		string message = getNextMessage(br);
		
		while (message != null)
		{
			numMessages++;
			w.update(message);
			message = getNextMessage(br);
			//heapsize = Mathf.Max(heapsize, RuntimeGenerator.
		}
		
		// Stop stopwatch
		long timeEnd = Stopwatch.GetTimestamp();
		
		// Processing is over, get stats...
		int milliseconds = (int)((timeEnd - timeBegin) / (float)100000);
		string outcome = "INCONCLUSIVE";
		Outcome oOut = w.getOutcome();
		
		if (oOut == Outcome.TRUE)
		{
			outcome = "TRUE";
		}
		
		else if (oOut == Outcome.FALSE)
		{
			outcome = "FALSE";
		}
		
		int maxNodes = w.getMaxNodes();
		int maxSize = w.getMaxSize();
		int maxAtoms = w.getMaxAtoms();
		
		System.Console.WriteLine("Messages:  " + numMessages);
		System.Console.WriteLine("Outcome:   " + outcome);
		System.Console.WriteLine("Max nodes: " + maxNodes);
		System.Console.WriteLine("Max size:  " + maxSize);
		System.Console.WriteLine("Max atoms: " + maxAtoms);
		System.Console.WriteLine("Time (ms): " + milliseconds);
		System.Console.WriteLine("Max heap:  " + heapsize);
		
		try
		{
			if (br != null)
			{
				br.Close();
			}
			
			if (bs != null)
			{
				bs.Close();
			}
			
			if (fs != null)
			{
				fs.Close();
			}
		}
		
		catch (IOException e)
		{
			System.Console.Error.WriteLine("ERROR: while closing trace file");
			
			return;
		}
	}