public async Task Verify(FileInfo kplModelFile, IEnumerable <IProperty> properties, FileInfo verificationDirectory, IModelCheckingProgressMonitor monitor) { await Task.Run(() => { try { monitor.Start(2, string.Format("Verifying the {0} model using the NuSMV modelchecker...", kplModelFile.Name)); monitor.LogProgress(0, "Generating the correspoding NuSMV model..."); KpModel kpModel = null; try { kpModel = KP.FromKpl(kplModelFile.FullName); } catch (KplParseException kplException) { throw new Exception(string.Format("Failed to parse input file {0}. Reason: {1}", kplModelFile.Name, kplException.Message)); } var experiment = new Experiment { LtlProperties = properties.Where(p => !(p is ICtlProperty)).Cast <ILtlProperty>().ToList(), CtlProperties = properties.Where(p => p is ICtlProperty).Cast <ICtlProperty>().ToList(), }; var verificationModelFileName = string.Format("{0}\\{1}.smv", verificationDirectory.FullName, Path.GetFileNameWithoutExtension(kplModelFile.Name)); TranslateSMV.Translate(kpModel, experiment, verificationModelFileName); monitor.LogProgress(1, "Performing model checking..."); ExecuteModel(verificationDirectory, verificationModelFileName); monitor.Done("Finished the verification process"); } catch (Exception e) { monitor.Terminate("Verification failed: " + e.Message); } }); }
private static void PerformNuSmvTransation(string[] args) { var argIndex = 1; if (args.Length < 3) { throw new Exception("Source file with kP system model not specified."); } string kplFileName = args[argIndex]; FileInfo fi = new FileInfo(kplFileName); if (!fi.Exists) { throw new Exception(string.Format("File '{0}' does not exist. Please specify a valid input file.", kplFileName)); } string outFileName = null; string kpxFileName = null; for (int i = ++argIndex; i < args.Length; i++) { if (args[i] == "-e") { if (++i < args.Length) { kpxFileName = args[i]; } } else if (args[i] == "-o") { if (++i < args.Length) { outFileName = args[i]; } } } KpModel kpModel = null; try { Console.WriteLine("-- KP model is loading"); kpModel = KP.FromKpl(kplFileName); Console.WriteLine("---- KP model loaded"); } catch (KplParseException kplException) { throw new Exception(string.Format("Failed to parse input file {0}. Reason: {1}", kplFileName, kplException.Message)); } Experiment kpExperiment = null; if (!string.IsNullOrEmpty(kpxFileName)) { if (new FileInfo(kpxFileName).Exists) { try { kpExperiment = KP.FromKpx(kpxFileName); } catch (Exception exception) { throw new Exception(string.Format("Failed to parse input file {0}. Reason: {1}", kplFileName, exception.Message)); } } else { throw new Exception(string.Format("File '{0}' does not exist. Please specify a valid experiment file.", kpxFileName)); } } Console.WriteLine("-- Translation to NuSMV is starting"); TranslateSMV.Translate(kpModel, kpExperiment, outFileName); Console.WriteLine("---- KP model translated NuSMV model successfully."); }