I can't see anything wrong with the above code, nor why two or more timers in the same applet isn't working for you. Can you expand and give an example where its failing?
If you are trying to wildcard match on an event you would be better off using a Filter and '*' or '>'. Lets see what you are trying to do, it might be your approach could be better optimized.
Correction I can see something wrong with what you are attempting to do.
dev = string.match(loc, "dbzoo%.hal%.Locate:*%.(%a+)") timer.dev = xap.Timer(lessen, myInt)
** timer.dev will create a variable called 'dev' in the timer table.
What you mean is :
timer[dev] = xap.Timer(lessen, myInt)
This will create a variable using the contents of DEV in the timer table.
----
If you are trying to have a TIMEOUT for each ENDPOINT you would be better of changing your design to have one REAPER function based on a timer and a TTL field that tracks for each endpoint how long its lived. This is the same design that I use for the JEENODE enpoints. See jeenode.lua#grimreaper
The bluenode.lua code also has a reaper in it you can examine.
Thanks Brett, Ill check that out. Tables, sets and arrays seem to be filled with subtle differences that provide enormous flexibility but a bit complicated to grasp.
I was in the process of creating my 'reaper' somewhat dramatically called "Destroyer" of location probablity.
I started by creating an Applet to detect from various sources and assigning a probability of 100 to that location as a level, then added the destroyer applet to start a countdown knocking off 10 each time over a few seconds.
It started to get a bit more complicated when I added a timer reset if the location was detected and the timer was running. Nevertheless this seemed to work ok until I tested being in two places at the same time. The activation of the second timer stopped the first...no matter what I tried.
Member for
15 years 7 monthsHi,I haven't used multiple
Hi,
I haven't used multiple timers myself but the weather applet that Brett wrote in the samples directory does. Here's the code snippet:
Member for
16 years 5 monthsHi Garry,Thanks, I think the
Hi Garry,
Thanks, I think the difference here is they both call different functions where mine all call the same function?
Code looks like this:
dev = string.match(loc, "dbzoo%.hal%.Locate:*%.(%a+)")
timer.dev = xap.Timer(lessen, myInt)
if pPblty == 100 and r == 0 then
timer.dev:start()
end
Member for
16 years 10 monthsI can't see anything wrong
I can't see anything wrong with the above code, nor why two or more timers in the same applet isn't working for you. Can you expand and give an example where its failing?
If you are trying to wildcard match on an event you would be better off using a Filter and '*' or '>'.
Lets see what you are trying to do, it might be your approach could be better optimized.
Brett
Member for
16 years 10 monthsCorrection I can see
Correction I can see something wrong with what you are attempting to do.
dev = string.match(loc, "dbzoo%.hal%.Locate:*%.(%a+)")
timer.dev = xap.Timer(lessen, myInt)
** timer.dev will create a variable called 'dev' in the timer table.
What you mean is :
timer[dev] = xap.Timer(lessen, myInt)
This will create a variable using the contents of DEV in the timer table.
----
If you are trying to have a TIMEOUT for each ENDPOINT you would be better of changing your design to have one REAPER function based on a timer and a TTL field that tracks for each endpoint how long its lived. This is the same design that I use for the JEENODE enpoints. See jeenode.lua#grimreaper
The bluenode.lua code also has a reaper in it you can examine.
Brett
Member for
16 years 5 monthsThanks Brett, Ill check that
Thanks Brett, Ill check that out. Tables, sets and arrays seem to be filled with subtle differences that provide enormous flexibility but a bit complicated to grasp.
I was in the process of creating my 'reaper' somewhat dramatically called "Destroyer" of location probablity.
I started by creating an Applet to detect from various sources and assigning a probability of 100 to that location as a level, then added the destroyer applet to start a countdown knocking off 10 each time over a few seconds.
It started to get a bit more complicated when I added a timer reset if the location was detected and the timer was running. Nevertheless this seemed to work ok until I tested being in two places at the same time. The activation of the second timer stopped the first...no matter what I tried.
Member for
16 years 10 monthsPerhaps by way of example
Perhaps by way of example this will be more clear:
[brett@wombat ~]$ lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> a={}
> a.dev="hello"
> =a.dev
hello
> =a['dev']
hello
> b='dev'
> =a[b]
hello
>