Hi Guido, The subscription feature for Siemens plcs is currently in the oven, I can safely support you in that regard.
If you have a hybrid architecture, with S7-300 and S7-1500 (1200) devices, it is important to point out that the new S7-1500 series only supports a subset of the features of the S7-300, so it does not include the possibility of reeralize S7 subscriptions. In summary, the S7-1200 & S7-1500 only support PUT / GET. Currently the variable and alarm subscription is functional for the S7-300, S7-400. For the VIPA and Sinamics G120PN equipment (and other drivers) I hope to have the equipment soon. In [1] you can find an example code for the subscription process. (It's testing code!) In [2] you will find the development branch which I hope to request the PR shortly. But eventually you can test the subscription and other new features. I am dedicating to finalize the alarm processor and carry out tests to continue with the documentation, so any feedback from you is welcome. Best regards, 1. https://github.com/glcj/PLC4XS7ExamplesV9/blob/master/src/main/java/com/ceos/plc4x/s7/PLCAlarmAck.java 2. https://github.com/glcj/plc4x/tree/s7szl El jue, 4 nov 2021 a las 6:06, Rennert, Guido (<guido.renn...@koehl-mb.eu>) escribió: > Hello, > > > > as a complete newbie in Java, S7 and PLC4X it does not help - if I have to > get some data from a Siemens-PLC. We decided to use PLC4X and as always > there can occur some little problems. Now I am involved in using PLC4X for > about one week. > > > > Ok let me first say what I use at the moment: > > - Java 11 64-Bit-Version on Intel (Windows 10) and Arm-System (Debian) > - PLC4X version 0.9.0 (but I tested in this case 0.10.0-SNAPSHOT, too) > - Siemens S7-300, S7-1500 (Software-PLC) and hopefully some more types > in the next weeks > > > > As preparation for more functionality I created an ugly short test > program, which does some reading out of a data block. This is really > running fine an I was surprised to get to this point in really a short > time. So I think that the PLC4X is a well kind of stuff. > > > > To improve at second the reading of data out of the PLC I tried to use the > possibility of ‘subscription’ – unfortunately this has been without success > the last 2 days. So I decided to ask what I am doing wrong. > > > > As an attachment there are some more information to be found as pictures > and some text parts. > > > > Explanation: > > > > I try to establish a subscription request by doing the builder and execute > the request afterwards (attachment Source_SubscriptionRequest.txt): > > > > > *// Create a new subscription request cyclic mode only ! > *PlcSubscriptionRequest.Builder > builder = plcConnection.subscriptionRequestBuilder(); > > *for *(String searchName : deviceData.*dataMap*.keySet()) { > *switch *(deviceData.getSubscriptionType(searchName)) { > *case **"CYCLIC"*: { > builder.addCyclicField(searchName, > deviceData.getDataPlaceAndType(searchName), Duration.*ofMillis*(Integer. > *valueOf*(deviceData.getSubscriptionTime(searchName)))); > };*break*; > *case **"ONCHANGE"*: { > *// TODO add onchange subscription builder* > };*break*; > *case **"ONEVENT"*: { > *// TODO add onevent subscription builder* > };*break*; > *default*: { > > };*break*; > } > } > > *// finalize the subscription builder *PlcSubscriptionRequest > subscriptionRequest = builder.build(); > > > *// activate the subscriptions now (here it doesn't matter if you use the > synchronize or asynchronize approach) *PlcSubscriptionResponse > plcSubscriptionResponse = subscriptionRequest.execute().get(20, TimeUnit. > *SECONDS*); > > *// PlcSubscriptionResponse plcSubscriptionResponse = > subscriptionRequest.execute().get(); // PlcSubscriptionResponse > plcSubscriptionResponse = subscriptionRequest.execute().get(5000, > TimeUnit.MILLISECONDS);* > > > > The ‘deviceData’-class contains all configuration values which are read > out of a very simple properties-file. The picture ‘Debug_BuilderInfo.PNG’ > shows the content of the two entries and I think they are OK so far. > > The property-file contains these information about the entries: > > > > # data address is the physical address inside the plc and the type > data_set_001=TEST_BIT0|%DB100:0.0:BOOL|BOOL|CYCLIC|333 > data_set_002=TEST_BIT1|%DB100:0.1:BOOL|BOOL|CYCLIC|444 > > > > The fieldname in the first line will be later ‘TEST_BIT0’ the address and > type will be ‘%DB100:0.0:BOOL’ it should be a cyclic mode ‘CYCLIC’ and the > cycle time should be ‘333’ [ms]. The other values in the line are not used > inside the program (maybe later but not now). > > > > > > Unfortunately this will lead me to an error I can’t resolve now. (the out > is the attachment Console_OutputOnError.txt) > > > > "C:\Program > Files\Java\openjdk-11.0.8.10-2.windows.redhat.x86_64\bin\java.exe" > -agentlib:jdwp=transport=dt_socket,address=127.0.0.1:50521,suspend=y,server=n > -Dplc_name=KoehlInhouseTestSPS > -javaagent:D:\Programme\IntelliJ_IDEA_2019.3.4\plugins\java\lib\rt\debugger-agent.jar > -Dfile.encoding=UTF-8 -classpath > D:\projekte\entwicklung\test-plc-subscription\target\classes;D:\projekte\entwicklung\.m2\spring_repository\org\apache\plc4x\plc4j-api\0.9.0\plc4j-api-0.9.0.jar;D:\projekte\entwicklung\.m2\spring_repository\com\fasterxml\jackson\core\jackson-annotations\2.12.5\jackson-annotations-2.12.5.jar;D:\projekte\entwicklung\.m2\spring_repository\org\apache\plc4x\plc4j-driver-s7\0.9.0\plc4j-driver-s7-0.9.0.jar;D:\projekte\entwicklung\.m2\spring_repository\org\apache\plc4x\plc4j-spi\0.9.0\plc4j-spi-0.9.0.jar;D:\projekte\entwicklung\.m2\spring_repository\io\netty\netty-codec\4.1.67.Final\netty-codec-4.1.67.Final.jar;D:\projekte\entwicklung\.m2\spring_repository\io\netty\netty-common\4.1.67.Final\netty-common-4.1.67.Final.jar;D:\projekte\entwicklung\.m2\spring_repository\commons-beanutils\commons-beanutils\1.9.4\commons-beanutils-1.9.4.jar;D:\projekte\entwicklung\.m2\spring_repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;D:\projekte\entwicklung\.m2\spring_repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;D:\projekte\entwicklung\.m2\spring_repository\com\fasterxml\jackson\core\jackson-core\2.12.5\jackson-core-2.12.5.jar;D:\projekte\entwicklung\.m2\spring_repository\com\fasterxml\jackson\core\jackson-databind\2.12.5\jackson-databind-2.12.5.jar;D:\projekte\entwicklung\.m2\spring_repository\com\github\jinahya\bit-io\1.4.3\bit-io-1.4.3.jar;D:\projekte\entwicklung\.m2\spring_repository\org\apache\plc4x\plc4j-transport-tcp\0.9.0\plc4j-transport-tcp-0.9.0.jar;D:\projekte\entwicklung\.m2\spring_repository\commons-codec\commons-codec\1.15\commons-codec-1.15.jar;D:\projekte\entwicklung\.m2\spring_repository\io\netty\netty-buffer\4.1.67.Final\netty-buffer-4.1.67.Final.jar;D:\projekte\entwicklung\.m2\spring_repository\io\netty\netty-transport\4.1.67.Final\netty-transport-4.1.67.Final.jar;D:\projekte\entwicklung\.m2\spring_repository\io\netty\netty-resolver\4.1.67.Final\netty-resolver-4.1.67.Final.jar;D:\projekte\entwicklung\.m2\spring_repository\io\vavr\vavr\0.10.4\vavr-0.10.4.jar;D:\projekte\entwicklung\.m2\spring_repository\io\vavr\vavr-match\0.10.4\vavr-match-0.10.4.jar;D:\projekte\entwicklung\.m2\spring_repository\org\slf4j\slf4j-api\2.0.0-alpha1\slf4j-api-2.0.0-alpha1.jar;D:\projekte\entwicklung\.m2\spring_repository\org\apache\commons\commons-lang3\3.12.0\commons-lang3-3.12.0.jar;D:\Programme\IntelliJ_IDEA_2019.3.4\lib\idea_rt.jar > de.koehl.plc_adapter.TestPlcAdapter > d:\projekte\entwicklung\test-plc-subscription\plc_data_s300.txt > > Connected to the target VM, address: '127.0.0.1:50521', transport: > 'socket' > > > > Using parameter value for path to ini files: > d:\projekte\entwicklung\test-plc-subscription\plc_data_s300.txt > > PLC : KoehlInhouseTestSPS > > SLF4J: No SLF4J providers were found. > > SLF4J: Defaulting to no-operation (NOP) logger implementation > > SLF4J: See http://www.slf4j.org/codes.html#noProviders for further > details. > > > > Connection established to: s7:// > 172.16.10.10?controller-type=S7_300&remote-rack=0&remote-slot=2 > > PLC with connection: s7:// > 172.16.10.10?controller-type=S7_300&remote-rack=0&remote-slot=2 is able > to be read ! > > PLC with connection: s7:// > 172.16.10.10?controller-type=S7_300&remote-rack=0&remote-slot=2 is able > to be written ! > > PLC with connection: s7:// > 172.16.10.10?controller-type=S7_300&remote-rack=0&remote-slot=2 is able > to do subscriptions ! > > PLC with connection: s7:// > 172.16.10.10?controller-type=S7_300&remote-rack=0&remote-slot=2 is not > able to do browsing ! > > Value could not be read! > > java.lang.ClassCastException: class > org.apache.plc4x.java.s7.readwrite.field.S7Field cannot be cast to class > org.apache.plc4x.java.s7.readwrite.field.S7SubscriptionField > (org.apache.plc4x.java.s7.readwrite.field.S7Field and > org.apache.plc4x.java.s7.readwrite.field.S7SubscriptionField are in unnamed > module of loader 'app') > > Number of threads starting was: 1 > > Number of threads on ending was: 4 > > java.lang.ClassCastException: class > org.apache.plc4x.java.s7.readwrite.field.S7Field cannot be cast to class > org.apache.plc4x.java.s7.readwrite.field.S7SubscriptionField > (org.apache.plc4x.java.s7.readwrite.field.S7Field and > org.apache.plc4x.java.s7.readwrite.field.S7SubscriptionField are in unnamed > module of loader 'app') > > at > org.apache.plc4x.java.s7.readwrite.protocol.S7ProtocolLogic.subscribe(S7ProtocolLogic.java:335) > > at > org.apache.plc4x.java.spi.optimizer.BaseOptimizer.lambda$optimizedSubscribe$4(BaseOptimizer.java:121) > > at > org.apache.plc4x.java.spi.optimizer.BaseOptimizer.send(BaseOptimizer.java:139) > > at > org.apache.plc4x.java.spi.optimizer.BaseOptimizer.optimizedSubscribe(BaseOptimizer.java:121) > > at > org.apache.plc4x.java.spi.connection.AbstractPlcConnection.subscribe(AbstractPlcConnection.java:167) > > at > org.apache.plc4x.java.spi.messages.DefaultPlcSubscriptionRequest.execute(DefaultPlcSubscriptionRequest.java:61) > > at > de.koehl.plc_adapter.TestPlcAdapter.readTestPlc(TestPlcAdapter.java:129) > > at de.koehl.plc_adapter.TestPlcAdapter.main(TestPlcAdapter.java:57) > > Disconnected from the target VM, address: '127.0.0.1:50521', transport: > 'socket' > > > > Process finished with exit code 0 > > > > As a further step to get more information I did some debugging at the line > where the exception crashes my code. > > Just look at the attached pictures, where you can see the content of the > subscription request. > > > > I switched to the PLC4X version 0.10.0-SNAPSHOT but this creates exactly > the same situation – no difference to version 0.9.0 > > > > Does anybody proposals how to solve this ? Or maybe - I do something wrong > but I don’t recognize what. > > > > Mit freundlichen Grüßen / Best regards > > > Dipl.-Ing. (FH) > *Guido Rennert* > Software Engineering > Logistic & Information Systems > > Phone: > > +352 27 68 27 - 3650 > > E-Mail: > > guido.renn...@koehl-mb.eu > > > > GEHEIMHALTUNGSPFLICHT: Diese E-Mail und alle damit verbundenen Anlagen > sind vertraulich und dürfen nur bestimmten Personen zugänglich gemacht > werden. Sofern Sie nicht zu den angegebenen Empfängern gehören, > benachrichtigen Sie bitte unverzüglich den Absender. Der Inhalt darf weder > an Dritte weitergegeben noch zu anderen Zwecken verwendet werden. Die > Informationen dürfen auch nicht auf einem Datenträger gespeichert oder auf > einen Datenträger kopiert werden. Unsere Datenschutzerklärung hier > <https://www.koehl-mb.eu/datenschutz/>. > > CONFIDENTIALITY: This e-mail and any attachments are confidential and may > be privileged. If you are not a named recipient, please notify the sender > immediately and delete the e-mail from your system. You are not authorized > to disclose the contents to another person, to use it for any purpose or > store or copy the information in any medium. Our privacy policy here > <https://www.koehl-mb.eu/en/data-protection/>. > > > -- *CEOS Automatización, C.A.* *GALPON SERVICIO INDUSTRIALES Y NAVALES FA, C.A.,* *PISO 1, OFICINA 2, AV. RAUL LEONI, SECTOR GUAMACHITO,* *FRENTE A LA ASOCIACION DE GANADEROS,BARCELONA,EDO. ANZOATEGUI* *Ing. César García* *Cel: +58 414-760.98.95* *Hotline Técnica SIEMENS: 0800 1005080* *Email: support.aan.automat...@siemens.com <support.aan.automat...@siemens.com>*