package com.ericsson.tic.vi; import java.util.TimerTask; import java.util.Timer; /** * This thread periodically reads thru the list of data to see if any of the * timestamps are older than the time-out time and resets the data if it is so. * * @author Sami Matilainen * @version 1.0 (2008-12-04) */ public class TimeOutTimer extends TimerTask { /** * Create a TimeOutTimer */ public TimeOutTimer() { Timer t = new Timer(true); t.schedule(this, VI.timeOut/2, VI.timeOut/2); // assume timeOut is a multiple of 1000 and thus divisible by 2 } /** * Periodically read thru the list of data to see if any of the * timestamps are older than the time-out time and resets the data * if it is so. */ public void run() { if (System.currentTimeMillis() >= VI.currentTimeStamp + 250) { VI.currentTimeStamp = System.currentTimeMillis(); } for (int d = 0; d < VI.dataArr.length; d++) { int le = 1; if (VI.dataArr[d].set == Data.SET_NODES) { le = VI.nodeArr.length; } else if (VI.dataArr[d].set == Data.SET_REL) { le = VI.nodeRelArr.length; } for (int i = 0; i < le; i++) { for (int j = 0; j < VI.dataArr[d].category.cats.length; j++) { if (VI.timeOut != 0 && VI.currentTimeStamp - VI.timeOut >= VI.dataArr[d].timeStamp[i][j]) { for (int k = 0; k < VI.dataArr[d].dimension; k++) { VI.dataArr[d].value[i][j][k] = VI.defaultValue; } VI.dataArr[d].normalizeValue(i, j); } } } } } }