Skip to content

Commit e6fb4e1

Browse files
committed
merge with main
2 parents 5267b9f + 1e85d86 commit e6fb4e1

File tree

4 files changed

+42
-10
lines changed

4 files changed

+42
-10
lines changed

include/reactor-uc/macros_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ typedef struct FederatedOutputConnection FederatedOutputConnection;
509509
void ReactorName##_ctor(ReactorName *self, Reactor *parent, Environment *env, __VA_ARGS__)
510510

511511
#define LF_FEDERATED_CONNECTION_BUNDLE_CALL_CTOR() \
512-
FederatedConnectionBundle_ctor(&self->super, parent, &self->channel.super, &self->inputs[0], \
512+
FederatedConnectionBundle_ctor(&self->super, parent, (NetworkChannel *)&self->channel.super, &self->inputs[0], \
513513
self->deserialize_hooks, sizeof(self->inputs) / sizeof(self->inputs[0]), \
514514
&self->outputs[0], self->serialize_hooks, \
515515
sizeof(self->outputs) / sizeof(self->outputs[0]), index);

include/reactor-uc/startup_coordinator.h

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,24 @@ typedef struct Environment Environment;
1212
typedef enum JoiningPolicy JoiningPolicy;
1313
typedef struct TimerConfig TimerConfig;
1414

15-
enum JoiningPolicy { JOIN_IMMEDIATELY = 0, JOIN_ALIGNED_WITH_SHORT_TIMER = 1, JOIN_AT_HYPER_PERIOD = 2 };
15+
enum JoiningPolicy { JOIN_IMMEDIATELY = 0, JOIN_TIMER_ALIGNED = 1, JOIN_AT_HYPER_PERIOD = 2 };
1616

1717
/** Represents the state of a neighbor. */
1818
typedef struct {
19-
bool core_federate; // Whether this federate can be not available
20-
bool handshake_response_received; // Whether a handshake response has been received from this neighbor.
21-
bool handshake_request_received; // Whether a handshake response has been sent to this neighbor.
22-
bool handshake_response_sent; // Whether a handshake response has been sent to this neighbor.
23-
size_t start_time_proposals_received; // The number of start time proposals received from this neighbor.
24-
StartupCoordinationState initial_state_of_neighbor; // Saves the initial state of the neighbor
25-
interval_t
26-
current_logical_time; // Used by transient to figure out the current logical times of all neighboring federates
19+
/**True, if this federate needs to be present during joining*/
20+
bool core_federate;
21+
/** True, if a handshake response has been received from this neighbor.*/
22+
bool handshake_response_received;
23+
/** True, if a handshake response has been sent to this neighbor.*/
24+
bool handshake_request_received;
25+
/** True, if a handshake response has been sent to this neighbor.*/
26+
bool handshake_response_sent;
27+
/** The number of start time proposals received from this neighbor.*/
28+
size_t start_time_proposals_received;
29+
/** Saves the initial state of the neighbor.*/
30+
StartupCoordinationState initial_state_of_neighbor;
31+
/** Used by transient federates, to figure out the current logical times of all neighboring federates. */
32+
interval_t current_logical_time;
2733
} NeighborState;
2834

2935
/** The payload of a StartupCoordinator event. */

lfc/core/src/main/kotlin/org/lflang/generator/uc/federated/UcStartupCoordinatorGenerator.kt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,27 @@ fun JoiningPolicy.toCString() =
2323
else -> throw IllegalArgumentException("Joining policy not handled")
2424
}
2525

26+
enum class JoiningPolicy {
27+
JOIN_IMMEDIATELY,
28+
JOIN_TIMER_ALIGNED;
29+
30+
companion object {
31+
fun parse(str: String): JoiningPolicy =
32+
when (str) {
33+
"\"JOIN_IMMEDIATELY\"" -> JOIN_IMMEDIATELY
34+
"\"JOIN_TIMER_ALIGNED\"" -> JOIN_TIMER_ALIGNED
35+
else -> throw IllegalArgumentException("Unknown joining policy: $str")
36+
}
37+
}
38+
}
39+
40+
fun JoiningPolicy.toCString() =
41+
when (this) {
42+
JoiningPolicy.JOIN_IMMEDIATELY -> "JOIN_IMMEDIATELY"
43+
JoiningPolicy.JOIN_TIMER_ALIGNED -> "JOIN_TIMER_ALIGNED"
44+
else -> throw IllegalArgumentException("Joining policy not handled")
45+
}
46+
2647
class UcStartupCoordinatorGenerator(
2748
private val federate: UcFederate,
2849
private val connectionGenerator: UcConnectionGenerator,

src/startup_coordinator.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#define NEIGHBOR_INDEX_SELF -1
1010
#define NUM_RESERVED_EVENTS 3 // 3 events is reserved for scheduling our own events.
1111

12+
#ifndef TRANSIENT_WAIT_TIME
13+
#define TRANSIENT_WAIT_TIME MSEC(250)
14+
#endif
15+
1216
/**
1317
* @brief Open connections to all neighbors. This function will block until all connections are established.
1418
*/
@@ -298,6 +302,7 @@ static void StartupCoordinator_handle_start_time_proposal(StartupCoordinator *se
298302
case StartupCoordinationState_RUNNING:
299303
// Should not be possible.
300304
validate(false);
305+
break;
301306
case StartupCoordinationState_HANDSHAKING:
302307
// This is possible. Our node might be still handshaking with another neighbor.
303308
// Intentional fall-through

0 commit comments

Comments
 (0)