Skip to content

Commit 000455b

Browse files
committed
Check S7 driver for USR & ALRM fault.
1 parent fd4bf09 commit 000455b

File tree

10 files changed

+60
-44
lines changed

10 files changed

+60
-44
lines changed

plc4j/drivers/bacnet/src/main/generated/org/apache/plc4x/java/bacnetip/readwrite/BACnetVendorId.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1628,9 +1628,6 @@ public enum BACnetVendorId {
16281628
OLYMPIA_ELECTRONICS((int) 1416, (int) 1416, (String) "Olympia Electronics"),
16291629
NORMAL_SOFTWARE_INC((int) 1417, (int) 1417, (String) "Normal Software, Inc."),
16301630
ST_ENGINEERING_SOLUTIONJSC((int) 1418, (int) 1418, (String) "ST Engineering Solution JSC"),
1631-
TECHKNAVE((int) 1407, (int) 1407, (String) "Techknave"),
1632-
ELSNER_ELEKTRONIK((int) 1408, (int) 1408, (String) "Elsner Elektronik"),
1633-
16341631
UNKNOWN_VENDOR((int) 0xFFFF, (int) 0xFFFF, (String) "Unknown");
16351632
private static final Map<Integer, BACnetVendorId> map;
16361633

plc4j/drivers/s7/src/main/generated/org/apache/plc4x/java/s7/readwrite/S7VarPayloadDataItem.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void serialize(WriteBuffer writeBuffer) throws SerializationException {
104104
// Padding Field (padding)
105105
writePaddingField(
106106
"padding",
107-
(int) ((((!(_lastItem))) ? ((COUNT(data)) % (2)) : 0)),
107+
(int) ((((!(_lastItem))) ? ((COUNT(data)) % (2)) : 0)),
108108
(short) 0x00,
109109
writeUnsignedShort(writeBuffer, 8));
110110

plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/protocol/S7HMuxImpl.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
package org.apache.plc4x.java.s7.readwrite.protocol;
2020

2121
import io.netty.buffer.ByteBuf;
22+
import io.netty.buffer.ByteBufUtil;
2223
import io.netty.channel.Channel;
2324
import io.netty.channel.ChannelHandler.Sharable;
2425
import io.netty.channel.ChannelHandlerContext;
@@ -117,7 +118,7 @@ public class S7HMuxImpl extends MessageToMessageCodec<ByteBuf, ByteBuf> implemen
117118
*/
118119
@Override
119120
protected void encode(ChannelHandlerContext ctx, ByteBuf outbb, List<Object> list) throws Exception {
120-
System.out.println("Llego aqui: " + outbb);
121+
//System.out.println("Llego aqui: " + ByteBufUtil.hexDump(outbb));
121122
if ((embed_ctx == null) && (ctx.channel() instanceof EmbeddedChannel)) embed_ctx = ctx;
122123
if ((tcp_channel != null) && (embed_ctx == ctx)){
123124
tcp_channel.writeAndFlush(outbb.copy());

plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/EventSubscription.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,25 +53,25 @@ public static void main(String[] args) throws Exception {
5353
try (PlcConnection connection = new DefaultPlcDriverManager().getConnection("s7://10.10.1.33?remote-rack=0&remote-slot=3&controller-type=S7_400")) {
5454
final PlcSubscriptionRequest.Builder subscription = connection.subscriptionRequestBuilder();
5555

56-
subscription.addEventTagAddress("myMODE", "MODE");
56+
// subscription.addEventTagAddress("myMODE", "MODE");
5757
// subscription.addEventTagAddress("mySYS", "SYS");
58-
// subscription.addEventTagAddress("myUSR", "USR");
58+
subscription.addEventTagAddress("myUSR", "USR");
5959
// subscription.addEventTagAddress("myALM", "ALM");
6060

6161
final PlcSubscriptionRequest sub = subscription.build();
6262
final PlcSubscriptionResponse subresponse = sub.execute().get();
6363

6464
//Si todo va bien con la subscripción puedo
65-
subresponse
66-
.getSubscriptionHandle("myMODE")
67-
.register(msg -> {
68-
System.out.println("******** S7ModeEvent ********");
69-
Map<String, Object> map = ((S7ModeEvent) msg).getMap();
70-
map.forEach((x, y) -> {
71-
System.out.println(x + " : " + y);
72-
});
73-
System.out.println("****************************");
74-
});
65+
// subresponse
66+
// .getSubscriptionHandle("myMODE")
67+
// .register(msg -> {
68+
// System.out.println("******** S7ModeEvent ********");
69+
// Map<String, Object> map = ((S7ModeEvent) msg).getMap();
70+
// map.forEach((x, y) -> {
71+
// System.out.println(x + " : " + y);
72+
// });
73+
// System.out.println("****************************");
74+
// });
7575
//
7676
// subresponse
7777
// .getSubscriptionHandle("mySYS")
@@ -112,7 +112,7 @@ public static void main(String[] args) throws Exception {
112112

113113
System.out.println("Waiting for events");
114114

115-
Thread.sleep(5000);
115+
Thread.sleep(30000);
116116

117117
System.out.println("Bye...");
118118

plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/SzlRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public static void main(String[] args) throws Exception {
6161
System.out.println("Chapter 34 System Status Lists (SSL).");
6262
System.out.println("URL: https://cache.industry.siemens.com/dl/files/604/44240604/att_67003/v1/s7sfc_en-EN.pdf");
6363
System.out.println("******************************************************************************************");
64-
64+
Thread.sleep(10000);
6565
try (PlcConnection connection = new DefaultPlcDriverManager().getConnection("s7://10.10.1.33?remote-rack=0&remote-slot=3&controller-type=S7_400")) { //(01)
6666

6767
final PlcReadRequest.Builder readrequest = connection.readRequestBuilder(); //(02)

plc4j/integrations/apache-hop/plc4x-hop-metadata/src/main/java/org/apache/plc4x/hop/metadata/Plc4xConnectionEditor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,18 @@ public Button[] createButtonsForButtonBar(Composite parent) {
120120

121121
Button wbTest = new Button(parent, SWT.PUSH | SWT.CENTER);
122122
props.setLook(wbTest);
123-
wbTest.setText("Test");
124-
wbTest.addListener(SWT.Selection, e -> test());
123+
wbTest.setText("Test connection");
124+
wbTest.addListener(SWT.Selection, e -> test_connection());
125125

126126
return new Button[] {wbTest};
127127
}
128128

129-
public void test() {
129+
public void test_connection() {
130130
PlcConnection plcConnection;
131131
try {
132132
Plc4xConnection meta = getMetadata();
133133
plcConnection = new DefaultPlcDriverManager().getConnection(meta.getUrl());
134-
plcConnection.connect();
134+
135135
Thread.sleep(100);
136136
plcConnection.close();
137137
MessageBox box = new MessageBox(parent.getShell(), SWT.ICON_INFORMATION | SWT.OK);

plc4j/integrations/apache-hop/plc4x-hop-transformer/pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@
6161
<artifactId>maven-dependency-plugin</artifactId>
6262
<configuration>
6363
<ignoredDependencies>
64-
<dependency>io.netty:netty-common:jar:4.1.89.Final</dependency>
65-
<dependency>io.netty:netty-all:jar:4.1.89.Final</dependency>
64+
<dependency>io.netty:netty-common:jar:${netty.version}</dependency>
65+
<dependency>io.netty:netty-all:jar:${netty.version}</dependency>
6666
<dependency>commons-lang:commons-lang:jar:2.6</dependency>
6767
<dependency>xml-apis:xml-apis:jar:1.4.01</dependency>
6868
<dependency>org.apache.plc4x:plc4j-spi:jar:${project.version}</dependency>
69-
<dependency>com.fasterxml.jackson.core:jackson-annotations:jar:2.14.2</dependency>
70-
<dependency>com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.14.2</dependency>
69+
<dependency>com.fasterxml.jackson.core:jackson-annotations:jar:${jackson.version}</dependency>
70+
<dependency>com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:${jackson.version}</dependency>
7171
</ignoredDependencies>
7272
</configuration>
7373
</plugin>
@@ -138,7 +138,7 @@
138138
<dependency>
139139
<groupId>org.apache.commons</groupId>
140140
<artifactId>commons-lang3</artifactId>
141-
<version>3.12.0</version>
141+
<version>${commons-lang3.version}</version>
142142
</dependency>
143143
<dependency>
144144
<groupId>com.fasterxml.jackson.core</groupId>
@@ -153,7 +153,7 @@
153153
<dependency>
154154
<groupId>com.fasterxml.jackson.datatype</groupId>
155155
<artifactId>jackson-datatype-jsr310</artifactId>
156-
<version>2.14.2</version>
156+
<version>${jackson.version}</version>
157157
</dependency>
158158
</dependencies>
159159
</project>

plc4j/integrations/apache-hop/plc4x-hop-transformer/src/main/java/org/apache/plc4x/hop/transforms/plc4xoutput/Plc4xWrite.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,15 +251,16 @@ public boolean processRow() throws HopException {
251251

252252
data.outputRowMeta = getInputRowMeta();
253253

254-
254+
first = true;
255255
if (first) {
256256
index.clear();
257257
plcfields.clear();
258258
meta.getFields().forEach((f) ->{
259259
Integer i = getInputRowMeta().indexOfValue(f.getName()); //(01)
260260
if (i>=0) {
261+
logDebug(">> i: " + i + " : " + f.getName() + " : " + f.getItem());
261262
index.put(f.getName(), i);
262-
plcfields.put(f.getName(),Plc4xPlcTag.of(f.getItem()));
263+
plcfields.put(f.getName(), Plc4xPlcTag.of(f.getItem()));
263264
}
264265
});
265266
first = false;
@@ -310,25 +311,39 @@ public boolean processRow() throws HopException {
310311

311312
if ((connmeta != null) && (connwrapper != null)){
312313
if (connwrapper.getConnection().isConnected()){
313-
314+
logDebug(">>>> Paso por aqui!");
314315
builder = null;
315316
builder = connwrapper.getConnection().writeRequestBuilder(); //(05)
316317
Integer i;
317318
for (Plc4xGeneratorField field: meta.getFields()){
318-
319+
logDebug(">>>> Paso por aqui! 22");
319320
i = index.get(field.getName());
320321
if (i != null) {
321322
//From Input Type
323+
logDebug(">>>> Paso por aqui! 33: " + inputRowMeta.getValueMeta(i).getTypeDesc() + " : " + field.getType());
322324
if (inputRowMeta.getValueMeta(i).getTypeDesc().
323325
equalsIgnoreCase(field.getType()))
324326
switch(inputRowMeta.getValueMeta(i).getType()) {
325327
case IValueMeta.TYPE_BOOLEAN:
326328
case IValueMeta.TYPE_INTEGER:
327329
case IValueMeta.TYPE_NUMBER:
328330
case IValueMeta.TYPE_BIGNUMBER:
331+
Object value= null;
332+
switch(plcfields.get(field.getName()).getDataType()) {
333+
case BOOL:
334+
case BYTE:
335+
case WORD:
336+
value = Short.parseShort(r[i].toString());
337+
break;
338+
case REAL:
339+
value = Float.parseFloat(r[i].toString());
340+
break;
341+
}
342+
343+
logDebug(">>>> " + field.getName() + " : " + field.getItem() + " : " + r[i] + " : " + plcfields.get(field.getName()).getDataType().name());
329344
builder.addTagAddress(field.getName(),
330345
field.getItem(),
331-
r[i]);
346+
value);
332347
break;
333348
case IValueMeta.TYPE_DATE:
334349
builder.addTagAddress(field.getName(),
@@ -401,6 +416,7 @@ public boolean processRow() throws HopException {
401416

402417
@Override
403418
public boolean init() {
419+
404420
try {
405421
if(super.init()){
406422
// Determine the number of rows to generate...
@@ -435,6 +451,7 @@ public boolean init() {
435451
logError("Error initializing transform", ex);
436452
return false;
437453
}
454+
438455
}
439456

440457
/*

plc4j/integrations/apache-hop/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
<properties>
3535
<!-- Set this to the Hop version you want to debug against-->
36-
<hop.version>2.3.0</hop.version>
36+
<hop.version>2.4.0</hop.version>
3737
<!-- Path You will be using to debug the application -->
3838
<hop.debug.path>/home/hans/Documents/test</hop.debug.path>
3939
<!-- Third-party dependencies-->

src/site/asciidoc/users/integrations/apache-hop.adoc

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
:imagesdir: ../../images/
1818
:icons: font
1919

20-
image::integrations/plc4x_hop_banner.jpg[]
20+
21+
22+
image::plc4x_hop_banner.jpg[banner,512,167]
2123

2224
== Apache Hop
2325

@@ -26,16 +28,15 @@ image::integrations/plc4x_hop_banner.jpg[]
2628
"__Hop aims to be the future of data integration. Visual development enables developers to be more productive than they can be through code. Our Design once, run anywhere workflows and pipelines can be designed in the Hop Gui and run on the Hop native engine (local or remote), or on Spark, Flink, Google Dataflow or AWS EMR through Beam. Lifecycle Management enables developers and administrators to switch between projects, environments and purposes without leaving your train of thought__."
2729

2830

31+
.Version control
32+
=== Record of revisions
2933

34+
[cols="1, 2,2a,5a"]
35+
|===
36+
|Rev |Release |Date |Description of the change
3037

38+
|0 |0.10.0 |2022/10/04 |Stable release.
3139

32-
33-
.Version control
34-
[width="100%",options="header,footer"]
35-
|====================
36-
| Date | Plc4x | Comments
37-
| 10/03/2023 |0.11.0-SNAPSHOT | xxx
38-
| | |
39-
|====================
40+
|===
4041

4142

0 commit comments

Comments
 (0)