Tue 27 Aug 00:14:56 CEST 2024
This commit is contained in:
		
							parent
							
								
									af363a23e6
								
							
						
					
					
						commit
						bf773fdac0
					
				
							
								
								
									
										37
									
								
								test/test-ag1.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								test/test-ag1.js
									
									
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,37 @@
 | 
			
		|||
function ac(options) {
 | 
			
		||||
  this.options=options;
 | 
			
		||||
  this.sensor=null;
 | 
			
		||||
  this.act = {
 | 
			
		||||
    start: function () {
 | 
			
		||||
      log('Starting .. '+this.options.msg)
 | 
			
		||||
    },
 | 
			
		||||
    percept: function () {
 | 
			
		||||
      rd.try(0,['SENSOR',_],function (t) {
 | 
			
		||||
        if (t) this.sensor=t[1];
 | 
			
		||||
      })
 | 
			
		||||
    },
 | 
			
		||||
    action : function () {
 | 
			
		||||
      log(this.sensor);
 | 
			
		||||
    },
 | 
			
		||||
    stop: function () {
 | 
			
		||||
      log('Terminating ..')
 | 
			
		||||
      kill()
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  this.trans = {
 | 
			
		||||
    start:"percept",
 | 
			
		||||
    percept: function () { 
 | 
			
		||||
      if (this.sensor!=null) return "action";
 | 
			
		||||
      else return "stop";
 | 
			
		||||
    },
 | 
			
		||||
    action:"stop"
 | 
			
		||||
  }
 | 
			
		||||
  this.next="start";
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
out(['SENSOR',1000])
 | 
			
		||||
var ag1 = create(ac,{msg:'with pace'},2);
 | 
			
		||||
 | 
			
		||||
start();
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user