Example #1
0
 public void unlockShareData()
 {
     if (mSpec != null)
     {
         mSpec.UnLockSharedData();
     }
 }
Example #2
0
        protected virtual void EnableAllControls()
        {
            ListView_Assertions.Enabled                = true;
            ComboBox_AdmissibleBehavior.Enabled        = true;
            ComboBox_VerificationEngine.Enabled        = true;
            this.CheckBox_GenerateWitnessTrace.Enabled = true;

            NumericUpDown_TimeOut.Enabled = true;

            Button_Verify.Text = VERIFY;
            ToolTip.SetToolTip(Button_Verify, VERIFY);
            ProgressBar.Value   = 0;
            ProgressBar.Visible = false;
            Cursor = Cursors.Default;
            TextBox_Output.Cursor = Cursors.Default;

            if (ListView_Assertions.SelectedItems.Count == 1)
            {
                ResetUIOptions(ListView_Assertions.SelectedItems[0], false);
            }
            else
            {
                ResetUIOptions(null, false);
            }


            MCTimer.Stop();

            Spec.UnLockSharedData();


            Common.Ultility.Ultility.FlashWindowEx(this);
        }
Example #3
0
        protected virtual void EnableAllControls()
        {
            ListView_Assertions.Enabled = true;

            this.CheckBox_Parallel.Enabled         = true;
            this.CheckBox_Verbose.Enabled          = true;
            this.CheckBox_BDD.Enabled              = true;
            this.CheckBox_CheckNonZenoness.Enabled = true;

            //the following three values
            //ComboBox_Fairness.Enabled = true;
            this.CheckBox_PartialOrderReduction.Enabled = true;
            //this.NUD_Depth.Enabled = true;

            NumericUpDown_TimeOut.Enabled = true;

            Button_Verify.Text = VERIFY;
            ToolTip.SetToolTip(Button_Verify, VERIFY);
            ProgressBar.Value   = 0;
            ProgressBar.Visible = false;
            Cursor = Cursors.Default;
            TextBox_Output.Cursor = Cursors.Default;

            if (ListView_Assertions.SelectedItems.Count == 1)
            {
                ResetUIOptions(ListView_Assertions.SelectedItems[0], false);
            }
            else
            {
                ResetUIOptions(null, false);
            }


            MCTimer.Stop();

            Spec.UnLockSharedData();
        }
        /* todo: xingzc.
         *
         * Need GlobalVar info to initialze nodeInfoTemplates/nodeInfoNone/nodeInfoCalculatorKind
         *
         * Need to know if left/right is parameterized system and cutnumber. This affects initialize() and Parser.
         * For parameterized system, no need to get a subgraph from a Configuration. A counter vector will be ok.
         * Probably we can still obtain a subgraph. But do not need to compare subgraphs. Instead, extract a counter
         * vector from the subgraph and use it to represent the state info.
         */
        public List <PairUpCandidate> execute(Graph left, Graph right, List <string> vars, bool notMaximalBipartite, SpecificationBase leftSpec, SpecificationBase rightSpec, bool eventDetails, bool matchProcessParameters, bool matchStateStructure, bool matchIfGuardCondition)
        {
            if (left.UserData != null)
            {
                this.cutnumber1 = (int)left.UserData;
            }
            if (right.UserData != null)
            {
                this.cutnumber2 = (int)right.UserData;
            }
            this.compareParameterizedSystem = (this.cutnumber1 != -1) && (this.cutnumber2 != -1);

            this.compareConfigGraph = compareConfigGraph && !compareParameterizedSystem;

            this.notMaximalBipartiteMatch = notMaximalBipartite;

            this.matchEventDetails = eventDetails;

            //ly; newly added.
            this.compareConfigGraph = matchStateStructure;
            //todo: matchIfGuardCondition needs to be added.

            List <string> primitiveVariables = new List <string>();

            Valuation leftValuation = leftSpec.GetEnvironment();

            foreach (string varName in vars)
            {
                if (leftValuation != null && leftValuation.Variables != null)
                {
                    ExpressionValue value = leftValuation.Variables.GetContainsKey(varName);
                    if (value is RecordValue)
                    {
                        RecordValue   array = value as RecordValue;
                        List <string> names = new List <string>();
                        for (int i = 0; i < array.Associations.Length; i++)
                        {
                            names.Add(varName);
                        }
                        selectedVariables.Add(names.ToArray());
                        vectorLength.Add(array.Associations.Length); // array length
                    }
                    else if (false)
                    {
                        // todo: xingzc. processing other complex data type
                    }
                    else // primitive types
                    {
                        primitiveVariables.Add(varName);
                    }
                }

                /* now assume variables of left/right graphs are the same and variables of all the nodes are the same
                 * thus, no need to do this
                 */
                /*if (rightValuation != null && rightValuation.Variables != null)
                 * {
                 *  ExpressionValue value = rightValuation.Variables.GetContainsKey(varName);
                 *  if (value is RecordValue)
                 *  {
                 *      selectedVariables.Add(new string[] {varName});
                 *      //vectorsLength.Add((value as RecordValue).Associations.Length); // array length
                 *  }
                 *  else if (false)
                 *  {
                 *      // todo: xingzc. processing other complex data type
                 *  }
                 *  else // primitive types
                 *  {
                 *      primitiveVariables.Add(varName);
                 *  }
                 * }*/
            }

            if (primitiveVariables.Count > 0)
            {
                selectedVariables.Add(primitiveVariables.ToArray());
                vectorLength.Add(primitiveVariables.Count);
            }

            initialize();

            PAT.GenericDiff.diff.GenericDiff diff = new PAT.GenericDiff.diff.GenericDiff(
                diffParameters.compatibleTypes,
                diffParameters.mappingWeights,
                diffParameters.distanceThresholdVectors,
                diffParameters.epsilonEdgesExcluded,
                diffParameters.maxIteration,
                diffParameters.noPairupIdenticalNodesWithOthers,
                diffParameters.stepsOfNeighbors,
                diffParameters.stopGreedySearchThreshold,
                diffParameters.stopPropagationThreshold,
                diffParameters.removeOutliersThreshold,
                diffParameters.considerNodeDistance,
                diffParameters.considerEdgeDistance,
                diffParameters.includeUnmatched,
                diffParameters.includeNeighbors,
                diffParameters.conductCandidatesSearch,
                diffParameters.appendEpsilonPairups,
                diffParameters.doGreedySearch,
                diffParameters.compareAdditionalInfo,
                diffParameters.notMaximalBipartiteMatch,
                diffParameters.searchPotentialCandidatesKind,
                diffParameters.neighborhoodMatchingStrategyKind,
                diffParameters.removeOutliersStrtegyKind,
                diffParameters.matchingStrategyKind,
                null);

            leftSpec.GrabSharedDataLock();
            leftSpec.LockSharedData(true);
            PATModelFileParser modelParser1 = new PATModelFileParser(left, Side.LHS, compareParameterizedSystem, this.compareConfigGraph, matchProcessParameters, infinity, cutnumber1);

            PAT.GenericDiff.graph.Graph graphLeft = createGraph(Side.LHS, modelParser1, leftGraphDataConfigs, "leftgraph");
            leftSpec.UnLockSharedData();

            rightSpec.GrabSharedDataLock();
            rightSpec.LockSharedData(true);
            PATModelFileParser modelParser2 = new PATModelFileParser(right, Side.RHS, compareParameterizedSystem, this.compareConfigGraph, matchProcessParameters, infinity, cutnumber2);

            PAT.GenericDiff.graph.Graph graphRight = createGraph(Side.RHS, modelParser2, rightGraphDataConfigs, "rightgraph");
            rightSpec.UnLockSharedData();

            List <PairUpCandidate> matches = diff.compare(graphLeft, graphRight);

            return(matches);
        }
        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;
            }
        }