33 * as stated in the file entitled Licensing-Information.
44 *
55 * Modifications:
6- * Copyright 2009-2012 Data Access Technologies, Inc.
6+ * Copyright 2009-2017 Data Access Technologies, Inc.
77 * Copyright 2020 Model Driven Solutions, Inc.
8+ * Copyright 2020 CEA LIST.
89 *
910 * Licensed under the Academic Free License version 3.0
1011 * (http://www.opensource.org/licenses/afl-3.0.php), except as stated
4546import fuml .syntax .structuredclassifiers .Association ;
4647import fuml .syntax .values .LiteralBoolean ;
4748
48- public abstract class ActionActivation extends
49- fuml .semantics .activities .ActivityNodeActivation {
49+ public abstract class ActionActivation extends fuml .semantics .activities .ExecutableNodeActivation {
5050
51- public fuml .semantics .actions .PinActivationList pinActivations = new fuml .semantics .actions .PinActivationList ();
5251 public boolean firing = false ;
53-
52+ public fuml .semantics .actions .PinActivationList pinActivations = new fuml .semantics .actions .PinActivationList ();
53+
5454 public void initialize (ActivityNode node , ActivityNodeActivationGroup group ) {
5555 // Initialize this action activation to be not firing.
56-
56+
5757 super .initialize (node , group );
5858 this .firing = false ;
5959 }
6060
6161 public void run () {
62- // Run this action activation and any outoging fork node attached to it.
62+ // Run this action activation and any outgoing fork node attached to it.
6363
6464 super .run ();
6565
@@ -111,8 +111,7 @@ public fuml.semantics.activities.TokenList takeOfferedTokens() {
111111 return offeredTokens ;
112112 } // takeOfferedTokens
113113
114- public void fire (
115- fuml .semantics .activities .TokenList incomingTokens ) {
114+ public void fire (fuml .semantics .activities .TokenList incomingTokens ) {
116115 // Do the main action behavior then concurrently fire all output pin
117116 // activations
118117 // and offer a single control token. Then activate the action again,
@@ -262,8 +261,7 @@ public void createNodeActivations() {
262261 }
263262 } // createNodeActivations
264263
265- public void addOutgoingEdge (
266- fuml .semantics .activities .ActivityEdgeInstance edge ) {
264+ public void addOutgoingEdge (fuml .semantics .activities .ActivityEdgeInstance edge ) {
267265 // If there are no outgoing activity edge instances, create a single
268266 // activity edge instance with a fork node execution at the other end.
269267 // Add the give edge to the fork node execution that is the target of
@@ -286,16 +284,14 @@ public void addOutgoingEdge(
286284 forkNodeActivation .addOutgoingEdge (edge );
287285 } // addOutgoingEdge
288286
289- public void addPinActivation (
290- fuml .semantics .actions .PinActivation pinActivation ) {
287+ public void addPinActivation (fuml .semantics .actions .PinActivation pinActivation ) {
291288 // Add a pin activation to this action activation.
292289
293290 this .pinActivations .addValue (pinActivation );
294291 pinActivation .actionActivation = this ;
295292 } // addPinActivation
296293
297- public fuml .semantics .actions .PinActivation getPinActivation (
298- fuml .syntax .actions .Pin pin ) {
294+ public fuml .semantics .actions .PinActivation getPinActivation (fuml .syntax .actions .Pin pin ) {
299295 // Precondition: The given pin is owned by the action of the action
300296 // activation.
301297 // Return the pin activation corresponding to the given pin.
@@ -315,8 +311,7 @@ public fuml.semantics.actions.PinActivation getPinActivation(
315311
316312 } // getPinActivation
317313
318- public void putToken (fuml .syntax .actions .OutputPin pin ,
319- fuml .semantics .values .Value value ) {
314+ public void putToken (fuml .syntax .actions .OutputPin pin , fuml .semantics .values .Value value ) {
320315 // Precondition: The action execution has fired and the given pin is
321316 // owned by the action of the action execution.
322317 // Place a token for the given value on the pin activation corresponding
@@ -331,8 +326,7 @@ public void putToken(fuml.syntax.actions.OutputPin pin,
331326 pinActivation .addToken (token );
332327 } // putToken
333328
334- public void putTokens (fuml .syntax .actions .OutputPin pin ,
335- fuml .semantics .values .ValueList values ) {
329+ public void putTokens (fuml .syntax .actions .OutputPin pin , fuml .semantics .values .ValueList values ) {
336330 // Precondition: The action execution has fired and the given pin is
337331 // owned by the action of the action execution.
338332 // Place tokens for the given values on the pin activation corresponding
@@ -347,8 +341,7 @@ public void putTokens(fuml.syntax.actions.OutputPin pin,
347341
348342 } // putTokens
349343
350- public fuml .semantics .values .ValueList getTokens (
351- fuml .syntax .actions .InputPin pin ) {
344+ public fuml .semantics .values .ValueList getTokens (fuml .syntax .actions .InputPin pin ) {
352345 // Precondition: The action execution has fired and the given pin is
353346 // owned by the action of the action execution.
354347 // Get any tokens held by the pin activation corresponding to the given
@@ -372,8 +365,7 @@ public fuml.semantics.values.ValueList getTokens(
372365 return values ;
373366 } // getTokens
374367
375- public fuml .semantics .values .ValueList takeTokens (
376- fuml .syntax .actions .InputPin pin ) {
368+ public fuml .semantics .values .ValueList takeTokens (fuml .syntax .actions .InputPin pin ) {
377369 // Precondition: The action execution has fired and the given pin is
378370 // owned by the action of the action execution.
379371 // Take any tokens held by the pin activation corresponding to the given
@@ -396,8 +388,7 @@ public fuml.semantics.values.ValueList takeTokens(
396388 return values ;
397389 } // takeTokens
398390
399- public boolean isSourceFor (
400- fuml .semantics .activities .ActivityEdgeInstance edgeInstance ) {
391+ public boolean isSourceFor (fuml .semantics .activities .ActivityEdgeInstance edgeInstance ) {
401392 // If this action has an outgoing fork node, check that the fork node is
402393 // the source of the given edge instance.
403394
@@ -410,8 +401,7 @@ public boolean isSourceFor(
410401 return isSource ;
411402 } // isSourceFor
412403
413- public boolean valueParticipatesInLink (
414- fuml .semantics .values .Value value ,
404+ public boolean valueParticipatesInLink (fuml .semantics .values .Value value ,
415405 fuml .semantics .structuredclassifiers .Link link ) {
416406 // Test if the given value participates in the given link.
417407
@@ -537,8 +527,7 @@ public fuml.syntax.classification.Property getOppositeEnd(
537527 return oppositeEnd ;
538528 } // getOppositeEnd
539529
540- public fuml .semantics .simpleclassifiers .BooleanValue makeBooleanValue (
541- boolean value ) {
530+ public fuml .semantics .simpleclassifiers .BooleanValue makeBooleanValue (boolean value ) {
542531 // Make a Boolean value using the built-in Boolean primitive type.
543532 // [This ensures that Boolean values created internally are the same as
544533 // the default used for evaluating Boolean literals.]
@@ -549,4 +538,38 @@ public fuml.semantics.simpleclassifiers.BooleanValue makeBooleanValue(
549538 .evaluate (booleanLiteral ));
550539 } // makeBooleanValue
551540
552- } // ActionActivation
541+ public void handle (fuml .semantics .values .Value exception , fuml .syntax .activities .ExceptionHandler handler ) {
542+ // Handle the given exception by firing the body of the given
543+ // exception handler. After the body fires, transfer its outputs
544+ // to the output pins of this action activation.
545+
546+ super .handle (exception , handler );
547+ this .transferOutputs ((Action )handler .handlerBody );
548+ }
549+
550+ public void transferOutputs (fuml .syntax .actions .Action handlerBody ) {
551+ // Transfer the output values from activation of the given exception
552+ // handler body to the output pins of this action activation.
553+
554+ ActionActivation handlerBodyActivation =
555+ (ActionActivation )this .group .getNodeActivation (handlerBody );
556+ OutputPinList sourceOutputs = handlerBody .output ;
557+ OutputPinList targetOutputs = ((Action ) this .node ).output ;
558+
559+ for (int i = 0 ; i < sourceOutputs .size (); i ++) {
560+ OutputPin sourcePin = sourceOutputs .getValue (i );
561+ OutputPin targetPin = targetOutputs .getValue (i );
562+
563+ PinActivation sourcePinActivation = handlerBodyActivation .getPinActivation (sourcePin );
564+ TokenList tokens = sourcePinActivation .takeTokens ();
565+ ValueList values = new ValueList ();
566+ for (int j = 0 ; j < tokens .size (); j ++) {
567+ Token token = tokens .getValue (j );
568+ values .addValue (token .getValue ());
569+ }
570+
571+ this .putTokens (targetPin , values );
572+ }
573+ }
574+
575+ } // ActionActivation
0 commit comments