134
-- a/c: 0, id: 1
{ addrstat = '8/4/0', addrmode = '8/5/0', addrspeed = '8/6/0', addrtemp = '8/7/0' },
-- a/c: 1, id: 2
{ addrstat = '8/4/1', addrmode = '8/5/1', addrspeed = '8/6/1', addrtemp = '8/7/1' },
}
-- read 8 bits and convert to single byte
function readbyte(offset)
local bits = mb:readdiscreteinputs(offset, 8)
local result = 0
for i = 1, 8 do
if bits[ i ] then
result = bit.lshift(1, i - 1)
end
end
return result
end
-- write single byte and convert to 8 bits
function writebyte(offset, byte)
local bits = {}
for i = 1, 8 do
table.insert(bits, bit.band(1, bit.rshift(byte, i - 1)) == 1)
end
mb:writebits(offset, unpack(bits))
end
end
-- local udp server init
if not server then
require('socket')
server = socket.udp()
server:setsockname('127.0.0.1', 28016)
server:settimeout(1)
-- remote command handler
function cmd(data)
local id, cmd, value, ac, addr, offset
-- command format id:cmd[:value]
id, cmd, value = unpack(data:split(':'))
id = tonumber(id) or 0
-- check if ac is valid
ac = aclist[ id ]
if not ac then
return
end
-- default offset
offset = (id - 1) * 152
-- on/off
if cmd == 'ON' or cmd == 'OFF' then
mb:writebits(offset, cmd == 'ON')
-- temperature settings
elseif cmd == 'TEMP' then
value = tonumber(value)
-- value ok
if value then
-- calculate register offset and write encoded value
offset = (id - 1) * 156
mb:writeregisters(offset, encodetemp(value))
end
-- operation mode
elseif cmd == 'MODE' then
value = tonumber(value)
-- verify bounds
if 0 <= value and value <= 3 then
-- convert to a/c value and write
writebyte( 8, value + 1)
end
-- fan speed
elseif cmd == 'SPEED' then
value = tonumber(value)
-- verify bounds
if 0 <= value and value <= 3 then
-- convert to a/c value and write
writebyte( 16, value + 2)
end
end
end
end
-- read current status for each a/c unit
for id, ac in ipairs(aclist) do
local stat, mode, temp, speed, offset
-- address offset
offset = (id - 1) * 152
-- on/off status
stat = mb:readdiscreteinputs(offset)
if type(stat) == 'boolean' and ac.stat ~= stat then
Summary of Contents for LogicMachine3 Re:actor
Page 10: ...10 Terminal connection schemes KNX TP...
Page 12: ...12 24V power supply...
Page 13: ...13 Analog inputs e g reed contact...
Page 14: ...14 Analog inputs 0 10V...
Page 15: ...15 Digital output...
Page 16: ...16 Resistive sensor input...
Page 17: ...17 Analog output...
Page 26: ...26 Make sure that bus status is Online press button in ETS...
Page 35: ...35 o Then minimize side bar by pressing on left arrow icon to make the map more visible...
Page 83: ...83 66 if err then 67 alert FTP upload failed s err 68 end...
Page 107: ...107...
Page 108: ...108 1 14 Help Documentation for scripting syntaxes is displayed in Help tab...
Page 126: ...126 Datapoints can be shown also in a way of table which can be later exported as CSV file...
Page 141: ...141...