public static ModuleFacadeBase LoadModule(string moduleName) { try { string facadeClass = "PAT." + moduleName + ".ModuleFacade"; string file = Path.Combine(Path.Combine(Common.Utility.Utilities.ModuleFolderPath, moduleName), "PAT.Module." + moduleName + ".dll"); Assembly assembly1 = Assembly.LoadFrom(file); ModuleFacadeBase CurrentModule = (ModuleFacadeBase)assembly1.CreateInstance( facadeClass, true, BindingFlags.CreateInstance, null, null, //new object[] {moduleNode.Attributes["name"].InnerText} null, null); return(CurrentModule); } catch { } return(null); }
public virtual void Initialize(Form simForm, ModuleFacadeBase module, string text, string options, string file, bool showVerbolMsg) { //initialize the parameters isiTarget = simForm; CurrentModule = module; Text = text; Options = options; File = file; ShowVerbolMsg = showVerbolMsg; }
private bool LoadModule(string moduleName) { bool ret = false; do { try { if (Common.Utility.Utilities.ModuleDictionary.ContainsKey(moduleName)) { if (mModule == null || moduleName != mModule.ModuleName) { mModule = Common.Utility.Utilities.ModuleDictionary[moduleName]; } ret = true; break; } string facadeClass = "PAT." + moduleName + ".ModuleFacade"; string file = Path.Combine(Path.Combine(Common.Utility.Utilities.ModuleFolderPath, moduleName), "PAT.Module." + moduleName + ".dll"); Assembly assembly = Assembly.LoadFrom(file); mModule = (ModuleFacadeBase)assembly.CreateInstance(facadeClass, true, BindingFlags.CreateInstance, null, null, null, null); if (mModule.GetType().Namespace != "PAT." + moduleName) { mModule = null; break; } //CurrentModule.ShowModel += new ShowModelHandler(ShowModel); //CurrentModule.ExampleMenualToolbarInitialize(this.MenuButton_Examples); mModule.ReadConfiguration(); ret = true; } catch { } } while (false); return(ret); }
public void Verify() { try { ModuleFacadeBase modulebase = PAT.Common.Ultility.Ultility.LoadModule("CSP"); SpecificationBase Spec = modulebase.ParseSpecification(File.ReadAllText(fullModelPath), "", fullModelPath); string resultMsg = ""; foreach (var assertion in Spec.AssertionDatabase.Values) { Console.WriteLine("Verifying the assertion: " + assertion.ToString()); // Apply verification settings assertion.UIInitialize(null, 0, 0); //Start the verification assertion.InternalStart(); if (assertion.VerificationOutput.VerificationResult.Equals(VerificationResultType.INVALID)) { resultMsg += "The assertion is invalid: " + assertion.ToString() + "\n"; if (assertion.VerificationOutput.CounterExampleTrace != null) { if (assertion.VerificationOutput.CounterExampleTrace.Count > 0) { //Get the counterexample trace resultMsg += "Counter Example Trace: "; foreach (ConfigurationBase step in assertion.VerificationOutput.CounterExampleTrace) { resultMsg += "->" + step.GetDisplayEvent(); } resultMsg += "\n"; } } } else if (assertion.VerificationOutput.VerificationResult.Equals(VerificationResultType.VALID)) { resultMsg += "The assertion is valid: " + assertion.ToString() + "\n"; } else { resultMsg += "The assertion could not be verified: " + assertion.ToString() + "\n"; } resultMsg += "\n"; } System.Windows.MessageBox.Show(resultMsg, "Refinement and Verification Completed!"); } catch (RuntimeException ex) { string runtimeErrMsg = "Runtime exception occurred: " + ex.Message + "\n"; //Out of memory Exception if (ex is OutOfMemoryException) { runtimeErrMsg += "Model is too big, out of memory."; } else { runtimeErrMsg += "Check your input model for the possiblity of errors."; } System.Windows.MessageBox.Show(runtimeErrMsg); } //General Exceptions catch (Exception ex) { System.Windows.MessageBox.Show("Error occurred: " + ex.Message); } }
private void StartVerification(bool completed, bool correct) { FlushString(); MCTimer.Stop(); if (AssertionIndex == 0) { if (completed && FileIndex > 0) { if (correct) { ListView_Assertions.Items[FileIndex - 1].ImageIndex = CORRECT_ICON; } else { ListView_Assertions.Items[FileIndex - 1].ImageIndex = WRONG_ICON; } } if (FileIndex < ListView_Assertions.Items.Count) { try { string file = ListView_Assertions.Items[FileIndex].SubItems[2].Text; FileIndex++; this.OutputWriter.WriteLine("*******************************************************"); this.OutputWriter.WriteLine("*" + file); this.OutputWriter.WriteLine("**************************START************************"); StatusLabel_Text.Text = Resources.Checking_file_ + file; StreamReader tr = new StreamReader(file); string specString = tr.ReadToEnd(); tr.Close(); if (Spec != null) { Spec.UnLockSharedData(); } string modulefolder = Common.Utility.Utilities.ModuleFolderNames[this.ComboBox_Modules.SelectedIndex]; ModuleFacadeBase modulebase = Common.Utility.Utilities.LoadModule(modulefolder); Spec = modulebase.ParseSpecification(specString, "", file); if (Spec != null) { Assertions = new List <string>(Spec.AssertionDatabase.Keys); } else { throw new Exception("ERROR Spec!"); } } catch (Exception ex) { if (FileIndex > 0) { ListView_Assertions.Items[FileIndex - 1].ImageIndex = WRONG_ICON; } this.OutputWriter.WriteLine("Error occurred: " + ex.Message + "\r\n" + ex.StackTrace); StartVerification(false, false); } } else { EnableAllControls(); return; } } try { if (Assertions.Count > 0) { OutputWriter.WriteLine("======================================================="); OutputWriter.WriteLine("Assertion: " + Assertions[AssertionIndex]); StatusLabel_Text.Text = Resources.Verifying_Assertion__ + Assertions[AssertionIndex]; FlushString(); Assertion = Spec.AssertionDatabase[Assertions[AssertionIndex]]; AssertionIndex++; AssertionIndex = AssertionIndex % Assertions.Count; //Assertion.UIInitialize(this, Fairness, this.CheckBox_PartialOrderReduction.Checked, this.CheckBox_Verbose.Checked, this.CheckBox_Parallel.Checked, this.ShortestPath, this.CheckBox_BDD.Checked, this.CheckBox_CheckNonZenoness.Checked, GetParameters()); Assertion.UIInitialize(this, (int)NUD_AdmissibleBehavior.Value, (int)NUD_VerificationEngine.Value); Assertion.VerificationOutput.GenerateCounterExample = CheckBox_GenerateCounterexample.Checked; Assertion.Action += OnAction; Assertion.ReturnResult += VerificationFinished; Assertion.Cancelled += Verification_Cancelled; Assertion.Failed += MC_Failed; seconds = 1; ProgressBar.Value = 0; //timer.Reset(); //startMemroySize = GC.GetTotalMemory(true); MCTimer.Start(); //timer.Start(); Assertion.Start(); } else { StartVerification(true, true); } } catch (RuntimeException e) { EnableAllControls(); Common.Utility.Utilities.LogRuntimeException(e); this.Close(); return; } catch (Exception ex) { EnableAllControls(); Common.Utility.Utilities.LogException(ex, Spec); this.Close(); return; } }
private SpecificationBase ParseSpecification(bool showVerbolMsg) { if (CurrentEditorTabItem == null || this.CurrentEditorTabItem.Text.Trim() == "") { if (showVerbolMsg) { MessageBox.Show(Resources.Please_input_a_model_first_, Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); } return(null); } DisableAllControls(); SpecificationBase spec = null; try { //clear the error list if (!ErrorListWindow.IsDisposed) { ErrorListWindow.Clear(); } CurrentModule = new ModuleFacade(); spec = CurrentModule.ParseSpecification(this.CurrentEditorTabItem.Text, "", CurrentEditorTabItem.FileName); if (spec != null) { CurrentEditorTabItem.Specification = spec; if (spec.Errors.Count > 0) { string key = ""; foreach (KeyValuePair <string, ParsingException> pair in spec.Errors) { key = pair.Key; break; } ParsingException parsingException = spec.Errors[key]; spec.Errors.Remove(key); throw parsingException; } if (showVerbolMsg) { this.StatusLabel_Status.Text = Resources.Grammar_Checked; MenuButton_OutputPanel.Checked = true; Output_Window.TextBox.Text = spec.GetSpecification() + "\r\n" + Output_Window.TextBox.Text; Output_Window.Show(DockContainer); if (spec.Warnings.Count > 0) { this.MenuButton_ErrorList.Checked = true; ErrorListWindow.AddWarnings(spec.Warnings); //ErrorListWindow.Show(DockContainer); ShowErrorMessage(); } } EnableAllControls(); return(spec); } else { EnableAllControls(); return(null); } } catch (ParsingException ex) { EnableAllControls(); if (showVerbolMsg) { if (spec != null) { ErrorListWindow.AddWarnings(spec.Warnings); ErrorListWindow.AddErrors(spec.Errors); //MenuButton_ErrorList.Checked = true; } CurrentEditorTabItem.HandleParsingException(ex); ErrorListWindow.InsertError(ex); MenuButton_ErrorList.Checked = true; if (ex.Line > 0) { MessageBox.Show(Resources.Parsing_error_at_line_ + ex.Line + Resources._column_ + ex.CharPositionInLine + ": " + ex.Text + "\nFile:" + ex.DisplayFileName + "\n" + ex.Message, Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Warning); MenuButton_OutputPanel.Checked = true; this.Output_Window.TextBox.Text = Resources.Parsing_error_at_line_ + ex.Line + Resources._column_ + ex.CharPositionInLine + ": " + ex.Text + "\nFile:" + ex.DisplayFileName + "\n" + ex.Message + "\r\n\r\n" + this.Output_Window.TextBox.Text; //"\n" + ex.StackTrace + } else { MessageBox.Show(Resources.Parsing_error__ + ex.Message, Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Warning); MenuButton_OutputPanel.Checked = true; this.Output_Window.TextBox.Text = Resources.Parsing_error__ + ex.Message + "\r\n\r\n" + this.Output_Window.TextBox.Text; //"\n" + ex.StackTrace + } ShowErrorMessage(); } } catch (Exception ex) { EnableAllControls(); if (showVerbolMsg) { MessageBox.Show(Resources.Parsing_error__ + ex.Message, Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); MenuButton_OutputPanel.Checked = true; this.Output_Window.TextBox.Text = Resources.Parsing_error__ + ex.Message + "\n" + ex.StackTrace + "\r\n\r\n" + this.Output_Window.TextBox.Text; } } return(null); }
public PATService() { modulebase = PAT.Common.Ultility.Ultility.LoadModule("CSP"); }