Skip to content
Snippets Groups Projects
Commit 77b91075 authored by René Schöne's avatar René Schöne
Browse files

finished strategies and more

parent 3c41cf34
No related branches found
No related tags found
No related merge requests found
components {
component robotCtrlA, docker compose = "ros_place_a", mqtt topic = "ros-place-a", status "ready" after 1 sec
component robotCtrlB, docker compose = "ros_place_b", mqtt topic = "ros-place-b", status "ready" after 1 sec
component ragA, docker compose = "rag_place_a", mqtt topic = "rag-a"
component ragB, docker compose = "rag_place_b", mqtt topic = "rag-b"
component random, docker compose = "cgv_random_dummy", status "ready" after 1 sec, start as up
component rosCore, docker compose = "ros_core", status "ready" after 2 sec
component mosquitto, docker compose = "mosquitto", status "ready" after 1 sec
component robotCtrlA, start using docker compose "ros_place_a", report using mqtt "ros-place-a", status "ready" after 1 sec
component robotCtrlB, start using docker compose "ros_place_b", report using mqtt "ros-place-b", status "ready" after 1 sec
component ragA, start using script "./place.sh a" in "ros3rag", report using mqtt "rag-a"
component ragB, start using script "./place.sh b" in "ros3rag", report using mqtt "rag-b"
component random, start using docker compose "cgv_random_dummy", status "ready" after 1 sec, start after reqs
component rosCore, start using docker compose "ros_core", status "ready" after 2 sec
component mosquitto, start using docker compose "mosquitto", status "ready" after 1 sec
// ros core needed for all other ros nodes
rosCore < robotCtrlA, robotCtrlB, random
......
......@@ -55,9 +55,8 @@ Comment = "//" [^\n\r]+
"in" { return sym(Terminals.IN); }
"start" { return sym(Terminals.START); }
"using" { return sym(Terminals.USING); }
"after reqs" { return sym(Terminals.AFTER_REQS); }
"reqs" { return sym(Terminals.REQS); }
"=" { return sym(Terminals.EQUALS); }
"," { return sym(Terminals.COMMA); }
"<" { return sym(Terminals.LT); }
"{" { return sym(Terminals.LB_CURLY); }
......
......@@ -60,7 +60,7 @@ aspect Manipulation {
//--- start ---
public abstract boolean StartStrategy.start() throws IOException, InterruptedException;
@Override
public boolean DockerComposeStrategy.start() throws IOException, InterruptedException {
public boolean DockerComposeStartStrategy.start() throws IOException, InterruptedException {
if (!getName().isBlank()) {
String[] args = { "docker-compose", "up", "-d", getName() };
if (coordinator().DRY_RUN) {
......@@ -91,7 +91,7 @@ aspect Manipulation {
}
@Override
public boolean ScriptStrategy.start() throws IOException, InterruptedException {
public boolean ScriptStartStrategy.start() throws IOException, InterruptedException {
String[] command = getCommand().split(" ");
if (coordinator().DRY_RUN) {
System.out.println("Would start script " + Arrays.toString(command));
......@@ -120,6 +120,7 @@ aspect Manipulation {
aspect Navigation {
inh Coordinator Component.coordinator();
inh Coordinator ParsedPrecedenceRelation.coordinator();
inh Coordinator StartStrategy.coordinator();
eq Coordinator.getChild().coordinator() = this;
inh Component StartStrategy.containingComponent();
......@@ -128,13 +129,13 @@ aspect Navigation {
syn boolean StartStrategy.isDockerComposeStartStrategy() = false;
eq DockerComposeStartStrategy.isDockerComposeStartStrategy() = true;
syn boolean StartStrategy.asDockerComposeStartStrategy() = null;
syn DockerComposeStartStrategy StartStrategy.asDockerComposeStartStrategy() = null;
eq DockerComposeStartStrategy.asDockerComposeStartStrategy() = this;
syn boolean ReportStrategy.isMqttReportStrategy() = false;
eq MqttReportStrategy.isMqttReportStrategy() = true;
syn boolean ReportStrategy.asMqttReportStrategy() = null;
syn MqttReportStrategy ReportStrategy.asMqttReportStrategy() = null;
eq MqttReportStrategy.asMqttReportStrategy() = this;
}
......@@ -203,8 +204,8 @@ aspect Printing {
return "[" + getStatus() + " after " + getDelayInSeconds() + " sec]";
}
syn String StartStrategy.details();
eq DockerComposeStrategy.details() = "docker compose (name: " + getName() + ")";
eq ScriptStrategy.details() = "script (cmd: '" + getCommand() + "'" + (getCwd().isBlank() ? "" : "cwd: '" + getCwd() + "'") + ")";
eq DockerComposeStartStrategy.details() = "docker compose (name: " + getName() + ")";
eq ScriptStartStrategy.details() = "script (cmd: '" + getCommand() + "'" + (getCwd().isBlank() ? "" : "cwd: '" + getCwd() + "'") + ")";
eq ManualStartStrategy.details() = "manual";
syn String ReportStrategy.details();
eq MqttReportStrategy.details() = "mqtt (topic: " + getTopicPrefix() + ")";
......@@ -232,7 +233,8 @@ aspect Resolving {
syn Optional<Component> Coordinator.resolveComponentByDockerComposeName(String dockerComposeName) {
for (Component comp : getComponentList()) {
if (comp.getDockerComposeName().equals(dockerComposeName)) {
if (comp.getStartStrategy().isDockerComposeStartStrategy() &&
comp.getStartStrategy().asDockerComposeStartStrategy().getName().equals(dockerComposeName)) {
return Optional.of(comp);
}
}
......
......@@ -47,18 +47,18 @@ Component component_body =
COMMA START USING start_strategy.s component_body.c {: c.setStartStrategy(s); return c; :}
| COMMA REPORT USING report_strategy.r component_body.c {: c.setReportStrategy(r); return c; :}
| COMMA STATUS TEXT.s AFTER INTEGER.i SEC component_body.c {: c.setAutoSetStatus(new AutoSetStatus(s, Integer.parseInt(i))); return c; :}
| COMMA START AFTER_REQS component_body.c {: c.setStartAsUp(true); return c; :}
| COMMA START AFTER REQS component_body.c {: c.setStartAsUp(true); return c; :}
| {: Component c = new Component(); c.setStartStrategy(new ManualStartStrategy()); return c; :}
;
StartStrategy start_strategy =
DOCKER_COMPOSE TEXT.dc component_body.c {: return new DockerComposeStrategy().setName(dc); :}
| SCRIPT TEXT.cmd {: return new ScriptStrategy().setCommand(cmd); :}
| SCRIPT TEXT.cmd IN TEXT.cwd {: return new ScriptStrategy().setCommand(cmd).setCwd(cwd); :}
DOCKER_COMPOSE TEXT.dc component_body.c {: return new DockerComposeStartStrategy().setName(dc); :}
| SCRIPT TEXT.cmd {: return new ScriptStartStrategy().setCommand(cmd); :}
| SCRIPT TEXT.cmd IN TEXT.cwd {: return new ScriptStartStrategy().setCommand(cmd).setCwd(cwd); :}
;
ReportStrategy report_strategy =
MQTT TEXT.topic component_body.c {: return new ReportStrategy().setMqttTopicPrefix(topic); return c; :}
MQTT TEXT.topic component_body.c {: return new MqttReportStrategy().setTopicPrefix(topic); :}
;
StringList string_list =
......
......@@ -4,6 +4,7 @@ import beaver.Parser;
import de.tudresden.inf.st.coordinator.ast.Component;
import de.tudresden.inf.st.coordinator.ast.Coordinator;
import de.tudresden.inf.st.coordinator.ast.MqttHandler;
import de.tudresden.inf.st.coordinator.ast.MqttReportStrategy;
import de.tudresden.inf.st.coordinator.parser.CoordinatorParser;
import de.tudresden.inf.st.coordinator.scanner.CoordinatorScanner;
import picocli.CommandLine;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment