Exemplo n.º 1
0
//#if XZC
//        public override List<string> GetActiveProcesses(Valuation GlobalEnv)
//        {
//            List<string> list = new List<string>();
//            for (int i = 0; i < Processes.Count; i++)
//            {
//                Common.Classes.Ultility.Ultility.AddList(list, Processes[i].GetActiveProcesses(GlobalEnv));
//            }
//            return list;
//        }
//#endif

        public override Process ClearConstant(Dictionary <string, Expression> constMapping)
        {
            List <Process> newnewListProcess = Processes;

            if (Processes == null)
            {
                if (Specification.IsParsing)
                {
                    return(new IndexExternalChoice(IndexedProcessDefinition.ClearConstant(constMapping)));
                }

                newnewListProcess = IndexedProcessDefinition.GetIndexedProcesses(constMapping);
            }

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

            for (int i = 0; i < newnewListProcess.Count; i++)
            {
                Process newProc = newnewListProcess[i].ClearConstant(constMapping);
                if (!(newProc is Stop))
                {
                    newListProcess.Add(newProc);
                }
            }

            //all processes are stop processes
            if (newListProcess.Count == 0)
            {
                return(new Stop());
            }

            return(new IndexExternalChoice(newListProcess));
        }
Exemplo n.º 2
0
//#if XZC
//        public override List<string> GetActiveProcesses(Valuation GlobalEnv)
//        {
//            if (Alphabets == null)
//            {
//                IdentifySharedEventsAndVariables();
//            }

//            List<string> resultList = new List<string>(Processes.Count);

//            List<Configuration> enabled = null;
//            int processesCount = Processes.Count;

//            //local action will make the process index to be true.
//            for (int i = 0; i < processesCount; i++)
//            {
//                enabled = new List<Configuration>();
//                Processes[i].MoveOneStep(GlobalEnv, enabled);
//                //enabled = Processes[i].GetEnabled(eStep);

//                foreach (Configuration s in enabled)
//                {
//                    if (!Alphabets[i].Contains(s.Event))
//                    {
//                        //resultList.Add(i.ToString());
//                        Common.Classes.Ultility.Ultility.AddList(resultList, Processes[i].GetActiveProcesses(GlobalEnv));

//                        break;
//                    }
//                }

//                //to check whether there are synchoronous channel input/output
//                if (SpecificationBase.HasSyncrhonousChannel)
//                {
//                    List<ConfigurationWithChannelData> outputs = new List<ConfigurationWithChannelData>();
//                    Processes[i].SyncOutput(GlobalEnv, outputs);

//                    foreach (ConfigurationWithChannelData vm in outputs)
//                    {
//                        for (int k = 0; k < Processes.Count; k++)
//                        {
//                            if (k != i)
//                            {
//                                List<Configuration> syncedProcess = new List<Configuration>();
//                                Processes[k].SyncInput(vm, syncedProcess);

//                                if (syncedProcess.Count > 0)
//                                {
//                                    Common.Classes.Ultility.Ultility.AddList(resultList, Processes[i].GetActiveProcesses(GlobalEnv));
//                                    Common.Classes.Ultility.Ultility.AddList(resultList, Processes[k].GetActiveProcesses(GlobalEnv));
//                                }
//                            }
//                        }
//                    }
//                }
//            }

//            enabled = new List<Configuration>();
//            MoveOneStep(GlobalEnv, enabled);

//            //shared actions will make the process index to be true.
//            foreach (Configuration s in enabled)
//            {
//                for (int i = 0; i < Alphabets.Length; i++)
//                {
//                    if(Alphabets[i].Contains(s.Event))
//                    {
//                        Common.Classes.Ultility.Ultility.AddList(resultList, Processes[i].GetActiveProcesses(GlobalEnv));
//                    }
//                }
//            }

//            return resultList;

//        }
//#endif

        public override Process ClearConstant(Dictionary <string, Expression> constMapping)
        {
            List <Process> newnewProcesses = Processes;

            List <Process> newProceses;
            int            size;

            if (Specification.IsParsing)
            {
                if (Processes == null)
                {
                    return(new IndexParallel(IndexedProcessDefinition.ClearConstant(constMapping)));
                }
                size        = Processes.Count;
                newProceses = new List <Process>(size);
                for (int i = 0; i < size; i++)
                {
                    newProceses.Add(Processes[i].ClearConstant(constMapping));
                }
            }

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

            size = newnewProcesses.Count;

            newProceses = new List <Process>(size);
            for (int i = 0; i < size; i++)
            {
                Process newProc = newnewProcesses[i].ClearConstant(constMapping);

                if (newProc is IndexParallel && (newProc as IndexParallel).Processes != null)
                {
                    List <Process> processes = (newProc as IndexParallel).Processes;
                    newProceses.AddRange(processes);
                }
                else
                {
                    newProceses.Add(newProc);
                }
            }

            return(new IndexParallel(newProceses));
        }
Exemplo n.º 3
0
        public override Process ClearConstant(Dictionary <string, Expression> constMapping)
        {
            List <Process> newProceses = new List <Process>();

            if (Specification.IsParsing)
            {
                if (Processes == null)
                {
                    return(new IndexInterleave(IndexedProcessDefinition.ClearConstant(constMapping)));
                }

                foreach (Process procese in Processes)
                {
                    newProceses.Add(procese.ClearConstant(constMapping));
                }

                return(new IndexInterleave(newProceses));
            }

            List <Process> newnewProcesses = Processes;

            if (Processes == null)
            {
                //return new IndexInterleave(IndexedProcessDefinition.GetIndexedProcesses(constMapping));
                newnewProcesses = IndexedProcessDefinition.GetIndexedProcesses(constMapping);
            }

            int size = newnewProcesses.Count;
            Dictionary <string, int> processCounters = new Dictionary <string, int>(size);

            for (int i = 0; i < size; i++)
            {
                Process newProc = newnewProcesses[i].ClearConstant(constMapping);

                if (newProc is IndexInterleave)
                {
                    List <Process> processes = (newProc as IndexInterleave).Processes;

                    foreach (var processe in processes)
                    {
                        string tmp = processe.ProcessID;
                        if (!processCounters.ContainsKey(tmp))
                        {
                            newProceses.Add(processe);
                            processCounters.Add(tmp, 1);
                        }
                        else
                        {
                            processCounters[tmp] = processCounters[tmp] + 1;
                        }
                    }
                }
                else if (newProc is IndexInterleaveAbstract)
                {
                    IndexInterleaveAbstract intAbs = newProc as IndexInterleaveAbstract;

                    foreach (var processe in intAbs.Processes)
                    {
                        string tmp = processe.ProcessID;
                        if (!processCounters.ContainsKey(tmp))
                        {
                            newProceses.Add(processe);
                            processCounters.Add(tmp, intAbs.ProcessesActualSize[tmp]);
                        }
                        else
                        {
                            processCounters[tmp] = processCounters[tmp] + intAbs.ProcessesCounter[tmp];
                        }
                    }
                }
                else
                {
                    if (!processCounters.ContainsKey(newProc.ProcessID))
                    {
                        newProceses.Add(newProc);
                        processCounters.Add(newProc.ProcessID, 1);
                    }
                    else
                    {
                        processCounters[newProc.ProcessID] = processCounters[newProc.ProcessID] + 1;
                    }
                }
            }

            foreach (KeyValuePair <string, int> pair in processCounters)
            {
                if (pair.Value > 1 || pair.Value == -1)
                {
                    IndexInterleaveAbstract toReturn = new IndexInterleaveAbstract(newProceses, processCounters);
                    toReturn.ProcessesActualSize = new Dictionary <string, int>(processCounters);
                    return(toReturn);
                }
            }

            return(new IndexInterleave(newProceses));
        }