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/10/03 22:29:58 UTC
(plc4x-extras) branch feature/merlot updated: Fix store problem.
This is an automated email from the ASF dual-hosted git repository.
cgarcia pushed a commit to branch feature/merlot
in repository https://gitbox.apache.org/repos/asf/plc4x-extras.git
The following commit(s) were added to refs/heads/feature/merlot by this push:
new 20fc1fc Fix store problem.
20fc1fc is described below
commit 20fc1fc2202bf16cb87921a67e7aae6bd13e763e
Author: Cesar Garcia <ce...@ceos.com.ve>
AuthorDate: Thu Oct 3 18:28:15 2024 -0400
Fix store problem.
---
.../plc4x/merlot/api/command/DemoCommand002.java | 4 +--
.../merlot/api/impl/PlcGeneralFunctionImpl.java | 18 +++---------
.../apache/plc4x/merlot/api/impl/PlcItemImpl.java | 1 -
.../plc4x/merlot/api/impl/PlcSecureBootImpl.java | 32 +++++++++++++---------
4 files changed, 25 insertions(+), 30 deletions(-)
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand002.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand002.java
index 0ed911e..c62aa49 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand002.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/command/DemoCommand002.java
@@ -67,11 +67,11 @@ public class DemoCommand002 implements Action {
build();
d.putGroup(grupo1);
- for (int i=0; i<1; i++) {
+ for (int i=0; i<100000; i++) {
item = new PlcItemImpl.PlcItemBuilder("ITEM_00" + i).
setItemDescription("THE ITEM 00" + i).
- setItemId("RANDOM/dummy:UINT[100]").
+ setItemId("RANDOM/dummy:UINT[1000]").
setItemEnable(true).
build();
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
index 03e689a..095faf7 100644
--- 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
@@ -511,25 +511,15 @@ public class PlcGeneralFunctionImpl implements PlcGeneralFunction {
}
}
+ //TODO: Check why filter is not working with DEVICE_UID group propertie.
@Override
public Map<UUID, String> getPlcDeviceGroups(UUID device_uid) {
Map<UUID, String> plcgroups = new HashMap<>();
+ final PlcDevice dev = getPlcDevice(device_uid);
try {
- //String filter = FILTER_DEVICE_GROUP.replace("*", device_uid.toString());
- String filter = "(DEVICE_UID = " + device_uid.toString() + ")";
- ServiceReference[] refs = bc.getServiceReferences(PlcGroup.class.getName(), (String) null);
- System.out.println("X Filtro: " + filter);
- System.out.println("X Numero de referencias ");
- if (null != refs) {
- for (ServiceReference ref:refs){
- final PlcGroup group = (PlcGroup) bc.getService(ref);
- plcgroups.put(group.getGroupUid(),group.getGroupName());
- }
- System.out.println("X Salido por aqui #1");
- }
- System.out.println("X Salido por aqui #2");
- } catch (InvalidSyntaxException ex) {
+ dev.getGroups().forEach(g -> plcgroups.put(g.getGroupUid(),g.getGroupName()));
+ } catch (Exception ex) {
LOGGER.info(ex.getMessage());
} finally {
return plcgroups;
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcItemImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcItemImpl.java
index 19a802d..456e190 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcItemImpl.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcItemImpl.java
@@ -225,7 +225,6 @@ public class PlcItemImpl implements PlcItem {
public void setPlcValue(PlcValue plcvalue) {
try {
//Creates the default buffer associated with the requested data.
- System.out.println("El tipo: \r\n" + plcvalue.toString());
if (null == itemInnerBuffer) {
int size = (plcvalue instanceof PlcList) ?
((PlcList) plcvalue).getLength() *
diff --git a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcSecureBootImpl.java b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcSecureBootImpl.java
index 1e3dcf5..c0263e1 100644
--- a/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcSecureBootImpl.java
+++ b/plc4j/tools/merlot/org.apache.plc4x.merlot.das.api/src/main/java/org/apache/plc4x/merlot/api/impl/PlcSecureBootImpl.java
@@ -60,6 +60,7 @@ public class PlcSecureBootImpl implements PlcSecureBoot, Job {
+ "DeviceId TEXT,"
+ "ShortName TEXT,"
+ "Description TEXT,"
+ + "Enable TEXT,"
+ "Md5 TEXT)";
private static final String SQL_CREATE_TABLE_GROUPS =
@@ -69,8 +70,9 @@ public class PlcSecureBootImpl implements PlcSecureBoot, Job {
+ "GroupName TEXT,"
+ "GroupDescripcion TEXT,"
+ "GroupScantime TEXT,"
+ + "Enable TEXT,"
+ "Md5 TEXT)";
-
+
private static final String SQL_CREATE_TABLE_ITEMS =
"CREATE TABLE IF NOT EXISTS Items("
+ "ItemUuid TEXT NOT NULL PRIMARY KEY,"
@@ -79,6 +81,7 @@ public class PlcSecureBootImpl implements PlcSecureBoot, Job {
+ "ItemName TEXT,"
+ "ItemDescripcion TEXT,"
+ "ItemTag TEXT,"
+ + "Enable TEXT,"
+ "Md5 TEXT)";
private static final String SQL_SELECT_DEVICES =
@@ -91,8 +94,8 @@ public class PlcSecureBootImpl implements PlcSecureBoot, Job {
"SELECT * FROM WHERE GroupId = ?";
private static final String SQL_INSERT_DEVICE =
- "INSERT INTO Devices(DeviceUuId, DriverName, DeviceName, DeviceId, ShortName, Description, Md5)"
- + "VALUES(?, ?, ?, ?, ?, ?, ?) "
+ "INSERT INTO Devices(DeviceUuId, DriverName, DeviceName, DeviceId, ShortName, Description, Enable, Md5)"
+ + "VALUES(?, ?, ?, ?, ?, ?, ?, ?) "
+ "ON CONFLICT(DeviceUuId) "
+ "DO "
+ "UPDATE SET "
@@ -105,8 +108,8 @@ public class PlcSecureBootImpl implements PlcSecureBoot, Job {
private static final String SQL_INSERT_GROUP =
- "INSERT INTO Groups(GroupUuid, DeviceUuid, GroupName, GroupDescripcion, GroupScantime, Md5)"
- + "VALUES(?, ?, ?, ?, ?, ?) "
+ "INSERT INTO Groups(GroupUuid, DeviceUuid, GroupName, GroupDescripcion, GroupScantime, Enable, Md5)"
+ + "VALUES(?, ?, ?, ?, ?, ?, ?) "
+ "ON CONFLICT(GroupUuid) "
+ "DO "
+ "UPDATE SET "
@@ -118,8 +121,8 @@ public class PlcSecureBootImpl implements PlcSecureBoot, Job {
+ "Md5 = excluded.Md5;";
private static final String SQL_INSERT_ITEM =
- "INSERT INTO Items(ItemUuid, DeviceUuid, GroupUuid, ItemName, ItemDescripcion, ItemTag, Md5)"
- + "VALUES(?, ?, ?, ?, ?, ?, ?) "
+ "INSERT INTO Items(ItemUuid, DeviceUuid, GroupUuid, ItemName, ItemDescripcion, ItemTag, Enable, Md5)"
+ + "VALUES(?, ?, ?, ?, ?, ?, ?, ?) "
+ "ON CONFLICT(ItemUuid) "
+ "DO "
+ "UPDATE SET "
@@ -294,8 +297,9 @@ public class PlcSecureBootImpl implements PlcSecureBoot, Job {
query.setString(3, plcDevice.getDeviceName());
query.setString(4, plcDevice.getUid().toString());
query.setString(5, "");
- query.setString(6, plcDevice.getDeviceDescription());
- query.setString(7,"");
+ query.setString(6, plcDevice.getDeviceDescription());
+ query.setString(7, Boolean.toString(plcDevice.isEnable()));
+ query.setString(8,"");
query.executeUpdate();
}
}
@@ -307,8 +311,9 @@ public class PlcSecureBootImpl implements PlcSecureBoot, Job {
query.setString(2, plcGroup.getGroupDeviceUid().toString());
query.setString(3, plcGroup.getGroupName());
query.setString(4, plcGroup.getGroupDescription());
- query.setString(5, Long.toOctalString(plcGroup.getPeriod()));
- query.setString(6, "");
+ query.setString(5, Long.toString(plcGroup.getPeriod()));
+ query.setString(6, Boolean.toString(plcGroup.isEnable()));
+ query.setString(7, "");
query.executeUpdate();
}
}
@@ -321,8 +326,9 @@ public class PlcSecureBootImpl implements PlcSecureBoot, Job {
query.setString(3, uuidGroup);
query.setString(4, plcItem.getItemName());
query.setString(5, plcItem.getItemDescription());
- query.setString(5, plcItem.getItemId());
- query.setString(6, "");
+ query.setString(6, plcItem.getItemId());
+ query.setString(7, Boolean.toString(plcItem.isEnable()));
+ query.setString(8, "");
query.executeUpdate();
}
}