I am trying to get imp.cancelwakeup() to let me change the sample period of a loop as shown in the following code:
`samplePeriod <- 3600.0;
t_handle <-0;
function loop()
{
t_handle = imp.wakeup(samplePeriod, loop);
}
agent.on(“period”, function (value) {
imp.cancelwakeup (t_handle);
samplePeriod = value.tofloat();
server.log(format(“new samplePeriod = %f”, samplePeriod));
});
`
if I change the sample period by sending a new value via http (say 100) I get this in the log:
new samplePeriod = 100.000000
so the new value has been received - but the previous wakeup function does not get cancelled i.e. the sample period remains until the original 3600 seconds has transpired and only then does it change to 100 seconds - I want it to change immediately. Any ideas what I am doing wrong?