Esempio n. 1
0
        public bool addAssertResult(AssertionBase assertion)
        {
            bool ret = false;
            do
            {
                if (assertion == null)
                    break;

                AssertType type = getAssertType(assertion.ToString());

                // Can not detected assert type
                if (type == AssertType.NONE)
                    break;

                int id = getLatexResultByType(type);
                // Found latex instance at id position
                if (id != -1)
                    mLatexList.RemoveAt(id);

                LatexResult lret = new LatexResult();
                lret.mType = type;
                lret.mMemo = assertion.getMems();
                lret.mTransition = assertion.getTransitions();
                lret.mState = assertion.getStates();
                lret.mTime = assertion.getTimes();
                lret.mRes = convertResultToLatex(type, assertion.getResult());

                mLatexList.Add(lret);
                ret = true;
            } while (false);

            return ret;
        }
Esempio n. 2
0
        public void startVerification(string assert)
        {
            do
            {
                mCurAssert = assert;
                if (!mSpec.GrabSharedDataLock())
                    break;

                try
                {
                    mSpec.LockSharedData(false);
                    mAssertion = mSpec.AssertionDatabase[assert];
                    mAssertion.UIInitialize(null, 0, 0);
                    mAssertion.ReturnResult += VerificationFinished;
                    mAssertion.Start();
                    System.Console.WriteLine("\nVerify {0}, result: {1}", assert, mAssertion.VerificationOutput.VerificationResult);
                }
                catch (RuntimeException e)
                {
                    mSpec.UnLockSharedData();
                    Common.Utility.Utilities.LogRuntimeException(e);
                    return;
                }
                catch (Exception ex)
                {
                    mSpec.UnLockSharedData();
                    Common.Utility.Utilities.LogException(ex, mSpec);
                    return;
                }
            } while (false);
        }
Esempio n. 3
0
        public static void Initialize(AssertionBase Assertion, PetriNet Process, SpecificationBase spec)
        {
            Specification Spec = spec as Specification;

            //get the relevant global variables; remove irrelevant variables so as to save memory;
            Valuation GlobalEnv = Spec.SpecValuation.GetClone();

            //Initialize InitialStep
            Assertion.InitialStep = new PNConfiguration(Process, Constants.INITIAL_EVENT, null, GlobalEnv, false, spec);
        }
Esempio n. 4
0
        public static void Initialize(AssertionBase Assertion, DefinitionRef Process, SpecificationBase spec)
        {
            Specification Spec = spec as Specification;

            //get the relevant global variables; remove irrelevant variables so as to save memory;
            Valuation GlobalEnv = Spec.SpecValuation.GetVariableChannelClone(Process.GetGlobalVariables(), Process.GetChannels());

            //Initialize InitialStep
            Assertion.InitialStep = new Configuration(Process, Constants.INITIAL_EVENT, null, GlobalEnv, false);

            Assertion.MustAbstract = Process.MustBeAbstracted();
        }
Esempio n. 5
0
        public void SetSpec(string name, string simulateProcess, SpecificationBase spec, AssertionBase assertion)
        {
            this.Spec = spec;
            Assertion = assertion;

            this.ComboBox_Process.Items.Clear();
            this.ComboBox_Process.Items.Add(simulateProcess);
            ComboBox_Process.SelectedIndexChanged -= ComboBox_Process_SelectedIndexChanged;
            ComboBox_Process.SelectedIndex = 0;
            ComboBox_Process.SelectedIndexChanged += ComboBox_Process_SelectedIndexChanged;

            if (name != "")
            {
                this.Text = this.Text + " - " + name; // +PAT.CSP.Ultility.Ultility.GetVersionNumber();
            }

            DisplayCounterExample();
        }
Esempio n. 6
0
        protected virtual void Verification_Cancelled(object sender, EventArgs e)
        {
            try
            {
                //cancel the verification
                if (mAssertion.VerificationMode)
                {
                    mListener.onAction(mAssertion.GetVerificationStatistics());
                    mListener.onAction(mAssertion.VerificationOutput.ResultString);
                    mListener.updateLatexResult(mAssertion);
                    mListener.RnderingOutputTextbox();

                    mAssertion.Clear();

                    //remove the events
                    mAssertion.Action -= mListener.onAction;
                    mAssertion.ReturnResult -= VerificationFinished;
                    mAssertion.Cancelled -= Verification_Cancelled;
                    mAssertion.Failed -= MC_Failed;
                    mAssertion.VerificationOutput = null;
                    mAssertion = null;

                    mListener.updateStatusLabel(Resources.Verification_Cancelled);
                    //StatusLabel_Text.Text = Resources.Verification_Cancelled;

                    //set the verification result to be unknow.
                    mListener.eventCancel();
                    //ListView_Assertions.SelectedItems[VerificationIndex].ImageIndex = UNKNOWN_ICON;
                }
                //cancel the result generation
                else
                {
                    mListener.onAction(mAssertion.VerificationOutput.ResultString);
                    mListener.updateStatusLabel(Resources.Result_Generation_Cancelled);
                    mListener.updateLatexResult(mAssertion);
                    mListener.RnderingOutputTextbox();
                    mAssertion.VerificationOutput = null;
                }

                mListener.enableAllControls();
                // Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                Common.Utility.Utilities.LogException(ex, mSpec);
            }
        }
Esempio n. 7
0
        protected virtual void MC_Failed(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            try
            {
                if (e.Exception is RuntimeException)
                {
                    Common.Utility.Utilities.LogRuntimeException(e.Exception as RuntimeException);
                    if (mAssertion != null)
                    {
                        mListener.onAction(mAssertion.GetVerificationStatistics());
                        mListener.onAction(mAssertion.VerificationOutput.ResultString);
                        mListener.RnderingOutputTextbox();
                    }
                    mListener.updateStatusLabel(Resources.Runtime_Exception_Happened);
                }
                else
                {
                    //if the button is enabled -> the failure is not triggered by cancel action.
                    if (mListener.isVerifyBtnEnabled())
                    {
                        Common.Utility.Utilities.LogException(e.Exception, mSpec);
                        mSpec.UnLockSharedData();
                        mListener.closeForm();
                    }
                    else
                    {
                        mListener.updateStatusLabel(Resources.Verification_Cancelled);
                        // this.StatusLabel_Text.Text = Resources.Verification_Cancelled;
                    }

                }

                if (mAssertion != null)
                {
                    mAssertion.Clear();

                    //remove the events
                    mAssertion.Action -= mListener.onAction;
                    mAssertion.ReturnResult -= VerificationFinished;
                    mAssertion.Cancelled -= Verification_Cancelled;
                    mAssertion.Failed -= MC_Failed;
                    mAssertion = null;
                }

                mListener.enableAllControls();
            }
            catch (Exception ex)
            {
                Common.Utility.Utilities.LogException(ex, mSpec);
            }
        }
Esempio n. 8
0
        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);
        }
Esempio n. 9
0
 public void updateLatexResult(AssertionBase assertion)
 {
     // Update latex result
     mLatexWorker.addAssertResult(assertion);
 }