コード例 #1
0
        public ProcedureExecution(Procedure procedure, OrganisationalEntity organisation, Agent agent)
        {
            this.procedure    = procedure;
            this.organisation = organisation;
            this.agent        = agent;

            agentToPartition         = new Dictionary <string, ActivityPartition>();
            partitionToAgent         = new Dictionary <ActivityPartition, AID>();
            activeTokens             = new List <ActivityExecutionToken>();
            affectations             = new Dictionary <string, InstanceSpecification>();
            activityParams           = new Dictionary <string, ValueSpecification>();
            actionsRunning           = new List <KeyValuePair <string, ActionNode> >();
            actionsDone              = new List <ActionNode>();
            allActionsDone           = new Dictionary <string, List <ActionNode> >(); // key: AID
            allActionsDoneTimestamps = new Dictionary <string, List <TimeExpression> >();

            for (int i = 0; i < procedure.Activity.Partitions.Count; i++)
            {
                ActivityPartition      partition    = procedure.Activity.Partitions[i];
                List <RoleAssignement> assignements = organisation.RoleAssignement;
                for (int j = 0; j < assignements.Count; j++)
                {
                    if (partition.name == assignements[j].Role.name)
                    {
                        agentToPartition.Add(assignements[j].Agent.toString(), partition);
                        partitionToAgent.Add(partition, assignements[j].Agent);
                        Agent agt = MascaretApplication.Instance.AgentPlateform.Agents[assignements[j].Agent.toString()];
                        if (agt == null)
                        {
                            MascaretApplication.Instance.VRComponentFactory.Log("CA VA TRANCHER");
                        }
                        affectations.Add(partition.name, agt);
                    }
                }
            }

            ActivityExecutionToken initialToken = new ActivityExecutionToken();

            initialToken.currentLocation = procedure.Activity.Initial;

            if (initialToken.currentLocation == null)
            {
                System.Console.WriteLine("ERROR: no initial node found, not allowed");
                System.Console.WriteLine("Procedure will not start.");
                return;
            }

            List <ActivityEdge> controlFlows = procedure.Activity.Initial.getOutgoingControlFlowEdges();

            if (controlFlows.Count == 1)
            {
                initialToken.outgoingEdge = controlFlows[0];
                activeTokens.Add(initialToken);

                ActionNode dummyActionVariable = null;
                tryToAdvanceToken(initialToken, dummyActionVariable, true); //first advancement
            }
            else
            {
                if (controlFlows.Count == 0)
                {
                    System.Console.WriteLine("WARNING: initial node has no outgoing edges");
                }
                else
                {
                    System.Console.WriteLine("ERROR: multiple outgoing edges for the initial node, not allowed");
                }
                System.Console.WriteLine("Procedure will not start.");
            }
        }
コード例 #2
0
ファイル: Activity.cs プロジェクト: mbbarange/Mascaret
 public void addPartition(ActivityPartition val)
 {
     val.Activity = this;
     partitions.Add(val);
 }