Commit 199d5bcb authored by René Schöne's avatar René Schöne
Browse files

Rename read/write to receive/send

parent f86f4292
Pipeline #7534 passed with stages
in 4 minutes and 32 seconds
...@@ -7,32 +7,32 @@ aspect Errors { ...@@ -7,32 +7,32 @@ aspect Errors {
[new TreeSet<ErrorMessage>()] [new TreeSet<ErrorMessage>()]
root RagConnect; root RagConnect;
ReadFromMqttDefinition contributes error("Read definition already defined for " + getToken().getName()) ReceiveFromMqttDefinition contributes error("Receive definition already defined for " + getToken().getName())
when isAlreadyDefined() when isAlreadyDefined()
to RagConnect.errors(); to RagConnect.errors();
ReadFromMqttDefinition contributes error("Reading target token must not be an NTA token!") ReceiveFromMqttDefinition contributes error("Receiving target token must not be an NTA token!")
when getToken().getNTA() when getToken().getNTA()
to RagConnect.errors(); to RagConnect.errors();
// if first mapping is null, then suitableDefaultMapping() == null // if first mapping is null, then suitableDefaultMapping() == null
ReadFromMqttDefinition contributes error("No suitable default mapping found for type " + ReceiveFromMqttDefinition contributes error("No suitable default mapping found for type " +
((getMappingList().isEmpty()) ((getMappingList().isEmpty())
? getToken().getJavaTypeUse().prettyPrint() ? getToken().getJavaTypeUse().prettyPrint()
: getMappingList().get(0).getFromType().prettyPrint())) : getMappingList().get(0).getFromType().prettyPrint()))
when effectiveMappings().get(0) == null when effectiveMappings().get(0) == null
to RagConnect.errors(); to RagConnect.errors();
ReadFromMqttDefinition contributes error("to-type of last mapping must be type of the Token!") ReceiveFromMqttDefinition contributes error("to-type of last mapping must be type of the Token!")
when getToken().getJavaTypeUse().prettyPrint().equals( when getToken().getJavaTypeUse().prettyPrint().equals(
effectiveMappings().get(effectiveMappings().size() - 1)) effectiveMappings().get(effectiveMappings().size() - 1))
to RagConnect.errors(); to RagConnect.errors();
WriteToMqttDefinition contributes error("Writing target token must be an NTA token!") SendToMqttDefinition contributes error("Sending target token must be an NTA token!")
when !getToken().getNTA() when !getToken().getNTA()
to RagConnect.errors(); to RagConnect.errors();
WriteToMqttDefinition contributes error("Write definition already defined for " + getToken().getName()) SendToMqttDefinition contributes error("Send definition already defined for " + getToken().getName())
when isAlreadyDefined() when isAlreadyDefined()
to RagConnect.errors(); to RagConnect.errors();
...@@ -44,7 +44,7 @@ aspect Errors { ...@@ -44,7 +44,7 @@ aspect Errors {
when isAlreadyDefinedAsList() when isAlreadyDefinedAsList()
to RagConnect.errors(); to RagConnect.errors();
DependencyDefinition contributes error("There must be a write update definition targeting " + getSource().parentTypeypeAndName() + " for dependency definition " + getID()) DependencyDefinition contributes error("There must be a send update definition targeting " + getSource().parentTypeypeAndName() + " for dependency definition " + getID())
when targetEndpointDefinition() == null when targetEndpointDefinition() == null
to RagConnect.errors(); to RagConnect.errors();
} }
......
//TypeComponentMustache ; //TypeComponentMustache ;
//rel TypeComponentMustache.TypeComponent -> TypeComponent ; //rel TypeComponentMustache.TypeComponent -> TypeComponent ;
MRagConnect ::= ReadDefinition:MReadDefinition* WriteDefinition:MWriteDefinition* MappingDefinition:MMappingDefinition* DependencyDefinition:MDependencyDefinition* RootTypeComponent:MTypeComponent* TokenComponent:MTokenComponent*; MRagConnect ::= ReceiveDefinition:MReceiveDefinition* SendDefinition:MSendDefinition* MappingDefinition:MMappingDefinition* DependencyDefinition:MDependencyDefinition* RootTypeComponent:MTypeComponent* TokenComponent:MTokenComponent*;
abstract MEndpointDefinition ::= InnerMappingDefinition:MInnerMappingDefinition*; abstract MEndpointDefinition ::= InnerMappingDefinition:MInnerMappingDefinition*;
MReadDefinition : MEndpointDefinition; MReceiveDefinition : MEndpointDefinition;
MWriteDefinition : MEndpointDefinition; MSendDefinition : MEndpointDefinition;
MMappingDefinition; MMappingDefinition;
MInnerMappingDefinition; MInnerMappingDefinition;
MDependencyDefinition; MDependencyDefinition;
...@@ -13,8 +13,8 @@ MTokenComponent; ...@@ -13,8 +13,8 @@ MTokenComponent;
rel MRagConnect.RagConnect -> RagConnect; rel MRagConnect.RagConnect -> RagConnect;
rel MInnerMappingDefinition.MappingDefinition -> MappingDefinition; rel MInnerMappingDefinition.MappingDefinition -> MappingDefinition;
rel MReadDefinition.ReadFromMqttDefinition -> ReadFromMqttDefinition; rel MReceiveDefinition.ReceiveFromMqttDefinition -> ReceiveFromMqttDefinition;
rel MWriteDefinition.WriteToMqttDefinition -> WriteToMqttDefinition; rel MSendDefinition.SendToMqttDefinition -> SendToMqttDefinition;
rel MMappingDefinition.MappingDefinition -> MappingDefinition; rel MMappingDefinition.MappingDefinition -> MappingDefinition;
rel MDependencyDefinition.DependencyDefinition -> DependencyDefinition; rel MDependencyDefinition.DependencyDefinition -> DependencyDefinition;
rel MTypeComponent.TypeComponent -> TypeComponent; rel MTypeComponent.TypeComponent -> TypeComponent;
......
...@@ -24,25 +24,25 @@ aspect Navigation { ...@@ -24,25 +24,25 @@ aspect Navigation {
syn TokenEndpointDefinition EndpointDefinition.asTokenEndpointDefinition() = null; syn TokenEndpointDefinition EndpointDefinition.asTokenEndpointDefinition() = null;
eq TokenEndpointDefinition.asTokenEndpointDefinition() = this; eq TokenEndpointDefinition.asTokenEndpointDefinition() = this;
// --- isWriteToMqttDefinition --- // --- isSendToMqttDefinition ---
syn boolean EndpointDefinition.isWriteToMqttDefinition() = false; syn boolean EndpointDefinition.isSendToMqttDefinition() = false;
eq WriteToMqttDefinition.isWriteToMqttDefinition() = true; eq SendToMqttDefinition.isSendToMqttDefinition() = true;
// --- asWriteToMqttDefinition --- // --- asSendToMqttDefinition ---
syn WriteToMqttDefinition EndpointDefinition.asWriteToMqttDefinition() = null; syn SendToMqttDefinition EndpointDefinition.asSendToMqttDefinition() = null;
eq WriteToMqttDefinition.asWriteToMqttDefinition() = this; eq SendToMqttDefinition.asSendToMqttDefinition() = this;
// --- asReadFromMqttDefinition --- // --- asReceiveFromMqttDefinition ---
syn ReadFromMqttDefinition EndpointDefinition.asReadFromMqttDefinition() = null; syn ReceiveFromMqttDefinition EndpointDefinition.asReceiveFromMqttDefinition() = null;
eq ReadFromMqttDefinition.asReadFromMqttDefinition() = this; eq ReceiveFromMqttDefinition.asReceiveFromMqttDefinition() = this;
// --- targetEndpointDefinition --- // --- targetEndpointDefinition ---
syn WriteToMqttDefinition DependencyDefinition.targetEndpointDefinition() { syn SendToMqttDefinition DependencyDefinition.targetEndpointDefinition() {
// resolve definition in here, as we do not need resolveMethod in any other place (yet) // resolve definition in here, as we do not need resolveMethod in any other place (yet)
for (EndpointDefinition endpointDefinition : ragconnect().getEndpointDefinitionList()) { for (EndpointDefinition endpointDefinition : ragconnect().getEndpointDefinitionList()) {
if (endpointDefinition.isWriteToMqttDefinition() && if (endpointDefinition.isSendToMqttDefinition() &&
endpointDefinition.asWriteToMqttDefinition().getToken().equals(this.getTarget())) { endpointDefinition.asSendToMqttDefinition().getToken().equals(this.getTarget())) {
return endpointDefinition.asWriteToMqttDefinition(); return endpointDefinition.asSendToMqttDefinition();
} }
} }
return null; return null;
......
...@@ -7,8 +7,8 @@ rel EndpointDefinition.Mapping* -> MappingDefinition; ...@@ -7,8 +7,8 @@ rel EndpointDefinition.Mapping* -> MappingDefinition;
abstract TokenEndpointDefinition : EndpointDefinition; abstract TokenEndpointDefinition : EndpointDefinition;
rel TokenEndpointDefinition.Token -> TokenComponent; rel TokenEndpointDefinition.Token -> TokenComponent;
ReadFromMqttDefinition : TokenEndpointDefinition; ReceiveFromMqttDefinition : TokenEndpointDefinition;
WriteToMqttDefinition : TokenEndpointDefinition; SendToMqttDefinition : TokenEndpointDefinition;
DependencyDefinition ::= <ID>; DependencyDefinition ::= <ID>;
rel DependencyDefinition.Source <-> TokenComponent.DependencySourceDefinition*; rel DependencyDefinition.Source <-> TokenComponent.DependencySourceDefinition*;
......
...@@ -79,23 +79,23 @@ aspect AttributesForMustache { ...@@ -79,23 +79,23 @@ aspect AttributesForMustache {
syn String MInnerMappingDefinition.methodName() = getMappingDefinition().methodName(); syn String MInnerMappingDefinition.methodName() = getMappingDefinition().methodName();
inh String MInnerMappingDefinition.inputVarName(); inh String MInnerMappingDefinition.inputVarName();
// --- MReadDefinition --- // --- MReceiveDefinition ---
eq MReadDefinition.preemptiveExpectedValue() = "get" + tokenName() + "()"; eq MReceiveDefinition.preemptiveExpectedValue() = "get" + tokenName() + "()";
eq MReadDefinition.preemptiveReturn() = "return;"; eq MReceiveDefinition.preemptiveReturn() = "return;";
eq MReadDefinition.endpointDef() = getReadFromMqttDefinition(); eq MReceiveDefinition.endpointDef() = getReceiveFromMqttDefinition();
eq MReadDefinition.firstInputVarName() = "message"; eq MReceiveDefinition.firstInputVarName() = "message";
// --- MWriteDefinition --- // --- MSendDefinition ---
eq MWriteDefinition.preemptiveExpectedValue() = lastValue(); eq MSendDefinition.preemptiveExpectedValue() = lastValue();
eq MWriteDefinition.preemptiveReturn() = "return false;"; eq MSendDefinition.preemptiveReturn() = "return false;";
eq MWriteDefinition.endpointDef() = getWriteToMqttDefinition(); eq MSendDefinition.endpointDef() = getSendToMqttDefinition();
eq MWriteDefinition.firstInputVarName() = "get" + tokenName() + "()"; eq MSendDefinition.firstInputVarName() = "get" + tokenName() + "()";
syn String MWriteDefinition.writeTopic() = getWriteToMqttDefinition().writeTopic(); syn String MSendDefinition.sendTopic() = getSendToMqttDefinition().sendTopic();
syn String MWriteDefinition.lastValue() = getWriteToMqttDefinition().lastValue(); syn String MSendDefinition.lastValue() = getSendToMqttDefinition().lastValue();
syn String MWriteDefinition.updateMethod() = getWriteToMqttDefinition().updateMethod(); syn String MSendDefinition.updateMethod() = getSendToMqttDefinition().updateMethod();
syn String MWriteDefinition.writeMethod() = getWriteToMqttDefinition().writeMethod(); syn String MSendDefinition.writeMethod() = getSendToMqttDefinition().writeMethod();
syn String MWriteDefinition.tokenResetMethod() = getWriteToMqttDefinition().tokenResetMethod(); syn String MSendDefinition.tokenResetMethod() = getSendToMqttDefinition().tokenResetMethod();
// --- MMappingDefinition --- // --- MMappingDefinition ---
syn String MMappingDefinition.toType() = getMappingDefinition().getToType().prettyPrint(); syn String MMappingDefinition.toType() = getMappingDefinition().getToType().prettyPrint();
...@@ -130,10 +130,10 @@ aspect AttributesForMustache { ...@@ -130,10 +130,10 @@ aspect AttributesForMustache {
MRagConnect result = new MRagConnect(); MRagConnect result = new MRagConnect();
result.setRagConnect(this); result.setRagConnect(this);
for (EndpointDefinition def : getEndpointDefinitionList()) { for (EndpointDefinition def : getEndpointDefinitionList()) {
if (def.isWriteToMqttDefinition()) { if (def.isSendToMqttDefinition()) {
result.addWriteDefinition(def.asWriteToMqttDefinition().toMustache()); result.addSendDefinition(def.asSendToMqttDefinition().toMustache());
} else { } else {
result.addReadDefinition(def.asReadFromMqttDefinition().toMustache()); result.addReceiveDefinition(def.asReceiveFromMqttDefinition().toMustache());
} }
} }
for (MappingDefinition def : allMappingDefinitions()) { for (MappingDefinition def : allMappingDefinitions()) {
...@@ -163,15 +163,15 @@ aspect AttributesForMustache { ...@@ -163,15 +163,15 @@ aspect AttributesForMustache {
addInnerMappingDefinition(inner); addInnerMappingDefinition(inner);
} }
} }
syn lazy MReadDefinition ReadFromMqttDefinition.toMustache() { syn lazy MReceiveDefinition ReceiveFromMqttDefinition.toMustache() {
MReadDefinition result = new MReadDefinition(); MReceiveDefinition result = new MReceiveDefinition();
result.setReadFromMqttDefinition(this); result.setReceiveFromMqttDefinition(this);
result.addInnerMappings(); result.addInnerMappings();
return result; return result;
} }
syn lazy MWriteDefinition WriteToMqttDefinition.toMustache() { syn lazy MSendDefinition SendToMqttDefinition.toMustache() {
MWriteDefinition result = new MWriteDefinition(); MSendDefinition result = new MSendDefinition();
result.setWriteToMqttDefinition(this); result.setSendToMqttDefinition(this);
result.addInnerMappings(); result.addInnerMappings();
return result; return result;
} }
...@@ -206,11 +206,11 @@ aspect AspectGeneration { ...@@ -206,11 +206,11 @@ aspect AspectGeneration {
syn String TokenComponent.externalName() = getName(); syn String TokenComponent.externalName() = getName();
syn String TokenEndpointDefinition.connectMethod() = "connect" + getToken().getName(); syn String TokenEndpointDefinition.connectMethod() = "connect" + getToken().getName();
syn String WriteToMqttDefinition.writeTopic() = "_topic_" + getToken().getName(); syn String SendToMqttDefinition.sendTopic() = "_topic_" + getToken().getName();
syn String WriteToMqttDefinition.lastValue() = "_lastValue" + getToken().getName(); syn String SendToMqttDefinition.lastValue() = "_lastValue" + getToken().getName();
syn String WriteToMqttDefinition.updateMethod() = "_update_" + getToken().getName(); syn String SendToMqttDefinition.updateMethod() = "_update_" + getToken().getName();
syn String WriteToMqttDefinition.writeMethod() = "_writeLastValue_" + getToken().getName(); syn String SendToMqttDefinition.writeMethod() = "_writeLastValue_" + getToken().getName();
syn String WriteToMqttDefinition.tokenResetMethod() = "get" + getToken().getName() + "_reset"; syn String SendToMqttDefinition.tokenResetMethod() = "get" + getToken().getName() + "_reset";
syn String MappingDefinition.methodName() = "_apply_" + getID(); syn String MappingDefinition.methodName() = "_apply_" + getID();
syn String DependencyDefinition.dependencyMethod() = "add" + syn String DependencyDefinition.dependencyMethod() = "add" +
Character.toUpperCase(getID().charAt(0)) + Character.toUpperCase(getID().charAt(0)) +
......
...@@ -106,7 +106,7 @@ aspect DefaultMappings { ...@@ -106,7 +106,7 @@ aspect DefaultMappings {
aspect Mappings { aspect Mappings {
// --- effectiveMappings --- // --- effectiveMappings ---
syn java.util.List<MappingDefinition> EndpointDefinition.effectiveMappings(); syn java.util.List<MappingDefinition> EndpointDefinition.effectiveMappings();
eq ReadFromMqttDefinition.effectiveMappings() { eq ReceiveFromMqttDefinition.effectiveMappings() {
// if there is a first mapping, check if its input type is byte[]. // if there is a first mapping, check if its input type is byte[].
// or if no mappings are specified. // or if no mappings are specified.
// then prepend the suitable default mapping // then prepend the suitable default mapping
...@@ -120,7 +120,7 @@ aspect Mappings { ...@@ -120,7 +120,7 @@ aspect Mappings {
} }
return result; return result;
} }
eq WriteToMqttDefinition.effectiveMappings() { eq SendToMqttDefinition.effectiveMappings() {
// if there is a mapping, check if the output type of the last mapping is byte[]. // if there is a mapping, check if the output type of the last mapping is byte[].
// or if no mappings are specified. // or if no mappings are specified.
// then append the suitable default mapping // then append the suitable default mapping
...@@ -160,7 +160,7 @@ aspect Mappings { ...@@ -160,7 +160,7 @@ aspect Mappings {
// --- suitableDefaultMapping --- // --- suitableDefaultMapping ---
syn DefaultMappingDefinition EndpointDefinition.suitableDefaultMapping(); syn DefaultMappingDefinition EndpointDefinition.suitableDefaultMapping();
eq ReadFromMqttDefinition.suitableDefaultMapping() { eq ReceiveFromMqttDefinition.suitableDefaultMapping() {
String typeName = getMappingList().isEmpty() ? String typeName = getMappingList().isEmpty() ?
getToken().getJavaTypeUse().getName() : getToken().getJavaTypeUse().getName() :
getMappingList().get(0).getFromType().prettyPrint(); getMappingList().get(0).getFromType().prettyPrint();
...@@ -181,7 +181,7 @@ aspect Mappings { ...@@ -181,7 +181,7 @@ aspect Mappings {
default: return null; default: return null;
} }
} }
eq WriteToMqttDefinition.suitableDefaultMapping() { eq SendToMqttDefinition.suitableDefaultMapping() {
String typeName = getMappingList().isEmpty() ? String typeName = getMappingList().isEmpty() ?
getToken().getJavaTypeUse().getName() : getToken().getJavaTypeUse().getName() :
getMappingList().get(getMappingList().size() - 1).getFromType().prettyPrint(); getMappingList().get(getMappingList().size() - 1).getFromType().prettyPrint();
......
...@@ -13,30 +13,30 @@ RagConnect ragconnect ...@@ -13,30 +13,30 @@ RagConnect ragconnect
:} ; :} ;
EndpointDefinition endpoint_definition EndpointDefinition endpoint_definition
= READ ID.type_name DOT ID.token_name SCOL = RECEIVE ID.type_name DOT ID.token_name SCOL
{: {:
ReadFromMqttDefinition result = new ReadFromMqttDefinition(); ReceiveFromMqttDefinition result = new ReceiveFromMqttDefinition();
result.setToken(TokenComponent.createRef(type_name + "." + token_name)); result.setToken(TokenComponent.createRef(type_name + "." + token_name));
return result; return result;
:} :}
| READ ID.type_name DOT ID.token_name USING string_list.mapping_defs SCOL | RECEIVE ID.type_name DOT ID.token_name USING string_list.mapping_defs SCOL
{: {:
ReadFromMqttDefinition result = new ReadFromMqttDefinition(); ReceiveFromMqttDefinition result = new ReceiveFromMqttDefinition();
result.setToken(TokenComponent.createRef(type_name + "." + token_name)); result.setToken(TokenComponent.createRef(type_name + "." + token_name));
for (String mapping_def : makeMappingDefs(mapping_defs)) { for (String mapping_def : makeMappingDefs(mapping_defs)) {
result.addMapping(MappingDefinition.createRef(mapping_def)); result.addMapping(MappingDefinition.createRef(mapping_def));
} }
return result; return result;
:} :}
| WRITE ID.type_name DOT ID.token_name SCOL | SEND ID.type_name DOT ID.token_name SCOL
{: {:
WriteToMqttDefinition result = new WriteToMqttDefinition(); SendToMqttDefinition result = new SendToMqttDefinition();
result.setToken(TokenComponent.createRef(type_name + "." + token_name)); result.setToken(TokenComponent.createRef(type_name + "." + token_name));
return result; return result;
:} :}
| WRITE ID.type_name DOT ID.token_name USING string_list.mapping_defs SCOL | SEND ID.type_name DOT ID.token_name USING string_list.mapping_defs SCOL
{: {:
WriteToMqttDefinition result = new WriteToMqttDefinition(); SendToMqttDefinition result = new SendToMqttDefinition();
result.setToken(TokenComponent.createRef(type_name + "." + token_name)); result.setToken(TokenComponent.createRef(type_name + "." + token_name));
for (String mapping_def : makeMappingDefs(mapping_defs)) { for (String mapping_def : makeMappingDefs(mapping_defs)) {
result.addMapping(MappingDefinition.createRef(mapping_def)); result.addMapping(MappingDefinition.createRef(mapping_def));
......
"read" { yybegin(DECLARATION); return sym(Terminals.READ); } "receive" { yybegin(DECLARATION); return sym(Terminals.RECEIVE); }
"write" { yybegin(DECLARATION); return sym(Terminals.WRITE); } "send" { yybegin(DECLARATION); return sym(Terminals.SEND); }
"using" { return sym(Terminals.USING); } "using" { return sym(Terminals.USING); }
"canDependOn" { return sym(Terminals.CAN_DEPEND_ON); } "canDependOn" { return sym(Terminals.CAN_DEPEND_ON); }
"maps" { return sym(Terminals.MAPS); } "maps" { return sym(Terminals.MAPS); }
......
...@@ -77,9 +77,9 @@ public class Compiler extends AbstractCompiler { ...@@ -77,9 +77,9 @@ public class Compiler extends AbstractCompiler {
} }
for (GrammarFile grammarFile : ragConnect.getProgram().getGrammarFileList()) { for (GrammarFile grammarFile : ragConnect.getProgram().getGrammarFileList()) {
Path outputFile = getConfiguration().outputDir().toPath().resolve(grammarFile.getFileName()); Path outputFile = getConfiguration().outputDir().toPath().resolve(grammarFile.getFileName());
writeToFile(outputFile, grammarFile.generateAbstractGrammar()); sendToFile(outputFile, grammarFile.generateAbstractGrammar());
} }
writeToFile(getConfiguration().outputDir().toPath().resolve("RagConnect.jadd"), ragConnect.generateAspect(optionRootNode.value())); sendToFile(getConfiguration().outputDir().toPath().resolve("RagConnect.jadd"), ragConnect.generateAspect(optionRootNode.value()));
return 0; return 0;
} }
...@@ -118,7 +118,7 @@ public class Compiler extends AbstractCompiler { ...@@ -118,7 +118,7 @@ public class Compiler extends AbstractCompiler {
System.out.println(message); System.out.println(message);
} }
private void writeToFile(Path path, String str) throws CompilerException { private void sendToFile(Path path, String str) throws CompilerException {
try (BufferedWriter writer = Files.newBufferedWriter(path)) { try (BufferedWriter writer = Files.newBufferedWriter(path)) {
writer.append(str); writer.append(str);
} catch (Exception e) { } catch (Exception e) {
......
...@@ -123,11 +123,11 @@ public class SimpleMain { ...@@ -123,11 +123,11 @@ public class SimpleMain {
" ;"); " ;");
model.addMappingDefinition(mappingDefinition); model.addMappingDefinition(mappingDefinition);
ReadFromMqttDefinition readFromMqttDefinition = new ReadFromMqttDefinition(); ReceiveFromMqttDefinition receiveFromMqttDefinition = new ReceiveFromMqttDefinition();
readFromMqttDefinition.setAlwaysApply(false); receiveFromMqttDefinition.setAlwaysApply(false);
readFromMqttDefinition.setToken(TokenComponent.createRef("Link.CurrentPosition")); receiveFromMqttDefinition.setToken(TokenComponent.createRef("Link.CurrentPosition"));
readFromMqttDefinition.addMapping(mappingDefinition); receiveFromMqttDefinition.addMapping(mappingDefinition);
model.addEndpointDefinition(readFromMqttDefinition); model.addEndpointDefinition(receiveFromMqttDefinition);
model.treeResolveAll(); model.treeResolveAll();
for (ErrorMessage error : model.errors()) { for (ErrorMessage error : model.errors()) {
......
{{> mqtt}} {{> mqtt}}
aspect ROS2RAG { aspect ROS2RAG {
{{#ReadDefinitions}} {{#ReceiveDefinitions}}
{{> readDefinition}} {{> receiveDefinition}}
{{/ReadDefinitions}} {{/ReceiveDefinitions}}
{{#WriteDefinitions}} {{#SendDefinitions}}
{{> writeDefinition}} {{> sendDefinition}}
{{/WriteDefinitions}} {{/SendDefinitions}}
{{#MappingDefinitions}} {{#MappingDefinitions}}
{{> mappingDefinition}} {{> mappingDefinition}}
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
{{mqttHandlerAttribute}}().newConnection(topic, message -> { {{mqttHandlerAttribute}}().newConnection(topic, message -> {
{{> mappingApplication}} {{> mappingApplication}}
{{#loggingEnabledForReads}} {{#loggingEnabledForReads}}
System.out.println("[Read] " + topic + " -> {{tokenName}} = " + {{lastResult}});{{!lastResult has to be a new attribute}} System.out.println("[Receive] " + topic + " -> {{tokenName}} = " + {{lastResult}});{{!lastResult has to be a new attribute}}
{{/loggingEnabledForReads}} {{/loggingEnabledForReads}}
set{{tokenName}}({{lastResult}}); set{{tokenName}}({{lastResult}});
}); });
......
private String {{parentTypeName}}.{{writeTopic}} = null; private String {{parentTypeName}}.{{sendTopic}} = null;
private byte[] {{parentTypeName}}.{{lastValue}} = null; private byte[] {{parentTypeName}}.{{lastValue}} = null;
public void {{parentTypeName}}.{{connectMethod}}(String topic, boolean writeCurrentValue) { public void {{parentTypeName}}.{{connectMethod}}(String topic, boolean writeCurrentValue) {
{{writeTopic}} = topic; {{sendTopic}} = topic;
{{updateMethod}}(); {{updateMethod}}();
if (writeCurrentValue) { if (writeCurrentValue) {
{{writeMethod}}(); {{writeMethod}}();
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
protected void {{parentTypeName}}.{{writeMethod}}() { protected void {{parentTypeName}}.{{writeMethod}}() {
{{#loggingEnabledForWrites}} {{#loggingEnabledForWrites}}
System.out.println("[Write] {{tokenName}} = " + get{{tokenName}}() + " -> " + {{writeTopic}}); System.out.println("[Send] {{tokenName}} = " + get{{tokenName}}() + " -> " + {{sendTopic}});
{{/loggingEnabledForWrites}} {{/loggingEnabledForWrites}}
{{mqttHandlerAttribute}}().publish({{writeTopic}}, {{lastValue}}); {{mqttHandlerAttribute}}().publish({{sendTopic}}, {{lastValue}});
} }
// --- update definitions --- // --- update definitions ---
read NativeTypes.IntValue; receive NativeTypes.IntValue;
read NativeTypes.ShortValue; receive NativeTypes.ShortValue;
read NativeTypes.LongValue; receive NativeTypes.LongValue;
read NativeTypes.FloatValue; receive NativeTypes.FloatValue;
read NativeTypes.DoubleValue; receive NativeTypes.DoubleValue;
read NativeTypes.CharValue; receive NativeTypes.CharValue;
read NativeTypes.StringValue; receive NativeTypes.StringValue;
read BoxedTypes.IntValue; receive BoxedTypes.IntValue;
read BoxedTypes.ShortValue; receive BoxedTypes.ShortValue;
read BoxedTypes.LongValue; receive BoxedTypes.LongValue;
read BoxedTypes.FloatValue; receive BoxedTypes.FloatValue;
read BoxedTypes.DoubleValue; receive BoxedTypes.DoubleValue;
read BoxedTypes.CharValue; receive BoxedTypes.CharValue;
// --- update definitions --- // --- update definitions ---
// native types, synthesized // native types, synthesized
write NativeTypesSyn.IntValue; send NativeTypesSyn.IntValue;
write NativeTypesSyn.ShortValue; send NativeTypesSyn.ShortValue;
write NativeTypesSyn.LongValue; send NativeTypesSyn.LongValue;
write NativeTypesSyn.FloatValue; send NativeTypesSyn.FloatValue;
write NativeTypesSyn.DoubleValue; send NativeTypesSyn.DoubleValue;
write NativeTypesSyn.CharValue; send NativeTypesSyn.CharValue;
write NativeTypesSyn.StringValue; send NativeTypesSyn.StringValue;
// boxed types, synthesized // boxed types, synthesized
write BoxedTypesSyn.IntValue; send BoxedTypesSyn.IntValue;
write BoxedTypesSyn.ShortValue; send BoxedTypesSyn.ShortValue;
write BoxedTypesSyn.LongValue; send BoxedTypesSyn.LongValue;
write BoxedTypesSyn.FloatValue; send BoxedTypesSyn.FloatValue;
write BoxedTypesSyn.DoubleValue; send BoxedTypesSyn.DoubleValue;
write BoxedTypesSyn.CharValue; send BoxedTypesSyn.CharValue;
// --- dependency definitions --- // --- dependency definitions ---
NativeTypesSyn.IntValue canDependOn NativeTypesSyn.DriverSyn as nativeIntDependency; NativeTypesSyn.IntValue canDependOn NativeTypesSyn.DriverSyn as nativeIntDependency;
...@@ -34,18 +34,18 @@ BoxedTypesSyn.CharValue canDependOn BoxedTypesSyn.DriverSyn as boxedCharDependen ...@@ -34,18 +34,18 @@ BoxedTypesSyn.CharValue canDependOn BoxedTypesSyn.DriverSyn as boxedCharDependen
// --- inherited attributes not supported --- // --- inherited attributes not supported ---
//// native types, inherited //// native types, inherited
//write NativeTypesInh.IntValue; //send NativeTypesInh.IntValue;
//write NativeTypesInh.ShortValue; //send NativeTypesInh.ShortValue;
//write NativeTypesInh.LongValue; //send NativeTypesInh.LongValue;
//write NativeTypesInh.FloatValue;