From 37f107d11ad873eb35c5b72ce450dc81e42ead00 Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Fri, 8 Sep 2023 00:34:00 -0700 Subject: [PATCH 1/4] Make preamble in controller private --- .../FurutaPendulum/PendulumController.lf | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/examples/C/src/modal_models/FurutaPendulum/PendulumController.lf b/examples/C/src/modal_models/FurutaPendulum/PendulumController.lf index a6ad66b7..af1c1448 100644 --- a/examples/C/src/modal_models/FurutaPendulum/PendulumController.lf +++ b/examples/C/src/modal_models/FurutaPendulum/PendulumController.lf @@ -9,18 +9,6 @@ */ target C -preamble {= - #include - #define PI 3.14159265 - #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) - double sign(double x) { - return (x > 0.0) - (x < 0.0); - } - double restrictAngle(double theta) { - return((fmod(fabs(theta) + PI, 2 * PI) - PI) * sign(theta)); - } -=} - reactor PendulumController( h: double = 0.005, // Sample interval w0: double = 6.3, @@ -38,6 +26,18 @@ reactor PendulumController( si3: double = -0.03254225945714, si4: double = -0.05808270221773, phi2: double = -7.0124562) { + preamble {= + #include + #define PI 3.14159265 + #define MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) + double sign(double x) { + return (x > 0.0) - (x < 0.0); + } + double restrictAngle(double theta) { + return((fmod(fabs(theta) + PI, 2 * PI) - PI) * sign(theta)); + } + =} + input theta: double input d_theta: double input phi: double From bd38c9b6df5ea664620203add37fa55d9a6473c3 Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Fri, 8 Sep 2023 10:41:48 -0700 Subject: [PATCH 2/4] Ensure that script exits with failure code when compilation fails --- examples/C/src/modal_models/FurutaPendulum/build_run_plot.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/C/src/modal_models/FurutaPendulum/build_run_plot.sh b/examples/C/src/modal_models/FurutaPendulum/build_run_plot.sh index 70393e20..1e8dc089 100755 --- a/examples/C/src/modal_models/FurutaPendulum/build_run_plot.sh +++ b/examples/C/src/modal_models/FurutaPendulum/build_run_plot.sh @@ -1,4 +1,5 @@ #!/bin/bash +set -euo pipefail # This script compiles the generated code, # executes it, and plots the results. # The first argument is the name of the main reactor From 941beb4f083fa570996ed77298c2d7c9a813ffd0 Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Fri, 8 Sep 2023 10:46:23 -0700 Subject: [PATCH 3/4] Also change other build scripts --- examples/C/src/rhythm/compile.sh | 3 ++- examples/C/src/rosace/build_run_plot.sh | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/C/src/rhythm/compile.sh b/examples/C/src/rhythm/compile.sh index 1eec9942..421a64fa 100755 --- a/examples/C/src/rhythm/compile.sh +++ b/examples/C/src/rhythm/compile.sh @@ -1,5 +1,6 @@ #!/bin/bash -# +set -euo pipefail + # Script to compile the code generated by lfc or by the Lingua Franca IDE # for the programs in this directory using arguments that are suitable to the # OS on which this is running. The OS is detected using the Posix command uname. diff --git a/examples/C/src/rosace/build_run_plot.sh b/examples/C/src/rosace/build_run_plot.sh index 59cce835..c276ff4a 100755 --- a/examples/C/src/rosace/build_run_plot.sh +++ b/examples/C/src/rosace/build_run_plot.sh @@ -1,4 +1,6 @@ #!/bin/bash +set -euo pipefail + # This script compiles the generated code, # executes it, and plots the results. # The one argument is the name of the main reactor. From 527eb9f55ea556c59046085bb217dc3c5d6075a8 Mon Sep 17 00:00:00 2001 From: Marten Lohstroh Date: Fri, 8 Sep 2023 11:58:25 -0700 Subject: [PATCH 4/4] Update setup-env.bash --- utils/scripts/setup-env.bash | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utils/scripts/setup-env.bash b/utils/scripts/setup-env.bash index 58a802ae..0eeee5a5 100644 --- a/utils/scripts/setup-env.bash +++ b/utils/scripts/setup-env.bash @@ -30,13 +30,13 @@ done # Install dependencies sudo apt-get update -## Setup C, C++, Python, Rust, protobuf, gRPC +## Setup C, C++, Python, Rust, protobuf, gRPC, gnuplot sudo apt-get install --assume-yes \ build-essential \ python3 python3-dev python3-pip \ rustc cargo \ libprotobuf-dev libprotobuf-c-dev protobuf-c-compiler protobuf-compiler python3-protobuf \ - protobuf-compiler-grpc libgrpc-dev libgrpc++-dev + protobuf-compiler-grpc libgrpc-dev libgrpc++-dev gnuplot python3 -m pip install --upgrade pip # Install python dependencies and