Logic Machine Forum
Advice on hanging Resident script (suspect storage get/set) - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Advice on hanging Resident script (suspect storage get/set) (/showthread.php?tid=124)



Advice on hanging Resident script (suspect storage get/set) - oab_nor - 04.11.2015

Hi, i'm experiencing some kind of hang/blocking/locking when this script runs for a few days.
 
The script runs as a Resident script every minute, but suddenly it stops. I try to disable, re- enable but without any success. 
Then, when I alter the storage key ('3_3_15_vent_effect') to e.g. '3_3_15_vent_effect_1' it runs fine for some time (days?).
 
Should I safeguard the storage get/set in some way? I'm I missing something obvious here?
 
Code:
deltaThreshold = 0.015
t1 = grp.getvalue('3/3/10')
t2 = grp.getvalue('3/3/11')
t3 = grp.getvalue('3/3/14')

-- Calc. effect
effect = (t1 - t3) / (t2 - t3)

prev_effect = storage.get('3_3_15_vent_effect', 0)

effectDelta = math.abs(prev_effect - effect)

-- Write to KNX buss if Delta > Treshold
if effectDelta > deltaThreshold then
 grp.write('3/3/15', effect)
 
 -- Store Calculated effect
 storage.set('3_3_15_vent_effect', effect)  
 log("New reading - Effect prev.=" .. prev_effect .. " New = " .. effect)
end

About the script: Calculate the effect of a heat recovery unit. Input values are collected from ModBus interface on LM (no need to do a grp.read()). I don't want to flood the KNX buss by writing every calculation, therefore the delta calculation. 

Alternative approaches are welcome...


_
Ole A.


RE: Advice on hanging Resident script (suspect storage get/set) - admin - 04.11.2015

You don't need storage in a resident script like this. All variables will keep their values after each call, but will be nil on first script run, so you have to check for that. Sending a telegram once a minute is not a problem. You should use grp.update instead of grp.write if you don't need this value on KNX/TP bus.


RE: Advice on hanging Resident script (suspect storage get/set) - oab_nor - 05.11.2015

Thank you for clarifying. Didn't realize variables were persisted at this level. 
 
Needs the values on the bus, and as we know, "he" is a grumpy ~100year old man you shouldn’t nag too often Wink 

_
Ole A.


RE: Advice on hanging Resident script (suspect storage get/set) - PassivPluss - 05.11.2015

I did this another way, I also use the modbus to collect from Systemair unit as well as my 1 wire sensors in the hc unit to collect values.
I have made a script that runs on event change. That means if one of the three values are updated then the script runs. Works as a charmSmile results last 24 hours can be viewed on www.passivpluss.no Smile