From ff3ddb84f4047566f67858a9aa6bc11c7663812f Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Fri, 29 Sep 2023 17:36:05 -0700 Subject: [PATCH] Expose after delays to runtime. --- .../org/lflang/federated/extensions/CExtension.java | 11 ++++++----- .../lflang/federated/extensions/CExtensionUtils.java | 4 ++++ .../org/lflang/federated/generator/FedASTUtils.java | 1 + .../lflang/federated/generator/FederateInstance.java | 2 ++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/core/src/main/java/org/lflang/federated/extensions/CExtension.java b/core/src/main/java/org/lflang/federated/extensions/CExtension.java index d6493f96c0..49916c6fc9 100644 --- a/core/src/main/java/org/lflang/federated/extensions/CExtension.java +++ b/core/src/main/java/org/lflang/federated/extensions/CExtension.java @@ -547,11 +547,12 @@ protected String makePreamble( int numOfNetworkActions = federate.networkMessageActions.size(); code.pr( """ - lf_action_base_t* _lf_action_table[%1$s]; - size_t _lf_action_table_size = %1$s; - lf_action_base_t* _lf_zero_delay_action_table[%2$s]; - size_t _lf_zero_delay_action_table_size = %2$s; - """ + interval_t _lf_action_delay_table[%1$s]; + lf_action_base_t* _lf_action_table[%1$s]; + size_t _lf_action_table_size = %1$s; + lf_action_base_t* _lf_zero_delay_action_table[%2$s]; + size_t _lf_zero_delay_action_table_size = %2$s; + """ .formatted(numOfNetworkActions, federate.zeroDelayNetworkMessageActions.size())); int numOfNetworkReactions = federate.networkReceiverReactions.size(); diff --git a/core/src/main/java/org/lflang/federated/extensions/CExtensionUtils.java b/core/src/main/java/org/lflang/federated/extensions/CExtensionUtils.java index 0903d2d90d..e0d70ea7b7 100644 --- a/core/src/main/java/org/lflang/federated/extensions/CExtensionUtils.java +++ b/core/src/main/java/org/lflang/federated/extensions/CExtensionUtils.java @@ -53,6 +53,10 @@ public static String initializeTriggersForNetworkActions( var reactor = main.lookupReactorInstance(federate.networkReceiverInstantiations.get(i)); var actionInstance = reactor.lookupActionInstance(action); var trigger = CUtil.actionRef(actionInstance, null); + var delay = federate.networkMessageActionDelays.get(i); + code.pr( + "_lf_action_delay_table[" + actionTableCount + "] = " + getNetworkDelayLiteral(delay) + "; \\" + ); code.pr( "_lf_action_table[" + (actionTableCount++) diff --git a/core/src/main/java/org/lflang/federated/generator/FedASTUtils.java b/core/src/main/java/org/lflang/federated/generator/FedASTUtils.java index e145248cb5..065f4b5000 100644 --- a/core/src/main/java/org/lflang/federated/generator/FedASTUtils.java +++ b/core/src/main/java/org/lflang/federated/generator/FedASTUtils.java @@ -273,6 +273,7 @@ private static void addNetworkReceiverReactor( // Keep track of this action in the destination federate. connection.dstFederate.networkMessageActions.add(networkAction); + connection.dstFederate.networkMessageActionDelays.add(connection.getDefinition().getDelay()); if (connection.getDefinition().getDelay() == null) connection.dstFederate.zeroDelayNetworkMessageActions.add(networkAction); diff --git a/core/src/main/java/org/lflang/federated/generator/FederateInstance.java b/core/src/main/java/org/lflang/federated/generator/FederateInstance.java index 1b3f9f5669..a0bc4d609a 100644 --- a/core/src/main/java/org/lflang/federated/generator/FederateInstance.java +++ b/core/src/main/java/org/lflang/federated/generator/FederateInstance.java @@ -170,6 +170,8 @@ public Instantiation getInstantiation() { */ public List networkMessageActions = new ArrayList<>(); + public List networkMessageActionDelays = new ArrayList<>(); + /** * List of networkMessage actions corresponding to zero-delay connections. This should be a subset * of the networkMessageActions.