~opencog-dev/embodiment-mv1.5-proxy/trunk

« back to all changes in this revision

Viewing changes to server/src/com/vettalabs/petaverse/plugins/TickTimerTask.java

  • Committer: Zhenhua Cai
  • Date: 2011-05-16 06:39:16 UTC
  • Revision ID: czhedu@gmail.com-20110516063916-bb7g0n32gn7qj680
clean up PhysiologicalModel and make it more interesting

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 * Free Software Foundation, Inc.,
21
21
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22
22
 */
23
 
 
24
 
package com.vettalabs.petaverse.plugins;
25
 
 
26
 
import java.util.TimerTask;
27
 
 
28
 
import multiverse.server.util.Log;
29
 
 
30
 
/**
31
 
 * @author Carlos Lopes
32
 
 *
33
 
 */
34
 
public class TickTimerTask extends TimerTask {
35
 
 
36
 
        /**
37
 
         * The PetaverseProxy object used to send messages.
38
 
         */
39
 
        private PetaverseProxy proxy;
40
 
        
41
 
        private long lastTime, interval;
42
 
        
43
 
        /**
44
 
         * 
45
 
         * @param proxy
46
 
         */
47
 
        public TickTimerTask(PetaverseProxy proxy, long interval) {
48
 
                super();
49
 
                this.proxy = proxy;
50
 
                this.lastTime = System.currentTimeMillis();
51
 
                this.interval = interval;
52
 
        }
53
 
        
54
 
        /**
55
 
         * 
56
 
         */
57
 
        public void run() {
58
 
                long curTime = System.currentTimeMillis();
59
 
                long elapsedTime = curTime - lastTime; 
60
 
                if (elapsedTime > (interval + 10)) {
61
 
                        if (Log.loggingDebug) Log.debug("TickTimerTask: delayed => " + elapsedTime);
62
 
                }
63
 
                lastTime = curTime;
64
 
                proxy.timeTick();
65
 
        }
66
 
 
67
 
}
 
23
 
 
24
package com.vettalabs.petaverse.plugins;
 
25
 
 
26
import java.util.TimerTask;
 
27
 
 
28
import multiverse.server.util.Log;
 
29
 
 
30
/**
 
31
 * @author Carlos Lopes
 
32
 *
 
33
 */
 
34
public class TickTimerTask extends TimerTask {
 
35
 
 
36
        /**
 
37
         * The PetaverseProxy object used to send messages.
 
38
         */
 
39
        private PetaverseProxy proxy;
 
40
        
 
41
        private long lastTime, interval;
 
42
        
 
43
        /**
 
44
         * 
 
45
         * @param proxy
 
46
         */
 
47
        public TickTimerTask(PetaverseProxy proxy, long interval) {
 
48
                super();
 
49
                this.proxy = proxy;
 
50
                this.lastTime = System.currentTimeMillis();
 
51
                this.interval = interval;
 
52
        }
 
53
        
 
54
        /**
 
55
         * 
 
56
         */
 
57
        public void run() {
 
58
                long curTime = System.currentTimeMillis();
 
59
                long elapsedTime = curTime - lastTime; 
 
60
                if (elapsedTime > (interval + 10)) {
 
61
                        if (Log.loggingDebug) Log.debug("TickTimerTask: delayed => " + elapsedTime);
 
62
                }
 
63
                lastTime = curTime;
 
64
                proxy.timeTick();
 
65
        }
 
66
 
 
67
}