public CallBehaviorBehaviorExecution(CallBehaviorAction paction, InstanceSpecification host, Dictionary<string, ValueSpecification> p)
     : base(paction, host, p, false)
 {
     this.action = paction;
 }
Пример #2
0
        //FinalNode, Merge et Decision devraent �tre des activityNode !!
        public void addActivityNode(XElement node, Activity activity)
        {
            MascaretApplication.Instance.VRComponentFactory.Log("New activity node");
            string type = "";
            string id = "";
            if (node.Attribute("{http://schema.omg.org/spec/XMI/2.1}type") != null)
                type = node.Attribute("{http://schema.omg.org/spec/XMI/2.1}type").Value;
            else
                type = node.Attribute("{http://www.omg.org/spec/XMI/20131001}type").Value;

            MascaretApplication.Instance.VRComponentFactory.Log(" Type : " + type);

            if (node.Attribute("{http://schema.omg.org/spec/XMI/2.1}id") != null)
                id = node.Attribute("{http://schema.omg.org/spec/XMI/2.1}id").Value;
            else
                id = node.Attribute("{http://www.omg.org/spec/XMI/20131001}id").Value;
            MascaretApplication.Instance.VRComponentFactory.Log(" ID : " + id);

            string name = "";
            if (node.Attribute("name") != null)
                name = node.Attribute("name").Value;
            else name = id;
            MascaretApplication.Instance.VRComponentFactory.Log(" Name : " + name);

            string idPartition = "";
            if (node.Attribute("inPartition") != null)
                idPartition = node.Attribute("inPartition").Value;

            MascaretApplication.Instance.VRComponentFactory.Log(id);
            MascaretApplication.Instance.VRComponentFactory.Log(type);
            MascaretApplication.Instance.VRComponentFactory.Log(name);
            MascaretApplication.Instance.VRComponentFactory.Log(idPartition);

            ActivityNode actNode = null;

            //Debug.Log(" TYPE NODE : " + type);

            if (type == "uml:InitialNode")
            {
                actNode = new InitialNode();
                activity.Initial = actNode;
                actNode.name = "Initial";
            }
            else if (type == "uml:FinalNode" || type == "uml:ActivityFinalNode")
            {
                actNode = new FinalNode();
            }
            else if (type == "uml:LoopNode")
            {
                addActivityGroup(node, activity);
            }
            else if (type == "uml:ForkNode")
            {
                actNode = new ForkNode();
            }
            else if (type == "uml:JoinNode")
            {
                actNode = new JoinNode();
            }
            else if (type == "uml:MergeNode")
            {
                actNode = new MergeNode();
            }
            /*else if (type == "uml:DecisionNode")
            {
                actNode = new DecisionNode();
            }*/
            else if (type == "uml:ObjectNode" || type == "uml:CentralBufferNode")
            {

                ObjectNode objNode = new ObjectNode(name);
                Classifier ressourceType = getObjectNodeType(node);
                if (ressourceType != null)
                    objNode.ResourceType = ressourceType;
                actNode = objNode;
                string type2 = node.Attribute("{http://schema.omg.org/spec/XMI/2.1}type").Value;
                if (_idClass.ContainsKey(type2))
                    ((ObjectNode)actNode).ResourceType = _idClass[type2];
            }
            else if (type == "uml:ValueSpecificationAction")
            {
                /*
                shared_ptr<XmlNode> valueNode = node->getChildByName("value");
                string expressionValue = valueNode->getProperty("value");
                shared_ptr<Expression> expression = make_shared<Expression>(expressionValue, _model->getBasicType("boolean"));
                _activityExpressions[node->getProperty("id")] = expression;
                */
            }
            else if (type == "uml:OpaqueAction")
            {
                if (isStereotypedPlayAnimation(node))
                {
                    string animationName = getAnimName(node);
                    MascaretApplication.Instance.VRComponentFactory.Log("%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% NEW PLAY ANIMATION : " + name + "    " + animationName);

                    ActionNode an = new ActionNode(name, "action");
                    PlayAnimationAction ap = new PlayAnimationAction();
                    ap.Description = getComment(node);
                    ap.name = name;
                    ap.Owner = activity;
                    ap.animationName = animationName;

                    an.Action = ap;
                    addPins(an, node);
                    actNode = an;
                }
            }
            else if (type == "uml:CallBehaviorAction")
            {

                ActionNode an = new ActionNode(name, "action");
                CallBehaviorAction cb = new CallBehaviorAction();
                cb.Description = getComment(node);
                cb.name = name;
                cb.Owner = activity;
                XElement beNode = node.Element("behavior");

                string opid;

                if (beNode != null) opid = beNode.Attribute("idref").Value;
                else opid = node.Attribute("behavior").Value;

                if (_idBehaviors.ContainsKey(opid))
                {
                    cb.Behavior = _idBehaviors[opid];
                }
                else
                {
                    // Debug.Log("[ModelLoader2 Info] Behavior " + opid
                    //           + " not yet found for ActionNode " + name + ". Postbone...");
                    _callBehaviors.Add(cb, opid);
                }

                an.Action = cb;
                addPins(an, node);
                actNode = an;

            }
            else if (type == "uml:CallOperationAction")
            {

                ActionNode an = new ActionNode(name, "action");
                //Debug.Log("Action Node : " +name);
                CallOperationAction act = new CallOperationAction();
                act.Description = getComment(node);
                an.Fml = getFML(node);

                act.name = name;

                act.Owner = activity;

                XElement opNode = node.Element("operation");
                if (opNode != null)
                {
                    string opid;
                    opid = opNode.Attribute("idref").Value;
                    //MascaretApplication.Instance.logfile.WriteLine("Operation ID : " + opid); MascaretApplication.Instance.logfile.Flush();
                    string stereo = getStereotype(opid);
                    MascaretApplication.Instance.VRComponentFactory.Log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + name + " : " + opid + " " + stereo);
                    if (stereo != "")
                    {

                        an.Stereotype = stereo;
                    }

                    if (_idOperations.ContainsKey(opid))
                        act.Operation = _idOperations[opid];
                    else
                    {
                        //cerr << "ERREUR PAS OPERATION... " << opid<< endl;
                        _callOperations.Add(act, opid);
                    }
                }
                else
                {
                    string opid;
                    opid = node.Attribute("operation").Value;
                    // MascaretApplication.Instance.logfile.WriteLine("Operation ID : " + opid); MascaretApplication.Instance.logfile.Flush();
                    string stereo = getStereotype(opid);
                    MascaretApplication.Instance.VRComponentFactory.Log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" + name + " : " + opid + " " + stereo);
                    if (stereo != "")
                    {

                        an.Stereotype = stereo;
                    }

                    // MascaretApplication.Instance.logfile.WriteLine("Operation ID : " + opid); MascaretApplication.Instance.logfile.Flush();

                    if (_idOperations.ContainsKey(opid))
                    {
                        act.Operation = _idOperations[opid];
                        // MascaretApplication.Instance.logfile.WriteLine("Operation Name : " + act.Operation); MascaretApplication.Instance.logfile.Flush();

                    }
                    else
                        _callOperations.Add(act, opid);
                }
                an.Action = act;
                addPins(an, node);
                actNode = an;
            }
            else if (type == "uml:SendSignalAction")
            {
                MascaretApplication.Instance.VRComponentFactory.Log("SendSignalAction");
                ActionNode an = new ActionNode(name, "action");
                SendSignalAction act = new SendSignalAction();
                XElement sigNode = node.Element("signal");
                if (sigNode != null)
                {
                    string signame = sigNode.Attribute("name").Value;
                    if (!_signals.ContainsKey(signame))
                    {
                        Signal ns = new Signal(signame);
                        _signals.Add(signame, ns);
                    }
                    act.SignalClass = _signals[signame];
                }
                else
                {
                    string signame = "";
                    if (node.Attribute("signal") != null)
                        signame = node.Attribute("signal").Value;
                    if (!_signals.ContainsKey(signame))
                    {
                        Signal ns = new Signal(signame);
                        _signals.Add(signame, ns);
                    }

                    act.SignalClass = _signals[signame];
                }

                XElement targetNode = node.Element("argument");
                if (targetNode != null)
                {
                    string targetName = targetNode.Attribute("name").Value;
                    XElement typeNode = targetNode.Element("type");
                    string classid = "";
                    if (typeNode != null)
                        classid = typeNode.Attribute("idref").Value;
                    else
                        classid = targetNode.Attribute("type").Value;
                    act.Target = new SendSignalTarget();
                    act.Target.targetName = targetName;
                    act.Target.targetClass = _idClass[classid];
                }
                else
                {
                    targetNode = node.Element("target");
                    if (targetNode != null)
                    {
                        MascaretApplication.Instance.VRComponentFactory.Log("SendSignal Target");
                        string targetName = targetNode.Attribute("name").Value;
                        string classid = targetNode.Attribute("type").Value;
                        MascaretApplication.Instance.VRComponentFactory.Log("name : " + targetName);
                        MascaretApplication.Instance.VRComponentFactory.Log("name : " + targetName + " : " + _idClass[classid]);

                        act.Target = new SendSignalTarget();
                        act.Target.targetName = targetName;
                        act.Target.targetClass = _idClass[classid];

                    }
                    else MascaretApplication.Instance.VRComponentFactory.Log("No target");
                }
                an.Action = act;
                addPins(an, node);
                actNode = an;
            }
            else if (type == "uml:AddStructuralFeatureValueAction")
            {
                //cerr << " ############# Found a AddStructuralFeatureValueAction : " << endl;
                /*
                shared_ptr<ActionNode> an = make_shared<ActionNode>(name);
                shared_ptr<Classifier> type;
                shared_ptr<XmlNode> pinNode = node->getChildByName("object");

                string attrName = pinNode->getProperty("name");

                cerr << " Name == " << attrName << endl;

                shared_ptr<XmlNode> typeNode = pinNode->getChildByName("type");
                if (typeNode && typeNode->getProperty("type") == "uml:PrimitiveType")
                {
                    string href = typeNode->getProperty("href");
                    string strType = href.substr(href.rfind('#') + 1);
                    boost::to_lower(strType);
                    type = _model->getBasicType(strType);
                }

                shared_ptr<XmlNode> valueNode = pinNode->getChildByName("value");
                if (valueNode)
                {
                    string value = valueNode->getProperty("value");
                    cerr << "    VALUE : " << value << endl;
                    shared_ptr<Expression> expression = make_shared<Expression>(value, type);
                    shared_ptr<AddStructuralFeatureValueAction> act =
                        make_shared<AddStructuralFeatureValueAction>();
                    act->setValue(expression);
                    act->setProperty(attrName);
                    an->setAction(act);
                }
                actNode = an;
                */

            }
            else if (type == "uml:AcceptEventAction")
            {
                MascaretApplication.Instance.VRComponentFactory.Log("New uml:AcceptEventAction");
                ActionNode an = new ActionNode(name, "action");
                AcceptEventAction act = new AcceptEventAction();

                XElement triggerNode = node.Element("trigger");
                if (triggerNode != null)
                {
                    MascaretApplication.Instance.VRComponentFactory.Log("trigger node found");

                    Trigger trigger = new Trigger(name);
                    MascaretApplication.Instance.VRComponentFactory.Log("Debug : " + name);
                    string idT = "";
                    if (triggerNode.Attribute("{http://schema.omg.org/spec/XMI/2.1}id") != null)
                        idT = triggerNode.Attribute("{http://schema.omg.org/spec/XMI/2.1}id").Value;
                    else
                        idT = triggerNode.Attribute("{http://www.omg.org/spec/XMI/20131001}id").Value;

                    trigger.Id = idT;
                    MascaretApplication.Instance.VRComponentFactory.Log(trigger.Id);

                    if (triggerNode.Attribute("event") != null)
                    {
                        string idEvent = triggerNode.Attribute("event").Value;

                        if (_events.ContainsKey(idEvent))
                        {
                            trigger.MEvent = _events[idEvent];
                            act.setTrigger(trigger);
                        }
                        else
                            MascaretApplication.Instance.VRComponentFactory.Log("Could not find event : " + idEvent);
                    }
                }
                an.Action = act;
                addPins(an, node);
                actNode = an;

                MascaretApplication.Instance.VRComponentFactory.Log(" Fin AcceptEventAction");

            }
            // ...
            else
            {
                //Debug.Log("Unknown state: " + type);
            }

            if (actNode != null)
            {
                _activityNodes.Add(id, actNode);
                activity.addNode(actNode);
                //cerr << "searching _partitions for '" << idPartition << "'" << endl;
                if (_partitions.ContainsKey(idPartition))
                {
                    actNode.Partitions.Add(_partitions[idPartition]);
                    _partitions[idPartition].Node.Add(actNode);
                }
                actNode.Summary = getSummary(node);
                actNode.Description = getComment(node);
                actNode.Tags = getTags(node);
            }
        }