Exemplo n.º 1
0
        public override void MoveOneStep(Valuation GlobalEnv, List <Configuration> list)
        {
            System.Diagnostics.Debug.Assert(list.Count == 0);

            FirstProcess.MoveOneStep(GlobalEnv, list);

            for (int i = 0; i < list.Count; i++)
            {
                Configuration step = list[i];
                if (step.Event != Constants.TERMINATION)
                {
                    Interrupt inter = new Interrupt(step.Process, SecondProcess);
                    step.Process = inter;
                }
            }

            List <Configuration> list2 = new List <Configuration>();

            SecondProcess.MoveOneStep(GlobalEnv, list2);
            for (int i = 0; i < list2.Count; i++)
            {
                Configuration step = list2[i];
                if (step.Event == Constants.TAU)
                {
                    Interrupt inter = new Interrupt(FirstProcess, step.Process);

                    step.Process = inter;
                }

                list.Add(step);
            }

            //return returnList;
        }
Exemplo n.º 2
0
        public override void MoveOneStep(Valuation GlobalEnv, List <Configuration> list)
        {
            System.Diagnostics.Debug.Assert(list.Count == 0);

            if (FirstProcess is Skip ||
                (FirstProcess is AtomicProcess && (FirstProcess as AtomicProcess).Process is Skip))
            {
                SecondProcess.MoveOneStep(GlobalEnv, list);
                return;
            }

            FirstProcess.MoveOneStep(GlobalEnv, list);
            for (int i = 0; i < list.Count; i++)
            {
                Configuration step = list[i];
                if (step.Event == Constants.TERMINATION)
                {
                    step.Event   = Constants.TAU;
                    step.Process = SecondProcess;
                }
                else
                {
                    Sequence p = new Sequence(step.Process, this.SecondProcess);
                    step.Process = p;
                }
                list[i] = step;
            }
        }
Exemplo n.º 3
0
        public override IEnumerable <ConfigurationBase> MakeOneMove()
        {
            List <Configuration> list = new List <Configuration>();

            Process.MoveOneStep(GlobalEnv, list);

            if (SpecificationBase.HasAtomicEvent)
            {
                List <Configuration> returnList = new List <Configuration>();
                foreach (Configuration configuration in list)
                {
                    if (configuration.IsAtomic)
                    {
                        returnList.Add(configuration);
                    }
                }

                if (returnList.Count > 0)
                {
                    return(returnList);
                }
            }

            IsDeadLock = list.Count == 0;
            return(list);
        }
Exemplo n.º 4
0
        public override void MoveOneStep(Valuation GlobalEnv, List <Configuration> list)
        {
            System.Diagnostics.Debug.Assert(list.Count == 0);

            Process.MoveOneStep(GlobalEnv, list);

            foreach (Configuration configuration in list)
            {
                configuration.Process  = new AtomicProcess(configuration.Process, true);
                configuration.IsAtomic = Started;
            }
        }
        public override void MoveOneStep(Valuation GlobalEnv, List <Configuration> list)
        {
            ExpressionValue v = EvaluatorDenotational.Evaluate(ConditionalExpression, GlobalEnv);

            if ((v as BoolConstant).Value)
            {
                FirstProcess.MoveOneStep(GlobalEnv, list);
            }
            else
            {
                SecondProcess.MoveOneStep(GlobalEnv, list);
            }
        }
Exemplo n.º 6
0
        public override void MoveOneStep(Valuation GlobalEnv, List <Configuration> list)
        {
            System.Diagnostics.Debug.Assert(list.Count == 0);

            ExpressionValue v = EvaluatorDenotational.Evaluate(Condition, GlobalEnv);

            if ((v as BoolConstant).Value)
            {
                Process.MoveOneStep(GlobalEnv, list);
            }

            //return new List<Configuration>(0);
        }
Exemplo n.º 7
0
        public override void MoveOneStep(Valuation GlobalEnv, List <Configuration> list)
        {
            System.Diagnostics.Debug.Assert(list.Count == 0);

            Process.MoveOneStep(GlobalEnv, list); //List<Configuration> returnlist =
            for (int i = 0; i < list.Count; i++)
            {
                Configuration step = list[i];

                if (HidingAlphabets.ContainEventName(step.Event))
                {
                    step.DisplayName = "[" + step.Event + "]";
                    step.Event       = Constants.TAU;
                }

                Hiding newHide = new Hiding(step.Process, HidingAlphabets);

                step.Process = newHide;
                list[i]      = step;
            }
        }
Exemplo n.º 8
0
        public override void MoveOneStep(Valuation GlobalEnv, List <Configuration> list)
        {
            System.Diagnostics.Debug.Assert(list.Count == 0);

            bool allTerminationCount  = true;
            bool hasAtomicTermination = false;

            for (int i = 0; i < Processes.Count; i++)
            {
                Process process            = Processes[i];
                List <Configuration> list1 = new List <Configuration>();
                process.MoveOneStep(GlobalEnv, list1);
                bool hasTermination = false;

                for (int j = 0; j < list1.Count; j++)
                {
                    Configuration step = list1[j];

                    if (step.Event == Constants.TERMINATION)
                    {
                        hasTermination = true;

                        if (step.IsAtomic)
                        {
                            hasAtomicTermination = true;
                        }
                    }
                    else
                    {
                        if (AssertionBase.CalculateParticipatingProcess)
                        {
                            step.ParticipatingProcesses = new string[] { i.ToString() };
                        }

                        List <Process> newProcess = new List <Process>(Processes.Count);
                        newProcess.AddRange(Processes);
                        newProcess[i] = step.Process;

                        IndexInterleave interleave = new IndexInterleave(newProcess);
                        step.Process = interleave;
                        list.Add(step);
                    }
                }

                //to check whether there are synchoronous channel input/output
                if (Specification.HasSyncrhonousChannel)
                {
                    SynchronousChannelInputOutput(list, i, GlobalEnv, null);
                }

                if (!hasTermination)
                {
                    allTerminationCount = false;
                }
            }

            if (allTerminationCount)
            {
                Configuration temp = new Configuration(new Stop(), Constants.TERMINATION, null, GlobalEnv, false);

                if (hasAtomicTermination)
                {
                    temp.IsAtomic = true;
                }

                if (AssertionBase.CalculateParticipatingProcess)
                {
                    temp.ParticipatingProcesses = new string[Processes.Count];
                    for (int i = 0; i < Processes.Count; i++)
                    {
                        temp.ParticipatingProcesses[i] = i.ToString();
                    }
                }
                list.Add(temp);
            }

            //return returnList;
        }
Exemplo n.º 9
0
        public override void MoveOneStep(Valuation GlobalEnv, List <Configuration> list)
        {
            System.Diagnostics.Debug.Assert(list.Count == 0);

            int  TerminationCount     = 0;
            bool hasAtomicTermination = false;

            List <Dictionary <string, int> > nextProcessCounters = null;

            for (int i = 0; i < Processes.Count; i++)
            {
                Process process            = Processes[i];
                List <Configuration> list1 = new List <Configuration>();
                process.MoveOneStep(GlobalEnv, list1);

                bool hasTermination = false;

                if (list1.Count > 0)
                {
                    nextProcessCounters = Common.Classes.Ultility.Ultility.ProcessCounterDecrement(Common.Classes.Ultility.Ultility.CutNumber, ProcessesCounter, process.ProcessID, 1);
                }

                for (int j = 0; j < list1.Count; j++)
                {
                    Configuration step = list1[j];

                    if (step.Event == Constants.TERMINATION)
                    {
                        hasTermination = true;

                        if (step.IsAtomic)
                        {
                            hasAtomicTermination = true;
                        }
                    }
                    else
                    {
                        foreach (Dictionary <string, int> ints in nextProcessCounters)
                        {
                            Dictionary <string, int> listInstance = new Dictionary <string, int>(ints);

                            List <Process> newProcess = new List <Process>(Processes);

                            AddOneProcess(newProcess, step.Process, listInstance);

                            IndexInterleaveAbstract interleave = new IndexInterleaveAbstract(newProcess, listInstance);
                            Configuration           newStep    = new Configuration(interleave, step.Event, step.DisplayName, step.GlobalEnv, step.IsDataOperation);
                            newStep.IsAtomic = step.IsAtomic;

                            if (AssertionBase.CalculateParticipatingProcess)
                            {
                                newStep.ParticipatingProcesses = new string[] { process.ProcessID };
                            }

                            list.Add(newStep);
                        }
                    }
                }

                if (hasTermination)
                {
                    TerminationCount++;
                }

                //to check whether there are synchoronous channel input/output
                if (Specification.HasSyncrhonousChannel)
                {
                    SynchronousChannelInputOutput(list, i, GlobalEnv, null);
                }
            }

            if (TerminationCount == Processes.Count)
            {
                Configuration temp = new Configuration(new Stop(), Constants.TERMINATION, null, GlobalEnv, false);

                if (hasAtomicTermination)
                {
                    temp.IsAtomic = true;
                }

                if (AssertionBase.CalculateParticipatingProcess)
                {
                    temp.ParticipatingProcesses = new string[Processes.Count];
                    for (int i = 0; i < Processes.Count; i++)
                    {
                        temp.ParticipatingProcesses[i] = i.ToString();
                    }
                }
                list.Add(temp);
            }

            //return returnList;
        }