From bf773fdac0b0af08fa2f6b1ee73244e2e3864a4e Mon Sep 17 00:00:00 2001 From: sbosse Date: Tue, 27 Aug 2024 00:15:26 +0200 Subject: [PATCH] Tue 27 Aug 00:14:56 CEST 2024 --- test/test-ag1.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/test-ag1.js diff --git a/test/test-ag1.js b/test/test-ag1.js new file mode 100644 index 0000000..7c250b8 --- /dev/null +++ b/test/test-ag1.js @@ -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(); +