visual_object_array_tip
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
visual_object_array_tip [2021/07/22 12:50] – emozolyak | visual_object_array_tip [2021/07/22 14:32] – [The solution] emozolyak | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Object array visualization tip ====== | ====== Object array visualization tip ====== | ||
- | There is a limit in the dashboard object size due to certain performance issues. Sometimes users need a very big and rich dasboard visualization, | + | There is a limit in the dashboard object size due to certain performance issues |
In this cases, some optimization trick maybe used. | In this cases, some optimization trick maybe used. | ||
Line 19: | Line 19: | ||
The solution was to pack all the elements into one string object, with each character reflecting the state of the respective process object. | The solution was to pack all the elements into one string object, with each character reflecting the state of the respective process object. | ||
+ | The idea is shown on the following gif images: | ||
+ | {{ : | ||
+ | {{ :: | ||
+ | |||
+ | == The code which makes the trick == | ||
+ | |||
+ | <code lua> | ||
+ | TRUE_SYMBOL = ' | ||
+ | FALSE_SYMBOL = ' | ||
+ | NUMBER_OF_SPACES = 2 | ||
+ | |||
+ | function main (userId) | ||
+ | | ||
+ | local bit_mask = R(" | ||
+ | local t = {} | ||
+ | |||
+ | for b = 8, 1, -1 do | ||
+ | local symbol = hasbit(bit_mask, | ||
+ | table.insert(t, | ||
+ | | ||
+ | |||
+ | local out = table.concat(t, | ||
+ | |||
+ | | ||
+ | end | ||
+ | |||
+ | -- HELPERS -- | ||
+ | function bw(n) | ||
+ | return 2 ^ (n - 1) -- returns weight of the bit in pos. n | ||
+ | end | ||
+ | |||
+ | function hasbit(x, b) | ||
+ | local p = bw(b) | ||
+ | return x % (p + p) >= p -- returns if b is true/false; if hasbit(value, | ||
+ | end | ||
+ | |||
+ | function U(reg, new_value) | ||
+ | local cur_value = R(reg) | ||
+ | if cur_value and new_value and (cur_value ~= new_value) then | ||
+ | WriteReg(reg, | ||
+ | end | ||
+ | end | ||
+ | |||
+ | </ | ||
+ | |||
+ | Using the font size and spacing adjusment in the lua script you can get necessary dimensions of this object. | ||
visual_object_array_tip.txt · Last modified: 2022/01/16 15:14 by 127.0.0.1