public void addRole(Role role) { System.Console.WriteLine(" Adding Role : " + role.name + " in " + this.name); roles.Add(role); }
public RoleAssignement(OrganisationalEntity organisation) { role = new Role(""); agent = new AID("", "", 0); this.organisation = organisation; }
public void addOrganisationalStructure(XElement orgNode) { XAttribute orgName = (XAttribute)orgNode.Attribute("name"); OrganisationalStructure organisation = new OrganisationalStructure(orgName.Value); organisation.Description = getComment(orgNode); organisation.Summary = getSummary(orgNode); organisation.Tags = getTags(orgNode); //Debug.Log(MascaretApplication.Instance.Model.name); MascaretApplication.Instance.AgentPlateform.Structures.Add(organisation); foreach (XElement child in orgNode.Elements()) { if (child.Name.LocalName.CompareTo("ownedAttribute") == 0) { string childType = "", roleName = ""; Classifier classe = null; XAttribute attr = (XAttribute)child.Attribute("type"); if (attr != null) { childType = attr.Value; classe = this._classifiers[childType]; } attr = (XAttribute)child.Attribute("name"); if (attr != null) roleName = attr.Value; if (classe != null) { try { Role role = new Role(roleName); role.RoleClass = (RoleClass)classe; organisation.addRole(role); } catch (InvalidCastException) { try { Ressource ressource = new Ressource(roleName); ressource.EntityClass = (EntityClass)classe; organisation.addResource(ressource); } catch (InvalidCastException) { } } } } } foreach (XElement child in orgNode.Elements()) { if (child.Name.LocalName.CompareTo("ownedBehavior") == 0) { string childType = "", childName = "", childId = ""; XAttribute attr = (XAttribute)child.Attribute("{http://schema.omg.org/spec/XMI/2.1}type"); if (attr == null) attr = (XAttribute)child.Attribute("{http://www.omg.org/spec/XMI/20131001}type"); if (attr != null) childType = attr.Value; attr = (XAttribute)child.Attribute("name"); if (attr != null) childName = attr.Value; attr = (XAttribute)child.Attribute("{http://schema.omg.org/spec/XMI/2.1}id"); if (attr == null) attr = (XAttribute)child.Attribute("{http://www.omg.org/spec/XMI/20131001}id"); if (attr != null) childId = attr.Value; if (childType.CompareTo("uml:Activity") == 0) { Activity activity = addActivity(child); Procedure procedure = null; MascaretApplication.Instance.VRComponentFactory.Log(" ?????? Procedure : " + childId); if (isStereotypedScenarioPedagogique(child)) { procedure = new PedagogicalScenario(childName); XAttribute attr2 = child.Attribute("{http://schema.omg.org/spec/XMI/2.1}id"); if (attr2 == null) attr2 = child.Attribute("{http://www.omg.org/spec/XMI/20131001}id"); ((PedagogicalScenario)procedure).Scene = _scenarioToScene[attr2.Value]; } else procedure = new Procedure(childName); procedure.Activity = activity; string stereo = getStereotype(childId); MascaretApplication.Instance.VRComponentFactory.Log("procedure;;;;;;;;;;;;;;;;;;;;;;;;;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + childName + " : " + childId + " " + stereo); if (stereo != "") { procedure.Stereotype = stereo; } organisation.addProcedure(procedure); _idBehaviors.Add(childId, activity); } } } }
public void pushProcedureToDo(Procedure proc, OrganisationalEntity org, Role role, Dictionary<String, ValueSpecification> parameters) { Agent agt = (Agent)(this.Host); ProcedureExecution procInfo = new ProcedureExecution(proc, org, agt); procInfo.buildAffectations(parameters, this.Host); /* Search if the current agent have something to do in this procedure */ List<ActivityPartition> parts = proc.Activity.Partitions; bool found = false; for (int iP = 0; iP < parts.Count; iP++) { if (parts[iP].name == role.name) { // file.WriteLine("[ProceduralBehavior Info] Found a role " + role.name + " in procedure " + proc.name); file.Flush(); found = true; } } runningProcedures.Add(procInfo); ispause = false; if (!found) { //inform all agents that this agent's role in this procedure has ended (used to unblock tokens in ProcedureExecution) sendProcedureDoneMessage(procInfo); runningProcedures.RemoveAt(runningProcedures.Count - 1); //remove it.. // ispause = true; } }