This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

2 byte error message
#3
It can also be done like this, but if you have several error messages the resulting string can be too large (string type is limited to 250 characters).
Code:
value = event.getvalue()

-- table key is bit number starting from 0
errors = {
  [0] = 'Stop & Go ratio ',
  [1] = 'Increased position travel ',
  [2] = 'Overload, reference position not attained ',
  [3] = 'No support at present',
  [8] = 'Connected actuator does not correspond to parameterised type',
  [9] = 'No communication possible at this address',
  [10] = 'Connected actuator signalling error, see Low-Byte',
  [11] = 'No valid Min / Max values',
  [12] = 'Non-Hall sensor motor actuators only: Actuator not yet synchronised',
  [13] = 'Test run active',
  [14] = 'Monitoring time of reference value elapsed',
}

result = {}

for i = 0, 15 do
  mask = bit.lshift(1, i)
  if bit.band(mask, value) ~= 0 then
    if errors[ i ] then
      table.insert(result, errors[ i ])
    end
  end
end

text = table.concat(result, '; ')
grp.update('1/1/1', text)

You can also make it multi-line by replacing '; ' in table.concat with '\n', but then you need some extra CSS:

Set "Additional classes" of your text object to "multiline" (without quotes) in Visualization editor.

Add to Custom CSS (Vis. graphics > Edit custom CSS)

.multiline {
white-space: pre;
text-align: left;
}
Reply


Messages In This Thread
2 byte error message - by Krstfr2k - 08.11.2017, 08:18
RE: 2 byte error message - by admin - 08.11.2017, 12:30
RE: 2 byte error message - by Krstfr2k - 08.11.2017, 14:04

Forum Jump: