static void Main(string[] args) { var stopwatch = Stopwatch.StartNew(); var oc5 = LusCompiler.Compile(File.ReadAllText(@"Examples/pressureTank.lus"), "TANK"); stopwatch.Stop(); Console.WriteLine($"Lustre compilation finished after {stopwatch.Elapsed.Minutes}:{stopwatch.Elapsed.Seconds:00}"); stopwatch = Stopwatch.StartNew(); var runner = new Oc5Runner(oc5); stopwatch.Stop(); Console.WriteLine($"Oc5 compilation finished after {stopwatch.Elapsed.Minutes}:{stopwatch.Elapsed.Seconds:00}"); var ticksCount = 1000000; var rand = new Random(); stopwatch = Stopwatch.StartNew(); for (int i = 0; i < ticksCount; i++) { bool randomBool = rand.NextDouble() > 0.5; runner.Tick(randomBool); } stopwatch.Stop(); Console.WriteLine($"{ticksCount} ticks finished after {stopwatch.Elapsed.Minutes}:{stopwatch.Elapsed.Seconds:00}"); Console.ReadKey(true); }
public LustreModelBase(string lustrePath, string mainNode, IEnumerable <Fault> faults) { var oc5 = LusCompiler.Compile(File.ReadAllText(lustrePath), mainNode); Runner = new Oc5Runner(oc5); StateVectorSize = Runner.Oc5ModelState.Bools.Count * sizeof(bool) + Runner.Oc5ModelState.Ints.Count * sizeof(int) + Runner.Oc5ModelState.Strings.Count * sizeof(char) * 30 + //HACK max. length of string is 30 chars (29 + '\0') Runner.Oc5ModelState.Floats.Count * sizeof(float) + Runner.Oc5ModelState.Doubles.Count * sizeof(double) + Runner.Oc5ModelState.Mappings.Count * sizeof(PositionInOc5State) + Runner.Oc5ModelState.InputMappings.Count * sizeof(PositionInOc5State) + Runner.Oc5ModelState.OutputMappings.Count * sizeof(PositionInOc5State) + sizeof(int) + // variable containing the current state sizeof(long); // variable containing the permanent faults Faults = faults.ToDictionary(fault => fault.Name, fault => fault); }