You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cg...@apache.org on 2024/08/23 13:25:44 UTC

(plc4x-extras) branch feature/merlot updated: Cleaning up dumb code.

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

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


The following commit(s) were added to refs/heads/feature/merlot by this push:
     new 30b5acf  Cleaning up dumb code.
30b5acf is described below

commit 30b5acfb63baf4a37dee6ab6f9153b558776a437
Author: César García <ce...@ceos.com.ve>
AuthorDate: Fri Aug 23 09:24:58 2024 -0400

    Cleaning up dumb code.
---
 .../merlot/org.apache.plc4x.merlot.das.api/pom.xml | 18 +++---
 .../org/apache/plc4x/merlot/api/PlcDevice.java     |  8 ++-
 .../java/org/apache/plc4x/merlot/api/PlcGroup.java |  7 +++
 .../java/org/apache/plc4x/merlot/api/PlcItem.java  |  4 +-
 .../org/apache/plc4x/merlot/api/PlcItemClient.java |  3 +-
 .../plc4x/merlot/api/command/DemoCommand001.java   |  2 +-
 .../plc4x/merlot/api/command/DemoCommand002.java   |  2 +-
 .../api/command/PlcDeviceControlCommand.java       | 21 +++----
 .../merlot/api/command/PlcDeviceDelCommand.java}   | 10 ++--
 .../api/command/PlcDeviceGroupListCommand.java}    |  4 +-
 .../api/command/PlcDeviceGroupNewCommand.java}     | 31 ++++++++---
 .../command/PlcDeviceGroupScheduleCommand.java}    |  4 +-
 .../plc4x/merlot/api/impl/PlcDeviceImpl.java       |  8 ++-
 .../apache/plc4x/merlot/api/impl/PlcGroupImpl.java | 22 +++++++-
 .../apache/plc4x/merlot/api/impl/PlcItemImpl.java  |  8 +--
 .../merlot/das/base/command/DeviceNewCommand.java  |  2 +-
 .../merlot/das/base/command/cmdDeviceDel.java      |  2 +-
 .../merlot/das/base/command/cmdDeviceGroupDel.java |  2 +-
 .../das/base/command/cmdDeviceGroupList.java       |  2 +-
 .../merlot/das/base/command/cmdDeviceGroupNew.java |  2 +-
 .../das/base/command/cmdDeviceGroupSchedule.java   |  2 +-
 .../plc4x/merlot/das/base/impl/BaseDeviceImpl.java |  6 ++
 .../plc4x/merlot/das/base/impl/BaseGroupImpl.java  | 13 +++++
 .../plc4x/merlot/das/base/impl/BaseItemImpl.java   | 14 ++---
 .../resources/OSGI-INF/blueprint/das-service.xml   |  2 +-
 .../merlot/org.apache.plc4x.merlot.db/pom.xml      |  6 +-
 .../plc4x/merlot/db/command/DBAddCommand.java      |  2 +-
 .../plc4x/merlot/db/core/DBBooleanFactory.java     | 36 +++++++++++-
 .../plc4x/merlot/db/core/DBFloatFactory.java       | 38 ++++++++++++-
 .../merlot/db/core/DBRecordsManagedService.java    | 64 +++++++++++++++++-----
 .../plc4x/merlot/db/core/DBUShortFactory.java      | 37 ++++++++++++-
 .../resources/OSGI-INF/blueprint/db-service.xml    | 21 ++++---
 plc4j/tools/merlot/pom.xml                         |  2 +-
 33 files changed, 307 insertions(+), 98 deletions(-)

diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/pom.xml b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/pom.xml
index e7b971e..c90ed05 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/pom.xml
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/pom.xml
@@ -55,7 +55,7 @@
                     <protocArtifact>com.google.protobuf:protoc:3.25.1:exe:${os.detected.classifier}</protocArtifact>
                     <pluginId>grpc-java</pluginId>
                     <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.62.2:exe:${os.detected.classifier}</pluginArtifact>
-                    <protoSourceRoot>src/main/resources/proto</protoSourceRoot>
+                    <protoSourceRoot>src/main/resources/proto</protoSourceRoot>                  
                 </configuration>
                 <executions>
                     <execution>
@@ -70,18 +70,20 @@
             <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
-                <version>5.1.8</version>
+                <version>5.1.9</version>
                 <extensions>true</extensions>
                 <configuration>
                     <instructions>
                         <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                         <Bundle-Version>0.13.0-SNAPSHOT</Bundle-Version>
-                        <Export-Package>org.apache.plc4x.merlot.api*;version=0.13.0-SNAPSHOT</Export-Package>
-                        <Import-Package>*</Import-Package>
-                        <Karaf-Commands>org.apache.plc4x.merlot.api.command*</Karaf-Commands>                            
+                        <Export-Package>org.apache.plc4x.merlot.api*;version=0.13.0-SNAPSHOT;-noimport:=true</Export-Package>                    
+                        <Import-Package>*</Import-Package>  
+                        <Karaf-Commands>org.apache.plc4x.merlot.api.command*</Karaf-Commands>
+                        <_removeheaders>Import-Service,Export-Service</_removeheaders>                          
                     </instructions>
                 </configuration>
             </plugin>
+            
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
@@ -91,8 +93,10 @@
                     <maxmem>256M</maxmem>
                 </configuration>
             </plugin>
+                                
         </plugins>
     </build>
+         
     <dependencies>
         <dependency>
             <groupId>io.netty</groupId>
@@ -129,11 +133,11 @@
             <artifactId>osgi.core</artifactId>
             <version>${osgi.core.version}</version>
         </dependency>
-        <dependency>
+<!--        <dependency> 
             <groupId>org.apache.karaf</groupId>
             <artifactId>org.apache.karaf.util</artifactId>
             <version>${karaf.version}</version>
-        </dependency>
+        </dependency>-->
         <dependency>
             <groupId>org.apache.karaf.shell</groupId>
             <artifactId>org.apache.karaf.shell.core</artifactId>
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcDevice.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcDevice.java
index 76c2eae..a5b1b4a 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcDevice.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcDevice.java
@@ -23,6 +23,7 @@ import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+import org.apache.plc4x.java.api.PlcConnection;
 import org.apache.plc4x.java.api.PlcDriver;
 import org.apache.plc4x.java.api.model.PlcTag;
 import org.apache.plc4x.java.api.types.PlcValueType;
@@ -133,7 +134,12 @@ public interface PlcDevice extends org.osgi.service.device.Device, org.osgi.serv
     /*
     * 
     */
-    public String getWritePlcTag(PlcTag plcTag, ByteBuf byteBuf, String... args);    
+    public String getWritePlcTag(PlcTag plcTag, ByteBuf byteBuf, String... args);  
+    
+    /*
+    *    
+    */
+    public PlcConnection getPlcConnection();
     
         	
 }
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcGroup.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcGroup.java
index 9c54b59..9ea93ac 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcGroup.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcGroup.java
@@ -18,12 +18,15 @@
  */
 package org.apache.plc4x.merlot.api;
 
+import com.lmax.disruptor.RingBuffer;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.atomic.AtomicReference;
 import org.apache.plc4x.java.api.PlcConnection;
+import org.apache.plc4x.merlot.api.impl.PlcDeviceReadEvent;
+import org.apache.plc4x.merlot.api.impl.PlcDeviceWriteEvent;
 
 
 public interface PlcGroup {
@@ -156,5 +159,9 @@ public interface PlcGroup {
     *
     */
     public List<PlcItem> getItems();
+    
+    public void setReadRingBuffer(RingBuffer<PlcDeviceReadEvent> readRingBuffer);  
+    
+    public void setWriteRingBuffer(RingBuffer<PlcDeviceWriteEvent> writeRingBuffer);     
      
 }
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcItem.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcItem.java
index cf9ffa6..e14f33f 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcItem.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcItem.java
@@ -186,12 +186,12 @@ public interface PlcItem {
     /*
     *
     */    
-    public void addItemClient(PlcItemListener client);
+    public void addItemListener(PlcItemListener client);
     
     /*
     *
     */    
-    public void removeItemClient(PlcItemListener client);    
+    public void removeItemListener(PlcItemListener client);    
     
     /*
     *
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcItemClient.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcItemClient.java
index c23af85..530b18e 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcItemClient.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcItemClient.java
@@ -16,12 +16,11 @@
  */
 package org.apache.plc4x.merlot.api;
 
-import org.apache.plc4x.java.api.messages.PlcReadResponse;
 import org.apache.plc4x.java.api.value.PlcValue;
 
 
 public interface PlcItemClient {
     
-    public void execute(PlcValue  plcvalue);
+    public void execute(PlcValue plcvalue);
     
 }
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand001.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand001.java
index 49ab446..c34b5dc 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand001.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand001.java
@@ -28,8 +28,8 @@ import org.apache.plc4x.merlot.api.PlcGroup;
 import org.apache.plc4x.merlot.api.impl.PlcGroupImpl;
 
 
-@Command(scope = "plc4x", name = "demo_001", description = "Command for test.")
 @Service
+@Command(scope = "plc4x", name = "demo_001", description = "Command for test.")
 public class DemoCommand001  implements Action  {
 
 //    private String filter_device =  "(&(" + Constants.OBJECTCLASS + "=" + Device.class.getName() + ")" +
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand002.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand002.java
index 365ecc7..f58508c 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand002.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand002.java
@@ -34,8 +34,8 @@ import org.apache.plc4x.merlot.api.impl.PlcGroupImpl;
 import org.apache.plc4x.merlot.api.impl.PlcItemImpl;
 
 
-@Command(scope = "plc4x", name = "demo_002", description = "Command for test.")
 @Service
+@Command(scope = "plc4x", name = "demo_002", description = "Command for test.")
 public class DemoCommand002  implements Action  {
   
     @Reference
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceControlCommand.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceControlCommand.java
index cc23b25..0d6593b 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceControlCommand.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceControlCommand.java
@@ -18,14 +18,11 @@
  */
 package org.apache.plc4x.merlot.api.command;
 
-import java.util.List;
-import java.util.UUID;
 import org.apache.karaf.shell.api.action.Action;
 import org.apache.karaf.shell.api.action.Command;
 import org.apache.karaf.shell.api.action.Option;
 import org.apache.karaf.shell.api.action.lifecycle.Reference;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
-import org.apache.plc4x.merlot.api.PlcDevice;
 import org.apache.plc4x.merlot.api.PlcGeneralFunction;
 
 @Command(scope = "plc4x", name = "device-ctrl", description = "List all channels")
@@ -47,15 +44,15 @@ public class PlcDeviceControlCommand implements Action {
     @Override
     public Object execute() throws Exception {
        
-        final PlcDevice dev = plcservice.getPlcDevice(UUID.fromString(did));
-        
-        if (null != dev) {
-            if (enable) {
-                dev.enable();
-            } else if (disable) {
-                dev.disable();
-            }            
-        }
+//        final PlcDevice dev = plcservice.getPlcDevice(UUID.fromString(did));
+//        
+//        if (null != dev) {
+//            if (enable) {
+//                dev.enable();
+//            } else if (disable) {
+//                dev.disable();
+//            }            
+//        }
              
         return null;
     }
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceDel.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceDelCommand.java
similarity index 93%
copy from plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceDel.java
copy to plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceDelCommand.java
index c678e88..1bf630c 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceDel.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceDelCommand.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.plc4x.merlot.das.base.command;
+package org.apache.plc4x.merlot.api.command;
 
 import java.util.List;
 import java.util.UUID;
@@ -31,16 +31,16 @@ import org.apache.plc4x.merlot.api.PlcDevice;
 
 @Command(scope = "plc4x", name = "device-del", description = "Delete a device.")
 @Service
-public class cmdDeviceDel implements Action {
+public class PlcDeviceDelCommand implements Action {
 
     @Reference
-    volatile List<PlcDriver> drivers;
+    BundleContext bc;     
     
     @Reference
-    volatile List<PlcDevice> devices;        
+    volatile List<PlcDriver> drivers;
     
     @Reference
-    BundleContext bc;      
+    volatile List<PlcDevice> devices;                 
     
     @Option(name = "-n", aliases = "--name", description = "Device name.", required = false, multiValued = false)
     String name;
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupList.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceGroupListCommand.java
similarity index 93%
copy from plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupList.java
copy to plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceGroupListCommand.java
index 957cde5..55971ea 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupList.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceGroupListCommand.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.plc4x.merlot.das.base.command;
+package org.apache.plc4x.merlot.api.command;
 
 import org.apache.karaf.shell.api.action.Action;
 import org.apache.karaf.shell.api.action.Command;
@@ -25,7 +25,7 @@ import org.osgi.framework.BundleContext;
 
 @Command(scope = "plc4x", name = "group-list", description = "Delete a device.")
 @Service
-public class cmdDeviceGroupList implements Action {
+public class PlcDeviceGroupListCommand implements Action {
 
     @Reference
     BundleContext bc;
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupNew.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceGroupNewCommand.java
similarity index 72%
copy from plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupNew.java
copy to plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceGroupNewCommand.java
index 2c7238a..6b5962d 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupNew.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceGroupNewCommand.java
@@ -14,10 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.plc4x.merlot.das.base.command;
+package org.apache.plc4x.merlot.api.command;
 
 import java.util.Hashtable;
 import java.util.List;
+import java.util.Optional;
 import java.util.UUID;
 import java.util.stream.Collectors;
 import org.apache.karaf.shell.api.action.Action;
@@ -26,6 +27,7 @@ import org.apache.karaf.shell.api.action.Command;
 import org.apache.karaf.shell.api.action.Option;
 import org.apache.karaf.shell.api.action.lifecycle.Reference;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.plc4x.merlot.api.PlcDevice;
 import org.apache.plc4x.merlot.scheduler.api.Job;
 import org.osgi.framework.BundleContext;
 import org.apache.plc4x.merlot.api.PlcGroup;
@@ -33,7 +35,7 @@ import org.apache.plc4x.merlot.api.impl.PlcGroupImpl;
 
 @Command(scope = "plc4x", name = "group-new", description = "Create group for a device.")
 @Service
-public class cmdDeviceGroupNew implements Action {
+public class PlcDeviceGroupNewCommand implements Action {
 
     @Reference
     BundleContext bc;
@@ -41,11 +43,14 @@ public class cmdDeviceGroupNew implements Action {
     @Reference
     volatile List<PlcGroup> groups;
     
-    @Option(name = "-u", aliases = "--uid", description = "Device uid.", required = true, multiValued = false)
+    @Reference
+    volatile List<PlcDevice> devices;          
+    
+    @Option(name = "-d", aliases = "--uid", description = "Device uid.", required = true, multiValued = false)
     String uid; 
     
-    @Option(name = "-p", aliases = "--period", description = "Group period schedule.", required = true, multiValued = false)
-    Long period; 
+    @Option(name = "-p", aliases = "--scantime", description = "Group scan time schedule.", required = true, multiValued = false)
+    Long scantime = 1000L; 
 
     @Argument(index = 0, name = "Name", description = "Name of the group.", required = true, multiValued = false)
     String name;
@@ -62,9 +67,21 @@ public class cmdDeviceGroupNew implements Action {
         
         if (mygroups.size() == 0) {
 
-   
+            Optional<PlcDevice> plcDevice = devices.stream().
+                                            filter(d -> d.getUid().toString().equals(uid)).
+                                            findFirst();
+            
+            if (plcDevice.isEmpty()) {
+                System.out.println("Device don't exists.");
+                return null;
+            }
+            
+            scantime = (scantime < 100) ? 100 : scantime;
+            
             PlcGroup group  = new PlcGroupImpl.PlcGroupBuilder(bc, name).
-                                    setGroupPeriod(5000).build();
+                                    setGroupPeriod(scantime).build();
+            
+            plcDevice.get().putGroup(group);
             
             bc.registerService(new String[]{Job.class.getName(), PlcGroup.class.getName()},
                     group, group.getProperties());            
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupSchedule.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceGroupScheduleCommand.java
similarity index 96%
copy from plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupSchedule.java
copy to plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceGroupScheduleCommand.java
index d10064d..eec00ef 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupSchedule.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceGroupScheduleCommand.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.plc4x.merlot.das.base.command;
+package org.apache.plc4x.merlot.api.command;
 
 import java.util.Hashtable;
 import org.apache.karaf.shell.api.action.Action;
@@ -31,7 +31,7 @@ import org.apache.plc4x.merlot.api.PlcGroup;
 
 @Command(scope = "plc4x", name = "group-rt", description = "Delete a device.")
 @Service
-public class cmdDeviceGroupSchedule implements Action {
+public class PlcDeviceGroupScheduleCommand implements Action {
 
     @Reference
     BundleContext bc;
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcDeviceImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcDeviceImpl.java
index 7df176c..1f5b304 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcDeviceImpl.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcDeviceImpl.java
@@ -136,7 +136,7 @@ public class PlcDeviceImpl implements PlcDevice {
                 readRingBuffer,
                 readSequenceBarrier,
                 (event, sequence, endofbatch)->{
-
+                    LOGGER.info("Ejecutando sequencia de lectura...");
                     if (null != event.getPlcGroup()){
                         if (null != plcConnection) {
                             if (refPlcConnection.get().isConnected()) {
@@ -155,6 +155,7 @@ public class PlcDeviceImpl implements PlcDevice {
                                         if (null == plcValue) {
                                             LOGGER.info(u.toString() + " Null value");
                                         } else
+                                        LOGGER.info("Write " + i.getItemName());
                                         i.setPlcValue(plcValue);
                                     });
 
@@ -407,6 +408,11 @@ public class PlcDeviceImpl implements PlcDevice {
         this.plcDriver = driver;
     }
 
+    @Override
+    public PlcConnection getPlcConnection() {
+        return plcConnection;
+    }
+        
     @Override
     public String getWritePlcTag(PlcTag plcTag, ByteBuf byteBuf, String... args) {
         String strTag = null;
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcGroupImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcGroupImpl.java
index 0bfe422..129e681 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcGroupImpl.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcGroupImpl.java
@@ -16,6 +16,7 @@
  */
 package org.apache.plc4x.merlot.api.impl;
 
+import com.lmax.disruptor.RingBuffer;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
@@ -61,6 +62,9 @@ public class PlcGroupImpl implements PlcGroup, Job {
     
     private final Map<UUID, PlcItem> groupItems;
     
+    private RingBuffer<PlcDeviceReadEvent>  readRingBuffer;
+    private RingBuffer<PlcDeviceWriteEvent> writeRingBuffer;
+    
     private PlcItemClientService groupItemsService = null;
     
     private AtomicReference<PlcConnection> plcConnection = null;
@@ -244,7 +248,11 @@ public class PlcGroupImpl implements PlcGroup, Job {
             if (null != plcConnection) {
                 if (plcConnection.get().isConnected()) {
                     watch.start();
-                    executeReadAllItems();
+                    //executeReadAllItems();
+                    long sequenceId = readRingBuffer.next();
+                    final PlcDeviceReadEvent readEvent = readRingBuffer.get(sequenceId);
+                    readEvent.setPlcGroup(this);
+                    readRingBuffer.publish(sequenceId);
                     watch.stop();
                     LOGGER.info("Elapse time: " + watch.getTime());
                      watch.reset();
@@ -260,6 +268,18 @@ public class PlcGroupImpl implements PlcGroup, Job {
                     ((String) groupProperties.get(PlcGroup.GROUP_UID)));
         }
     }
+
+    @Override
+    public void setReadRingBuffer(RingBuffer<PlcDeviceReadEvent> readRingBuffer) {
+        this.readRingBuffer = readRingBuffer;
+    }
+
+    @Override
+    public void setWriteRingBuffer(RingBuffer<PlcDeviceWriteEvent> writeRingBuffer) {
+        this.writeRingBuffer = writeRingBuffer;
+    }
+    
+    
     
     /*
     * Execute the read function for all items
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcItemImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcItemImpl.java
index 5b9f80f..bf8a543 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcItemImpl.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcItemImpl.java
@@ -22,14 +22,11 @@ import com.lmax.disruptor.RingBuffer;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.ByteBufUtil;
 import io.netty.buffer.Unpooled;
-import java.time.LocalDate;
-import java.time.ZoneOffset;
 import java.util.Date;
 import java.util.Hashtable;
 import java.util.LinkedList;
 import java.util.UUID;
 import java.util.concurrent.locks.ReentrantLock;
-import org.apache.commons.lang3.NotImplementedException;
 import org.apache.plc4x.java.api.messages.PlcReadResponse;
 import org.apache.plc4x.java.api.model.PlcTag;
 import org.apache.plc4x.java.api.types.PlcResponseCode;
@@ -224,6 +221,7 @@ public class PlcItemImpl implements PlcItem {
 
     @Override
     public void setPlcValue(PlcValue  plcvalue) {
+        
         if (null == itemInnerBuffer) {
             int size = (plcvalue instanceof PlcList) ? 
                     ((PlcList) plcvalue).getLength() * 
@@ -337,7 +335,7 @@ public class PlcItemImpl implements PlcItem {
     }
 
     @Override
-    public void addItemClient(PlcItemListener client) {
+    public void addItemListener(PlcItemListener client) {
         if (!itemClients.contains(client)) {
             client.atach(this);
             itemClients.add(client);
@@ -345,7 +343,7 @@ public class PlcItemImpl implements PlcItem {
     }
 
     @Override
-    public void removeItemClient(PlcItemListener client) {
+    public void removeItemListener(PlcItemListener client) {
         if (!itemClients.contains(client)) {
             itemClients.remove(client);            
             client.detach();
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/DeviceNewCommand.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/DeviceNewCommand.java
index 27d4785..79f189b 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/DeviceNewCommand.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/DeviceNewCommand.java
@@ -31,7 +31,7 @@ import org.osgi.framework.BundleContext;
 import org.apache.plc4x.merlot.api.PlcDevice;
 import org.apache.plc4x.merlot.api.impl.PlcDeviceImpl;
 
-@Command(scope = "plc4x", name = "device-new", description = "Create a new device.")
+@Command(scope = "plc4x", name = "device-new_x", description = "Create a new device.")
 @Service
 public class DeviceNewCommand implements Action {
     private static final Pattern p = Pattern.compile("^([a-zA-Z0-9]+)(:)(.*)"); 
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceDel.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceDel.java
index c678e88..3eba0bb 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceDel.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceDel.java
@@ -29,7 +29,7 @@ import org.apache.plc4x.java.api.PlcDriver;
 import org.osgi.framework.BundleContext;
 import org.apache.plc4x.merlot.api.PlcDevice;
 
-@Command(scope = "plc4x", name = "device-del", description = "Delete a device.")
+@Command(scope = "plc4x", name = "device-del_x", description = "Delete a device.")
 @Service
 public class cmdDeviceDel implements Action {
 
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupDel.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupDel.java
index 3fe5a34..48d780d 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupDel.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupDel.java
@@ -20,7 +20,7 @@ import org.apache.karaf.shell.api.action.Action;
 import org.apache.karaf.shell.api.action.Command;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
 
-@Command(scope = "plc4x", name = "group-del", description = "Delete a device.")
+@Command(scope = "plc4x", name = "group-del_x", description = "Delete a device.")
 @Service
 public class cmdDeviceGroupDel implements Action {
 
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupList.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupList.java
index 957cde5..cd454c8 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupList.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupList.java
@@ -23,7 +23,7 @@ import org.apache.karaf.shell.api.action.lifecycle.Reference;
 import org.apache.karaf.shell.api.action.lifecycle.Service;
 import org.osgi.framework.BundleContext;
 
-@Command(scope = "plc4x", name = "group-list", description = "Delete a device.")
+@Command(scope = "plc4x", name = "group-list_x", description = "Delete a device.")
 @Service
 public class cmdDeviceGroupList implements Action {
 
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupNew.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupNew.java
index 2c7238a..509cf34 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupNew.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupNew.java
@@ -31,7 +31,7 @@ import org.osgi.framework.BundleContext;
 import org.apache.plc4x.merlot.api.PlcGroup;
 import org.apache.plc4x.merlot.api.impl.PlcGroupImpl;
 
-@Command(scope = "plc4x", name = "group-new", description = "Create group for a device.")
+@Command(scope = "plc4x", name = "group-new_x", description = "Create group for a device.")
 @Service
 public class cmdDeviceGroupNew implements Action {
 
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupSchedule.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupSchedule.java
index d10064d..d40ac19 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupSchedule.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupSchedule.java
@@ -29,7 +29,7 @@ import org.osgi.framework.ServiceReference;
 import org.apache.plc4x.merlot.api.PlcChannel;
 import org.apache.plc4x.merlot.api.PlcGroup;
 
-@Command(scope = "plc4x", name = "group-rt", description = "Delete a device.")
+@Command(scope = "plc4x", name = "group-rt_x", description = "Delete a device.")
 @Service
 public class cmdDeviceGroupSchedule implements Action {
 
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseDeviceImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseDeviceImpl.java
index f187aa6..907fe18 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseDeviceImpl.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseDeviceImpl.java
@@ -23,6 +23,7 @@ import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+import org.apache.plc4x.java.api.PlcConnection;
 import org.apache.plc4x.java.api.PlcDriver;
 import org.apache.plc4x.java.api.model.PlcTag;
 import org.apache.plc4x.merlot.api.PlcDevice;
@@ -220,6 +221,11 @@ import org.apache.plc4x.merlot.api.PlcGroup;
         throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
     }
 
+    @Override
+    public PlcConnection getPlcConnection() {
+        throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
+    }
+
 
     public static class BaseDeviceBuilder {
         private final BundleContext bc;        
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseGroupImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseGroupImpl.java
index 7849f0c..9eef573 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseGroupImpl.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseGroupImpl.java
@@ -16,6 +16,7 @@
  */
 package org.apache.plc4x.merlot.das.base.impl;
 
+import com.lmax.disruptor.RingBuffer;
 import java.util.Hashtable;
 import java.util.List;
 import java.util.Map;
@@ -26,6 +27,8 @@ import org.apache.plc4x.merlot.scheduler.api.Job;
 import org.apache.plc4x.merlot.scheduler.api.JobContext;
 import org.apache.plc4x.merlot.api.PlcItem;
 import org.apache.plc4x.merlot.api.PlcGroup;
+import org.apache.plc4x.merlot.api.impl.PlcDeviceReadEvent;
+import org.apache.plc4x.merlot.api.impl.PlcDeviceWriteEvent;
 
 
 public class BaseGroupImpl implements PlcGroup, Job {
@@ -196,6 +199,16 @@ public class BaseGroupImpl implements PlcGroup, Job {
         throw new UnsupportedOperationException("Not supported yet.");
     }
 
+    @Override
+    public void setReadRingBuffer(RingBuffer<PlcDeviceReadEvent> readRingBuffer) {
+        throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
+    }
+
+    @Override
+    public void setWriteRingBuffer(RingBuffer<PlcDeviceWriteEvent> writeRingBuffer) {
+        throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
+    }
+
 
     
 }
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseItemImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseItemImpl.java
index 70833ff..54286e6 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseItemImpl.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseItemImpl.java
@@ -205,37 +205,37 @@ public class BaseItemImpl implements PlcItem {
     }
 
     @Override
-    public void addItemClient(PlcItemListener client) {
+    public void enable() {
         throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
     }
 
     @Override
-    public void removeItemClient(PlcItemListener client) {
+    public void disable() {
         throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
     }
 
     @Override
-    public void enable() {
+    public Hashtable<String, Object> getProperties() {
         throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
     }
 
     @Override
-    public void disable() {
+    public void setRingBuffer(RingBuffer<PlcDeviceWriteEvent> ringBuffer) {
         throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
     }
 
     @Override
-    public Hashtable<String, Object> getProperties() {
+    public void itemWrite() {
         throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
     }
 
     @Override
-    public void setRingBuffer(RingBuffer<PlcDeviceWriteEvent> ringBuffer) {
+    public void addItemListener(PlcItemListener client) {
         throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
     }
 
     @Override
-    public void itemWrite() {
+    public void removeItemListener(PlcItemListener client) {
         throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
     }
     
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das/src/main/resources/OSGI-INF/blueprint/das-service.xml b/plc4j/tools/merlot/org.apache.plc4x.merlot.das/src/main/resources/OSGI-INF/blueprint/das-service.xml
index d47b8d7..011e87e 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das/src/main/resources/OSGI-INF/blueprint/das-service.xml
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das/src/main/resources/OSGI-INF/blueprint/das-service.xml
@@ -16,7 +16,7 @@
   limitations under the License.
 -->
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="eager">
-
+    
     <reference
         id="refPlcGeneralFunction"
         interface="org.apache.plc4x.merlot.api.PlcGeneralFunction" availability="mandatory" timeout="120000"/>    
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/pom.xml b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/pom.xml
index 968dd90..b5b5826 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/pom.xml
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/pom.xml
@@ -39,18 +39,19 @@
             <plugin>
                 <groupId>org.apache.felix</groupId>
                 <artifactId>maven-bundle-plugin</artifactId>
-                <version>5.1.8</version>
+                <version>5.1.9</version>
                 <extensions>true</extensions>
                 <configuration>
                     <instructions>
                         <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                         <Bundle-Version>0.13.0-SNAPSHOT</Bundle-Version>
                         <Export-Package>org.apache.plc4x.merlot.db*;version=0.13.0-SNAPSHOT</Export-Package>
-                        <Karaf-Commands>org.apache.plc4x.merlot.db*</Karaf-Commands>                          
                         <Import-Package>*</Import-Package>
+                        <Karaf-Commands>org.apache.plc4x.merlot.db.command*</Karaf-Commands>                                                
                     </instructions>
                 </configuration>
             </plugin>
+            
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
@@ -60,6 +61,7 @@
                     <maxmem>256M</maxmem>
                 </configuration>
             </plugin>
+            
         </plugins>
     </build>
     <dependencies>
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/command/DBAddCommand.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/command/DBAddCommand.java
index 0ee9cac..d0964e8 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/command/DBAddCommand.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/command/DBAddCommand.java
@@ -46,7 +46,7 @@ public class DBAddCommand  implements Action {
     @Reference
     PVDatabase master;
     
-    @Reference
+//    @Reference
     DBControl dbControl;
     
     @Option(name = "-n", aliases = "--new", description = "New DBRecord.", required = false, multiValued = false)
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBBooleanFactory.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBBooleanFactory.java
index 7972524..9605073 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBBooleanFactory.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBBooleanFactory.java
@@ -18,6 +18,10 @@
  */
 package org.apache.plc4x.merlot.db.core;
 
+import io.grpc.netty.shaded.io.netty.buffer.ByteBuf;
+import io.grpc.netty.shaded.io.netty.buffer.Unpooled;
+import org.apache.plc4x.merlot.api.PlcItem;
+import org.apache.plc4x.merlot.api.PlcItemListener;
 import org.epics.nt.NTScalar;
 import org.epics.nt.NTScalarArray;
 import org.epics.nt.NTScalarArrayBuilder;
@@ -26,6 +30,7 @@ import org.epics.pvdata.factory.FieldFactory;
 import org.epics.pvdata.pv.FieldCreate;
 import org.epics.pvdata.pv.PVBoolean;
 import org.epics.pvdata.pv.PVBooleanArray;
+import org.epics.pvdata.pv.PVString;
 import org.epics.pvdata.pv.PVStructure;
 import org.epics.pvdata.pv.ScalarType;
 import org.epics.pvdatabase.PVRecord;
@@ -79,13 +84,22 @@ public class DBBooleanFactory extends DBBaseFactory {
         return pvRecord;
     }
     
-    class DBBooleanRecord extends PVRecord {
+    class DBBooleanRecord extends PVRecord implements PlcItemListener {
         
         private PVBoolean value;
+        private PlcItem plcItem = null;
+        private ByteBuf innerBuffer = null;
+        private int offset = 0;             
         
         public DBBooleanRecord(String recordName,PVStructure pvStructure) {
             super(recordName, pvStructure);
             value = pvStructure.getBooleanField("value");
+            PVString id = pvStructure.getStringField("id");
+            String strId = id.get();
+            String[] strParts = strId.split("\\/");
+            if (strParts.length == 2) {
+                offset = Integer.getInteger(strParts[1]) * Byte.BYTES;
+            }            
         }    
 
         /**
@@ -95,8 +109,26 @@ public class DBBooleanFactory extends DBBaseFactory {
         public void process()
         {
             super.process();
-
+            if (null != plcItem )
+                plcItem.itemWrite();
         } 
+
+        @Override
+        public void atach(PlcItem plcItem) {
+            this.plcItem = plcItem;
+            innerBuffer = Unpooled.wrappedBuffer(plcItem.getInnerBuffer(), offset, Byte.BYTES);
+        }
+
+        @Override
+        public void detach() {
+            this.plcItem  = null;
+        }
+
+        @Override
+        public void update() {
+            if (null != plcItem)            
+                value.put(innerBuffer.getBoolean(0));
+        }
     }
     
     
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBFloatFactory.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBFloatFactory.java
index 35ccfcf..41555d8 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBFloatFactory.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBFloatFactory.java
@@ -18,6 +18,10 @@
  */
 package org.apache.plc4x.merlot.db.core;
 
+import io.grpc.netty.shaded.io.netty.buffer.ByteBuf;
+import io.grpc.netty.shaded.io.netty.buffer.Unpooled;
+import org.apache.plc4x.merlot.api.PlcItem;
+import org.apache.plc4x.merlot.api.PlcItemListener;
 import org.epics.nt.NTScalar;
 import org.epics.nt.NTScalarArray;
 import org.epics.nt.NTScalarArrayBuilder;
@@ -26,6 +30,7 @@ import org.epics.pvdata.factory.FieldFactory;
 import org.epics.pvdata.pv.FieldCreate;
 import org.epics.pvdata.pv.PVFloat;
 import org.epics.pvdata.pv.PVFloatArray;
+import org.epics.pvdata.pv.PVString;
 import org.epics.pvdata.pv.PVStructure;
 import org.epics.pvdata.pv.ScalarType;
 import org.epics.pvdatabase.PVRecord;
@@ -77,13 +82,22 @@ public class DBFloatFactory extends DBBaseFactory {
         return pvRecord;
     }
 
-    class DBFloatRecord extends PVRecord {
+    class DBFloatRecord extends PVRecord implements PlcItemListener {
     
-        private PVFloat value;        
+        private PVFloat value;  
+        private PlcItem plcItem = null;
+        private ByteBuf innerBuffer = null;
+        private int offset = 0;        
         
         public DBFloatRecord(String recordName,PVStructure pvStructure) {
             super(recordName, pvStructure);
             value = pvStructure.getFloatField("value");
+            PVString id = pvStructure.getStringField("id");
+            String strId = id.get();
+            String[] strParts = strId.split("\\/");
+            if (strParts.length == 2) {
+                offset = Integer.getInteger(strParts[1]) * Float.BYTES;
+            }               
         }    
 
         /**
@@ -93,8 +107,26 @@ public class DBFloatFactory extends DBBaseFactory {
         public void process()
         {
             super.process();
-
+            if (null != plcItem )
+                plcItem.itemWrite();
         }        
+
+        @Override
+        public void atach(PlcItem plcItem) {
+            this.plcItem = plcItem;
+            innerBuffer = Unpooled.wrappedBuffer(plcItem.getInnerBuffer(), offset, Float.BYTES);
+        }
+
+        @Override
+        public void detach() {
+            this.plcItem  = null;
+        }
+
+        @Override
+        public void update() {
+            if (null != plcItem)            
+                value.put(innerBuffer.getFloat(0));
+        }
     }  
     
 }
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBRecordsManagedService.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBRecordsManagedService.java
index 2f843f5..0e8c2ec 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBRecordsManagedService.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBRecordsManagedService.java
@@ -32,7 +32,15 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.stream.Stream;
 import org.apache.plc4x.java.api.PlcConnection;
+import org.apache.plc4x.java.api.PlcDriver;
+import org.apache.plc4x.merlot.api.PlcDevice;
+import org.apache.plc4x.merlot.api.PlcGeneralFunction;
+import org.apache.plc4x.merlot.api.PlcItem;
+import org.apache.plc4x.merlot.api.PlcItemListener;
+import org.epics.pvdata.pv.PVBoolean;
+import org.epics.pvdata.pv.PVStructure;
 import org.epics.pvdatabase.PVDatabase;
 import org.epics.pvdatabase.PVRecord;
 import org.osgi.framework.BundleContext;
@@ -48,6 +56,7 @@ import org.slf4j.LoggerFactory;
 public class DBRecordsManagedService implements ManagedServiceFactory, Job {
     
     private static final Logger LOGGER = LoggerFactory.getLogger(DBRecordsManagedService.class);  
+    private final PlcGeneralFunction generalFunction;
     private final PVDatabase master;
     private static Map<String, Dictionary<String, ?>> waitingConfigs = null;    
     static final String PID = "org.apache.plc4x.merlot.db.records";   
@@ -61,11 +70,12 @@ public class DBRecordsManagedService implements ManagedServiceFactory, Job {
     
     private final DBControl dbControl;
 
-    public DBRecordsManagedService(BundleContext bundleContext, PVDatabase master, DBControl dbControl) {
+    public DBRecordsManagedService(BundleContext bundleContext) {
         this.bundleContext = bundleContext;
-        this.master = master;
-        this.dbControl = dbControl;
+        this.master = null;
+        this.dbControl = null;
         waitingConfigs = Collections.synchronizedMap(new HashMap<String, Dictionary<String, ?>>());
+        this.generalFunction = null;
     }
          
     @Override
@@ -73,6 +83,14 @@ public class DBRecordsManagedService implements ManagedServiceFactory, Job {
         return PID;
     }
 
+    /*
+    * All PvRecords are loaded from the configuration file and validated 
+    * against existing Devices.
+    * If the Device does not exist, the PvRecords are not loaded and wait 
+    * for the device to be present. 
+    * TODO: If the PlcItem associated with the PvRecord does not exist, 
+    *       it can be passed to a waiting queue.
+    */
     @Override
     public void updated(String pid, Dictionary<String, ?> props) throws ConfigurationException {        
         String dataValue= null;
@@ -104,15 +122,16 @@ public class DBRecordsManagedService implements ManagedServiceFactory, Job {
                 return;
         }
         
-        BaseDriver dummyDriver = getDriver(device);
+        //
+        PlcDevice plcDevice = getDevice(device);
         
-        if (dummyDriver == null){
+        if (plcDevice == null){
             LOGGER.debug("Device driver [" + device + "] is not deployed.");
             waitingConfigs.put(device, props); 
             return;
         }
         
-        PlcConnection connPlc = dummyDriver.getPlcConnection();
+        PlcConnection connPlc = plcDevice.getPlcConnection();
         
         if (connPlc == null){
             LOGGER.debug("Device driver [" + device + "] native driver is not present.");
@@ -155,10 +174,25 @@ public class DBRecordsManagedService implements ManagedServiceFactory, Job {
                     }
                 }
             }
-
-            dbControl.attach(device, pvRecords);
+            
             //Si todo OK, los agregoa a la base de datos
-            pvRecords.forEach(pvr -> master.addRecord(pvr));
+            List<PlcItem> plcItems = new ArrayList<PlcItem>();
+            plcDevice.getGroups().forEach(g->plcItems.addAll(g.getItems()));
+
+            pvRecords.forEach(pvr -> {
+
+                PVStructure structure = pvr.getPVStructure();
+                PVBoolean pvScanEnable = structure.getBooleanField("scan_enable");
+                pvScanEnable.put(false);   
+                String id = structure.getStringField("id").get();
+                plcItems.stream().filter(p -> id.contains(p.getItemId())).
+                        findFirst().
+                        ifPresent(p -> {
+                            pvScanEnable.put(true);                             
+                            p.addItemListener((PlcItemListener) pvr);
+                            master.addRecord(pvr);                            
+                        });
+            });
 
         }
     }
@@ -203,13 +237,13 @@ public class DBRecordsManagedService implements ManagedServiceFactory, Job {
         return null;
     }
     
-    private BaseDriver getDriver(String device){
+    private PlcDevice getDevice(String device){
         try{
-            String filterdriver =  "(DRIVER_ID=" + device + ")"; 
-            ServiceReference[] refdrvs = bundleContext.getAllServiceReferences(Driver.class.getName(), filterdriver);
-            BaseDriver refdrv = (BaseDriver) bundleContext.getService(refdrvs[0]);
-            if (refdrv==null) LOGGER.info("BasicDriver [" + device + "] don't found");
-            return refdrv;            
+            String filterdriver =  "(DEVICE_CATEGORY=" + device + ")"; 
+            ServiceReference[] refdrvs = bundleContext.getAllServiceReferences(PlcDevice.class.getName(), filterdriver);
+            PlcDevice refDev = (PlcDevice) bundleContext.getService(refdrvs[0]);
+            if (refDev == null) LOGGER.info("Device [" + device + "] don't found");
+            return refDev;            
         } catch (Exception ex){
             LOGGER.debug("getDriver: " + ex.toString());
         }
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBUShortFactory.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBUShortFactory.java
index 630f5da..6653b7a 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBUShortFactory.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBUShortFactory.java
@@ -18,6 +18,12 @@
  */
 package org.apache.plc4x.merlot.db.core;
 
+import io.grpc.netty.shaded.io.netty.buffer.ByteBuf;
+import io.grpc.netty.shaded.io.netty.buffer.Unpooled;
+import org.apache.plc4x.java.api.value.PlcValue;
+import org.apache.plc4x.merlot.api.PlcItem;
+import org.apache.plc4x.merlot.api.PlcItemClient;
+import org.apache.plc4x.merlot.api.PlcItemListener;
 import org.epics.nt.NTScalar;
 import org.epics.nt.NTScalarArray;
 import org.epics.nt.NTScalarArrayBuilder;
@@ -79,9 +85,12 @@ public class DBUShortFactory extends DBBaseFactory {
         return pvRecord;
     }
 
-    class DBUShortRecord extends PVRecord {
+    class DBUShortRecord extends PVRecord implements PlcItemListener{
     
-        private PVUShort value;      
+        private PVUShort value;
+        private PlcItem plcItem = null;
+        private ByteBuf innerBuffer = null;
+        private int offset = 0;
         
         private DBUShortRecord(String recordName,PVStructure pvStructure) {
             super(recordName, pvStructure);
@@ -95,8 +104,30 @@ public class DBUShortFactory extends DBBaseFactory {
         public void process()
         {
             super.process();
-
+            if (null != plcItem )
+                plcItem.itemWrite();            
         }  
+
+        @Override
+        public void atach(final PlcItem plcItem) {
+            this.plcItem = plcItem;
+            innerBuffer = Unpooled.wrappedBuffer(plcItem.getInnerBuffer(), offset, Short.BYTES);
+        }
+
+        @Override
+        public void detach() {
+            this.plcItem  = null;
+        }
+
+        @Override
+        public void update() {
+            if (null != plcItem)            
+                value.put(innerBuffer.getShort(0));
+        }
+
+
+
+
     }
           
 }
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/resources/OSGI-INF/blueprint/db-service.xml b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/resources/OSGI-INF/blueprint/db-service.xml
index 8d09aea..03ae991 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/resources/OSGI-INF/blueprint/db-service.xml
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/resources/OSGI-INF/blueprint/db-service.xml
@@ -17,6 +17,10 @@
 -->
 <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="eager">
     
+<!--    <reference
+        id="refPlcGeneralFunction"
+        interface="org.apache.plc4x.merlot.api.PlcGeneralFunction" availability="mandatory" timeout="120000"/>     -->
+    
     <bean id="beanDBBooleanFactory" class="org.apache.plc4x.merlot.db.core.DBBooleanFactory" scope="singleton"/>
     <bean id="beanDBByteFactory" class="org.apache.plc4x.merlot.db.core.DBByteFactory" scope="singleton"/>
     <bean id="beanDBDoubleFactory" class="org.apache.plc4x.merlot.db.core.DBDoubleFactory" scope="singleton"/>
@@ -50,13 +54,14 @@
         <property name="bundleContext" ref="blueprintBundleContext"/>
     </bean>
 
-    <bean id="DBRecordsManagedService" 
+<!--    <bean id="beanDBRecordsManagedService" 
         class="org.apache.plc4x.merlot.db.core.DBRecordsManagedService" 
         scope="singleton">
         <argument ref="blueprintBundleContext" />
         <argument ref="DBBean" />
         <argument ref="DBControl" />
-    </bean>
+        <argument ref="refPlcGeneralFunction" />        
+    </bean>-->
     
     <bean id="DBRPCReferenceListener" 
           class="org.apache.plc4x.merlot.db.impl.DBRPCReferenceListenerImpl" 
@@ -80,16 +85,16 @@
        </reference-listener>
     </reference-list>    
     
-    <service ref="DBRecordsManagedService" auto-export="interfaces">
+<!--    <service ref="DBRecordsManagedService" auto-export="interfaces">
     	<service-properties>
             <entry key="service.pid" value="org.apache.plc4x.merlot.db.records"/>
             <entry key="scheduler.name" value="DBRecordsManagedService"/>  
             <entry key="scheduler.period" value="5000"/>
-            <!-- <entry key="scheduler.times" value="5"/> -->
+             <entry key="scheduler.times" value="5"/> 
             <entry key="scheduler.immediate" value="true"/>
             <entry key="scheduler.concurrent" value="false"/>                               
      	</service-properties>        
-    </service>   
+    </service>   -->
 
     <service id="DBBooleanFactory"  
              ref="beanDBBooleanFactory" 
@@ -195,14 +200,14 @@
              ref="DBChannelProvider" 
              interface="org.epics.pvaccess.client.ChannelProvider"/>
     
-    <service id="MasterDBControl" ref="DBControl" auto-export="interfaces">
+<!--    <service id="MasterDBControl" ref="DBControl" auto-export="interfaces">
         <service-properties>
             <entry key="scheduler.name" value="MasterDBControl"/>  
             <entry key="scheduler.period" value="1000"/>
-            <!-- <entry key="scheduler.times" value="5"/> -->
+             <entry key="scheduler.times" value="5"/> 
             <entry key="scheduler.immediate" value="true"/>
             <entry key="scheduler.concurrent" value="false"/>                      
         </service-properties>
-    </service>
+    </service>-->
     
 </blueprint>
\ No newline at end of file
diff --git a/plc4j/tools/merlot/pom.xml b/plc4j/tools/merlot/pom.xml
index 7610b71..42fdd9b 100644
--- a/plc4j/tools/merlot/pom.xml
+++ b/plc4j/tools/merlot/pom.xml
@@ -72,7 +72,7 @@ under the License.
     <javaluator.version>3.0.3</javaluator.version>
                    
     <!-- Integration version -->
-    <karaf.version>4.4.5</karaf.version>
+    <karaf.version>4.4.6</karaf.version>
     <decanter.version>2.10.0</decanter.version>                
     <org.osgi.core.version>6.0.0</org.osgi.core.version>
     <osgi.core.version>8.0.0</osgi.core.version>