Skip to content

Commit 047c17b

Browse files
Changed placeholder strings to make them more distinguishable from normal strings
1 parent bf42820 commit 047c17b

File tree

3 files changed

+124
-123
lines changed

3 files changed

+124
-123
lines changed

lib/src/main/java/plc2skill/mapping/Plc2SkillMapper.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,13 @@
3636
public class Plc2SkillMapper {
3737

3838
private final Logger logger = LoggerFactory.getLogger(getClass());
39+
40+
private final String placeholderIdentifier = "__NodeIdRootComponent__";
41+
private final String placeholderEndpointURL = "__ServerEndpointUrl__";
3942

4043
private QuadStore rmlMappingResult;
4144
static String stateMachineTemplateFile = "PLCStateMachine.ttl";
42-
static String pattern = "_Replace_";
45+
static String pattern = "__SkillNamePlaceholder__";
4346

4447
private Path plcOpenFilePath;
4548
private String endpointUrl;
@@ -111,7 +114,6 @@ private String completeMappingResult() {
111114
// If a nodeIdRoot is given by the user, use it
112115
if (nodeIdRoot != null) {
113116
String stringMappingResult = RmlMapper.convertResultToString(this.rmlMappingResult);
114-
String placeholderIdentifier = "PLCIdentifier";
115117
resultWithIpPlaceholder = stringMappingResult.replaceAll(placeholderIdentifier, this.nodeIdRoot); // Replaces nodeID-Placeholder
116118

117119
} else {
@@ -135,15 +137,14 @@ private String completeMappingResult() {
135137

136138
}
137139
} catch (Exception e) {
138-
logger.error("Error while making a connection to the OPC UA server. Please check your endpointUrl and make sure the server is running.\n"
139-
+ "No nodeIdRoot was provided and a connection to the OPC UA could not be made. The mapping result will contain incomplete nodeIds with unreplaced template strings.");
140+
logger.error("Error while making a connection to the OPC UA server. Please check your endpointUrl and make sure the server is running.");
141+
logger.error("No nodeIdRoot was provided and a connection to the OPC UA could not be made. The mapping result will contain incomplete nodeIds with unreplaced template strings.");
140142
e.printStackTrace();
141143
}
142144

143145
resultWithIpPlaceholder = RmlMapper.convertResultToString(rmlMappingResult);
144146
}
145147

146-
String placeholderEndpointURL = "ServerIP";
147148
String result = resultWithIpPlaceholder.replaceAll(placeholderEndpointURL, this.endpointUrl);
148149
return result;
149150
}
@@ -195,8 +196,8 @@ private String createStateMachines(Path plcOpenFilePath) {
195196
// For every procedureNode: Create a customized state machine by replacing the placeholder and add it to the total stateMachin string
196197
String mappedStateMachines = "";
197198
for (int i = 0; i < procedureNodes.getLength(); i++) {
198-
String nodeName = procedureNodes.item(i).getAttributes().getNamedItem("name").getNodeValue();
199-
String stateMachine = stateMachineTemplate.replaceAll(pattern, nodeName);
199+
String skillName = procedureNodes.item(i).getAttributes().getNamedItem("name").getNodeValue();
200+
String stateMachine = stateMachineTemplate.replaceAll(pattern, skillName);
200201
mappedStateMachines += stateMachine;
201202
}
202203

lib/src/main/resources/PLC2SkillMappingRules.ttl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
rr:predicateObjectMap[
2525
rr:predicate OPCUA:nodeId;
2626
rr:objectMap[
27-
rr:template "PLCIdentifier.{./ancestor::resource/@name}.{./ancestor::resource/task/pouInstance/@name}.{@name}";
27+
rr:template "__NodeIdRootComponent__.{./ancestor::resource/@name}.{./ancestor::resource/task/pouInstance/@name}.{@name}";
2828
rr:datatype xsd:string;
2929
]
3030
];
@@ -78,7 +78,7 @@
7878
rr:predicateObjectMap [
7979
rr:predicate OPCUA:nodeId;
8080
rr:objectMap [
81-
rr:template "PLCIdentifier.{./ancestor::resource/@name}.{./ancestor::resource/task/pouInstance/@name}.{@name}.{./ancestor::instances/configurations/configuration/resource/addData/data/pou[@name=./type/derived/@name]/interface/inputVars/variable[./type/derived/@name='PLC2Skill.SkillParameter']/@name}.value";
81+
rr:template "__NodeIdRootComponent__.{./ancestor::resource/@name}.{./ancestor::resource/task/pouInstance/@name}.{@name}.{./ancestor::instances/configurations/configuration/resource/addData/data/pou[@name=./type/derived/@name]/interface/inputVars/variable[./type/derived/@name='PLC2Skill.SkillParameter']/@name}.value";
8282
rr:datatype xsd:string;
8383
]
8484
];
@@ -132,7 +132,7 @@
132132
rr:predicateObjectMap [
133133
rr:predicate OPCUA:nodeId;
134134
rr:objectMap [
135-
rr:template "PLCIdentifier.{./ancestor::resource/@name}.{./ancestor::resource/task/pouInstance/@name}.{@name}.{./ancestor::instances/configurations/configuration/resource/addData/data/pou[@name=./type/derived/@name]/interface/outputVars/variable[./type/derived/@name='PLC2Skill.SkillParameter']/@name}.value";
135+
rr:template "__NodeIdRootComponent__.{./ancestor::resource/@name}.{./ancestor::resource/task/pouInstance/@name}.{@name}.{./ancestor::instances/configurations/configuration/resource/addData/data/pou[@name=./type/derived/@name]/interface/outputVars/variable[./type/derived/@name='PLC2Skill.SkillParameter']/@name}.value";
136136
rr:datatype xsd:string;
137137
]
138138
];
@@ -214,7 +214,7 @@
214214
rr:predicateObjectMap [
215215
rr:predicate OPCUA:nodeId;
216216
rr:objectMap [
217-
rr:template "PLCIdentifier.{./ancestor::resource/@name}.{./ancestor::resource/task/pouInstance/@name}.{@name}.currentState";
217+
rr:template "__NodeIdRootComponent__.{./ancestor::resource/@name}.{./ancestor::resource/task/pouInstance/@name}.{@name}.currentState";
218218
rr:datatype xsd:string;
219219
]
220220
];
@@ -1119,7 +1119,7 @@
11191119
rr:predicateObjectMap[
11201120
rr:predicate OPCUA:nodeId;
11211121
rr:objectMap[
1122-
rr:template "PLCIdentifier.{./ancestor::resource/@name}.{./ancestor::resource/task/pouInstance/@name}.{@name}.transition";
1122+
rr:template "__NodeIdRootComponent__.{./ancestor::resource/@name}.{./ancestor::resource/task/pouInstance/@name}.{@name}.transition";
11231123
rr:datatype xsd:string
11241124
]
11251125

@@ -1619,7 +1619,7 @@
16191619
rr:predicateObjectMap [
16201620
rr:predicate OPCUA:hasEndpointUrl;
16211621
rr:objectMap [
1622-
rr:template "ServerIP";
1622+
rr:template "__ServerEndpointUrl__";
16231623
rr:datatype xsd:string
16241624
]];
16251625
rr:predicateObjectMap [

0 commit comments

Comments
 (0)