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/11 02:24:45 UTC
(plc4x-extras) 01/01: Reorganizing the project.
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
commit c5aeb17bf2dd6bd33f9f05340c8b7d5d31cb5ca6
Author: César García <ce...@ceos.com.ve>
AuthorDate: Sat Aug 10 22:23:49 2024 -0400
Reorganizing the project.
---
plc4j/tools/merlot/.project | 28 +
.../merlot/.settings/org.eclipse.m2e.core.prefs | 4 +
plc4j/tools/merlot/org.apache.plc4x.dummy/pom.xml | 72 +
.../main/java/org/apache/plc4x/dummy/Comando.java | 34 +
.../java/org/apache/plc4x/dummy/MyService.java | 23 +
.../java/org/apache/plc4x/dummy/MyServiceImpl.java | 25 +
.../resources/OSGI-INF/blueprint/my-service.xml | 24 +
.../org.apache.plc4x.merlot.branding/.classpath | 57 +
.../org.apache.plc4x.merlot.branding/.project | 34 +
.../.settings/org.eclipse.jdt.apt.core.prefs | 2 +
.../.settings/org.eclipse.jdt.core.prefs | 9 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
.../org.apache.plc4x.merlot.branding/pom.xml | 88 +
.../apache/plc4x/merlot/branding/Activator.java | 32 +
.../apache/karaf/branding/branding-ssh.properties | 33 +
.../org/apache/karaf/branding/branding.properties | 31 +
.../org.apache.plc4x.merlot.das.api/.classpath | 57 +
.../org.apache.plc4x.merlot.das.api/.project | 34 +
.../.settings/org.eclipse.jdt.apt.core.prefs | 2 +
.../.settings/org.eclipse.jdt.core.prefs | 9 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
.../merlot/org.apache.plc4x.merlot.das.api/pom.xml | 186 +
.../cfg/org.apache.plc4x.merlot.das.devices.cfg | 50 +
.../apache/plc4x/merlot/api/ByteBasedDriver.java | 121 +
.../java/org/apache/plc4x/merlot/api/Driver.java | 104 +
.../apache/plc4x/merlot/api/DriverCallback.java | 26 +
.../org/apache/plc4x/merlot/api/DriverEvent.java | 85 +
.../plc4x/merlot/api/MessageBasedDriver.java | 23 +
.../org/apache/plc4x/merlot/api/Optimizer.java | 38 +
.../org/apache/plc4x/merlot/api/PlcChannel.java | 27 +
.../org/apache/plc4x/merlot/api/PlcDevice.java | 125 +
.../apache/plc4x/merlot/api/PlcDeviceFactory.java | 29 +
.../org/apache/plc4x/merlot/api/PlcFunction.java | 30 +
.../plc4x/merlot/api/PlcGeneralFunction.java | 241 +
.../java/org/apache/plc4x/merlot/api/PlcGroup.java | 160 +
.../java/org/apache/plc4x/merlot/api/PlcItem.java | 220 +
.../org/apache/plc4x/merlot/api/PlcItemClient.java | 27 +
.../apache/plc4x/merlot/api/PlcItemListener.java | 32 +
.../apache/plc4x/merlot/api/TagBasedDriver.java | 24 +
.../plc4x/merlot/api/command/DemoCommand001.java | 85 +
.../plc4x/merlot/api/command/DemoCommand002.java | 90 +
.../plc4x/merlot/api/command/DemoCommand003.java | 87 +
.../plc4x/merlot/api/command/DemoCommand004.java | 87 +
.../api/command/PlcDeviceControlCommand.java | 63 +
.../merlot/api/command/PlcDeviceListCommand.java | 153 +
.../merlot/api/command/PlcDriverListCommand.java | 59 +
.../merlot/api/command/PlcGroupControlCommand.java | 85 +
.../merlot/api/command/PlcItemControlCommand.java | 63 +
.../org/apache/plc4x/merlot/api/core/Merlot.java | 662 +
.../merlot/api/core/PlcDeviceManagedService.java | 175 +
.../merlot/api/core/PlcItemClientService.java | 131 +
.../merlot/api/impl/DriverEventFactoryImpl.java | 24 +
.../plc4x/merlot/api/impl/DriverEventImpl.java | 231 +
.../merlot/api/impl/DriverSessionFactoryImpl.java | 24 +
.../merlot/api/impl/DriverThreadFactoryImpl.java | 31 +
.../merlot/api/impl/PlcDeviceFactoryImpl.java | 43 +
.../plc4x/merlot/api/impl/PlcDeviceImpl.java | 361 +
.../merlot/api/impl/PlcDriverAdminServiceImpl.java | 64 +
.../plc4x/merlot/api/impl/PlcFunctionData.java | 68 +
.../plc4x/merlot/api/impl/PlcFunctionEvent.java | 96 +
.../merlot/api/impl/PlcGeneralFunctionImpl.java | 664 +
.../apache/plc4x/merlot/api/impl/PlcGroupImpl.java | 362 +
.../apache/plc4x/merlot/api/impl/PlcItemImpl.java | 432 +
.../merlot/api/impl/PlcOperationMetadata.java | 101 +
.../plc4x/merlot/api/impl/PlcPropertyMetadata.java | 119 +
.../apache/plc4x/merlot/api/impl/PlcValueImpl.java | 361 +
.../resources/OSGI-INF/blueprint/api-service.xml | 191 +
.../src/main/resources/OSGI-INF/bundle.info | 39 +
.../src/main/resources/proto/das.proto | 31 +
.../src/main/resources/proto/helloworld.proto | 27 +
.../src/main/resources/proto/modbus.proto | 85 +
.../src/main/resources/proto/ping.proto | 21 +
.../org.apache.plc4x.merlot.das.base/.classpath | 57 +
.../org.apache.plc4x.merlot.das.base/.project | 34 +
.../.settings/org.eclipse.jdt.apt.core.prefs | 2 +
.../.settings/org.eclipse.jdt.core.prefs | 9 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
.../org.apache.plc4x.merlot.das.base/pom.xml | 125 +
.../cfg/org.apache.plc4x.merlot.das.devices.cfg | 50 +
.../plc4x/merlot/das/base/api/BaseDevice.java | 25 +
.../merlot/das/base/api/BaseDeviceFactory.java | 25 +
.../plc4x/merlot/das/base/api/BaseDriver.java | 38 +
.../plc4x/merlot/das/base/api/BaseDriverMBean.java | 62 +
.../merlot/das/base/command/DeviceNewCommand.java | 98 +
.../merlot/das/base/command/cmdDeviceDel.java | 76 +
.../merlot/das/base/command/cmdDeviceGroupDel.java | 33 +
.../das/base/command/cmdDeviceGroupItemDel.java | 22 +
.../das/base/command/cmdDeviceGroupItemList.java | 22 +
.../das/base/command/cmdDeviceGroupItemNew.java | 22 +
.../das/base/command/cmdDeviceGroupList.java | 42 +
.../merlot/das/base/command/cmdDeviceGroupNew.java | 79 +
.../das/base/command/cmdDeviceGroupSchedule.java | 70 +
.../merlot/das/base/command/cmdDriverList.java | 48 +
.../das/base/core/BaseDeviceManagedService.java | 184 +
.../das/base/impl/BaseDeviceFactoryImpl.java | 43 +
.../plc4x/merlot/das/base/impl/BaseDeviceImpl.java | 320 +
.../merlot/das/base/impl/BaseDriverMBeanImpl.java | 126 +
.../merlot/das/base/impl/BaseFunctionImpl.java | 78 +
.../plc4x/merlot/das/base/impl/BaseGroupImpl.java | 204 +
.../plc4x/merlot/das/base/impl/BaseItemImpl.java | 240 +
.../resources/OSGI-INF/blueprint/base-service.xml | 64 +
.../org.apache.plc4x.merlot.das.ref/.classpath | 57 +
.../org.apache.plc4x.merlot.das.ref/.project | 34 +
.../.settings/org.eclipse.jdt.apt.core.prefs | 2 +
.../.settings/org.eclipse.jdt.core.prefs | 9 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
.../merlot/org.apache.plc4x.merlot.das.ref/pom.xml | 96 +
.../apache/plc4x/merlot/das/ref/api/MyService.java | 23 +
.../plc4x/merlot/das/ref/api/MyServiceImpl.java | 25 +
.../das/ref/impl/Plc4xReferringDriverImpl.java | 97 +
.../OSGI-INF/blueprint/referring-drv-service.xml | 42 +
.../merlot/org.apache.plc4x.merlot.das/.classpath | 57 +
.../merlot/org.apache.plc4x.merlot.das/.project | 34 +
.../.settings/org.eclipse.jdt.apt.core.prefs | 2 +
.../.settings/org.eclipse.jdt.core.prefs | 9 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
.../merlot/org.apache.plc4x.merlot.das/pom.xml | 93 +
.../apache/plc4x/merlot/das/api/DeviceManager.java | 52 +
.../plc4x/merlot/das/api/WhiteBoardHandler.java | 32 +
.../plc4x/merlot/das/command/AddDevCommand.java | 35 +
.../plc4x/merlot/das/command/DelDevCommand.java | 35 +
.../plc4x/merlot/das/command/ListDevCommand.java | 132 +
.../plc4x/merlot/das/command/ReadDevCommand.java | 79 +
.../plc4x/merlot/das/command/WriteDevCommand.java | 24 +
.../plc4x/merlot/das/core/DeviceAnalyzer.java | 99 +
.../plc4x/merlot/das/core/DriverAnalyzer.java | 60 +
.../plc4x/merlot/das/core/DriverAttributes.java | 113 +
.../apache/plc4x/merlot/das/core/DriverLoader.java | 192 +
.../plc4x/merlot/das/core/DriverMatcher.java | 207 +
.../plc4x/merlot/das/core/NamedThreadFactory.java | 47 +
.../org/apache/plc4x/merlot/das/core/Util.java | 179 +
.../plc4x/merlot/das/impl/DeviceManagerImpl.java | 718 ++
.../plc4x/merlot/das/impl/PlcDasGrpcImpl.java | 59 +
.../merlot/das/impl/WhiteBoardHandlerImpl.java | 166 +
.../resources/OSGI-INF/blueprint/das-service.xml | 64 +
.../src/main/resources/OSGI-INF/bundle.info | 39 +
.../merlot/org.apache.plc4x.merlot.db/.classpath | 57 +
.../merlot/org.apache.plc4x.merlot.db/.project | 34 +
.../.settings/org.eclipse.jdt.apt.core.prefs | 2 +
.../.settings/org.eclipse.jdt.core.prefs | 9 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
.../merlot/org.apache.plc4x.merlot.db/pom.xml | 131 +
.../cfg/org.apache.plc4x.merlot.db.records.cfg | 57 +
.../apache/plc4x/merlot/db/api/DBCollector.java | 30 +
.../org/apache/plc4x/merlot/db/api/DBControl.java | 34 +
.../merlot/db/api/DBRPCReferenceListener.java | 34 +
.../org/apache/plc4x/merlot/db/api/DBRecord.java | 24 +
.../plc4x/merlot/db/api/DBRecordFactory.java | 32 +
.../plc4x/merlot/db/command/DBAddCommand.java | 133 +
.../plc4x/merlot/db/command/DBDelCommand.java | 24 +
.../plc4x/merlot/db/command/DBDumpCommand.java | 67 +
.../plc4x/merlot/db/command/DBListCommand.java | 46 +
.../plc4x/merlot/db/command/DBScalarCommand.java | 52 +
.../apache/plc4x/merlot/db/core/DBBaseFactory.java | 144 +
.../plc4x/merlot/db/core/DBBooleanFactory.java | 101 +
.../apache/plc4x/merlot/db/core/DBByteFactory.java | 101 +
.../plc4x/merlot/db/core/DBDoubleFactory.java | 99 +
.../plc4x/merlot/db/core/DBFloatFactory.java | 100 +
.../apache/plc4x/merlot/db/core/DBIntFactory.java | 100 +
.../apache/plc4x/merlot/db/core/DBLongFactory.java | 99 +
.../merlot/db/core/DBRecordsManagedService.java | 218 +
.../plc4x/merlot/db/core/DBShortFactory.java | 102 +
.../plc4x/merlot/db/core/DBStringFactory.java | 99 +
.../plc4x/merlot/db/core/DBUByteFactory.java | 99 +
.../apache/plc4x/merlot/db/core/DBUIntFactory.java | 100 +
.../plc4x/merlot/db/core/DBULongFactory.java | 100 +
.../plc4x/merlot/db/core/DBUShortFactory.java | 100 +
.../merlot/db/core/DbChannelProviderFactory.java | 34 +
.../org/apache/plc4x/merlot/db/core/DbFactory.java | 43 +
.../plc4x/merlot/db/impl/DBCollectorImpl.java | 737 ++
.../apache/plc4x/merlot/db/impl/DBControlImpl.java | 107 +
.../merlot/db/impl/DBRPCReferenceListenerImpl.java | 92 +
.../resources/OSGI-INF/blueprint/db-service.xml | 201 +
.../src/main/resources/OSGI-INF/bundle.info | 38 +
.../org.apache.plc4x.merlot.derby/.classpath | 57 +
.../merlot/org.apache.plc4x.merlot.derby/.project | 34 +
.../.settings/org.eclipse.jdt.apt.core.prefs | 2 +
.../.settings/org.eclipse.jdt.core.prefs | 9 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
.../merlot/org.apache.plc4x.merlot.derby/pom.xml | 83 +
.../plc4x/merlot/derby/api/DerbyService.java | 25 +
.../plc4x/merlot/derby/impl/DerbyServiceImpl.java | 53 +
.../OSGI-INF/blueprint/derby-svr-service.xml | 42 +
.../.classpath | 57 +
.../org.apache.plc4x.merlot.drv.simulated/.project | 34 +
.../.settings/org.eclipse.jdt.apt.core.prefs | 2 +
.../.settings/org.eclipse.jdt.core.prefs | 9 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
.../org.apache.plc4x.merlot.drv.simulated/pom.xml | 76 +
.../plc4x/merlot/drv/simulated/api/MyService.java | 23 +
.../merlot/drv/simulated/api/MyServiceImpl.java | 25 +
.../impl/SimulatedReferringDriverImpl.java | 68 +
.../OSGI-INF/blueprint/simulated-drv--service.xml | 47 +
.../org.apache.plc4x.merlot.features/.project | 28 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
.../org.apache.plc4x.merlot.features/pom.xml | 65 +
.../src/main/feature/feature.xml | 649 +
.../merlot/org.apache.plc4x.merlot.grpc/pom.xml | 86 +
.../apache/plc4x/merlot/grpc/api/GrpcServer.java | 13 +
.../apache/plc4x/merlot/grpc/api/MyService.java | 23 +
.../plc4x/merlot/grpc/api/MyServiceImpl.java | 25 +
.../plc4x/merlot/grpc/impl/GreeterService.java | 26 +
.../plc4x/merlot/grpc/impl/HelloWorldServer.java | 80 +
.../resources/OSGI-INF/blueprint/grpc-service.xml | 40 +
.../merlot/org.apache.plc4x.merlot.h2/.classpath | 57 +
.../merlot/org.apache.plc4x.merlot.h2/.project | 34 +
.../.settings/org.eclipse.jdt.apt.core.prefs | 2 +
.../.settings/org.eclipse.jdt.core.prefs | 9 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
.../merlot/org.apache.plc4x.merlot.h2/pom.xml | 65 +
.../java/org/apache/plc4x/merlot/h2/MyService.java | 23 +
.../org/apache/plc4x/merlot/h2/MyServiceImpl.java | 25 +
.../OSGI-INF/blueprint/h2-svr-service.xml | 89 +
.../org.apache.plc4x.merlot.modbus.dev/.classpath | 57 +
.../org.apache.plc4x.merlot.modbus.dev/.project | 34 +
.../.settings/org.eclipse.jdt.apt.core.prefs | 2 +
.../.settings/org.eclipse.jdt.core.prefs | 9 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
.../org.apache.plc4x.merlot.modbus.dev/pom.xml | 117 +
.../cfg/org.apache.plc4x.merlot.modbus.dev.cfg | 50 +
.../apache/plc4x/merlot/modbus/dev/api/Modbus.java | 305 +
.../plc4x/merlot/modbus/dev/api/ModbusDevice.java | 146 +
.../merlot/modbus/dev/api/ModbusDeviceArray.java | 47 +
.../dev/command/ModbusDeviceDumpCommand.java | 102 +
.../dev/command/ModbusDeviceListCommand.java | 78 +
.../modbus/dev/command/ModbusDeviceNewCommand.java | 125 +
.../dev/command/ModbusDeviceReadCommand.java | 79 +
.../dev/command/ModbusDeviceWriteCommand.java | 81 +
.../merlot/modbus/dev/core/ModbusDeviceHelper.java | 256 +
.../dev/core/ModbusDeviceManagedService.java | 115 +
.../modbus/dev/impl/ModbusDeviceArrayImpl.java | 98 +
.../modbus/dev/impl/ModbusDeviceGrpcImpl.java | 204 +
.../merlot/modbus/dev/impl/ModbusDeviceImpl.java | 167 +
.../OSGI-INF/blueprint/modbus-service.xml | 56 +
.../src/main/resources/OSGI-INF/bundle.info | 39 +
.../org.apache.plc4x.merlot.modbus.sim/.classpath | 57 +
.../org.apache.plc4x.merlot.modbus.sim/.project | 34 +
.../.settings/org.eclipse.jdt.apt.core.prefs | 2 +
.../.settings/org.eclipse.jdt.core.prefs | 9 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
.../org.apache.plc4x.merlot.modbus.sim/pom.xml | 134 +
.../cfg/org.apache.plc4x.merlot.modbus.sim.cfg | 90 +
.../plc4x/merlot/modbus/sim/api/ModbusSim.java | 59 +
.../merlot/modbus/sim/api/ModbusSimMBean.java | 52 +
.../modbus/sim/command/ModbusSimAdminCommand.java | 87 +
.../modbus/sim/core/ModbusSimManagedService.java | 157 +
.../modbus/sim/core/ModbusSimSignalType.java | 48 +
.../merlot/modbus/sim/impl/ModbusSimFuncImpl.java | 73 +
.../merlot/modbus/sim/impl/ModbusSimImpl.java | 406 +
.../merlot/modbus/sim/impl/ModbusSimMBeanImpl.java | 106 +
.../modbus/sim/impl/ModbusSimRandomImpl.java | 69 +
.../modbus/sim/impl/ModbusSimSignalImpl.java | 108 +
.../OSGI-INF/blueprint/modbus-sim-service.xml | 39 +
.../src/main/scilab/plot_sawtooth.sce | 54 +
.../src/main/scilab/plot_sin.sce | 57 +
.../src/main/scilab/plot_square.sce | 55 +
.../src/main/scilab/plot_triangular.sce | 57 +
.../org.apache.plc4x.merlot.modbus.svr/.classpath | 57 +
.../org.apache.plc4x.merlot.modbus.svr/.project | 34 +
.../.settings/org.eclipse.jdt.apt.core.prefs | 2 +
.../.settings/org.eclipse.jdt.core.prefs | 9 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
.../org.apache.plc4x.merlot.modbus.svr/pom.xml | 134 +
.../cfg/org.apache.plc4x.merlot.modbus.svr.cfg | 44 +
.../plc4x/merlot/modbus/svr/api/ModbusADU.java | 56 +
.../plc4x/merlot/modbus/svr/api/ModbusServer.java | 70 +
.../merlot/modbus/svr/api/ModbusServerMBean.java | 58 +
.../modbus/svr/command/ModbusServerCommand.java | 88 +
.../modbus/svr/core/ModbusServerADUDecoder.java | 61 +
.../modbus/svr/core/ModbusServerADUEncoder.java | 52 +
.../modbus/svr/core/ModbusServerADUHandler.java | 847 ++
.../modbus/svr/core/ModbusServerInitializer.java | 39 +
.../svr/core/ModbusServerManagedService.java | 124 +
.../merlot/modbus/svr/impl/ModbusADUImpl.java | 119 +
.../merlot/modbus/svr/impl/ModbusServerImpl.java | 236 +
.../modbus/svr/impl/ModbusServerMBeanImpl.java | 123 +
.../OSGI-INF/blueprint/modbus-svr-service.xml | 40 +
.../src/main/resources/OSGI-INF/bundle.info | 49 +
.../org.apache.plc4x.merlot.scheduler/.classpath | 57 +
.../org.apache.plc4x.merlot.scheduler/.project | 34 +
.../.settings/org.eclipse.jdt.apt.core.prefs | 2 +
.../.settings/org.eclipse.jdt.core.prefs | 9 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
.../org.apache.plc4x.merlot.scheduler/pom.xml | 149 +
.../org/apache/plc4x/merlot/scheduler/api/Job.java | 36 +
.../plc4x/merlot/scheduler/api/JobContext.java | 40 +
.../merlot/scheduler/api/ScheduleOptions.java | 65 +
.../plc4x/merlot/scheduler/api/Scheduler.java | 162 +
.../plc4x/merlot/scheduler/api/SchedulerError.java | 38 +
.../plc4x/merlot/scheduler/api/SchedulerMBean.java | 32 +
.../merlot/scheduler/api/SchedulerStorage.java | 48 +
.../merlot/scheduler/api/SchedulerWhiteBoard.java | 48 +
.../plc4x/merlot/scheduler/command/List.java | 50 +
.../plc4x/merlot/scheduler/command/Reschedule.java | 86 +
.../merlot/scheduler/command/ScheduleCommand.java | 93 +
.../merlot/scheduler/command/ScheduleScript.java | 101 +
.../plc4x/merlot/scheduler/command/Trigger.java | 59 +
.../plc4x/merlot/scheduler/command/Unschedule.java | 47 +
.../command/completer/JobNameCompleter.java | 54 +
.../scheduler/command/support/CommandJob.java | 49 +
.../scheduler/command/support/ScriptJob.java | 55 +
.../scheduler/command/support/TriggerJob.java | 50 +
.../plc4x/merlot/scheduler/core/Activator.java | 76 +
.../scheduler/core/InternalScheduleOptions.java | 171 +
.../merlot/scheduler/core/KarafStdScheduler.java | 108 +
.../scheduler/core/KarafStdSchedulerFactory.java | 47 +
.../core/NonParallelQuartzJobExecutor.java | 33 +
.../merlot/scheduler/core/QuartzJobExecutor.java | 96 +
.../merlot/scheduler/core/QuartzScheduler.java | 340 +
.../scheduler/core/QuartzSchedulerStorage.java | 51 +
.../merlot/scheduler/core/SchedulerMBeanImpl.java | 93 +
.../merlot/scheduler/core/WhiteboardHandler.java | 179 +
.../scheduler/impl/SchedulerWhiteBoardImpl.java | 172 +
.../OSGI-INF/blueprint/scheduler-service.xml | 71 +
.../src/main/resources/OSGI-INF/bundle.info | 46 +
.../nb-configuration.xml | 19 +
.../merlot/org.apache.plc4x.merlot.ui/pom.xml | 242 +
.../plc4x/merlot/ui/JakartaRestConfiguration.java | 13 +
.../merlot/ui/resources/JakartaEE10Resource.java | 20 +
.../src/main/qooxdoo/.gitignore | 4 +
.../src/main/qooxdoo/Manifest.json | 26 +
.../src/main/qooxdoo/compile.json | 29 +
.../src/main/qooxdoo/package-lock.json | 12416 +++++++++++++++++++
.../src/main/qooxdoo/package.json | 8 +
.../src/main/qooxdoo/qx-lock.json | 29 +
.../src/main/qooxdoo/readme.md | 5 +
.../src/main/qooxdoo/source/boot/index.html | 49 +
.../src/main/qooxdoo/source/boot/nojs.html | 26 +
.../ui/controller/services/eventlog/EventLog.js | 6 +
.../class/org/apache/plc4x/ui/test/DemoTest.js | 55 +
.../class/org/apache/plc4x/ui/view/Application.js | 93 +
.../org/apache/plc4x/ui/view/DefaultLayout.js | 397 +
.../class/org/apache/plc4x/ui/view/__init__.js | 6 +
.../org/apache/plc4x/ui/view/theme/Appearance.js | 18 +
.../class/org/apache/plc4x/ui/view/theme/Color.js | 18 +
.../org/apache/plc4x/ui/view/theme/Decoration.js | 18 +
.../class/org/apache/plc4x/ui/view/theme/Font.js | 18 +
.../class/org/apache/plc4x/ui/view/theme/Theme.js | 21 +
.../org/apache/plc4x/ui/view/utils/FormItems.js | 350 +
.../org/apache/plc4x/ui/view/utils/LogTable.js | 137 +
.../org/apache/plc4x/ui/view/utils/TestLayout.js | 144 +
.../class/org/apache/plc4x/ui/view/utils/Tree.js | 222 +
.../apache/plc4x/ui/view/utils/TreeDataHandler.js | 460 +
.../source/resource/org/apache/plc4x/ui/app.png | Bin 0 -> 4523 bytes
.../org/apache/plc4x/ui/css/sourceview.css | 41 +
.../resource/org/apache/plc4x/ui/css/style.css | 41 +
.../resource/org/apache/plc4x/ui/favicon.png | Bin 0 -> 1488 bytes
.../resource/org/apache/plc4x/ui/js_256x256.png | Bin 0 -> 2950 bytes
.../source/resource/org/apache/plc4x/ui/test.png | Bin 0 -> 2478 bytes
.../main/qooxdoo/source/resource/plc4xui/app.png | Bin 0 -> 4523 bytes
.../qooxdoo/source/resource/plc4xui/favicon.png | Bin 0 -> 1488 bytes
.../qooxdoo/source/resource/plc4xui/js_256x256.png | Bin 0 -> 2950 bytes
.../main/qooxdoo/source/resource/plc4xui/test.png | Bin 0 -> 2478 bytes
.../src/main/qooxdoo/source/translation/readme.txt | 1 +
.../src/main/resources/META-INF/persistence.xml | 7 +
.../src/main/webapp/WEB-INF/beans.xml | 6 +
.../src/main/webapp/WEB-INF/web.xml | 11 +
.../merlot/org.apache.plc4x.merlot.uns/.classpath | 57 +
.../merlot/org.apache.plc4x.merlot.uns/.project | 34 +
.../.settings/org.eclipse.jdt.apt.core.prefs | 2 +
.../.settings/org.eclipse.jdt.core.prefs | 9 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
.../merlot/org.apache.plc4x.merlot.uns/pom.xml | 309 +
.../src/main/cfg/org.apache.plc4x.merlot.uns.cfg | 28 +
.../src/main/cfg/org.ops4j.datasource-model.cfg | 30 +
.../src/main/cfg/org.ops4j.datasource-tf.cfg | 30 +
.../org/apache/plc4x/merlot/uns/api/Model.java | 98 +
.../apache/plc4x/merlot/uns/api/ModelMBean.java | 40 +
.../plc4x/merlot/uns/command/ModelAddCommand.java | 65 +
.../plc4x/merlot/uns/command/ModelDelCommand.java | 51 +
.../merlot/uns/command/ModelDomineCommand.java | 67 +
.../plc4x/merlot/uns/command/ModelTreeCommand.java | 73 +
.../plc4x/merlot/uns/core/EmbeddedADSVerTrunk.java | 324 +
.../plc4x/merlot/uns/core/LdapEmbeddedServer.java | 65 +
.../plc4x/merlot/uns/core/ModelManagedService.java | 38 +
.../plc4x/merlot/uns/core/ModelRPCService.java | 162 +
.../plc4x/merlot/uns/core/PhysicalModelEnum.java | 31 +
.../apache/plc4x/merlot/uns/impl/ModelImpl.java | 611 +
.../plc4x/merlot/uns/impl/ModelMBeanImpl.java | 73 +
.../resources/OSGI-INF/blueprint/uns-service.xml | 82 +
.../tools/merlot/org.apache.plc4x.merlot/.project | 28 +
.../.settings/org.eclipse.m2e.core.prefs | 4 +
plc4j/tools/merlot/org.apache.plc4x.merlot/pom.xml | 228 +
plc4j/tools/merlot/pom.xml | 139 +
384 files changed, 44639 insertions(+)
diff --git a/plc4j/tools/merlot/.project b/plc4j/tools/merlot/.project
new file mode 100644
index 0000000..8170b95
--- /dev/null
+++ b/plc4j/tools/merlot/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.apache.plc4x-plc4j-apache-karaf</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+ <filteredResources>
+ <filter>
+ <id>1711319417495</id>
+ <name></name>
+ <type>30</type>
+ <matcher>
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
+ <arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
+ </matcher>
+ </filter>
+ </filteredResources>
+</projectDescription>
diff --git a/plc4j/tools/merlot/.settings/org.eclipse.m2e.core.prefs b/plc4j/tools/merlot/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/plc4j/tools/merlot/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/plc4j/tools/merlot/org.apache.plc4x.dummy/pom.xml b/plc4j/tools/merlot/org.apache.plc4x.dummy/pom.xml
new file mode 100644
index 0000000..2cbb9f9
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.dummy/pom.xml
@@ -0,0 +1,72 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <!--
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>plc4j-apache-karaf</artifactId>
+ <groupId>org.apache.plc4x</groupId>
+ <version>0.13.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.plc4x.dummy</groupId>
+ <artifactId>org.apache.plc4x.dummy</artifactId>
+ <version>0.13.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>org.apache.plc4x.dummy Blueprint Bundle</name>
+ <description>org.apache.plc4x.dummy OSGi blueprint bundle project.</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>5.1.8</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Bundle-Version>0.13.0-SNAPSHOT</Bundle-Version>
+ <Export-Package>org.apache.plc4x.dummy*;version=0.13.0-SNAPSHOT</Export-Package>
+ <Import-Package>*</Import-Package>
+ <Karaf-Commands>org.apache.plc4x.dummy*</Karaf-Commands>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ <maxmem>256M</maxmem>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.directory.api</groupId>
+ <artifactId>api-ldap-model</artifactId>
+ <version>2.1.4</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/plc4j/tools/merlot/org.apache.plc4x.dummy/src/main/java/org/apache/plc4x/dummy/Comando.java b/plc4j/tools/merlot/org.apache.plc4x.dummy/src/main/java/org/apache/plc4x/dummy/Comando.java
new file mode 100644
index 0000000..cfdace9
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.dummy/src/main/java/org/apache/plc4x/dummy/Comando.java
@@ -0,0 +1,34 @@
+/*
+ * 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.dummy;
+
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+
+
+@Command(scope = "dummy", name = "new", description = "Command for test.")
+@Service
+public class Comando implements Action{
+
+ @Override
+ public Object execute() throws Exception {
+ System.out.println("Ejecuto comando...");
+ return null;
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.dummy/src/main/java/org/apache/plc4x/dummy/MyService.java b/plc4j/tools/merlot/org.apache.plc4x.dummy/src/main/java/org/apache/plc4x/dummy/MyService.java
new file mode 100644
index 0000000..8afdd2f
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.dummy/src/main/java/org/apache/plc4x/dummy/MyService.java
@@ -0,0 +1,23 @@
+/*
+ * 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.dummy;
+
+public interface MyService {
+
+ public String echo(String message);
+
+}
\ No newline at end of file
diff --git a/plc4j/tools/merlot/org.apache.plc4x.dummy/src/main/java/org/apache/plc4x/dummy/MyServiceImpl.java b/plc4j/tools/merlot/org.apache.plc4x.dummy/src/main/java/org/apache/plc4x/dummy/MyServiceImpl.java
new file mode 100644
index 0000000..42f3f73
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.dummy/src/main/java/org/apache/plc4x/dummy/MyServiceImpl.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.dummy;
+
+public class MyServiceImpl implements MyService {
+
+ public String echo(String message) {
+ return "Echo processed: " + message;
+ }
+
+}
\ No newline at end of file
diff --git a/plc4j/tools/merlot/org.apache.plc4x.dummy/src/main/resources/OSGI-INF/blueprint/my-service.xml b/plc4j/tools/merlot/org.apache.plc4x.dummy/src/main/resources/OSGI-INF/blueprint/my-service.xml
new file mode 100644
index 0000000..b8e10ef
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.dummy/src/main/resources/OSGI-INF/blueprint/my-service.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="lazy">
+
+ <bean id="serviceBean" class="org.apache.plc4x.dummy.MyServiceImpl"/>
+
+ <service ref="serviceBean" interface="org.apache.plc4x.dummy.MyService"/>
+
+</blueprint>
\ No newline at end of file
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/.classpath b/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/.classpath
new file mode 100644
index 0000000..653dfd7
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/.classpath
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="optional" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="test" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="test" value="true"/>
+ <attribute name="optional" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path="target/generated-sources/annotations">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="ignore_optional_problems" value="true"/>
+ <attribute name="m2e-apt" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="ignore_optional_problems" value="true"/>
+ <attribute name="m2e-apt" value="true"/>
+ <attribute name="test" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/.project b/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/.project
new file mode 100644
index 0000000..35fe541
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.apache.plc4x.merlot.branding-org.apache.plc4x.merlot.branding</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+ <filteredResources>
+ <filter>
+ <id>1711319417660</id>
+ <name></name>
+ <type>30</type>
+ <matcher>
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
+ <arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
+ </matcher>
+ </filter>
+ </filteredResources>
+</projectDescription>
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/.settings/org.eclipse.jdt.apt.core.prefs b/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/.settings/org.eclipse.jdt.apt.core.prefs
new file mode 100644
index 0000000..d4313d4
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/.settings/org.eclipse.jdt.apt.core.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.apt.aptEnabled=false
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/.settings/org.eclipse.jdt.core.prefs b/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..1b6e1ef
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,9 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
+org.eclipse.jdt.core.compiler.processAnnotations=disabled
+org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/.settings/org.eclipse.m2e.core.prefs b/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/pom.xml b/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/pom.xml
new file mode 100644
index 0000000..2ac1126
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/pom.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <!--
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>merlot</artifactId>
+ <groupId>org.apache.plc4x</groupId>
+ <version>0.13.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.plc4x.merlot.branding</groupId>
+ <artifactId>org.apache.plc4x.merlot.branding</artifactId>
+ <version>0.13.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>PLC4J: Merlot :: branding :: Merlot branding</name>
+ <description>org.apache.plc4x.merlot.branding OSGi bundle project.</description>
+
+ <properties>
+ <maven-bundle-plugin.version>5.1.8</maven-bundle-plugin.version>
+ <osgi.version>8.0.0</osgi.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.core</artifactId>
+ <version>${osgi.version}</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>${maven-bundle-plugin.version}</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Bundle-Version>0.13.0-SNAPSHOT</Bundle-Version>
+ <!--
+ <Bundle-Activator>org.apache.plc4x.merlot.branding.Activator</Bundle-Activator>
+ <Export-Package>org.apache.plc4x.merlot.branding*;version=0.13.0-SNAPSHOT</Export-Package>
+ -->
+ <Export-Package>org.apache.karaf.branding*</Export-Package>
+ <Spring-Context>*;publish-context:=false</Spring-Context>
+ <Import-Package>*</Import-Package>
+ <Private-Package>!*</Private-Package>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ <maxmem>256M</maxmem>
+ </configuration>
+ </plugin>
+
+ </plugins>
+ </build>
+
+</project>
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/src/main/java/org/apache/plc4x/merlot/branding/Activator.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/src/main/java/org/apache/plc4x/merlot/branding/Activator.java
new file mode 100644
index 0000000..2463998
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/src/main/java/org/apache/plc4x/merlot/branding/Activator.java
@@ -0,0 +1,32 @@
+/*
+ * 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.branding;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class Activator implements BundleActivator {
+
+ public void start(BundleContext context) {
+ System.out.println("Starting the bundle");
+ }
+
+ public void stop(BundleContext context) {
+ System.out.println("Stopping the bundle");
+ }
+
+}
\ No newline at end of file
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/src/main/resources/org/apache/karaf/branding/branding-ssh.properties b/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/src/main/resources/org/apache/karaf/branding/branding-ssh.properties
new file mode 100644
index 0000000..19aef77
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/src/main/resources/org/apache/karaf/branding/branding-ssh.properties
@@ -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.
+##
+
+welcome = \
+\u001B[36m __ __ _ _ \u001B[0m\r\n\
+\u001B[36m | \\/ | ___ _ __ | | ___ | |_ \u001B[0m\r\n\
+\u001B[36m | |\\/| | / _ \\ | '__| | | / _ \\ | __| \u001B[0m\r\n\
+\u001B[36m | | | | | __/ | | | | | (_) | | |_ \u001B[0m\r\n\
+\u001B[36m |_| |_| \\___| |_| |_| \\___/ \\__| \u001B[0m\r\n\
+\r\n\
+\u001B[33m Plc4x-Merlot \u001B[34mIndustrial \u001B[31mGateway\u001B[0m \r\n\
+\r\n\
+Hit '\u001B[1m<tab>\u001B[0m' for a list of available commands\r\n\
+ and '\u001B[1m[cmd] --help\u001B[0m' for help on a specific command.\r\n\
+Hit '\u001B[1m<ctrl-d>\u001B[0m' or type '\u001B[1msystem:shutdown\u001B[0m' or '\u001B[1mlogout\u001B[0m' to shutdown Merlot.\r\n
+
+
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/src/main/resources/org/apache/karaf/branding/branding.properties b/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/src/main/resources/org/apache/karaf/branding/branding.properties
new file mode 100644
index 0000000..5de53df
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.branding/src/main/resources/org/apache/karaf/branding/branding.properties
@@ -0,0 +1,31 @@
+##
+## 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.
+##
+
+welcome = \
+\u001B[36m __ __ _ _ \u001B[0m\r\n\
+\u001B[36m | \\/ | ___ _ __ | | ___ | |_ \u001B[0m\r\n\
+\u001B[36m | |\\/| | / _ \\ | '__| | | / _ \\ | __| \u001B[0m\r\n\
+\u001B[36m | | | | | __/ | | | | | (_) | | |_ \u001B[0m\r\n\
+\u001B[36m |_| |_| \\___| |_| |_| \\___/ \\__| \u001B[0m\r\n\
+\r\n\
+\u001B[33m Plc4x-Merlot \u001B[34mIndustrial \u001B[31mGateway\u001B[0m \r\n\
+\r\n\
+Hit '\u001B[1m<tab>\u001B[0m' for a list of available commands\r\n\
+ and '\u001B[1m[cmd] --help\u001B[0m' for help on a specific command.\r\n\
+Hit '\u001B[1m<ctrl-d>\u001B[0m' or type '\u001B[1msystem:shutdown\u001B[0m' or '\u001B[1mlogout\u001B[0m' to shutdown Merlot.\r\n
\ No newline at end of file
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/.classpath b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/.classpath
new file mode 100644
index 0000000..653dfd7
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/.classpath
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="optional" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="test" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="test" value="true"/>
+ <attribute name="optional" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path="target/generated-sources/annotations">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="ignore_optional_problems" value="true"/>
+ <attribute name="m2e-apt" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="ignore_optional_problems" value="true"/>
+ <attribute name="m2e-apt" value="true"/>
+ <attribute name="test" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/.project b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/.project
new file mode 100644
index 0000000..0b2f2e4
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.apache.plc4x.merlot.api-org.apache.plc4x.merlot.api</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+ <filteredResources>
+ <filter>
+ <id>1711319417658</id>
+ <name></name>
+ <type>30</type>
+ <matcher>
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
+ <arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
+ </matcher>
+ </filter>
+ </filteredResources>
+</projectDescription>
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/.settings/org.eclipse.jdt.apt.core.prefs b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/.settings/org.eclipse.jdt.apt.core.prefs
new file mode 100644
index 0000000..d4313d4
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/.settings/org.eclipse.jdt.apt.core.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.apt.aptEnabled=false
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/.settings/org.eclipse.jdt.core.prefs b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..1b6e1ef
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,9 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
+org.eclipse.jdt.core.compiler.processAnnotations=disabled
+org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/.settings/org.eclipse.m2e.core.prefs b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
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
new file mode 100644
index 0000000..c63fcb9
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/pom.xml
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <!--
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>merlot</artifactId>
+ <groupId>org.apache.plc4x</groupId>
+ <version>0.13.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.plc4x.merlot.api</groupId>
+ <artifactId>org.apache.plc4x.merlot.api</artifactId>
+ <version>0.13.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>PLC4J: Merlot :: api :: OSGi Device access</name>
+ <description>org.apache.plc4x.merlot.api OSGi blueprint bundle project.</description>
+
+ <build>
+
+ <extensions>
+ <!-- Detecta el sistema operativo y lo agrega al ambiente de Maven -->
+ <extension>
+ <groupId>kr.motd.maven</groupId>
+ <artifactId>os-maven-plugin</artifactId>
+ <version>1.7.1</version>
+ </extension>
+ </extensions>
+
+ <plugins>
+
+ <plugin>
+ <groupId>org.xolstice.maven.plugins</groupId>
+ <artifactId>protobuf-maven-plugin</artifactId>
+ <version>0.6.1</version>
+ <configuration>
+ <protocArtifact>com.google.protobuf:protoc:3.25.1:exe:${os.detected.classifier}</protocArtifact>
+ <pluginId>grpc-java</pluginId>
+ <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.62.2:exe:${os.detected.classifier}</pluginArtifact>
+ <protoSourceRoot>src/main/resources/proto</protoSourceRoot>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>compile</goal>
+ <goal>compile-custom</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>5.1.8</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Bundle-Version>0.13.0-SNAPSHOT</Bundle-Version>
+ <Export-Package>org.apache.plc4x.merlot.api*;version=0.13.0-SNAPSHOT</Export-Package>
+ <Import-Package>*</Import-Package>
+ <Karaf-Commands>org.apache.plc4x.merlot.api.command*</Karaf-Commands>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ <maxmem>256M</maxmem>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-buffer</artifactId>
+ <version>${netty.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4j-api</artifactId>
+ <version>0.13.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.cmpn</artifactId>
+ <version>${osgi.cmpn.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.lmax</groupId>
+ <artifactId>disruptor</artifactId>
+ <version>${disruptor.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.service.dal</artifactId>
+ <version>1.0.2</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.plc4x.merlot.scheduler</groupId>
+ <artifactId>org.apache.plc4x.merlot.scheduler</artifactId>
+ <version>0.13.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.core</artifactId>
+ <version>${osgi.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf</groupId>
+ <artifactId>org.apache.karaf.util</artifactId>
+ <version>${karaf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.core</artifactId>
+ <version>${karaf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>annotations-api</artifactId>
+ <version>${tomcat.annotation.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ <version>${guava.android.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.google.errorprone</groupId>
+ <artifactId>error_prone_annotations</artifactId>
+ <version>${errorprone.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-api</artifactId>
+ <version>${grpc.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-stub</artifactId>
+ <version>${grpc.version}</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-protobuf</artifactId>
+ <version>${grpc.version}</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-netty-shaded</artifactId>
+ <version>${grpc.version}</version>
+ <type>jar</type>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-lang3</artifactId>
+ <version>3.14.0</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/cfg/org.apache.plc4x.merlot.das.devices.cfg b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/cfg/org.apache.plc4x.merlot.das.devices.cfg
new file mode 100644
index 0000000..37b0094
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/cfg/org.apache.plc4x.merlot.das.devices.cfg
@@ -0,0 +1,50 @@
+
+################################################################################
+#
+# 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.
+#
+################################################################################
+
+################################################################################
+# Demo config file for devices.
+#
+# The configuration files have the following content:
+#
+# device=url,name,description
+#
+# where
+#
+# . device: Descriptive name within the control architecture.
+# Must be unique.
+# . url: URL as the driver is defined. It generally follows the
+# standardized pattern in the Apache PLC4X project.
+# . name: Device short name.
+# . description: Long description of the device. Such as location
+# or functionality.
+#
+# Example:
+# AS01=s7://192.168.1.23/0/2,simatic,compresor system
+#
+# Although there can be a single configuration file for all devices,
+# practice shows that it is recommended to have one configuration file
+# per device.
+#
+# Example:
+# org.apache.plc4x.merlot.das.device-AS01.cfg
+#
+################################################################################
+
+
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/ByteBasedDriver.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/ByteBasedDriver.java
new file mode 100644
index 0000000..dff0bbd
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/ByteBasedDriver.java
@@ -0,0 +1,121 @@
+/*
+ * 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
+ *
+ * https://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;
+
+import io.netty.buffer.ByteBuf;
+
+
+public interface ByteBasedDriver extends Driver{
+
+ //Administrative
+
+ public long InitializeDevice(DriverCallback cb);
+ public long ShutDownDevice(DriverCallback cb);
+
+ //Device Handler
+
+ public long GetDeviceMode(DriverCallback cb);
+ public long StartDevice(DriverCallback cb);
+ public long StopDevice(DriverCallback cb);
+ public long GetPDUSize(DriverCallback cb);
+
+ //Bits
+
+ /*
+ * This function can be used to read bits in a device in packed format.
+ * The different values are stored in the ByteBuf table called.
+ * The bits which are not read in the last byte that receives the data
+ * are in an undetermined state.
+ * @param channel Channel number (0-31)
+ * @param device Device number (0-255)
+ * @param nb Number of bits to be read. The maximum number depends on the protocol and target device.
+ * @param adr Address of the first bit to be read in the device.
+ * @return ByteBuf Table receiving read data.
+ */
+ public ByteBuf ReadMemoryBits(DriverCallback cb, int device, int nb, int adr);
+
+ /*
+ * This function can be used to write bits in a device in packed format.
+ * The different values are stored in the ByteBuf table called bf.
+ * The bits which are not read in the last byte that receives the data
+ * are in an undetermined state.
+ * @param channel Channel number (0-31)
+ * @param device Device number (0-255)
+ * @param nb Number of bits to be read. The maximum number depends on the protocol and target device.
+ * @param adr Adress of the first bit to be write in the device.
+ * @return int Error status.
+ */
+ public long WriteMemoryBits(DriverCallback cb, int device, int nb, int adr, ByteBuf bf);
+
+ public long ReadInputBits(DriverCallback cb, int device, int nb, int adr);
+
+ public long ReadOutputBits(DriverCallback cb, int device, int nb, int adr);
+ public long WriteOutputBits(DriverCallback cb, int device, int nb, int adr, ByteBuf bf);
+
+ public long ReadDataBits(DriverCallback cb, int device, int nb, int adr);
+ public long WriteDataBits(DriverCallback cb, int device, int nb, int adr, ByteBuf bf);
+
+ //Bytes
+
+ public long ReadMemoryBytes(DriverCallback cb, int device, int nb, int adr);
+ public long WriteMemoryBytes(DriverCallback cb, int device, int nb, int adr, ByteBuf bf);
+
+ public long ReadInputBytes(DriverCallback cb, int device, int nb, int adr, ByteBuf bf);
+
+ public long ReadOutputBytes(DriverCallback cb, int device, int nb, int adr);
+ public long WriteOutputBytes(DriverCallback cb, int device, int nb, int adr, ByteBuf bf);
+
+ public long ReadDataBytes(DriverCallback cb, int device, int nb, int adr);
+ public long WriteDataBytes(DriverCallback cb, int device, int nb, int adr, ByteBuf bf);
+
+ //Words
+
+ public long ReadMemoryWords(DriverCallback cb, int device, int nb, int adr);
+ public long WriteMemoryWords(DriverCallback cb, int device, int nb, int adr, ByteBuf bf);
+
+ public long ReadInputWords(DriverCallback cb, int device, int nb, int adr);
+
+ public long ReadOutputWords(DriverCallback cb, int device, int nb, int adr);
+ public long WriteOutputWords(DriverCallback cb, int device, int nb, int adr, ByteBuf bf);
+
+ public long ReadDataWords(DriverCallback cb, int device, int nb, int adr);
+ public long WriteDataWords(DriverCallback cb, int device, int nb, int adr, ByteBuf bf);
+
+ //Double Words
+
+ public long ReadMemoryDoubleWords(DriverCallback cb, int device, int nb, int adr);
+ public long WriteMemorDoubleyWords(DriverCallback cb, int device, int nb, int adr, ByteBuf bf);
+
+ public long ReadInputDoubleWords(DriverCallback cb, int device, int nb, int adr);
+
+ public long ReadOutputDoubleWords(DriverCallback cb, int device, int nb, int adr);
+ public long WriteOutputDoubleWords(DriverCallback cb, int device, int nb, int adr, ByteBuf bf);
+
+ public long ReadDataDoubleWords(DriverCallback cb, int device, int nb, int adr);
+ public long WriteDataDoubleWords(DriverCallback cb, int device, int nb, int adr, ByteBuf bf);
+
+ //Timer and Counter functions
+
+ public long ReadTimer(DriverCallback cb, int device, int nb, int adr);
+ public long WriteTimer(DriverCallback cb, int device, int nb, int adr, ByteBuf bf);
+
+ public long ReadCounter(DriverCallback cb, int device, int nb, int adr);
+ public long WriteCounter(DriverCallback cb, int device, int nb, int adr, ByteBuf bf);
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/Driver.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/Driver.java
new file mode 100644
index 0000000..4242fbc
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/Driver.java
@@ -0,0 +1,104 @@
+/*
+ * 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
+ *
+ * https://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;
+
+import org.apache.plc4x.merlot.api.core.Merlot;
+import org.apache.plc4x.merlot.api.core.Merlot.STATE;
+import java.time.LocalDateTime;
+
+
+public interface Driver extends org.osgi.service.device.Driver {
+
+ public void init() throws Exception;
+
+ public void destroy() throws Exception;
+
+
+ public void reset();
+ public void start();
+ public void stop();
+ public void abort();
+ public void clear();
+ public void hold();
+ public void unhold();
+ public void suspend();
+ public void unsuspend();
+
+ public void onStopped();
+ public void onResetting();
+ public void onIdle();
+ public void onStarting();
+ public void onExecute();
+ public void onCompleting();
+ public void onComplete();
+ public void onHolding();
+ public void onHeld();
+ public void onUnholding();
+ public void onSuspending();
+ public void onSuspended();
+ public void onUnsuspending();
+ public void onAborting();
+ public void onAborted();
+ public void onClearing();
+ public void onStopping();
+
+
+
+
+ public STATE getState();
+
+ public void setUrl(String url);
+
+ public String getUrl();
+
+ public LocalDateTime getStartDateTime();
+
+ public LocalDateTime getLastFailDateTime();
+
+ public long getRunningTime();
+
+ public long getStoppedTime();
+
+ public long getSendMessages();
+
+ public long getFailedMessages();
+
+ public long getDelay();
+
+ public long getMaxDelay();
+
+ public long getMinDelay();
+
+ public void putEvent(DriverEvent event);
+
+ public DriverEvent getEvent();
+
+ public DriverEvent EventFactory(Merlot m);
+
+ public long getRequestQueueSize();
+
+ public long getRequestQueueItems();
+
+ public long getResponseQueueSize();
+
+ public long getResponseQueueItems();
+
+
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/DriverCallback.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/DriverCallback.java
new file mode 100644
index 0000000..88b7dbc
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/DriverCallback.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
+ *
+ * https://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;
+
+
+public interface DriverCallback {
+
+ public void execute(DriverEvent cb);
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/DriverEvent.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/DriverEvent.java
new file mode 100644
index 0000000..206661e
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/DriverEvent.java
@@ -0,0 +1,85 @@
+/*
+ * 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
+ *
+ * https://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;
+
+import org.apache.plc4x.merlot.api.core.Merlot.FUNCTION;
+import io.netty.buffer.ByteBuf;
+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;
+
+
+public interface DriverEvent {
+
+ public void setSequence(long Sequence);
+
+ public long getSequence();
+
+ public void setTransactionID(int TransactionID);
+
+ public int getTransactionID();
+
+ public void setProtocolID(short ProtocolID);
+
+ public short getProtocolID();
+
+ public void setField(int Field);
+
+ public int getField();
+
+ public void setLengthField(int LengthField);
+
+ public int getLengthField();
+
+ public void setUnitID(byte UnitID);
+
+ public byte getUnitID();
+
+ public void setFunctionCode(FUNCTION FunctionCode);
+
+ public FUNCTION getFunctionCode();
+
+ public void setData(ByteBuf Data);
+
+ public ByteBuf getData();
+
+ public byte[] getSerialized() ;
+
+ public void setCallback(DriverCallback cb);
+
+ public DriverCallback getCallback();
+
+
+ public void setPlcReadRequest(PlcReadRequest plcReadRequest);
+ public PlcReadRequest getPlcReadRequest();
+
+ public void setPlcReadResponse(PlcReadResponse plcReadResponse);
+ public PlcReadResponse getPlcReadResponse();
+
+ public void setPlcWriteRequest(PlcWriteRequest plcWriteRequest);
+ public PlcWriteRequest getPlcWriteRequest();
+
+ public void setPlcWriteResponse(PlcWriteResponse plcWriteResponse);
+ public PlcWriteResponse getPlcWriteResponse();
+
+ @Override
+ public String toString();
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/MessageBasedDriver.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/MessageBasedDriver.java
new file mode 100644
index 0000000..d3e1442
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/MessageBasedDriver.java
@@ -0,0 +1,23 @@
+/*
+ * 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
+ *
+ * https://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;
+
+public interface MessageBasedDriver extends Driver{
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/Optimizer.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/Optimizer.java
new file mode 100644
index 0000000..4dc6cb8
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/Optimizer.java
@@ -0,0 +1,38 @@
+/*
+ * 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
+ *
+ * https://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;
+
+
+public interface Optimizer {
+
+ public void init() throws Exception;
+
+ public void destroy() throws Exception;
+
+ public void start();
+
+ public void stop();
+
+ public boolean isOptimized();
+
+ public void setOptimizaed(boolean optimized);
+
+ public boolean doOptimization(Driver driver, DriverEvent rxevent, DriverEvent txevent);
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcChannel.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcChannel.java
new file mode 100644
index 0000000..8a7d48b
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcChannel.java
@@ -0,0 +1,27 @@
+/*
+ * 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
+ *
+ * https://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;
+
+
+public interface PlcChannel {
+
+ public void activate();
+ public void deactivate();
+
+}
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
new file mode 100644
index 0000000..c34e3c4
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcDevice.java
@@ -0,0 +1,125 @@
+/*
+ * 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
+ *
+ * https://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;
+
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.plc4x.java.api.PlcDriver;
+
+
+public interface PlcDevice extends org.osgi.service.device.Device, org.osgi.service.dal.Device {
+
+ /*
+ *
+ */
+ public void init() throws Exception;
+
+ /*
+ *
+ */
+ public void destroy() throws Exception;
+
+ /*
+ *
+ */
+ public void enable();
+
+ /*
+ *
+ */
+ public void disable();
+
+ /*
+ *
+ */
+ public boolean isEnable();
+
+ /*
+ *
+ */
+ public Hashtable<String, ?> getProperties();
+
+ /*
+ *
+ */
+ public String getDeviceName();
+
+ /*
+ *
+ */
+ public void setDeviceName(String groupname);
+
+ /*
+ *
+ */
+ public String getDeviceDescription();
+
+ /*
+ *
+ */
+ public void setDeviceDescription(String groupdescription);
+
+ /*
+ *
+ */
+ public void setUid(UUID uid);
+
+ /*
+ *
+ */
+ public UUID getUid();
+
+ /*
+ *
+ */
+ public void setUrl(String url);
+
+ /*
+ *
+ */
+ public String getUrl();
+
+ /*
+ *
+ */
+ public void attach(PlcDriver driver);
+
+ /*
+ *
+ */
+ public void putGroup(PlcGroup group);
+
+ /*
+ *
+ */
+ public PlcGroup getGroup(UUID uid);
+
+ /*
+ *
+ */
+ public void removeGroup(UUID uid);
+
+ /*
+ *
+ */
+ public List<PlcGroup> getGroups();
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcDeviceFactory.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcDeviceFactory.java
new file mode 100644
index 0000000..9bf5242
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcDeviceFactory.java
@@ -0,0 +1,29 @@
+/*
+ * 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
+ *
+ * https://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;
+
+
+public interface PlcDeviceFactory {
+
+ /*
+ *
+ */
+ public PlcDevice create(String device, String url, String name, String description);
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcFunction.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcFunction.java
new file mode 100644
index 0000000..6de1e43
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcFunction.java
@@ -0,0 +1,30 @@
+/*
+ * 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
+ *
+ * https://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;
+
+import java.util.Hashtable;
+import java.util.Map;
+import org.osgi.service.dal.Function;
+
+
+public interface PlcFunction extends Function {
+
+ public Hashtable<String, Object> getProperties();
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcGeneralFunction.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcGeneralFunction.java
new file mode 100644
index 0000000..768c7c2
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcGeneralFunction.java
@@ -0,0 +1,241 @@
+/*
+ * 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
+ *
+ * https://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;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.plc4x.java.api.value.PlcValue;
+
+
+public interface PlcGeneralFunction extends PlcFunction {
+
+
+ /*
+ * Returns a list of the Plc Drivers registered in the context.
+ *
+ * @return Returns a map with key corresponding to the "code" of the driver
+ * and value corresponding to the "name" of the driver,
+ * where "name" is the long description
+ */
+ public Map<String, String> getPlcDrivers();
+
+ /*
+ * Returns a list of the PlcDevice registered in the context.
+ *
+ * @param driver_code A String with the "code" of the driver.
+ * @return Returns a map with key corresponding to the "uid" of the device
+ * and value corresponding to the "name" of the device.
+ */
+ public Map<UUID, String> getPlcDevices(String driver_code);
+
+ /*
+ * Returns a list of the PlcDevice registered in the context.
+ *
+ * @param driver_code A String with the "code" of the driver.
+ * @return Returns a map with key corresponding to the "uid" of the device
+ * and value corresponding to the "name" of the device.
+ */
+ public PlcDevice getPlcDevice(UUID device_uid);
+
+ /*
+ * Returns the metadata associated with the device, according to
+ * chapter 141 Device Abstraction Layer Specification
+ *
+ * To maintain compatibility between the Device access specification and
+ * Device abstraction layer specifications, the value of the
+ * DEVICE_CATEGORY meta corresponds to that defined in chapter 103.
+ *
+ * From Device chapter 103
+ * DEVICE_CATEGORY = "DEVICE_CATEGORY"
+ * DEVICE_DESCRIPTION = "DEVICE_DESCRIPTION"
+ * DEVICE_SERIAL = "DEVICE_SERIAL"
+ * DRIVER_ID = "DRIVER_ID"
+ *
+ * From Device chapter 141
+ * SERVICE_UID = "dal.device.UID"
+ * SERVICE_REFERENCE_UIDS = "dal.device.reference.UIDs"
+ * SERVICE_DRIVER = "dal.device.driver"
+ * SERVICE_NAME = "dal.device.name"
+ * SERVICE_STATUS = "dal.device.status"
+ * STATUS_REMOVED, STATUS_OFFLINE, STATUS_ONLINE
+ * STATUS_PROCESSING, STATUS_NOT_INITIALIZED,
+ * STATUS_NOT_CONFIGURED
+ * SERVICE_STATUS_DETAIL = "dal.device.status.detail"
+ * STATUS_DETAIL_CONNECTING, STATUS_DETAIL_INITIALIZING
+ * STATUS_DETAIL_REMOVING,STATUS_DETAIL_FIRMWARE_UPDATING
+ * STATUS_DETAIL_CONFIGURATION_UNAPPLIED,
+ * STATUS_DETAIL_BROKEN,
+ * STATUS_DETAIL_COMMUNICATION_ERROR,
+ * STATUS_DETAIL_DATA_INSUFFICIENT,
+ * STATUS_DETAIL_INACCESSIBLE,
+ * STATUS_DETAIL_CONFIGURATION_ERROR,
+ * STATUS_DETAIL_DUTY_CYCLE
+ *
+ * @param group_uid String representation of the group's UUID.
+ * @return Returns a map with key corresponding to the property of the device
+ * and value corresponding to this property of the device.
+ */
+ public Map<String, Object> getPlcDeviceMeta(UUID group_uid);
+
+ /*
+ * @param group_uid String representation of the group's UUID.
+ * @return Returns a map with key corresponding to the property of the device
+ * and value corresponding to this property of the device.
+ */
+ public void setPlcDeviceName(UUID device_uid, String device_name);
+
+
+ /*
+ * @param group_uid String representation of the group's UUID.
+ * @return Returns a map with key corresponding to the property of the device
+ * and value corresponding to this property of the device.
+ */
+ public void setPlcDeviceDesc(UUID device_uid, String device_desc);
+
+ /*
+ * Returns a map of groups associated with the device defined by device_uid,
+ * where key corresponds to the uid of the group, and the value to its name.
+ *
+ * @param device_uid String representation of the device's UUID.
+ * @return Returns a map with key corresponding to the uid of the group
+ * and value corresponding to the name of the group.
+ */
+ public Map<UUID, String> getPlcDeviceGroups(UUID device_uid);
+
+
+ /*
+ * Returns a PlcGroup registered in the context.
+ *
+ * @param group_uid A UUID with the uid of the group.
+ * @return Returns a PlcGroup regsitered like service.
+ *
+ */
+ public PlcGroup getPlcGroup(UUID group_uid);
+
+ /*
+ * Allows you to change the group scanning period. The minimum
+ * value is 100 msec. This value can be changed even
+ * if the device is enabled.
+ *
+ * @param group_uid String representation of the group's UUID.
+ * @return Returns a map with key corresponding to the property of the device
+ * and value corresponding to this property of the device.
+ */
+ public int setPlcGroupScanRate(UUID group_uid, long scan_rate);
+
+ /*
+ * Returns the number of items associated with the
+ * indicated group of group_id.
+ *
+ * @param group_uid String representation of the group's UUID.
+ * @return Returns the number of items in the group.
+ *
+ */
+ public int getPlcGroupItemsCount(UUID group_uid);
+
+ /*
+ * Returns a map of the items associated with the group defined by group_is,
+ * where key corresponds to the uid of the item, and the value to its name.
+ *
+ * @param group_uid String representation of the group's UUID.
+ * @return Returns a map with key corresponding to the uid of the item
+ * and value corresponding to the name of the item.
+ */
+ public Map<UUID, String> getPlcGroupItems(UUID group_uid);
+
+ /*
+ * Returns the data type associated with the item as defined in
+ * org.apache.plc4x.java.api.types.PlcValueType.
+ *
+ * @param item_uid String representation of the item's UUID.
+ * @return Return a short value, representing the value type.
+ */
+ public PlcItem getPlcItem(UUID item_uid);
+
+ /*
+ * Returns the data type associated with the item as defined in
+ * org.apache.plc4x.java.api.types.PlcValueType.
+ *
+ * @param item_uid String representation of the item's UUID.
+ * @return Return a short value, representing the value type.
+ */
+ public short getPlcItemType(UUID item_uid);
+
+ /*
+ * Returns the value associated with the Item.
+ *
+ * @param item_uid String representation of the item's UUID.
+ * @return Return a short value, representing the value type.
+ * It can be null.
+ */
+ public PlcValue getPlcItemValue(UUID item_uid);
+
+ /*
+ * Returns the value associated with the Item as a ByteBuf.
+ *
+ * @param item_uid String representation of the item's UUID.
+ * @return Return a short value, representing the value type.
+ */
+ public ByteBuf getPlcItemByteBuf(UUID item_uid);
+
+ /*
+ * Returns the value associated with the Item as a byte array.
+ *
+
+ * @return Return a short value, representing the value type.
+ */
+ public byte[] getPlcItemBytes(UUID item_uid);
+
+ /*
+ * Enables the element corresponding to the UUID.
+ *
+ * @param item_uid String representation of the item's UUID.
+ */
+ public void enable(UUID uuid);
+
+ /*
+ * Disables the element corresponding to the UUID.
+ *
+ * @param item_uid String representation of the item's UUID.
+ */
+ public void disable(UUID uuid);
+
+ /*
+ * Returns the value associated with the Item.
+ *
+ * @param uuid UUID representation of the device.
+ * @param tag String representation of the item's UUID.
+ * @return Return a short value, representing the value type.
+ * It can be null.
+ */
+ public PlcValue read(UUID uuid, String tag);
+
+ /*
+ * Writes a value to the item defined by UUID and tag.
+ * Value corresponds to the String of the value to be written.
+ *
+ * @param uuid String representation of the item's UUID.
+ * @param tag String representation of the item's UUID.
+ * @param value String representation of the item's UUID.
+ */
+ public void write(UUID uuid, String tag, String value);
+
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcGroup.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcGroup.java
new file mode 100644
index 0000000..9c54b59
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcGroup.java
@@ -0,0 +1,160 @@
+/*
+ * 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
+ *
+ * https://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;
+
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.plc4x.java.api.PlcConnection;
+
+
+public interface PlcGroup {
+
+ public static final String GROUP_DEVICE_UID = "DEVICE_UID";
+
+ public static final String GROUP_UID = "plc4x.group.uid";
+
+ public static final String GROUP_NAME = "scheduler.name";
+
+ public static final String GROUP_DESCRIPTION = "plc4x.group.description";
+
+ public static final String GROUP_PERIOD = "scheduler.period";
+
+ public static final String GROUP_IMMEDIATE = "scheduler.immediate";
+
+ public static final String GROUP_CONCURRENT = "scheduler.concurrent";
+
+ /*
+ *
+ */
+ public void enable();
+
+ /*
+ *
+ */
+ public void disable();
+
+ /*
+ *
+ */
+ public boolean isEnable();
+
+ /*
+ *
+ */
+ public UUID getGroupUid();
+
+ /*
+ *
+ */
+ public UUID getGroupDeviceUid();
+
+ /*
+ *
+ */
+ public void setGroupDeviceUid(UUID device_uid);
+
+ /*
+ *
+ */
+ public String getGroupName();
+
+ /*
+ *
+ */
+ public void setGroupName(String groupname);
+
+ /*
+ *
+ */
+ public String getGroupDescription();
+
+ /*
+ *
+ */
+ public void setGroupDescription(String groupdescription);
+
+ /*
+ *
+ */
+ public long getPeriod();
+
+ /*
+ *
+ */
+ public void setPeriod(long scantime);
+
+ /*
+ *
+ */
+ public long getGroupTransmit();
+
+ /*
+ *
+ */
+ public long getGroupReceives();
+
+ /*
+ *
+ */
+ public long getGroupErrors();
+
+ /*
+ *
+ */
+ public void setPlcConnection(AtomicReference<PlcConnection> plcConnection);
+
+ /*
+ *
+ */
+ public Map<UUID, PlcItem> getGroupItems();
+
+ /*
+ *
+ */
+ public void setGroupItems(long groupitems);
+
+ /*
+ *
+ */
+ public Hashtable<String, Object> getProperties();
+
+ /*
+ *
+ */
+ public void putItem(PlcItem item);
+
+ /*
+ *
+ */
+ public PlcItem getItem(UUID itemkey);
+
+ /*
+ *
+ */
+ public void removeItem(UUID itemkey);
+
+ /*
+ *
+ */
+ public List<PlcItem> getItems();
+
+}
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
new file mode 100644
index 0000000..3e6182c
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcItem.java
@@ -0,0 +1,220 @@
+/*
+ * 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
+ *
+ * https://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;
+
+import io.netty.buffer.ByteBuf;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Hashtable;
+import java.util.UUID;
+import org.apache.plc4x.java.api.messages.PlcReadResponse;
+import org.apache.plc4x.java.api.model.PlcTag;
+import org.apache.plc4x.java.api.types.PlcResponseCode;
+import org.apache.plc4x.java.api.value.PlcValue;
+
+public interface PlcItem {
+
+ /*
+ *
+ */
+ public static final String ITEM_UID = "plc4x.item.uid";
+
+ public static final String ITEM_NAME = "plc4x.item.name";
+
+ public static final String ITEM_DESCRIPTION = "plc4x.item.desc";
+
+ public static final String ITEM_ID = "plc4x.item.id";
+
+ /*
+ *
+ */
+ public void enable();
+
+ /*
+ *
+ */
+ public void disable();
+
+
+ /*
+ *
+ */
+ public UUID getItemUid();
+
+ /*
+ *
+ */
+ public String getItemName();
+
+ /*
+ *
+ */
+ public void setItemName(String itemname);
+
+ /*
+ *
+ */
+ public String getItemDescription();
+
+ /*
+ *
+ */
+ public void setItemDescription(String itemdescription);
+
+ /*
+ *
+ */
+ public String getItemId();
+
+ /*
+ *
+ */
+ public void setItemId(String itemid);
+
+ /*
+ *
+ */
+ public PlcTag getItemPlcTag();
+
+ /*
+ *
+ */
+ public void setItemPlcTag(PlcTag itemplctag);
+
+ /*
+ *
+ */
+ public Boolean getEnable();
+
+ /*
+ *
+ */
+ public void setEnable(Boolean enable);
+
+ /*
+ *
+ */
+ public Boolean isEnable();
+
+ /*
+ *
+ */
+ public Boolean getIsArray();
+
+ /*
+ *
+ */
+ public void setIsArray(Boolean isArray);
+
+ /*
+ *
+ */
+ public Boolean getIsDisableOutput();
+
+ /*
+ *
+ */
+ public void setIsDisableOutput(Boolean isDisableOutput);
+
+ /*
+ *
+ */
+ public long getItemTransmits();
+
+ /*
+ *
+ */
+ public long getItemReceives();
+
+ /*
+ *
+ */
+ public long getItemErrors();
+
+ /*
+ *
+ */
+ public int getAccessRights();
+
+ /*
+ *
+ */
+ public void setAccessRights(int accessrigths);
+
+ /*
+ *
+ */
+ public PlcResponseCode getDataQuality();
+
+ /*
+ *
+ */
+ public void setDataQuality(PlcResponseCode dataquality);
+
+ /*
+ *
+ */
+ public void setPlcValue(PlcValue plcvalue);
+
+ /*
+ *
+ */
+ public PlcValue getItemPlcValue();
+
+ /*
+ *
+ */
+ public ByteBuf getItemByteBuf();
+
+ /*
+ *
+ */
+ public byte[] getItemBytes();
+
+ /*
+ *
+ */
+ public void addItemClient(PlcItemListener client);
+
+ /*
+ *
+ */
+ public void removeItemClient(PlcItemListener client);
+
+ /*
+ *
+ */
+ public Hashtable<String, Object> getProperties();
+
+ /*
+ *
+ */
+ public Date getLastReadDate();
+
+ /*
+ *
+ */
+ public Date getLastWriteDate();
+
+ /*
+ *
+ */
+ public Date getLastErrorDate();
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcItemClient.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcItemClient.java
new file mode 100644
index 0000000..c23af85
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcItemClient.java
@@ -0,0 +1,27 @@
+/*
+ * 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;
+
+import org.apache.plc4x.java.api.messages.PlcReadResponse;
+import org.apache.plc4x.java.api.value.PlcValue;
+
+
+public interface PlcItemClient {
+
+ public void execute(PlcValue plcvalue);
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcItemListener.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcItemListener.java
new file mode 100644
index 0000000..8ad1804
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/PlcItemListener.java
@@ -0,0 +1,32 @@
+/*
+ * 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
+ *
+ * https://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;
+
+import io.netty.buffer.ByteBuf;
+
+
+public interface PlcItemListener {
+
+ void atach(final PlcItem plcitem);
+
+ void detach();
+
+ void update();
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/TagBasedDriver.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/TagBasedDriver.java
new file mode 100644
index 0000000..3369666
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/TagBasedDriver.java
@@ -0,0 +1,24 @@
+/*
+ * 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
+ *
+ * https://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;
+
+
+public interface TagBasedDriver extends Driver{
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand001.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand001.java
new file mode 100644
index 0000000..49ab446
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand001.java
@@ -0,0 +1,85 @@
+/*
+ * 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.command;
+
+import java.util.Hashtable;
+import java.util.UUID;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.plc4x.merlot.scheduler.api.Job;
+import org.osgi.framework.BundleContext;
+import org.apache.plc4x.merlot.api.PlcGroup;
+import org.apache.plc4x.merlot.api.impl.PlcGroupImpl;
+
+
+@Command(scope = "plc4x", name = "demo_001", description = "Command for test.")
+@Service
+public class DemoCommand001 implements Action {
+
+// private String filter_device = "(&(" + Constants.OBJECTCLASS + "=" + Device.class.getName() + ")" +
+// "(" + org.osgi.service.device.Constants.DEVICE_SERIAL + "=dummy))";
+
+ @Reference
+ BundleContext bc;
+
+ @Override
+ public Object execute() throws Exception {
+// Hashtable properties = new Hashtable();
+// properties.putIfAbsent(Constants.DEVICE_CATEGORY, "s7");
+// properties.putIfAbsent(Constants.DEVICE_DESCRIPTION, this);
+// properties.putIfAbsent(Constants.DEVICE_SERIAL, this);
+//
+// PlcDevice plcdevice = new BaseDeviceImpl.BaseDeviceBuilder(bc, "s7://192.168.1.1","NAME","LA DESCRIPCION").build();
+// bc.registerService(PlcDevice.class.getName(), plcdevice, plcdevice.getProperties());
+
+
+ Hashtable props = new Hashtable();
+
+ props.put(PlcGroup.GROUP_NAME, "PRUEBA_DE_SCHEDULER_1");
+ props.put(PlcGroup.GROUP_UID, UUID.randomUUID().toString());
+ props.put(PlcGroup.GROUP_PERIOD, 5000L);
+ props.put(PlcGroup.GROUP_IMMEDIATE, true);
+ props.put(PlcGroup.GROUP_CONCURRENT, false);
+
+ PlcGroup grupo1 = new PlcGroupImpl.PlcGroupBuilder(bc, "PRUEBA_DE_SCHEDULER_1", UUID.fromString((String) props.get(PlcGroup.GROUP_UID))).
+ setGroupPeriod((long) props.get(PlcGroup.GROUP_PERIOD)).
+ build();
+
+ bc.registerService(new String[]{Job.class.getName(), PlcGroup.class.getName()}, grupo1, props);
+
+ props.put(PlcGroup.GROUP_NAME, "PRUEBA_DE_SCHEDULER_2");
+ props.put(PlcGroup.GROUP_UID, UUID.randomUUID().toString());
+ PlcGroup grupo2 = new PlcGroupImpl.PlcGroupBuilder(bc, "PRUEBA_DE_SCHEDULER_2", UUID.fromString((String) props.get(PlcGroup.GROUP_UID))).
+ setGroupPeriod((long) props.get(PlcGroup.GROUP_PERIOD)).
+ build();
+
+ bc.registerService(new String[]{Job.class.getName(), PlcGroup.class.getName()}, grupo2, props);
+
+ props.put(PlcGroup.GROUP_NAME, "PRUEBA_DE_SCHEDULER_3");
+ props.put(PlcGroup.GROUP_UID, UUID.randomUUID().toString());
+ PlcGroup grupo3 = new PlcGroupImpl.PlcGroupBuilder(bc, "PRUEBA_DE_SCHEDULER_3", UUID.fromString((String) props.get(PlcGroup.GROUP_UID))).
+ setGroupPeriod((long) props.get(PlcGroup.GROUP_PERIOD)).
+ build();
+
+ bc.registerService(new String[]{Job.class.getName(), PlcGroup.class.getName()}, grupo3, props);
+
+ return null;
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand002.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand002.java
new file mode 100644
index 0000000..365ecc7
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand002.java
@@ -0,0 +1,90 @@
+/*
+ * 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.command;
+
+import java.util.Hashtable;
+import java.util.List;
+import java.util.UUID;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.plc4x.merlot.api.PlcDevice;
+import org.apache.plc4x.merlot.scheduler.api.Job;
+import org.osgi.framework.BundleContext;
+import org.apache.plc4x.merlot.api.PlcGroup;
+import org.apache.plc4x.merlot.api.PlcItem;
+import org.apache.plc4x.merlot.api.core.PlcItemClientService;
+import org.apache.plc4x.merlot.api.impl.PlcGroupImpl;
+import org.apache.plc4x.merlot.api.impl.PlcItemImpl;
+
+
+@Command(scope = "plc4x", name = "demo_002", description = "Command for test.")
+@Service
+public class DemoCommand002 implements Action {
+
+ @Reference
+ BundleContext bc;
+
+ @Reference
+ PlcItemClientService items_service;
+
+ @Reference
+ volatile List<PlcDevice> devices;
+
+ @Option(name = "-d", aliases = "--did", description = "Device uid.", required = true, multiValued = false)
+ String gid;
+
+ @Option(name = "-n", aliases = "--name", description = "Technological name of the group.", required = true, multiValued = false)
+ String group_name;
+
+ @Override
+ public Object execute() throws Exception {
+
+
+
+ devices.stream().
+ filter(p -> p.getUid().toString().equalsIgnoreCase(gid)).
+ forEach(d -> {
+ PlcItem item;
+ PlcGroup grupo1 = new PlcGroupImpl.PlcGroupBuilder(bc, group_name, UUID.randomUUID()).
+ setGroupPeriod(5000L).
+ setItemService(items_service).
+ setGroupDeviceUid(d.getUid()).
+ build();
+ d.putGroup(grupo1);
+
+ for (int i=0; i<1; i++) {
+
+ item = new PlcItemImpl.PlcItemBuilder("ITEM_00" + i).
+ setItemDescription("THE ITEM 00" + i).
+ setItemId("RANDOM/foo_" +i + ":INT").
+ setItemEnable(true).
+ build();
+
+ grupo1.putItem(item);
+
+ };
+
+
+ });
+
+ return null;
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand003.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand003.java
new file mode 100644
index 0000000..5e16425
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand003.java
@@ -0,0 +1,87 @@
+/*
+ * 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.command;
+
+import java.util.List;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.plc4x.java.api.value.PlcValue;
+import org.osgi.framework.BundleContext;
+import org.apache.plc4x.merlot.api.PlcGroup;
+import org.apache.plc4x.merlot.api.PlcItem;
+import org.apache.plc4x.merlot.api.PlcItemClient;
+import org.apache.plc4x.merlot.api.core.PlcItemClientService;
+import org.apache.plc4x.merlot.api.impl.PlcItemImpl;
+
+
+@Command(scope = "plc4x", name = "demo_003", description = "Command for test.")
+@Service
+public class DemoCommand003 implements Action, PlcItemClient {
+
+ @Reference
+ BundleContext bc;
+
+ @Reference
+ PlcItemClientService clients;
+
+ @Reference
+ volatile List<PlcGroup> groups;
+
+ @Option(name = "-g", aliases = "--gid", description = "Group uid.", required = true, multiValued = false)
+ String gid;
+
+ @Argument(index = 0, name = "name", description = "Item name", required = true, multiValued = false)
+ String item_name;
+
+ @Argument(index = 1, name = "desc", description = "Item description", required = true, multiValued = false)
+ String item_desc;
+
+ @Argument(index = 2, name = "id", description = "Item id", required = true, multiValued = false)
+ String item_id;
+
+ @Argument(index = 3, name = "enbale", description = "Enable the item", required = true, multiValued = false)
+ Boolean item_enable = false;
+
+ @Override
+ public Object execute() throws Exception {
+
+ groups.stream().
+ filter(g -> g.getGroupUid().toString().equalsIgnoreCase(gid)).
+ forEach(g -> {
+ PlcItem item = new PlcItemImpl.PlcItemBuilder(item_name).
+ setItemDescription(item_desc).
+ setItemId(item_id).
+ setItemEnable(item_enable).
+ build();
+ g.putItem(item);
+
+ clients.subcription(this, item.getItemUid());
+ });
+
+ return null;
+ }
+
+ @Override
+ public void execute(PlcValue plcvalue) {
+ System.out.println("Value: " + plcvalue.getString());
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand004.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand004.java
new file mode 100644
index 0000000..6e7d913
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand004.java
@@ -0,0 +1,87 @@
+/*
+ * 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.command;
+
+import java.util.List;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.plc4x.java.api.value.PlcValue;
+import org.osgi.framework.BundleContext;
+import org.apache.plc4x.merlot.api.PlcGroup;
+import org.apache.plc4x.merlot.api.PlcItem;
+import org.apache.plc4x.merlot.api.PlcItemClient;
+import org.apache.plc4x.merlot.api.core.PlcItemClientService;
+import org.apache.plc4x.merlot.api.impl.PlcItemImpl;
+
+
+@Command(scope = "plc4x", name = "demo_004", description = "Prueba Registro glo.")
+@Service
+public class DemoCommand004 implements Action, PlcItemClient {
+
+ @Reference
+ BundleContext bc;
+
+ @Reference
+ PlcItemClientService clients;
+
+ @Reference
+ volatile List<PlcGroup> groups;
+
+ @Option(name = "-g", aliases = "--gid", description = "Group uid.", required = true, multiValued = false)
+ String gid;
+
+ @Argument(index = 0, name = "name", description = "Item name", required = true, multiValued = false)
+ String item_name;
+
+ @Argument(index = 1, name = "desc", description = "Item description", required = true, multiValued = false)
+ String item_desc;
+
+ @Argument(index = 2, name = "id", description = "Item id", required = true, multiValued = false)
+ String item_id;
+
+ @Argument(index = 3, name = "enbale", description = "Enable the item", required = true, multiValued = false)
+ Boolean item_enable = false;
+
+ @Override
+ public Object execute() throws Exception {
+
+ groups.stream().
+ filter(g -> g.getGroupUid().toString().equalsIgnoreCase(gid)).
+ forEach(g -> {
+ PlcItem item = new PlcItemImpl.PlcItemBuilder(item_name).
+ setItemDescription(item_desc).
+ setItemId(item_id).
+ setItemEnable(item_enable).
+ build();
+ g.putItem(item);
+
+ clients.subcription(this, item.getItemUid());
+ });
+
+ return null;
+ }
+
+ @Override
+ public void execute(PlcValue plcvalue) {
+ System.out.println("Value: " + plcvalue.getString());
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceControlCommand.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceControlCommand.java
new file mode 100644
index 0000000..cc23b25
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceControlCommand.java
@@ -0,0 +1,63 @@
+/*
+ * 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
+ *
+ * https://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.command;
+
+import java.util.List;
+import java.util.UUID;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.plc4x.merlot.api.PlcDevice;
+import org.apache.plc4x.merlot.api.PlcGeneralFunction;
+
+@Command(scope = "plc4x", name = "device-ctrl", description = "List all channels")
+@Service
+public class PlcDeviceControlCommand implements Action {
+
+ @Reference
+ PlcGeneralFunction plcservice;
+
+ @Option(name = "-d", aliases = "--did", description = "Device uid.", required = true, multiValued = false)
+ String did;
+
+ @Option(name = "-e", aliases = "--enable", description = "Enable the device.", required = false, multiValued = false)
+ Boolean enable = false;
+
+ @Option(name = "-x", aliases = "--disable", description = "Disable the device.", required = false, multiValued = false)
+ Boolean disable = false;
+
+ @Override
+ public Object execute() throws Exception {
+
+ final PlcDevice dev = plcservice.getPlcDevice(UUID.fromString(did));
+
+ if (null != dev) {
+ if (enable) {
+ dev.enable();
+ } else if (disable) {
+ dev.disable();
+ }
+ }
+
+ return null;
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceListCommand.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceListCommand.java
new file mode 100644
index 0000000..39a3fb5
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDeviceListCommand.java
@@ -0,0 +1,153 @@
+/*
+ * 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.command;
+
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.support.table.ShellTable;
+import org.apache.plc4x.merlot.api.PlcDevice;
+import org.apache.plc4x.merlot.api.PlcGroup;
+import org.osgi.service.device.Device;
+import org.apache.plc4x.merlot.api.PlcGeneralFunction;
+
+@Command(scope = "plc4x", name = "device-list", description = "List al device & groups")
+@Service
+public class PlcDeviceListCommand implements Action {
+
+ @Reference
+ PlcGeneralFunction plcservice;
+
+ @Option(name = "-d", aliases = "--did", description = "Device uid.", required = false, multiValued = false)
+ String did;
+
+ @Option(name = "-g", aliases = "--gid", description = "Group uid.", required = false, multiValued = false)
+ String gid;
+
+ @Override
+ public Object execute() throws Exception {
+ if ((null == did) && (null == gid))
+ printAllDevices();
+ if (null != did) {
+ printAllGroups();
+ } else if (null != gid) {
+ printAllItems();
+ }
+ return null;
+ }
+
+ private void printAllDevices() {
+ int[] i = new int[1];
+ final Map<UUID, String> devices = plcservice.getPlcDevices("*");
+ if (null != devices) {
+ ShellTable table = new ShellTable();
+ table.column("Uid");
+ table.column("Name");
+ table.column("Description");
+ table.column("Enable");
+ table.column("Url");
+ table.column("Groups");
+ table.column("Items");
+
+ devices.forEach((u,s) -> {
+ final PlcDevice dev = plcservice.getPlcDevice(u);
+ i[0] = 0;
+ dev.getGroups().forEach(g-> {
+ i[0] += g.getItems().size();
+ });
+ table.addRow().addContent(dev.getUid(),
+ dev.getDeviceName(),
+ dev.getDeviceDescription(),
+ dev.isEnable(),
+ dev.getUrl(),
+ dev.getGroups().size(),
+ i[0]);
+ });
+ table.print(System.out);
+ } else {
+ System.out.println("No device registered.");
+ }
+ }
+
+ private void printAllGroups() {
+ final PlcDevice dev = plcservice.getPlcDevice(UUID.fromString(did));
+
+ if (null != dev) {
+ ShellTable table = new ShellTable();
+ table.column("Uid");
+ table.column("Name");
+ table.column("Description");
+ table.column("Enable");
+ table.column("Items");
+ table.column("Transmits");
+ table.column("Receives");
+ table.column("Errors");
+
+ dev.getGroups().forEach(g -> {
+ table.addRow().addContent(g.getGroupUid(),
+ g.getGroupName(),
+ g.getGroupDescription(),
+ g.isEnable(),
+ g.getItems().size(),
+ g.getGroupTransmit(),
+ g.getGroupReceives(),
+ g.getGroupErrors());
+ });
+
+ table.print(System.out);
+ }
+ }
+
+ private void printAllItems() {
+ final PlcGroup g = plcservice.getPlcGroup(UUID.fromString(gid));
+ if (null != g) {
+ ShellTable table = new ShellTable();
+ table.column("Uid");
+ table.column("Name");
+ table.column("Description");
+ table.column("Id");
+ table.column("Enable");
+ table.column("Transmits");
+ table.column("Receives");
+ table.column("Errors");
+ table.column("LastReadDate");
+ table.column("LastWriteDate");
+ table.column("LastErrorDate");
+ g.getItems().forEach(i -> {
+ table.addRow().addContent( i.getItemUid(),
+ i.getItemName(),
+ i.getItemDescription(),
+ i.getItemId(),
+ i.isEnable(),
+ i.getItemTransmits(),
+ i.getItemReceives(),
+ i.getItemErrors(),
+ i.getLastReadDate(),
+ i.getLastWriteDate(),
+ i.getLastErrorDate());
+ });
+ table.print(System.out);
+ };
+ }
+
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDriverListCommand.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDriverListCommand.java
new file mode 100644
index 0000000..bfdab71
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcDriverListCommand.java
@@ -0,0 +1,59 @@
+/*
+ * 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
+ *
+ * https://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.command;
+
+import java.util.List;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.support.table.ShellTable;
+import org.apache.plc4x.java.api.PlcDriver;
+import org.apache.plc4x.merlot.api.PlcDevice;
+import org.apache.plc4x.merlot.api.impl.PlcDriverAdminServiceImpl;
+import org.apache.plc4x.merlot.api.PlcGeneralFunction;
+
+@Command(scope = "plc4x", name = "driver-list", description = "List all channels")
+@Service
+public class PlcDriverListCommand implements Action {
+
+ @Reference
+ PlcGeneralFunction plcservice;
+
+ @Override
+ public Object execute() throws Exception {
+ ShellTable table = new ShellTable();
+ table.column("Code");
+ table.column("Name");
+
+// drivers.forEach(d -> {
+// table.addRow().addContent( d.getProtocolCode(),
+// d.getProtocolName());
+// });
+
+ plcservice.getPlcDrivers().forEach((c,d) -> {
+ table.addRow().addContent( c,
+ d);
+ });
+
+ table.print(System.out);
+ return null;
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcGroupControlCommand.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcGroupControlCommand.java
new file mode 100644
index 0000000..68285ee
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcGroupControlCommand.java
@@ -0,0 +1,85 @@
+/*
+ * 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
+ *
+ * https://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.command;
+
+import java.util.List;
+import java.util.UUID;
+import java.util.function.Consumer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.support.table.ShellTable;
+import org.apache.plc4x.merlot.api.PlcGroup;
+import org.apache.plc4x.merlot.api.impl.PlcGroupImpl;
+import org.apache.plc4x.merlot.scheduler.api.ScheduleOptions;
+import org.apache.plc4x.merlot.scheduler.api.Scheduler;
+import org.apache.plc4x.merlot.scheduler.api.SchedulerError;
+import org.slf4j.LoggerFactory;
+import org.apache.plc4x.merlot.api.PlcGeneralFunction;
+
+@Command(scope = "plc4x", name = "group-ctrl", description = "Control state of ")
+@Service
+public class PlcGroupControlCommand implements Action {
+
+ private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(PlcGroupControlCommand.class);
+
+ @Reference
+ PlcGeneralFunction plcservice;
+
+ @Reference
+ Scheduler scheduler;
+
+ @Option(name = "-g", aliases = "--gid", description = "Group uid.", required = true, multiValued = false)
+ String gid;
+
+ @Option(name = "-e", aliases = "--enable", description = "Enable the group.", required = false, multiValued = false)
+ Boolean enable = false;
+
+ @Option(name = "-x", aliases = "--disable", description = "Disable the group.", required = false, multiValued = false)
+ Boolean disable = false;
+
+ @Option(name = "-s", aliases = "--schedule", description = "Change scan time for the group in ms.", required = false, multiValued = false)
+ long period = 0L;
+
+ @Override
+ public Object execute() throws Exception {
+ UUID grp_uid = UUID.fromString(gid);
+ final PlcGroup grp = plcservice.getPlcGroup(grp_uid);
+
+ if (null != grp) {
+ if (enable) {
+ grp.enable();
+ } else if (disable){
+ grp.disable();
+ }
+
+ if ((period > 100) && (period != grp.getPeriod())){
+ plcservice.setPlcGroupScanRate(grp_uid, period);
+ }
+ }
+
+ return null;
+ }
+
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcItemControlCommand.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcItemControlCommand.java
new file mode 100644
index 0000000..8b716de
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/PlcItemControlCommand.java
@@ -0,0 +1,63 @@
+/*
+ * 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
+ *
+ * https://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.command;
+
+import java.util.UUID;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.plc4x.merlot.api.PlcItem;
+import org.apache.plc4x.merlot.api.PlcGeneralFunction;
+
+@Command(scope = "plc4x", name = "item-ctrl", description = "List all channels")
+@Service
+public class PlcItemControlCommand implements Action {
+
+ @Reference
+ PlcGeneralFunction plcservice;
+
+
+ @Option(name = "-i", aliases = "--iid", description = "Item uid.", required = true, multiValued = false)
+ String iid;
+
+ @Option(name = "-e", aliases = "--enable", description = "Enable the device.", required = false, multiValued = false)
+ Boolean enable = false;
+
+ @Option(name = "-x", aliases = "--disable", description = "Disable the device.", required = false, multiValued = false)
+ Boolean disable = false;
+
+ @Override
+ public Object execute() throws Exception {
+ UUID item_uid = UUID.fromString(iid);
+ final PlcItem item = plcservice.getPlcItem(item_uid);
+
+ if (null != item){
+ if (enable) {
+ item.enable();
+ } else if (disable) {
+ item.disable();
+ }
+ }
+
+ return null;
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/core/Merlot.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/core/Merlot.java
new file mode 100644
index 0000000..40e122f
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/core/Merlot.java
@@ -0,0 +1,662 @@
+/*
+ * 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
+ *
+ * https://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.core;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class Merlot {
+
+
+ public enum STATE {
+
+ STOPPED(0x0000,"TEXTO"),
+ RESETTING(0x0002,"TEXTO"),
+ IDLE(0x0004,"TEXTO"),
+ STARTING(0x0006,"TEXTO"),
+ EXECUTE(0x0008,"TEXTO"),
+ COMPLETING(0x000A,"TEXTO"),
+ COMPLETE(0x000C,"TEXTO"),
+ ABORTING(0x000E,"TEXTO"),
+ ABORTED(0x0010,"TEXTO"),
+ CLEARING(0x0012,"TEXTO"),
+ STOPPING(0x0014,"TEXTO"),
+ HOLDING(0x0016,"TEXTO"),
+ HELD(0x0018,"TEXTO"),
+ UNHOLDING(0x001A,"TEXTO"),
+ SUSPENDING(0x001C,"TEXTO"),
+ SUSPENDED(0x001E,"TEXTO"),
+ UNSUSPENDING(0x0020,"TEXTO");
+
+ private static final Map<Integer, STATE> map;
+
+ static {
+ map = new HashMap<>();
+ for (STATE state : STATE.values()) {
+ map.put(state.code, state);
+ }
+ };
+
+ private final String description;
+ private final int code;
+
+ STATE(int code, String description){
+ this.description = description;
+ this.code = code;
+ }
+
+ public String getDescription(){
+ return description;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public static STATE valueOf(int code) {
+ return map.get(code);
+ }
+
+ }
+
+
+ public enum STATUS {
+ M_OK(0x6000,"TEXTO"),
+ M_INITIATE_IND(0x6001,"TEXTO"),
+ M_CYCL_READ_ABORT_IND(0x6002,"TEXTO"),
+ M_CYCL_READ_IND(0x6003,"TEXTO"),
+
+ M_ERR(0x8000,"TEXTO"),
+ M_ERR_ADD_VALUE_PDU(0x8001,"TEXTO"),
+ M_ERR_BLOCK_ALREADY_EXISTS(0x8002,"TEXTO"),
+ M_ERR_BLOCK_NOT_FOUND(0x8003,"TEXTO"),
+ M_ERR_BLOCK_PROTECTED(0x8004,"TEXTO"),
+ M_ERR_BLOCK_TOO_LARGE(0x8005,"TEXTO"),
+ M_ERR_CONN_ABORTED(0x8006,"TEXTO"),
+ M_ERR_CONN_ALREADY_FREE(0x8007,"TEXTO"),
+ M_ERR_CONN_ALREADY_PASSED(0x8008,"TEXTO"),
+ M_ERR_CONN_CNF(0x8009,"TEXTO"),
+ M_ERR_CONN_NAME_NOT_FOUND(0x800A,"TEXTO"),
+ M_ERR_COORD_RULE(0x800B,"TEXTO"),
+ M_ERR_DGN_CONN_NOT_ANNOUNCED(0x800C,"TEXTO"),
+ M_ERR_DGN_CONN_TOO_MUCH(0x800D,"TEXTO"),
+ M_ERR_DGN_INFO_NOT_AVAIL(0x800E,"TEXTO"),
+ M_ERR_FEW_PROT_LEVEL(0x800F,"TEXTO"),
+ M_ERR_FILE_NOT_FOUND(0x8010,"TEXTO"),
+ M_ERR_FW_ERROR(0x8011,"TEXTO"),
+ M_ERR_IEC_DATA_TYPE_MISMATCH(0x8012,"TEXTO"),
+ M_ERR_IEC_INVALID_REF(0x8013,"TEXTO"),
+ M_ERR_IEC_LOWER_LAYER(0x8014,"TEXTO"),
+ M_ERR_IEC_NEG_RESPONSE(0x8015,"TEXTO"),
+ M_ERR_IEC_NO(0x8016,"TEXTO"),
+ M_ERR_IEC_NO_ACCESS_TO_REM_OBJECT(0x8017,"TEXTO"),
+ M_ERR_IEC_PARTNER_IN_WRONG_STATE(0x8018,"TEXTO"),
+ M_ERR_IEC_RECEIVER_DISABLED(0x8019,"TEXTO"),
+ M_ERR_IEC_RECEIVER_OVERRUN(0x801A,"TEXTO"),
+ M_ERR_IEC_RESET_RECEIVED(0x801B,"TEXTO"),
+ M_ERR_INSTALL(0x801C,"TEXTO"),
+ M_ERR_INTERNAL_ERROR(0x801D,"TEXTO"),
+ M_ERR_INVALID_BLOCK(0x801E,"TEXTO"),
+ M_ERR_INVALID_BLOCK_NR(0x801F,"TEXTO"),
+ M_ERR_INVALID_BLOCK_TYPE(0x8020,"TEXTO"),
+ M_ERR_INVALID_CONN_STATE(0x8021,"TEXTO"),
+ M_ERR_INVALID_CREF(0x8022,"TEXTO"),
+ M_ERR_INVALID_CYCL_READ_STATE(0x8023,"TEXTO"),
+ M_ERR_INVALID_DATA_SIZE(0x8024,"TEXTO"),
+ M_ERR_INVALID_DATARANGE_OR_TYPE(0x8025,"TEXTO"),
+ M_ERR_INVALID_FILENAME(0x8026,"TEXTO"),
+ M_ERR_INVALID_FILETYPE(0x8027,"TEXTO"),
+ M_ERR_INVALID_ORDERIDM(0x8028,"TEXTO"),
+ M_ERR_INVALID_PARAMETER(0x8029,"TEXTO"),
+ M_ERR_INVALID_PASSWORD(0x802A,"TEXTO"),
+ M_ERR_INVALID_READ_BUFFER(0x802B,"TEXTO"),
+ M_ERR_INVALID_SEGMENT(0x802C,"TEXTO"),
+ M_ERR_INVALID_WRITE_BUFFER(0x802D,"TEXTO"),
+ M_ERR_MAX_REQ(0x802E,"TEXTO"),
+ M_ERR_NO_PASSWORD(0x802F,"TEXTO"),
+ M_ERR_NO_RCV_BLOCK(0x8030,"TEXTO"),
+ M_ERR_NO_RESOURCE(0x8031,"TEXTO"),
+ M_ERR_NO_SIN_SERV(0x8032,"TEXTO"),
+ M_ERR_OBJ_ACCESS_DENIED(0x8033,"TEXTO"),
+ M_ERR_OBJ_ATTR_INCONSISTENT(0x8034,"TEXTO"),
+ M_ERR_OBJ_UNDEFINED(0x8035,"TEXTO"),
+ M_ERR_ORDERID_USED(0x8036,"TEXTO"),
+ M_ERR_R_ID_USED(0x8037,"TEXTO"),
+ M_ERR_RECEIVE_BUFFER_FULL(0x8038,"TEXTO"),
+ M_ERR_REM_BRCV(0x8039,"TEXTO"),
+ M_ERR_REM_BSEND(0x803A,"TEXTO"),
+ M_ERR_REM_BSEND_CANCEL(0x803B,"TEXTO"),
+ M_ERR_REM_DATABASE_TOO_SMALL(0x803C,"TEXTO"),
+ M_ERR_RETRY(0x803D,"TEXTO"),
+ M_ERR_SERVICE_CONN_ALREADY_USED(0x803E,"TEXTO"),
+ M_ERR_SERVICE_NOT_SUPPORTED(0x803F,"TEXTO"),
+ M_ERR_SERVICE_VFD_ALREADY_USED(0x8040,"TEXTO"),
+ M_ERR_SYMB_ADDRESS(0x8041,"TEXTO"),
+ M_ERR_SYMB_ADDRESS_INCONSISTENT(0x8042,"TEXTO"),
+ M_ERR_TOO_LONG_DATA(0x8043,"TEXTO"),
+ M_ERR_UNKNOWN_ERROR(0x8044,"TEXTO"),
+ M_ERR_WRONG_CP_DESCR(0x8045,"TEXTO"),
+ M_ERR_WRONG_IND_CNF(0x8046,"TEXTO");
+
+ private static final Map<Integer, STATUS> map;
+
+ static {
+ map = new HashMap<>();
+ for (STATUS status : STATUS.values()) {
+ map.put(status.code, status);
+ }
+ }
+
+ private final String description;
+ private final int code;
+
+ STATUS(int code, String description){
+ this.description = description;
+ this.code = code;
+ }
+
+ public String getDescription(){
+ return description;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public static STATUS valueOf(int code) {
+ return map.get(code);
+ }
+
+ }
+
+ public enum FUNCTION {
+
+ //DRIVER CONFIG
+ M_INITIATE_CNF(0x4000,"TEXTO"),
+ M_READ_CNF(0x4001,"TEXTO"),
+ M_WRITE_CNF(0x4002,"TEXTO"),
+ M_MULTIPLE_READ_CNF(0x4003,"TEXTO"),
+ M_MULTIPLE_WRITE_CNF(0x4004,"TEXTO"),
+ M_CYCL_READ_INIT_CNF(0x4005,"TEXTO"),
+ M_CYCL_READ_START_CNF(0x4006,"TEXTO"),
+ M_CYCL_READ_STOP_CNF(0x4007,"TEXTO"),
+ M_CYCL_READ_DELETE_CNF(0x4008,"TEXTO"),
+ M_PASSWORD_CNF(0x4009,"TEXTO"),
+ M_PASSWORD_LEN(0x400A,"TEXTO"),
+ M_RESET_PASSWORD(0x400B,"TEXTO"),
+
+ //DEVICE
+ FC_INITIALIZE_DEVICE(0x0000,"TEXTO"),
+ FC_SHUTDOWN_DEVICE(0x0002,"TEXTO"),
+
+ FC_GET_DEVICE_MODE(0x0004,"TEXTO"),
+ FC_STAR_DEVICE(0x0006,"TEXTO"),
+ FC_STOP_DEVICE(0x0008,"TEXTO"),
+ FC_GET_PDU_SIZE(0x0010,"TEXTO"),
+
+ //BITS
+ FC_READ_MEMORY_BITS(0x0012,"TEXTO"),
+ FC_WRIE_MEMORY_BITS(0x0014,"TEXTO"),
+
+ FC_READ_INPUT_BITS(0x0016,"TEXTO"),
+
+ FC_READ_OUTPUT_BITS(0x0018,"TEXTO"),
+ FC_WRITE_OUTPUT_BITS(0x0020,"TEXTO"),
+
+ FC_READ_DATA_BITS(0x0022,"TEXTO"),
+ FC_WRITE_DATA_BITS(0x0024,"TEXTO"),
+
+ //BYTES
+ FC_READ_MEMORY_BYTES(0x0026,"TEXTO"),
+ FC_WRITE_MEMORY_BYTES(0x0028,"TEXTO"),
+
+ FC_READ_INPUT_BYTES(0x0030,"TEXTO"),
+
+ FC_READ_OUTPUT_BYTES(0x0032,"TEXTO"),
+ FC_WRITE_OUTPUT_BYTES(0x0034,"TEXTO"),
+
+ FC_READ_DATA_BYTES(0x0036,"TEXTO"),
+ FC_WRITE_DATA_BYTES(0x0038,"TEXTO"),
+
+ //WORD
+ FC_READ_MEMORY_WORDS(0x0040,"TEXTO"),
+ FC_WRITE_MEMORY_WORDS(0x0042,"TEXTO"),
+
+ FC_READ_INPUT_WORDS(0x0044,"TEXTO"),
+
+ FC_READ_OUTPUT_WORDS(0x0046,"TEXTO"),
+ FC_WRITE_OUTPUT_WORDS(0x0048,"TEXTO"),
+
+ FC_READ_DATA_WORDS(0x0050,"TEXTO"),
+ FC_WRITE_DATA_WORDS(0x0052,"TEXTO"),
+
+ //DWORDS
+ FC_READ_MEMORY_DWORDS(0x0054,"TEXTO"),
+ FC_WRITE_MEMORY_DWORDS(0x0056,"TEXTO"),
+
+ FC_READ_INPUT_DWORDS(0x0058,"TEXTO"),
+
+ FC_READ_OUTPUT_DWORDS(0x0060,"TEXTO"),
+ FC_WRITE_OUTPUT_DWORDS(0x0062,"TEXTO"),
+
+ FC_READ_DATA_DWORDS(0x0064,"TEXTO"),
+ FC_WRITE_DATA_DWORDS(0x0066,"TEXTO"),
+
+ //TIMERS
+ FC_READ_TIMERS(0x0068,"TEXTO"),
+ FC_WRITE_TIMERS(0x0070,"TEXTO"),
+
+ //COUNTER
+ FC_READ_COUNTERS(0x0072,"TEXTO"),
+ FC_WRITE_COUNTERS(0x0074,"TEXTO");
+
+
+ private static final Map<Integer, FUNCTION> map;
+
+ static {
+ map = new HashMap<>();
+ for (FUNCTION func : FUNCTION.values()) {
+ map.put(func.code, func);
+ }
+ }
+
+ private final String description;
+ private final int code;
+
+ FUNCTION(int code, String description){
+ this.description = description;
+ this.code = code;
+ }
+
+ public String getDescription(){
+ return description;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public static FUNCTION valueOf(int code) {
+ return map.get(code);
+ }
+ }
+
+ public enum TYPE_IEC {
+ M_TYPE_IEC_BOOL(0xC000,"TEXTO"),
+ M_TYPE_IEC_SINT(0xC001,"TEXTO"),
+ M_TYPE_IEC_INT(0xC002,"TEXTO"),
+ M_TYPE_IEC_DINT(0xC003,"TEXTO"),
+ M_TYPE_IEC_LINT(0xC004,"TEXTO"),
+ M_TYPE_IEC_USINT(0xC005,"TEXTO"),
+ M_TYPE_IEC_UINT(0xC006,"TEXTO"),
+ M_TYPE_IEC_UDINT(0xC007,"TEXTO"),
+ M_TYPE_IEC_ULINT(0xC008,"TEXTO"),
+ M_TYPE_IEC_REAL(0xC009,"TEXTO"),
+ M_TYPE_IEC_LREAL(0xC00A,"TEXTO"),
+ M_TYPE_IEC_TIME(0xC00B,"TEXTO"),
+ M_TYPE_IEC_DATE(0xC00C,"TEXTO"),
+ M_TYPE_IEC_TIME_OF_DAY(0xC00D,"TEXTO"),
+ M_TYPE_IEC_TOD(0xC00E,"TEXTO"),
+ M_TYPE_IEC_DATE_AND_TIME(0xC00F,"TEXTO"),
+ M_TYPE_IEC_DT(0xC010,"TEXTO"),
+ M_TYPE_IEC_STRING(0xC011,"TEXTO"),
+ M_TYPE_IEC_BYTE(0xC012,"TEXTO"),
+ M_TYPE_IEC_WORD(0xC013,"TEXTO"),
+ M_TYPE_IEC_DWORD(0xC014,"TEXTO"),
+ M_TYPE_IEC_LWORD(0xC015,"TEXTO"),
+ M_TYPE_IEC_WSTRING(0xC016,"TEXTO");
+
+ private static final Map<Integer, TYPE_IEC> map;
+
+ static {
+ map = new HashMap<>();
+ for (TYPE_IEC func : TYPE_IEC.values()) {
+ map.put(func.code, func);
+ }
+ }
+
+ private final String description;
+ private final int code;
+
+ TYPE_IEC(int code, String description){
+ this.description = description;
+ this.code = code;
+ }
+
+ public String getDescription(){
+ return description;
+ }
+
+ public int getCode() {
+ return code;
+ }
+
+ public static TYPE_IEC valueOf(int code) {
+ return map.get(code);
+ }
+ }
+
+ public static final int M_INITIATE_CNF = 0x4000;
+ public static final int M_READ_CNF = 0x4001;
+ public static final int M_WRITE_CNF = 0x4002;
+ public static final int M_MULTIPLE_READ_CNF = 0x4003;
+ public static final int M_MULTIPLE_WRITE_CNF = 0x4004;
+ public static final int M_CYCL_READ_INIT_CNF = 0x4005;
+ public static final int M_CYCL_READ_START_CNF = 0x4006;
+ public static final int M_CYCL_READ_STOP_CNF = 0x4007;
+ public static final int M_CYCL_READ_DELETE_CNF = 0x4008;
+ public static final int M_PASSWORD_CNF = 0x4009;
+ public static final int M_PASSWORD_LEN = 0x400A;
+ public static final int M_RESET_PASSWORD = 0x400B;
+
+ public static final int M_OK = 0x6000;
+ public static final int M_INITIATE_IND = 0x6001;
+ public static final int M_CYCL_READ_ABORT_IND = 0x6002;
+ public static final int M_CYCL_READ_IND = 0x6003;
+
+ public static final int M_ERR = 0x8000;
+ public static final int M_ERR_ADD_VALUE_PDU = 0x8001;
+ public static final int M_ERR_BLOCK_ALREADY_EXISTS = 0x8002;
+ public static final int M_ERR_BLOCK_NOT_FOUND = 0x8003;
+ public static final int M_ERR_BLOCK_PROTECTED = 0x8004;
+ public static final int M_ERR_BLOCK_TOO_LARGE = 0x8005;
+ public static final int M_ERR_CONN_ABORTED = 0x8006;
+ public static final int M_ERR_CONN_ALREADY_FREE = 0x8007;
+ public static final int M_ERR_CONN_ALREADY_PASSED = 0x8008;
+ public static final int M_ERR_CONN_CNF = 0x8009;
+ public static final int M_ERR_CONN_NAME_NOT_FOUND = 0x800A;
+ public static final int M_ERR_COORD_RULE = 0x800B;
+ public static final int M_ERR_DGN_CONN_NOT_ANNOUNCED = 0x800C;
+ public static final int M_ERR_DGN_CONN_TOO_MUCH = 0x800D;
+ public static final int M_ERR_DGN_INFO_NOT_AVAIL = 0x800E;
+ public static final int M_ERR_FEW_PROT_LEVEL = 0x800F;
+ public static final int M_ERR_FILE_NOT_FOUND = 0x8010;
+ public static final int M_ERR_FW_ERROR = 0x8011;
+ public static final int M_ERR_IEC_DATA_TYPE_MISMATCH = 0x8012;
+ public static final int M_ERR_IEC_INVALID_REF = 0x8013;
+ public static final int M_ERR_IEC_LOWER_LAYER = 0x8014;
+ public static final int M_ERR_IEC_NEG_RESPONSE = 0x8015;
+ public static final int M_ERR_IEC_NO = 0x8016;
+ public static final int M_ERR_IEC_NO_ACCESS_TO_REM_OBJECT = 0x8017;
+ public static final int M_ERR_IEC_PARTNER_IN_WRONG_STATE = 0x8018;
+ public static final int M_ERR_IEC_RECEIVER_DISABLED = 0x8019;
+ public static final int M_ERR_IEC_RECEIVER_OVERRUN = 0x801A;
+ public static final int M_ERR_IEC_RESET_RECEIVED = 0x801B;
+ public static final int M_ERR_INSTALL = 0x801C;
+ public static final int M_ERR_INTERNAL_ERROR = 0x801D;
+ public static final int M_ERR_INVALID_BLOCK = 0x801E;
+ public static final int M_ERR_INVALID_BLOCK_NR = 0x801F;
+ public static final int M_ERR_INVALID_BLOCK_TYPE = 0x8020;
+ public static final int M_ERR_INVALID_CONN_STATE = 0x8021;
+ public static final int M_ERR_INVALID_CREF = 0x8022;
+ public static final int M_ERR_INVALID_CYCL_READ_STATE = 0x8023;
+ public static final int M_ERR_INVALID_DATA_SIZE = 0x8024;
+ public static final int M_ERR_INVALID_DATARANGE_OR_TYPE = 0x8025;
+ public static final int M_ERR_INVALID_FILENAME = 0x8026;
+ public static final int M_ERR_INVALID_FILETYPE = 0x8027;
+ public static final int M_ERR_INVALID_ORDERIDM = 0x8028;
+ public static final int M_ERR_INVALID_PARAMETER = 0x8029;
+ public static final int M_ERR_INVALID_PASSWORD = 0x802A;
+ public static final int M_ERR_INVALID_READ_BUFFER = 0x802B;
+ public static final int M_ERR_INVALID_SEGMENT = 0x802C;
+ public static final int M_ERR_INVALID_WRITE_BUFFER = 0x802D;
+ public static final int M_ERR_MAX_REQ = 0x802E;
+ public static final int M_ERR_NO_PASSWORD = 0x802F;
+ public static final int M_ERR_NO_RCV_BLOCK = 0x8030;
+ public static final int M_ERR_NO_RESOURCE = 0x8031;
+ public static final int M_ERR_NO_SIN_SERV = 0x8032;
+ public static final int M_ERR_OBJ_ACCESS_DENIED = 0x8033;
+ public static final int M_ERR_OBJ_ATTR_INCONSISTENT = 0x8034;
+ public static final int M_ERR_OBJ_UNDEFINED = 0x8035;
+ public static final int M_ERR_ORDERID_USED = 0x8036;
+ public static final int M_ERR_R_ID_USED = 0x8037;
+ public static final int M_ERR_RECEIVE_BUFFER_FULL = 0x8038;
+ public static final int M_ERR_REM_BRCV = 0x8039;
+ public static final int M_ERR_REM_BSEND = 0x803A;
+ public static final int M_ERR_REM_BSEND_CANCEL = 0x803B;
+ public static final int M_ERR_REM_DATABASE_TOO_SMALL = 0x803C;
+ public static final int M_ERR_RETRY = 0x803D;
+ public static final int M_ERR_SERVICE_CONN_ALREADY_USED = 0x803E;
+ public static final int M_ERR_SERVICE_NOT_SUPPORTED = 0x803F;
+ public static final int M_ERR_SERVICE_VFD_ALREADY_USED = 0x8040;
+ public static final int M_ERR_SYMB_ADDRESS = 0x8041;
+ public static final int M_ERR_SYMB_ADDRESS_INCONSISTENT = 0x8042;
+ public static final int M_ERR_TOO_LONG_DATA = 0x8043;
+ public static final int M_ERR_UNKNOWN_ERROR = 0x8044;
+ public static final int M_ERR_WRONG_CP_DESCR = 0x8045;
+ public static final int M_ERR_WRONG_IND_CNF = 0x8046;
+
+ public static final int M_TYPE_IEC_BOOL = 0xC000;
+ public static final int M_TYPE_IEC_SINT = 0xC001;
+ public static final int M_TYPE_IEC_INT = 0xC002;
+ public static final int M_TYPE_IEC_DINT = 0xC003;
+ public static final int M_TYPE_IEC_LINT = 0xC004;
+ public static final int M_TYPE_IEC_USINT = 0xC005;
+ public static final int M_TYPE_IEC_UINT = 0xC006;
+ public static final int M_TYPE_IEC_UDINT = 0xC007;
+ public static final int M_TYPE_IEC_ULINT = 0xC008;
+ public static final int M_TYPE_IEC_REAL = 0xC009;
+ public static final int M_TYPE_IEC_LREAL = 0xC00A;
+ public static final int M_TYPE_IEC_TIME = 0xC00B;
+ public static final int M_TYPE_IEC_DATE = 0xC00C;
+ public static final int M_TYPE_IEC_TIME_OF_DAY = 0xC00D;
+ public static final int M_TYPE_IEC_TOD = 0xC00E;
+ public static final int M_TYPE_IEC_DATE_AND_TIME = 0xC00F;
+ public static final int M_TYPE_IEC_DT = 0xC010;
+ public static final int M_TYPE_IEC_STRING = 0xC011;
+ public static final int M_TYPE_IEC_BYTE = 0xC012;
+ public static final int M_TYPE_IEC_WORD = 0xC013;
+ public static final int M_TYPE_IEC_DWORD = 0xC014;
+ public static final int M_TYPE_IEC_LWORD = 0xC015;
+ public static final int M_TYPE_IEC_WSTRING = 0xC016;
+
+ //DEVICE
+ public final static int FC_INITIALIZE_DEVICE = 0;
+ public final static int FC_SHUTDOWN_DEVICE = 2;
+
+ public final static int FC_GET_DEVICE_MODE = 4;
+ public final static int FC_STAR_DEVICE = 6;
+ public final static int FC_STOP_DEVICE = 8;
+ public final static int FC_GET_PDU_SIZE = 10;
+
+ //BITS
+ public final static int FC_READ_MEMORY_BITS = 12;
+ public final static int FC_WRIE_MEMORY_BITS = 14;
+
+ public final static int FC_READ_INPUT_BITS = 16;
+
+ public final static int FC_READ_OUTPUT_BITS = 18;
+ public final static int FC_WRITE_OUTPUT_BITS = 20;
+
+ public final static int FC_READ_DATA_BITS = 22;
+ public final static int FC_WRITE_DATA_BITS = 24;
+
+ //BYTES
+ public final static int FC_READ_MEMORY_BYTES = 26;
+ public final static int FC_WRITE_MEMORY_BYTES = 28;
+
+ public final static int FC_READ_INPUT_BYTES = 30;
+
+ public final static int FC_READ_OUTPUT_BYTES = 32;
+ public final static int FC_WRITE_OUTPUT_BYTES = 34;
+
+ public final static int FC_READ_DATA_BYTES = 36;
+ public final static int FC_WRITE_DATA_BYTES = 38;
+
+ //WORD
+ public final static int FC_READ_MEMORY_WORDS = 40;
+ public final static int FC_WRITE_MEMORY_WORDS = 42;
+
+ public final static int FC_READ_INPUT_WORDS = 44;
+
+ public final static int FC_READ_OUTPUT_WORDS = 46;
+ public final static int FC_WRITE_OUTPUT_WORDS = 48;
+
+ public final static int FC_READ_DATA_WORDS = 50;
+ public final static int FC_WRITE_DATA_WORDS = 52;
+
+ //DWORDS
+ public final static int FC_READ_MEMORY_DWORDS = 54;
+ public final static int FC_WRITE_MEMORY_DWORDS = 56;
+
+ public final static int FC_READ_INPUT_DWORDS = 58;
+
+ public final static int FC_READ_OUTPUT_DWORDS = 60;
+ public final static int FC_WRITE_OUTPUT_DWORDS = 62;
+
+ public final static int FC_READ_DATA_DWORDS = 64;
+ public final static int FC_WRITE_DATA_DWORDS = 66;
+
+ //TIMERS
+ public final static int FC_READ_TIMERS = 68;
+ public final static int FC_WRITE_TIMERS = 70;
+
+ //COUNTER
+ public final static int FC_READ_COUNTERS = 72;
+ public final static int FC_WRITE_COUNTERS = 74;
+
+ /**
+ * Return int error description.
+ * @param err
+ * @return String with the error description.
+ */
+ public static String getConstantString(int constant){
+ String s = "";
+ switch(constant){
+
+ case M_INITIATE_CNF: s = "M_INITIATE_CNF";break;
+ case M_READ_CNF: s = "M_READ_CNF";break;
+ case M_WRITE_CNF: s = "M_WRITE_CNF";break;
+ case M_MULTIPLE_READ_CNF: s = "M_MULTIPLE_READ_CNF";break;
+ case M_MULTIPLE_WRITE_CNF: s = "M_MULTIPLE_WRITE_CNF";break;
+ case M_CYCL_READ_INIT_CNF: s = "M_CYCL_READ_INIT_CNF";break;
+ case M_CYCL_READ_START_CNF: s = "M_CYCL_READ_START_CNF";break;
+ case M_CYCL_READ_STOP_CNF: s = "M_CYCL_READ_STOP_CNF";break;
+ case M_CYCL_READ_DELETE_CNF: s = "M_CYCL_READ_DELETE_CNF";break;
+ case M_PASSWORD_CNF: s = "M_PASSWORD_CNF";break;
+ case M_PASSWORD_LEN: s = "M_PASSWORD_LEN";break;
+ case M_RESET_PASSWORD: s = "M_RESET_PASSWORD";break;
+
+ case M_OK: s = "M_OK";break;
+ case M_INITIATE_IND: s = "M_INITIATE_IND";break;
+ case M_CYCL_READ_ABORT_IND: s = "M_CYCL_READ_ABORT_IND";break;
+ case M_CYCL_READ_IND: s = "M_CYCL_READ_IND";break;
+
+ case M_ERR: s = "M_ERR";break;
+ case M_ERR_ADD_VALUE_PDU: s = "M_ERR_ADD_VALUE_PDU";break;
+ case M_ERR_BLOCK_ALREADY_EXISTS: s = "M_ERR_BLOCK_ALREADY_EXISTS";break;
+ case M_ERR_BLOCK_NOT_FOUND: s = "M_ERR_BLOCK_NOT_FOUND";break;
+ case M_ERR_BLOCK_PROTECTED: s = "M_ERR_BLOCK_PROTECTED";break;
+ case M_ERR_BLOCK_TOO_LARGE: s = "M_ERR_BLOCK_TOO_LARGE";break;
+ case M_ERR_CONN_ABORTED: s = "M_ERR_CONN_ABORTED";break;
+ case M_ERR_CONN_ALREADY_FREE: s = "M_ERR_CONN_ALREADY_FREE";break;
+ case M_ERR_CONN_ALREADY_PASSED: s = "M_ERR_CONN_ALREADY_PASSED";break;
+ case M_ERR_CONN_CNF: s = "M_ERR_CONN_CNF";break;
+ case M_ERR_CONN_NAME_NOT_FOUND: s = "M_ERR_CONN_NAME_NOT_FOUND";break;
+ case M_ERR_COORD_RULE: s = "M_ERR_COORD_RULE";break;
+ case M_ERR_DGN_CONN_NOT_ANNOUNCED: s = "M_ERR_DGN_CONN_NOT_ANNOUNCED";break;
+ case M_ERR_DGN_CONN_TOO_MUCH: s = "M_ERR_DGN_CONN_TOO_MUCH";break;
+ case M_ERR_DGN_INFO_NOT_AVAIL: s = "M_ERR_DGN_INFO_NOT_AVAIL";break;
+ case M_ERR_FEW_PROT_LEVEL: s = "M_ERR_FEW_PROT_LEVEL";break;
+ case M_ERR_FILE_NOT_FOUND: s = "M_ERR_FILE_NOT_FOUND";break;
+ case M_ERR_FW_ERROR: s = "M_ERR_FW_ERROR";break;
+ case M_ERR_IEC_DATA_TYPE_MISMATCH: s = "M_ERR_IEC_DATA_TYPE_MISMATCH";break;
+ case M_ERR_IEC_INVALID_REF: s = "M_ERR_IEC_INVALID_REF";break;
+ case M_ERR_IEC_LOWER_LAYER: s = "M_ERR_IEC_LOWER_LAYER";break;
+ case M_ERR_IEC_NEG_RESPONSE: s = "M_ERR_IEC_NEG_RESPONSE";break;
+ case M_ERR_IEC_NO: s = "M_ERR_IEC_NO";break;
+ case M_ERR_IEC_NO_ACCESS_TO_REM_OBJECT: s = "M_ERR_IEC_NO_ACCESS_TO_REM_OBJECT";break;
+ case M_ERR_IEC_PARTNER_IN_WRONG_STATE: s = "M_ERR_IEC_PARTNER_IN_WRONG_STATE";break;
+ case M_ERR_IEC_RECEIVER_DISABLED: s = "M_ERR_IEC_RECEIVER_DISABLED";break;
+ case M_ERR_IEC_RECEIVER_OVERRUN: s = "M_ERR_IEC_RECEIVER_OVERRUN";break;
+ case M_ERR_IEC_RESET_RECEIVED: s = "M_ERR_IEC_RESET_RECEIVED";break;
+ case M_ERR_INSTALL: s = "M_ERR_INSTALL";break;
+ case M_ERR_INTERNAL_ERROR: s = "M_ERR_INTERNAL_ERROR";break;
+ case M_ERR_INVALID_BLOCK: s = "M_ERR_INVALID_BLOCK";break;
+ case M_ERR_INVALID_BLOCK_NR: s = "M_ERR_INVALID_BLOCK_NR";break;
+ case M_ERR_INVALID_BLOCK_TYPE: s = "M_ERR_INVALID_BLOCK_TYPE";break;
+ case M_ERR_INVALID_CONN_STATE: s = "M_ERR_INVALID_CONN_STATE";break;
+ case M_ERR_INVALID_CREF: s = "M_ERR_INVALID_CREF";break;
+ case M_ERR_INVALID_CYCL_READ_STATE: s = "M_ERR_INVALID_CYCL_READ_STATE";break;
+ case M_ERR_INVALID_DATA_SIZE: s = "M_ERR_INVALID_DATA_SIZE";break;
+ case M_ERR_INVALID_DATARANGE_OR_TYPE: s = "M_ERR_INVALID_DATARANGE_OR_TYPE";break;
+ case M_ERR_INVALID_FILENAME: s = "M_ERR_INVALID_FILENAME";break;
+ case M_ERR_INVALID_FILETYPE: s = "M_ERR_INVALID_FILETYPE";break;
+ case M_ERR_INVALID_ORDERIDM: s = "M_ERR_INVALID_ORDERIDM";break;
+ case M_ERR_INVALID_PARAMETER: s = "M_ERR_INVALID_PARAMETER";break;
+ case M_ERR_INVALID_PASSWORD: s = "M_ERR_INVALID_PASSWORD";break;
+ case M_ERR_INVALID_READ_BUFFER: s = "M_ERR_INVALID_READ_BUFFER";break;
+ case M_ERR_INVALID_SEGMENT: s = "M_ERR_INVALID_SEGMENT";break;
+ case M_ERR_INVALID_WRITE_BUFFER: s = "M_ERR_INVALID_WRITE_BUFFER";break;
+ case M_ERR_MAX_REQ: s = "M_ERR_MAX_REQ";break;
+ case M_ERR_NO_PASSWORD: s = "M_ERR_NO_PASSWORD";break;
+ case M_ERR_NO_RCV_BLOCK: s = "M_ERR_NO_RCV_BLOCK";break;
+ case M_ERR_NO_RESOURCE: s = "M_ERR_NO_RESOURCE";break;
+ case M_ERR_NO_SIN_SERV: s = "M_ERR_NO_SIN_SERV";break;
+ case M_ERR_OBJ_ACCESS_DENIED: s = "M_ERR_OBJ_ACCESS_DENIED";break;
+ case M_ERR_OBJ_ATTR_INCONSISTENT: s = "M_ERR_OBJ_ATTR_INCONSISTENT";break;
+ case M_ERR_OBJ_UNDEFINED: s = "M_ERR_OBJ_UNDEFINED";break;
+ case M_ERR_ORDERID_USED: s = "M_ERR_ORDERID_USED";break;
+ case M_ERR_R_ID_USED: s = "M_ERR_R_ID_USED";break;
+ case M_ERR_RECEIVE_BUFFER_FULL: s = "M_ERR_RECEIVE_BUFFER_FULL";break;
+ case M_ERR_REM_BRCV: s = "M_ERR_REM_BRCV";break;
+ case M_ERR_REM_BSEND: s = "M_ERR_REM_BSEND";break;
+ case M_ERR_REM_BSEND_CANCEL: s = "M_ERR_REM_BSEND_CANCEL";break;
+ case M_ERR_REM_DATABASE_TOO_SMALL: s = "M_ERR_REM_DATABASE_TOO_SMALL";break;
+ case M_ERR_RETRY: s = "M_ERR_RETRY";break;
+ case M_ERR_SERVICE_CONN_ALREADY_USED: s = "M_ERR_SERVICE_CONN_ALREADY_USED";break;
+ case M_ERR_SERVICE_NOT_SUPPORTED: s = "M_ERR_SERVICE_NOT_SUPPORTED";break;
+ case M_ERR_SERVICE_VFD_ALREADY_USED: s = "M_ERR_SERVICE_VFD_ALREADY_USED";break;
+ case M_ERR_SYMB_ADDRESS: s = "M_ERR_SYMB_ADDRESS";break;
+ case M_ERR_SYMB_ADDRESS_INCONSISTENT: s = "M_ERR_SYMB_ADDRESS_INCONSISTENT";break;
+ case M_ERR_TOO_LONG_DATA: s = "M_ERR_TOO_LONG_DATA";break;
+ case M_ERR_UNKNOWN_ERROR: s = "M_ERR_UNKNOWN_ERROR";break;
+ case M_ERR_WRONG_CP_DESCR: s = "M_ERR_WRONG_CP_DESCR";break;
+ case M_ERR_WRONG_IND_CNF: s = "M_ERR_WRONG_IND_CNF";break;
+
+ case M_TYPE_IEC_BOOL: s = "M_TYPE_IEC_BOOL";break;
+ case M_TYPE_IEC_SINT: s = "M_TYPE_IEC_SINT";break;
+ case M_TYPE_IEC_INT: s = "M_TYPE_IEC_INT";break;
+ case M_TYPE_IEC_DINT: s = "M_TYPE_IEC_DINT";break;
+ case M_TYPE_IEC_LINT: s = "M_TYPE_IEC_LINT";break;
+ case M_TYPE_IEC_USINT: s = "M_TYPE_IEC_USINT";break;
+ case M_TYPE_IEC_UINT: s = "M_TYPE_IEC_UINT";break;
+ case M_TYPE_IEC_UDINT: s = "M_TYPE_IEC_UDINT";break;
+ case M_TYPE_IEC_ULINT: s = "M_TYPE_IEC_ULINT";break;
+ case M_TYPE_IEC_REAL: s = "M_TYPE_IEC_REAL";break;
+ case M_TYPE_IEC_LREAL: s = "M_TYPE_IEC_LREAL";break;
+ case M_TYPE_IEC_TIME: s = "M_TYPE_IEC_TIME";break;
+ case M_TYPE_IEC_DATE: s = "M_TYPE_IEC_DATE";break;
+ case M_TYPE_IEC_TIME_OF_DAY: s = "M_TYPE_IEC_TIME_OF_DAY";break;
+ case M_TYPE_IEC_TOD: s = "M_TYPE_IEC_TOD";break;
+ case M_TYPE_IEC_DATE_AND_TIME: s = "M_TYPE_IEC_DATE_AND_TIME";break;
+ case M_TYPE_IEC_DT: s = "M_TYPE_IEC_DT";break;
+ case M_TYPE_IEC_STRING: s = "M_TYPE_IEC_STRING";break;
+ case M_TYPE_IEC_BYTE: s = "M_TYPE_IEC_BYTE";break;
+ case M_TYPE_IEC_WORD: s = "M_TYPE_IEC_WORD";break;
+ case M_TYPE_IEC_DWORD: s = "M_TYPE_IEC_DWORD";break;
+ case M_TYPE_IEC_LWORD: s = "M_TYPE_IEC_LWORD";break;
+ case M_TYPE_IEC_WSTRING: s = "M_TYPE_IEC_WSTRING";break;
+
+ default: s = "M_WITHOUT_DESCRIPTION";break;
+ }
+ return s;
+ };
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/core/PlcDeviceManagedService.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/core/PlcDeviceManagedService.java
new file mode 100644
index 0000000..17a623c
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/core/PlcDeviceManagedService.java
@@ -0,0 +1,175 @@
+/*
+ * 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.core;
+
+import org.apache.plc4x.merlot.scheduler.api.Job;
+import org.apache.plc4x.merlot.scheduler.api.JobContext;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import org.apache.plc4x.java.api.PlcDriver;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.ConfigurationEvent;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ConfigurationListener;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.device.Device;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.plc4x.merlot.api.PlcDeviceFactory;
+import org.apache.plc4x.merlot.api.PlcDevice;
+/**
+ *
+ * @author cgarcia
+ */
+public class PlcDeviceManagedService implements ManagedService, ConfigurationListener, Job {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(PlcDeviceManagedService.class);
+ private final BundleContext bc;
+ private static Map<String, Dictionary<String, ?>> waitingConfigs = null;
+ private String filter_driver = "(&(" + Constants.OBJECTCLASS + "=" + PlcDriver.class.getName() + ")" +
+ "(org.apache.plc4x.driver.code=*))";
+ private String filter_device = "(&(" + Constants.OBJECTCLASS + "=" + Device.class.getName() + ")" +
+ "(" + org.apache.plc4x.merlot.api.PlcDevice.SERVICE_NAME + "=*))";
+ private String filter_factory = "(&(" + Constants.OBJECTCLASS + "=" + PlcDeviceFactory.class.getName() + ")" +
+ "(org.apache.plc4x.device.factory=*))";
+
+
+ public PlcDeviceManagedService(BundleContext bc) {
+ this.bc = bc;
+ waitingConfigs = Collections.synchronizedMap(new HashMap<String, Dictionary<String, ?>>());
+ }
+
+ public String getName() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ /*
+ * Example:
+ * AS01 = s7://192.168.1.23/0/2,simatic,compresor system
+ * \__/ \___________________/ \_____/ \______________/
+ * key url name description
+ *
+ */
+ @Override
+ public void updated(Dictionary<String, ?> props) throws ConfigurationException {
+ if (null == props) return;
+
+// if (props.size() < 3){
+// waitingConfigs.put(pid, props);
+// return;
+// }
+
+ if (props!=null) {
+ Enumeration<String> keys = props.keys();
+ for (Enumeration e = props.keys(); e.hasMoreElements();) {
+ Object key = e.nextElement();
+ String driver_information = props.get(key).toString();
+ String[] drv_data = driver_information.split(":",2);
+ if (drv_data.length == 2) {
+ try {
+ String deviceFilter = filter_device.replace("*",key.toString());
+ ServiceReference[] references = bc.getServiceReferences((String) null, deviceFilter);
+ if (references != null){
+ for (ServiceReference reference:references){
+ LOGGER.info("The device already exists: " + reference.getProperty(org.apache.plc4x.merlot.api.PlcDevice.SERVICE_NAME));
+ }
+ } else {
+ String factoryFilter = filter_factory.replace("*",drv_data[0]);
+ references = bc.getServiceReferences((String) null, factoryFilter);
+
+ if (null != references){
+ //1. Si existe el factory, existe el driver.
+ drv_data = driver_information.split(",",3);
+
+ ServiceReference reference = references[0];
+ PlcDeviceFactory bdf = (PlcDeviceFactory) bc.getService(reference);
+ if (bdf != null){
+ PlcDevice device = bdf.create(key.toString(), drv_data[0], drv_data[1], drv_data[2]);
+ if (device != null) {
+
+ bc.registerService(org.apache.plc4x.merlot.api.PlcDevice.class.getName(), device, device.getProperties());
+
+ } else {
+ LOGGER.info("Failed to register driver." + factoryFilter);
+// waitingConfigs.put(pid, props);
+ }
+ } else {
+ LOGGER.info("The factory is not available:" + drv_data[0]);
+// waitingConfigs.put(pid, props);
+ };
+ } else {
+ LOGGER.info("There is no factory specific for the driver [{}], using base device. to register device driver.", factoryFilter);
+ //1. Si existe un driver se puede registrar el dispositivo.
+ //2. Registra el dispositivo con un BaseDevice
+ String factoryBaseFilter = filter_factory.replace("*","base");
+
+ references = bc.getServiceReferences((String) null, factoryBaseFilter);
+
+ //Filters changes to other configuration files.
+ if ((null != references) && (references.length > 0) && (!drv_data[0].equalsIgnoreCase("file"))) {
+ ServiceReference reference = references[0];
+ PlcDeviceFactory bdf = (PlcDeviceFactory) bc.getService(reference);
+ drv_data = driver_information.split(",",3);
+ PlcDevice device = bdf.create(key.toString() , drv_data[0], drv_data[1], drv_data[2]);
+
+ bc.registerService(org.apache.plc4x.merlot.api.PlcDevice.class.getName(), device, device.getProperties());
+
+ } else {
+ LOGGER.info("The base factory is not available.");
+ }
+ }
+ }
+ } catch (InvalidSyntaxException ex) {
+ LOGGER.info("Exception: " + ex);
+ }
+ } else {
+ LOGGER.info("Key not valid: " + key.toString() + " : " + drv_data[0]);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void execute(JobContext arg0) {
+// String pid = null;
+// Dictionary<String, ?> props = null;
+// Set<String> keys = new HashSet<>();
+// keys.addAll(waitingConfigs.keySet());
+// for (String key:keys){
+// pid = key;
+// props = waitingConfigs.remove(key);
+// try {
+// updated(pid,props);
+// } catch (ConfigurationException ex) {
+// LOGGER.debug("Problem updating [" + key +"] from waiting list." );
+// }
+// }
+ }
+
+ @Override
+ public void configurationEvent(ConfigurationEvent event) {
+ LOGGER.info(">>> Cambio de configuración: " + event.getPid());
+ }
+
+}
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
new file mode 100644
index 0000000..18ca5a5
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/core/PlcItemClientService.java
@@ -0,0 +1,131 @@
+/*
+ * 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.core;
+
+import com.lmax.disruptor.RingBuffer;
+import com.lmax.disruptor.TimeoutException;
+import com.lmax.disruptor.dsl.Disruptor;
+import com.lmax.disruptor.util.DaemonThreadFactory;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+import org.apache.plc4x.java.api.value.PlcValue;
+import org.apache.plc4x.merlot.api.PlcItemClient;
+import org.osgi.framework.BundleContext;
+import org.slf4j.LoggerFactory;
+
+
+public class PlcItemClientService {
+ private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(PlcItemClientService .class);
+ private final int BUFFER_SIZE = 1024;
+
+ private final BundleContext bc;
+ private ConcurrentHashMap<UUID, List<PlcItemClient>> item_clients;
+ private Disruptor<PlcItemEvent> disruptor;
+ private RingBuffer<PlcItemEvent> ringbuffer;
+
+ public PlcItemClientService(BundleContext bc) {
+ this.bc = bc;
+ }
+
+ public void init(){
+ //
+ item_clients = new ConcurrentHashMap<>();
+
+ disruptor = new Disruptor<>(PlcItemEvent::new, BUFFER_SIZE, DaemonThreadFactory.INSTANCE);
+
+ 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);
+ }
+ });
+ disruptor.start();
+ ringbuffer = disruptor.getRingBuffer();
+ }
+
+ public void destroy() {
+ try {
+ disruptor.shutdown(1, TimeUnit.SECONDS);
+ } catch (TimeoutException ex) {
+ LOGGER.info(ex.getMessage());
+ }
+ item_clients.clear();
+ }
+
+ //TODO: Check if the Item really exists
+ public boolean subcription(PlcItemClient client, UUID item_uid){
+ if (item_clients.containsKey(item_uid)) {
+ final List<PlcItemClient> clients = item_clients.get(item_uid);
+ if (!clients.contains(client)) {
+ clients.add(client);
+ return true;
+ }
+ } else {
+ final List<PlcItemClient> clients = new ArrayList<PlcItemClient>();
+ clients.add(client);
+ item_clients.put(item_uid, clients);
+ return true;
+ }
+ return false;
+ }
+
+ public void putItemEvent(UUID item_uid, PlcValue plcvalue){
+ if (item_clients.containsKey(item_uid)) {
+ ringbuffer.publishEvent((event, sequence, buffer) -> {
+ event.setUid(item_uid);
+ event.setPlcValue(plcvalue);
+ });
+ }
+ }
+
+ public class PlcItemEvent {
+ private UUID uid;
+
+ private int event;
+
+ private PlcValue plcvalue;
+
+ public UUID getUid() {
+ return uid;
+ }
+
+ public void setUid(UUID uid) {
+ this.uid = uid;
+ }
+
+ public int getEvent() {
+ return event;
+ }
+
+ public void setEvent(int event) {
+ this.event = event;
+ }
+
+ public PlcValue getPlcValue() {
+ return plcvalue;
+ }
+
+ public void setPlcValue(PlcValue plcvalue) {
+ this.plcvalue = plcvalue;
+ }
+
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/DriverEventFactoryImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/DriverEventFactoryImpl.java
new file mode 100644
index 0000000..30666f4
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/DriverEventFactoryImpl.java
@@ -0,0 +1,24 @@
+/*
+ * 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
+ *
+ * https://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;
+
+
+public class DriverEventFactoryImpl {
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/DriverEventImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/DriverEventImpl.java
new file mode 100644
index 0000000..128c95a
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/DriverEventImpl.java
@@ -0,0 +1,231 @@
+/*
+ * 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
+ *
+ * https://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.DriverCallback;
+import org.apache.plc4x.merlot.api.DriverEvent;
+import org.apache.plc4x.merlot.api.core.Merlot.FUNCTION;
+import com.lmax.disruptor.EventFactory;
+import io.netty.buffer.ByteBuf;
+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;
+
+
+public class DriverEventImpl implements DriverEvent {
+
+ private int TransactionID = 0;
+ private long Sequence = 0;
+ private short ProtocolID = 0;
+ private int Field = 0;
+ private int LengthField = 0;
+ private byte UnitID = 0;
+ private FUNCTION FunctionCode;
+ private ByteBuf Data = null;
+ private DriverCallback cb = null;
+
+ private PlcReadRequest plcReadRequest = null;
+ private PlcReadResponse plcReadResponse = null;
+ private PlcWriteRequest plcWriteRequest = null;
+ private PlcWriteResponse plcWriteResponse = null;
+
+
+ public static final EventFactory<DriverEvent> FACTORY = new EventFactory<DriverEvent>() {
+ @Override
+ public DriverEvent newInstance()
+ {
+ return new DriverEventImpl();
+ }
+ };
+
+ public DriverEventImpl(){
+
+ }
+
+/*
+ public DriverEventImpl(byte unitID, short protocolID, byte functionCode, short transactionID, ByteBuf data,
+ short lengthField, DriverCallback cb) {
+ super();
+ UnitID = unitID;
+ ProtocolID = protocolID;
+ FunctionCode = functionCode;
+ TransactionID = transactionID;
+ Data = data;
+ LengthField = lengthField;
+ this.cb = cb;
+ }
+*/
+ @Override
+ public void setTransactionID(int TransactionID) {
+ this.TransactionID = TransactionID;
+ }
+
+ @Override
+ public int getTransactionID() {
+ return this.TransactionID;
+ }
+
+ @Override
+ public void setProtocolID(short ProtocolID) {
+ this.ProtocolID = ProtocolID;
+ }
+
+ @Override
+ public short getProtocolID() {
+ return this.ProtocolID;
+ }
+
+ @Override
+ public void setField(int Field) {
+ this.Field = Field;
+ }
+
+ @Override
+ public int getField() {
+ return this.Field;
+ }
+
+ @Override
+ public void setLengthField(int LengthField) {
+ this.LengthField = LengthField;
+ }
+
+ @Override
+ public int getLengthField() {
+ return this.LengthField;
+ }
+
+ @Override
+ public void setUnitID(byte UnitID) {
+ this.UnitID = UnitID;
+ }
+
+ @Override
+ public byte getUnitID() {
+ return this.UnitID;
+ }
+
+ @Override
+ public void setFunctionCode(FUNCTION FunctionCode) {
+ this.FunctionCode = FunctionCode;
+ }
+
+ @Override
+ public FUNCTION getFunctionCode() {
+ return this.FunctionCode;
+ }
+
+ @Override
+ public void setData(ByteBuf Data) {
+ this.Data = Data;
+ }
+
+ @Override
+ public ByteBuf getData() {
+ return this.Data;
+ }
+
+ @Override
+ public byte[] getSerialized() {
+ return null;
+ }
+
+ @Override
+ public void setCallback(DriverCallback cb) {
+ this.cb = cb;
+ }
+
+ @Override
+ public DriverCallback getCallback() {
+ return cb;
+ }
+
+ @Override
+ public void setSequence(long Sequence) {
+ this.Sequence = Sequence;
+ }
+
+ @Override
+ public long getSequence() {
+ return Sequence;
+ }
+
+ @Override
+ public void setPlcReadRequest(PlcReadRequest plcReadRequest) {
+ this.plcReadRequest = plcReadRequest;
+ }
+
+ @Override
+ public PlcReadRequest getPlcReadRequest() {
+ return plcReadRequest;
+ }
+
+ @Override
+ public void setPlcReadResponse(PlcReadResponse plcReadResponse) {
+ this.plcReadResponse = plcReadResponse;
+ }
+
+ @Override
+ public PlcReadResponse getPlcReadResponse() {
+ return plcReadResponse;
+ }
+
+ @Override
+ public void setPlcWriteRequest(PlcWriteRequest plcWriteRequest) {
+ this.plcWriteRequest = plcWriteRequest;
+ }
+
+ @Override
+ public PlcWriteRequest getPlcWriteRequest() {
+ return plcWriteRequest;
+ }
+
+ @Override
+ public void setPlcWriteResponse(PlcWriteResponse plcWriteResponse) {
+ this.plcWriteResponse = plcWriteResponse;
+ }
+
+ @Override
+ public PlcWriteResponse getPlcWriteResponse() {
+ return plcWriteResponse;
+ }
+
+ @Override
+ public String toString() {
+ return "DriverEventImpl{" +
+ "TransactionID=" + TransactionID +
+ ", Sequence=" + Sequence +
+ ", ProtocolID=" + ProtocolID +
+ ", Field=" + Field +
+ ", LengthField=" + LengthField +
+ ", UnitID=" + UnitID +
+ ", FunctionCode=" + FunctionCode +
+ ", Data=" + Data +
+ ", cb=" + cb +
+ ", plcReadRequest=" + plcReadRequest +
+ ", plcReadResponse=" + plcReadResponse +
+ ", plcWriteRequest=" + plcWriteRequest +
+ ", plcWriteResponse=" + plcWriteResponse + '}';
+ }
+
+
+
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/DriverSessionFactoryImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/DriverSessionFactoryImpl.java
new file mode 100644
index 0000000..2474e63
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/DriverSessionFactoryImpl.java
@@ -0,0 +1,24 @@
+/*
+ * 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
+ *
+ * https://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;
+
+
+public class DriverSessionFactoryImpl {
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/DriverThreadFactoryImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/DriverThreadFactoryImpl.java
new file mode 100644
index 0000000..fb144ae
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/DriverThreadFactoryImpl.java
@@ -0,0 +1,31 @@
+/*
+ * 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
+ *
+ * https://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 java.util.concurrent.ThreadFactory;
+
+
+public class DriverThreadFactoryImpl implements ThreadFactory {
+
+ @Override
+ public Thread newThread(Runnable r) {
+ return new Thread(r);
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcDeviceFactoryImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcDeviceFactoryImpl.java
new file mode 100644
index 0000000..2a334c7
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcDeviceFactoryImpl.java
@@ -0,0 +1,43 @@
+/*
+ * 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.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.plc4x.merlot.api.PlcDevice;
+import org.apache.plc4x.merlot.api.PlcDeviceFactory;
+import org.osgi.framework.BundleContext;
+
+/*
+*
+*/
+public class PlcDeviceFactoryImpl implements PlcDeviceFactory {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PlcDeviceFactory.class);
+
+ private final BundleContext bc;
+
+ public PlcDeviceFactoryImpl(BundleContext bc) {
+ this.bc = bc;
+ }
+
+ @Override
+ public PlcDevice create(String device, String url, String name, String description) {
+ return new PlcDeviceImpl.PlcDeviceBuilder(bc, url, name, description).build();
+
+ }
+
+}
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
new file mode 100644
index 0000000..cb4775a
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcDeviceImpl.java
@@ -0,0 +1,361 @@
+/*
+ * 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 java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicReference;
+import static java.util.stream.Collectors.toList;
+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.merlot.api.PlcDevice;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.dal.Device;
+import org.osgi.service.dal.DeviceException;
+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;
+
+/*
+*
+*/
+public class PlcDeviceImpl implements PlcDevice {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(PlcDeviceImpl.class);
+
+ private static final String FILTER_DEVICE = "(&(" +
+ org.osgi.framework.Constants.OBJECTCLASS +
+ "=" + PlcDevice.class.getName() + ")" +
+ "(" + PlcDevice.SERVICE_UID + "=*))";
+
+ protected final BundleContext bc;
+ protected boolean enable = false;
+ protected boolean autostart = false;
+
+ protected PlcDriver plcDriver = null;
+ AtomicReference<PlcConnection> refPlcConnection;
+ PlcConnection plcConnection = null;
+
+ protected Hashtable<String, Object> myProperties;
+
+ 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.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);
+ if (null != builder.service_uid) {
+ myProperties.put(PlcDevice.SERVICE_UID, builder.service_uid.toString());
+ } else {
+ myProperties.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);
+ }
+
+ @Override
+ public void init() throws Exception {
+ //
+ }
+
+ @Override
+ public void destroy() throws Exception {
+ //
+ }
+
+ @Override
+ public void enable() {
+ if (null != plcDriver) {
+ //Try to connect
+ final String url = (String) myProperties.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));
+ } else {
+ LOGGER.info("The connection could not be established, check the url.");
+ }
+ } catch (PlcConnectionException ex) {
+ LOGGER.info(ex.getLocalizedMessage());
+ enable = false;
+ }
+ } else {
+ LOGGER.info("The PlcDriver has not been assigned to the device.");
+ }
+ }
+
+ @Override
+ public void disable() {
+ enable = false;
+ LOGGER.info("Device [{}] was disable.", myProperties.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());
+ plcConnection.close();
+ if (!plcConnection.isConnected()) {
+ enable = false;
+ LOGGER.info("Device [{}] connection was close.", myProperties.get(Device.SERVICE_NAME));
+ }
+ }
+ } catch (Exception ex) {
+ LOGGER.info(ex.getLocalizedMessage());
+ }
+ }
+
+ @Override
+ public boolean isEnable() {
+ return enable;
+ }
+
+ @Override
+ public Hashtable<String, ?> getProperties() {
+ return myProperties;
+ }
+
+ @Override
+ public String getDeviceName() {
+ return (String) myProperties.get(Device.SERVICE_NAME);
+ }
+
+ @Override
+ public void setDeviceName(String devicename) {
+ myProperties.put(Device.SERVICE_NAME, devicename);
+ }
+
+ @Override
+ public String getDeviceDescription() {
+ return (String) myProperties.get(Device.SERVICE_DESCRIPTION);
+ }
+
+ @Override
+ public void setDeviceDescription(String devicedescription) {
+ myProperties.put(Device.SERVICE_DESCRIPTION, devicedescription);
+ }
+
+ @Override
+ public void setUid(UUID uid) {
+ myProperties.put(PlcDevice.SERVICE_UID, uid.toString());
+ }
+
+ @Override
+ public UUID getUid() {
+ return UUID.fromString((String) myProperties.get(PlcDevice.SERVICE_UID));
+ }
+
+ @Override
+ public void setUrl(String url) {
+ if (!enable) {
+ myProperties.put(Device.SERVICE_DRIVER, url);
+ }
+ }
+
+ @Override
+ public String getUrl() {
+ return (String) myProperties.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)));
+ group.setPlcConnection(refPlcConnection);
+ device_groups.put(group.getGroupUid(), group);
+ bc.registerService(new String[]{Job.class.getName(),
+ PlcGroup.class.getName()},
+ group,
+ group.getProperties());
+ } else {
+ LOGGER.info("The device is enabled or the group identifier already exists.");
+ }
+ }
+
+ @Override
+ public PlcGroup getGroup(UUID uid) {
+ return device_groups.get(uid);
+ }
+
+ @Override
+ public void removeGroup(UUID uid) {
+ String filter = FILTER_DEVICE.replace("*", uid.toString());
+ ServiceReference<?> sr = bc.getServiceReference(filter);
+ bc.ungetService(sr);
+ device_groups.remove(uid);
+ }
+
+ @Override
+ public List<PlcGroup> getGroups() {
+ return device_groups.values().stream().
+ collect(toList());
+ }
+
+ @Override
+ public void noDriverFound() {
+ LOGGER.info("The associated driver is not found. go to IDLE.");
+ }
+
+ @Override
+ public Object getServiceProperty(String propKey) {
+ return myProperties.get(propKey);
+ }
+
+ @Override
+ public String[] getServicePropertyKeys() {
+ return myProperties.keySet().toArray(new String[myProperties.size()]);
+ }
+
+ @Override
+ public void remove() throws DeviceException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void attach(PlcDriver driver) {
+ LOGGER.info("Device: {} attach to driver {} ", myProperties.get(Device.SERVICE_NAME), driver.getProtocolCode());
+ this.plcDriver = driver;
+ }
+
+
+ public static class PlcDeviceBuilder {
+ private final BundleContext bc;
+ private final String service_name;
+ private final String service_description;
+ private final String service_driver;
+ private UUID service_uid;
+ private String device_category;
+ private String service_firmware_vendor;
+ private String service_firmware_version;
+ private String service_hardware_vendor;
+ private String service_hardware_version;
+ private String service_model;
+ private String[] service_reference_uids;
+ private String service_serial_number;
+ private String service_status;
+ private String service_status_detail;
+ private String[] service_types;
+
+ public PlcDeviceBuilder(BundleContext bc, String service_driver, String service_name, String service_description) {
+ this.bc = bc;
+ this.service_name = service_name;
+ this.service_description = service_description;
+ this.service_driver = service_driver;
+ String[] drv = service_driver.split(":");
+ this.device_category = drv[0];
+ }
+
+ public PlcDeviceBuilder setServiceUid(UUID serviceuid) {
+ this.service_uid = serviceuid;
+ return this;
+ }
+
+ public PlcDeviceBuilder setDeviceCategory(String device_category) {
+ this.device_category = device_category;
+ return this;
+ }
+
+ public PlcDeviceBuilder setServiceFirmwareVendor(String service_firmware_vendor) {
+ this.service_firmware_vendor = service_firmware_vendor;
+ return this;
+ }
+
+ public PlcDeviceBuilder setServiceFirmwareVersion(String service_firmware_version) {
+ this.service_firmware_version = service_firmware_version;
+ return this;
+ }
+
+ public PlcDeviceBuilder setServiceHardwareVendor(String service_hardware_vendor) {
+ this.service_hardware_vendor = service_hardware_vendor;
+ return this;
+ }
+
+ public PlcDeviceBuilder setServiceHardwareVersion(String service_hardware_version) {
+ this.service_hardware_version = service_hardware_version;
+ return this;
+ }
+
+ public PlcDeviceBuilder setServiceModel(String service_model) {
+ this.service_model = service_model;
+ return this;
+ }
+
+ public PlcDeviceBuilder setServiceReferenceUids(String[] service_reference_uids) {
+ this.service_reference_uids = service_reference_uids;
+ return this;
+ }
+
+ public PlcDeviceBuilder setServiceSerialNumber(String service_serial_number) {
+ this.service_serial_number = service_serial_number;
+ return this;
+ }
+
+ public PlcDeviceBuilder setServiceStatus(String service_status) {
+ this.service_status = service_status;
+ return this;
+ }
+
+ public PlcDeviceBuilder setServiceStatusDetail(String service_status_detail) {
+ this.service_status_detail = service_status_detail;
+ return this;
+ }
+
+ public PlcDeviceBuilder setServiceTypes(String[] service_types) {
+ this.service_types = service_types;
+ return this;
+ }
+
+
+ public PlcDevice build() {
+ PlcDevice plcdevice = new PlcDeviceImpl(this);
+ validateBaseDeviceObject(plcdevice);
+ return plcdevice;
+ }
+
+ private void validateBaseDeviceObject(PlcDevice plcdevice) {
+ //
+ }
+ }
+
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcDriverAdminServiceImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcDriverAdminServiceImpl.java
new file mode 100644
index 0000000..9d66bcb
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcDriverAdminServiceImpl.java
@@ -0,0 +1,64 @@
+/*
+ * 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
+ *
+ * https://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 java.util.List;
+import org.apache.plc4x.java.api.PlcDriver;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.event.EventAdmin;
+
+/*
+*
+*/
+public class PlcDriverAdminServiceImpl {
+
+ private BundleContext bc;
+ private final EventAdmin eventAdmin;
+ private List<PlcDriver> drivers = null;
+
+
+ public PlcDriverAdminServiceImpl(BundleContext bc, EventAdmin eventAdmin) {
+ this.bc = bc;
+ this.eventAdmin = eventAdmin;
+ }
+
+ public void setPlcDriverList(List<PlcDriver> drivers) {
+ this.drivers = drivers;
+ }
+
+ public List<PlcDriver> getPlcDriverList() {
+ return drivers;
+ }
+
+
+ public void bind(ServiceReference reference) {
+ //
+ }
+
+ public void bind(PlcDriver driver){
+ //
+ }
+
+ public void unbind(ServiceReference driver){
+ //
+ }
+
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcFunctionData.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcFunctionData.java
new file mode 100644
index 0000000..8cb78c8
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcFunctionData.java
@@ -0,0 +1,68 @@
+/*
+ * 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 java.util.Hashtable;
+import java.util.Map;
+import org.osgi.service.dal.FunctionData;
+import static org.osgi.service.dal.FunctionData.DESCRIPTION;
+import static org.osgi.service.dal.PropertyMetadata.DESCRIPTION;
+
+
+public class PlcFunctionData extends FunctionData {
+
+ public PlcFunctionData(PlcFunctionDataBuilder builder) {
+ super(builder.metadata);
+ }
+
+
+ public static class PlcFunctionDataBuilder {
+ private final Map<String, Object > metadata;
+ private long timestamp = Long.MIN_VALUE;
+
+ public PlcFunctionDataBuilder() {
+ metadata = new Hashtable<>();
+ }
+
+ public PlcFunctionDataBuilder putDescription(String desc) {
+ this.metadata.put(DESCRIPTION, desc);
+ return this;
+ }
+
+ public PlcFunctionDataBuilder putTimeStamp(long timestamp) {
+ this.timestamp = timestamp;
+ return this;
+ }
+
+ public PlcFunctionDataBuilder putMetaData(String k, Object o) {
+ this.metadata.put(k, o);
+ return this;
+ }
+
+ public PlcFunctionData build(){
+ PlcFunctionData fdmeta = new PlcFunctionData(this);
+ validatePlcGroupObject(fdmeta);
+ return fdmeta;
+ }
+
+ private void validatePlcGroupObject(PlcFunctionData fdmeta) {
+ //
+ }
+
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcFunctionEvent.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcFunctionEvent.java
new file mode 100644
index 0000000..b9dac43
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcFunctionEvent.java
@@ -0,0 +1,96 @@
+/*
+ * 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 java.util.Hashtable;
+import java.util.Map;
+import java.util.UUID;
+import org.osgi.service.dal.FunctionEvent;
+import static org.osgi.service.dal.FunctionEvent.EVENT_CLASS;
+import static org.osgi.service.dal.FunctionEvent.EVENT_PACKAGE;
+import static org.osgi.service.dal.FunctionEvent.FUNCTION_UID;
+import static org.osgi.service.dal.FunctionEvent.PROPERTY_NAME;
+import static org.osgi.service.dal.FunctionEvent.PROPERTY_VALUE;
+
+
+public class PlcFunctionEvent extends FunctionEvent {
+
+ public PlcFunctionEvent(PlcFunctionEventBuilder builder) {
+ super(builder.topic, builder.metadata);
+ }
+
+ public static class PlcFunctionEventBuilder {
+ private final Map<String, Object > metadata;
+ private String topic = null;
+
+ public PlcFunctionEventBuilder() {
+ metadata = new Hashtable<>();
+ }
+
+ public PlcFunctionEventBuilder setTopic(String topic) {
+ this.topic = topic;
+ return this;
+ }
+
+ public PlcFunctionEventBuilder putEventClass(String evclass) {
+ metadata.put(EVENT_CLASS, evclass);
+ return this;
+ }
+
+ public PlcFunctionEventBuilder putEventPackage(String evpackage) {
+ metadata.put(EVENT_PACKAGE, evpackage);
+ return this;
+ }
+
+ public PlcFunctionEventBuilder putFunctionUid(UUID uid) {
+ metadata.put(FUNCTION_UID, uid);
+ return this;
+ }
+
+ public PlcFunctionEventBuilder putPropertyName(String name) {
+ metadata.put(PROPERTY_NAME, name);
+ return this;
+ }
+
+ public PlcFunctionEventBuilder putPropertyValue(Object o) {
+ metadata.put(PROPERTY_VALUE, o);
+ return this;
+ }
+
+ public PlcFunctionEventBuilder putTopicPropertyChanged(Object o) {
+ metadata.put(TOPIC_PROPERTY_CHANGED, o);
+ return this;
+ }
+
+ public PlcFunctionEventBuilder putMetaData(String k, Object o) {
+ this.metadata.put(k, o);
+ return this;
+ }
+
+ public PlcFunctionEvent build(){
+ PlcFunctionEvent femeta = new PlcFunctionEvent(this);
+ validatePlcGroupObject(femeta);
+ return femeta;
+ }
+
+ private void validatePlcGroupObject(PlcFunctionEvent femeta) {
+ //
+ }
+
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcGeneralFunctionImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcGeneralFunctionImpl.java
new file mode 100644
index 0000000..0fe564a
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcGeneralFunctionImpl.java
@@ -0,0 +1,664 @@
+/*
+ * 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 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.value.PlcValue;
+import org.apache.plc4x.merlot.api.PlcDevice;
+import org.apache.plc4x.merlot.api.PlcDeviceFactory;
+import org.apache.plc4x.merlot.api.PlcFunction;
+import org.apache.plc4x.merlot.api.PlcGroup;
+import org.apache.plc4x.merlot.api.PlcItem;
+import org.apache.plc4x.merlot.scheduler.api.ScheduleOptions;
+import org.apache.plc4x.merlot.scheduler.api.Scheduler;
+import org.apache.plc4x.merlot.scheduler.api.SchedulerError;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.dal.OperationMetadata;
+import org.osgi.service.dal.PropertyMetadata;
+import org.slf4j.LoggerFactory;
+import org.apache.plc4x.merlot.api.PlcGeneralFunction;
+
+/*
+*
+*/
+public class PlcGeneralFunctionImpl implements PlcGeneralFunction {
+
+ private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(PlcGeneralFunctionImpl.class);
+
+ private static String FILTER_DRIVER = "(&(" + Constants.OBJECTCLASS + "=" + PlcDriver.class.getName() + ")" +
+ "(org.apache.plc4x.driver.code=*))";
+
+ private static String FILTER_DEVICE_CATEGORY = "(&(" + Constants.OBJECTCLASS + "=" + PlcDevice.class.getName() + ")" +
+ "(" + org.osgi.service.device.Constants.DEVICE_CATEGORY + "=*))";
+
+ private static final String FILTER_DEVICE_UID = "(&(" +
+ org.osgi.framework.Constants.OBJECTCLASS + "=" +
+ PlcDevice.class.getName() + ")" +
+ "(" + PlcDevice.SERVICE_UID + "=*))";
+
+ private static String FILTER_DEVICE_GROUP = "(&(" + Constants.OBJECTCLASS + "=" + PlcGroup.class.getName() + ")" +
+ "(" + org.apache.plc4x.merlot.api.PlcGroup.GROUP_DEVICE_UID + "=*))";
+
+ private static String FILTER_GROUP_UID = "(&(" + Constants.OBJECTCLASS + "=" + PlcGroup.class.getName() + ")" +
+ "(" + org.apache.plc4x.merlot.api.PlcGroup.GROUP_UID + "=*))";
+
+ private static String FILTER_ITEM_UID = "(&(" + Constants.OBJECTCLASS + "=" + PlcItem.class.getName() + ")" +
+ "(" + PlcItem.ITEM_UID + "=*))";
+
+ private static String FILTER_FACTORY = "(&(" + Constants.OBJECTCLASS + "=" + PlcDeviceFactory.class.getName() + ")" +
+ "(org.apache.plc4x.device.factory=*))";
+
+
+
+ private static final String[] operations = {"getPlcDrivers",
+ "getPlcDevices",
+ "getPlcDevice",
+ "getPlcDeviceMeta",
+ "setPlcDeviceName",
+ "setPlcDeviceDesc",
+ "getPlcDeviceGroups",
+ "getPlcGroup",
+ "setPlcGroupScanRate",
+ "getPlcGroupItemsCount",
+ "getPlcGroupItems",
+ "getPlcItem",
+ "getPlcItemType",
+ "getPlcItemValue",
+ "getPlcItemByteBuf",
+ "enable",
+ "disable",
+ "read",
+ "write"};
+
+ private static final PlcOperationMetadata OP_GET_PLCDRIVERS_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("List all Plc4x drivers in the context.").
+ setReturnValueMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("value").
+ putLongDescription("All PlcDriver in a Map<String, String>.").
+ build()).
+ build();
+
+ private static final PlcOperationMetadata OP_GET_PLCDEVICES_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("List all device in the context.").
+ setReturnValueMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("value").
+ putLongDescription("All PlcDevice in a Map<UUID, String>.").
+ build()).
+ build();
+
+ private static final PlcOperationMetadata OP_GET_PLCDEVICE_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("Return a PlcDevice .").
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("uuid").
+ putLongDescription("UUID of the device.").
+ build()).
+ setReturnValueMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("value").
+ putLongDescription("Return a PlcDevice with the uid equal to uuid.").
+ build()).
+ build();
+
+ private static final PlcOperationMetadata OP_GET_PLCDEVICE_META_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("Return metadata from asociated PlcDevice.").
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("uuid").
+ putLongDescription("UUID of the device.").
+ build()).
+ setReturnValueMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("value").
+ putLongDescription("All PlcDevice in a Map<UUID, Object>.").
+ build()).
+ build();
+
+ private static final PlcOperationMetadata OP_SET_PLCDEVICE_NAME_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("Assigns the device name indicated by the UUID.").
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("uuid").
+ putLongDescription("UUID of the device.").
+ build()).
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("device_name").
+ putLongDescription("String with new name.").
+ build()).
+ build();
+
+ private static final PlcOperationMetadata OP_SET_PLCDEVICE_DESC_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("Assigns the device description indicated by the UUID.").
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("uuid").
+ putLongDescription("UUID of the device.").
+ build()).
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("device_desc").
+ putLongDescription("String with new device description.").
+ build()).
+ build();
+
+ private static final PlcOperationMetadata OP_GET_PLCDEVICE_GROUPS_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("Lists the all groups associated with a device.").
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("uuid").
+ putLongDescription("UUID of the device.").
+ build()).
+ setReturnValueMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("value").
+ putLongDescription("All PlcGroup in a Map<UUID, String>.").
+ build()).
+ build();
+
+ private static final PlcOperationMetadata OP_GET_PLCGROUP_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("Return the PlcGroup indicate by uid.").
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("uuid").
+ putLongDescription("UUID of the group.").
+ build()).
+ setReturnValueMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("value").
+ putLongDescription("Return PlcGroup searched by uid.").
+ build()).
+ build();
+
+ private static final PlcOperationMetadata OP_SET_PLCGROUP_SR_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("Set the scan rate (period) of the group").
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("uuid").
+ putLongDescription("UUID of the device.").
+ build()).
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("scan_rate").
+ putLongDescription("a long value for the scan rate in ms. Minimum 100 ms").
+ build()).
+ build();
+
+ private static final PlcOperationMetadata OP_GET_PLCGROUP_ITEMS_COUNT_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("Get the number of items in a group.").
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("uuid").
+ putLongDescription("UUID of the group.").
+ build()).
+ setReturnValueMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("value").
+ putLongDescription("Return a integer with the number of items in the group.").
+ build()).
+ build();
+
+ private static final PlcOperationMetadata OP_GET_PLCGROUP_ITEMS_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("Lists the items associated with a group.").
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("uuid").
+ putLongDescription("UUID of the group.").
+ build()).
+ setReturnValueMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("value").
+ putLongDescription("All PlcItem in a group like a Map<UUID, String>.").
+ build()).
+ build();
+
+ private static final PlcOperationMetadata OP_GET_PLCITEM_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("Get a PlcItem from a group.").
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("uuid").
+ putLongDescription("UUID of the item.").
+ build()).
+ setReturnValueMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("value").
+ putLongDescription("A PlcItem from the group").
+ build()).
+ build();
+
+ private static final PlcOperationMetadata OP_GET_PLCITEM_TYPE_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("Get the default type for a PlcItem.").
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("item_uid").
+ putLongDescription("UUID of the device.").
+ build()).
+ setReturnValueMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("value").
+ putLongDescription("A PlcItem default Type.").
+ build()).
+ build();
+
+ private static final PlcOperationMetadata OP_GET_PLCITEM_VALUE_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("Lists the groups associated with a device.").
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("uuid").
+ putLongDescription("UUID of the device.").
+ build()).
+ setReturnValueMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("value").
+ putLongDescription("Return PlcValue of PlcItem default Type.").
+ build()).
+ build();
+
+ private static final PlcOperationMetadata OP_GET_PLCITEM_BYTEBUF_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("Lists the groups associated with a device.").
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("uuid").
+ putLongDescription("UUID of the device.").
+ build()).
+ build();
+
+ private static final PlcOperationMetadata OP_ENABLE_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("Enable a single PlcItem.").
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("uuid").
+ putLongDescription("String representing the UUID of the device.").
+ build()).
+ build();
+
+ private static final PlcOperationMetadata OP_DISABLE_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("Disable a single PlcItem.").
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("uuid").
+ putLongDescription("String representing the UUID of the device.").
+ build()).
+ build();
+
+ private static final PlcOperationMetadata OP_READ_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("Read a single PlcValue from PlcItem.").
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("uuid").
+ putLongDescription("String representing the UUID of the device.").
+ build()).
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("tag").
+ putLongDescription("PlcItem ID.").
+ build()).
+ build();
+
+ private static final PlcOperationMetadata OP_WRITE_META = new PlcOperationMetadata.
+ PlcOperationMetaDataBuilder().
+ putDescription("Write a single PlcValue from PlcItem.").
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("uuid").
+ putLongDescription("String representing the UUID of the device.").
+ build()).
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("tag").
+ putLongDescription("PlcItem ID.").
+ build()).
+ addOperationMetadata(new PlcPropertyMetadata.PlcPropertyMetaDataBuilder().
+ putDescription("value").
+ putLongDescription("Value to write in String.").
+ build()).
+ build();
+
+ private final BundleContext bc;
+ private final Scheduler scheduler;
+ protected Hashtable<String, Object> myProperties;
+
+ public PlcGeneralFunctionImpl(BundleContext bc, Scheduler scheduler) {
+ this.myProperties = new Hashtable<String, Object>();
+ this.bc = bc;
+ this.scheduler = scheduler;
+ myProperties.put(PlcFunction.SERVICE_OPERATION_NAMES, operations);
+
+ }
+
+ public void bind(PlcFunction fc, Map properties) {
+ myProperties.clear();
+ myProperties.putAll(properties);
+ }
+
+ public void unbind(PlcFunction fc, Map properties) {
+ //
+ }
+
+ @Override
+ public Hashtable<String, Object> getProperties() {
+ return myProperties;
+ }
+
+ @Override
+ public PropertyMetadata getPropertyMetadata(String propertyName) {
+ return null;
+ }
+
+ @Override
+ public OperationMetadata getOperationMetadata(String operationName) {
+ switch (operationName) {
+ case "getPlcDrivers": return OP_GET_PLCDRIVERS_META;
+ case "getPlcDevices": return OP_GET_PLCDEVICES_META;
+ case "getPlcDevice": return OP_GET_PLCDEVICE_META;
+ case "getPlcDeviceMeta": return OP_GET_PLCDEVICE_META_META;
+ case "setPlcDeviceName": return OP_SET_PLCDEVICE_NAME_META;
+ case "setPlcDeviceDesc": return OP_SET_PLCDEVICE_DESC_META;
+ case "getPlcDeviceGroups": return OP_GET_PLCDEVICE_GROUPS_META;
+ case "getPlcGroup": return OP_GET_PLCGROUP_META;
+ case "setPlcGroupScanRate": return OP_SET_PLCGROUP_SR_META;
+ case "getPlcGroupItemsCount": return OP_GET_PLCGROUP_ITEMS_COUNT_META;
+ case "getPlcGroupItems": return OP_GET_PLCGROUP_ITEMS_META;
+ case "getPlcItem": return OP_GET_PLCITEM_META;
+ case "getPlcItemType": return OP_GET_PLCITEM_TYPE_META;
+ case "getPlcItemValue": return OP_GET_PLCITEM_VALUE_META;
+ case "getPlcItemByteBuf": return OP_GET_PLCITEM_BYTEBUF_META;
+ case "enable": return OP_ENABLE_META;
+ case "disable": return OP_DISABLE_META;
+ case "read": return OP_READ_META;
+ case "write": return OP_WRITE_META;
+ default: return null;
+ }
+ }
+
+ @Override
+ public Object getServiceProperty(String propKey) {
+ return null;
+ }
+
+ @Override
+ public String[] getServicePropertyKeys() {
+ return operations;
+ }
+
+ @Override
+ public Map<String, String> getPlcDrivers() {
+ Map<String, String> drivers = new HashMap<>();
+
+ try {
+ ServiceReference[] refs = bc.getServiceReferences((String) null, FILTER_DRIVER);
+
+ if (null != refs) {
+ for (ServiceReference ref:refs){
+ final PlcDriver driver = (PlcDriver) bc.getService(ref);
+ drivers.put(driver.getProtocolCode(),driver.getProtocolName());
+ }
+ }
+ } catch (InvalidSyntaxException ex) {
+ LOGGER.info(ex.getMessage());
+ } finally {
+ return drivers;
+ }
+ }
+
+ @Override
+ public Map<UUID, String> getPlcDevices(String driver_code) {
+ Map<UUID, String> plcdevices = new HashMap<>();
+
+ try {
+ String filter = FILTER_DEVICE_CATEGORY.replace("*", driver_code);
+ ServiceReference[] refs = bc.getServiceReferences((String) null, filter);
+ if (null != refs) {
+ for (ServiceReference ref:refs){
+ final PlcDevice device = (PlcDevice) bc.getService(ref);
+ plcdevices.put(device.getUid(),device.getDeviceName());
+ }
+ }
+ } catch (InvalidSyntaxException ex) {
+ LOGGER.info(ex.getMessage());
+ } finally {
+ return plcdevices;
+ }
+ }
+
+ @Override
+ public PlcDevice getPlcDevice(UUID device_uid) {
+ String filter = FILTER_DEVICE_UID.replace("*", device_uid.toString());
+ try {
+ ServiceReference[] refs = bc.getServiceReferences((String) null, filter);
+ if (null != refs) {
+ final PlcDevice plcdevice = (PlcDevice) bc.getService(refs[0]);
+ return plcdevice;
+ } else {
+ LOGGER.info("No device detectec with filter: " + filter);
+ }
+ } catch (InvalidSyntaxException ex) {
+ LOGGER.info(ex.getMessage());
+ }
+
+ return null;
+ }
+
+ @Override
+ public Map<String, Object> getPlcDeviceMeta(UUID group_uid) {
+ Map<String, Object> props = new HashMap<>();
+
+ try {
+ String filter = FILTER_DEVICE_UID.replace("*", group_uid.toString());
+ ServiceReference ref = bc.getServiceReference(filter);
+ if (null != ref) {
+ final PlcDevice device = (PlcDevice) bc.getService(ref);
+ props.putAll(device.getProperties());
+ }
+ } catch (Exception ex) {
+ LOGGER.info(ex.getMessage());
+ } finally {
+ return props;
+ }
+ }
+
+ @Override
+ public void setPlcDeviceName(UUID device_uid, String group_name) {
+ final PlcDevice plcdevice = getPlcDevice(device_uid);
+ if (null != plcdevice){
+ plcdevice.setDeviceName(group_name);
+ }
+ }
+
+ @Override
+ public void setPlcDeviceDesc(UUID device_uid, String device_desc) {
+ final PlcDevice plcdevice = getPlcDevice(device_uid);
+ if (null != plcdevice){
+ plcdevice.setDeviceDescription(device_desc);
+ }
+ }
+
+ @Override
+ public Map<UUID, String> getPlcDeviceGroups(UUID device_uid) {
+ Map<UUID, String> plcgroups = new HashMap<>();
+
+ try {
+ String filter = FILTER_DEVICE_GROUP.replace("*", device_uid.toString());
+ ServiceReference[] refs = bc.getServiceReferences((String) null, filter);
+ if (null != refs) {
+ for (ServiceReference ref:refs){
+ final PlcGroup group = (PlcGroup) bc.getService(ref);
+ plcgroups.put(group.getGroupUid(),group.getGroupName());
+ }
+ }
+ } catch (InvalidSyntaxException ex) {
+ LOGGER.info(ex.getMessage());
+ } finally {
+ return plcgroups;
+ }
+ }
+
+ @Override
+ public PlcGroup getPlcGroup(UUID group_uid) {
+ String filter = FILTER_GROUP_UID.replace("*", group_uid.toString());
+ try {
+ ServiceReference[] refs = bc.getServiceReferences((String) null, filter);
+ if (null != refs) {
+ final PlcGroup plcgroup = (PlcGroup) bc.getService(refs[0]);
+ return plcgroup;
+ };
+ } catch (InvalidSyntaxException ex) {
+ LOGGER.info(ex.getMessage());
+ }
+
+
+ return null;
+ }
+
+ @Override
+ public int setPlcGroupScanRate(UUID group_uid, long scan_rate) {
+ final PlcGroup plcgroup = getPlcGroup(group_uid);
+ if (null != plcgroup){
+ try {
+ scheduler.getJobs().entrySet().stream().
+ filter(e -> e.getKey().startsWith(plcgroup.getGroupName())).
+ forEach(e ->{
+ ScheduleOptions options = scheduler.NOW(-1, scan_rate);
+ try {
+ scheduler.reschedule(e.getKey(), options);
+ } catch (IllegalArgumentException ex) {
+ LOGGER.info(ex.getMessage());
+ } catch (SchedulerError ex) {
+ LOGGER.info(ex.getMessage());
+ }
+ });
+ } catch (SchedulerError ex) {
+ LOGGER.info(ex.getMessage());
+ }
+ }
+ return 0;
+ }
+
+ @Override
+ public int getPlcGroupItemsCount(UUID group_uid) {
+ final PlcGroup plcgroup = getPlcGroup(group_uid);
+ return plcgroup.getItems().size();
+ }
+
+ @Override
+ public Map<UUID, String> getPlcGroupItems(UUID group_uid) {
+ Map<UUID, String> plcitems = new HashMap<>();
+ final PlcGroup plcgroup = getPlcGroup(group_uid);
+ List<PlcItem> items = plcgroup.getItems();
+ items.forEach(i -> {plcitems.put(i.getItemUid(), i.getItemName());});
+ return plcitems;
+ }
+
+ //Items
+
+ @Override
+ public PlcItem getPlcItem(UUID item_uid) {
+ String filter = FILTER_ITEM_UID.replace("*", item_uid.toString());
+ ServiceReference ref = bc.getServiceReference(filter);
+ if (null != ref) {
+ final PlcItem plcitem = (PlcItem) bc.getService(ref);
+ return plcitem;
+ };
+
+ return null;
+ }
+
+ @Override
+ public short getPlcItemType(UUID item_uid) {
+ final PlcItem item = getPlcItem(item_uid);
+ return item.getItemPlcValue().getPlcValueType().getValue();
+ }
+
+ @Override
+ public PlcValue getPlcItemValue(UUID item_uid) {
+ final PlcItem item = getPlcItem(item_uid);
+ return item.getItemPlcValue();
+ }
+
+ @Override
+ public ByteBuf getPlcItemByteBuf(UUID item_uid) {
+ final PlcItem item = getPlcItem(item_uid);
+ return item.getItemByteBuf();
+ }
+
+ @Override
+ public byte[] getPlcItemBytes(UUID item_uid) {
+ final PlcItem item = getPlcItem(item_uid);
+ return item.getItemBytes();
+ }
+
+ @Override
+ public void enable(UUID uuid) {
+ final String strfilter = "(|" +
+ FILTER_DEVICE_UID.replace("*", uuid.toString()) +
+ FILTER_GROUP_UID.replace("*", uuid.toString()) +
+ FILTER_ITEM_UID.replace("*", uuid.toString()) +
+ ")";
+ final ServiceReference ref = bc.getServiceReference(strfilter);
+ if (null != ref) {
+ final Object plcasset = bc.getService(ref);
+ if (plcasset instanceof PlcDevice) {
+ ((PlcDevice) plcasset).enable();
+ } else if (plcasset instanceof PlcGroup){
+ ((PlcGroup) plcasset).enable();
+ } else if (plcasset instanceof PlcItem) {
+ ((PlcItem) plcasset).enable();
+ }
+ } else {
+ LOGGER.info("The Plc4x asset service does not exist uid: {}", uuid.toString());
+ }
+ }
+
+ @Override
+ public void disable(UUID uuid) {
+ final String strfilter = "(| " +
+ FILTER_DEVICE_UID.replace("*", uuid.toString()) +
+ FILTER_GROUP_UID.replace("*", uuid.toString()) +
+ FILTER_ITEM_UID.replace("*", uuid.toString()) +
+ ")";
+ final ServiceReference ref = bc.getServiceReference(strfilter);
+ if (null != ref) {
+ final Object plcasset = bc.getService(ref);
+ if (plcasset instanceof PlcDevice) {
+ ((PlcDevice) plcasset).disable();
+ } else if (plcasset instanceof PlcGroup){
+ ((PlcGroup) plcasset).disable();
+ } else if (plcasset instanceof PlcItem) {
+ ((PlcItem) plcasset).disable();
+ }
+ } else {
+ LOGGER.info("The Plc4x asset service does not exist uid: {}", uuid.toString());
+ }
+ }
+
+ @Override
+ public PlcValue read(UUID uuid, String tag) {
+ final String strfilter = FILTER_ITEM_UID.replace("*", uuid.toString());
+ final ServiceReference ref = bc.getServiceReference(strfilter);
+ if (null != ref) {
+ final Object plcasset = bc.getService(ref);
+ if (plcasset instanceof PlcItem) {
+ final PlcValue plcvalue = ((PlcItem) plcasset).getItemPlcValue();
+ return plcvalue;
+ }
+ LOGGER.info("The PlcItem asset service does not exist uid: {}", uuid.toString());
+ }
+ return null;
+ }
+
+ @Override
+ public void write(UUID uuid, String tag, String value) {
+ //
+ }
+
+}
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
new file mode 100644
index 0000000..c8a4399
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcGroupImpl.java
@@ -0,0 +1,362 @@
+/*
+ * 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 java.util.Collection;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
+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;
+import org.osgi.framework.BundleContext;
+import org.apache.plc4x.merlot.api.PlcItem;
+import org.apache.plc4x.merlot.api.PlcGroup;
+import org.apache.plc4x.merlot.api.core.PlcItemClientService;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.LoggerFactory;
+
+/*
+*
+*/
+public class PlcGroupImpl implements PlcGroup, Job {
+ private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(PlcGroupImpl.class);
+ private static final String FILTER_ITEM = "(&(" + org.osgi.framework.Constants.OBJECTCLASS + "=" + PlcItem.class.getName() + ")" +
+ "(" + PlcItem.ITEM_UID + "=*))";
+
+ protected final BundleContext bc;
+
+ private UUID uid;
+
+ private boolean enable = false;
+
+ private long grouptransmit = 0;
+ private long groupreceives = 0;
+ private long grouperrors = 0;
+
+ private long groupitems = 0;
+ private long groupupdatrate = -1;
+
+ private final Hashtable<String, Object> myproperties;
+
+ private final Map<UUID, PlcItem> group_items;
+
+ private PlcItemClientService items_service = null;
+
+ private AtomicReference<PlcConnection> plcConnection = null;
+ private PlcReadRequest.Builder builder = null;
+
+ private StopWatch watch = new StopWatch();
+ private long[] aux = new long[1];
+
+
+
+ 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);
+
+ }
+
+ public void start(int bc){
+ //
+ if (null != plcConnection) {
+ if (plcConnection.get().isConnected()) {
+ enable = true;
+ } else {
+ enable = false;
+ }
+ } else {
+ LOGGER.info("The PlcConnection has not been assigned to the group.");
+ enable = false;
+ }
+ }
+
+ public void stop(int bc){
+ enable = false;
+ }
+
+ @Override
+ public void enable() {
+ enable = true;
+ }
+
+ @Override
+ public void disable() {
+ enable = false;
+ }
+
+
+ @Override
+ public UUID getGroupUid() {
+ return UUID.fromString((String) myproperties.get(PlcGroup.GROUP_UID));
+ }
+
+ @Override
+ public UUID getGroupDeviceUid() {
+ return (UUID) myproperties.get(PlcGroup.GROUP_DEVICE_UID);
+ }
+
+ @Override
+ public void setGroupDeviceUid(UUID device_uid) {
+ myproperties.put(PlcGroup.GROUP_DEVICE_UID, device_uid);
+ }
+
+ @Override
+ public String getGroupName() {
+ return (String) myproperties.get(PlcGroup.GROUP_NAME);
+ }
+
+ @Override
+ public void setGroupName(String groupname) {
+ myproperties.put(PlcGroup.GROUP_NAME, groupname);
+ }
+
+ @Override
+ public String getGroupDescription() {
+ return (String) myproperties.get(PlcGroup.GROUP_DESCRIPTION);
+ }
+
+ @Override
+ public void setGroupDescription(String groupdescription) {
+ myproperties.put(PlcGroup.GROUP_DESCRIPTION, groupdescription);
+ }
+
+ @Override
+ public boolean isEnable() {
+ return enable;
+ }
+
+ @Override
+ public long getPeriod() {
+ return (long) myproperties.get(PlcGroup.GROUP_PERIOD);
+ }
+
+ @Override
+ public void setPeriod(long period) {
+ myproperties.put(PlcGroup.GROUP_PERIOD, (period < 100)?100:period);
+ }
+
+ @Override
+ public long getGroupTransmit() {
+ aux[0] = 0;
+ group_items.forEach((uid, item) -> {aux[0] = +item.getItemTransmits();});
+ return aux[0];
+ }
+
+ @Override
+ public long getGroupReceives() {
+ aux[0] = 0;
+ group_items.forEach((uid, item) -> {aux[0] = +item.getItemReceives();});
+ return aux[0];
+ }
+
+ @Override
+ public long getGroupErrors() {
+ aux[0] = 0;
+ group_items.forEach((uid, 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));
+ this.plcConnection = plcConnection;
+ }
+
+ @Override
+ public Map<UUID, PlcItem> getGroupItems() {
+ return group_items;
+ }
+
+ @Override
+ public void setGroupItems(long groupitems) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Hashtable<String, Object> getProperties() {
+ return myproperties;
+ }
+
+ @Override
+ public void putItem(PlcItem item) {
+ if (!group_items.containsKey(item.getItemUid())) {
+ group_items.put(item.getItemUid(), item);
+ bc.registerService(PlcItem.class.getName(), item, item.getProperties());
+ }
+ }
+
+ @Override
+ public PlcItem getItem(UUID itemuid) {
+ return group_items.get(itemuid);
+ }
+
+ //TODO: remove from context
+ @Override
+ public void removeItem(UUID itemuid) {
+ String filter = FILTER_ITEM.replace("*", itemuid.toString());
+ ServiceReference<?> sr = bc.getServiceReference(filter);
+ bc.ungetService(sr);
+ group_items.remove(itemuid);
+ }
+
+ @Override
+ public List<PlcItem> getItems() {
+ return group_items.values().stream().
+ collect(Collectors.toList());
+ }
+
+ @Override
+ public void execute(JobContext context) {
+ if (enable) {
+ if (null != plcConnection) {
+ if (plcConnection.get().isConnected()) {
+ watch.start();
+ executeReadAllItems();
+ watch.stop();
+ System.out.println("Elapse time: " + watch.getTime());
+ watch.reset();
+ } else {
+ LOGGER.info("The driver is disconnected.");
+ }
+ } else {
+ LOGGER.info("Unassigned connection.");
+ }
+ } else {
+ LOGGER.info("The group {}:{} is disable.",
+ ((String) myproperties.get(PlcGroup.GROUP_NAME)),
+ ((String) myproperties.get(PlcGroup.GROUP_UID)));
+ }
+ }
+
+ /*
+ * Execute the read function for all items
+ *
+ */
+ private void executeReadAllItems() {
+ //1. The item was
+ builder = plcConnection.get().readRequestBuilder();
+ group_items.forEach((u,i) ->{
+ if (i.isEnable()) {
+ builder.addTagAddress(u.toString(), i.getItemId());
+ }
+ });
+ final PlcReadRequest readRequest = builder.build();
+ try {
+ PlcReadResponse syncResponse = readRequest.execute().get();
+ group_items.forEach((u,i) -> {
+ System.out.println(i.getItemName());
+ 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);
+ });
+
+ } catch (Exception ex) {
+ LOGGER.info(ex.getMessage());
+ }
+ }
+
+ 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 boolean group_enable = false;
+ private long group_period = 100;
+ private PlcItemClientService items_service = null;
+
+ public PlcGroupBuilder(BundleContext bc, String group_name, UUID group_uid) {
+ this.bc = bc;
+ this.group_name = group_name;
+ this.group_uid = group_uid;
+ this.group_description = "";
+ }
+
+ public PlcGroupBuilder(BundleContext bc, String group_name) {
+ this.bc = bc;
+ this.group_name = group_name;
+ this.group_uid = UUID.randomUUID();
+ this.group_description = "";
+ }
+
+ public PlcGroupBuilder setGroupDescription(String group_description) {
+ this.group_description = group_description;
+ return this;
+ }
+
+ public PlcGroupBuilder setGroupUid(UUID group_uid) {
+ this.group_uid = group_uid;
+ return this;
+ }
+
+ public PlcGroupBuilder setGroupDeviceUid(UUID device_uid) {
+ this.device_uid = device_uid;
+ return this;
+ }
+
+ public PlcGroupBuilder setGroupEnable(boolean group_enable) {
+ this.group_enable = group_enable;
+ return this;
+ }
+
+ public PlcGroupBuilder setGroupPeriod(long group_period) {
+ this.group_period = group_period;
+ return this;
+ }
+
+ public PlcGroupBuilder setItemService(PlcItemClientService items_service) {
+ this.items_service = items_service;
+ return this;
+ }
+
+ public PlcGroup build() {
+ PlcGroup plcgroup = new PlcGroupImpl(this);
+ validatePlcGroupObject(plcgroup);
+ return plcgroup;
+ }
+
+ private void validatePlcGroupObject(PlcGroup plcgroup) {
+ //
+ }
+
+
+
+ }
+
+}
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
new file mode 100644
index 0000000..3383ba9
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcItemImpl.java
@@ -0,0 +1,432 @@
+/*
+ * 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
+ *
+ * https://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 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;
+import java.util.UUID;
+import java.util.concurrent.locks.ReentrantLock;
+import org.apache.commons.lang3.NotImplementedException;
+import org.apache.plc4x.java.api.messages.PlcReadResponse;
+import org.apache.plc4x.java.api.model.PlcTag;
+import org.apache.plc4x.java.api.types.PlcResponseCode;
+import org.apache.plc4x.java.api.value.PlcValue;
+import org.apache.plc4x.merlot.api.PlcItem;
+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 boolean item_enable = false;
+
+ private int item_accessrigths = 0;
+
+ private Boolean item_isarray = false;
+ private Boolean item_disableoutput = false;
+
+ private final Hashtable<String, Object> myproperties;
+
+ private PlcTag item_plctag = null;
+ private PlcValue item_plcvalue = 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 PlcReadResponse plcresponse;
+ private PlcResponseCode dataquality;
+
+ private Date lastreadtime;
+ private Date lastwritetime;
+ private Date lasterrortime;
+
+
+ public PlcItemImpl(PlcItemBuilder builder) {
+ this.myproperties = new Hashtable<>();
+
+ myproperties.put(PlcItem.ITEM_NAME, builder.item_name);
+ item_name = builder.item_name;
+
+ myproperties.put(PlcItem.ITEM_DESCRIPTION, builder.item_description);
+ item_description = builder.item_description;
+
+ myproperties.put(PlcItem.ITEM_UID, builder.item_uid.toString());
+ item_uid = builder.item_uid;
+
+ myproperties.put(PlcItem.ITEM_ID, builder.item_id);
+ item_id = builder.item_id;
+
+
+ item_enable = builder.item_enable;
+ item_accessrigths = builder.item_accessrigths;
+
+ item_isarray = builder.item_isarray;
+ item_disableoutput = builder.item_disableoutput;
+
+ item_buffer = Unpooled.buffer();
+ item_clients = new LinkedList<>();
+ }
+
+ @Override
+ public void enable() {
+ item_enable = true;
+ }
+
+ @Override
+ public void disable() {
+ item_enable = false;
+ }
+
+ @Override
+ public UUID getItemUid() {
+ return UUID.fromString((String) myproperties.get(PlcItem.ITEM_UID));
+ }
+
+ @Override
+ public String getItemName() {
+ return (String) myproperties.get(PlcItem.ITEM_NAME);
+ }
+
+ @Override
+ public void setItemName(String itemname) {
+ myproperties.put(PlcItem.ITEM_NAME, item_name);
+ }
+
+ @Override
+ public String getItemDescription() {
+ return (String) myproperties.get(PlcItem.ITEM_DESCRIPTION);
+ }
+
+ @Override
+ public void setItemDescription(String item_description) {
+ myproperties.put(PlcItem.ITEM_DESCRIPTION, item_description);
+ }
+
+ @Override
+ public String getItemId() {
+ return (String) myproperties.get(PlcItem.ITEM_ID);
+ }
+
+ @Override
+ public void setItemId(String item_id) {
+ myproperties.put(PlcItem.ITEM_ID, item_id);
+ }
+
+ @Override
+ public PlcTag getItemPlcTag() {
+ return item_plctag;
+ }
+
+ @Override
+ public void setItemPlcTag(PlcTag itemplctag) {
+ this.item_plctag = itemplctag;
+ }
+
+ @Override
+ public Boolean getEnable() {
+ return item_enable;
+ }
+
+ @Override
+ public void setEnable(Boolean enable) {
+ this.item_enable = enable;
+
+ }
+
+ @Override
+ public Boolean isEnable() {
+ return item_enable;
+ }
+
+ @Override
+ public Boolean getIsArray() {
+ return item_isarray;
+ }
+
+ @Override
+ public void setIsArray(Boolean isArray) {
+ this.item_isarray = isArray;
+ }
+
+ @Override
+ public Boolean getIsDisableOutput() {
+ return item_disableoutput;
+ }
+
+ @Override
+ public void setIsDisableOutput(Boolean item_disableoutput) {
+ this.item_disableoutput = item_disableoutput;
+ }
+
+ @Override
+ public long getItemTransmits() {
+ return itemtransmit;
+ }
+
+ @Override
+ public long getItemReceives() {
+ return itemreceives;
+ }
+
+ public long getItemErrors() {
+ return itemerrors;
+ }
+
+
+ @Override
+ public int getAccessRights() {
+ return item_accessrigths;
+ }
+
+ @Override
+ public void setAccessRights(int item_accessrigths) {
+ this.item_accessrigths = item_accessrigths;
+ }
+
+ @Override
+ public PlcResponseCode getDataQuality() {
+ return dataquality;
+ }
+
+ @Override
+ public void setPlcValue(PlcValue plcvalue) {
+
+ lock.lock();
+ try {
+ this.item_plcvalue = plcvalue;
+ item_buffer.clear();
+ switch (item_plctag.getPlcValueType()){
+ case BYTE:
+ item_plcvalue.getList().forEach(p -> {item_buffer.writeByte(p.getByte());});
+ break;
+ case CHAR:
+ case STRING:
+ plcresponse.getAllStrings(item_uid.toString()).forEach(s -> {
+ item_buffer.writeBytes(s.getBytes());
+ });
+ item_plcvalue.getList().forEach(p -> {item_buffer.writeBytes(p.getRaw());});
+ break;
+ case WORD:
+ case USINT:
+ case SINT:
+ case UINT:
+ case INT:
+ case DINT:
+ item_plcvalue.getList().forEach(p -> {item_buffer.writeShort(p.getShort());});
+ break;
+ case UDINT:
+ case ULINT:
+ case LINT:
+ item_plcvalue.getList().forEach(p -> {item_buffer.writeLong(p.getLong());});
+ break;
+ case BOOL:
+ item_plcvalue.getList().forEach(p -> {item_buffer.writeBoolean(p.getBoolean());});
+ break;
+ case REAL:
+ case LREAL:
+ item_plcvalue.getList().forEach(p -> {item_buffer.writeFloat(p.getFloat());});
+ break;
+ case DATE_AND_TIME:
+ item_plcvalue.getList().forEach(p -> {item_buffer.writeLong(p.getDateTime().toEpochSecond(ZoneOffset.UTC));});
+ break;
+ case DATE:
+ plcresponse.getAllDates(item_uid.toString()).forEach(dt -> {
+ item_buffer.writeLong(dt.toEpochDay());
+ });
+ item_plcvalue.getList().forEach(p -> {item_buffer.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));});
+ break;
+ default:
+ throw new NotImplementedException("The response type for datatype " + item_plcvalue.getPlcValueType() + " is not yet implemented");
+ }
+ } catch (Exception ex) {
+
+ } finally {
+ lock.unlock();
+ }
+ }
+
+ @Override
+ public PlcValue getItemPlcValue() {
+ lock.lock();
+ PlcValue plcvalue;
+ try {
+ plcvalue = item_plcvalue;
+ } finally {
+ lock.unlock();
+ }
+ return plcvalue;
+ }
+
+ @Override
+ public ByteBuf getItemByteBuf() {
+ lock.lock();
+ ByteBuf itembuffer;
+ try {
+ itembuffer = item_buffer.duplicate();
+ } finally {
+ lock.unlock();
+ }
+ return itembuffer;
+ }
+
+ @Override
+ public byte[] getItemBytes() {
+ lock.lock();
+ byte[] bytebuffer;
+ try {
+ bytebuffer = item_buffer.array();
+ } finally {
+ lock.unlock();
+ }
+ return bytebuffer;
+ }
+
+ @Override
+ public void setDataQuality(PlcResponseCode dataquality) {
+ this.dataquality = dataquality;
+ }
+
+ @Override
+ public void addItemClient(PlcItemListener client) {
+ if (!item_clients.contains(client)) {
+ client.atach(this);
+ item_clients.add(client);
+ }
+ }
+
+ @Override
+ public void removeItemClient(PlcItemListener client) {
+ if (!item_clients.contains(client)) {
+ item_clients.remove(client);
+ client.detach();
+ }
+ }
+
+ @Override
+ public Hashtable<String, Object> getProperties() {
+ return myproperties;
+ }
+
+ @Override
+ public Date getLastReadDate() {
+ return lastreadtime;
+ }
+
+ @Override
+ public Date getLastWriteDate() {
+ return lastwritetime;
+ }
+
+ @Override
+ public Date getLastErrorDate() {
+ return lasterrortime;
+ }
+
+ private void updateClients(){
+ item_clients.forEach(c -> c.update());
+ }
+
+ 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();
+ }
+
+ public PlcItemBuilder setItemUid(UUID item_uid) {
+ this.item_uid = item_uid;
+ return this;
+ }
+
+ public PlcItemBuilder setItemDescription(String item_description) {
+ this.item_description = item_description;
+ return this;
+ }
+
+ public PlcItemBuilder setItemId(String item_id) {
+ this.item_id = item_id;
+ return this;
+ }
+
+ public PlcItemBuilder setItemEnable(boolean item_enable) {
+ this.item_enable = item_enable;
+ return this;
+ }
+
+ public PlcItemBuilder setItemAccessrigths(int item_accessrigths) {
+ this.item_accessrigths = item_accessrigths;
+ return this;
+ }
+
+ public PlcItemBuilder setItemIsarray(Boolean item_isarray) {
+ this.item_isarray = item_isarray;
+ return this;
+ }
+
+ public PlcItemBuilder setItemDisableoutput(Boolean item_disableoutput) {
+ this.item_disableoutput = item_disableoutput;
+ return this;
+ }
+
+ public PlcItem build() {
+ PlcItem plcitem = new PlcItemImpl(this);
+ validatePlcItemObject(plcitem);
+ return plcitem;
+ }
+
+ private void validatePlcItemObject(PlcItem plcitem) {
+ //
+ }
+
+
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcOperationMetadata.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcOperationMetadata.java
new file mode 100644
index 0000000..12905a7
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcOperationMetadata.java
@@ -0,0 +1,101 @@
+/*
+ * 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
+ *
+ * https://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 java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import org.apache.plc4x.java.api.value.PlcValue;
+import org.osgi.service.dal.OperationMetadata;
+import static org.osgi.service.dal.OperationMetadata.DESCRIPTION;
+import org.osgi.service.dal.PropertyMetadata;
+
+/*
+*
+*/
+public class PlcOperationMetadata implements OperationMetadata{
+
+ private final Map<String, Object > metadata;
+
+ private PlcOperationMetadata valuemeta;
+ private final PlcPropertyMetadata[] opmetas;
+
+ public PlcOperationMetadata(PlcOperationMetaDataBuilder builder){
+ this.metadata = builder.metadata;
+ this.opmetas = builder.opmetas.toArray(new PlcPropertyMetadata[0]);
+ }
+
+ @Override
+ public Map<String, ?> getMetadata() {
+ return metadata;
+ }
+
+ @Override
+ public PropertyMetadata getReturnValueMetadata() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public PropertyMetadata[] getParametersMetadata() {
+ return opmetas;
+ }
+
+ public static class PlcOperationMetaDataBuilder {
+
+ private final Map<String, Object > metadata;
+ private final List<PlcPropertyMetadata> opmetas = new ArrayList<>();
+ private PlcPropertyMetadata valuemeta;
+
+ public PlcOperationMetaDataBuilder() {
+ metadata = new Hashtable<>();
+ }
+
+ public PlcOperationMetaDataBuilder putDescription(String desc) {
+ this.metadata.put(DESCRIPTION, desc);
+ return this;
+ }
+
+ public PlcOperationMetaDataBuilder setReturnValueMetadata(PlcPropertyMetadata opmeta) {
+ this.valuemeta = opmeta;
+ return this;
+ }
+
+ public PlcOperationMetaDataBuilder addOperationMetadata(PlcPropertyMetadata opmeta) {
+ this.opmetas.add(opmeta);
+ return this;
+ }
+
+ public PlcOperationMetaDataBuilder putMetaData(String k, Object o) {
+ this.metadata.put(k, o);
+ return this;
+ }
+
+ public PlcOperationMetadata build(){
+ PlcOperationMetadata opmeta = new PlcOperationMetadata(this);
+ validatePlcGroupObject(opmeta);
+ return opmeta;
+ }
+
+ private void validatePlcGroupObject(PlcOperationMetadata opmeta) {
+ //
+ }
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcPropertyMetadata.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcPropertyMetadata.java
new file mode 100644
index 0000000..63820a8
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcPropertyMetadata.java
@@ -0,0 +1,119 @@
+/*
+ * 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
+ *
+ * https://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 java.util.Hashtable;
+import java.util.Map;
+import org.osgi.service.dal.FunctionData;
+import org.osgi.service.dal.OperationMetadata;
+import static org.osgi.service.dal.OperationMetadata.DESCRIPTION;
+import org.osgi.service.dal.PropertyMetadata;
+import static org.osgi.service.dal.PropertyMetadata.DESCRIPTION;
+
+/*
+*
+*/
+public class PlcPropertyMetadata implements PropertyMetadata{
+
+ /**
+ * Metadata key, which value represents the property long description. The
+ * property value type is {@code java.lang.String}.
+ */
+ public static final String DESC_LONG = "long_description";
+
+ private final Map<String, Object > metadata;
+
+ public PlcPropertyMetadata(PlcPropertyMetaDataBuilder builder){
+ this.metadata = builder.metadata;
+ }
+
+ @Override
+ public Map<String, ?> getMetadata(String unit) {
+ return this.metadata;
+ }
+
+ //TODO: Here you must consult the UNS/S88 service, which deploys the management of engineering units.
+ @Override
+ public FunctionData getStep(String unit) {
+ return null;
+ }
+
+ //TODO: Here you must consult the UNS/S88 service, which deploys the management of engineering units.
+ @Override
+ public FunctionData[] getEnumValues(String unit) {
+ return null;
+ }
+
+ //TODO: Here you must consult the UNS/S88 service, which deploys the management of engineering units.
+ @Override
+ public FunctionData getMinValue(String unit) {
+ return null;
+ }
+
+ //TODO: Here you must consult the UNS/S88 service, which deploys the management of engineering units.
+ @Override
+ public FunctionData getMaxValue(String unit) {
+ return null;
+ }
+
+ public static class PlcPropertyMetaDataBuilder {
+
+ private final Map<String, Object > metadata;
+
+ public PlcPropertyMetaDataBuilder() {
+ metadata = new Hashtable<>();
+ }
+
+ public PlcPropertyMetaDataBuilder putDescription(String desc) {
+ this.metadata.put(DESCRIPTION, desc);
+ return this;
+ }
+
+ public PlcPropertyMetaDataBuilder putLongDescription(String desc) {
+ this.metadata.put(DESC_LONG, desc);
+ return this;
+ }
+
+ public PlcPropertyMetaDataBuilder putAccess(int access) {
+ this.metadata.put(ACCESS, access);
+ return this;
+ }
+
+ public PlcPropertyMetaDataBuilder putUnits(String... units) {
+ this.metadata.put(UNITS, units);
+ return this;
+ }
+
+ public PlcPropertyMetaDataBuilder putMetaData(String k, Object o) {
+ this.metadata.put(k, o);
+ return this;
+ }
+
+ public PlcPropertyMetadata build(){
+ PlcPropertyMetadata prometa = new PlcPropertyMetadata(this);
+ validatePlcGroupObject(prometa);
+ return prometa;
+ }
+
+ private void validatePlcGroupObject(PlcPropertyMetadata prometa) {
+ //
+ }
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcValueImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcValueImpl.java
new file mode 100644
index 0000000..25564a0
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcValueImpl.java
@@ -0,0 +1,361 @@
+/*
+ * 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
+ *
+ * https://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 java.math.BigDecimal;
+import java.math.BigInteger;
+import java.time.Duration;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import static java.util.stream.Collectors.toList;
+import static java.util.stream.Collectors.toMap;
+import org.apache.plc4x.java.api.types.PlcValueType;
+import org.apache.plc4x.java.api.value.PlcValue;
+import org.apache.plc4x.merlot.api.PlcGroup;
+import org.osgi.service.dal.FunctionData;
+import static org.osgi.service.dal.FunctionData.DESCRIPTION;
+import static org.osgi.service.dal.FunctionData.FIELD_TIMESTAMP;
+
+/*
+*
+*/
+public class PlcValueImpl extends FunctionData implements PlcValue {
+
+ public static final String PV = "pv";
+
+ private PlcValueType value_type;
+
+ public PlcValueImpl(PlcValueBuilder builder){
+ super(builder.timestamp, builder.metadata);
+ this.value_type = builder.value_type;
+ }
+
+ @Override
+ public PlcValueType getPlcValueType() {
+ return value_type;
+ }
+
+ @Override
+ public Object getObject() {
+ return getMetadata().get(PV);
+ }
+
+ @Override
+ public boolean isSimple() {
+ return !getMetadata().get(PV).getClass().isArray();
+ }
+
+ @Override
+ public boolean isNullable() {
+ return true;
+ }
+
+ @Override
+ public boolean isNull() {
+ return (null == getMetadata().get(PV));
+ }
+
+ @Override
+ public boolean is(Class<?> clazz) {
+ return getMetadata().get(PV).getClass().isAssignableFrom(clazz);
+ }
+
+ @Override
+ public boolean isConvertibleTo(Class<?> clazz) {
+ return getMetadata().get(PV).getClass().isAssignableFrom(clazz);
+ }
+
+ @Override
+ public <T> T get(Class<T> clazz) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isBoolean() {
+ return (getMetadata().get(PV) instanceof Boolean);
+ }
+
+ @Override
+ public boolean getBoolean() {
+ return (Boolean) getMetadata().get(PV);
+ }
+
+ @Override
+ public boolean isByte() {
+ return (getMetadata().get(PV) instanceof Byte);
+ }
+
+ @Override
+ public byte getByte() {
+ return (Byte) getMetadata().get(PV);
+ }
+
+ @Override
+ public boolean isShort() {
+ return (getMetadata().get(PV) instanceof Short);
+ }
+
+ @Override
+ public short getShort() {
+ return (Short) getMetadata().get(PV);
+ }
+
+ @Override
+ public boolean isInteger() {
+ return (getMetadata().get(PV) instanceof Integer);
+ }
+
+ @Override
+ public int getInteger() {
+ return (Integer) getMetadata().get(PV);
+ }
+
+ @Override
+ public int getInt() {
+ return (int) getMetadata().get(PV);
+ }
+
+ @Override
+ public boolean isLong() {
+ return (getMetadata().get(PV) instanceof Long);
+ }
+
+ @Override
+ public long getLong() {
+ return (Long) getMetadata().get(PV);
+ }
+
+ @Override
+ public boolean isBigInteger() {
+ return (getMetadata().get(PV) instanceof BigInteger);
+ }
+
+ @Override
+ public BigInteger getBigInteger() {
+ return (BigInteger) getMetadata().get(PV);
+ }
+
+ @Override
+ public boolean isFloat() {
+ return (getMetadata().get(PV) instanceof Float);
+ }
+
+ @Override
+ public float getFloat() {
+ return (Float) getMetadata().get(PV);
+ }
+
+ @Override
+ public boolean isDouble() {
+ return (getMetadata().get(PV) instanceof Double);
+ }
+
+ @Override
+ public double getDouble() {
+ return (Double) getMetadata().get(PV);
+ }
+
+ @Override
+ public boolean isBigDecimal() {
+ return (getMetadata().get(PV) instanceof BigDecimal);
+ }
+
+ @Override
+ public BigDecimal getBigDecimal() {
+ return (BigDecimal) getMetadata().get(PV);
+ }
+
+ @Override
+ public boolean isString() {
+ return (getMetadata().get(PV) instanceof String);
+ }
+
+ @Override
+ public String getString() {
+ return (String) getMetadata().get(PV);
+ }
+
+ @Override
+ public boolean isDuration() {
+ return (getMetadata().get(PV) instanceof Duration);
+ }
+
+ @Override
+ public Duration getDuration() {
+ return (Duration) getMetadata().get(PV);
+ }
+
+ @Override
+ public boolean isTime() {
+ return (getMetadata().get(PV) instanceof LocalTime);
+ }
+
+ @Override
+ public LocalTime getTime() {
+ return (LocalTime) getMetadata().get(PV);
+ }
+
+ @Override
+ public boolean isDate() {
+ return (getMetadata().get(PV) instanceof LocalDate);
+ }
+
+ @Override
+ public LocalDate getDate() {
+ return (LocalDate) getMetadata().get(PV);
+ }
+
+ @Override
+ public boolean isDateTime() {
+ return (getMetadata().get(PV) instanceof LocalDateTime);
+ }
+
+ @Override
+ public LocalDateTime getDateTime() {
+ return (LocalDateTime) getMetadata().get(PV);
+ }
+
+ @Override
+ public byte[] getRaw() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public boolean isList() {
+ return getMetadata().get(PV).getClass().isArray();
+ }
+
+ @Override
+ public int getLength() {
+ return getMetadata().size();
+ }
+
+ @Override
+ public PlcValue getIndex(int i) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public List<? extends PlcValue> getList() {
+ return (List<? extends PlcValue>) getMetadata().values().stream().
+ filter(o-> (o instanceof PlcValue)).
+ collect(toList());
+ }
+
+ @Override
+ public boolean isStruct() {
+ return (getMetadata().size() > 3);
+ }
+
+ @Override
+ public Set<String> getKeys() {
+ return getMetadata().keySet();
+ }
+
+ @Override
+ public boolean hasKey(String key) {
+ return getMetadata().containsKey(key);
+ }
+
+ @Override
+ public PlcValue getValue(String key) {
+ return new PlcValueImpl.
+ PlcValueBuilder().
+ putDescription(key).
+ putTimeStamp((long) getMetadata().get(FIELD_TIMESTAMP)).
+ putValueType(value_type).
+ putMetaData(key, getMetadata().get(key)).
+ build();
+ }
+
+ @Override
+ public Map<String, ? extends PlcValue> getStruct() {
+ return (Map<String,? extends PlcValue>) (List<? extends PlcValue>) getMetadata().
+ entrySet().stream().
+ filter(e -> (e.getValue() instanceof PlcValue)).
+ collect(toMap(e -> e.getKey(), e -> e.getValue()));
+ }
+
+ @Override
+ public Set<String> getMetaDataNames() {
+ throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
+ }
+
+ @Override
+ public boolean hasMetaData(String key) {
+ throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
+ }
+
+ @Override
+ public PlcValue getMetaData(String key) {
+ throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
+ }
+
+
+ public static class PlcValueBuilder {
+
+ private final Map<String, Object > metadata;
+ private long timestamp;
+ private PlcValueType value_type;
+
+ public PlcValueBuilder() {
+ metadata = new Hashtable<>();
+ }
+
+ public PlcValueBuilder putDescription(String desc) {
+ metadata.put(DESCRIPTION, desc);
+ return this;
+ }
+
+ public PlcValueBuilder putTimeStamp(long timestamp) {
+ metadata.put(FIELD_TIMESTAMP, timestamp);
+ return this;
+ }
+
+ public PlcValueBuilder putValueType(PlcValueType value_type) {
+ this.value_type = value_type;
+ return this;
+ }
+
+ public PlcValueBuilder putMetaData(String k, Object o) {
+ if (!FIELD_TIMESTAMP.equalsIgnoreCase(k) &&
+ !DESCRIPTION.equalsIgnoreCase(k)) {
+ this.metadata.put(k, o);
+ }
+ return this;
+ }
+
+ public PlcValueImpl build() {
+ PlcValueImpl plcvalue = new PlcValueImpl(this);
+ validatePlcGroupObject(plcvalue);
+ return plcvalue;
+ }
+
+ private void validatePlcGroupObject(PlcValue plcvalue) {
+ //
+ }
+
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/resources/OSGI-INF/blueprint/api-service.xml b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/resources/OSGI-INF/blueprint/api-service.xml
new file mode 100644
index 0000000..43b7ea6
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/resources/OSGI-INF/blueprint/api-service.xml
@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" default-activation="eager">
+
+ <!--
+ -->
+ <reference id="servEventAdmin"
+ interface="org.osgi.service.event.EventAdmin">
+ </reference>
+
+ <!--
+ -->
+ <reference id="servScheduler"
+ interface="org.apache.plc4x.merlot.scheduler.api.Scheduler">
+ </reference>
+
+ <!--
+ -->
+ <reference id="servPlcFunctionRef"
+ interface="org.apache.plc4x.merlot.api.PlcFunction"
+ component-name="beanPlcGeneralFunction"
+ availability="optional">
+ <reference-listener bind-method="bind" unbind-method="unbind" ref="beanPlcGeneralFunction"/>
+ </reference>
+
+ <!--
+ -->
+ <reference-list id="Plc4xDriverReference"
+ interface="org.apache.plc4x.java.api.PlcDriver"
+ availability="mandatory">
+ <reference-listener bind-method="bind" unbind-method="unbind" ref="beanPlcDriverAdmin" />
+ </reference-list>
+
+ <!--
+ -->
+ <bean id="beanPlcDriverAdmin" class="org.apache.plc4x.merlot.api.impl.PlcDriverAdminServiceImpl" scope="singleton">
+ <argument ref="blueprintBundleContext"/>
+ <argument ref="servEventAdmin"/>
+ <property name="plcDriverList" ref="Plc4xDriverReference"/>
+ </bean>
+
+ <!--
+ -->
+ <bean id="beanPlcDeviceFactory"
+ class="org.apache.plc4x.merlot.api.impl.PlcDeviceFactoryImpl"
+ scope="singleton">
+ <argument ref="blueprintBundleContext" />
+ </bean>
+
+ <!--
+ -->
+<!-- <bean id="beanPlcFunction"
+ class="org.apache.plc4x.merlot.api.impl.PlcFunctionImpl"
+ scope="singleton"
+ activation="eager">
+ <argument ref="blueprintBundleContext" />
+ </bean> -->
+
+ <!--
+ -->
+ <bean id="beanPlcManagedService"
+ class="org.apache.plc4x.merlot.api.core.PlcDeviceManagedService"
+ scope="singleton"
+ activation="eager">
+ <argument ref="blueprintBundleContext" />
+ </bean>
+
+ <!--
+ -->
+ <bean id="beanPlcItemClientService"
+ class="org.apache.plc4x.merlot.api.core.PlcItemClientService"
+ scope="singleton"
+ init-method = "init"
+ destroy-method = "destroy"
+ activation="eager">
+ <argument ref="blueprintBundleContext" />
+ </bean>
+
+ <!--
+ -->
+ <bean id="beanPlcGeneralFunction"
+ class="org.apache.plc4x.merlot.api.impl.PlcGeneralFunctionImpl"
+ scope="singleton"
+ activation="eager">
+ <argument ref="blueprintBundleContext" />
+ <argument ref="servScheduler" />
+ </bean>
+
+ <!--
+ -->
+ <service ref="beanPlcDeviceFactory" auto-export="interfaces">
+ <service-properties>
+ <entry key="org.apache.plc4x.device.factory" value="base"/>
+ </service-properties>
+ </service>
+
+ <!--
+ . Mandatory service propertye
+ SERVICE_UID = "dal.function.UID"
+
+ . Optional service propertye
+ SERVICE_TYPE = "dal.function.type"
+ SERVICE_DESCRIPTION = "dal.function.description"
+ SERVICE_OPERATION_NAMES = "dal.function.operation.names"
+ SERVICE_PROPERTY_NAMES = "dal.function.property.names"
+ SERVICE_REFERENCE_UIDS = "dal.function.reference.UIDs
+ SERVICE_DEVICE_UID = "dal.function.device.UID"
+ SERVICE_VERSION = "dal.function.version"
+ -->
+ <service id="servPlcFunction" ref="beanPlcGeneralFunction" auto-export="interfaces">
+ <service-properties>
+ <entry key="dal.function.UID">
+ <bean class="java.util.UUID" factory-method="randomUUID" />
+ </entry>
+ <entry key="dal.function.description" value="Basic operations for the base devices."/>
+ <entry key="dal.function.operation.names">
+ <array value-type="java.lang.String">
+ <value>"getPlcDrivers"</value>
+ <value>"getPlcDevices"</value>
+ <value>"getPlcDevice"</value>
+ <value>"getPlcDeviceMeta"</value>
+ <value>"setPlcDeviceName"</value>
+ <value>"setPlcDeviceDesc"</value>
+ <value>"getPlcDeviceGroups"</value>
+ <value>"getPlcGroup"</value>
+ <value>"setPlcGroupScanRate"</value>
+ <value>"getPlcGroupItemsCount"</value>
+ <value>"getPlcGroupItems"</value>
+ <value>"getPlcItem"</value>
+ <value>"getPlcItemType"</value>
+ <value>"getPlcItemValue"</value>
+ <value>"getPlcItemByteBuf"</value>
+ <value>"enable"</value>
+ <value>"disable"</value>
+ <value>"read"</value>
+ <value>"write"</value>
+ </array>
+ </entry>
+ </service-properties>
+<!-- <registration-listener ref="beanPlcFunction" registration-method="register"
+ unregistration-method="unregister" /> -->
+ </service>
+
+ <!--
+ -->
+ <service ranking="0" ref="beanPlcDriverAdmin" interface="org.apache.plc4x.merlot.api.impl.PlcDriverAdminServiceImpl">
+ <!--
+ <service-properties>
+ <entry key="DRIVER_ID" value="org.apache.plc4x.referring"/>
+ </service-properties>
+ -->
+ </service>
+
+ <!--
+ -->
+ <service ref="beanPlcManagedService" auto-export="interfaces">
+ <service-properties>
+ <entry key="service.pid" value="org.apache.plc4x.merlot.das.devices"/>
+ <entry key="scheduler.name" value="PlcDeviceManagedService"/>
+ <entry key="scheduler.period" value="5000"/>
+ <entry key="scheduler.immediate" value="true"/>
+ <entry key="scheduler.concurrent" value="false"/>
+ </service-properties>
+ </service>
+
+ <!--
+ -->
+ <service ref="beanPlcItemClientService" interface="org.apache.plc4x.merlot.api.core.PlcItemClientService">
+ </service>
+
+ <!--
+ -->
+<!-- <service ref="beanPlcGeneralService" interface="org.apache.plc4x.merlot.api.PlcGeneralService">
+ </service> -->
+
+</blueprint>
\ No newline at end of file
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/resources/OSGI-INF/bundle.info b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/resources/OSGI-INF/bundle.info
new file mode 100644
index 0000000..dd83e61
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/resources/OSGI-INF/bundle.info
@@ -0,0 +1,39 @@
+#
+#
+# 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.
+#
+#
+h1. Synopsis
+
+ ${project.name}
+
+ ${project.description}
+
+ Maven URL:
+ [mvn:${project.groupId}/${project.artifactId}/${project.version}]
+
+h1. Description
+
+ This is the common API for the entire application. Objects must implement the respective interfaces depending on their context.
+
+
+
+h1. Commands
+
+ The package has no commands.
+
+
+
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/resources/proto/das.proto b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/resources/proto/das.proto
new file mode 100644
index 0000000..896071d
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/resources/proto/das.proto
@@ -0,0 +1,31 @@
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.plc4x.merlot.api";
+option java_outer_classname = "Das";
+option objc_class_prefix = "MB";
+
+package das;
+
+//Set of services for access Device access service
+service PlcDas {
+
+ /*
+ * Obtains a list Plc4x drivers in the system.
+ * @param DasRequest It doesn't matter
+ * @return DriversInfo containing the is and description od Plc4x drivers.
+ */
+ rpc GetPlcDrivers (DasRequest) returns (DriversInfo) {};
+
+}
+
+message DasRequest {
+ string das = 1;
+}
+
+/**
+ * This is an example of a protobuf message.
+ */
+message DriversInfo {
+ map<string, string> driver = 1;
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/resources/proto/helloworld.proto b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/resources/proto/helloworld.proto
new file mode 100644
index 0000000..c585275
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/resources/proto/helloworld.proto
@@ -0,0 +1,27 @@
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.plc4x.merlot.api";
+option java_outer_classname = "HelloWorld";
+option objc_class_prefix = "HLW";
+
+package helloworld;
+
+// The greeting service definition.
+service Greeter {
+ // Sends a greeting
+ rpc SayHello (HelloRequest) returns (HelloReply) {};
+
+}
+
+// The request message containing the user's name.
+message HelloRequest {
+ string name = 1;
+}
+
+// The response message containing the greetings
+message HelloReply {
+ string message = 1;
+}
+
+
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/resources/proto/modbus.proto b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/resources/proto/modbus.proto
new file mode 100644
index 0000000..11c4c0d
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/resources/proto/modbus.proto
@@ -0,0 +1,85 @@
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.plc4x.merlot.api";
+option java_outer_classname = "Modbus";
+option objc_class_prefix = "MB";
+
+package modbus;
+
+//Set of services for access to Modbus devices from a UI user interface.
+service Plc4xModbus {
+
+ /* Obtains a list of Modbus devices created in the Merlot environment.
+ * @param ModbusId It doesn't matter
+ * @return A byte[] containing the addresses of existing devices
+ */
+ rpc GetModbusDevices (ModbusId) returns (BufferReply) {};
+
+ /* Gets the device information, UID, Description, etc.
+ * @param ModbusId Device UID
+ * @return A ModbusInfo type message
+ */
+ rpc GetModbusDevicesInfo (ModbusId) returns (ModbusInfo) {};
+
+ /* It includes the uid, the area to be accessed, the initial record,
+ * and the amount of data to be returned.
+ * @param ModbusArea Device UID, area, registar and length.
+ * @return A byte[] containing the data
+ */
+ rpc GetModbusData (ModbusArea) returns (BufferReply) {};
+
+ /* Writes a value to a register, depending on the data type.
+ * Only one value is written.
+ * @param WriteModbusRegister Device UID, area, registar and value.
+ * @return A byte[] containing the same data
+ */
+ rpc WriteModbusData (WriteModbusRegister) returns (BufferReply) {};
+
+}
+
+//Message to obtain the information of a device.
+message ModbusInfo{
+ bool enable = 1;
+ int32 uid = 2;
+ string description = 3;
+ int32 discrete_inputs = 4;
+ int32 coils = 5;
+ int32 input_register = 6;
+ int32 holding_register = 7;
+}
+
+
+//Message to indicate the Modbus device
+message ModbusId {
+ int32 uid = 1;
+}
+
+//Reply message of type byte[] buffer for data return
+message BufferReply {
+ repeated int32 data = 1;
+}
+
+//Area within the Modbus device that you want to intervene.
+message ModbusArea {
+ int32 uid = 1;
+ ModbusAreaType area = 2;
+ int32 init = 3;
+ int32 length = 4;
+}
+
+//Value to write to the Modbus device.
+message WriteModbusRegister {
+ int32 uid = 1;
+ ModbusAreaType area = 2;
+ int32 register = 3;
+ int32 value = 4;
+}
+
+//Enum for the different areas of the Modbus device.
+enum ModbusAreaType{
+ MB_DISCRETE_INPUTS = 0;
+ MB_COILS = 1;
+ MB_INPUT_REGISTER = 2;
+ MB_HOLDING_REGISTER = 3;
+}
\ No newline at end of file
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/resources/proto/ping.proto b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/resources/proto/ping.proto
new file mode 100644
index 0000000..704ac39
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/resources/proto/ping.proto
@@ -0,0 +1,21 @@
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "org.apache.plc4x.merlot.api";
+option java_outer_classname = "Ping";
+option objc_class_prefix = "MB";
+
+
+// The greeting service definition.
+service Plc4xPing {
+
+ rpc Ping (DateTime) returns (DateTime) {};
+
+}
+
+/**
+ * This is an example of a protobuf message.
+ */
+message DateTime {
+ string datetime = 1;
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/.classpath b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/.classpath
new file mode 100644
index 0000000..653dfd7
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/.classpath
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" output="target/classes" path="src/main/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="optional" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="src/test/java">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="test" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="test" value="true"/>
+ <attribute name="optional" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
+ <attributes>
+ <attribute name="maven.pomderived" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" path="target/generated-sources/annotations">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="ignore_optional_problems" value="true"/>
+ <attribute name="m2e-apt" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
+ <attributes>
+ <attribute name="optional" value="true"/>
+ <attribute name="maven.pomderived" value="true"/>
+ <attribute name="ignore_optional_problems" value="true"/>
+ <attribute name="m2e-apt" value="true"/>
+ <attribute name="test" value="true"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/.project b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/.project
new file mode 100644
index 0000000..d79062d
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.apache.plc4x.merlot.das.base-org.apache.plc4x.merlot.das.base</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.m2e.core.maven2Nature</nature>
+ </natures>
+ <filteredResources>
+ <filter>
+ <id>1711319417662</id>
+ <name></name>
+ <type>30</type>
+ <matcher>
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
+ <arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
+ </matcher>
+ </filter>
+ </filteredResources>
+</projectDescription>
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/.settings/org.eclipse.jdt.apt.core.prefs b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/.settings/org.eclipse.jdt.apt.core.prefs
new file mode 100644
index 0000000..d4313d4
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/.settings/org.eclipse.jdt.apt.core.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.apt.aptEnabled=false
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/.settings/org.eclipse.jdt.core.prefs b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..1b6e1ef
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,9 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
+org.eclipse.jdt.core.compiler.compliance=1.8
+org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
+org.eclipse.jdt.core.compiler.processAnnotations=disabled
+org.eclipse.jdt.core.compiler.release=disabled
+org.eclipse.jdt.core.compiler.source=1.8
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/.settings/org.eclipse.m2e.core.prefs b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 0000000..f897a7f
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/pom.xml b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/pom.xml
new file mode 100644
index 0000000..658e657
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/pom.xml
@@ -0,0 +1,125 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+ <!--
+ 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.
+ -->
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>merlot</artifactId>
+ <groupId>org.apache.plc4x</groupId>
+ <version>0.13.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.plc4x.merlot.das.base</groupId>
+ <artifactId>org.apache.plc4x.merlot.das.base</artifactId>
+ <version>0.13.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>PLC4J: Merlot :: das :: Base device impl</name>
+ <description>org.apache.plc4x.merlot.das.base OSGi blueprint bundle project.</description>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>5.1.8</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
+ <Bundle-Version>0.13.0-SNAPSHOT</Bundle-Version>
+ <Export-Package>org.apache.plc4x.merlot.das.base*;version=0.13.0-SNAPSHOT</Export-Package>
+ <Import-Package>*</Import-Package>
+ <Karaf-Commands>org.apache.plc4x.merlot.das.base.command*</Karaf-Commands>
+ </instructions>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.8</source>
+ <target>1.8</target>
+ <maxmem>256M</maxmem>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <phase>package</phase>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>src/main/cfg/org.apache.plc4x.merlot.das.devices.cfg</file>
+ <type>cfg</type>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.core</artifactId>
+ <version>${karaf.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.core</artifactId>
+ <version>${osgi.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.cmpn</artifactId>
+ <version>${osgi.cmpn.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.plc4x</groupId>
+ <artifactId>plc4j-api</artifactId>
+ <version>0.13.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.plc4x.merlot.scheduler</groupId>
+ <artifactId>org.apache.plc4x.merlot.scheduler</artifactId>
+ <version>0.13.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.epics</groupId>
+ <artifactId>epics-pvdata</artifactId>
+ <version>${epics.pvdata.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.plc4x.merlot.api</groupId>
+ <artifactId>org.apache.plc4x.merlot.api</artifactId>
+ <version>0.13.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/cfg/org.apache.plc4x.merlot.das.devices.cfg b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/cfg/org.apache.plc4x.merlot.das.devices.cfg
new file mode 100644
index 0000000..37b0094
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/cfg/org.apache.plc4x.merlot.das.devices.cfg
@@ -0,0 +1,50 @@
+
+################################################################################
+#
+# 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.
+#
+################################################################################
+
+################################################################################
+# Demo config file for devices.
+#
+# The configuration files have the following content:
+#
+# device=url,name,description
+#
+# where
+#
+# . device: Descriptive name within the control architecture.
+# Must be unique.
+# . url: URL as the driver is defined. It generally follows the
+# standardized pattern in the Apache PLC4X project.
+# . name: Device short name.
+# . description: Long description of the device. Such as location
+# or functionality.
+#
+# Example:
+# AS01=s7://192.168.1.23/0/2,simatic,compresor system
+#
+# Although there can be a single configuration file for all devices,
+# practice shows that it is recommended to have one configuration file
+# per device.
+#
+# Example:
+# org.apache.plc4x.merlot.das.device-AS01.cfg
+#
+################################################################################
+
+
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/api/BaseDevice.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/api/BaseDevice.java
new file mode 100644
index 0000000..a54e290
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/api/BaseDevice.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.das.base.api;
+
+import org.apache.plc4x.merlot.api.PlcDevice;
+
+public interface BaseDevice extends PlcDevice {
+
+
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/api/BaseDeviceFactory.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/api/BaseDeviceFactory.java
new file mode 100644
index 0000000..fdf80bf
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/api/BaseDeviceFactory.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.das.base.api;
+
+import org.apache.plc4x.merlot.api.PlcDeviceFactory;
+
+
+public interface BaseDeviceFactory extends PlcDeviceFactory {
+
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/api/BaseDriver.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/api/BaseDriver.java
new file mode 100644
index 0000000..4118dd9
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/api/BaseDriver.java
@@ -0,0 +1,38 @@
+/*
+ * 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.das.base.api;
+
+import java.time.LocalDateTime;
+import org.apache.plc4x.java.api.PlcConnection;
+import org.apache.plc4x.java.api.PlcDriver;
+import org.apache.plc4x.merlot.api.Driver;
+import org.osgi.framework.BundleContext;
+
+public interface BaseDriver extends Driver {
+
+ public void setBundleContext(BundleContext bundleContext);
+
+ public void setPlcDriver(PlcDriver plcDriver);
+
+ public PlcDriver getPlcDriver();
+
+ public PlcConnection getPlcConnection();
+
+
+
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/api/BaseDriverMBean.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/api/BaseDriverMBean.java
new file mode 100644
index 0000000..f22dd19
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/api/BaseDriverMBean.java
@@ -0,0 +1,62 @@
+/*
+ * 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.das.base.api;
+
+import java.time.LocalDateTime;
+
+
+public interface BaseDriverMBean {
+
+ public void init() throws Exception;
+
+ public void destroy() throws Exception;
+
+ public void start();
+
+ public void stop();
+
+ public void setUrl(String url);
+
+ public String getUrl();
+
+ public LocalDateTime getStartDateTime();
+
+ public LocalDateTime getLastFailDateTime();
+
+ public long getRunningTime();
+
+ public long getStoppedTime();
+
+ public long getSendMessages();
+
+ public long getFailedMessages();
+
+ public long getDelay();
+
+ public long getMaxDelay();
+
+ public long getMinDelay();
+
+ public long getRequestQueueSize();
+
+ public long getRequestQueueItems();
+
+ public long getResponseQueueSize();
+
+ public long getResponseQueueItems();
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/DeviceNewCommand.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/DeviceNewCommand.java
new file mode 100644
index 0000000..27d4785
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/DeviceNewCommand.java
@@ -0,0 +1,98 @@
+/*
+ * 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.das.base.command;
+
+import java.util.List;
+import java.util.UUID;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import static java.util.stream.Collectors.toList;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.plc4x.java.api.PlcDriver;
+import org.osgi.framework.BundleContext;
+import org.apache.plc4x.merlot.api.PlcDevice;
+import org.apache.plc4x.merlot.api.impl.PlcDeviceImpl;
+
+@Command(scope = "plc4x", name = "device-new", description = "Create a new device.")
+@Service
+public class DeviceNewCommand implements Action {
+ private static final Pattern p = Pattern.compile("^([a-zA-Z0-9]+)(:)(.*)");
+
+ @Reference
+ volatile List<PlcDriver> drivers;
+
+ @Reference
+ volatile List<PlcDevice> devices;
+
+ @Reference
+ BundleContext bc;
+
+ @Argument(index = 0, name = "Url", description = "URL of device", required = true, multiValued = false)
+ String url;
+
+ @Argument(index = 1, name = "Name", description = "Name of device.", required = true, multiValued = false)
+ String name;
+
+ @Argument(index = 2, name = "Description", description = "Description of device", required = true, multiValued = false)
+ String description;
+
+ @Override
+ public Object execute() throws Exception {
+ Matcher m = p.matcher(url);
+ UUID uuid = UUID.randomUUID();
+
+ m.matches();
+ String drivercode = m.group(1);
+
+ List<PlcDriver> devdrivers = drivers.stream().
+ filter(drv -> drv.getProtocolCode().equals(drivercode)).
+ collect(toList());
+
+ List<PlcDevice> ctxdevices = devices.stream().
+ filter(dev -> dev.getDeviceName().equals(name)).
+ collect(toList());
+
+ if (!ctxdevices.isEmpty()) {
+ System.out.println("A device with the same name exists.");
+ return null;
+ }
+
+ if (!devdrivers.isEmpty()) {
+
+ PlcDevice device = new PlcDeviceImpl.PlcDeviceBuilder(bc,
+ url,
+ name,
+ description).
+ build();
+
+
+ bc.registerService(PlcDevice.class.getName(), device, device.getProperties());
+
+ System.out.println("UID: " + uuid.toString());
+ } else {
+ System.out.println("Driver not found.");
+ }
+
+
+ return null;
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceDel.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceDel.java
new file mode 100644
index 0000000..b55307b
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceDel.java
@@ -0,0 +1,76 @@
+/*
+ * 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.das.base.command;
+
+import java.util.List;
+import java.util.UUID;
+import static java.util.stream.Collectors.toList;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.plc4x.java.api.PlcDriver;
+import org.osgi.framework.BundleContext;
+import org.apache.plc4x.merlot.api.PlcDevice;
+
+@Command(scope = "plc4x", name = "device-del", description = "Delete a device.")
+@Service
+public class cmdDeviceDel implements Action {
+
+ @Reference
+ volatile List<PlcDriver> drivers;
+
+ @Reference
+ volatile List<PlcDevice> devices;
+
+ @Reference
+ BundleContext bc;
+
+ @Option(name = "-n", aliases = "--name", description = "Device name.", required = false, multiValued = false)
+ String name;
+
+ @Option(name = "-i", aliases = "--uid", description = "Device identifier (UID). ", required = false, multiValued = false)
+ String uuid;
+
+
+ @Override
+ public Object execute() throws Exception {
+ List<PlcDevice> ctxdevices = null;
+
+ if (null != name) {
+ ctxdevices = devices.stream().
+ filter(dev -> dev.getDeviceName().equals(name)).
+ collect(toList());
+ } else if (null != uuid) {
+ ctxdevices = devices.stream().
+ filter(dev -> dev.getUid().equals(UUID.fromString(uuid))).
+ collect(toList());
+ }
+
+ if ((null == ctxdevices) || (ctxdevices.isEmpty())) {
+ System.out.println("A device not exists.");
+ 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/command/cmdDeviceGroupDel.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupDel.java
new file mode 100644
index 0000000..3fe5a34
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupDel.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.das.base.command;
+
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+
+@Command(scope = "plc4x", name = "group-del", description = "Delete a device.")
+@Service
+public class cmdDeviceGroupDel implements Action {
+
+ @Override
+ public Object execute() throws Exception {
+
+ return null;
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupItemDel.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupItemDel.java
new file mode 100644
index 0000000..6281c0e
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupItemDel.java
@@ -0,0 +1,22 @@
+/*
+ * 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.das.base.command;
+
+
+public class cmdDeviceGroupItemDel {
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupItemList.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupItemList.java
new file mode 100644
index 0000000..034bb36
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupItemList.java
@@ -0,0 +1,22 @@
+/*
+ * 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.das.base.command;
+
+
+public class cmdDeviceGroupItemList {
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupItemNew.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupItemNew.java
new file mode 100644
index 0000000..c20b571
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupItemNew.java
@@ -0,0 +1,22 @@
+/*
+ * 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.das.base.command;
+
+
+public class cmdDeviceGroupItemNew {
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupList.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupList.java
new file mode 100644
index 0000000..957cde5
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupList.java
@@ -0,0 +1,42 @@
+/*
+ * 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.das.base.command;
+
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.osgi.framework.BundleContext;
+
+@Command(scope = "plc4x", name = "group-list", description = "Delete a device.")
+@Service
+public class cmdDeviceGroupList implements Action {
+
+ @Reference
+ BundleContext bc;
+
+ @Option(name = "-u", aliases = "--uid", description = "Device uid.", required = true, multiValued = false)
+ String uid;
+
+ @Override
+ public Object execute() throws Exception {
+ System.out.println("");
+ return null;
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupNew.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupNew.java
new file mode 100644
index 0000000..2c7238a
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupNew.java
@@ -0,0 +1,79 @@
+/*
+ * 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.das.base.command;
+
+import java.util.Hashtable;
+import java.util.List;
+import java.util.UUID;
+import java.util.stream.Collectors;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Argument;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.plc4x.merlot.scheduler.api.Job;
+import org.osgi.framework.BundleContext;
+import org.apache.plc4x.merlot.api.PlcGroup;
+import org.apache.plc4x.merlot.api.impl.PlcGroupImpl;
+
+@Command(scope = "plc4x", name = "group-new", description = "Create group for a device.")
+@Service
+public class cmdDeviceGroupNew implements Action {
+
+ @Reference
+ BundleContext bc;
+
+ @Reference
+ volatile List<PlcGroup> groups;
+
+ @Option(name = "-u", aliases = "--uid", description = "Device uid.", required = true, multiValued = false)
+ String uid;
+
+ @Option(name = "-p", aliases = "--period", description = "Group period schedule.", required = true, multiValued = false)
+ Long period;
+
+ @Argument(index = 0, name = "Name", description = "Name of the group.", required = true, multiValued = false)
+ String name;
+
+ @Argument(index = 1, name = "Description", description = "Description of group", required = true, multiValued = false)
+ String description;
+
+ @Override
+ public Object execute() throws Exception {
+
+ List<PlcGroup> mygroups = groups.stream().
+ filter(g -> g.getGroupName().equalsIgnoreCase(name)).
+ collect(Collectors.toList());
+
+ if (mygroups.size() == 0) {
+
+
+ PlcGroup group = new PlcGroupImpl.PlcGroupBuilder(bc, name).
+ setGroupPeriod(5000).build();
+
+ bc.registerService(new String[]{Job.class.getName(), PlcGroup.class.getName()},
+ group, group.getProperties());
+
+ } else {
+ System.out.println("A group with that name already exists.");
+ }
+
+ return null;
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupSchedule.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupSchedule.java
new file mode 100644
index 0000000..d10064d
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDeviceGroupSchedule.java
@@ -0,0 +1,70 @@
+/*
+ * 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.das.base.command;
+
+import java.util.Hashtable;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.Option;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.plc4x.merlot.scheduler.api.ScheduleOptions;
+import org.apache.plc4x.merlot.scheduler.api.Scheduler;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.apache.plc4x.merlot.api.PlcChannel;
+import org.apache.plc4x.merlot.api.PlcGroup;
+
+@Command(scope = "plc4x", name = "group-rt", description = "Delete a device.")
+@Service
+public class cmdDeviceGroupSchedule implements Action {
+
+ @Reference
+ BundleContext bc;
+
+ @Reference
+ Scheduler scheduler;
+
+ @Option(name = "-u", aliases = "--uid", description = "Channel uid.", required = true, multiValued = false)
+ String uid;
+
+ @Option(name = "-s", aliases = "--scantime", description = "Channel scan time in ms.", required = true, multiValued = false)
+ Long scantime = 100L;
+
+ @Override
+ public Object execute() throws Exception {
+ Hashtable props = new Hashtable();
+ String filter = "(" + PlcGroup.GROUP_UID + "=" + uid + ")";
+ props.put(PlcGroup.GROUP_UID, uid);
+
+ ServiceReference[] services = bc.getServiceReferences(PlcGroup.class.getName(), filter);
+
+ if (services.length > 0) {
+ String[] keys = services[0].getPropertyKeys();
+
+ String jobkey = services[0].getProperty(PlcGroup.GROUP_NAME) + "." +
+ services[0].getProperty("service.id");
+ ScheduleOptions options = scheduler.NOW(-1, scantime);
+
+ scheduler.reschedule(jobkey, options);
+
+ }
+
+ return null;
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDriverList.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDriverList.java
new file mode 100644
index 0000000..ca4f7b1
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/command/cmdDriverList.java
@@ -0,0 +1,48 @@
+/*
+ * 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.das.base.command;
+
+import java.util.List;
+import java.util.regex.Pattern;
+import org.apache.karaf.shell.api.action.Action;
+import org.apache.karaf.shell.api.action.Command;
+import org.apache.karaf.shell.api.action.lifecycle.Reference;
+import org.apache.karaf.shell.api.action.lifecycle.Service;
+import org.apache.karaf.shell.support.table.ShellTable;
+import org.apache.plc4x.java.api.PlcDriver;
+import org.apache.plc4x.merlot.api.impl.PlcDriverAdminServiceImpl;
+
+//@Command(scope = "plc4x", name = "driver-list", description = "List all Plc4x drivers.")
+//@Service
+public class cmdDriverList implements Action {
+
+ @Reference
+ PlcDriverAdminServiceImpl channels;
+
+ @Override
+ public Object execute() throws Exception {
+ ShellTable table = new ShellTable();
+ table.column("Code");
+ table.column("Name");
+ List<PlcDriver> drivers = channels.getPlcDriverList();
+
+ drivers.forEach(drv -> {table.addRow().addContent(drv.getProtocolCode(), drv.getProtocolName());});
+ table.print(System.out);
+ return null;
+ }
+
+}
\ No newline at end of file
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/core/BaseDeviceManagedService.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/core/BaseDeviceManagedService.java
new file mode 100644
index 0000000..ac6941d
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/core/BaseDeviceManagedService.java
@@ -0,0 +1,184 @@
+/*
+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.das.base.core;
+
+import org.apache.plc4x.merlot.das.base.api.BaseDevice;
+import org.apache.plc4x.merlot.scheduler.api.Job;
+import org.apache.plc4x.merlot.scheduler.api.JobContext;
+import java.util.Collections;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+import org.apache.plc4x.java.api.PlcDriver;
+import org.apache.plc4x.merlot.das.base.impl.BaseDeviceFactoryImpl;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.cm.ConfigurationEvent;
+import org.osgi.service.cm.ConfigurationException;
+import org.osgi.service.cm.ConfigurationListener;
+import org.osgi.service.cm.ManagedService;
+import org.osgi.service.device.Device;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.plc4x.merlot.api.PlcDeviceFactory;
+import org.apache.plc4x.merlot.api.PlcDevice;
+/**
+ *
+ * @author cgarcia
+ */
+public class BaseDeviceManagedService implements ManagedService, ConfigurationListener, Job {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(BaseDeviceManagedService.class);
+ private final BundleContext bc;
+ private static Map<String, Dictionary<String, ?>> waitingConfigs = null;
+ private String filter_driver = "(&(" + Constants.OBJECTCLASS + "=" + PlcDriver.class.getName() + ")" +
+ "(org.apache.plc4x.driver.code=*))";
+ private String filter_device = "(&(" + Constants.OBJECTCLASS + "=" + Device.class.getName() + ")" +
+ "(" + org.apache.plc4x.merlot.api.PlcDevice.SERVICE_NAME + "=*))";
+ private String filter_factory = "(&(" + Constants.OBJECTCLASS + "=" + PlcDeviceFactory.class.getName() + ")" +
+ "(org.apache.plc4x.device.factory=*))";
+
+
+ public BaseDeviceManagedService(BundleContext bc) {
+ this.bc = bc;
+ waitingConfigs = Collections.synchronizedMap(new HashMap<String, Dictionary<String, ?>>());
+ }
+
+ public String getName() {
+ throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+ }
+
+ /*
+ * Example:
+ * AS01 = s7://192.168.1.23/0/2,simatic,compresor system
+ * \__/ \___________________/ \_____/ \______________/
+ * key url name description
+ *
+ */
+ @Override
+ public void updated(Dictionary<String, ?> props) throws ConfigurationException {
+ if (null == props) return;
+
+// if (props.size() < 3){
+// waitingConfigs.put(pid, props);
+// return;
+// }
+
+ if (props!=null) {
+ Enumeration<String> keys = props.keys();
+ for (Enumeration e = props.keys(); e.hasMoreElements();) {
+ Object key = e.nextElement();
+ String driver_information = props.get(key).toString();
+ String[] drv_data = driver_information.split(":",2);
+ if (drv_data.length == 2) {
+ try {
+ String deviceFilter = filter_device.replace("*",key.toString());
+ ServiceReference[] references = bc.getServiceReferences((String) null, deviceFilter);
+ if (references != null){
+ for (ServiceReference reference:references){
+ LOGGER.info("The device already exists: " + reference.getProperty(org.apache.plc4x.merlot.api.PlcDevice.SERVICE_NAME));
+ }
+ } else {
+ String factoryFilter = filter_factory.replace("*",drv_data[0]);
+ references = bc.getServiceReferences((String) null, factoryFilter);
+
+ if (null != references){
+ //1. Si existe el factory, existe el driver.
+ drv_data = driver_information.split(",",3);
+
+ ServiceReference reference = references[0];
+ PlcDeviceFactory bdf = (PlcDeviceFactory) bc.getService(reference);
+ if (bdf != null){
+ PlcDevice device = bdf.create(key.toString(), drv_data[0], drv_data[1], drv_data[1]);
+ if (device != null) {
+ device.enable();
+ LOGGER.info("Starting device["+ key.toString() + "] @ url[ " + drv_data[0]+ "]");
+ } else {
+ LOGGER.info("Failed to register driver." + factoryFilter);
+// waitingConfigs.put(pid, props);
+ }
+ } else {
+ LOGGER.info("The factory is not available:" + drv_data[0]);
+// waitingConfigs.put(pid, props);
+ };
+ } else {
+ LOGGER.info("There is no factory specific for the driver [{}], using base device. to register device driver.", factoryFilter);
+ //1. Si existe un driver se puede registrar el dispositivo.
+ LOGGER.info("Clave: " + key.toString() + " : " + drv_data[0]);
+
+ //2. Registra el dispositivo con un BaseDevice
+ String factoryBaseFilter = filter_factory.replace("*","base");
+ LOGGER.info("Buscando referencia con filtro [{}].", factoryBaseFilter);
+ references = bc.getServiceReferences((String) null, factoryBaseFilter);
+
+ if ((null != references) && (references.length > 0) && (!drv_data[0].equalsIgnoreCase("file"))) {
+ ServiceReference reference = references[0];
+ Hashtable properties = new Hashtable();
+ properties.putIfAbsent(org.osgi.service.device.Constants.DEVICE_CATEGORY, drv_data[0]);
+ properties.putIfAbsent(org.osgi.service.device.Constants.DEVICE_DESCRIPTION, this);
+ properties.putIfAbsent(org.osgi.service.device.Constants.DEVICE_SERIAL, this);
+ PlcDeviceFactory bdf = (PlcDeviceFactory) bc.getService(reference);
+ drv_data = driver_information.split(",",3);
+ PlcDevice device = bdf.create(key.toString() , drv_data[0], drv_data[1], drv_data[2]);
+ LOGGER.info("Registra ahora el dispositivo...");
+ bc.registerService(org.apache.plc4x.merlot.api.PlcDevice.class.getName(), device, device.getProperties());
+
+ } else {
+ LOGGER.info("The base factory is not available.");
+ }
+ }
+ }
+ } catch (InvalidSyntaxException ex) {
+ LOGGER.info("Exception: " + ex);
+ }
+ } else {
+ LOGGER.info("Key not valid: " + key.toString() + " : " + drv_data[0]);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void execute(JobContext arg0) {
+// String pid = null;
+// Dictionary<String, ?> props = null;
+// Set<String> keys = new HashSet<>();
+// keys.addAll(waitingConfigs.keySet());
+// for (String key:keys){
+// pid = key;
+// props = waitingConfigs.remove(key);
+// try {
+// updated(pid,props);
+// } catch (ConfigurationException ex) {
+// LOGGER.debug("Problem updating [" + key +"] from waiting list." );
+// }
+// }
+ }
+
+ @Override
+ public void configurationEvent(ConfigurationEvent event) {
+ LOGGER.info(">>> Cambio de configuración: " + event.getPid());
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseDeviceFactoryImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseDeviceFactoryImpl.java
new file mode 100644
index 0000000..8e2c102
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseDeviceFactoryImpl.java
@@ -0,0 +1,43 @@
+/*
+ * 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.das.base.impl;
+
+import org.apache.plc4x.merlot.das.base.api.BaseDeviceFactory;
+import org.apache.plc4x.merlot.das.base.core.BaseDeviceManagedService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.plc4x.merlot.api.PlcDevice;
+import org.apache.plc4x.merlot.api.PlcDeviceFactory;
+import org.apache.plc4x.merlot.api.impl.PlcDeviceImpl;
+import org.osgi.framework.BundleContext;
+
+public class BaseDeviceFactoryImpl implements PlcDeviceFactory {
+ private static final Logger LOGGER = LoggerFactory.getLogger(BaseDeviceFactory.class);
+
+ private final BundleContext bc;
+
+ public BaseDeviceFactoryImpl(BundleContext bc) {
+ this.bc = bc;
+ }
+
+ @Override
+ public PlcDevice create(String device, String url, String name, String description) {
+ return new PlcDeviceImpl.PlcDeviceBuilder(bc, url, name, description).build();
+
+ }
+
+}
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
new file mode 100644
index 0000000..454fb4e
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseDeviceImpl.java
@@ -0,0 +1,320 @@
+/*
+ * 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.das.base.impl;
+
+
+import java.util.HashMap;
+import org.apache.plc4x.merlot.api.Driver;
+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.merlot.api.PlcDevice;
+import org.apache.plc4x.merlot.das.base.api.BaseDevice;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.dal.Device;
+import org.osgi.service.dal.DeviceException;
+import org.osgi.service.device.Constants;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.plc4x.merlot.api.PlcItem;
+import org.apache.plc4x.merlot.api.PlcGroup;
+
+ public class BaseDeviceImpl implements PlcDevice {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(BaseDeviceImpl.class);
+ protected final BundleContext bc;
+ protected boolean enable = false;
+ protected boolean autostart = false;
+ protected UUID uid = null;
+ protected PlcDriver plcdriver = null;
+ protected String url = null;
+
+ protected Hashtable<String, Object> myProperties = new Hashtable<String, Object>();
+
+ private final Map<UUID, PlcGroup> groups = new HashMap();
+
+ public BaseDeviceImpl(BaseDeviceBuilder builder) {
+ this.bc = builder.bc;
+ myProperties.put(Device.SERVICE_DRIVER, builder.service_driver);
+ myProperties.put(Device.SERVICE_NAME, builder.service_name);
+ myProperties.put(Device.SERVICE_DESCRIPTION, builder.service_description);
+ if (null != builder.device_category) myProperties.put(Constants.DEVICE_CATEGORY, builder.device_category);
+
+ if (null != builder.service_uid) myProperties.put(Device.SERVICE_UID, builder.service_uid);
+
+ 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);
+ }
+
+ @Override
+ public void init() throws Exception {
+ //
+ }
+
+ @Override
+ public void destroy() throws Exception {
+ //
+ }
+
+
+ public void start() {
+ if (null != plcdriver) {
+ //Try to connect
+
+ //if is ok then enable
+ enable = true;
+ }
+ }
+
+
+ public void stop() {
+ enable = false;
+ //Disconect from plc.
+
+ }
+
+ @Override
+ public void enable() {
+ throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
+ }
+
+ @Override
+ public void disable() {
+ throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
+ }
+
+
+
+ @Override
+ public Hashtable<String, ?> getProperties() {
+ return myProperties;
+ }
+
+
+ @Override
+ public String getDeviceName() {
+ return (String) myProperties.get(Device.SERVICE_NAME);
+ }
+
+ @Override
+ public void setDeviceName(String devicename) {
+ myProperties.put(Device.SERVICE_NAME, devicename);
+ }
+
+ @Override
+ public String getDeviceDescription() {
+ return (String) myProperties.get(Device.SERVICE_DESCRIPTION);
+ }
+
+ @Override
+ public void setDeviceDescription(String devicedescription) {
+ myProperties.put(Device.SERVICE_DESCRIPTION, devicedescription);
+ }
+
+ @Override
+ public void setUid(UUID uid) {
+ this.uid = uid;
+ }
+
+ @Override
+ public UUID getUid() {
+ return uid;
+ }
+
+
+ @Override
+ public boolean isEnable() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void setUrl(String url) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String getUrl() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void putGroup(PlcGroup group) {
+ if (!enable) {
+ Hashtable props = new Hashtable();
+ props.put(PlcGroup.GROUP_NAME, "PRUEBA_DE_SCHEDULER");
+ props.put(PlcGroup.GROUP_UID, UUID.randomUUID().toString());
+ props.put(PlcGroup.GROUP_PERIOD, 1000L);
+ props.put(PlcGroup.GROUP_IMMEDIATE, true);
+ props.put(PlcGroup.GROUP_CONCURRENT, false);
+ groups.put(group.getGroupUid(), group);
+ }
+ }
+
+ @Override
+ public PlcGroup getGroup(UUID uid) {
+ return groups.get(uid);
+ }
+
+ @Override
+ public void removeGroup(UUID uid) {
+ groups.remove(uid);
+ }
+
+ @Override
+ public List<PlcGroup> getGroups() {
+ return null;
+ }
+
+
+ @Override
+ public void noDriverFound() {
+ LOGGER.info("The associated driver is not found. go to IDLE.");
+ }
+
+ @Override
+ public Object getServiceProperty(String propKey) {
+ return myProperties.get(propKey);
+ }
+
+ @Override
+ public String[] getServicePropertyKeys() {
+ return myProperties.keySet().toArray(new String[myProperties.size()]);
+ }
+
+ @Override
+ public void remove() throws DeviceException {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public void attach(PlcDriver driver) {
+ LOGGER.info("Device: {} attach to driver {} ", myProperties.get(Device.SERVICE_NAME), driver.getProtocolCode());
+ this.plcdriver = driver;
+ }
+
+
+ public static class BaseDeviceBuilder {
+ private final BundleContext bc;
+ private final String service_name;
+ private final String service_description;
+ private final String service_driver;
+ private String service_uid;
+ private String device_category;
+ private String service_firmware_vendor;
+ private String service_firmware_version;
+ private String service_hardware_vendor;
+ private String service_hardware_version;
+ private String service_model;
+ private String[] service_reference_uids;
+ private String service_serial_number;
+ private String service_status;
+ private String service_status_detail;
+ private String[] service_types;
+
+ public BaseDeviceBuilder(BundleContext bc, String service_driver, String service_name, String service_description) {
+ this.bc = bc;
+ this.service_name = service_name;
+ this.service_description = service_description;
+ this.service_driver = service_driver;
+ String[] drv = service_driver.split(":");
+ this.device_category = drv[0];
+ }
+
+ public BaseDeviceBuilder setServiceUid(String serviceuid) {
+ this.service_uid = serviceuid;
+ return this;
+ }
+
+ public BaseDeviceBuilder setDeviceCategory(String device_category) {
+ this.device_category = device_category;
+ return this;
+ }
+
+ public BaseDeviceBuilder setServiceFirmwareVendor(String service_firmware_vendor) {
+ this.service_firmware_vendor = service_firmware_vendor;
+ return this;
+ }
+
+ public BaseDeviceBuilder setServiceFirmwareVersion(String service_firmware_version) {
+ this.service_firmware_version = service_firmware_version;
+ return this;
+ }
+
+ public BaseDeviceBuilder setServiceHardwareVendor(String service_hardware_vendor) {
+ this.service_hardware_vendor = service_hardware_vendor;
+ return this;
+ }
+
+ public BaseDeviceBuilder setServiceHardwareVersion(String service_hardware_version) {
+ this.service_hardware_version = service_hardware_version;
+ return this;
+ }
+
+ public BaseDeviceBuilder setServiceModel(String service_model) {
+ this.service_model = service_model;
+ return this;
+ }
+
+ public BaseDeviceBuilder setServiceReferenceUids(String[] service_reference_uids) {
+ this.service_reference_uids = service_reference_uids;
+ return this;
+ }
+
+ public BaseDeviceBuilder setServiceSerialNumber(String service_serial_number) {
+ this.service_serial_number = service_serial_number;
+ return this;
+ }
+
+ public BaseDeviceBuilder setServiceStatus(String service_status) {
+ this.service_status = service_status;
+ return this;
+ }
+
+ public BaseDeviceBuilder setServiceStatusDetail(String service_status_detail) {
+ this.service_status_detail = service_status_detail;
+ return this;
+ }
+
+ public BaseDeviceBuilder setServiceTypes(String[] service_types) {
+ this.service_types = service_types;
+ return this;
+ }
+
+
+ public PlcDevice build() {
+ PlcDevice plcdevice = new BaseDeviceImpl(this);
+ validateBaseDeviceObject(plcdevice);
+ return plcdevice;
+ }
+
+ private void validateBaseDeviceObject(PlcDevice plcdevice) {
+ //
+ }
+ }
+
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseDriverMBeanImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseDriverMBeanImpl.java
new file mode 100644
index 0000000..0d75bf0
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseDriverMBeanImpl.java
@@ -0,0 +1,126 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.apache.plc4x.merlot.das.base.impl;
+
+import org.apache.plc4x.merlot.das.base.api.BaseDriver;
+import org.apache.plc4x.merlot.das.base.api.BaseDriverMBean;
+import java.time.LocalDateTime;
+import javax.management.NotCompliantMBeanException;
+import javax.management.StandardMBean;
+
+/**
+ *
+ * @author cgarcia
+ */
+public class BaseDriverMBeanImpl extends StandardMBean implements BaseDriverMBean {
+
+ private final BaseDriver driver;
+
+ public BaseDriverMBeanImpl(BaseDriver driver) throws NotCompliantMBeanException {
+ super(BaseDriverMBean.class);
+ this.driver = driver;
+ };
+
+ @Override
+ public void init() throws Exception {
+ driver.init();
+ }
+
+ @Override
+ public void destroy() throws Exception {
+ driver.destroy();
+ }
+
+ @Override
+ public void start() {
+ driver.start();
+ }
+
+ @Override
+ public void stop() {
+ driver.stop();
+ }
+
+ @Override
+ public void setUrl(String url) {
+ driver.setUrl(url);
+ }
+
+ @Override
+ public String getUrl() {
+ return driver.getUrl();
+ }
+
+ @Override
+ public LocalDateTime getStartDateTime() {
+ return driver.getStartDateTime();
+ }
+
+ @Override
+ public LocalDateTime getLastFailDateTime() {
+ return driver.getLastFailDateTime();
+ }
+
+ @Override
+ public long getRunningTime() {
+ return driver.getRunningTime();
+ }
+
+ @Override
+ public long getStoppedTime() {
+ return driver.getStoppedTime();
+ }
+
+ @Override
+ public long getSendMessages() {
+ return driver.getSendMessages();
+ }
+
+ @Override
+ public long getFailedMessages() {
+ return driver.getFailedMessages();
+ }
+
+ @Override
+ public long getDelay() {
+ return driver.getDelay();
+ }
+
+ @Override
+ public long getMaxDelay() {
+ return driver.getMaxDelay();
+ }
+
+ @Override
+ public long getMinDelay() {
+ return driver.getMinDelay();
+ }
+
+
+ @Override
+ public long getRequestQueueSize() {
+ return driver.getRequestQueueSize();
+ }
+
+ @Override
+ public long getRequestQueueItems() {
+ return driver.getRequestQueueItems();
+ }
+
+ @Override
+ public long getResponseQueueSize() {
+ return driver.getResponseQueueSize();
+ }
+
+ @Override
+ public long getResponseQueueItems() {
+ return driver.getResponseQueueItems();
+ }
+
+
+
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseFunctionImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseFunctionImpl.java
new file mode 100644
index 0000000..3bc862a
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseFunctionImpl.java
@@ -0,0 +1,78 @@
+/*
+ * 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.das.base.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.plc4x.java.api.PlcDriver;
+import org.osgi.framework.ServiceReference;
+import org.osgi.service.dal.Function;
+import org.osgi.service.dal.OperationMetadata;
+import org.osgi.service.dal.PropertyMetadata;
+import org.apache.plc4x.merlot.api.PlcDevice;
+import org.osgi.framework.BundleContext;
+
+
+public class BaseFunctionImpl implements Function {
+
+ protected final BundleContext bc;
+ private Map<String, PlcDevice> plcdevices = new HashMap<String, PlcDevice>();
+
+ public BaseFunctionImpl(BundleContext bc) {
+ this.bc = bc;
+ }
+
+ public void bind(ServiceReference reference) {
+ //
+ System.out.println("Registro dispositivo reference...");
+ }
+
+ public void bind(PlcDevice plcdevice){
+ if (null != plcdevice) {
+ System.out.println("Registro dispositivo PlcDevice...");
+ plcdevices.put(plcdevice.getUid().toString(), plcdevice);
+ }
+ }
+
+ public void unbind(ServiceReference deviceref){
+ System.out.println("DeRegistro dispositivo PlcDevice...");
+ final PlcDevice plcdevice = (PlcDevice) deviceref.getBundle();
+ plcdevices.remove(plcdevice.getUid().toString());
+ }
+
+
+ @Override
+ public PropertyMetadata getPropertyMetadata(String propertyName) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public OperationMetadata getOperationMetadata(String operationName) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public Object getServiceProperty(String propKey) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ @Override
+ public String[] getServicePropertyKeys() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+}
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseGroupImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseGroupImpl.java
new file mode 100644
index 0000000..100ec99
--- /dev/null
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.base/src/main/java/org/apache/plc4x/merlot/das/base/impl/BaseGroupImpl.java
@@ -0,0 +1,204 @@
+/*
+ * 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.das.base.impl;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.concurrent.atomic.AtomicReference;
+import org.apache.plc4x.java.api.PlcConnection;
+import org.apache.plc4x.merlot.scheduler.api.Job;
+import org.apache.plc4x.merlot.scheduler.api.JobContext;
+import org.osgi.framework.BundleContext;
+import org.apache.plc4x.merlot.api.PlcItem;
+import org.apache.plc4x.merlot.api.PlcGroup;
+
+
+public class BaseGroupImpl implements PlcGroup, Job {
+
+ private UUID uid;
+
+ private String groupname;
+ private String groupdescription;
+
+ private boolean enable = false;
+
+ private long scantime;
... 37358 lines suppressed ...