private void StartVerification(ListViewItem item) { if (!ModuleSpecificCheckPassed()) { return; } if (!Spec.GrabSharedDataLock()) { MessageBox.Show(Resources.Please_wait_for_the_simulation_or_parsing_finished_before_verification, Common.Ultility.Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DisableAllControls(); try { Spec.LockSharedData(false); StatusLabel_Text.Text = Resources.ModelCheckingForm_StartVerification_Verification_Starts; item.ImageIndex = UNKNOWN_ICON; Assertion = Spec.AssertionDatabase[item.SubItems[2].Text]; Assertion.UIInitialize(this, ComboBox_AdmissibleBehavior.SelectedIndex == -1 ? 0 : ComboBox_AdmissibleBehavior.SelectedIndex, ComboBox_VerificationEngine.SelectedIndex == -1 ? 0 : ComboBox_VerificationEngine.SelectedIndex); Assertion.VerificationOutput.GenerateCounterExample = CheckBox_GenerateWitnessTrace.Checked; Assertion.Action += OnAction; Assertion.ReturnResult += VerificationFinished; Assertion.Cancelled += Verification_Cancelled; Assertion.Failed += MC_Failed; seconds = 1; ProgressBar.Value = 0; MCTimer.Start(); Assertion.Start(); } catch (RuntimeException e) { Spec.UnLockSharedData(); Common.Ultility.Ultility.LogRuntimeException(e); Button_Verify.Text = VERIFY; this.Close(); return; } catch (Exception ex) { Spec.UnLockSharedData(); Common.Ultility.Ultility.LogException(ex, Spec); Button_Verify.Text = VERIFY; this.Close(); return; } }
public void startVerification(string assert) { do { mCurAssert = assert; if (!mListener.moduleSpecificCheckPassed()) { break; } if (!mSpec.GrabSharedDataLock()) { MessageBox.Show(Resources.Please_wait_for_the_simulation_or_parsing_finished_before_verification, Common.Utility.Utilities.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); break; } mListener.disableAllControls(); try { mSpec.LockSharedData(false); mListener.updateStatusLabel(Resources.ModelCheckingForm_StartVerification_Verification_Starts); mListener.updateResStartVerify(); mAssertion = mSpec.AssertionDatabase[assert]; int admissibleIndex = mListener.getCmbAdmissibleIndex(); int verificationEngineIndex = mListener.getCmbVerificationEngineIndex(); mAssertion.UIInitialize(mForm, admissibleIndex == -1 ? 0 : admissibleIndex, verificationEngineIndex == -1 ? 0 : verificationEngineIndex); mAssertion.VerificationOutput.GenerateCounterExample = mListener.generateCounterExample(); mAssertion.Action += mListener.onAction; mAssertion.ReturnResult += VerificationFinished; mAssertion.Cancelled += Verification_Cancelled; mAssertion.Failed += MC_Failed; mSeconds = 1; mTimer.Start(); mAssertion.Start(); } catch (RuntimeException e) { mSpec.UnLockSharedData(); Common.Utility.Utilities.LogRuntimeException(e); mListener.updateVerifyBtnLabel(LABEL_VERIFY); mListener.closeForm(); return; } catch (Exception ex) { mSpec.UnLockSharedData(); Common.Utility.Utilities.LogException(ex, mSpec); mListener.updateVerifyBtnLabel(LABEL_VERIFY); mListener.closeForm(); return; } } while (false); }
protected virtual void VerificationFinished() { try { if (Utility.Utilities.IsValidLicenseAvailable == Utility.Utilities.LicenseType.Evaluation || Utility.Utilities.IsValidLicenseAvailable == Utility.Utilities.LicenseType.Invalid) { if (mAssertion.VerificationOutput.NoOfStates > Utility.Utilities.LicenseBoundedStateNumber) { mListener.updateResFinishedVerify(); mListener.updateStatusLabel(Resources.Verification_Completed); mAssertion.Clear(); //remove the events mAssertion.Action -= mListener.onAction; mAssertion.Cancelled -= Verification_Cancelled; mAssertion.ReturnResult -= VerificationFinished; mAssertion.Failed -= MC_Failed; mListener.enableAllControls(); mTimer.Stop(); return; } } mListener.onAction(mAssertion.GetVerificationStatistics()); mListener.onResult(mAssertion.VerificationOutput.VerificationResult); mListener.updateStatusLabel(Resources.Generating_Result); mAssertion.ReturnResult -= VerificationFinished; mAssertion.ReturnResult += VerificationResult; mAssertion.VerificationOutput.GenerateCounterExample = mListener.generateCounterExample(); mAssertion.VerificationMode = false; mAssertion.Start(); } catch (Exception ex) { mAssertion.Clear(); //remove the events mAssertion.Action -= mListener.onAction; mAssertion.Cancelled -= Verification_Cancelled; mAssertion.ReturnResult -= VerificationFinished; mAssertion.Failed -= MC_Failed; mSpec.AssertionDatabase[mCurAssert] = mAssertion; Common.Utility.Utilities.LogException(ex, mSpec); } // Add by Minh //mListener.RnderingOutputTextbox(); mSpec.UnLockSharedData(); mSpec.UnLockSpecificationData(); }
protected virtual void VerificationFinished() { try { //timer.Stop(); // MCTimer.Stop(); // long stopMemorySize = System.GC.GetTotalMemory(false); // TextBox_Output.Text = "Estimated Memory Used:" + (stopMemorySize - startMemroySize) / 1000.0 + "KB\r\n\r\n" + TextBox_Output.Text; // TextBox_Output.Text = "Time Used:" + timer.Elapsed.TotalSeconds + "s\r\n" + TextBox_Output.Text; // //TextBox_Output.Text = "\tSearch Depth:" + Assertion.SearchedDepth + "\r\n" + TextBox_Output.Text; //#if Statistics // if(DBM.TimerNumber > 0) // { // TextBox_Output.Text = "Number of Clocks Used: " + DBM.TimerNumber + "\r\n" + TextBox_Output.Text; // } //#endif // if (this.CheckBox_Parallel.Checked && Assertion is AssertionLTL) // { // AssertionLTL ltl = Assertion as AssertionLTL; // TextBox_Output.Text = "SCC Ratio: " + Math.Round(((double)ltl.SCCTotalSize / (double)Assertion.VerificationOutput.NoOfStates), 2).ToString() + "\r\n" + TextBox_Output.Text; //DataStore.DataManager.GetNoOfStates() // if (ltl.SCCCount != 0) // { // TextBox_Output.Text = "Average SCC Size: " + (ltl.SCCTotalSize / ltl.SCCCount) + "\r\n" + TextBox_Output.Text; // } // else // { // TextBox_Output.Text = "Average SCC Size: 0\r\n" + TextBox_Output.Text; // } // TextBox_Output.Text = "Total SCC states: " + ltl.SCCTotalSize + "\r\n" + TextBox_Output.Text; // TextBox_Output.Text = "Number of SCC found: " + ltl.SCCCount + "\r\n" + TextBox_Output.Text; // } // TextBox_Output.Text = "Total Transitions:" + Assertion.VerificationOutput.Transitions + "\r\n" + TextBox_Output.Text; // string group = ""; // if (Assertion.VerificationOutput.NoOfGroupedStates > 0) // { // group = " (" + Assertion.VerificationOutput.NoOfGroupedStates + " states are grouped)"; // } // TextBox_Output.Text = "Visited States:" + Assertion.VerificationOutput.NoOfStates + group + "\r\n" + TextBox_Output.Text; //DataStore.DataManager.GetNoOfStates() // TextBox_Output.Text = "********Verification Statistics********\r\n" + TextBox_Output.Text; if (Common.Ultility.Ultility.IsValidLicenseAvailable == Ultility.Ultility.LicenseType.Evaluation || Common.Ultility.Ultility.IsValidLicenseAvailable == Ultility.Ultility.LicenseType.Invalid) { if (Assertion.VerificationOutput.NoOfStates > Common.Ultility.Ultility.LicenseBoundedStateNumber) { ListView_Assertions.SelectedItems[VerificationIndex].ImageIndex = UNKNOWN_ICON; TextBox_Output.Text = String.Format( "You are running an evaluation version of PAT. The number of searched states are limited to {0}.\r\nPurchase the full version to unlock the full functions of PAT.\r\n\r\n", Common.Ultility.Ultility.LicenseBoundedStateNumber) + TextBox_Output.Text; StatusLabel_Text.Text = Resources.Verification_Completed; Assertion.Clear(); //remove the events Assertion.Action -= OnAction; Assertion.Cancelled -= Verification_Cancelled; Assertion.ReturnResult -= VerificationFinished; Assertion.Failed -= MC_Failed; EnableAllControls(); return; } } TextBox_Output.Text = Assertion.GetVerificationStatistics() + TextBox_Output.Text; if (Assertion.VerificationOutput.VerificationResult == VerificationResultType.UNKNOWN) { ListView_Assertions.SelectedItems[VerificationIndex].ImageIndex = UNKNOWN_ICON; } else if (Assertion.VerificationOutput.VerificationResult == VerificationResultType.VALID) { ListView_Assertions.SelectedItems[VerificationIndex].ImageIndex = CORRECT_ICON; } else if (Assertion.VerificationOutput.VerificationResult == VerificationResultType.WITHPROBABILITY) { ListView_Assertions.SelectedItems[VerificationIndex].ImageIndex = CORRECT_ICON_PRPB; } else { ListView_Assertions.SelectedItems[VerificationIndex].ImageIndex = WRONG_ICON; } StatusLabel_Text.Text = Resources.Generating_Result; Assertion.ReturnResult -= VerificationFinished; Assertion.ReturnResult += VerificationResult; //Assertion.VerificationOutput.GenerateCounterExample = CheckBox_GenerateWitnessTrace.Checked; Assertion.VerificationMode = false; Assertion.Start(); } catch (Exception ex) { Assertion.Clear(); //remove the events Assertion.Action -= OnAction; Assertion.Cancelled -= Verification_Cancelled; Assertion.ReturnResult -= VerificationFinished; Assertion.Failed -= MC_Failed; Spec.AssertionDatabase[Label_SelectedAssertion.Text] = Assertion; Common.Ultility.Ultility.LogException(ex, Spec); //MessageBox.Show("Exception happened during verification: " + ex.Message + "\r\n" + ex.StackTrace, "PAT", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected virtual void VerificationFinished() { try { //timer.Stop(); //MCTimer.Stop(); //long stopMemorySize = System.GC.GetTotalMemory(false); //TextBox_Output.Text = "Estimated Memory Used:" + (stopMemorySize - startMemroySize) / 1000.0 + "KB\r\n\r\n" + TextBox_Output.Text; //TextBox_Output.Text = "Time Used:" + timer.Elapsed.TotalSeconds + "s\r\n" + TextBox_Output.Text; //if(DBM.TimerNumber > 0) //{ // TextBox_Output.Text = "Number of Clocks Used: " + DBM.TimerNumber + "\r\n" + TextBox_Output.Text; //} //if (this.CheckBox_Parallel.Checked && Assertion is AssertionLTL) //{ // AssertionLTL ltl = Assertion as AssertionLTL; // TextBox_Output.Text = "SCC Ratio: " + Math.Round(((double)ltl.SCCTotalSize / (double)Assertion.VerificationOutput.NoOfStates), 2).ToString() + "\r\n" + TextBox_Output.Text; //DataStore.DataManager.GetNoOfStates() // if (ltl.SCCCount != 0) // { // TextBox_Output.Text = "Average SCC Size: " + (ltl.SCCTotalSize / ltl.SCCCount) + "\r\n" + TextBox_Output.Text; // } // else // { // TextBox_Output.Text = "Average SCC Size: 0\r\n" + TextBox_Output.Text; // } // TextBox_Output.Text = "Total SCC states: " + ltl.SCCTotalSize + "\r\n" + TextBox_Output.Text; // TextBox_Output.Text = "Number of SCC found: " + ltl.SCCCount + "\r\n" + TextBox_Output.Text; //} //TextBox_Output.Text = "Total Transitions:" + Assertion.VerificationOutput.Transitions + "\r\n" + TextBox_Output.Text; //string group = ""; //if (Assertion.VerificationOutput.NoOfGroupedStates > 0) //{ // group = " (" + Assertion.VerificationOutput.NoOfGroupedStates + " states are grouped)"; //} //TextBox_Output.Text = "Visited States:" + Assertion.VerificationOutput.NoOfStates + group + "\r\n" + TextBox_Output.Text; //DataStore.DataManager.GetNoOfStates() //TextBox_Output.Text = "********Verification Statistics********\r\n" + TextBox_Output.Text; TextBox_Output.Text = Assertion.GetVerificationStatistics() + TextBox_Output.Text; //if(CheckBox_GenerateCounterexample.Checked) //{ StatusLabel_Text.Text = Resources.Generating_Result___; Assertion.ReturnResult -= VerificationFinished; Assertion.ReturnResult += VerificationResult; Assertion.VerificationMode = false; Assertion.Start(); //} //else //{ // StatusLabel_Text.Text = Resources.Verification_Completed; // StartVerification(true, true); //} } catch (Exception ex) { Assertion.Clear(); //remove the events Assertion.Action -= OnAction; Assertion.Cancelled -= Verification_Cancelled; Assertion.ReturnResult -= VerificationFinished; Assertion.Failed -= MC_Failed; Common.Utility.Utilities.LogException(ex, Spec); //MessageBox.Show("Exception happened during verification: " + ex.Message + "\r\n" + ex.StackTrace, "PAT", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
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 void StartVerification(ListViewItem item) { if (!ModuleSpecificCheckPassed()) { return; } if (!Spec.GrabSharedDataLock()) { MessageBox.Show(Resources.Please_wait_for_the_simulation_or_parsing_finished_before_verification, Common.Ultility.Ultility.APPLICATION_NAME, MessageBoxButtons.OK, MessageBoxIcon.Error); return; } DisableAllControls(); try { Spec.LockSharedData(false); StatusLabel_Text.Text = Resources.ModelCheckingForm_StartVerification_Verification_Starts; //these data will not change for SpecProcess.SharedData, so once it is created after parsing, there is no need to set them again. //SpecProcess.SharedData.VariableLowerBound = Valuation.VariableLowerBound; //SpecProcess.SharedData.VariableUpperLowerBound = Valuation.VariableUpperLowerBound; //SpecProcess.SharedData.AlphaDatabase = Specification.AlphaDatabase; //SpecProcess.SharedData.HasSyncrhonousChannel = Specification.HasSyncrhonousChannel; //SpecProcess.SharedData.SyncrhonousChannelNames = Specification.SyncrhonousChannelNames; //SpecProcess.SharedData.FairnessType = AssertionBase.FairnessType; //SpecProcess.SharedData.CalculateParticipatingProcess = AssertionBase.FairnessType == FairnessType.PROCESS_LEVEL_WEAK_FAIRNESS || AssertionBase.FairnessType == FairnessType.PROCESS_LEVEL_STRONG_FAIRNESS || Assertion.MustAbstract; //SpecProcess.SharedData.CalculateCreatedProcess = Assertion.MustAbstract; //SpecProcess.SharedData.DataManager = DataStore.DataManager; item.ImageIndex = UNKNOWN_ICON; Assertion = Spec.AssertionDatabase[item.SubItems[2].Text]; 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.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(); } catch (RuntimeException e) { Common.Ultility.Ultility.LogRuntimeException(e); this.Close(); return; } catch (Exception ex) { //TextBox_Output.Text += ex.Message + "\r\n" + ex.StackTrace; //EnableAllControls(); Common.Ultility.Ultility.LogException(ex, Spec); this.Close(); return; } }