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 64c0fb9  Test command for HTC.
64c0fb9 is described below

commit 64c0fb92b90c3a5f87c34a52068c9d8e605f068e
Author: César García <[email protected]>
AuthorDate: Sat Mar 21 20:11:27 2026 -0400

    Test command for HTC.
---
 .../org.apache.plc4x.merlot.archiver/pom.xml       |   7 +-
 .../plc4x/merlot/archiver/api/MerlotGPClient.java  | 159 +-------------
 .../plc4x/merlot/archiver/api/MerlotHtc.java       |   3 +-
 .../merlot/archiver/command/MerlotHtcCommand.java  |  72 +++++++
 .../merlot/archiver/impl/MerlotGPClientImpl.java   | 228 ++-------------------
 .../merlot/archiver/impl/MerlotHtcRTImpl.java      |  64 +++---
 .../archiver/impl/MerlotPvHtcCollectorImpl.java    |  20 +-
 .../archiver/impl/MerlotPvRtCollectorImpl.java     |   7 +-
 .../OSGI-INF/blueprint/archiver-service.xml        |   3 +-
 9 files changed, 137 insertions(+), 426 deletions(-)

diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/pom.xml 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/pom.xml
index e6d00f6..7acdd43 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/pom.xml
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/pom.xml
@@ -52,7 +52,7 @@
                             java.nio.file.spi,
                             *
                         </Import-Package>
-                        
<Karaf-Commands>org.apache.plc4x.merlot.api.command*</Karaf-Commands>
+                        
<Karaf-Commands>org.apache.plc4x.merlot.archiver.command*</Karaf-Commands>
                         
<!--<_removeheaders>Import-Service,Export-Service</_removeheaders>-->   
                         <SPI-Consumer>*</SPI-Consumer>                         
                       
                     </instructions>
@@ -196,5 +196,10 @@
             <artifactId>commons-collections4</artifactId>
             <version>4.5.0</version>
         </dependency>
+        <dependency>
+            <groupId>org.apache.karaf.shell</groupId>
+            <artifactId>org.apache.karaf.shell.core</artifactId>
+            <version>4.4.10</version>
+        </dependency>
     </dependencies>
 </project>
diff --git 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/api/MerlotGPClient.java
 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/api/MerlotGPClient.java
index 7a42662..c3a0b21 100644
--- 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/api/MerlotGPClient.java
+++ 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/api/MerlotGPClient.java
@@ -45,165 +45,16 @@ public interface MerlotGPClient {
     /**
      * 
      */
-    public void destroy();    
-        
-    /**
-     * Reads the value of the given expression, asking for {@link VType} 
values.
-     * 
-     * @param channelName the name of the channel
-     * @return the future value
-     */
-    public Future<VType> readOnce(String channelName);
-    
-    /**
-     * Reads the value of the given expression.
-     * 
-     * @param <R> the read type
-     * @param expression the expression to read
-     * @return the future value
-     */
-    public <R> Future<R> readOnce(Expression<R, ?> expression);
+    public void destroy();   
     
     /**
-     * Reads the channel with the given name, asking for {@link VType} values.
      * 
-     * @param channelName the name of the channel
-     * @return the configuration options
-     */
-    public PVReaderConfiguration<VType> read(String channelName);
+     */    
+    public GPClientInstance gpClientFactory(String ThreadsId);
     
     /**
-     * Reads the given expression.
      * 
-     * @param <R> the read type
-     * @param expression the expression to read
-     * @return the configuration options
-     */
-    public <R> PVReaderConfiguration<R> read(Expression<R, ?> expression);
-    
-    /**
-     * Reads and writes the channel with the given name, asking for {@link 
VType} values.
-     * 
-     * @param channelName the name of the channel
-     * @return the configuration options
-     */
-    public PVConfiguration<VType, Object> readAndWrite(String channelName);
-
-    /**
-     * Reads and writes the given expression.
-     * 
-     * @param <R> the read type
-     * @param <W> the write type
-     * @param expression the expression to read and write
-     * @return the configuration options
-     */
-    public <R, W> PVConfiguration<R, W> readAndWrite(Expression<R, W> 
expression);
-    
-    /**
-     * Keep only the latest value from the channel.
-     * <p>
-     * In case of data bursts (i.e. data coming in at rate faster than the
-     * reader can handle) this strategy will skip the notification in between,
-     * but always notify on the last value.
-     * 
-     * @param <R> the type to read
-     * @param readType the type to read
-     * @return the caching strategy
-     */
-    public <R> ReadCollector<R, R> cacheLastValue(Class<R> readType);
-    
-    /**
-     * Return all the values queued from the last update.
-     * <p>
-     * In case of data bursts (i.e. data coming in at rate faster than the
-     * reader can handle) this strategy will combine the notifications and
-     * return all the values.
-     * 
-     * @param <R> the type to read
-     * @param readType the type to read
-     * @return the caching strategy
-     */
-    public <R> ReadCollector<R, List<R>> queueAllValues(Class<R> readType);
-
-    /**
-     * A write buffer for the the given type.
-     * 
-     * @param <W> the type to write
-     * @param writeType the type to write
-     * @return the caching strategy
-     */
-    public <W> WriteCollector<W> writeType(Class<W> writeType);
-
-    /**
-     * A channel that reads and writes the given data types with the given 
strategy.
-     * 
-     * @param <R> the type to read
-     * @param <W> the type to write
-     * @param channelName the name of the channel
-     * @param readCollector the read buffer
-     * @param writeCollector the write buffer
-     * @return a new channel expression
-     */
-    public <R, W> Expression<R, W> channel(String channelName, 
ReadCollector<?, R> readCollector, WriteCollector<W> writeCollector);
-    
-    /**
-     * A channel that reads the given data type with the given strategy.
-     * 
-     * @param <R> the type to read
-     * @param channelName the name of the channel
-     * @param readCollector the read buffer
-     * @return a new channel expression
-     */
-    public <R> Expression<R, Object> channel(String channelName, 
ReadCollector<?, R> readCollector);
-
-    /**
-     * A channel that reads {@link VType}s caching the latest value.
-     * 
-     * @param channelName the name of the channel
-     * @return a new channel expression
-     */
-    public Expression<VType, Object> channel(String channelName);
-
-    /**
-     * An expression that allows to directly send/receive values to/from
-     * PVReaders/PVWriters. This can be used for testing purpose or to 
integrate
-     * data models that do not fit datasources or services.
-     * 
-     * @param <R> the type to read
-     * @param <C> the type to collect
-     * @param <W> the type to write
-     * @param readCollector the read buffer
-     * @param writeCollector the write buffer
-     * @return a new collector expression
-     */
-    public <R, C, W> CollectorExpression<R, C, W> collector(ReadCollector<C, 
R> readCollector, WriteCollector<W> writeCollector);
-
-    /**
-     * An expression that allows to directly send/receive values to/from
-     * PVReaders/PVWriters. This can be used for testing purpose or to 
integrate
-     * data models that do not fit datasources or services.
-     * 
-     * @param <R> the type to read
-     * @param <C> the type to collect
-     * @param readCollector the read buffer
-     * @return a new collector expression
-     */
-    public <R, C> CollectorExpression<R, C, Object> collector(ReadCollector<C, 
R> readCollector);
-
-    /**
-     * An expression that allows to directly send/receive values to/from
-     * PVReaders/PVWriters. This can be used for testing purpose or to 
integrate
-     * data models that do not fit datasources or services.
-     * 
-     * @return a new collector expression
-     */
-    public CollectorExpression<VType, VType, Object> collector();
-
-    /**
-     * The default instance of the general purpose client.
-     * 
-     * @return the default instance
-     */
-    public GPClientInstance defaultInstance();
+     */    
+    public GPClientInstance gpClientDefaultInstance();
     
 }
diff --git 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/api/MerlotHtc.java
 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/api/MerlotHtc.java
index b6434f0..2457b15 100644
--- 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/api/MerlotHtc.java
+++ 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/api/MerlotHtc.java
@@ -16,6 +16,7 @@
  */
 package org.apache.plc4x.merlot.archiver.api;
 
+import java.util.List;
 import org.epics.gpclient.PV;
 
 
@@ -49,6 +50,6 @@ public interface MerlotHtc {
     /*
     *
     */
-    PV[] getPs(String strPV, String init, String end);
+    List<PV> getPVs(String strPV, String init, String end);
     
 }
diff --git 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/command/MerlotHtcCommand.java
 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/command/MerlotHtcCommand.java
new file mode 100644
index 0000000..779ce58
--- /dev/null
+++ 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/command/MerlotHtcCommand.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.plc4x.merlot.archiver.command;
+
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+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.karaf.shell.support.table.ShellTable;
+import org.apache.plc4x.merlot.archiver.api.MerlotHtc;
+import org.osgi.framework.BundleContext;
+
+@Service
+@Command(scope = "plc4x", name = "htc", description = "Historical collector 
admin.")
+public class MerlotHtcCommand   implements Action {
+
+    @Reference
+    BundleContext bc;
+    
+    @Reference
+    volatile List<MerlotHtc> htcs;      
+    
+    @Option(name = "-l", aliases = "--list", description = "List collector 
PVs.", required = false, multiValued = false)
+    String strHtc;     
+    
+    @Override
+    public Object execute() throws Exception {
+        if (null == strHtc){
+            ListCollectorsServices(null);
+        } else {
+            ListCollectorsServices(strHtc);
+        }
+        return null;
+    }
+    
+    private void ListCollectorsServices(String id){
+        if (null == id) {
+            ShellTable table = new ShellTable();
+            table.column("Uid");
+            table.column("Key");
+            htcs.forEach(htc -> {
+                    table.addRow().addContent("uno",htc.getPVs().length);
+            });
+            
+        } else {
+            ShellTable table = new ShellTable();
+            table.column("Item");
+            table.column("PV");             
+        }
+    }
+    
+ 
+    
+}
diff --git 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotGPClientImpl.java
 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotGPClientImpl.java
index 0857fda..ddae5db 100644
--- 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotGPClientImpl.java
+++ 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotGPClientImpl.java
@@ -18,23 +18,13 @@
 package org.apache.plc4x.merlot.archiver.impl;
 
 import java.time.Duration;
-import java.util.List;
 import java.util.ServiceLoader;
 import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
 import org.apache.plc4x.merlot.archiver.api.MerlotGPClient;
-import org.epics.gpclient.CollectorExpression;
-import org.epics.gpclient.Expression;
-import org.epics.gpclient.GPClient;
 import org.epics.gpclient.GPClientConfiguration;
 import org.epics.gpclient.GPClientInstance;
-import org.epics.gpclient.PVConfiguration;
-import org.epics.gpclient.PVReaderConfiguration;
-import org.epics.gpclient.ReadCollector;
-import org.epics.gpclient.WriteCollector;
 import org.epics.gpclient.datasource.CompositeDataSource;
 import org.epics.gpclient.datasource.DataSourceProvider;
-import org.epics.vtype.VType;
 
 /**
  *
@@ -43,12 +33,11 @@ import org.epics.vtype.VType;
 public class MerlotGPClientImpl implements MerlotGPClient {
     
     private GPClientInstance gpClient;    
-    
+    private CompositeDataSource cds = new CompositeDataSource();
     
     @Override
     public void init() {
         ServiceLoader<DataSourceProvider> ldr = 
ServiceLoader.load(DataSourceProvider.class);
-        CompositeDataSource cds = new CompositeDataSource();
         for (DataSourceProvider spiObject : ldr) {
             cds.putDataSource(spiObject.getName(), spiObject.createInstance());
         }
@@ -63,214 +52,25 @@ public class MerlotGPClientImpl implements MerlotGPClient {
     @Override
     public void destroy() {
         gpClient.getDefaultDataSource().getChannels().clear();
-    }    
-            
-    /**
-     * Reads the value of the given expression, asking for {@link VType} 
values.
-     * 
-     * @param channelName the name of the channel
-     * @return the future value
-     */
-    @Override
-    public Future<VType> readOnce(String channelName) {
-        return gpClient.readOnce(channelName);
-    }
-    
-    /**
-     * Reads the value of the given expression.
-     * 
-     * @param <R> the read type
-     * @param expression the expression to read
-     * @return the future value
-     */
-    @Override
-    public <R> Future<R> readOnce(Expression<R, ?> expression) {
-        return gpClient.readOnce(expression);
-    }
-    
-    /**
-     * Reads the channel with the given name, asking for {@link VType} values.
-     * 
-     * @param channelName the name of the channel
-     * @return the configuration options
-     */
-    @Override
-    public PVReaderConfiguration<VType> read(String channelName) {
-        return gpClient.read(channelName);
-    }
-    
-    /**
-     * Reads the given expression.
-     * 
-     * @param <R> the read type
-     * @param expression the expression to read
-     * @return the configuration options
-     */
-    @Override
-    public <R> PVReaderConfiguration<R> read(Expression<R, ?> expression) {
-        return gpClient.read(expression);
-    }
-    
-    /**
-     * Reads and writes the channel with the given name, asking for {@link 
VType} values.
-     * 
-     * @param channelName the name of the channel
-     * @return the configuration options
-     */
-    @Override
-    public PVConfiguration<VType, Object> readAndWrite(String channelName) {
-        return gpClient.readAndWrite(channelName);
-    }
-
-    /**
-     * Reads and writes the given expression.
-     * 
-     * @param <R> the read type
-     * @param <W> the write type
-     * @param expression the expression to read and write
-     * @return the configuration options
-     */
-    @Override
-    public <R, W> PVConfiguration<R, W> readAndWrite(Expression<R, W> 
expression) {
-        return gpClient.readAndWrite(expression);
-    }
-    
-    /**
-     * Keep only the latest value from the channel.
-     * <p>
-     * In case of data bursts (i.e. data coming in at rate faster than the
-     * reader can handle) this strategy will skip the notification in between,
-     * but always notify on the last value.
-     * 
-     * @param <R> the type to read
-     * @param readType the type to read
-     * @return the caching strategy
-     */
-    @Override
-    public <R> ReadCollector<R, R> cacheLastValue(Class<R> readType) {
-        return GPClient.cacheLastValue(readType);
-    }
+        gpClient.close();
+    } 
     
-    /**
-     * Return all the values queued from the last update.
-     * <p>
-     * In case of data bursts (i.e. data coming in at rate faster than the
-     * reader can handle) this strategy will combine the notifications and
-     * return all the values.
-     * 
-     * @param <R> the type to read
-     * @param readType the type to read
-     * @return the caching strategy
-     */
     @Override
-    public <R> ReadCollector<R, List<R>> queueAllValues(Class<R> readType) {
-        return GPClient.queueAllValues(readType);
-    }
-
-    /**
-     * A write buffer for the the given type.
-     * 
-     * @param <W> the type to write
-     * @param writeType the type to write
-     * @return the caching strategy
-     */
-    @Override
-    public <W> WriteCollector<W> writeType(Class<W> writeType) {
-        return GPClient.writeType(writeType);
-    }
-
-    /**
-     * A channel that reads and writes the given data types with the given 
strategy.
-     * 
-     * @param <R> the type to read
-     * @param <W> the type to write
-     * @param channelName the name of the channel
-     * @param readCollector the read buffer
-     * @param writeCollector the write buffer
-     * @return a new channel expression
-     */
-    @Override
-    public <R, W> Expression<R, W> channel(String channelName, 
ReadCollector<?, R> readCollector, WriteCollector<W> writeCollector) {
-        return GPClient.channel(channelName, readCollector, writeCollector);
-    }
-    
-    /**
-     * A channel that reads the given data type with the given strategy.
-     * 
-     * @param <R> the type to read
-     * @param channelName the name of the channel
-     * @param readCollector the read buffer
-     * @return a new channel expression
-     */
-    @Override
-    public <R> Expression<R, Object> channel(String channelName, 
ReadCollector<?, R> readCollector) {
-        return GPClient.channel(channelName, readCollector);
-    }
-
-    /**
-     * A channel that reads {@link VType}s caching the latest value.
-     * 
-     * @param channelName the name of the channel
-     * @return a new channel expression
-     */
-    @Override
-    public Expression<VType, Object> channel(String channelName) {
-        return GPClient.channel(channelName);
-    }
-
-    /**
-     * An expression that allows to directly send/receive values to/from
-     * PVReaders/PVWriters. This can be used for testing purpose or to 
integrate
-     * data models that do not fit datasources or services.
-     * 
-     * @param <R> the type to read
-     * @param <C> the type to collect
-     * @param <W> the type to write
-     * @param readCollector the read buffer
-     * @param writeCollector the write buffer
-     * @return a new collector expression
-     */
-    @Override
-    public <R, C, W> CollectorExpression<R, C, W> collector(ReadCollector<C, 
R> readCollector, WriteCollector<W> writeCollector) {
-        return GPClient.collector(readCollector, writeCollector);
-    }
-
-    /**
-     * An expression that allows to directly send/receive values to/from
-     * PVReaders/PVWriters. This can be used for testing purpose or to 
integrate
-     * data models that do not fit datasources or services.
-     * 
-     * @param <R> the type to read
-     * @param <C> the type to collect
-     * @param readCollector the read buffer
-     * @return a new collector expression
-     */
-    @Override
-    public <R, C> CollectorExpression<R, C, Object> collector(ReadCollector<C, 
R> readCollector) {
-        return GPClient.collector(readCollector);
-    }
-
-    /**
-     * An expression that allows to directly send/receive values to/from
-     * PVReaders/PVWriters. This can be used for testing purpose or to 
integrate
-     * data models that do not fit datasources or services.
-     * 
-     * @return a new collector expression
-     */
-    @Override
-    public CollectorExpression<VType, VType, Object> collector() {
-        return collector(cacheLastValue(VType.class));
+    public GPClientInstance gpClientFactory(String ThreadsId) {
+        return new 
GPClientConfiguration().defaultMaxRate(Duration.ofMillis(50))
+                
.notificationExecutor(org.epics.util.concurrent.Executors.localThread())
+                
.dataSource(cds).dataProcessingThreadPool(Executors.newScheduledThreadPool(Math.max(1,
 Runtime.getRuntime().availableProcessors() - 1),
+                
org.epics.util.concurrent.Executors.namedPool(ThreadsId))).build(); 
     }
 
-    /**
-     * The default instance of the general purpose client.
-     * 
-     * @return the default instance
-     */
     @Override
-    public GPClientInstance defaultInstance() {
+    public GPClientInstance gpClientDefaultInstance() {
         return gpClient;
     }    
-
     
+    
+    public void bindDataSourceProvider(DataSourceProvider dsp) {
+        cds.putDataSource(dsp);
+    }    
+   
 }
diff --git 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotHtcRTImpl.java
 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotHtcRTImpl.java
index 8f10ddd..021eeeb 100644
--- 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotHtcRTImpl.java
+++ 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotHtcRTImpl.java
@@ -18,11 +18,16 @@ package org.apache.plc4x.merlot.archiver.impl;
 
 import java.time.Duration;
 import java.time.LocalDateTime;
+import java.util.Collection;
+import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 import org.apache.commons.collections4.queue.CircularFifoQueue;
+import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
+import org.apache.plc4x.merlot.archiver.api.MerlotGPClient;
 import org.apache.plc4x.merlot.archiver.api.MerlotHtc;
 import org.epics.gpclient.GPClient;
 import org.epics.gpclient.GPClientConfiguration;
@@ -38,38 +43,39 @@ import org.slf4j.LoggerFactory;
  *
  * @author cgarcia
  */
-public class MerlotHtcRTImpl implements MerlotHtc{
+public class MerlotHtcRTImpl implements MerlotHtc {
     private static final org.slf4j.Logger LOGGER = 
LoggerFactory.getLogger(MerlotHtcRTImpl.class); 
     
-    private static final Pattern SIM_PATTERN = 
Pattern.compile("(^ACK:)((,{0,1}(16#[0-9a-fA-F]{8})(;([0-9a-fA-F]{2})))+)");
+    private static final Pattern SIM_PATTERN = Pattern.compile("(^noise)");
     
     CompositeDataSource cds = new  CompositeDataSource();
     
     private Map<String, PVReader<VType>> readerPvs = new 
ConcurrentHashMap<>();      
     private Map<String, CircularFifoQueue<Pair<LocalDateTime, PV>>> pvs = new 
ConcurrentHashMap<>();    
     
-    static GPClientInstance gpClient;   
+    final GPClientInstance gpClient;   
     
     private PVReader<VType> pv1;
     private PVReader<VType> pv2;    
+
+    public MerlotHtcRTImpl(MerlotGPClient gpMerlotClient) {
+        this.gpClient = gpMerlotClient.gpClientFactory("GPClient HtcRT ");
+    }
     
     @Override
     public void init() {
-
-        gpClient = new 
GPClientConfiguration().defaultMaxRate(Duration.ofMillis(50))
-                
.notificationExecutor(org.epics.util.concurrent.Executors.localThread())
-                .dataSource(cds)
-                
.dataProcessingThreadPool(java.util.concurrent.Executors.newScheduledThreadPool(
-                        Math.max(1, Runtime.getRuntime().availableProcessors() 
- 1),
-                        
org.epics.util.concurrent.Executors.namedPool("MerlotHtcRT-Worker ")))
-                .build();                           
+        pv1 = gpClient.read("sim://noise")
+                .addReadListener((event, p) ->{
+                    pvs.get("").add(new ImmutablePair(LocalDateTime.now(), p));
+                })
+                .start();  
+        readerPvs.put("sim://noise", pv1);
     }
 
     @Override
     public void destroy() {
         try {
             pv1.close();
-            pv2.close();            
             gpClient.close();
         } catch (IllegalStateException e) {
             e.printStackTrace();
@@ -92,29 +98,17 @@ public class MerlotHtcRTImpl implements MerlotHtc{
     }
 
     @Override
-    public PV[] getPs(String strPV, String init, String end) {
-        return null;
-    }
-    
-    public void bindDataSourceProvider(DataSourceProvider dsp) {
-        System.out.println("Encontro un servicio: " + dsp.getName());
-        cds.putDataSource(dsp);
-        if ("sim".equalsIgnoreCase(dsp.getName())){
-            pv1 = gpClient.read("sim://noise")
-                    .addReadListener((event, p) ->{
-                        System.out.println(event + " <1>  " + p.isConnected() 
+ " " + p.getValue());
-
-                    })
-                    .start(); 
-
-            pv2 = gpClient.read("sim://noise")
-                    .addReadListener((event, p) ->{
-                        System.out.println(event + " <2> " + p.isConnected() + 
" " + p.getValue());
-
-                    })
-                    .start();                  
-
-        }
+    public List<PV> getPVs(String strPV, String init, String end) {
+        List<PV> result;
+        LocalDateTime inicio = LocalDateTime.parse(init);
+        LocalDateTime fin = LocalDateTime.parse(end);
+        result = pvs.get(strPV).stream().filter(pair -> {
+            LocalDateTime fecha = pair.getLeft();
+            return !fecha.isBefore(inicio) && !fecha.isAfter(fin);
+        })
+        .map(Pair::getRight)
+        .collect(Collectors.toList());       
+        return result;
     }
     
 }
diff --git 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotPvHtcCollectorImpl.java
 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotPvHtcCollectorImpl.java
index da813cb..b59f209 100644
--- 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotPvHtcCollectorImpl.java
+++ 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotPvHtcCollectorImpl.java
@@ -16,8 +16,6 @@
  */
 package org.apache.plc4x.merlot.archiver.impl;
 
-import java.io.StringWriter;
-import java.time.Duration;
 import java.time.Instant;
 import java.util.Date;
 import java.util.Dictionary;
@@ -25,17 +23,10 @@ import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Map;
-import java.util.ServiceLoader;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.Executors;
 import java.util.function.BiConsumer;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import javax.json.Json;
-import javax.json.JsonObject;
-import javax.json.JsonWriter;
-import javax.json.JsonWriterFactory;
-import javax.json.stream.JsonGenerator;
 import org.apache.commons.lang3.tuple.MutablePair;
 import org.apache.plc4x.merlot.archiver.api.MerlotCollector;
 import org.apache.plc4x.merlot.archiver.api.MerlotGPClient;
@@ -43,19 +34,14 @@ import org.apache.plc4x.merlot.scheduler.api.Job;
 import org.apache.plc4x.merlot.scheduler.api.JobContext;
 import org.apache.plc4x.merlot.scheduler.api.ScheduleOptions;
 import org.apache.plc4x.merlot.scheduler.api.Scheduler;
-import org.epics.gpclient.GPClient;
-import org.epics.gpclient.GPClientConfiguration;
 import org.epics.gpclient.GPClientInstance;
 import org.epics.gpclient.PVEvent;
 import org.epics.gpclient.PVEventRecorder;
 import org.epics.gpclient.PVReader;
 import org.epics.gpclient.PVReaderListener;
-import org.epics.gpclient.datasource.CompositeDataSource;
-import org.epics.gpclient.datasource.DataSourceProvider;
 import org.epics.vtype.VNumber;
 import org.epics.vtype.VType;
 import org.osgi.service.cm.ConfigurationException;
-import org.osgi.service.cm.ManagedService;
 import org.osgi.service.cm.ManagedServiceFactory;
 import org.osgi.service.event.Event;
 import org.osgi.service.event.EventAdmin;
@@ -75,16 +61,16 @@ public class MerlotPvHtcCollectorImpl implements 
MerlotCollector, ManagedService
     
     private final Scheduler scheduler;
     private final EventAdmin eventAdmin;
-    private final MerlotGPClient gpClient;    
+    private final GPClientInstance gpClient;    
     private final Map<String, SchedulerGroup> groups = new 
ConcurrentHashMap<>();     
     private final Map<String, MutablePair<SchedulerGroup, PVReader<VType>>> 
pvs = new ConcurrentHashMap<>();    
 
     
     
-    public MerlotPvHtcCollectorImpl(Scheduler scheduler, EventAdmin 
eventAdmin, MerlotGPClient gpClient) {
+    public MerlotPvHtcCollectorImpl(Scheduler scheduler, EventAdmin 
eventAdmin, MerlotGPClient gpMerlotClient) {
         this.scheduler = scheduler;
         this.eventAdmin = eventAdmin;
-        this.gpClient = gpClient;
+        this.gpClient = gpMerlotClient.gpClientDefaultInstance();
     }
     
 
diff --git 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotPvRtCollectorImpl.java
 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotPvRtCollectorImpl.java
index 5936ca1..a2ee2d1 100644
--- 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotPvRtCollectorImpl.java
+++ 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/java/org/apache/plc4x/merlot/archiver/impl/MerlotPvRtCollectorImpl.java
@@ -33,6 +33,7 @@ import org.apache.plc4x.merlot.scheduler.api.Job;
 import org.apache.plc4x.merlot.scheduler.api.JobContext;
 import org.apache.plc4x.merlot.scheduler.api.ScheduleOptions;
 import org.apache.plc4x.merlot.scheduler.api.Scheduler;
+import org.epics.gpclient.GPClientInstance;
 import org.epics.gpclient.PVEvent;
 import org.epics.gpclient.PVEventRecorder;
 import org.epics.gpclient.PVReader;
@@ -58,14 +59,14 @@ public class MerlotPvRtCollectorImpl implements 
MerlotCollector, ManagedServiceF
            
     private final Scheduler scheduler;
     private final EventAdmin eventAdmin;
-    private final MerlotGPClient gpClient;
+    private final GPClientInstance gpClient;
     private final Map<String, SchedulerGroup> groups = new 
ConcurrentHashMap<>();     
     private final Map<String, MutablePair<SchedulerGroup, PVReader<VType>>> 
pvs = new ConcurrentHashMap<>();  
     
-    public MerlotPvRtCollectorImpl(Scheduler scheduler, EventAdmin eventAdmin, 
MerlotGPClient gpClient) {
+    public MerlotPvRtCollectorImpl(Scheduler scheduler, EventAdmin eventAdmin, 
MerlotGPClient gpMerlotClient) {
         this.scheduler = scheduler;
         this.eventAdmin = eventAdmin;
-        this.gpClient = gpClient;
+        this.gpClient = gpMerlotClient.gpClientDefaultInstance();
     }
      
 
diff --git 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/resources/OSGI-INF/blueprint/archiver-service.xml
 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/resources/OSGI-INF/blueprint/archiver-service.xml
index 94a2326..7f1959b 100644
--- 
a/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/resources/OSGI-INF/blueprint/archiver-service.xml
+++ 
b/plc4j/tools/merlot/org.apache.plc4x.merlot.archiver/src/main/resources/OSGI-INF/blueprint/archiver-service.xml
@@ -95,6 +95,7 @@
             destroy-method="destroy"                           
             scope="singleton"
             activation="eager">
+            <argument ref="MerlotGPClientBean" />          
     </bean>   
     
 <!--    <bean id="MerlotDataBrowserIoTDBSearchPVBean" 
@@ -127,7 +128,7 @@
         availability="optional">
         <reference-listener
             bind-method="bindDataSourceProvider"
-            ref="MerlotHtcRTBean"/>    
+            ref="MerlotGPClientBean"/>    
     </reference-list>
     
     <service ref="MerlotGPClientBean" auto-export="interfaces">       

Reply via email to