Exemplo n.º 1
0
        private static 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(Common.Classes.Ultility.Ultility.CutNumber, 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(Common.Classes.Ultility.Ultility.CutNumber, 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(Common.Classes.Ultility.Ultility.CutNumber, counter[tmp], 1);
                }
            }
        }
Exemplo n.º 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, GlobalEnv, false);
                            newStep.IsAtomic = vm.IsAtomic || p.IsAtomic;

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

                            returnList.Add(newStep);
                        }
                    }
                }
            }
        }
Exemplo n.º 3
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, GlobalEnv, false);
                            newStep.IsAtomic = vm.IsAtomic || p.IsAtomic;

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

                            returnList.Add(newStep);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
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.º 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 (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.º 6
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);
            }
        }