fix error ratio calc
This commit is contained in:
parent
744f1b2108
commit
d861fe19f2
@ -66,7 +66,7 @@ abstract public class MbusDevice {
|
||||
}
|
||||
|
||||
public double getErrorRatio() {
|
||||
return this.errorCnt / (this.successCnt + this.errorCnt);
|
||||
return (double)this.errorCnt / (double)(this.successCnt + this.errorCnt);
|
||||
}
|
||||
|
||||
public void parse(byte[] frame) throws MbusException {
|
||||
|
@ -69,7 +69,7 @@ public class MbusScheduledQuerier extends Thread {
|
||||
}
|
||||
}
|
||||
logger.info("CycleCnt: " + cnt + ", SuccessCnt: " + successCnt + ", ErrCnt: " + errCnt);
|
||||
this.queue.add(new MbusStatisticsDataObject("MbusgwChild", errCnt, successCnt));
|
||||
this.queue.add(new MbusStatisticsDataObject("MbusgwChild", errCnt, successCnt, ((double)errCnt / (double)(errCnt+successCnt))));
|
||||
try {
|
||||
Thread.sleep(5*1000);
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -6,14 +6,16 @@ public class MbusStatisticsDataObject extends ADataObject {
|
||||
private static final long serialVersionUID = 1L;
|
||||
static final String ERROR_CNT_KEY = "error";
|
||||
static final String SUCCESS_CNT_KEY = "success";
|
||||
static final String ERROR_RATIO_KEY = "errorRatio";
|
||||
static final String TABLE_NAME = "Statistics";
|
||||
static final String KIND_NAME = "Statistics";
|
||||
|
||||
public MbusStatisticsDataObject(String name, int error, int success) {
|
||||
public MbusStatisticsDataObject(String name, int error, int success, double errorRatio) {
|
||||
super(name, KIND_NAME);
|
||||
HashMap<String, Object> values = new HashMap<String, Object>();
|
||||
values.put(ERROR_CNT_KEY, error);
|
||||
values.put(SUCCESS_CNT_KEY, success);
|
||||
values.put(ERROR_RATIO_KEY, errorRatio);
|
||||
setValues(values);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user