Skip to content

Commit

Permalink
Improve dataflow encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferdinando Villa committed Oct 19, 2024
1 parent 2801a37 commit cf50e25
Showing 1 changed file with 14 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,34 +39,36 @@ private void encodeActuator(Actuator actuator, PrintWriter outWriter, int indent

outWriter.append(spacer).append(actuator.getActuatorType().name().toLowerCase()).append(" ");
outWriter.append(actuator.getActuatorType() == Actuator.Type.RESOLVE
? ("obs" + actuator.getId())
: actuator.getObservable().getUrn())
.append("\n");
? ("obs" + actuator.getId())
: actuator.getObservable().getUrn());

if (actuator.getStrategyUrn() != null) {
outWriter.append(dspacer).append("using ").append(actuator.getStrategyUrn());
outWriter.append("\n").append(dspacer).append("using ").append(actuator.getStrategyUrn());
}

outWriter.append("\n");

if (!actuator.getChildren().isEmpty()) {
outWriter.append(dspacer).append("(\n");
outWriter.append("\n").append(dspacer).append("(\n");
int i = 0;
for (var child : actuator.getChildren()) {
encodeActuator(child, outWriter, indent + 6);
if (i < actuator.getChildren().size() - 1) {
outWriter.append(",");
if (i < (actuator.getChildren().size() - 1)) {
outWriter.append(",\n");
}
i++;
}
outWriter.append(dspacer).append(")\n");
outWriter.append("\n").append(dspacer).append(")");
}

if (!actuator.getComputation().isEmpty()) {
outWriter.append(dspacer).append("apply\n");
outWriter.append("\n").append(dspacer).append("apply");
int i = 0;
for (var computation : actuator.getComputation()) {
outWriter.append(spacer).append(dspacer).append(computation.encode(Language.KIM)).append(i < (actuator.getComputation().size() - 1) ? ",\n" : "\n");
if (actuator.getComputation().size() > 1) {
outWriter.append("\n").append(spacer).append(dspacer);
} else {
outWriter.append(" ");
}
outWriter.append(computation.encode(Language.KIM)).append(i < (actuator.getComputation().size() - 1) ? "," : "");
i++;
}
}
Expand Down

0 comments on commit cf50e25

Please sign in to comment.