While Loop for reading values - 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: While Loop for reading values (/showthread.php?tid=3091) |
While Loop for reading values - tomnord - 06.01.2021 Hello. I'm writing av script to read several values from different GA and comparing all of these values to get the highest of them as an output. I can structure the GA's so that they come with increment of +1. Any tips from people who have done this before? -Regards RE: While Loop for reading values - admin - 06.01.2021 Why not use tags? You can get values for all objects with a single function call this way. While Loop for reading values - tomnord - 06.01.2021 Oh, I did not know. Could you give an example? Sent fra min SM-G980F via Tapatalk RE: While Loop for reading values - admin - 06.01.2021 Code: function tag_max(tag) RE: While Loop for reading values - tomnord - 06.01.2021 works perfekt, thank you! RE: While Loop for reading values - tomnord - 19.01.2021 Spinoff on this post. Here we use tags to calculate the max value. Is there any clever way to disregard a value if a GA is "true"? I want to check if the damper is in faultstate before running the "max"script. RE: While Loop for reading values - Daniel - 19.01.2021 This is an or gate, this https://forum.logicmachine.net/showthread.php?tid=1851&pid=11545#pid11545 or this https://forum.logicmachine.net/showthread.php?tid=291&pid=1518#pid1518 RE: While Loop for reading values - tomnord - 19.01.2021 i don't think that will work. There is one fault GA for each damper, and I only want to dismiss the value from that one damper. Is it possible to alter tags on GAs from script? RE: While Loop for reading values - admin - 19.01.2021 Do you mean that you want to check another status object before including value in the calculation? In this case you need some addressing rules so you can get status object address for another tagged object. RE: While Loop for reading values - tomnord - 19.01.2021 (19.01.2021, 13:30)admin Wrote: Do you mean that you want to check another status object before including value in the calculation? In this case you need some addressing rules so you can get status object address for another tagged object. That is correct yes. If the Fault GA is "true" then the other value should be ignored. RE: While Loop for reading values - admin - 19.01.2021 In this example each fault object has the next middle group (shift = 256, 1/1/123 => 1/2/123). Change as needed, shift can be negative. Code: function tag_max(tag, shift) RE: While Loop for reading values - tomnord - 19.01.2021 Code: input = event.getvalue() Could this have been done easier? RE: While Loop for reading values - Trond Hoyem - 25.01.2021 (19.01.2021, 15:00)tomnord Wrote: Hi Just to give my toughts.... I am doing smililar things as you describe here in many projects. What I have found to be the best way is to aloways use a very strict naming policy. By doing that I can find the address for fault (as you mention here) by replacin the code for temp with the code for fault. To find the address I need I can then do something like this; Code: adresse = string.gsub(grp.find(event.dst).name, 'TRIGGER_OUTPUT', 'TRIGGER_INPUT') Here I replace the TRIGGER_OUTPUT with TRIGGER_INPUT to find the address to forward the value to if the locking is not true. You could do the same by simply replacing 'TEMPERATURE' with 'FAULT', or whatever would be your naming policy. |