Skip to content

Commit 9501fe5

Browse files
NiHoffmannbjost2s
authored andcommitted
Issue #1542 and #1649: introcuding spike prime pybricks and refactor progRunController -> connectionController
1 parent 2e20851 commit 9501fe5

File tree

99 files changed

+4154
-1860
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+4154
-1860
lines changed

OpenRobertaRobot/src/main/java/de/fhg/iais/roberta/bean/UsedHardwareBean.java

+16
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import java.util.Set;
1010

1111
import de.fhg.iais.roberta.components.UsedActor;
12+
import de.fhg.iais.roberta.components.UsedImport;
1213
import de.fhg.iais.roberta.components.UsedSensor;
1314
import de.fhg.iais.roberta.syntax.lang.expr.VarDeclaration;
1415
import de.fhg.iais.roberta.syntax.lang.methods.Method;
@@ -18,6 +19,7 @@
1819
* Container for all used hardware related information, used in for example code generation. Currently used for more than just used hardware, should be split up
1920
* into multiple separate beans in the future.
2021
*/
22+
//TODO change name of class, no longer only used hardware
2123
//TODO move unrelated data to specific beans. Refactor fields from Mbed into usedActors/Sensors
2224
public class UsedHardwareBean implements IProjectBean {
2325

@@ -37,6 +39,7 @@ public class UsedHardwareBean implements IProjectBean {
3739
private Set<UsedActor> usedActors = new LinkedHashSet<>();
3840
private Set<String> usedImages = new HashSet<>();
3941
private Map<String, String[][]> usedIDImages = new HashMap<>();
42+
private Set<UsedImport> usedImports = new LinkedHashSet<>();
4043

4144
public List<VarDeclaration> getVisitedVars() {
4245
return this.visitedVars;
@@ -71,6 +74,10 @@ public boolean isNNBlockUsed() {
7174
return this.isNNBlockUsed;
7275
}
7376

77+
public Set<UsedImport> getUsedImports() {
78+
return this.usedImports;
79+
}
80+
7481
public Set<UsedSensor> getUsedSensors() {
7582
return this.usedSensors;
7683
}
@@ -95,6 +102,10 @@ public boolean isActorUsed(String type) {
95102
return this.usedActors.stream().anyMatch(usedActor -> usedActor.getType().equals(type));
96103
}
97104

105+
public boolean isImportUsed(String type) {
106+
return this.usedImports.stream().anyMatch(usedImport -> usedImport.getType().equals(type));
107+
}
108+
98109
public Map<Integer, Boolean> getLoopsLabelContainer() {
99110
return this.loopsLabelContainer;
100111
}
@@ -147,6 +158,11 @@ public Builder setNNBlockUsed(boolean isNNBlockUsed) {
147158
return this;
148159
}
149160

161+
public Builder addUsedImport(UsedImport usedImport) {
162+
this.usedHardwareBean.usedImports.add(usedImport);
163+
return this;
164+
}
165+
150166
public Builder addUsedSensor(UsedSensor usedSensor) {
151167
this.usedHardwareBean.usedSensors.add(usedSensor);
152168
return this;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package de.fhg.iais.roberta.components;
2+
3+
public class UsedImport {
4+
5+
private final String type;
6+
7+
/**
8+
* Used Import flag for Code generation
9+
*
10+
* @param type the Import name or type
11+
*/
12+
public UsedImport(String type) {
13+
this.type = type;
14+
}
15+
16+
/**
17+
* @return the Type
18+
*/
19+
public String getType() {
20+
return this.type;
21+
}
22+
23+
@Override
24+
public int hashCode() {
25+
final int prime = 31;
26+
int result = 1;
27+
result = prime * result + ((this.type == null) ? 0 : this.type.hashCode());
28+
return result;
29+
}
30+
31+
@Override
32+
public boolean equals(Object obj) {
33+
if ( this == obj ) {
34+
return true;
35+
}
36+
if ( obj == null ) {
37+
return false;
38+
}
39+
if ( getClass() != obj.getClass() ) {
40+
return false;
41+
}
42+
UsedImport other = (UsedImport) obj;
43+
44+
if ( this.type == null ) {
45+
if ( other.type != null ) {
46+
return false;
47+
}
48+
} else if ( !this.type.equals(other.type) ) {
49+
return false;
50+
}
51+
return true;
52+
}
53+
54+
@Override
55+
public String toString() {
56+
return "UsedImport [" + this.getType() + "]";
57+
}
58+
59+
}

OpenRobertaRobot/src/main/java/de/fhg/iais/roberta/factory/RobotFactory.java

-16
Original file line numberDiff line numberDiff line change
@@ -157,18 +157,6 @@ public final String getRobotAnnouncement() {
157157
return this.pluginProperties.getStringProperty("robot.announcement");
158158
}
159159

160-
public final Boolean hasStopButton() {
161-
return this.pluginProperties.getStringProperty("robot.stopButton") != null;
162-
}
163-
164-
public final String getConnectionType() {
165-
return this.pluginProperties.getStringProperty("robot.connection");
166-
}
167-
168-
public final void setConnectionType(String type) {
169-
this.pluginProperties.setStringProperty("robot.connection", type);
170-
}
171-
172160
public final String getVendorId() {
173161
return this.pluginProperties.getStringProperty("robot.vendor");
174162
}
@@ -212,10 +200,6 @@ public final String getMenuVersion() {
212200
return this.pluginProperties.getStringProperty("robot.menu.version");
213201
}
214202

215-
public final Boolean hasWlanCredentials() {
216-
return this.pluginProperties.getStringProperty("robot.haswlan") != null;
217-
}
218-
219203
public final String getFirmwareDefaultProgramName() {
220204
return this.pluginProperties.getStringProperty("robot.factory.default");
221205
}

OpenRobertaRobot/src/main/java/de/fhg/iais/roberta/util/syntax/SC.java

+5
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,9 @@ public interface SC {
139139

140140
String OLEDSSD1306I2C = "OLEDSSD1306I2C";
141141

142+
String COlOR_IMPORT = "COLOR_IMPORT";
143+
String WAIT = "WAIT";
144+
String PORT = "PORT";
145+
String MATH = "MATH";
146+
142147
}

OpenRobertaServer/src/main/java/de/fhg/iais/roberta/generated/restEntities/SetRobotResponse.java

+8-70
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,18 @@ public class SetRobotResponse extends BaseResponse {
2525
protected boolean markerSim;
2626
protected boolean markerSimDefined = false;
2727
protected boolean nn;
28-
protected JSONArray nnActivations;
2928
protected boolean nnDefined = false;
29+
protected JSONArray nnActivations;
3030
protected boolean webotsSim;
3131
protected boolean webotsSimDefined = false;
3232
protected String webotsUrl;
33-
protected String connection;
3433
protected String vendor;
3534
protected boolean configurationUsed;
3635
protected boolean configurationUsedDefined = false;
3736
protected String commandLine;
3837
protected String signature;
3938
protected String sourceCodeFileExtension;
4039
protected String binaryFileExtension;
41-
protected boolean hasWlan;
42-
protected boolean hasWlanDefined = false;
4340
protected String firmwareDefault;
4441

4542
/**
@@ -92,14 +89,12 @@ public static SetRobotResponse makeFromProperties(
9289
JSONArray nnActivations,
9390
boolean webotsSim,
9491
String webotsUrl,
95-
String connection,
9692
String vendor,
9793
boolean configurationUsed,
9894
String commandLine,
9995
String signature,
10096
String sourceCodeFileExtension,
10197
String binaryFileExtension,
102-
boolean hasWlan,
10398
String firmwareDefault) {
10499
SetRobotResponse entity = new SetRobotResponse();
105100
entity.setCmd(cmd);
@@ -129,14 +124,12 @@ public static SetRobotResponse makeFromProperties(
129124
entity.setNnActivations(nnActivations);
130125
entity.setWebotsSim(webotsSim);
131126
entity.setWebotsUrl(webotsUrl);
132-
entity.setConnection(connection);
133127
entity.setVendor(vendor);
134128
entity.setConfigurationUsed(configurationUsed);
135129
entity.setCommandLine(commandLine);
136130
entity.setSignature(signature);
137131
entity.setSourceCodeFileExtension(sourceCodeFileExtension);
138132
entity.setBinaryFileExtension(binaryFileExtension);
139-
entity.setHasWlan(hasWlan);
140133
entity.setFirmwareDefault(firmwareDefault);
141134
entity.immutable();
142135
return entity;
@@ -206,14 +199,12 @@ public SetRobotResponse merge(JSONObject jsonO) {
206199
setMarkerSim(jsonO.getBoolean(key));
207200
} else if ( "nn".equals(key) ) {
208201
setNn(jsonO.getBoolean(key));
209-
} else if ( "nn.activations".equals(key) ) {
202+
} else if ( "nnActivations".equals(key) ) {
210203
setNnActivations(jsonO.getJSONArray(key));
211204
} else if ( "webotsSim".equals(key) ) {
212205
setWebotsSim(jsonO.getBoolean(key));
213206
} else if ( "webotsUrl".equals(key) ) {
214207
setWebotsUrl(jsonO.optString(key));
215-
} else if ( "connection".equals(key) ) {
216-
setConnection(jsonO.getString(key));
217208
} else if ( "vendor".equals(key) ) {
218209
setVendor(jsonO.getString(key));
219210
} else if ( "configurationUsed".equals(key) ) {
@@ -226,8 +217,6 @@ public SetRobotResponse merge(JSONObject jsonO) {
226217
setSourceCodeFileExtension(jsonO.getString(key));
227218
} else if ( "binaryFileExtension".equals(key) ) {
228219
setBinaryFileExtension(jsonO.getString(key));
229-
} else if ( "hasWlan".equals(key) ) {
230-
setHasWlan(jsonO.getBoolean(key));
231220
} else if ( "firmwareDefault".equals(key) ) {
232221
setFirmwareDefault(jsonO.optString(key));
233222
} else {
@@ -296,14 +285,11 @@ private SetRobotResponse validate() {
296285
_message = "required property nn of SetRobotResponse-object is not set: " + toString();
297286
}
298287
if ( nnActivations == null ) {
299-
_message = "required property nn.activations of SetRobotResponse-object is not set: " + toString();
288+
_message = "required property nnActivations of SetRobotResponse-object is not set: " + toString();
300289
}
301290
if ( !webotsSimDefined ) {
302291
_message = "required property webotsSim of SetRobotResponse-object is not set: " + toString();
303292
}
304-
if ( connection == null ) {
305-
_message = "required property connection of SetRobotResponse-object is not set: " + toString();
306-
}
307293
if ( vendor == null ) {
308294
_message = "required property vendor of SetRobotResponse-object is not set: " + toString();
309295
}
@@ -316,9 +302,6 @@ private SetRobotResponse validate() {
316302
if ( binaryFileExtension == null ) {
317303
_message = "required property binaryFileExtension of SetRobotResponse-object is not set: " + toString();
318304
}
319-
if ( !hasWlanDefined ) {
320-
_message = "required property hasWlan of SetRobotResponse-object is not set: " + toString();
321-
}
322305
if ( _message != null ) {
323306
this.immutable = false;
324307
throw new RuntimeException(_message);
@@ -478,21 +461,21 @@ public SetRobotResponse setNn(boolean nn) {
478461
}
479462

480463
/**
481-
* GET NN activations. Object must be immutable. Never return null or an undefined/default value.
464+
* GET nnActivations. Object must be immutable. Never return null or an undefined/default value.
482465
*/
483466
public JSONArray getNnActivations() {
484467
if ( !this.immutable ) {
485-
throw new RuntimeException("no NN activations from an object under construction: " + toString());
468+
throw new RuntimeException("no nnActivations from an object under construction: " + toString());
486469
}
487470
return this.nnActivations;
488471
}
489472

490473
/**
491-
* SET NN activations for the robot. Object must be mutable.
474+
* SET nnActivations. Object must be mutable.
492475
*/
493476
public SetRobotResponse setNnActivations(JSONArray nnActivations) {
494477
if ( this.immutable ) {
495-
throw new RuntimeException("nn activations assigned to an immutable object: " + toString());
478+
throw new RuntimeException("nnActivations assigned to an immutable object: " + toString());
496479
}
497480
this.nnActivations = nnActivations;
498481
return this;
@@ -550,27 +533,6 @@ public SetRobotResponse setWebotsUrl(String webotsUrl) {
550533
return this;
551534
}
552535

553-
/**
554-
* GET connection. Object must be immutable. Never return null or an undefined/default value.
555-
*/
556-
public String getConnection() {
557-
if ( !this.immutable ) {
558-
throw new RuntimeException("no connection from an object under construction: " + toString());
559-
}
560-
return this.connection;
561-
}
562-
563-
/**
564-
* SET connection. Object must be mutable.
565-
*/
566-
public SetRobotResponse setConnection(String connection) {
567-
if ( this.immutable ) {
568-
throw new RuntimeException("connection assigned to an immutable object: " + toString());
569-
}
570-
this.connection = connection;
571-
return this;
572-
}
573-
574536
/**
575537
* GET vendor. Object must be immutable. Never return null or an undefined/default value.
576538
*/
@@ -716,28 +678,6 @@ public SetRobotResponse setBinaryFileExtension(String binaryFileExtension) {
716678
return this;
717679
}
718680

719-
/**
720-
* GET hasWlan. Object must be immutable. Never return null or an undefined/default value.
721-
*/
722-
public boolean getHasWlan() {
723-
if ( !this.immutable ) {
724-
throw new RuntimeException("no hasWlan from an object under construction: " + toString());
725-
}
726-
return this.hasWlan;
727-
}
728-
729-
/**
730-
* SET hasWlan. Object must be mutable.
731-
*/
732-
public SetRobotResponse setHasWlan(boolean hasWlan) {
733-
if ( this.immutable ) {
734-
throw new RuntimeException("hasWlan assigned to an immutable object: " + toString());
735-
}
736-
this.hasWlan = hasWlan;
737-
this.hasWlanDefined = true;
738-
return this;
739-
}
740-
741681
/**
742682
* GET firmwareDefault. Object must be immutable. Never return null or an undefined/default value.
743683
*/
@@ -834,7 +774,6 @@ public JSONObject toJson() {
834774
if ( this.webotsUrl != null ) {
835775
jsonO.put("webotsUrl", this.webotsUrl);
836776
}
837-
jsonO.put("connection", this.connection);
838777
jsonO.put("vendor", this.vendor);
839778
jsonO.put("configurationUsed", this.configurationUsed);
840779
if ( this.commandLine != null ) {
@@ -845,7 +784,6 @@ public JSONObject toJson() {
845784
}
846785
jsonO.put("sourceCodeFileExtension", this.sourceCodeFileExtension);
847786
jsonO.put("binaryFileExtension", this.binaryFileExtension);
848-
jsonO.put("hasWlan", this.hasWlan);
849787
if ( this.firmwareDefault != null ) {
850788
jsonO.put("firmwareDefault", this.firmwareDefault);
851789
}
@@ -857,7 +795,7 @@ public JSONObject toJson() {
857795

858796
@Override
859797
public String toString() {
860-
return "SetRobotResponse [immutable=" + this.immutable + ", cmd=" + this.cmd + ", rc=" + this.rc + ", message=" + this.message + ", cause=" + this.cause + ", parameters=" + this.parameters + ", initToken=" + this.initToken + ", serverTime=" + this.serverTime + ", serverVersion=" + this.serverVersion + ", robotWait=" + this.robotWait + ", robotBattery=" + this.robotBattery + ", robotName=" + this.robotName + ", robotVersion=" + this.robotVersion + ", robotFirmwareName=" + this.robotFirmwareName + ", robotSensorvalues=" + this.robotSensorvalues + ", robotNepoexitvalue=" + this.robotNepoexitvalue + ", robotState=" + this.robotState + ", notificationsAvailable=" + this.notificationsAvailable + ", robot=" + this.robot + ", program=" + this.program + ", configuration=" + this.configuration + ", sim=" + this.sim + ", multipleSim=" + this.multipleSim + ", markerSim=" + this.markerSim + ", nn=" + this.nn + ", nnActivations=" + this.nnActivations + ", webotsSim=" + this.webotsSim + ", webotsUrl=" + this.webotsUrl + ", connection=" + this.connection + ", vendor=" + this.vendor + ", configurationUsed=" + this.configurationUsed + ", commandLine=" + this.commandLine + ", signature=" + this.signature + ", sourceCodeFileExtension=" + this.sourceCodeFileExtension + ", binaryFileExtension=" + this.binaryFileExtension + ", hasWlan=" + this.hasWlan + ", firmwareDefault=" + this.firmwareDefault + " ]";
798+
return "SetRobotResponse [immutable=" + this.immutable + ", cmd=" + this.cmd + ", rc=" + this.rc + ", message=" + this.message + ", cause=" + this.cause + ", parameters=" + this.parameters + ", initToken=" + this.initToken + ", serverTime=" + this.serverTime + ", serverVersion=" + this.serverVersion + ", robotWait=" + this.robotWait + ", robotBattery=" + this.robotBattery + ", robotName=" + this.robotName + ", robotVersion=" + this.robotVersion + ", robotFirmwareName=" + this.robotFirmwareName + ", robotSensorvalues=" + this.robotSensorvalues + ", robotNepoexitvalue=" + this.robotNepoexitvalue + ", robotState=" + this.robotState + ", notificationsAvailable=" + this.notificationsAvailable + ", robot=" + this.robot + ", program=" + this.program + ", configuration=" + this.configuration + ", sim=" + this.sim + ", multipleSim=" + this.multipleSim + ", markerSim=" + this.markerSim + ", nn=" + this.nn + ", nnActivations=" + this.nnActivations + ", webotsSim=" + this.webotsSim + ", webotsUrl=" + this.webotsUrl + ", vendor=" + this.vendor + ", configurationUsed=" + this.configurationUsed + ", commandLine=" + this.commandLine + ", signature=" + this.signature + ", sourceCodeFileExtension=" + this.sourceCodeFileExtension + ", binaryFileExtension=" + this.binaryFileExtension + ", firmwareDefault=" + this.firmwareDefault + " ]";
861799
}
862800

863801
@Override

OpenRobertaServer/src/main/java/de/fhg/iais/roberta/javaServer/restServices/all/controller/ClientAdmin.java

-2
Original file line numberDiff line numberDiff line change
@@ -197,14 +197,12 @@ public Response setRobot(FullRestRequest fullRequest) throws Exception //
197197
response.setNnActivations(robotFactory.getNNActivations());
198198
response.setWebotsSim(robotFactory.hasWebotsSim());
199199
response.setWebotsUrl(robotFactory.getWebotsUrl());
200-
response.setConnection(robotFactory.getConnectionType());
201200
response.setVendor(robotFactory.getVendorId());
202201
response.setConfigurationUsed(robotFactory.hasConfiguration());
203202
response.setCommandLine(robotFactory.getCommandline());
204203
response.setSignature(robotFactory.getSignature());
205204
response.setSourceCodeFileExtension(robotFactory.getSourceCodeFileExtension());
206205
response.setBinaryFileExtension(robotFactory.getBinaryFileExtension());
207-
response.setHasWlan(robotFactory.hasWlanCredentials());
208206
response.setFirmwareDefault(robotFactory.getFirmwareDefaultProgramName());
209207
LOG.info("set robot to {}", robot);
210208
Statistics.info("ChangeRobot", "success", true, "robot", robot);

OpenRobertaServer/src/main/java/de/fhg/iais/roberta/javaServer/restServices/all/controller/ClientInit.java

-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ public Response command(InitRequest fullRequest, @Context HttpServletRequest htt
101101
robotDescription.put("infoDE", robotInfoDE);
102102
robotDescription.put("infoEN", robotInfoEN);
103103
robotDescription.put("announcement", httpSessionState.getRobotFactory(robot).getRobotAnnouncement());
104-
robotDescription.put("stopButton", httpSessionState.getRobotFactory(robot).hasStopButton());
105104
robotDescription.put("group", httpSessionState.getRobotFactory(robot).getGroup());
106105
robotDescription.put("sim", httpSessionState.getRobotFactory(robot).hasSim());
107106
robotDescription.put("nn", httpSessionState.getRobotFactory(robot).hasNN());

0 commit comments

Comments
 (0)