Logic Machine Forum
2 byte error message - 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: 2 byte error message (/showthread.php?tid=1081)



2 byte error message - Krstfr2k - 08.11.2017

Hello (again)!

I have a UK24EIB Gateway which has a 2byte error message for each MP-Address.

Error codes for High-Byte: 
0b0000’0000 = No error present 
0b0000’0001 = Connected actuator does not correspond to parameterised type 
0b0000’0010 = No communication possible at this address 
0b0000’0100 = Connected actuator signalling error, see Low-Byte 
0b0000’1000 = No valid Min / Max values 
0b0001’0000 = Non-Hall sensor motor actuators only: Actuator not yet synchronised 
0b0010’0000 = Test run active 
0b0100’0000 = Monitoring time of reference value elapsed 
0b1000’0000 = Not used Several errors can be present together, OR-gated bitwise 

Error codes for Low-Byte: 
0b0000’0000 = No error present 
0b0000’0001 = Stop & Go ratio 
0b0000’0010 = Increased position travel 
0b0000’0100 = Overload, reference position not attained 
0b0000’1000 = No support at present 

The first 4 Bits are always 0. Several errors can be present together, OR-gated bitwise


Is there a way to present these values in visualization?


RE: 2 byte error message - Erwin van der Zwart - 08.11.2017

Hi,

Use function getbit() from this post:

https://forum.logicmachine.net/showthread.php?tid=522&pid=2850#pid2850

BR,

Erwin


RE: 2 byte error message - admin - 08.11.2017

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;
}


RE: 2 byte error message - Krstfr2k - 08.11.2017

Thank you so much for the help, exactly what I was looking for!