This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x-extras.git


The following commit(s) were added to refs/heads/develop by this push:
     new f649d13  fix: Fixed some compile errors which were a direct result 
from my changes to the connection state api changes.
f649d13 is described below

commit f649d13242e4d17e017065dc34d9bb93b40c0656
Author: Christofer Dutz <[email protected]>
AuthorDate: Mon Jan 26 15:34:23 2026 +0100

    fix: Fixed some compile errors which were a direct result from my changes 
to the connection state api changes.
---
 .../plc4j/s7event/PlcCycSubscriptionS7400H.java    | 49 ++++++++++---------
 .../examples/plc4j/s7event/PlcReadDataS7400H.java  | 51 ++++++++++----------
 .../examples/plc4j/s7event/PlcReadS71200.java      | 51 ++++++++++----------
 .../plc4j/s7event/PlcReadWriteStrings.java         | 55 +++++++++++-----------
 4 files changed, 108 insertions(+), 98 deletions(-)

diff --git 
a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcCycSubscriptionS7400H.java
 
b/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcCycSubscriptionS7400H.java
index 6b2b946..692e952 100644
--- 
a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcCycSubscriptionS7400H.java
+++ 
b/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcCycSubscriptionS7400H.java
@@ -24,6 +24,7 @@ import org.apache.plc4x.java.DefaultPlcDriverManager;
 import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest;
 import org.apache.plc4x.java.api.messages.PlcUnsubscriptionRequest;
 import org.apache.plc4x.java.api.messages.PlcSubscriptionResponse;
+import org.apache.plc4x.java.api.model.PlcConnectionStateChangedEvent;
 import org.apache.plc4x.java.s7.events.S7CyclicEvent;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -209,32 +210,34 @@ public class PlcCycSubscriptionS7400H implements 
ConnectionStateListener {
         ShutDown.set(true);        
     }    
    
-    
/***************************************************************************
-    * This method is called when the driver makes an internal TCP connection.
-    * The first connection of the driver does not generate this event.
-    * In the case of high availability systems, this signal should be used 
-    * to restart subscriptions to events, alarms, etc. 
-    
***************************************************************************/    
     @Override
-    public void connected() {
-        logger.info("*****************************************************");  
       
-        logger.info("*************** Plc is connected. *******************");  
    
-        logger.info("*****************************************************"); 
-        isConnected.set(true);        
+    public void onConnectionStateChanged(PlcConnectionStateChangedEvent event) 
{
+        switch (event.getChangeType()) {
+            /*
+             * This block is called when the driver makes an internal TCP 
connection.
+             * The first connection of the driver does not generate this event.
+             * In the case of high availability systems, this signal should be 
used
+             * to restart subscriptions to events, alarms, etc.
+             */
+            case CONNECTED -> {
+                
logger.info("*****************************************************");
+                logger.info("*************** Plc is connected. 
*******************");
+                
logger.info("*****************************************************");
+                isConnected.set(true);
+            }
+            /*
+             * This block is called when there is a physical disconnection of 
the driver
+             * Check the monitoring parameters given in the URL during 
connection.
+             */
+            case DISCONNECTED -> {
+                
logger.info("*****************************************************");
+                logger.info("*************** Plc is disconnected. 
****************");
+                
logger.info("*****************************************************");
+                isConnected.set(false);
+            }
+        }
     }
 
-    
/***************************************************************************
-    * This method is called when there is a physical disconnection of the 
driver
-    * Check the monitoring parameters given in the URL during connection.
-    
***************************************************************************/    
-    @Override
-    public void disconnected() {
-        logger.info("*****************************************************");  
       
-        logger.info("*************** Plc is disconnected. ****************");  
       
-        logger.info("*****************************************************");  
       
-        isConnected.set(false);
-    }        
-    
     
/***************************************************************************
     * This object encapsulates the three steps required for cyclic 
subscription.
     * Try to handle all possible exceptions that are generated.
diff --git 
a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadDataS7400H.java
 
b/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadDataS7400H.java
index 518868b..4abd2e3 100644
--- 
a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadDataS7400H.java
+++ 
b/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadDataS7400H.java
@@ -30,6 +30,7 @@ import org.apache.plc4x.java.api.messages.PlcReadRequest;
 import org.apache.plc4x.java.api.messages.PlcReadResponse;
 import org.apache.plc4x.java.api.messages.PlcWriteRequest;
 import org.apache.plc4x.java.api.messages.PlcWriteResponse;
+import org.apache.plc4x.java.api.model.PlcConnectionStateChangedEvent;
 import org.apache.plc4x.java.api.types.PlcResponseCode;
 import org.apache.plc4x.java.s7.readwrite.protocol.S7HPlcConnection;
 import org.slf4j.Logger;
@@ -267,32 +268,34 @@ public class PlcReadDataS7400H implements 
ConnectionStateListener {
         } catch (Exception ex) { //(07)
             logger.info("Write: " + ex.getMessage());
         };          
-    }        
-    
/***************************************************************************
-    * This method is called when the driver makes an internal TCP connection.
-    * The first connection of the driver does not generate this event.
-    * In the case of high availability systems, this signal should be used 
-    * to restart subscriptions to events, alarms, etc. 
-    
***************************************************************************/    
-    @Override
-    public void connected() {
-        logger.info("*****************************************************");  
       
-        logger.info("*************** Plc is connected. *******************");  
    
-        logger.info("*****************************************************"); 
-        isConnected.set(true);        
     }
 
-    
/***************************************************************************
-    * This method is called when there is a physical disconnection of the 
driver
-    * Check the monitoring parameters given in the URL during connection.
-    
***************************************************************************/    
     @Override
-    public void disconnected() {
-        logger.info("*****************************************************");  
       
-        logger.info("*************** Plc is disconnected. ****************");  
       
-        logger.info("*****************************************************");  
       
-        isConnected.set(false);
-    }    
-    
+    public void onConnectionStateChanged(PlcConnectionStateChangedEvent event) 
{
+        switch (event.getChangeType()) {
+            /*
+             * This block is called when the driver makes an internal TCP 
connection.
+             * The first connection of the driver does not generate this event.
+             * In the case of high availability systems, this signal should be 
used
+             * to restart subscriptions to events, alarms, etc.
+             */
+            case CONNECTED -> {
+                
logger.info("*****************************************************");
+                logger.info("*************** Plc is connected. 
*******************");
+                
logger.info("*****************************************************");
+                isConnected.set(true);
+            }
+            /*
+             * This block is called when there is a physical disconnection of 
the driver
+             * Check the monitoring parameters given in the URL during 
connection.
+             */
+            case DISCONNECTED -> {
+                
logger.info("*****************************************************");
+                logger.info("*************** Plc is disconnected. 
****************");
+                
logger.info("*****************************************************");
+                isConnected.set(false);
+            }
+        }
+    }
     
 }
diff --git 
a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadS71200.java
 
b/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadS71200.java
index 93ffb02..d139e5e 100644
--- 
a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadS71200.java
+++ 
b/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadS71200.java
@@ -28,6 +28,7 @@ import 
org.apache.plc4x.java.api.exceptions.PlcConnectionException;
 import org.apache.plc4x.java.api.listener.ConnectionStateListener;
 import org.apache.plc4x.java.api.messages.PlcReadRequest;
 import org.apache.plc4x.java.api.messages.PlcReadResponse;
+import org.apache.plc4x.java.api.model.PlcConnectionStateChangedEvent;
 import org.apache.plc4x.java.api.types.PlcResponseCode;
 import org.apache.plc4x.java.s7.readwrite.protocol.S7HPlcConnection;
 import org.slf4j.Logger;
@@ -232,32 +233,34 @@ public class PlcReadS71200 implements 
ConnectionStateListener {
             logger.info("Read: " + ex.getMessage());
         };
           
-    }    
-
-    
/***************************************************************************
-    * This method is called when the driver makes an internal TCP connection.
-    * The first connection of the driver does not generate this event.
-    * In the case of high availability systems, this signal should be used 
-    * to restart subscriptions to events, alarms, etc. 
-    
***************************************************************************/    
-    @Override
-    public void connected() {
-        logger.info("*****************************************************");  
       
-        logger.info("*************** Plc is connected. *******************");  
    
-        logger.info("*****************************************************"); 
-        isConnected.set(true);        
     }
 
-    
/***************************************************************************
-    * This method is called when there is a physical disconnection of the 
driver
-    * Check the monitoring parameters given in the URL during connection.
-    
***************************************************************************/    
     @Override
-    public void disconnected() {
-        logger.info("*****************************************************");  
       
-        logger.info("*************** Plc is disconnected. ****************");  
       
-        logger.info("*****************************************************");  
       
-        isConnected.set(false);
+    public void onConnectionStateChanged(PlcConnectionStateChangedEvent event) 
{
+        switch (event.getChangeType()) {
+            /*
+             * This block is called when the driver makes an internal TCP 
connection.
+             * The first connection of the driver does not generate this event.
+             * In the case of high availability systems, this signal should be 
used
+             * to restart subscriptions to events, alarms, etc.
+             */
+            case CONNECTED -> {
+                
logger.info("*****************************************************");
+                logger.info("*************** Plc is connected. 
*******************");
+                
logger.info("*****************************************************");
+                isConnected.set(true);
+            }
+            /*
+             * This block is called when there is a physical disconnection of 
the driver
+             * Check the monitoring parameters given in the URL during 
connection.
+             */
+            case DISCONNECTED -> {
+                
logger.info("*****************************************************");
+                logger.info("*************** Plc is disconnected. 
****************");
+                
logger.info("*****************************************************");
+                isConnected.set(false);
+            }
+        }
     }
-    
+
 }
diff --git 
a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadWriteStrings.java
 
b/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadWriteStrings.java
index ff586c7..e175a72 100644
--- 
a/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadWriteStrings.java
+++ 
b/plc4j/examples/plc4j-s7event/src/main/java/org/apache/plc4x/examples/plc4j/s7event/PlcReadWriteStrings.java
@@ -29,6 +29,7 @@ import org.apache.plc4x.java.api.messages.PlcReadRequest;
 import org.apache.plc4x.java.api.messages.PlcReadResponse;
 import org.apache.plc4x.java.api.messages.PlcWriteRequest;
 import org.apache.plc4x.java.api.messages.PlcWriteResponse;
+import org.apache.plc4x.java.api.model.PlcConnectionStateChangedEvent;
 import org.apache.plc4x.java.api.types.PlcResponseCode;
 import org.apache.plc4x.java.s7.readwrite.protocol.S7HPlcConnection;
 import org.slf4j.Logger;
@@ -399,34 +400,34 @@ public class PlcReadWriteStrings implements 
ConnectionStateListener {
         } catch (Exception ex) { //(07)
             logger.info("Read: " + ex.getMessage());
         };          
-    }        
-    
-    
/***************************************************************************
-    * This method is called when the driver makes an internal TCP connection.
-    * The first connection of the driver does not generate this event.
-    * In the case of high availability systems, this signal should be used 
-    * to restart subscriptions to events, alarms, etc. 
-    
***************************************************************************/    
-    @Override
-    public void connected() {
-        logger.info("*****************************************************");  
       
-        logger.info("*************** Plc is connected. *******************");  
    
-        logger.info("*****************************************************"); 
-        isConnected.set(true);        
     }
 
-    
/***************************************************************************
-    * This method is called when there is a physical disconnection of the 
driver
-    * Check the monitoring parameters given in the URL during connection.
-    
***************************************************************************/    
     @Override
-    public void disconnected() {
-        logger.info("*****************************************************");  
       
-        logger.info("*************** Plc is disconnected. ****************");  
       
-        logger.info("*****************************************************");  
       
-        isConnected.set(false);
-    }    
-    
-    
-    
+    public void onConnectionStateChanged(PlcConnectionStateChangedEvent event) 
{
+        switch (event.getChangeType()) {
+            /*
+             * This block is called when the driver makes an internal TCP 
connection.
+             * The first connection of the driver does not generate this event.
+             * In the case of high availability systems, this signal should be 
used
+             * to restart subscriptions to events, alarms, etc.
+             */
+            case CONNECTED -> {
+                
logger.info("*****************************************************");
+                logger.info("*************** Plc is connected. 
*******************");
+                
logger.info("*****************************************************");
+                isConnected.set(true);
+            }
+            /*
+             * This block is called when there is a physical disconnection of 
the driver
+             * Check the monitoring parameters given in the URL during 
connection.
+             */
+            case DISCONNECTED -> {
+                
logger.info("*****************************************************");
+                logger.info("*************** Plc is disconnected. 
****************");
+                
logger.info("*****************************************************");
+                isConnected.set(false);
+            }
+        }
+    }
+
 }

Reply via email to