Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deprecated API in ui examples and tests #1155

Merged
merged 3 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ reactor Receive {
in->value
);
if (in->value >= 10) {
request_stop();
lf_request_stop();
}
=}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ reactor GetUserInput {

reaction(user_response) -> another {=
if (user_response->value == EOF) {
request_stop();
lf_request_stop();
return;
}
// If the prompt_time is 0, then the user is cheating and
// hitting return before being prompted.
if (self->prompt_time == 0LL) {
printf("YOU CHEATED!\n");
request_stop();
lf_request_stop();
} else {
int time_in_ms = (lf_time_logical() - self->prompt_time) / 1000000LL;
printf("Response time in milliseconds: %d\n", time_in_ms);
Expand Down
2 changes: 1 addition & 1 deletion test/C/src/PingPong.lf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ reactor Ping(count:int(10)) {
if (self->pingsLeft > 0) {
lf_schedule(serve, 0);
} else {
request_stop();
lf_request_stop();
}
=}
}
Expand Down
6 changes: 3 additions & 3 deletions test/C/src/RequestStop.lf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Test verifying that request_stop() called in a shutdown reaction is ignored.
// Test verifying that lf_request_stop() called in a shutdown reaction is ignored.
target C;
main reactor {
reaction(shutdown) {=
tag_t current_time = lf_tag();
lf_print("Shutdown invoked at tag (%lld, %d). Calling request_stop(), which should have no effect.",
lf_print("Shutdown invoked at tag (%lld, %d). Calling lf_request_stop(), which should have no effect.",
current_tag.time - lf_time_start(), current_tag.microstep
);
request_stop();
lf_request_stop();
=}
}
housengw marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 3 additions & 3 deletions test/C/src/Stop.lf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* A test for the request_stop() functionality in Lingua Franca.
* A test for the lf_request_stop() functionality in Lingua Franca.
*
* @author Soroush Bateni
*/
Expand All @@ -21,9 +21,9 @@ reactor Consumer {
exit(1);
} else if (lf_tag_compare(current_tag,
(tag_t) { .time = MSEC(10) + lf_time_start(), .microstep = 8}) == 0) {
// Call request_stop() at relative tag (10 msec, 8)
// Call lf_request_stop() at relative tag (10 msec, 8)
printf("Requesting stop.\n");
request_stop();
lf_request_stop();
} else if (lf_tag_compare(current_tag,
(tag_t) { .time = MSEC(10) + lf_time_start(), .microstep = 9}) == 0) {
// Check that this reaction is indeed also triggered at (10 msec, 9)
Expand Down
8 changes: 4 additions & 4 deletions test/C/src/StopZero.lf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Test for request_stop() at tag (0,0).
* Test for lf_request_stop() at tag (0,0).
* This also tests for logically simultaneous calls
* to request_stop().
* to lf_request_stop().
*
* @author Soroush Bateni
*/
Expand All @@ -25,7 +25,7 @@ reactor Sender {
printf("Requesting stop at (%lld, %u).\n",
lf_time_logical_elapsed(),
lf_tag().microstep);
request_stop();
lf_request_stop();
} else if (lf_tag_compare(lf_tag(), one) > 0) {
fprintf(stderr, "ERROR: Reaction called after shutdown at (%lld, %u).\n",
lf_time_logical_elapsed(),
Expand Down Expand Up @@ -74,7 +74,7 @@ reactor Receiver {
printf("Requesting stop at (%lld, %u).\n",
lf_time_logical_elapsed(),
lf_tag().microstep);
request_stop();
lf_request_stop();
}
=}

Expand Down
2 changes: 1 addition & 1 deletion test/C/src/TimeLimit.lf
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ reactor Destination {
main reactor TimeLimit(period:time(1 usec)) {
timer stop(10 secs);
reaction(stop) {=
request_stop();
lf_request_stop();
=}
c = new Clock(period = period);
d = new Destination();
Expand Down
2 changes: 1 addition & 1 deletion test/C/src/concurrent/PingPongThreaded.lf
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ reactor Ping(count:int(10)) {
if (self->pingsLeft > 0) {
lf_schedule(serve, 0);
} else {
request_stop();
lf_request_stop();
}
=}
}
Expand Down
6 changes: 3 additions & 3 deletions test/C/src/concurrent/StopThreaded.lf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* A test for the request_stop() functionality in Lingua Franca.
* A test for the lf_request_stop() functionality in Lingua Franca.
* This version of the test is threaded.
*
* @author Soroush Bateni
Expand All @@ -26,9 +26,9 @@ reactor Consumer {
current_tag.time - lf_time_start(), current_tag.microstep);
} else if (lf_tag_compare(current_tag,
(tag_t) { .time = MSEC(10) + lf_time_start(), .microstep = 8}) == 0) {
// Call request_stop() at relative tag (10 msec, 8)
// Call lf_request_stop() at relative tag (10 msec, 8)
lf_print("Requesting stop.");
request_stop();
lf_request_stop();
} else if (lf_tag_compare(current_tag,
(tag_t) { .time = MSEC(10) + lf_time_start(), .microstep = 9}) == 0) {
// Check that this reaction is indeed also triggered at (10 msec, 9)
Expand Down
6 changes: 3 additions & 3 deletions test/C/src/concurrent/StopZeroThreaded.lf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Test for request_stop() at tag (0,0).
* Test for lf_request_stop() at tag (0,0).
* This version uses the threaded runtime.
*
* @author Soroush Bateni
Expand All @@ -25,7 +25,7 @@ reactor Sender {
printf("Requesting stop at (%lld, %u).\n",
lf_time_logical_elapsed(),
lf_tag().microstep);
request_stop();
lf_request_stop();
} else if (lf_tag_compare(lf_tag(), one) > 0) {
fprintf(stderr, "ERROR: Reaction called after shutdown at (%lld, %u).\n",
lf_time_logical_elapsed(),
Expand Down Expand Up @@ -74,7 +74,7 @@ reactor Receiver {
printf("Requesting stop at (%lld, %u).\n",
lf_time_logical_elapsed(),
lf_tag().microstep);
request_stop();
lf_request_stop();
}
=}

Expand Down
2 changes: 1 addition & 1 deletion test/C/src/concurrent/TimeLimitThreaded.lf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ reactor Destination {
main reactor (period:time(1 usec)) {
timer stop(10 secs);
reaction(stop) {=
request_stop();
lf_request_stop();
=}
c = new Clock(period = period);
d = new Destination();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Test for request_stop() in federated execution with decentralized coordination.
* Test for lf_request_stop() in federated execution with decentralized coordination.
*
* @author Soroush Bateni
*/
Expand Down
2 changes: 1 addition & 1 deletion test/C/src/federated/CycleDetection.lf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ reactor UserInput {
lf_print_error_and_exit("Did not receive the expected balance. Expected: 200. Got: %d.", balance->value);
}
lf_print("Balance: %d", balance->value);
request_stop();
lf_request_stop();
=}

reaction(shutdown) {=
Expand Down
2 changes: 1 addition & 1 deletion test/C/src/federated/DistributedCountPhysicalAfterDelay.lf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ reactor Print {
exit(3);
}
self->c++;
request_stop();
lf_request_stop();
=}
reaction(shutdown) {=
if (self->c != 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ reactor STPReceiver(take_a_break_after:int(10), break_interval:time(400 msec), s
if (current_tag.time != self->last_time_updated_stp) {
lf_print("Raising the STP offset by %lld.", MSEC(10));
self->stp_offset += MSEC(10);
set_stp_offset(MSEC(10));
lf_set_stp_offset(MSEC(10));
self->last_time_updated_stp = current_tag.time;
}
=}
Expand Down
10 changes: 5 additions & 5 deletions test/C/src/federated/DistributedStop.lf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Test for request_stop() in federated execution with centralized coordination.
* Test for lf_request_stop() in federated execution with centralized coordination.
*
* @author Soroush Bateni
*/
Expand All @@ -18,17 +18,17 @@ reactor Sender {
if (lf_tag().microstep == 0) {
// Instead of having a separate reaction
// for 'act' like Stop.lf, we trigger the
// same reaction to test request_stop() being
// same reaction to test lf_request_stop() being
// called multiple times
lf_schedule(act, 0);
}
if (lf_time_logical_elapsed() == USEC(1)) {
// Call request_stop() both at (1 usec, 0) and
// Call lf_request_stop() both at (1 usec, 0) and
// (1 usec, 1)
lf_print("Requesting stop at (%lld, %u).",
lf_time_logical_elapsed(),
lf_tag().microstep);
request_stop();
lf_request_stop();
}

tag_t _1usec1 = (tag_t) { .time = USEC(1) + lf_time_start(), .microstep = 1u };
Expand Down Expand Up @@ -74,7 +74,7 @@ reactor Receiver (
lf_print("Requesting stop at (%lld, %u).",
lf_time_logical_elapsed(),
lf_tag().microstep);
request_stop();
lf_request_stop();
// The receiver should receive a message at tag
// (1 usec, 1) and trigger this reaction
self->reaction_invoked_correctly = true;
Expand Down
10 changes: 5 additions & 5 deletions test/C/src/federated/DistributedStopDecentralized.lf
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
/**
* Test for request_stop() in federated execution with decentralized coordination.
* Test for lf_request_stop() in federated execution with decentralized coordination.
*
* @author Soroush Bateni
*/
target C {
coordination: decentralized
target C {
coordination: decentralized
};

import Sender, Receiver from "DistributedStop.lf"

federated reactor DistributedStopDecentralized {
federated reactor DistributedStopDecentralized {
sender = new Sender();
receiver = new Receiver();

sender.out -> receiver.in;
sender.out -> receiver.in;
}
housengw marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 3 additions & 3 deletions test/C/src/federated/DistributedStopZero.lf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Test for request_stop() in federated execution with centralized coordination
* Test for lf_request_stop() in federated execution with centralized coordination
* at tag (0,0).
*
* @author Soroush Bateni
Expand All @@ -21,7 +21,7 @@ reactor Sender {
printf("Requesting stop at (%lld, %u).\n",
lf_time_logical_elapsed(),
lf_tag().microstep);
request_stop();
lf_request_stop();
}
=}

Expand Down Expand Up @@ -53,7 +53,7 @@ reactor Receiver {
printf("Requesting stop at (%lld, %u).\n",
lf_time_logical_elapsed(),
lf_tag().microstep);
request_stop();
lf_request_stop();
}
=}

Expand Down
6 changes: 3 additions & 3 deletions test/C/src/federated/DistributedStopZeroDecentralized.lf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Test for request_stop() in federated execution with decentralized coordination
* Test for lf_request_stop() in federated execution with decentralized coordination
* at tag (0,0).
*
* @author Soroush Bateni
Expand All @@ -8,9 +8,9 @@ target C;

import Sender, Receiver from "DistributedStopZero.lf"

federated reactor {
federated reactor {
sender = new Sender();
receiver = new Receiver();

sender.out -> receiver.in;
sender.out -> receiver.in;
}
housengw marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion test/C/src/federated/HelloDistributed.lf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ reactor Source {
reaction(startup) -> out {=
lf_print("Sending 'Hello World!' message from source federate.");
lf_set(out, "Hello World!");
request_stop();
lf_request_stop();
=}
}
reactor Destination {
Expand Down
4 changes: 2 additions & 2 deletions test/C/src/federated/PingPongDistributedPhysical.lf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ reactor Ping(count:int(10)) {
if (self->pingsLeft > 0) {
lf_schedule(serve, 0);
} else {
request_stop();
lf_request_stop();
}
=}
}
Expand All @@ -54,7 +54,7 @@ reactor Pong(expected:int(10)) {
printf("At logical time %lld, Pong received %d.\n", lf_time_logical_elapsed(), receive->value);
lf_set(send, receive->value);
if (self->count == self->expected) {
request_stop();
lf_request_stop();
}
=}
reaction(shutdown) {=
Expand Down
6 changes: 3 additions & 3 deletions test/C/src/federated/StopAtShutdown.lf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Check that request_stop() doesn't cause
* Check that lf_request_stop() doesn't cause
* any issues at the shutdown tag.
*
* Original bug discovered by Steven Wong <housengw@berkeley.edu>
Expand All @@ -21,7 +21,7 @@ reactor A {
=}

reaction(shutdown) {=
request_stop();
lf_request_stop();
=}
}

Expand All @@ -32,7 +32,7 @@ reactor B {
lf_set(out, 1);
=}
reaction(shutdown) {=
request_stop();
lf_request_stop();
=}
}

Expand Down