Skip to main content
summaryrefslogtreecommitdiffstats
blob: 0f9c7d372bbc8da59d69bc0c85946c5be9a9c5d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*****************************************************************************
 * Copyright (c) 2012 CEA LIST.
 *
 *    
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  CEA LIST - Initial API and implementation
 *
 *****************************************************************************/
package org.eclipse.papyrus.moka.fuml.Semantics.Activities.IntermediateActivities;

import java.util.List;

import org.eclipse.papyrus.moka.fuml.debug.Debug;
import org.eclipse.papyrus.moka.fuml.Semantics.Classes.Kernel.Value;
import org.eclipse.papyrus.moka.fuml.Semantics.CommonBehaviors.BasicBehaviors.ParameterValue;
import org.eclipse.papyrus.moka.fuml.Semantics.Loci.LociL1.Locus;
import org.eclipse.uml2.uml.ActivityParameterNode;
import org.eclipse.uml2.uml.Parameter;

public class ActivityParameterNodeActivation extends ObjectNodeActivation {

	public void fire(List<Token> incomingTokens) {
		super.fire(incomingTokens) ;
		Locus locus = this.getExecutionLocus() ;
		if (locus.isInDebugMode) {
			if (locus.engine.isTerminated())
				return ;
		}
		// If there are no incoming edges, this is an activation of an input
		// activity parameter node.
		// Get the values from the input parameter indicated by the activity
		// parameter node and offer those values as object tokens.
		if(this.node.getIncomings().size() == 0) {
			Debug.println("[fire] Input activity parameter node " + this.node.getName() + "...");
			Parameter parameter = ((ActivityParameterNode)(this.node)).getParameter();
			ParameterValue parameterValue = this.getActivityExecution().getParameterValue(parameter);
			// Debug.println("[fire] parameter = " + parameter.name);
			if(parameterValue != null) {
				Debug.println("[fire] Parameter has " + parameterValue.values.size() + " value(s).");
				// List<Token> tokens = new ArrayList<Token>();
				List<Value> values = parameterValue.values;
				for(int i = 0; i < values.size(); i++) {
					Value value = values.get(i);
					ObjectToken token = new ObjectToken();
					token.value = value;
					this.addToken(token);
				}
				this.sendUnofferedTokens();
			}
		}
		// If there are one or more incoming edges, this is an activation of an
		// output activity parameter node.
		// Take the tokens offered on incoming edges and add them to the set of
		// tokens being offered.
		// [Note that an output activity parameter node may fire multiple times,
		// accumulating tokens offered to it.]
		else {
			Debug.println("[fire] Output activity parameter node " + this.node.getName() + "...");
			this.addTokens(incomingTokens);
		}
	}

	public void clearTokens() {
		// Clear all held tokens only if this is an input parameter node.
		if(this.node.getIncomings().size() == 0) {
			super.clearTokens();
		}
	}
}

Back to the top