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/20 13:54:25 UTC
(plc4x-extras) branch feature/merlot updated: Fixed DeviceDetector startup.
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 247f42b Fixed DeviceDetector startup.
247f42b is described below
commit 247f42b27734220deaffe2ebade5ba728eb11614
Author: César García <ce...@ceos.com.ve>
AuthorDate: Tue Aug 20 09:53:25 2024 -0400
Fixed DeviceDetector startup.
---
.../merlot/org.apache.plc4x.merlot.das.api/pom.xml | 5 +
.../org/apache/plc4x/merlot/api/PlcDevice.java | 8 +
.../java/org/apache/plc4x/merlot/api/PlcItem.java | 26 +-
.../java/org/apache/plc4x/merlot/api/PlcModel.java | 25 ++
.../apache/plc4x/merlot/api/PlcModelFactory.java | 26 ++
.../merlot/api/core/PlcItemClientService.java | 2 +-
.../merlot/api/impl/PlcBatchEventProcessor.java | 349 +++++++++++++++++++++
.../plc4x/merlot/api/impl/PlcDeviceImpl.java | 271 +++++++++++++---
.../plc4x/merlot/api/impl/PlcDeviceReadEvent.java | 33 ++
.../plc4x/merlot/api/impl/PlcDeviceWriteEvent.java | 52 +++
.../apache/plc4x/merlot/api/impl/PlcGroupImpl.java | 162 +++++-----
.../apache/plc4x/merlot/api/impl/PlcItemImpl.java | 274 ++++++++--------
.../merlot/das/base/command/cmdDeviceDel.java | 2 -
.../plc4x/merlot/das/base/impl/BaseDeviceImpl.java | 7 +
.../plc4x/merlot/das/base/impl/BaseItemImpl.java | 19 +-
.../merlot/org.apache.plc4x.merlot.das.ref/pom.xml | 1 +
.../das/ref/impl/Plc4xReferringDriverImpl.java | 2 +-
.../merlot/org.apache.plc4x.merlot.das/pom.xml | 7 +-
.../resources/OSGI-INF/blueprint/das-service.xml | 2 +-
.../merlot/org.apache.plc4x.merlot.db/pom.xml | 2 +-
.../apache/plc4x/merlot/db/core/DBBaseFactory.java | 1 +
.../plc4x/merlot/db/core/DBBooleanFactory.java | 2 +
.../apache/plc4x/merlot/db/core/DBByteFactory.java | 1 +
.../plc4x/merlot/db/core/DBDoubleFactory.java | 4 +-
.../plc4x/merlot/db/core/DBFloatFactory.java | 2 +-
.../apache/plc4x/merlot/db/core/DBIntFactory.java | 4 +-
.../apache/plc4x/merlot/db/core/DBLongFactory.java | 4 +-
.../merlot/db/core/DBRecordsManagedService.java | 2 +
.../plc4x/merlot/db/core/DBShortFactory.java | 1 +
.../plc4x/merlot/db/core/DBStringFactory.java | 1 +
.../plc4x/merlot/db/core/DBUByteFactory.java | 1 +
.../apache/plc4x/merlot/db/core/DBUIntFactory.java | 2 +-
.../plc4x/merlot/db/core/DBULongFactory.java | 2 +
.../plc4x/merlot/db/core/DBUShortFactory.java | 2 +
.../plc4x/merlot/db/impl/DBCollectorImpl.java | 4 +-
.../impl/SimulatedReferringDriverImpl.java | 11 +-
.../src/main/feature/feature.xml | 18 +-
.../modbus/sim/impl/ModbusSimSignalImpl.java | 2 -
.../scheduler/impl/SchedulerWhiteBoardImpl.java | 2 +-
plc4j/tools/merlot/org.apache.plc4x.merlot/pom.xml | 2 +-
40 files changed, 1029 insertions(+), 314 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 c63fcb9..e7b971e 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
@@ -182,5 +182,10 @@
<artifactId>commons-lang3</artifactId>
<version>3.14.0</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4j-driver-simulated</artifactId>
+ <version>0.13.0-SNAPSHOT</version>
+ </dependency>
</dependencies>
</project>
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 3ba9b4c..76c2eae 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
@@ -18,11 +18,14 @@
*/
package org.apache.plc4x.merlot.api;
+import io.netty.buffer.ByteBuf;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.plc4x.java.api.PlcDriver;
+import org.apache.plc4x.java.api.model.PlcTag;
+import org.apache.plc4x.java.api.types.PlcValueType;
import org.osgi.service.dal.DeviceException;
/*
@@ -127,5 +130,10 @@ public interface PlcDevice extends org.osgi.service.device.Device, org.osgi.serv
*/
public List<PlcGroup> getGroups();
+ /*
+ *
+ */
+ public String getWritePlcTag(PlcTag plcTag, ByteBuf byteBuf, String... args);
+
}
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 4e5896a..9ae529e 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
@@ -18,13 +18,16 @@
*/
package org.apache.plc4x.merlot.api;
+import com.lmax.disruptor.RingBuffer;
import io.netty.buffer.ByteBuf;
import java.util.Date;
import java.util.Hashtable;
import java.util.UUID;
import org.apache.plc4x.java.api.model.PlcTag;
import org.apache.plc4x.java.api.types.PlcResponseCode;
+import org.apache.plc4x.java.api.types.PlcValueType;
import org.apache.plc4x.java.api.value.PlcValue;
+import org.apache.plc4x.merlot.api.impl.PlcDeviceWriteEvent;
public interface PlcItem {
@@ -98,18 +101,13 @@ public interface PlcItem {
/*
*
*/
- public Boolean getEnable();
+ public Boolean isEnable();
/*
*
*/
public void setEnable(Boolean enable);
-
- /*
- *
- */
- public Boolean isEnable();
-
+
/*
*
*/
@@ -123,7 +121,7 @@ public interface PlcItem {
/*
*
*/
- public Boolean getIsDisableOutput();
+ public Boolean isDisableOutput();
/*
*
@@ -178,7 +176,7 @@ public interface PlcItem {
/*
*
*/
- public ByteBuf getItemByteBuf();
+ public ByteBuf getItemByteBuf();
/*
*
@@ -215,4 +213,14 @@ public interface PlcItem {
*/
public Date getLastErrorDate();
+ /*
+ *
+ */
+ public void setRingBuffer(RingBuffer<PlcDeviceWriteEvent> ringBuffer);
+
+ /*
+ *
+ */
+ public void itemWrite();
+
}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcModel.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcModel.java
new file mode 100644
index 0000000..e91c02d
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcModel.java
@@ -0,0 +1,25 @@
+/*
+ * 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.api;
+
+/*
+* PlcModel represents the internal data structure associated with a PLC,
+* RTU, etc. Exception or time-based subscriptions go against this model.
+*/
+public interface PlcModel {
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcModelFactory.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcModelFactory.java
new file mode 100644
index 0000000..f6221c7
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcModelFactory.java
@@ -0,0 +1,26 @@
+/*
+ * 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.api;
+
+/*
+* Objects that implement this interface are responsible for building
+* specific PlcModels. Each equipment model will have a specific structure.
+* For example, Modbus vs S7 vs Rockwell.
+*/
+public interface PlcModelFactory {
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/core/PlcItemClientService.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/core/PlcItemClientService.java
index 18ca5a5..2744abc 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/core/PlcItemClientService.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/core/PlcItemClientService.java
@@ -53,7 +53,7 @@ public class PlcItemClientService {
disruptor.handleEventsWith((event, sequence, endOfBatch) -> {
if (item_clients.containsKey(event.uid)) {
item_clients.get(event.uid).forEach(c -> c.execute(event.plcvalue));
- System.out.println("PlcValue: " + event.plcvalue);
+ LOGGER.info("PlcValue: " + event.plcvalue);
}
});
disruptor.start();
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcBatchEventProcessor.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcBatchEventProcessor.java
new file mode 100644
index 0000000..bb1d7b1
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcBatchEventProcessor.java
@@ -0,0 +1,349 @@
+/*
+ * Copyright 2022 LMAX Ltd.
+ *
+ * Licensed 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.api.impl;
+
+import com.lmax.disruptor.AlertException;
+import com.lmax.disruptor.BatchRewindStrategy;
+import com.lmax.disruptor.DataProvider;
+import com.lmax.disruptor.EventHandler;
+import com.lmax.disruptor.EventProcessor;
+import com.lmax.disruptor.ExceptionHandler;
+import com.lmax.disruptor.ExceptionHandlers;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import static com.lmax.disruptor.RewindAction.REWIND;
+import com.lmax.disruptor.RewindHandler;
+import com.lmax.disruptor.RewindableEventHandler;
+import com.lmax.disruptor.RewindableException;
+import com.lmax.disruptor.RingBuffer;
+import com.lmax.disruptor.Sequence;
+import com.lmax.disruptor.SequenceBarrier;
+import com.lmax.disruptor.Sequencer;
+import com.lmax.disruptor.TimeoutException;
+import static java.lang.Math.min;
+
+
+/**
+ * Convenience class for handling the batching semantics of consuming entries
+ * from a {@link RingBuffer} and delegating the available
+ * events to an {@link EventHandler}.
+ *
+ * Simple adaptation of BatchEventProcessor<T> from the Disruptor project to
+ * comply with read/write exclusion.
+ *
+ * @param <T> event implementation storing the data for sharing during exchange or parallel coordination of an event.
+ */
+public final class PlcBatchEventProcessor<T>
+ implements EventProcessor
+{
+ private static final int IDLE = 0;
+ private static final int HALTED = IDLE + 1;
+ private static final int RUNNING = HALTED + 1;
+ private static final int PAUSED = RUNNING + 1;
+
+ private final AtomicInteger running = new AtomicInteger(IDLE);
+ private ExceptionHandler<? super T> exceptionHandler;
+ private final DataProvider<T> dataProvider;
+ private final SequenceBarrier sequenceBarrier;
+ private final EventHandler<? super T> eventHandler;
+ private final int batchLimitOffset;
+ private final Sequence sequence = new Sequence(Sequencer.INITIAL_CURSOR_VALUE);
+ private final RewindHandler rewindHandler;
+ private int retriesAttempted = 0;
+
+ PlcBatchEventProcessor(
+ final DataProvider<T> dataProvider,
+ final SequenceBarrier sequenceBarrier,
+ final EventHandler<? super T> eventHandler,
+ final int maxBatchSize,
+ final BatchRewindStrategy batchRewindStrategy
+ )
+ {
+ this.dataProvider = dataProvider;
+ this.sequenceBarrier = sequenceBarrier;
+ this.eventHandler = eventHandler;
+
+ if (maxBatchSize < 1)
+ {
+ throw new IllegalArgumentException("maxBatchSize must be greater than 0");
+ }
+ this.batchLimitOffset = maxBatchSize - 1;
+
+ this.rewindHandler = eventHandler instanceof RewindableEventHandler
+ ? new TryRewindHandler(batchRewindStrategy)
+ : new NoRewindHandler();
+ }
+
+ @Override
+ public Sequence getSequence()
+ {
+ return sequence;
+ }
+
+ @Override
+ public void halt()
+ {
+ running.set(HALTED);
+ sequenceBarrier.alert();
+ }
+
+ public void pause()
+ {
+ running.set(PAUSED);
+ }
+
+ public void restart()
+ {
+ running.set(RUNNING);
+ }
+
+ @Override
+ public boolean isRunning()
+ {
+ return running.get() != IDLE;
+ }
+
+ /**
+ * Set a new {@link ExceptionHandler} for handling exceptions propagated out of the {@link BatchEventProcessor}.
+ *
+ * @param exceptionHandler to replace the existing exceptionHandler.
+ */
+ public void setExceptionHandler(final ExceptionHandler<? super T> exceptionHandler)
+ {
+ if (null == exceptionHandler)
+ {
+ throw new NullPointerException();
+ }
+
+ this.exceptionHandler = exceptionHandler;
+ }
+
+ /**
+ * It is ok to have another thread rerun this method after a halt().
+ *
+ * @throws IllegalStateException if this object instance is already running in a thread
+ */
+ @Override
+ public void run()
+ {
+ int witnessValue = running.compareAndExchange(IDLE, RUNNING);
+ if (witnessValue == IDLE) // Successful CAS
+ {
+ sequenceBarrier.clearAlert();
+
+ notifyStart();
+ try
+ {
+ if (running.get() == RUNNING)
+ {
+ processEvents();
+ }
+ }
+ finally
+ {
+ notifyShutdown();
+ running.set(IDLE);
+ }
+ }
+ else
+ {
+ if (witnessValue == RUNNING)
+ {
+ throw new IllegalStateException("Thread is already running");
+ }
+ else
+ {
+ earlyExit();
+ }
+ }
+ }
+
+ private void processEvents()
+ {
+ T event = null;
+ long nextSequence = sequence.get() + 1L;
+
+ while (true)
+ {
+ if (running.get() == PAUSED) continue;
+
+ final long startOfBatchSequence = nextSequence;
+ try
+ {
+ try
+ {
+ final long availableSequence = sequenceBarrier.waitFor(nextSequence);
+ final long endOfBatchSequence = min(nextSequence + batchLimitOffset, availableSequence);
+
+ if (nextSequence <= endOfBatchSequence)
+ {
+ eventHandler.onBatchStart(endOfBatchSequence - nextSequence + 1, availableSequence - nextSequence + 1);
+ }
+
+ while (nextSequence <= endOfBatchSequence)
+ {
+ event = dataProvider.get(nextSequence);
+ eventHandler.onEvent(event, nextSequence, nextSequence == endOfBatchSequence);
+ nextSequence++;
+ }
+
+ retriesAttempted = 0;
+
+ sequence.set(endOfBatchSequence);
+
+ //TODO: How disable the compiler catch error?
+ if (false) throw new RewindableException(null);
+ }
+ //No rewing Handler for this Object
+ catch (final RewindableException e)
+ {
+ nextSequence = rewindHandler.attemptRewindGetNextSequence(e, startOfBatchSequence);
+ }
+ }
+ catch (final TimeoutException e)
+ {
+ notifyTimeout(sequence.get());
+ }
+ catch (final AlertException ex)
+ {
+ if (running.get() != RUNNING)
+ {
+ break;
+ }
+ }
+ catch (final Throwable ex)
+ {
+ handleEventException(ex, nextSequence, event);
+ sequence.set(nextSequence);
+ nextSequence++;
+ }
+ }
+ }
+
+ private void earlyExit()
+ {
+ notifyStart();
+ notifyShutdown();
+ }
+
+ private void notifyTimeout(final long availableSequence)
+ {
+ try
+ {
+ eventHandler.onTimeout(availableSequence);
+ }
+ catch (Throwable e)
+ {
+ handleEventException(e, availableSequence, null);
+ }
+ }
+
+ /**
+ * Notifies the EventHandler when this processor is starting up.
+ */
+ private void notifyStart()
+ {
+ try
+ {
+ eventHandler.onStart();
+ }
+ catch (final Throwable ex)
+ {
+ handleOnStartException(ex);
+ }
+ }
+
+ /**
+ * Notifies the EventHandler immediately prior to this processor shutting down.
+ */
+ private void notifyShutdown()
+ {
+ try
+ {
+ eventHandler.onShutdown();
+ }
+ catch (final Throwable ex)
+ {
+ handleOnShutdownException(ex);
+ }
+ }
+
+ /**
+ * Delegate to {@link ExceptionHandler#handleEventException(Throwable, long, Object)} on the delegate or
+ * the default {@link ExceptionHandler} if one has not been configured.
+ */
+ private void handleEventException(final Throwable ex, final long sequence, final T event)
+ {
+ getExceptionHandler().handleEventException(ex, sequence, event);
+ }
+
+ /**
+ * Delegate to {@link ExceptionHandler#handleOnStartException(Throwable)} on the delegate or
+ * the default {@link ExceptionHandler} if one has not been configured.
+ */
+ private void handleOnStartException(final Throwable ex)
+ {
+ getExceptionHandler().handleOnStartException(ex);
+ }
+
+ /**
+ * Delegate to {@link ExceptionHandler#handleOnShutdownException(Throwable)} on the delegate or
+ * the default {@link ExceptionHandler} if one has not been configured.
+ */
+ private void handleOnShutdownException(final Throwable ex)
+ {
+ getExceptionHandler().handleOnShutdownException(ex);
+ }
+
+ private ExceptionHandler<? super T> getExceptionHandler()
+ {
+ ExceptionHandler<? super T> handler = exceptionHandler;
+ return handler == null ? ExceptionHandlers.defaultHandler() : handler;
+ }
+
+ private class TryRewindHandler implements RewindHandler
+ {
+ private final BatchRewindStrategy batchRewindStrategy;
+
+ TryRewindHandler(final BatchRewindStrategy batchRewindStrategy)
+ {
+ this.batchRewindStrategy = batchRewindStrategy;
+ }
+
+ @Override
+ public long attemptRewindGetNextSequence(final RewindableException e, final long startOfBatchSequence) throws RewindableException
+ {
+ if (batchRewindStrategy.handleRewindException(e, ++retriesAttempted) == REWIND)
+ {
+ return startOfBatchSequence;
+ }
+ else
+ {
+ retriesAttempted = 0;
+ throw e;
+ }
+ }
+ }
+
+ private static class NoRewindHandler implements RewindHandler
+ {
+ @Override
+ public long attemptRewindGetNextSequence(final RewindableException e, final long startOfBatchSequence)
+ {
+ throw new UnsupportedOperationException("Rewindable Exception thrown from a non-rewindable event handler", e);
+ }
+ }
+}
\ No newline at end of file
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 a1f6fd6..7df176c 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
@@ -17,16 +17,32 @@
package org.apache.plc4x.merlot.api.impl;
+import com.lmax.disruptor.RingBuffer;
+import com.lmax.disruptor.SequenceBarrier;
+import com.lmax.disruptor.dsl.Disruptor;
+import com.lmax.disruptor.util.DaemonThreadFactory;
+import io.netty.buffer.ByteBuf;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.UUID;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import static java.util.stream.Collectors.toList;
+import org.apache.commons.lang3.time.StopWatch;
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.api.PlcDriver;
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
+import org.apache.plc4x.java.api.messages.PlcReadRequest;
+import org.apache.plc4x.java.api.messages.PlcReadResponse;
+import org.apache.plc4x.java.api.messages.PlcWriteRequest;
+import org.apache.plc4x.java.api.messages.PlcWriteResponse;
+import org.apache.plc4x.java.api.model.PlcTag;
+import org.apache.plc4x.java.api.types.PlcValueType;
+import org.apache.plc4x.java.api.value.PlcValue;
+import org.apache.plc4x.java.simulated.tag.SimulatedTag;
import org.apache.plc4x.merlot.api.PlcDevice;
import org.osgi.framework.BundleContext;
import org.osgi.service.dal.Device;
@@ -35,6 +51,7 @@ import org.osgi.service.device.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.plc4x.merlot.api.PlcGroup;
+import org.apache.plc4x.merlot.api.PlcItem;
import org.apache.plc4x.merlot.scheduler.api.Job;
import org.osgi.framework.ServiceReference;
@@ -44,6 +61,10 @@ import org.osgi.framework.ServiceReference;
public class PlcDeviceImpl implements PlcDevice {
private static final Logger LOGGER = LoggerFactory.getLogger(PlcDeviceImpl.class);
+ private static final int BUFFER_SIZE = 1024;
+ private static final int DEFAULT_WRITE_BATCH_SIZE = 9;
+ private static final String WRITE_TASK_NAME = "write task";
+ private static final String READ_TASK_NAME = "read task";
private static final String FILTER_DEVICE = "(&(" +
org.osgi.framework.Constants.OBJECTCLASS +
@@ -58,59 +79,189 @@ public class PlcDeviceImpl implements PlcDevice {
AtomicReference<PlcConnection> refPlcConnection;
PlcConnection plcConnection = null;
- protected Hashtable<String, Object> myProperties;
+ protected Hashtable<String, Object> deviceProperties;
+
+ private final Map<UUID, PlcGroup> deviceGroups;
+
+ private StopWatch watch = new StopWatch();
+ int[] messageCounter = new int[2];
+
+ //
+ Disruptor<PlcDeviceReadEvent> readDisruptor =
+ new Disruptor<>(PlcDeviceReadEvent::new, BUFFER_SIZE, DaemonThreadFactory.INSTANCE);
+ RingBuffer<PlcDeviceReadEvent> readRingBuffer = readDisruptor.getRingBuffer();
+ private Thread threadReadProcessor = null;
+
+ Disruptor<PlcDeviceWriteEvent> writeDisruptor =
+ new Disruptor<>(PlcDeviceWriteEvent::new, BUFFER_SIZE, DaemonThreadFactory.INSTANCE);
+ RingBuffer<PlcDeviceWriteEvent> writeRingBuffer = writeDisruptor.getRingBuffer();
+ private Thread threadWriteProcessor = null;
+
- private final Map<UUID, PlcGroup> device_groups;
public PlcDeviceImpl(PlcDeviceBuilder builder) {
this.refPlcConnection = new AtomicReference<PlcConnection>();
- this.myProperties = new Hashtable<String, Object>();
- this.device_groups = new HashMap<UUID, PlcGroup>();
+ this.deviceProperties = new Hashtable<String, Object>();
+ this.deviceGroups = new HashMap<UUID, PlcGroup>();
this.bc = builder.bc;
- myProperties.put(PlcDevice.SERVICE_DRIVER, builder.service_driver);
- myProperties.put(PlcDevice.SERVICE_NAME, builder.service_name);
- myProperties.put(PlcDevice.SERVICE_DESCRIPTION, builder.service_description);
+ deviceProperties.put(PlcDevice.SERVICE_DRIVER, builder.service_driver);
+ deviceProperties.put(PlcDevice.SERVICE_NAME, builder.service_name);
+ deviceProperties.put(PlcDevice.SERVICE_DESCRIPTION, builder.service_description);
if (null != builder.service_uid) {
- myProperties.put(PlcDevice.SERVICE_UID, builder.service_uid.toString());
+ deviceProperties.put(PlcDevice.SERVICE_UID, builder.service_uid.toString());
} else {
- myProperties.put(PlcDevice.SERVICE_UID, UUID.randomUUID().toString());
+ deviceProperties.put(PlcDevice.SERVICE_UID, UUID.randomUUID().toString());
}
- if (null != builder.device_category) myProperties.put(Constants.DEVICE_CATEGORY, builder.device_category);
- if (null != builder.service_firmware_vendor) myProperties.put(Device.SERVICE_FIRMWARE_VENDOR, builder.service_firmware_vendor);
- if (null != builder.service_firmware_version) myProperties.put(Device.SERVICE_FIRMWARE_VERSION, builder.service_firmware_version);
- if (null != builder.service_hardware_vendor) myProperties.put(Device.SERVICE_HARDWARE_VENDOR, builder.service_hardware_vendor);
- if (null != builder.service_hardware_version) myProperties.put(Device.SERVICE_HARDWARE_VERSION, builder.service_hardware_version);
- if (null != builder.service_model) myProperties.put(Device.SERVICE_MODEL, builder.service_model);
- if (null != builder.service_reference_uids) myProperties.put(Device.SERVICE_REFERENCE_UIDS, builder.service_reference_uids);
- if (null != builder.service_serial_number) myProperties.put(Device.SERVICE_SERIAL_NUMBER, builder.service_serial_number);
- if (null != builder.service_status) myProperties.put(Device.SERVICE_STATUS, builder.service_status);
- if (null != builder.service_status_detail) myProperties.put(Device.SERVICE_STATUS_DETAIL, builder.service_status_detail);
- if (null != builder.service_types) myProperties.put(Device.SERVICE_TYPES, builder.service_types);
+ if (null != builder.device_category) deviceProperties.put(Constants.DEVICE_CATEGORY, builder.device_category);
+ if (null != builder.service_firmware_vendor) deviceProperties.put(Device.SERVICE_FIRMWARE_VENDOR, builder.service_firmware_vendor);
+ if (null != builder.service_firmware_version) deviceProperties.put(Device.SERVICE_FIRMWARE_VERSION, builder.service_firmware_version);
+ if (null != builder.service_hardware_vendor) deviceProperties.put(Device.SERVICE_HARDWARE_VENDOR, builder.service_hardware_vendor);
+ if (null != builder.service_hardware_version) deviceProperties.put(Device.SERVICE_HARDWARE_VERSION, builder.service_hardware_version);
+ if (null != builder.service_model) deviceProperties.put(Device.SERVICE_MODEL, builder.service_model);
+ if (null != builder.service_reference_uids) deviceProperties.put(Device.SERVICE_REFERENCE_UIDS, builder.service_reference_uids);
+ if (null != builder.service_serial_number) deviceProperties.put(Device.SERVICE_SERIAL_NUMBER, builder.service_serial_number);
+ if (null != builder.service_status) deviceProperties.put(Device.SERVICE_STATUS, builder.service_status);
+ if (null != builder.service_status_detail) deviceProperties.put(Device.SERVICE_STATUS_DETAIL, builder.service_status_detail);
+ if (null != builder.service_types) deviceProperties.put(Device.SERVICE_TYPES, builder.service_types);
}
@Override
public void init() throws Exception {
- //
+ //Prepare Disruptor for execute and launches the threads.
+ final SequenceBarrier readSequenceBarrier = readRingBuffer.newBarrier();
+
+ final PlcBatchEventProcessor<PlcDeviceReadEvent> readProcessor =
+ new PlcBatchEventProcessor<PlcDeviceReadEvent>(
+ readRingBuffer,
+ readSequenceBarrier,
+ (event, sequence, endofbatch)->{
+
+ if (null != event.getPlcGroup()){
+ if (null != plcConnection) {
+ if (refPlcConnection.get().isConnected()) {
+ watch.start();
+ final PlcReadRequest.Builder builder = refPlcConnection.get().readRequestBuilder();
+ event.getPlcGroup().getGroupItems().forEach((u,i) ->{
+ if (i.isEnable()) {
+ builder.addTagAddress(u.toString(), i.getItemId());
+ }
+ });
+ final PlcReadRequest readRequest = builder.build();
+ try {
+ final PlcReadResponse syncResponse = readRequest.execute().get();
+ event.getPlcGroup().getGroupItems().forEach((u,i) -> {
+ final PlcValue plcValue = syncResponse.getPlcValue(u.toString());
+ if (null == plcValue) {
+ LOGGER.info(u.toString() + " Null value");
+ } else
+ i.setPlcValue(plcValue);
+ });
+
+ } catch (Exception ex) {
+ LOGGER.info(ex.getMessage());
+ }
+ watch.stop();
+ LOGGER.debug("Elapse time: " + watch.getTime());
+ watch.reset();
+ } else {
+ LOGGER.info("The driver is disconnected.");
+ }
+ } else {
+ LOGGER.info("Unassigned connection.");
+ }
+ }
+ },
+ 4,
+ null);
+
+ readRingBuffer.addGatingSequences(readProcessor.getSequence());
+
+ final SequenceBarrier writeSequenceBarrier = writeRingBuffer.newBarrier();
+
+ messageCounter[0] = 0;
+ final PlcBatchEventProcessor<PlcDeviceWriteEvent> writeProcessor =
+ new PlcBatchEventProcessor<PlcDeviceWriteEvent>(
+ writeRingBuffer,
+ writeSequenceBarrier,
+ (event, sequence, endofbatch)->{
+ if (null != event.getPlcItem()){
+ if (null != plcConnection) {
+ if (refPlcConnection.get().isConnected()) {
+ watch.start();
+ if (messageCounter[0] == 0) {
+ readProcessor.pause();
+ }
+
+ messageCounter[0]++;
+
+ final PlcItem plcItem = event.getPlcItem();
+ final PlcTag plcTag = plcItem.getItemPlcTag();
+
+ String strTag = getWritePlcTag(plcTag,
+ event.getByteBuf());
+
+ final PlcWriteRequest writeRequest =
+ refPlcConnection.get().writeRequestBuilder().
+ addTagAddress("bar", strTag, event.getByteBuf().array()).
+ build();
+
+ //TODO: Agregar tiempo de supervision
+ PlcWriteResponse writeResponse =
+ writeRequest.execute().get();
+
+ LOGGER.info("Write to: " + event.getByteBuf().array());
+ watch.stop();
+ LOGGER.debug("Elapse time: " + watch.getTime());
+ watch.reset();
+ if ((messageCounter[0] > DEFAULT_WRITE_BATCH_SIZE) || (endofbatch)) {
+ readProcessor.pause();
+ messageCounter[0] = 0;
+ }
+
+ }
+ }
+ }
+ },
+ 4,
+ null);
+
+ writeRingBuffer.addGatingSequences(writeProcessor.getSequence());
+
+ //TODO: Lanzar las tareas.
+ threadWriteProcessor = new Thread(writeProcessor);
+ threadWriteProcessor.setName(this.getDeviceName() + WRITE_TASK_NAME);
+ threadWriteProcessor.start();
+
+ threadReadProcessor = new Thread(readProcessor);
+ threadReadProcessor.setName(this.getDeviceName() + READ_TASK_NAME);
+ threadReadProcessor.start();
+
}
@Override
public void destroy() throws Exception {
- //
+ //Shutdown Disruptor and threads.
+ threadReadProcessor.interrupt();
+ threadWriteProcessor.interrupt();
+
+ writeDisruptor.shutdown();
+ readDisruptor.shutdown();
+
}
@Override
public void enable() {
if (null != plcDriver) {
//Try to connect
- final String url = (String) myProperties.get(Device.SERVICE_DRIVER);
+ final String url = (String) deviceProperties.get(Device.SERVICE_DRIVER);
try {
plcConnection = plcDriver.getConnection(url);
plcConnection.connect();
refPlcConnection.set(plcConnection);
if (plcConnection.isConnected()) {
enable = true;
- LOGGER.info("Device [{}] was enbale.", myProperties.get(Device.SERVICE_NAME));
+ LOGGER.info("Device [{}] was enbale.", deviceProperties.get(Device.SERVICE_NAME));
} else {
LOGGER.info("The connection could not be established, check the url.");
}
@@ -126,17 +277,17 @@ public class PlcDeviceImpl implements PlcDevice {
@Override
public void disable() {
enable = false;
- LOGGER.info("Device [{}] was disable.", myProperties.get(Device.SERVICE_NAME));
+ LOGGER.info("Device [{}] was disable.", deviceProperties.get(Device.SERVICE_NAME));
try {
if (null != plcConnection) {
//All groups are disabled for security, they are activated
//individually manually. Simple job to do when the IDE
//is available.
- device_groups.forEach((u, d) -> d.disable());
+ deviceGroups.forEach((u, d) -> d.disable());
plcConnection.close();
if (!plcConnection.isConnected()) {
enable = false;
- LOGGER.info("Device [{}] connection was close.", myProperties.get(Device.SERVICE_NAME));
+ LOGGER.info("Device [{}] connection was close.", deviceProperties.get(Device.SERVICE_NAME));
}
}
} catch (Exception ex) {
@@ -151,57 +302,57 @@ public class PlcDeviceImpl implements PlcDevice {
@Override
public Hashtable<String, ?> getProperties() {
- return myProperties;
+ return deviceProperties;
}
@Override
public String getDeviceName() {
- return (String) myProperties.get(Device.SERVICE_NAME);
+ return (String) deviceProperties.get(Device.SERVICE_NAME);
}
@Override
public void setDeviceName(String devicename) {
- myProperties.put(Device.SERVICE_NAME, devicename);
+ deviceProperties.put(Device.SERVICE_NAME, devicename);
}
@Override
public String getDeviceDescription() {
- return (String) myProperties.get(Device.SERVICE_DESCRIPTION);
+ return (String) deviceProperties.get(Device.SERVICE_DESCRIPTION);
}
@Override
public void setDeviceDescription(String devicedescription) {
- myProperties.put(Device.SERVICE_DESCRIPTION, devicedescription);
+ deviceProperties.put(Device.SERVICE_DESCRIPTION, devicedescription);
}
@Override
public void setUid(UUID uid) {
- myProperties.put(PlcDevice.SERVICE_UID, uid.toString());
+ deviceProperties.put(PlcDevice.SERVICE_UID, uid.toString());
}
@Override
public UUID getUid() {
- return UUID.fromString((String) myProperties.get(PlcDevice.SERVICE_UID));
+ return UUID.fromString((String) deviceProperties.get(PlcDevice.SERVICE_UID));
}
@Override
public void setUrl(String url) {
if (!enable) {
- myProperties.put(Device.SERVICE_DRIVER, url);
+ deviceProperties.put(Device.SERVICE_DRIVER, url);
}
}
@Override
public String getUrl() {
- return (String) myProperties.get(Device.SERVICE_DRIVER);
+ return (String) deviceProperties.get(Device.SERVICE_DRIVER);
}
@Override
public void putGroup(PlcGroup group) {
- if ((!enable) && (!device_groups.containsKey(group.getGroupUid()))) {
- group.setGroupDeviceUid(UUID.fromString((String) myProperties.get(PlcDevice.SERVICE_UID)));
+ if ((!enable) && (!deviceGroups.containsKey(group.getGroupUid()))) {
+ group.setGroupDeviceUid(UUID.fromString((String) deviceProperties.get(PlcDevice.SERVICE_UID)));
group.setPlcConnection(refPlcConnection);
- device_groups.put(group.getGroupUid(), group);
+ deviceGroups.put(group.getGroupUid(), group);
bc.registerService(new String[]{Job.class.getName(),
PlcGroup.class.getName()},
group,
@@ -213,7 +364,7 @@ public class PlcDeviceImpl implements PlcDevice {
@Override
public PlcGroup getGroup(UUID uid) {
- return device_groups.get(uid);
+ return deviceGroups.get(uid);
}
@Override
@@ -221,12 +372,12 @@ public class PlcDeviceImpl implements PlcDevice {
String filter = FILTER_DEVICE.replace("*", uid.toString());
ServiceReference<?> sr = bc.getServiceReference(filter);
bc.ungetService(sr);
- device_groups.remove(uid);
+ deviceGroups.remove(uid);
}
@Override
public List<PlcGroup> getGroups() {
- return device_groups.values().stream().
+ return deviceGroups.values().stream().
collect(toList());
}
@@ -237,12 +388,12 @@ public class PlcDeviceImpl implements PlcDevice {
@Override
public Object getServiceProperty(String propKey) {
- return myProperties.get(propKey);
+ return deviceProperties.get(propKey);
}
@Override
public String[] getServicePropertyKeys() {
- return myProperties.keySet().toArray(new String[myProperties.size()]);
+ return deviceProperties.keySet().toArray(new String[deviceProperties.size()]);
}
@Override
@@ -252,11 +403,39 @@ public class PlcDeviceImpl implements PlcDevice {
@Override
public void attach(PlcDriver driver) {
- LOGGER.info("Device: {} attach to driver {} ", myProperties.get(Device.SERVICE_NAME), driver.getProtocolCode());
+ LOGGER.info("Device: {} attach to driver {} ", deviceProperties.get(Device.SERVICE_NAME), driver.getProtocolCode());
this.plcDriver = driver;
}
-
+ @Override
+ public String getWritePlcTag(PlcTag plcTag, ByteBuf byteBuf, String... args) {
+ String strTag = null;
+ if (plcTag instanceof SimulatedTag) {
+ final SimulatedTag localTag = (SimulatedTag) plcTag;
+ switch (plcTag.getPlcValueType()) {
+ case BOOL:;
+ strTag = localTag.getType().name() + "/" +
+ localTag.getName() +
+ ":BOOL" +
+ "[" +
+ byteBuf.capacity() +
+ "]";
+ break;
+ case BYTE:;
+ strTag = localTag.getType().name() + "/" +
+ localTag.getName() +
+ ":BYTE" +
+ "[" +
+ byteBuf.capacity() +
+ "]";
+ break;
+
+ };
+ }
+
+ return strTag;
+ }
+
public static class PlcDeviceBuilder {
private final BundleContext bc;
private final String service_name;
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcDeviceReadEvent.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcDeviceReadEvent.java
new file mode 100644
index 0000000..135731f
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcDeviceReadEvent.java
@@ -0,0 +1,33 @@
+/*
+ * 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.api.impl;
+
+import org.apache.plc4x.merlot.api.PlcGroup;
+
+public class PlcDeviceReadEvent {
+ private PlcGroup plcGroup;
+
+ public PlcGroup getPlcGroup() {
+ return plcGroup;
+ }
+
+ public void setPlcGroup(final PlcGroup plcGroup) {
+ this.plcGroup = plcGroup;
+ }
+
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcDeviceWriteEvent.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcDeviceWriteEvent.java
new file mode 100644
index 0000000..02710da
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcDeviceWriteEvent.java
@@ -0,0 +1,52 @@
+/*
+ * 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.api.impl;
+
+import io.netty.buffer.ByteBuf;
+import org.apache.plc4x.merlot.api.PlcItem;
+
+public class PlcDeviceWriteEvent {
+ private PlcItem plcItem;
+ private ByteBuf byteBuf;
+ private int offset;
+
+ public PlcItem getPlcItem() {
+ return plcItem;
+ }
+
+ public void setPlcItem(final PlcItem plcItem) {
+ this.plcItem = plcItem;
+ }
+
+ public ByteBuf getByteBuf(){
+ return byteBuf;
+ }
+
+ public void setByteBuf(ByteBuf byteBuf){
+ this.byteBuf = byteBuf;
+ }
+
+ public int getOffset() {
+ return offset;
+ }
+
+ public void setOffset(int offset) {
+ this.offset = offset;
+ }
+
+
+}
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 c8a4399..0bfe422 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,7 +16,6 @@
*/
package org.apache.plc4x.merlot.api.impl;
-import java.util.Collection;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
@@ -27,7 +26,6 @@ import org.apache.commons.lang3.time.StopWatch;
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.api.messages.PlcReadRequest;
import org.apache.plc4x.java.api.messages.PlcReadResponse;
-import org.apache.plc4x.java.api.types.PlcResponseCode;
import org.apache.plc4x.java.api.value.PlcValue;
import org.apache.plc4x.merlot.scheduler.api.Job;
import org.apache.plc4x.merlot.scheduler.api.JobContext;
@@ -48,22 +46,22 @@ public class PlcGroupImpl implements PlcGroup, Job {
protected final BundleContext bc;
- private UUID uid;
+ private UUID groupUid;
private boolean enable = false;
- private long grouptransmit = 0;
- private long groupreceives = 0;
- private long grouperrors = 0;
+ private long groupTransmit = 0;
+ private long groupReceives = 0;
+ private long groupErrors = 0;
- private long groupitems = 0;
- private long groupupdatrate = -1;
+ private long groupItemsLength = 0;
+ private long groupUpdateRate = -1;
- private final Hashtable<String, Object> myproperties;
+ private final Hashtable<String, Object> groupProperties;
- private final Map<UUID, PlcItem> group_items;
+ private final Map<UUID, PlcItem> groupItems;
- private PlcItemClientService items_service = null;
+ private PlcItemClientService groupItemsService = null;
private AtomicReference<PlcConnection> plcConnection = null;
private PlcReadRequest.Builder builder = null;
@@ -75,19 +73,19 @@ public class PlcGroupImpl implements PlcGroup, Job {
public PlcGroupImpl(PlcGroupBuilder builder) {
this.bc = builder.bc;
- this.items_service = builder.items_service;
- this.group_items = new Hashtable<>();
- this.myproperties = new Hashtable<>();
-
- myproperties.put(PlcGroup.GROUP_UID, builder.group_uid.toString());
- myproperties.put(PlcGroup.GROUP_NAME, builder.group_name);
- if (null != builder.device_uid)
- myproperties.put(PlcGroup.GROUP_DEVICE_UID, builder.device_uid);
-
- myproperties.put(PlcGroup.GROUP_DESCRIPTION, builder.group_description);
- myproperties.put(PlcGroup.GROUP_CONCURRENT, false);
- myproperties.put(PlcGroup.GROUP_IMMEDIATE, true);
- myproperties.put(PlcGroup.GROUP_PERIOD, builder.group_period);
+ this.groupItemsService = builder.groupItemsService;
+ this.groupItems = new Hashtable<>();
+ this.groupProperties = new Hashtable<>();
+
+ groupProperties.put(PlcGroup.GROUP_UID, builder.groupUid.toString());
+ groupProperties.put(PlcGroup.GROUP_NAME, builder.groupName);
+ if (null != builder.groupDeviceUid)
+ groupProperties.put(PlcGroup.GROUP_DEVICE_UID, builder.groupDeviceUid);
+
+ groupProperties.put(PlcGroup.GROUP_DESCRIPTION, builder.groupDescription);
+ groupProperties.put(PlcGroup.GROUP_CONCURRENT, false);
+ groupProperties.put(PlcGroup.GROUP_IMMEDIATE, true);
+ groupProperties.put(PlcGroup.GROUP_PERIOD, builder.groupPeriod);
}
@@ -122,37 +120,37 @@ public class PlcGroupImpl implements PlcGroup, Job {
@Override
public UUID getGroupUid() {
- return UUID.fromString((String) myproperties.get(PlcGroup.GROUP_UID));
+ return UUID.fromString((String) groupProperties.get(PlcGroup.GROUP_UID));
}
@Override
public UUID getGroupDeviceUid() {
- return (UUID) myproperties.get(PlcGroup.GROUP_DEVICE_UID);
+ return (UUID) groupProperties.get(PlcGroup.GROUP_DEVICE_UID);
}
@Override
- public void setGroupDeviceUid(UUID device_uid) {
- myproperties.put(PlcGroup.GROUP_DEVICE_UID, device_uid);
+ public void setGroupDeviceUid(UUID groupDeviceUid) {
+ groupProperties.put(PlcGroup.GROUP_DEVICE_UID, groupDeviceUid);
}
@Override
public String getGroupName() {
- return (String) myproperties.get(PlcGroup.GROUP_NAME);
+ return (String) groupProperties.get(PlcGroup.GROUP_NAME);
}
@Override
public void setGroupName(String groupname) {
- myproperties.put(PlcGroup.GROUP_NAME, groupname);
+ groupProperties.put(PlcGroup.GROUP_NAME, groupname);
}
@Override
public String getGroupDescription() {
- return (String) myproperties.get(PlcGroup.GROUP_DESCRIPTION);
+ return (String) groupProperties.get(PlcGroup.GROUP_DESCRIPTION);
}
@Override
public void setGroupDescription(String groupdescription) {
- myproperties.put(PlcGroup.GROUP_DESCRIPTION, groupdescription);
+ groupProperties.put(PlcGroup.GROUP_DESCRIPTION, groupdescription);
}
@Override
@@ -162,81 +160,81 @@ public class PlcGroupImpl implements PlcGroup, Job {
@Override
public long getPeriod() {
- return (long) myproperties.get(PlcGroup.GROUP_PERIOD);
+ return (long) groupProperties.get(PlcGroup.GROUP_PERIOD);
}
@Override
public void setPeriod(long period) {
- myproperties.put(PlcGroup.GROUP_PERIOD, (period < 100)?100:period);
+ groupProperties.put(PlcGroup.GROUP_PERIOD, (period < 100)?100:period);
}
@Override
public long getGroupTransmit() {
aux[0] = 0;
- group_items.forEach((uid, item) -> {aux[0] = +item.getItemTransmits();});
+ groupItems.forEach((groupUid, item) -> {aux[0] = +item.getItemTransmits();});
return aux[0];
}
@Override
public long getGroupReceives() {
aux[0] = 0;
- group_items.forEach((uid, item) -> {aux[0] = +item.getItemReceives();});
+ groupItems.forEach((groupUid, item) -> {aux[0] = +item.getItemReceives();});
return aux[0];
}
@Override
public long getGroupErrors() {
aux[0] = 0;
- group_items.forEach((uid, item) -> {aux[0] = +item.getItemErrors();});
+ groupItems.forEach((groupUid, item) -> {aux[0] = +item.getItemErrors();});
return aux[0];
}
@Override
public void setPlcConnection(AtomicReference<PlcConnection> plcConnection) {
- LOGGER.info("Grupo [{}] Volatile: Se asigno la conexión.", myproperties.get(PlcGroup.GROUP_NAME));
+ LOGGER.info("Grupo [{}] Volatile: Se asigno la conexión.", groupProperties.get(PlcGroup.GROUP_NAME));
this.plcConnection = plcConnection;
}
@Override
public Map<UUID, PlcItem> getGroupItems() {
- return group_items;
+ return groupItems;
}
@Override
- public void setGroupItems(long groupitems) {
+ public void setGroupItems(long groupItems) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Hashtable<String, Object> getProperties() {
- return myproperties;
+ return groupProperties;
}
@Override
public void putItem(PlcItem item) {
- if (!group_items.containsKey(item.getItemUid())) {
- group_items.put(item.getItemUid(), item);
+ if (!groupItems.containsKey(item.getItemUid())) {
+ groupItems.put(item.getItemUid(), item);
bc.registerService(PlcItem.class.getName(), item, item.getProperties());
}
}
@Override
- public PlcItem getItem(UUID itemuid) {
- return group_items.get(itemuid);
+ public PlcItem getItem(UUID itemgroupUid) {
+ return groupItems.get(itemgroupUid);
}
//TODO: remove from context
@Override
- public void removeItem(UUID itemuid) {
- String filter = FILTER_ITEM.replace("*", itemuid.toString());
+ public void removeItem(UUID itemgroupUid) {
+ String filter = FILTER_ITEM.replace("*", itemgroupUid.toString());
ServiceReference<?> sr = bc.getServiceReference(filter);
bc.ungetService(sr);
- group_items.remove(itemuid);
+ groupItems.remove(itemgroupUid);
}
@Override
public List<PlcItem> getItems() {
- return group_items.values().stream().
+ return groupItems.values().stream().
collect(Collectors.toList());
}
@@ -248,7 +246,7 @@ public class PlcGroupImpl implements PlcGroup, Job {
watch.start();
executeReadAllItems();
watch.stop();
- System.out.println("Elapse time: " + watch.getTime());
+ LOGGER.info("Elapse time: " + watch.getTime());
watch.reset();
} else {
LOGGER.info("The driver is disconnected.");
@@ -258,8 +256,8 @@ public class PlcGroupImpl implements PlcGroup, Job {
}
} else {
LOGGER.info("The group {}:{} is disable.",
- ((String) myproperties.get(PlcGroup.GROUP_NAME)),
- ((String) myproperties.get(PlcGroup.GROUP_UID)));
+ ((String) groupProperties.get(PlcGroup.GROUP_NAME)),
+ ((String) groupProperties.get(PlcGroup.GROUP_UID)));
}
}
@@ -267,10 +265,10 @@ public class PlcGroupImpl implements PlcGroup, Job {
* Execute the read function for all items
*
*/
- private void executeReadAllItems() {
+ public void executeReadAllItems() {
//1. The item was
builder = plcConnection.get().readRequestBuilder();
- group_items.forEach((u,i) ->{
+ groupItems.forEach((u,i) ->{
if (i.isEnable()) {
builder.addTagAddress(u.toString(), i.getItemId());
}
@@ -278,12 +276,10 @@ public class PlcGroupImpl implements PlcGroup, Job {
final PlcReadRequest readRequest = builder.build();
try {
PlcReadResponse syncResponse = readRequest.execute().get();
- group_items.forEach((u,i) -> {
- System.out.println(i.getItemName());
+ groupItems.forEach((u,i) -> {
final PlcValue plcvalue = syncResponse.getPlcValue(u.toString());
- if (null == plcvalue) System.out.println("Valor nulo");
- System.out.println(i.getItemName() + " : " + plcvalue.getInt());
- items_service.putItemEvent(u, plcvalue);
+ if (null == plcvalue) LOGGER.info("Valor nulo");
+ groupItemsService.putItemEvent(u, plcvalue);
});
} catch (Exception ex) {
@@ -293,40 +289,40 @@ public class PlcGroupImpl implements PlcGroup, Job {
public static class PlcGroupBuilder {
protected final BundleContext bc;
- private final String group_name;
- private String group_description;
- private UUID group_uid;
- private UUID device_uid = null;
+ private final String groupName;
+ private String groupDescription;
+ private UUID groupUid;
+ private UUID groupDeviceUid = null;
private boolean group_enable = false;
- private long group_period = 100;
- private PlcItemClientService items_service = null;
+ private long groupPeriod = 100;
+ private PlcItemClientService groupItemsService = null;
- public PlcGroupBuilder(BundleContext bc, String group_name, UUID group_uid) {
+ public PlcGroupBuilder(BundleContext bc, String groupName, UUID group_groupUid) {
this.bc = bc;
- this.group_name = group_name;
- this.group_uid = group_uid;
- this.group_description = "";
+ this.groupName = groupName;
+ this.groupUid = group_groupUid;
+ this.groupDescription = "";
}
- public PlcGroupBuilder(BundleContext bc, String group_name) {
+ public PlcGroupBuilder(BundleContext bc, String groupName) {
this.bc = bc;
- this.group_name = group_name;
- this.group_uid = UUID.randomUUID();
- this.group_description = "";
+ this.groupName = groupName;
+ this.groupUid = UUID.randomUUID();
+ this.groupDescription = "";
}
- public PlcGroupBuilder setGroupDescription(String group_description) {
- this.group_description = group_description;
+ public PlcGroupBuilder setGroupDescription(String groupDescription) {
+ this.groupDescription = groupDescription;
return this;
}
- public PlcGroupBuilder setGroupUid(UUID group_uid) {
- this.group_uid = group_uid;
+ public PlcGroupBuilder setGroupUid(UUID group_groupUid) {
+ this.groupUid = group_groupUid;
return this;
}
- public PlcGroupBuilder setGroupDeviceUid(UUID device_uid) {
- this.device_uid = device_uid;
+ public PlcGroupBuilder setGroupDeviceUid(UUID groupDeviceUid) {
+ this.groupDeviceUid = groupDeviceUid;
return this;
}
@@ -335,13 +331,13 @@ public class PlcGroupImpl implements PlcGroup, Job {
return this;
}
- public PlcGroupBuilder setGroupPeriod(long group_period) {
- this.group_period = group_period;
+ public PlcGroupBuilder setGroupPeriod(long groupPeriod) {
+ this.groupPeriod = groupPeriod;
return this;
}
- public PlcGroupBuilder setItemService(PlcItemClientService items_service) {
- this.items_service = items_service;
+ public PlcGroupBuilder setItemService(PlcItemClientService groupItemsService) {
+ this.groupItemsService = groupItemsService;
return this;
}
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 3383ba9..aecae77 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
@@ -18,11 +18,11 @@
*/
package org.apache.plc4x.merlot.api.impl;
+import com.lmax.disruptor.RingBuffer;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import java.time.LocalDate;
import java.time.ZoneOffset;
-import java.util.Collection;
import java.util.Date;
import java.util.Hashtable;
import java.util.LinkedList;
@@ -42,185 +42,180 @@ import org.apache.plc4x.merlot.api.PlcItemListener;
public class PlcItemImpl implements PlcItem {
private ReentrantLock lock = new ReentrantLock();
- private String item_name;
- private String item_description;
- private String item_id;
- private UUID item_uid;
+ private String itemName;
+ private String itemDescription;
+ private String itemId;
+ private UUID itemUid;
- private boolean item_enable = false;
+ private boolean itemEnable = false;
- private int item_accessrigths = 0;
+ private int itemAccessrigths = 0;
- private Boolean item_isarray = false;
- private Boolean item_disableoutput = false;
+ private Boolean itemIsArray = false;
+ private Boolean itemDisableOutput = false;
- private final Hashtable<String, Object> myproperties;
+ private final Hashtable<String, Object> itemProperties;
- private PlcTag item_plctag = null;
- private PlcValue item_plcvalue = null;
+ private PlcTag itemPlcTag = null;
+ private PlcValue itemPlcValue = null;
- private LinkedList<PlcItemListener> item_clients = null;
- private ByteBuf item_buffer = null;
-
-
- private long itemtransmit = 0;
- private long itemreceives = 0;
- private long itemerrors = 0;
-
+ private LinkedList<PlcItemListener> itemClients = null;
+ private ByteBuf itemBuffer = null;
+
+ private long itemTransmit = 0;
+ private long itemReceives = 0;
+ private long itemErrors = 0;
- private PlcReadResponse plcresponse;
- private PlcResponseCode dataquality;
+ private PlcReadResponse plcResponse;
+ private PlcResponseCode plcDataquality;
- private Date lastreadtime;
- private Date lastwritetime;
- private Date lasterrortime;
+ private Date lastReadDate;
+ private Date lastWriteDate;
+ private Date lastErrorDate;
+
+ private RingBuffer<PlcDeviceWriteEvent> ringBuffer;
public PlcItemImpl(PlcItemBuilder builder) {
- this.myproperties = new Hashtable<>();
+ this.itemProperties = new Hashtable<>();
- myproperties.put(PlcItem.ITEM_NAME, builder.item_name);
- item_name = builder.item_name;
+ itemProperties.put(PlcItem.ITEM_NAME, builder.itemName);
+ itemName = builder.itemName;
- myproperties.put(PlcItem.ITEM_DESCRIPTION, builder.item_description);
- item_description = builder.item_description;
+ itemProperties.put(PlcItem.ITEM_DESCRIPTION, builder.itemDescription);
+ itemDescription = builder.itemDescription;
- myproperties.put(PlcItem.ITEM_UID, builder.item_uid.toString());
- item_uid = builder.item_uid;
+ itemProperties.put(PlcItem.ITEM_UID, builder.itemUid.toString());
+ itemUid = builder.itemUid;
- myproperties.put(PlcItem.ITEM_ID, builder.item_id);
- item_id = builder.item_id;
+ itemProperties.put(PlcItem.ITEM_ID, builder.itemId);
+ itemId = builder.itemId;
- item_enable = builder.item_enable;
- item_accessrigths = builder.item_accessrigths;
+ itemEnable = builder.itemEnable;
+ itemAccessrigths = builder.itemAccessrigths;
- item_isarray = builder.item_isarray;
- item_disableoutput = builder.item_disableoutput;
+ itemIsArray = builder.itemIsArray;
+ itemDisableOutput = builder.itemDisableOutput;
- item_buffer = Unpooled.buffer();
- item_clients = new LinkedList<>();
+ itemBuffer = Unpooled.buffer();
+ itemClients = new LinkedList<>();
}
@Override
public void enable() {
- item_enable = true;
+ itemEnable = true;
}
@Override
public void disable() {
- item_enable = false;
+ itemEnable = false;
}
@Override
public UUID getItemUid() {
- return UUID.fromString((String) myproperties.get(PlcItem.ITEM_UID));
+ return UUID.fromString((String) itemProperties.get(PlcItem.ITEM_UID));
}
@Override
public String getItemName() {
- return (String) myproperties.get(PlcItem.ITEM_NAME);
+ return (String) itemProperties.get(PlcItem.ITEM_NAME);
}
@Override
public void setItemName(String itemname) {
- myproperties.put(PlcItem.ITEM_NAME, item_name);
+ itemProperties.put(PlcItem.ITEM_NAME, itemName);
}
@Override
public String getItemDescription() {
- return (String) myproperties.get(PlcItem.ITEM_DESCRIPTION);
+ return (String) itemProperties.get(PlcItem.ITEM_DESCRIPTION);
}
@Override
- public void setItemDescription(String item_description) {
- myproperties.put(PlcItem.ITEM_DESCRIPTION, item_description);
+ public void setItemDescription(String itemDescription) {
+ itemProperties.put(PlcItem.ITEM_DESCRIPTION, itemDescription);
}
@Override
public String getItemId() {
- return (String) myproperties.get(PlcItem.ITEM_ID);
+ return (String) itemProperties.get(PlcItem.ITEM_ID);
}
@Override
- public void setItemId(String item_id) {
- myproperties.put(PlcItem.ITEM_ID, item_id);
+ public void setItemId(String itemId) {
+ itemProperties.put(PlcItem.ITEM_ID, itemId);
}
@Override
public PlcTag getItemPlcTag() {
- return item_plctag;
+ return itemPlcTag;
}
@Override
public void setItemPlcTag(PlcTag itemplctag) {
- this.item_plctag = itemplctag;
+ this.itemPlcTag = itemplctag;
}
@Override
- public Boolean getEnable() {
- return item_enable;
+ public Boolean isEnable() {
+ return itemEnable;
}
@Override
public void setEnable(Boolean enable) {
- this.item_enable = enable;
+ this.itemEnable = enable;
}
-
- @Override
- public Boolean isEnable() {
- return item_enable;
- }
@Override
public Boolean getIsArray() {
- return item_isarray;
+ return itemIsArray;
}
@Override
public void setIsArray(Boolean isArray) {
- this.item_isarray = isArray;
+ this.itemIsArray = isArray;
}
@Override
- public Boolean getIsDisableOutput() {
- return item_disableoutput;
+ public Boolean isDisableOutput() {
+ return itemDisableOutput;
}
@Override
- public void setIsDisableOutput(Boolean item_disableoutput) {
- this.item_disableoutput = item_disableoutput;
+ public void setIsDisableOutput(Boolean itemDisableOutput) {
+ this.itemDisableOutput = itemDisableOutput;
}
@Override
public long getItemTransmits() {
- return itemtransmit;
+ return itemTransmit;
}
@Override
public long getItemReceives() {
- return itemreceives;
+ return itemReceives;
}
public long getItemErrors() {
- return itemerrors;
+ return itemErrors;
}
@Override
public int getAccessRights() {
- return item_accessrigths;
+ return itemAccessrigths;
}
@Override
- public void setAccessRights(int item_accessrigths) {
- this.item_accessrigths = item_accessrigths;
+ public void setAccessRights(int itemAccessrigths) {
+ this.itemAccessrigths = itemAccessrigths;
}
@Override
public PlcResponseCode getDataQuality() {
- return dataquality;
+ return plcDataquality;
}
@Override
@@ -228,18 +223,18 @@ public class PlcItemImpl implements PlcItem {
lock.lock();
try {
- this.item_plcvalue = plcvalue;
- item_buffer.clear();
- switch (item_plctag.getPlcValueType()){
+ this.itemPlcValue = plcvalue;
+ itemBuffer.clear();
+ switch (itemPlcTag.getPlcValueType()){
case BYTE:
- item_plcvalue.getList().forEach(p -> {item_buffer.writeByte(p.getByte());});
+ itemPlcValue.getList().forEach(p -> {itemBuffer.writeByte(p.getByte());});
break;
case CHAR:
case STRING:
- plcresponse.getAllStrings(item_uid.toString()).forEach(s -> {
- item_buffer.writeBytes(s.getBytes());
+ plcResponse.getAllStrings(itemUid.toString()).forEach(s -> {
+ itemBuffer.writeBytes(s.getBytes());
});
- item_plcvalue.getList().forEach(p -> {item_buffer.writeBytes(p.getRaw());});
+ itemPlcValue.getList().forEach(p -> {itemBuffer.writeBytes(p.getRaw());});
break;
case WORD:
case USINT:
@@ -247,36 +242,36 @@ public class PlcItemImpl implements PlcItem {
case UINT:
case INT:
case DINT:
- item_plcvalue.getList().forEach(p -> {item_buffer.writeShort(p.getShort());});
+ itemPlcValue.getList().forEach(p -> {itemBuffer.writeShort(p.getShort());});
break;
case UDINT:
case ULINT:
case LINT:
- item_plcvalue.getList().forEach(p -> {item_buffer.writeLong(p.getLong());});
+ itemPlcValue.getList().forEach(p -> {itemBuffer.writeLong(p.getLong());});
break;
case BOOL:
- item_plcvalue.getList().forEach(p -> {item_buffer.writeBoolean(p.getBoolean());});
+ itemPlcValue.getList().forEach(p -> {itemBuffer.writeBoolean(p.getBoolean());});
break;
case REAL:
case LREAL:
- item_plcvalue.getList().forEach(p -> {item_buffer.writeFloat(p.getFloat());});
+ itemPlcValue.getList().forEach(p -> {itemBuffer.writeFloat(p.getFloat());});
break;
case DATE_AND_TIME:
- item_plcvalue.getList().forEach(p -> {item_buffer.writeLong(p.getDateTime().toEpochSecond(ZoneOffset.UTC));});
+ itemPlcValue.getList().forEach(p -> {itemBuffer.writeLong(p.getDateTime().toEpochSecond(ZoneOffset.UTC));});
break;
case DATE:
- plcresponse.getAllDates(item_uid.toString()).forEach(dt -> {
- item_buffer.writeLong(dt.toEpochDay());
+ plcResponse.getAllDates(itemUid.toString()).forEach(dt -> {
+ itemBuffer.writeLong(dt.toEpochDay());
});
- item_plcvalue.getList().forEach(p -> {item_buffer.writeLong(p.getDateTime().toLocalDate().toEpochDay());});
+ itemPlcValue.getList().forEach(p -> {itemBuffer.writeLong(p.getDateTime().toLocalDate().toEpochDay());});
break;
case TIME:
break;
case TIME_OF_DAY:
- item_plcvalue.getList().forEach(p -> {item_buffer.writeLong(p.getTime().toEpochSecond(LocalDate.MAX, ZoneOffset.UTC));});
+ itemPlcValue.getList().forEach(p -> {itemBuffer.writeLong(p.getTime().toEpochSecond(LocalDate.MAX, ZoneOffset.UTC));});
break;
default:
- throw new NotImplementedException("The response type for datatype " + item_plcvalue.getPlcValueType() + " is not yet implemented");
+ throw new NotImplementedException("The response type for datatype " + itemPlcValue.getPlcValueType() + " is not yet implemented");
}
} catch (Exception ex) {
@@ -290,7 +285,7 @@ public class PlcItemImpl implements PlcItem {
lock.lock();
PlcValue plcvalue;
try {
- plcvalue = item_plcvalue;
+ plcvalue = itemPlcValue;
} finally {
lock.unlock();
}
@@ -302,7 +297,7 @@ public class PlcItemImpl implements PlcItem {
lock.lock();
ByteBuf itembuffer;
try {
- itembuffer = item_buffer.duplicate();
+ itembuffer = itemBuffer.duplicate();
} finally {
lock.unlock();
}
@@ -314,7 +309,7 @@ public class PlcItemImpl implements PlcItem {
lock.lock();
byte[] bytebuffer;
try {
- bytebuffer = item_buffer.array();
+ bytebuffer = itemBuffer.array();
} finally {
lock.unlock();
}
@@ -322,97 +317,114 @@ public class PlcItemImpl implements PlcItem {
}
@Override
- public void setDataQuality(PlcResponseCode dataquality) {
- this.dataquality = dataquality;
+ public void setDataQuality(PlcResponseCode plcDataquality) {
+ this.plcDataquality = plcDataquality;
}
@Override
public void addItemClient(PlcItemListener client) {
- if (!item_clients.contains(client)) {
+ if (!itemClients.contains(client)) {
client.atach(this);
- item_clients.add(client);
+ itemClients.add(client);
}
}
@Override
public void removeItemClient(PlcItemListener client) {
- if (!item_clients.contains(client)) {
- item_clients.remove(client);
+ if (!itemClients.contains(client)) {
+ itemClients.remove(client);
client.detach();
}
}
@Override
public Hashtable<String, Object> getProperties() {
- return myproperties;
+ return itemProperties;
}
@Override
public Date getLastReadDate() {
- return lastreadtime;
+ return lastReadDate;
}
@Override
public Date getLastWriteDate() {
- return lastwritetime;
+ return lastWriteDate;
}
@Override
public Date getLastErrorDate() {
- return lasterrortime;
+ return lastErrorDate;
}
private void updateClients(){
- item_clients.forEach(c -> c.update());
+ itemClients.forEach(c -> c.update());
+ }
+
+ @Override
+ public void setRingBuffer(RingBuffer<PlcDeviceWriteEvent> ringBuffer) {
+ this.ringBuffer = ringBuffer;
}
+ @Override
+ public void itemWrite() {
+
+
+ }
+
+ @Override
+ public String toString() {
+ return "";
+ }
+
+
public static class PlcItemBuilder {
- private final String item_name;
- private UUID item_uid;
- private String item_description;
- private String item_id;
- private Boolean item_enable = false;
- private int item_accessrigths = 0;
- private Boolean item_isarray = false;
- private Boolean item_disableoutput = false;
-
- public PlcItemBuilder(String item_name) {
- this.item_name = item_name;
- this.item_uid = UUID.randomUUID();
+ private final String itemName;
+ private UUID itemUid;
+ private String itemDescription;
+ private String itemId;
+ private Boolean itemEnable = false;
+ private int itemAccessrigths = 0;
+ private Boolean itemIsArray = false;
+ private Boolean itemDisableOutput = false;
+
+ public PlcItemBuilder(String itemName) {
+ this.itemName = itemName;
+ this.itemUid = UUID.randomUUID();
}
- public PlcItemBuilder setItemUid(UUID item_uid) {
- this.item_uid = item_uid;
+ public PlcItemBuilder setItemUid(UUID itemUid) {
+ this.itemUid = itemUid;
return this;
}
- public PlcItemBuilder setItemDescription(String item_description) {
- this.item_description = item_description;
+ public PlcItemBuilder setItemDescription(String itemDescription) {
+ this.itemDescription = itemDescription;
return this;
}
- public PlcItemBuilder setItemId(String item_id) {
- this.item_id = item_id;
+ public PlcItemBuilder setItemId(String itemId) {
+ this.itemId = itemId;
return this;
}
- public PlcItemBuilder setItemEnable(boolean item_enable) {
- this.item_enable = item_enable;
+ public PlcItemBuilder setItemEnable(boolean itemEnable) {
+ this.itemEnable = itemEnable;
return this;
}
- public PlcItemBuilder setItemAccessrigths(int item_accessrigths) {
- this.item_accessrigths = item_accessrigths;
+ public PlcItemBuilder setItemAccessrigths(int itemAccessrigths) {
+ this.itemAccessrigths = itemAccessrigths;
return this;
}
- public PlcItemBuilder setItemIsarray(Boolean item_isarray) {
- this.item_isarray = item_isarray;
+ public PlcItemBuilder setItemIsarray(Boolean itemIsArray) {
+ this.itemIsArray = itemIsArray;
return this;
}
- public PlcItemBuilder setItemDisableoutput(Boolean item_disableoutput) {
- this.item_disableoutput = item_disableoutput;
+ public PlcItemBuilder setItemDisableoutput(Boolean itemDisableOutput) {
+ this.itemDisableOutput = itemDisableOutput;
return this;
}
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 b55307b..c678e88 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
@@ -68,8 +68,6 @@ public class cmdDeviceDel implements Action {
return null;
}
- System.out.println(">>> " + ctxdevices.get(0).getDeviceName());
-
return null;
}
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 d1ba502..f187aa6 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
@@ -17,12 +17,14 @@
package org.apache.plc4x.merlot.das.base.impl;
+import io.netty.buffer.ByteBuf;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.apache.plc4x.java.api.PlcDriver;
+import org.apache.plc4x.java.api.model.PlcTag;
import org.apache.plc4x.merlot.api.PlcDevice;
import org.osgi.framework.BundleContext;
import org.osgi.service.dal.Device;
@@ -213,6 +215,11 @@ import org.apache.plc4x.merlot.api.PlcGroup;
this.plcdriver = driver;
}
+ @Override
+ public String getWritePlcTag(PlcTag plcTag, ByteBuf byteBuf, String... args) {
+ 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/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 81f1ef9..40e1039 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
@@ -16,6 +16,7 @@
*/
package org.apache.plc4x.merlot.das.base.impl;
+import com.lmax.disruptor.RingBuffer;
import io.netty.buffer.ByteBuf;
import java.util.Date;
import java.util.Hashtable;
@@ -25,6 +26,7 @@ import org.apache.plc4x.java.api.types.PlcResponseCode;
import org.apache.plc4x.java.api.value.PlcValue;
import org.apache.plc4x.merlot.api.PlcItem;
import org.apache.plc4x.merlot.api.PlcItemListener;
+import org.apache.plc4x.merlot.api.impl.PlcDeviceWriteEvent;
public class BaseItemImpl implements PlcItem {
@@ -109,11 +111,6 @@ public class BaseItemImpl implements PlcItem {
this.id = itemid;
}
- @Override
- public Boolean getEnable() {
- return enable;
- }
-
@Override
public void setEnable(Boolean enable) {
this.enable = enable;
@@ -137,7 +134,7 @@ public class BaseItemImpl implements PlcItem {
@Override
- public Boolean getIsDisableOutput() {
+ public Boolean isDisableOutput() {
return disableoutput;
}
@@ -231,5 +228,15 @@ public class BaseItemImpl implements PlcItem {
public Hashtable<String, Object> getProperties() {
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
}
+
+ @Override
+ public void setRingBuffer(RingBuffer<PlcDeviceWriteEvent> ringBuffer) {
+ throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
+ }
+
+ @Override
+ public void itemWrite() {
+ 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.ref/pom.xml b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.ref/pom.xml
index e75809b..4bbd1c8 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.ref/pom.xml
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.ref/pom.xml
@@ -47,6 +47,7 @@
<Bundle-Version>0.13.0-SNAPSHOT</Bundle-Version>
<Export-Package>org.apache.plc4x.merlot.das.ref*;version=0.13.0-SNAPSHOT</Export-Package>
<Import-Package>*</Import-Package>
+ <_removeheaders>Import-Service,Export-Service</_removeheaders>
</instructions>
</configuration>
</plugin>
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.ref/src/main/java/org/apache/plc4x/merlot/das/ref/impl/Plc4xReferringDriverImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.ref/src/main/java/org/apache/plc4x/merlot/das/ref/impl/Plc4xReferringDriverImpl.java
index dcaca7f..1b5e97f 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.ref/src/main/java/org/apache/plc4x/merlot/das/ref/impl/Plc4xReferringDriverImpl.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.ref/src/main/java/org/apache/plc4x/merlot/das/ref/impl/Plc4xReferringDriverImpl.java
@@ -50,7 +50,7 @@ public class Plc4xReferringDriverImpl implements Driver {
@Override
public int match(ServiceReference<?> reference) throws Exception {
if (!drivers.isEmpty()) {
- final String drv_code = (String) reference.getProperty(Constants.DEVICE_CATEGORY);
+ final String drv_code = (String) reference.getProperty(Constants.DEVICE_CATEGORY);
final PlcDriver plcdriver = drivers.get(drv_code);
if (null == plcdriver) {
final PlcDevice plcdev = (PlcDevice) bc.getService(reference);
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das/pom.xml b/plc4j/tools/merlot/org.apache.plc4x.merlot.das/pom.xml
index 09dd713..1864647 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das/pom.xml
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das/pom.xml
@@ -48,7 +48,8 @@
<Bundle-Version>0.13.0-SNAPSHOT</Bundle-Version>
<Export-Package>org.apache.plc4x.merlot.das*;version=0.13.0-SNAPSHOT</Export-Package>
<Import-Package>org.apache.plc4x.merlot.*;version="[0.0,1)",*</Import-Package>
- <Karaf-Commands>org.apache.plc4x.merlot.das.command*</Karaf-Commands>
+ <Karaf-Commands>org.apache.plc4x.merlot.das.command*</Karaf-Commands>
+ <_removeheaders>Import-Service,Export-Service</_removeheaders>
</instructions>
</configuration>
</plugin>
@@ -82,12 +83,12 @@
<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4j-api</artifactId>
- <version>0.10.0</version>
+ <version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.plc4x.merlot.api</groupId>
<artifactId>org.apache.plc4x.merlot.api</artifactId>
- <version>0.13.0-SNAPSHOT</version>
+ <version>${project.version}</version>
</dependency>
</dependencies>
</project>
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 07686db..d47b8d7 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
@@ -41,7 +41,7 @@
<service id="WhiteBoardService" ref="WhiteBoardBean" interface="org.apache.plc4x.merlot.das.api.WhiteBoardHandler"/>
- <service ref="beanPlcDasGrpc" interface="io.grpc.BindableService" />
+ <service ref="beanPlcDasGrpc" interface="io.grpc.BindableService" />
<reference
id="DriverSelector"
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 57225f1..4dfdc58 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/pom.xml
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/pom.xml
@@ -31,7 +31,7 @@
<version>0.13.0-SNAPSHOT</version>
<packaging>bundle</packaging>
- <name>PLC4J: Merlot :: db :: Simple database</name>
+ <name>PLC4J: Merlot :: db :: Simple RT database</name>
<description>org.apache.plc4x.merlot.db OSGi blueprint bundle project.</description>
<build>
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBBaseFactory.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBBaseFactory.java
index 25161ac..afed420 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBBaseFactory.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBBaseFactory.java
@@ -30,6 +30,7 @@ import org.slf4j.LoggerFactory;
public class DBBaseFactory implements DBRecordFactory {
private static final Logger LOGGER = LoggerFactory.getLogger(DBBaseFactory.class);
+
@Override
public PVRecord create(String recordName) {
throw new UnsupportedOperationException("Not supported yet.");
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 9790577..7972524 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
@@ -32,7 +32,9 @@ import org.epics.pvdatabase.PVRecord;
public class DBBooleanFactory extends DBBaseFactory {
+
private static FieldCreate fieldCreate = FieldFactory.getFieldCreate();
+
public DBBooleanFactory() {};
@Override
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBByteFactory.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBByteFactory.java
index 10816b1..00a98ef 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBByteFactory.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBByteFactory.java
@@ -32,6 +32,7 @@ import org.epics.pvdatabase.PVRecord;
public class DBByteFactory extends DBBaseFactory {
+
private static FieldCreate fieldCreate = FieldFactory.getFieldCreate();
public DBByteFactory() {
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBDoubleFactory.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBDoubleFactory.java
index c92ce90..462d8de 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBDoubleFactory.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBDoubleFactory.java
@@ -32,9 +32,9 @@ import org.epics.pvdatabase.PVRecord;
public class DBDoubleFactory extends DBBaseFactory {
- private static FieldCreate fieldCreate = FieldFactory.getFieldCreate();
-
+ private static FieldCreate fieldCreate = FieldFactory.getFieldCreate();
+
@Override
public PVRecord create(String recordName) {
NTScalarBuilder ntScalarBuilder = NTScalar.createBuilder();
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 12986e1..35ccfcf 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
@@ -32,8 +32,8 @@ import org.epics.pvdatabase.PVRecord;
public class DBFloatFactory extends DBBaseFactory {
- private static FieldCreate fieldCreate = FieldFactory.getFieldCreate();
+ private static FieldCreate fieldCreate = FieldFactory.getFieldCreate();
@Override
public PVRecord create(String recordName) {
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBIntFactory.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBIntFactory.java
index 8d7ff43..30fc2c8 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBIntFactory.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBIntFactory.java
@@ -32,9 +32,9 @@ import org.epics.pvdatabase.PVRecord;
public class DBIntFactory extends DBBaseFactory {
- private static FieldCreate fieldCreate = FieldFactory.getFieldCreate();
-
+ private static FieldCreate fieldCreate = FieldFactory.getFieldCreate();
+
@Override
public PVRecord create(String recordName) {
NTScalarBuilder ntScalarBuilder = NTScalar.createBuilder();
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBLongFactory.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBLongFactory.java
index 1a012e0..cc71be4 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBLongFactory.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBLongFactory.java
@@ -32,9 +32,9 @@ import org.epics.pvdatabase.PVRecord;
public class DBLongFactory extends DBBaseFactory {
- private static FieldCreate fieldCreate = FieldFactory.getFieldCreate();
-
+ private static FieldCreate fieldCreate = FieldFactory.getFieldCreate();
+
@Override
public PVRecord create(String recordName) {
NTScalarBuilder ntScalarBuilder = NTScalar.createBuilder();
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 59ffdf3..2f843f5 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
@@ -46,6 +46,7 @@ import org.slf4j.LoggerFactory;
public class DBRecordsManagedService implements ManagedServiceFactory, Job {
+
private static final Logger LOGGER = LoggerFactory.getLogger(DBRecordsManagedService.class);
private final PVDatabase master;
private static Map<String, Dictionary<String, ?>> waitingConfigs = null;
@@ -104,6 +105,7 @@ public class DBRecordsManagedService implements ManagedServiceFactory, Job {
}
BaseDriver dummyDriver = getDriver(device);
+
if (dummyDriver == null){
LOGGER.debug("Device driver [" + device + "] is not deployed.");
waitingConfigs.put(device, props);
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBShortFactory.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBShortFactory.java
index cf2889c..c6c8ec1 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBShortFactory.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBShortFactory.java
@@ -33,6 +33,7 @@ import org.epics.pvdatabase.PVRecord;
public class DBShortFactory extends DBBaseFactory {
+
private static FieldCreate fieldCreate = FieldFactory.getFieldCreate();
@Override
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBStringFactory.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBStringFactory.java
index d56be99..5adfc6c 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBStringFactory.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBStringFactory.java
@@ -32,6 +32,7 @@ import org.epics.pvdatabase.PVRecord;
public class DBStringFactory extends DBBaseFactory {
+
private static FieldCreate fieldCreate = FieldFactory.getFieldCreate();
@Override
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBUByteFactory.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBUByteFactory.java
index e0fb7cb..2f4cc19 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBUByteFactory.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBUByteFactory.java
@@ -32,6 +32,7 @@ import org.epics.pvdatabase.PVRecord;
public class DBUByteFactory extends DBBaseFactory {
+
private static FieldCreate fieldCreate = FieldFactory.getFieldCreate();
@Override
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBUIntFactory.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBUIntFactory.java
index 81bfabb..0193149 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBUIntFactory.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBUIntFactory.java
@@ -32,8 +32,8 @@ import org.epics.pvdatabase.PVRecord;
public class DBUIntFactory extends DBBaseFactory {
+
private static FieldCreate fieldCreate = FieldFactory.getFieldCreate();
-
@Override
public PVRecord create(String recordName) {
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBULongFactory.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBULongFactory.java
index 68bb4e5..b520a82 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBULongFactory.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/core/DBULongFactory.java
@@ -32,7 +32,9 @@ import org.epics.pvdatabase.PVRecord;
public class DBULongFactory extends DBBaseFactory {
+
private static FieldCreate fieldCreate = FieldFactory.getFieldCreate();
+
public DBULongFactory() {}
@Override
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 f216caf..630f5da 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
@@ -32,7 +32,9 @@ import org.epics.pvdatabase.PVRecord;
public class DBUShortFactory extends DBBaseFactory {
+
private static FieldCreate fieldCreate = FieldFactory.getFieldCreate();
+
public DBUShortFactory() {}
@Override
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/impl/DBCollectorImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/impl/DBCollectorImpl.java
index f1d8a40..0e91048 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/impl/DBCollectorImpl.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.db/src/main/java/org/apache/plc4x/merlot/db/impl/DBCollectorImpl.java
@@ -86,7 +86,9 @@ import org.slf4j.LoggerFactory;
//TODO: add the logger system, the write is INFO, the read maybe DEBUG
//TODO: Read/Write information for every tag for statical use.
public class DBCollectorImpl implements DBCollector, PVListener {
- private static final Logger LOGGER = LoggerFactory.getLogger(DBCollectorImpl.class);
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(DBCollectorImpl.class);
+
private final BundleContext bundleContext;
private final String device;
private final BaseDriver devDriver;
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.drv.simulated/src/main/java/org/apache/plc4x/merlot/drv/simulated/impl/SimulatedReferringDriverImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.drv.simulated/src/main/java/org/apache/plc4x/merlot/drv/simulated/impl/SimulatedReferringDriverImpl.java
index 595ca4c..f28b0f7 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.drv.simulated/src/main/java/org/apache/plc4x/merlot/drv/simulated/impl/SimulatedReferringDriverImpl.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.drv.simulated/src/main/java/org/apache/plc4x/merlot/drv/simulated/impl/SimulatedReferringDriverImpl.java
@@ -33,35 +33,30 @@ public class SimulatedReferringDriverImpl implements Driver {
private final EventAdmin eventAdmin;
private PlcDriver plcdriver = null;
- public SimulatedReferringDriverImpl(BundleContext bc, EventAdmin eventAdmin) {
- System.out.println("Creo el objeto.....");
+ public SimulatedReferringDriverImpl(BundleContext bc, EventAdmin eventAdmin) {
this.bc = bc;
this.eventAdmin = eventAdmin;
}
@Override
public int match(ServiceReference reference) throws Exception {
- System.out.println("Match not supported yet.");
return 0;
}
@Override
public String attach(ServiceReference reference) throws Exception {
- System.out.println("Attach not supported yet.");
return null;
}
public void bind(ServiceReference reference) {
- System.out.println(">>> Bind ref to simulated driver");
+
}
public void bind(PlcDriver driver){
- System.out.println(">>> Bind simulated driver");
this.plcdriver = driver;
}
- public void unbind(ServiceReference driver){
- System.out.println(">>> Unbind ref to simulated driver");
+ public void unbind(ServiceReference driver){
this.plcdriver = null;
}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.features/src/main/feature/feature.xml b/plc4j/tools/merlot/org.apache.plc4x.merlot.features/src/main/feature/feature.xml
index 719a747..a4559c9 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.features/src/main/feature/feature.xml
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.features/src/main/feature/feature.xml
@@ -99,21 +99,21 @@
1. Driver packages must have a "start-level" greater than 40.
-->
<feature>grpc</feature>
- <bundle start-level="32">mvn:org.apache.plc4x.merlot.api/org.apache.plc4x.merlot.api/${project.version}</bundle>
+
<feature>plc4x-epics-core</feature>
- <feature>plc4x-scheduler</feature>
-
- <bundle start-level="36" dependency="true">mvn:org.apache.plc4x.merlot.das/org.apache.plc4x.merlot.das/${project.version}</bundle>
- <bundle start-level="38" dependency="true">mvn:org.apache.plc4x.merlot.das.ref/org.apache.plc4x.merlot.das.ref/${project.version}</bundle>
+ <feature>plc4x-scheduler</feature>
+
+ <bundle start-level="32">mvn:org.apache.plc4x.merlot.api/org.apache.plc4x.merlot.api/${project.version}</bundle>
+ <bundle start-level="50">mvn:org.apache.plc4x.merlot.das/org.apache.plc4x.merlot.das/${project.version}</bundle>
+ <bundle start-level="60">mvn:org.apache.plc4x.merlot.das.ref/org.apache.plc4x.merlot.das.ref/${project.version}</bundle>
- <bundle start-level="40">mvn:org.apache.plc4x.merlot.das.base/org.apache.plc4x.merlot.das.base/${project.version}</bundle>
+ <bundle start-level="100">mvn:org.apache.plc4x.merlot.das.base/org.apache.plc4x.merlot.das.base/${project.version}</bundle>
<configfile finalname="/etc/org.apache.plc4x.merlot.das.devices.cfg">mvn:org.apache.plc4x.merlot.das.base/org.apache.plc4x.merlot.das.base/${project.version}/cfg</configfile>
<!-- <bundle start-level="40">mvn:org.apache.plc4x.dummy/org.apache.plc4x.dummy/${project.version}</bundle> -->
-
- </feature>
-
+ </feature>
+
<!-- asm -->
<feature name="asm" version="${asm.version}">
<bundle dependency="false" start-level="20">mvn:org.ow2.asm/asm/${asm.version}</bundle>
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.modbus.sim/src/main/java/org/apache/plc4x/merlot/modbus/sim/impl/ModbusSimSignalImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.modbus.sim/src/main/java/org/apache/plc4x/merlot/modbus/sim/impl/ModbusSimSignalImpl.java
index b104234..5574f2a 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.modbus.sim/src/main/java/org/apache/plc4x/merlot/modbus/sim/impl/ModbusSimSignalImpl.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.modbus.sim/src/main/java/org/apache/plc4x/merlot/modbus/sim/impl/ModbusSimSignalImpl.java
@@ -38,8 +38,6 @@ public class ModbusSimSignalImpl extends ModbusSimImpl {
public void setFunction(String strFunction) {
this.strFunction = strFunction;
signalType = ModbusSimSignalType.valueOfEvent(strFunction);
- System.out.println(">>>>" + strFunction + "<<<<<");
- System.out.println(">>>>" + signalType.getSignal() );
}
@Override
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.scheduler/src/main/java/org/apache/plc4x/merlot/scheduler/impl/SchedulerWhiteBoardImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.scheduler/src/main/java/org/apache/plc4x/merlot/scheduler/impl/SchedulerWhiteBoardImpl.java
index a939c6f..6baf83d 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.scheduler/src/main/java/org/apache/plc4x/merlot/scheduler/impl/SchedulerWhiteBoardImpl.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.scheduler/src/main/java/org/apache/plc4x/merlot/scheduler/impl/SchedulerWhiteBoardImpl.java
@@ -117,7 +117,7 @@ public class SchedulerWhiteBoardImpl implements SchedulerWhiteBoard {
date.setTime(System.currentTimeMillis() + period);
}
- System.out.println("Paso por aqui >>> ....: " + period);
+
this.scheduler.schedule(job, this.scheduler.NOW(times, period)
.name(name)
.canRunConcurrently((concurrent != null ? concurrent : true)));
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot/pom.xml b/plc4j/tools/merlot/org.apache.plc4x.merlot/pom.xml
index 711caac..cdec44e 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot/pom.xml
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot/pom.xml
@@ -216,7 +216,7 @@
<feature>service</feature>
<feature>system</feature>
<feature>aries-blueprint</feature>
- <feature>decanter-collector-log</feature>
+ <feature>decanter-collector-log</feature>
</bootFeatures>
<javase>1.8</javase>