This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

test if resident script running
#1
Hi,

It is possible to test whether a resident script is running?

Thanks,

Roger
Reply
#2
(29.03.2018, 19:42)rocfusion Wrote: Hi,

It is possible to test whether a resident script is running?

Thanks,

Roger

From the manual on the left side of Script Editor:
Code:
script.status('scriptname')
Done is better than perfect
Reply
#3
Perfect, thank you..
Reply
#4
Hi buuuudzik,
I would like to link the status of a script to an object.

So, I use status script.status('scriptname') but in order to do that I have to create another script?

status = script.status ('Sequenza Irrigazione 1')
Value = status
grp.write('32/1/3', value)

But who trigger this script? So does it become a dangerous loop?

Thanks.
Reply
#5
If you want to have such mapping better is to managing script by this object and not in other place.

So e.g. you have your script "Irrigating" and you use script.enable and script.disable only in event script for object e.g. 2/2/2 'Irrigating on/off'

You can also add something in Init script.
Done is better than perfect
Reply
#6
Code:
mintimer = 1 -- minimum timer value in seconds
maxtimer = 60 -- maximum timer value in seconds

objects = {
 {
   output = '3/6/1',
   timer = '3/6/101',
 },
 {
   output = '3/6/2',
   timer = '3/6/102',
 },
 {
   output = '3/6/3',
   timer = '3/6/103',
 },
 {
   output = '3/6/4',
   timer = '3/6/104',
 },
 {
   output = '3/6/5',
   timer = '3/6/105',
 },
 {
   output = '3/6/6',
   timer = '3/6/106',
 },
 {
   output = '3/6/7',
   timer = '3/6/107',
 },
 {
   output = '3/6/8',
   timer = '3/6/108',
 }
}

function dosleep(obj)
 local timer = grp.getvalue(obj)
 timer = tonumber(timer)

 if timer then
   if timer < mintimer then
     timer = mintimer
   elseif timer > maxtimer then
     timer = maxtimer
   end

   sleep(timer) -- conversione da secondi a minuti
 end
end

for _, item in ipairs(objects) do
 grp.write(item.output, true)
 dosleep(item.timer)
 grp.write(item.output, false)
end

Let me show you. This above is a event scheduler which run when group 3/6/201 is triggered (true or false it does not matter)

If script status group is 32/1/3 do you mean insert this below in the same script above?

status = script.status('scriptname')
value = status
grp.write(32/1/3, value)

I did that. I use this instruction at the beginning of the script and at the end. Problem is that I never received false to group 32/1/3.

I hope you understand what you mean.

Thanks.
Reply
#7
In this case actually you have object and now I see that you have some os.sleep. So you can do it like below:

Code:
scriptStatusGA = '32/1/3'

grp.checkupdate(scriptStatusGA, true)

-- YOUR SCRIPT

grp.update(scriptStatusGA, false)
Done is better than perfect
Reply
#8
Great!! Thank you very much
Reply


Forum Jump: