Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/#2755 signaling the data source that has a problem #2948

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e089221
#2755 Signaling the Data Source that has a problem -
Limraj Nov 6, 2023
a164318
#2755 Signaling the Data Source that has a problem - corrected signal…
Limraj Nov 6, 2023
5952f6a
#2755 Signaling the Data Source that has a problem - corrected signal…
Limraj Nov 7, 2023
2b79551
#2755 Signaling the Data Source that has a problem
Limraj Feb 1, 2024
eb8b857
Merge remote-tracking branch 'origin/release/2.7.7' into fix/#2755_Si…
Limraj Feb 5, 2024
7ced950
#2755 signaling the data source that has a problem:
Limraj Feb 9, 2024
b766789
Merge remote-tracking branch 'origin/release/2.7.7' into fix/#2755_Si…
Limraj Feb 20, 2024
3d85583
#2755 signaling the data source that has a problem:
Limraj Feb 21, 2024
baf2367
#2798 Corrected History Annotation Change Point Value By User:
Limraj Feb 21, 2024
59772a7
#2755 Signaling the data source that has a problem:
Limraj Feb 27, 2024
1f01b33
#2755 Signaling the data source that has a problem:
Limraj Feb 27, 2024
d2f79e2
#2755 Signaling the data source that has a problem:
Limraj Feb 27, 2024
d494a84
#2755 Signaling the data source that has a problem:
Limraj Feb 28, 2024
1690c7c
#2755 Signaling the data source that has a problem:
Limraj Feb 28, 2024
e5884bf
#2755 Signaling the data source that has a problem:
Limraj Feb 28, 2024
b23f320
#2755 Signaling the data source that has a problem:
Limraj Feb 21, 2024
25b7bf9
#2755 Signaling the data source that has a problem:
Limraj Feb 27, 2024
b8aaf1c
#2755 Signaling the data source that has a problem:
Limraj Feb 27, 2024
1be40ff
#2755 Signaling the data source that has a problem:
Limraj Feb 27, 2024
03eaa31
#2755 Signaling the data source that has a problem:
Limraj Feb 28, 2024
1c6aee4
#2755 Signaling the data source that has a problem:
Limraj Feb 28, 2024
aa20f4b
#2755 Signaling the data source that has a problem:
Limraj Feb 28, 2024
29d8ad4
Merge branch 'fix/#2755_Signaling_the_Data_Source_that_has_a_problem'…
Limraj Feb 28, 2024
13545b7
#2755 Signaling the data source that has a problem:
Limraj Feb 28, 2024
42b5247
#2755 Signaling the data source that has a problem:
Limraj Feb 29, 2024
2514e2e
Merge branch 'release/2.7.7' into fix/#2755_Signaling_the_Data_Source…
Limraj Feb 29, 2024
ba319da
Merge branch 'release/2.7.7' into fix/#2755_Signaling_the_Data_Source…
Limraj Feb 29, 2024
f48680a
Merge branch 'release/2.7.7.1' into fix/#2755_Signaling_the_Data_Sour…
Limraj Apr 22, 2024
5cefb6e
Merge branch 'release/2.7.7.1' into fix/#2755_Signaling_the_Data_Sour…
Limraj Apr 28, 2024
6683544
Merge remote-tracking branch 'origin/release/2.7.8' into fix/#2755_Si…
Limraj May 6, 2024
e543606
Merge remote-tracking branch 'origin/release/2.7.8' into fix/#2755_Si…
Limraj May 16, 2024
7644641
Merge branch 'release/2.7.8' into fix/#2755_Signaling_the_Data_Source…
Patrykb0802 Jul 12, 2024
692dede
#2755 Signaling the Data Source that has a problem:
Limraj Jul 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion WebContent/WEB-INF/snippet/warningContent.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<td><tag:img png="exclamation" title="common.valueUnreliable"/></td>
<td style="white-space:nowrap;" colspan="3">
<fmt:message key="common.valueUnreliable"/>
<tag:img png="arrow_refresh" title="common.refresh" onclick="WatchListDwr.forcePointRead(${point.id})" style="display:inline"/>
<tag:img png="arrow_refresh" title="common.refresh" onclick="MiscDwr.forcePointRead(${point.id})" style="display:inline"/>
</td>
</tr>
</c:if>
Expand Down
9 changes: 9 additions & 0 deletions WebContent/WEB-INF/snippet/warningIcon.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<%@ include file="/WEB-INF/snippet/common.jsp" %>
<c:choose>
<c:when test="${!empty invalid || !empty disabled || pointRT.attributes.UNRELIABLE || pointRT.attributes.DP_UPDATE_ERROR}">
<tag:img png="exclamation" title="common.valueUnreliable"/>
</c:when>
<c:otherwise>
<tag:img png="warn" title="common.warning"/>
</c:otherwise>
</c:choose>
2 changes: 1 addition & 1 deletion WebContent/WEB-INF/snippet/watchListMessages.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</c:if>
<c:if test="${pointRT.attributes.UNRELIABLE || pointRT.attributes.DP_UPDATE_ERROR}">
<tag:img png="exclamation" title="common.valueUnreliable"/> <fmt:message key="common.valueUnreliable"/>
<tag:img png="arrow_refresh" title="common.refresh" onclick="WatchListDwr.forcePointRead(${point.id})"/><br/>
<tag:img png="arrow_refresh" title="common.refresh" onclick="MiscDwr.forcePointRead(${point.id})"/><br/>
</c:if>
<c:forEach items="${events}" var="event">
<c:if test="${event.alarmLevel>0}">
Expand Down
2 changes: 1 addition & 1 deletion WebContent/WEB-INF/tags/pointComponent.tag
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<div style="position:absolute;left:-16px;top:0px;z-index:${vc.z+1};">
<div id="c${vc.id}Warning" style="display:none;" onmouseover="showMenu('c${vc.id}Messages', 16, 0);"
onmouseout="hideLayer('c${vc.id}Messages');">
<tag:img png="warn" title="common.warning"/>
<div id="c${vc.id}WarningIcon"></div>
<div id="c${vc.id}Messages" onmouseout="hideLayer(this);" class="controlContent"></div>
</div>
<div id="c${vc.id}Changing" style="display:none;"><tag:img png="icon_edit" title="common.settingValue"/></div>
Expand Down
4 changes: 4 additions & 0 deletions WebContent/resources/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ mango.view.setMessages = function(state) {
var warningNode = $("c"+ state.id +"Warning");
if (warningNode && state.messages != null) {
$set("c"+ state.id +"Messages", state.messages);
var warningIconNode = $("c"+ state.id +"WarningIcon");
if(warningIconNode) {
$set("c"+ state.id +"WarningIcon", state.warningIcon);
}
if (state.messages)
show(warningNode);
else
Expand Down
6 changes: 5 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,18 @@ test {
includeTestsMatching "com.serotonin.mango.vo.report.ImageChartUtilsTestsSuite"
includeTestsMatching "org.scada_lts.serorepl.utils.StringUtilsTestsSuite"
includeTestsMatching "org.scada_lts.monitor.ConcurrentMonitoredValuesTest"
includeTestsMatching "com.serotonin.mango.rt.dataSource.DataPointUnreliableUtilsTest"
includeTestsMatching "com.serotonin.mango.rt.dataSource.InitializeDataSourceRtTestsSuite"
includeTestsMatching "com.serotonin.mango.util.AddLimitIfWithoutSqlDataSourceUtilsTest"
includeTestsMatching "com.serotonin.mango.util.StartStopDataPointsUtilsTestsSuite"
includeTestsMatching "org.scada_lts.utils.BlockingQueuesUtilsTest"
}

failFast = true

testLogging {

//exceptionFormat = "full"
exceptionFormat = "full"
showStandardStreams = true

afterTest { desc, result ->
Expand Down
85 changes: 42 additions & 43 deletions src/br/org/scadabr/rt/dataSource/alpha2/Alpha2DataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,14 @@
import com.serotonin.mango.rt.dataImage.SetPointSource;
import com.serotonin.mango.rt.dataImage.types.MangoValue;
import com.serotonin.mango.rt.dataSource.PollingDataSource;
import com.serotonin.mango.util.LoggingUtils;
import com.serotonin.web.i18n.LocalizableMessage;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Alpha2DataSource extends PollingDataSource {

private static final Log LOG = LogFactory.getLog(Alpha2DataSource.class);
public static final int POINT_READ_EXCEPTION_EVENT = 1;
public static final int POINT_WRITE_EXCEPTION_EVENT = 2;
public static final int DATA_SOURCE_EXCEPTION_EVENT = 3;
Expand Down Expand Up @@ -65,6 +69,7 @@ protected void doPoll(long time) {
MangoValue value = MangoValue.stringToValue(deviceValue
.getValue(), rt.getDataTypeId());
rt.updatePointValue(new PointValueTime(value, time));
returnToNormal(POINT_READ_EXCEPTION_EVENT, time, rt);
}
}

Expand Down Expand Up @@ -131,18 +136,18 @@ public void setPointValue(DataPointRT dataPoint, PointValueTime valueTime,
master.runController();
else
master.stopController();
} else
} else {
master.write(devices);
} catch (Exception e) {
treatException(POINT_WRITE_EXCEPTION_EVENT, e, System
.currentTimeMillis());
returnToNormal(POINT_WRITE_EXCEPTION_EVENT, System.currentTimeMillis(), dataPoint);
}
} catch (Throwable e) {
treatException(POINT_WRITE_EXCEPTION_EVENT, e, System.currentTimeMillis(), dataPoint);
}

}

@Override
public void initialize() {
super.initialize();

SerialParameters parameters = new SerialParameters();
parameters.setBaudRate(vo.getBaudRate());
Expand All @@ -155,24 +160,33 @@ public void initialize() {
try {
master.init();
master.lineCheck();
} catch (Exception e) {
returnToNormal(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis());
} catch (Throwable e) {
treatException(DATA_SOURCE_EXCEPTION_EVENT, e, System
.currentTimeMillis());
return;
}
super.initialize();

}

@Override
public void terminate() {
super.terminate();
try {
master.terminate();
} catch (Exception e) {
e.printStackTrace();
if(master != null)
master.terminate();
returnToNormal(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis());
} catch (Throwable e) {
LOG.error(LoggingUtils.info(e, this), e);
raiseEvent(DATA_SOURCE_EXCEPTION_EVENT, System.currentTimeMillis(), true,
new LocalizableMessage("event.exception2",
vo.getName(), e.getMessage()));
}
}

private void treatException(int exceptionType, Exception e, long time) {
private void treatException(int exceptionType, Throwable e, long time) {
LOG.warn(LoggingUtils.info(e, this), e);
if (e instanceof COMMException) {
raiseEvent(exceptionType, time, true, new LocalizableMessage(
"alpha2.commException", vo.getName(), e.getMessage()));
Expand All @@ -190,37 +204,22 @@ private void treatException(int exceptionType, Exception e, long time) {
}
}

// public static void main(String[] args) {
// List<String> lista = new ArrayList<String>();
//
// for (int i = 0; i < 250; i++) {
// lista.add("device " + i);
// }
//
// final int maxNum = 82;
// List<List<String>> messages = new ArrayList<List<String>>();
//
// int numMessages = lista.size() % maxNum == 0 ? ((int) (lista.size() /
// maxNum))
// : ((int) (lista.size() / maxNum)) + 1;
//
// for (int i = 0; i < numMessages; i++) {
// List<String> temp;
// if (i == numMessages - 1) {
// temp = lista.subList(0 + (i * (maxNum)), lista.size());
// } else {
// int init = 0 + (i * (maxNum));
// int end = (maxNum) + ((maxNum) * i);
// temp = lista.subList(init, end);
//
// }
// messages.add(temp);
// }
// System.out.println("Enviar " + messages.size() + " mensagens!");
// for (List<String> list : messages) {
// System.out.println("Mensagem: " + list.size());
// }
//
// }

private void treatException(int exceptionType, Throwable e, long time, DataPointRT dataPointRT) {
LOG.warn(LoggingUtils.info(e, this), e);
if (e instanceof COMMException) {
raiseEvent(exceptionType, time, true, new LocalizableMessage(
"alpha2.commException", vo.getName(), e.getMessage()), dataPointRT);
} else if (e instanceof InvalidFrameReceivedException) {
raiseEvent(exceptionType, time, true, new LocalizableMessage(
"alpha2.invalidFrameException", vo.getName(), e
.getMessage()), dataPointRT);
} else if (e instanceof ErrorMessageReceivedException) {
raiseEvent(exceptionType, time, true, new LocalizableMessage(
"alpha2.errorMessageException", vo.getName(), e
.getMessage()), dataPointRT);
} else {
raiseEvent(exceptionType, time, true, new LocalizableMessage(
"alpha2.unknownException", vo.getName(), e.getMessage()), dataPointRT);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.serotonin.mango.util.LoggingUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Expand Down Expand Up @@ -58,19 +59,20 @@ protected void doPoll(long time) {
} catch (Exception e) {
raiseEvent(POINT_READ_EXCEPTION_EVENT, time, true,
new LocalizableMessage("event.exception2",
vo.getName(), e.getMessage()));
vo.getName(), e.getMessage()), dataPoint);
timestamp = time;
}

}

dataPoint.updatePointValue(new PointValueTime(value,
timestamp));
returnToNormal(POINT_READ_EXCEPTION_EVENT, time, dataPoint);
} catch (Exception e) {
LOG.error(LoggingUtils.info(e, this), e);
raiseEvent(POINT_READ_EXCEPTION_EVENT, time, true,
new LocalizableMessage("event.exception2", vo
.getName(), e.getMessage()));
e.printStackTrace();
.getName(), e.getMessage()), dataPoint);
}

}
Expand Down Expand Up @@ -143,7 +145,7 @@ private String readFile(File file) {
} while (c != -1);
reader.close();
} catch (Exception e) {
e.printStackTrace();
LOG.error(LoggingUtils.info(e, this), e);
}
return sb.toString();
}
Expand Down
Loading
Loading