Get object name - 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: Get object name (/showthread.php?tid=3403) |
Get object name - tomnord - 04.06.2021 Hi. When using a event based script, I want to use event.getvalue() to read the actual value, but I also want to read the object name that triggers the script. I will use this name to read other GA's using grp.find(). Code: pseudo: RE: Get object name - admin - 04.06.2021 Like this: Code: name = grp.find(event.dst).name RE: Get object name - tomnord - 04.06.2021 (04.06.2021, 08:42)admin Wrote: Like this: Thank you. Any quick tip on how to replace characteres in a string? eg: "AA2233_PV" needs to be changed to "AA2233_Alarm" Found a way, string.gsub() How will the os.sleep() work in a event script? if timer is started, will it be reset on next event change? or will the script pause untill the first sleep command is finished? RE: Get object name - admin - 04.06.2021 Each event script instance is completely separate from others. So if you have sleep calls there it's possible to have multiple instances running in parallel which can lead to unwanted behavior. What kind of script are you creating? Maybe there's a better solution but you need to give a more detailed explanation. RE: Get object name - tomnord - 04.06.2021 Ah, I'm trying to make a script that uses a temperature value and checks if this value is under or over a setpoint that is read from another GA. If over or under then set alarm GA to true. else false. And I want a delay on sending that is adjustable so that any minor fluctuations are eliminated. my code so far: Code: value = event.getvalue() The thing is, that I have 2-300 values to check ? RE: Get object name - admin - 04.06.2021 For multiple objects you can use a tag. This way you can use a single script for all objects. Using os.sleep in this case won't harm but it's possible to overload the system by having a lot of event script processes. The more correct approach is to have an event script that sets/resets the last time that alarm was triggered (via storage) and a resident script which checks if the alarm has been set for a certain period then writes the alarm value to an object. RE: Get object name - tomnord - 04.06.2021 (04.06.2021, 12:42)admin Wrote: For multiple objects you can use a tag. This way you can use a single script for all objects. Could you give a pseudo example to set me off in the right direction? RE: Get object name - admin - 04.06.2021 Event script (attached to a tag): Code: value = event.getvalue() Resident script. Adjust the sleep time as needed (at least 5 seconds) depending on the average delay between objects value being detected as out of bounds and the alarm object change to 1. Code: if not check then |