Logic Machine Forum
FAN SPEEDS TO TEXT - 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: FAN SPEEDS TO TEXT (/showthread.php?tid=3560)



FAN SPEEDS TO TEXT - d.r soutras - 15.09.2021

Hello guys.
I need your help.
I have a w4k and i need to convert the vrv speeds to text.
So the AUTO is 0
The LOW is 1 to 33
The MEDIUM is 34 to 67
The HIGH is 68 to 100.
The GA is 1byte unsigned integer.
The script that i want to create will have the 1 byte as an input and i will write the result in an other GA with the desired string/text.
I m attaching a photo of the visualization.    


RE: FAN SPEEDS TO TEXT - Erwin van der Zwart - 15.09.2021

Code:
textobject ='1/1/1'
speed = event.getvalue()
if speed == 0 then
  grp.checkwrite(textobject, 'Auto')
elseif speed > 0 and speed =< 33 then
  grp.checkwrite(textobject, 'Low')
elseif speed > 33 and speed <= 67 then
  grp.checkwrite(textobject, 'Medium')
elseif speed > 67 then
  grp.checkwrite(textobject, 'High')
end



RE: FAN SPEEDS TO TEXT - d.r soutras - 17.09.2021

Thank you Erwin again for your quick reply!
You are a life saver!
Your script works like a charm!!!!


RE: FAN SPEEDS TO TEXT - admin - 20.09.2021

Another option is to generate text labels via a script and use them as Custom values (enums):
Code:
text = {}

text[ 0 ] = 'Auto'

for i = 1, 33 do
  text[ i ] = 'Low'
end

for i = 34, 67 do
  text[ i ] = 'Medium'
end

for i = 68, 100 do
  text[ i ] = 'High'
end

-- must be an existing object
grp.create({
  address = '32/1/20',
  enums = text
})



RE: FAN SPEEDS TO TEXT - d.r soutras - 20.09.2021

Thank you very much admin!


RE: FAN SPEEDS TO TEXT - khalil - 27.06.2022

Hello all
How to change custom values via JS
BR,


RE: FAN SPEEDS TO TEXT - admin - 27.06.2022

Custom values can only be changed from Lua side. Visualization has to be reloaded for new value to appear. Why do you need to change these value from JS?


RE: FAN SPEEDS TO TEXT - khalil - 27.06.2022

(27.06.2022, 12:31)admin Wrote: Custom values can only be changed from Lua side. Visualization has to be reloaded for new value to appear. Why do you need to change these value from JS?

Thanks Admin
I aim to use it in this example https://forum.logicmachine.net/showthread.php?tid=4091, to change the custom value and icon via JS.
While I should create 1byte object for the custom values (auto off, auto on, manual of, manual on, overload).

then no need to write on Custom value I should write on new 1byte object