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