From 66edbc143c492e716320320f784ca36a520e5899 Mon Sep 17 00:00:00 2001 From: YuaFox Date: Fri, 2 Aug 2024 10:20:41 +0200 Subject: [PATCH 1/5] #2974 synoptic panel state not loading correctly - Synoptic State now checks the condition when is enabled --- scadalts-ui/src/components/SynopticPanel/slts/State.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scadalts-ui/src/components/SynopticPanel/slts/State.vue b/scadalts-ui/src/components/SynopticPanel/slts/State.vue index 53d51d6455..08f450bf66 100644 --- a/scadalts-ui/src/components/SynopticPanel/slts/State.vue +++ b/scadalts-ui/src/components/SynopticPanel/slts/State.vue @@ -133,8 +133,13 @@ export default { onPointEnabledUpdate(enabled) { if(enabled) { - this.changeComponentText(`${this.componentId}_value`, this.lastValue); - this.changeComponentColor(`${this.componentId}`, this.enabledColor); + if(this.lastValue){ + this.onPointValueUpdate(this.lastValue) + }else{ + // Point does not have any data + this.changeComponentText(`${this.componentId}_value`, "N/A"); + this.changeComponentColor(`${this.componentId}`, this.enabledColor); + } } else { this.changeComponentText(`${this.componentId}_value`, "N/A"); this.changeComponentColor(`${this.componentId}`, "#d6d5d5"); From 51f1ca2ebcc471ea316e944703d09a6c5d3e1237 Mon Sep 17 00:00:00 2001 From: YuaFox Date: Wed, 21 Aug 2024 17:42:31 +0200 Subject: [PATCH 2/5] #2974 synoptic panel state not loading correctly - The api shows a datapoint is disabled if datasource is disabled --- src/org/scada_lts/web/mvc/api/PointValueAPI.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/org/scada_lts/web/mvc/api/PointValueAPI.java b/src/org/scada_lts/web/mvc/api/PointValueAPI.java index ad35df22a8..796db5f2ff 100644 --- a/src/org/scada_lts/web/mvc/api/PointValueAPI.java +++ b/src/org/scada_lts/web/mvc/api/PointValueAPI.java @@ -322,11 +322,13 @@ public class PointValueAPI { private static final Log LOG = LogFactory.getLog(PointValueAPI.class); private DataPointService dataPointService = new DataPointService(); - private DataSourceService dataSourceService = new DataSourceService(); @Resource private PointValueService pointValueService; + @Resource + private DataSourceService dataSourceService; + private String getValue(MangoValue value, String type) { if (value instanceof AlphanumericValue) { @@ -365,6 +367,11 @@ public ResponseEntity getValue(@PathVariable("xid") String xid, HttpServ if (user != null) { DataPointVO dpvo = dataPointService.getDataPoint(xid); PointValueTime pvt = pointValueService.getLatestPointValue(dpvo.getId()); + + // API should show datapoint is disabled if datasource is disabled + DataSourceVO dataSourceVO = dataSourceService.getDataSource(dpvo.getDataSourceId()); + dpvo.setEnabled(dpvo.isEnabled() && dataSourceVO.isEnabled()); + String json = null; ObjectMapper mapper = new ObjectMapper(); @@ -402,6 +409,11 @@ public ResponseEntity getValue(@PathVariable("id") int id, HttpServletRe if (user != null) { DataPointVO dpvo = dataPointService.getDataPoint(id); PointValueTime pvt = pointValueService.getLatestPointValue(dpvo.getId()); + + // API should show datapoint is disabled if datasource is disabled + DataSourceVO dataSourceVO = dataSourceService.getDataSource(dpvo.getDataSourceId()); + dpvo.setEnabled(dpvo.isEnabled() && dataSourceVO.isEnabled()); + String json = null; ObjectMapper mapper = new ObjectMapper(); From b03a676558061a645723d60f040b56900ef0e3d4 Mon Sep 17 00:00:00 2001 From: YuaFox Date: Thu, 22 Aug 2024 09:22:59 +0200 Subject: [PATCH 3/5] #2974 synoptic panel state not loading correctly - Datapoint is running moved to DataPointService --- src/org/scada_lts/mango/service/DataPointService.java | 7 ++++++- src/org/scada_lts/web/mvc/api/PointValueAPI.java | 9 ++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/org/scada_lts/mango/service/DataPointService.java b/src/org/scada_lts/mango/service/DataPointService.java index ba428095cd..3286967dec 100644 --- a/src/org/scada_lts/mango/service/DataPointService.java +++ b/src/org/scada_lts/mango/service/DataPointService.java @@ -24,6 +24,7 @@ import java.util.*; import java.util.stream.Collectors; +import com.serotonin.mango.rt.dataImage.DataPointRT; import com.serotonin.mango.rt.dataImage.SetPointSource; import com.serotonin.mango.rt.dataImage.types.MangoValue; import com.serotonin.mango.rt.event.type.AuditEventType; @@ -46,7 +47,6 @@ import org.scada_lts.dao.*; import org.scada_lts.dao.model.point.PointValue; import org.scada_lts.dao.pointhierarchy.PointHierarchyDAO; -import org.scada_lts.dao.PointLinkDAO; import org.scada_lts.dao.pointvalues.PointValueAmChartDAO; import org.scada_lts.dao.pointvalues.PointValueDAO; import org.scada_lts.dao.pointvalues.PointValueDAO4REST; @@ -681,6 +681,11 @@ public List getDataPointsByXid(Set xids) { return pointIds; } + public boolean isDataPointRunning(DataPointVO dataPoint){ + DataPointRT dp = Common.ctx.getRuntimeManager().getDataPoint(dataPoint.getId()); + return dp != null; + } + private List aggregateValuesFromRange(long startTs, long endTs, List pointIds, AggregateSettings aggregateSettings) { diff --git a/src/org/scada_lts/web/mvc/api/PointValueAPI.java b/src/org/scada_lts/web/mvc/api/PointValueAPI.java index 796db5f2ff..294986c53f 100644 --- a/src/org/scada_lts/web/mvc/api/PointValueAPI.java +++ b/src/org/scada_lts/web/mvc/api/PointValueAPI.java @@ -326,9 +326,6 @@ public class PointValueAPI { @Resource private PointValueService pointValueService; - @Resource - private DataSourceService dataSourceService; - private String getValue(MangoValue value, String type) { if (value instanceof AlphanumericValue) { @@ -369,8 +366,7 @@ public ResponseEntity getValue(@PathVariable("xid") String xid, HttpServ PointValueTime pvt = pointValueService.getLatestPointValue(dpvo.getId()); // API should show datapoint is disabled if datasource is disabled - DataSourceVO dataSourceVO = dataSourceService.getDataSource(dpvo.getDataSourceId()); - dpvo.setEnabled(dpvo.isEnabled() && dataSourceVO.isEnabled()); + dpvo.setEnabled(dataPointService.isDataPointRunning(dpvo)); String json = null; ObjectMapper mapper = new ObjectMapper(); @@ -411,8 +407,7 @@ public ResponseEntity getValue(@PathVariable("id") int id, HttpServletRe PointValueTime pvt = pointValueService.getLatestPointValue(dpvo.getId()); // API should show datapoint is disabled if datasource is disabled - DataSourceVO dataSourceVO = dataSourceService.getDataSource(dpvo.getDataSourceId()); - dpvo.setEnabled(dpvo.isEnabled() && dataSourceVO.isEnabled()); + dpvo.setEnabled(dataPointService.isDataPointRunning(dpvo)); String json = null; ObjectMapper mapper = new ObjectMapper(); From 3e08dbd5d7632db56083ca2be8f4cb0c15feacba Mon Sep 17 00:00:00 2001 From: YuaFox Date: Thu, 22 Aug 2024 12:01:10 +0200 Subject: [PATCH 4/5] #2974 synoptic panel state not loading correctly - Changed isDataPointRunning implementation --- src/org/scada_lts/mango/service/DataPointService.java | 6 ++++-- src/org/scada_lts/web/mvc/api/PointValueAPI.java | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/org/scada_lts/mango/service/DataPointService.java b/src/org/scada_lts/mango/service/DataPointService.java index 3286967dec..1fd09d744d 100644 --- a/src/org/scada_lts/mango/service/DataPointService.java +++ b/src/org/scada_lts/mango/service/DataPointService.java @@ -101,6 +101,8 @@ public class DataPointService implements MangoDataPoint { private final GetObjectsWithAccess getDataPointsWithAccess; + private final DataSourceService dataSourceService = new DataSourceService(); + public DataPointService() { this.dataPointDAO = ApplicationBeans.getBean("dataPointDAO", DataPointDAO.class); this.dataSourceDAO = ApplicationBeans.getBean("dataSourceDAO", DataSourceDAO.class); @@ -682,8 +684,8 @@ public List getDataPointsByXid(Set xids) { } public boolean isDataPointRunning(DataPointVO dataPoint){ - DataPointRT dp = Common.ctx.getRuntimeManager().getDataPoint(dataPoint.getId()); - return dp != null; + DataSourceVO dataSourceVO = dataSourceService.getDataSource(dataPoint.getDataSourceId()); + return dataPoint.isEnabled() && dataSourceVO.isEnabled(); } private List aggregateValuesFromRange(long startTs, long endTs, diff --git a/src/org/scada_lts/web/mvc/api/PointValueAPI.java b/src/org/scada_lts/web/mvc/api/PointValueAPI.java index 294986c53f..1d5b0c6e98 100644 --- a/src/org/scada_lts/web/mvc/api/PointValueAPI.java +++ b/src/org/scada_lts/web/mvc/api/PointValueAPI.java @@ -322,6 +322,7 @@ public class PointValueAPI { private static final Log LOG = LogFactory.getLog(PointValueAPI.class); private DataPointService dataPointService = new DataPointService(); + private DataSourceService dataSourceService = new DataSourceService(); @Resource private PointValueService pointValueService; From d8bad116befd545c371a1900d474495086589001 Mon Sep 17 00:00:00 2001 From: YuaFox Date: Thu, 22 Aug 2024 13:13:31 +0200 Subject: [PATCH 5/5] #2974 synoptic panel state not loading correctly - Changed DataSourceService yo DataSourceDAO --- src/org/scada_lts/mango/service/DataPointService.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/org/scada_lts/mango/service/DataPointService.java b/src/org/scada_lts/mango/service/DataPointService.java index 1fd09d744d..0e44ceb8c2 100644 --- a/src/org/scada_lts/mango/service/DataPointService.java +++ b/src/org/scada_lts/mango/service/DataPointService.java @@ -24,7 +24,6 @@ import java.util.*; import java.util.stream.Collectors; -import com.serotonin.mango.rt.dataImage.DataPointRT; import com.serotonin.mango.rt.dataImage.SetPointSource; import com.serotonin.mango.rt.dataImage.types.MangoValue; import com.serotonin.mango.rt.event.type.AuditEventType; @@ -101,8 +100,6 @@ public class DataPointService implements MangoDataPoint { private final GetObjectsWithAccess getDataPointsWithAccess; - private final DataSourceService dataSourceService = new DataSourceService(); - public DataPointService() { this.dataPointDAO = ApplicationBeans.getBean("dataPointDAO", DataPointDAO.class); this.dataSourceDAO = ApplicationBeans.getBean("dataSourceDAO", DataSourceDAO.class); @@ -684,7 +681,7 @@ public List getDataPointsByXid(Set xids) { } public boolean isDataPointRunning(DataPointVO dataPoint){ - DataSourceVO dataSourceVO = dataSourceService.getDataSource(dataPoint.getDataSourceId()); + DataSourceVO dataSourceVO = dataSourceDAO.getDataSource(dataPoint.getDataSourceId()); return dataPoint.isEnabled() && dataSourceVO.isEnabled(); }