Пример #1
0
        private void AddOneProcess(List <Process> processes, Process newProcess, Dictionary <string, int> counter)
        {
            if (newProcess is IndexInterleave)
            {
                IndexInterleave index = newProcess as IndexInterleave;

                foreach (Process processe in index.Processes)
                {
                    string tmp = processe.ProcessID;

                    if (!counter.ContainsKey(tmp))
                    {
                        counter.Add(tmp, 1);
                        processes.Add(processe);
                    }
                    else
                    {
                        counter[tmp] = Common.Classes.Ultility.Ultility.ProcessCounterIncrement(MustAbstract ? Common.Classes.Ultility.Ultility.CutNumber : -1, counter[tmp], 1);
                    }
                }
            }
            else if (newProcess is IndexInterleaveAbstract)
            {
                IndexInterleaveAbstract index = newProcess as IndexInterleaveAbstract;

                foreach (Process processe in index.Processes)
                {
                    string tmp = processe.ProcessID;

                    if (!counter.ContainsKey(tmp))
                    {
                        counter.Add(tmp, index.ProcessesCounter[tmp]);
                        processes.Add(processe);
                    }
                    else
                    {
                        counter[tmp] = Common.Classes.Ultility.Ultility.ProcessCounterIncrement(MustAbstract ? Common.Classes.Ultility.Ultility.CutNumber : -1, counter[tmp], index.ProcessesCounter[tmp]);
                    }
                }
            }
            else
            {
                string tmp = newProcess.ProcessID;
                if (!counter.ContainsKey(tmp))
                {
                    counter.Add(tmp, 1);
                    processes.Add(newProcess);
                }
                else
                {
                    counter[tmp] = Common.Classes.Ultility.Ultility.ProcessCounterIncrement(MustAbstract?Common.Classes.Ultility.Ultility.CutNumber : -1, counter[tmp], 1);
                }
            }
        }
Пример #2
0
        private void SynchronousChannelInputOutput(List <Configuration> returnList, int i, Valuation GlobalEnv, string evt)
        {
            List <ConfigurationWithChannelData> outputs = new List <ConfigurationWithChannelData>();

            Processes[i].SyncOutput(GlobalEnv, outputs);

            foreach (ConfigurationWithChannelData pair in outputs)
            {
                Configuration vm = pair;

                if (evt != null && vm.Event != evt)
                {
                    continue;
                }

                Process output = vm.Process;

                for (int k = 0; k < Processes.Count; k++)
                {
                    if (k != i)
                    {
                        List <Configuration> syncedProcess = new List <Configuration>();
                        Processes[k].SyncInput(pair, syncedProcess);

                        foreach (Configuration p in syncedProcess)
                        {
                            List <Process> newProcess = new List <Process>(Processes.Count);
                            newProcess.AddRange(Processes);
                            newProcess[i] = output;
                            newProcess[k] = p.Process;

                            IndexInterleave interleave = new IndexInterleave(newProcess);
                            Configuration   newStep    = new Configuration(interleave, vm.Event, vm.DisplayName, p.GlobalEnv, false);
                            newStep.IsAtomic = vm.IsAtomic || p.IsAtomic;

                            if (AssertionBase.CalculateParticipatingProcess)
                            {
                                newStep.ParticipatingProcesses = new string[] { i.ToString(), k.ToString() };
                            }

                            returnList.Add(newStep);
                        }
                    }
                }
            }
        }
Пример #3
0
        public override Process Rename(Dictionary <string, Expression> constMapping, Dictionary <string, string> newDefNames, Dictionary <string, Definition> renamedProcesses)
        {
            List <Process> newnewListProcess = Processes;

            if (Processes == null)
            {
                newnewListProcess = IndexedProcessDefinition.GetIndexedProcesses(constMapping);
            }

            List <Process> newProceses = new List <Process>();

            foreach (Process process in newnewListProcess)
            {
                newProceses.Add(process.Rename(constMapping, newDefNames, renamedProcesses));
            }

            Process result = new IndexInterleave(newProceses);

            result.IsBDDEncodableProp = this.IsBDDEncodableProp;
            return(result);
        }
Пример #4
0
        public IndexInterleave(List <Process> processes)
        {
            Processes = processes;

            List <string> tmp     = new List <string>(Processes.Count);
            bool          hasStop = false;

            for (int i = 0; i < Processes.Count; i++)
            {
                if (Processes[i] is IndexInterleave)
                {
                    IndexInterleave newProc = (Processes[i] as IndexInterleave);

                    if (newProc.Processes != null)
                    {
                        foreach (Process processe in newProc.Processes)
                        {
                            if (!hasStop && processe is Stop)
                            {
                                hasStop = true;
                            }

                            if (!(processe is Stop && hasStop) && !(processe is Skip))
                            {
                                tmp.Add(processe.ProcessID);
                            }
                        }
                    }
                    else
                    {
                        tmp.Add(newProc.IndexedProcessDefinition.ToString());
                    }
                }
                else
                {
                    if (!hasStop && Processes[i] is Stop)
                    {
                        hasStop = true;
                    }

                    if (!(Processes[i] is Stop && hasStop) && !(Processes[i] is Skip))
                    {
                        tmp.Add(Processes[i].ProcessID);
                    }
                }
            }

            if (tmp.Count == 0)
            {
                if (hasStop)
                {
                    Stop stop = new Stop();
                    Processes = new List <Process>();
                    Processes.Add(stop);
                    ProcessID = stop.ProcessID;
                }
                else
                {
                    Skip skip = new Skip();
                    Processes = new List <Process>();
                    Processes.Add(skip);
                    ProcessID = skip.ProcessID;
                }
            }
            else
            {
                //tmp.Sort();

                ProcessID = Constants.INTERLEAVE + tmp[0];
                for (int i = 1; i < tmp.Count; i++)
                {
                    ProcessID += Constants.SEPARATOR + tmp[i];
                }

                ProcessID = DataStore.DataManager.InitializeProcessID(ProcessID);
            }
        }
Пример #5
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 (SpecificationBase.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;
        }