Add new logic block which will replace the current one

This commit is contained in:
Joachim Stolberg 2021-02-22 20:35:22 +01:00
parent 3aed046eb7
commit e82c621f5c
12 changed files with 517 additions and 66 deletions

View File

@ -89,3 +89,17 @@ techage.register_node({"default:furnace", "default:furnace_active"}, {
return techage.put_items(inv, "dst", stack)
end,
})
techage.register_node({"mobs:beehive"}, {
on_pull_item = function(pos, in_dir, num)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return techage.get_items(pos, inv, "beehive", num)
end,
on_unpull_item = function(pos, in_dir, stack)
local meta = minetest.get_meta(pos)
local inv = meta:get_inventory()
return techage.put_items(inv, "beehive", stack)
end,
})

View File

@ -62,7 +62,7 @@ end
function techage.liquid.is_empty(pos)
local nvm = techage.get_nvm(pos)
return not nvm.liquid or (nvm.liquid.amount or 0) == 0
return not nvm.liquid or (nvm.liquid.amount or 0) <= 0
end
techage.liquid.recv_message = {

View File

@ -907,32 +907,43 @@ techage.manual_DE.aText = {
"\n"..
"\n"..
"\n",
"Den TA3 Logikblock kann man so programmieren\\, dass ein oder mehrere Eingangssignale zu einem Ausgangssignal verknüpft und gesendet werden. Dieser Block kann daher diverse Logik-Elemente wie AND\\, OR\\, NOT\\, XOR usw. ersetzen.\n"..
"Eingangssignale für den Logikblock sind 'on'/'off' Kommandos. Ein 'on' ist ein logisches 'true'\\, ein 'off' entspricht dem 'false'.\n"..
"Eingangssignale werden über die Nummer referenziert\\, also bspw. 'n123' für das Signal vom Sender mit der Nummer 123.\n"..
"Den TA3 Logikblock kann man so programmieren\\, dass ein oder mehrere Eingangskommandos zu einem Ausgangskommando verknüpft und gesendet werden. Dieser Block kann daher diverse Logik-Elemente wie AND\\, OR\\, NOT\\, XOR usw. ersetzen.\n"..
"Eingangkommandos für den Logikblock sind 'on'/'off' Kommandos. Ein 'on' ist ein logisches 'true'\\, ein 'off' entspricht dem 'false'.\n"..
"Eingangskommandos werden über die Nummer referenziert\\, also bspw. '1234' für das Kommando vom Sender mit der Nummer 1234.\n"..
"Das gleiche gilt für Ausgangskommandos.\n"..
"\n"..
"*Beispiele für den IF Ausdruck*\n"..
"Eine Regel ist wie folgt aufgebaut:\n"..
"\n"..
" <output> = true/false if <input-expression> is true\n"..
"\n"..
"'<output>' ist die Nummer des Blocks\\, zu dem das Kommando gesendet werden soll.\n"..
"\n"..
"'<input-expression>' ist ein boolescher Ausdruck\\, bei dem Eingabenummern ausgewertet werden. \n"..
"\n"..
" - \n"..
" - \n"..
"\n"..
"*Beispiele für den Input Ausdruck*\n"..
"\n"..
"Signal negieren (NOT):\n"..
"\n"..
" not n123\n"..
" 1234 == false\n"..
"\n"..
"Logisches UND (AND):\n"..
"\n"..
" n123 and n345\n"..
" 1234 == true and 2345 == true\n"..
"\n"..
"Logisches ODER (OR):\n"..
"\n"..
" n123 or n345\n"..
" 1234 == true or 2345 == true\n"..
"\n"..
"Ist der 'if'-Ausdruck wahr (true)\\, wird der 'then' Zweig ausgeführt\\, anderenfalls der 'else' Zweig.\n"..
"Bei 'then' und 'else' kann entweder 'true'\\, 'false'\\, oder nichts eingegeben werden:\n"..
"Folgende Operatoren sind zulässig: 'and' 'or' 'true' 'false' '==' '~=' '(' ')'\n"..
"\n"..
" - bei 'true' wird 'on' gesendet\n"..
" - bei 'false' wird 'off' gesendet\n"..
" - wird nichts eingegeben\\, wird auch nichts gesendet\n"..
"Ist der Ausdruck wahr (true)\\, wird ein Kommando an den Block mit der '<output>' Nummer gesendet.\n"..
"\n"..
"Den oder die Ziel-Blöcke für das Ausgangssignal muss man im Zielnummern-Feld eingeben.\n"..
"Es können bis zu vier Regeln definiert werden\\, wobei immer alle Regeln geprüft werden\\, wenn ein Kommando empfangen wird.\n"..
"\n"..
"Die interne Durchlaufzeit aller Kommandos beträgt 100 ms.\n"..
"\n"..
"\n"..
"\n",

View File

@ -896,32 +896,41 @@ techage.manual_EN.aText = {
"\n"..
"\n"..
"\n",
"The TA3 logic block can be programmed so that one or more input signals are linked to one output signal and sent. This block can therefore replace various logic elements such as AND\\, OR\\, NOT\\, XOR etc.\n"..
"Input signals for the logic block are 'on' / 'off' commands. An 'on' is a logical 'true'\\, an 'off' corresponds to the 'false'.\n"..
"Input signals are referenced by the number\\, e.g. 'n123' for the signal from the transmitter with the number 123.\n"..
"The TA3 logic block can be programmed in such a way that one or more input commands are linked to one output command and sent. This block can therefore replace various logic elements such as AND\\, OR\\, NOT\\, XOR etc. \n"..
"Input commands for the logic block are 'on' /'off' commands. An 'on' is a logical 'true'\\, an 'off' corresponds to the'false'. \n"..
"Input commands are referenced via the number\\, e.g. '1234' for the command from the sender with the number 1234. \n"..
"The same applies to output commands.\n"..
"\n"..
"* Examples for the IF expression *\n"..
"A rule is structured as follows: \n"..
"\n"..
" <output> = true/false if <input-expression> is true\n"..
"\n"..
"'<output>' is the block number to which the command should be sent.\n"..
"\n"..
"'<input-expression>' is a boolean expression where input numbers are evaluated.\n"..
"\n"..
" - \n"..
" - \n"..
"\n"..
"*Examples for the input expression*\n"..
"\n"..
"Negate signal (NOT):\n"..
"\n"..
" not n123\n"..
" 1234 == false\n"..
"\n"..
"Logical AND:\n"..
"\n"..
" n123 and n345\n"..
" 1234 == true and 2345 == true\n"..
"\n"..
"Logical OR:\n"..
"\n"..
" n123 or n345\n"..
" 1234 == true or 2345 == true\n"..
"\n"..
"If the 'if' expression is true\\, the 'then' branch is executed\\, otherwise the 'else' branch.\n"..
"With 'then' and 'else' you can either enter 'true'\\, 'false'\\, or nothing:\n"..
"The following operators are allowed: 'and' 'or' 'true' 'false' '==' '~=' '(' ')'\n"..
"\n"..
" - 'true' will lead to a 'on' command\n"..
" - 'false' will lead to a 'off' command\n"..
" - if nothing is entered\\, nothing is sent\n"..
"\n"..
"The target block or blocks for the output signal must be entered in the target number field.\n"..
"If the expression is true\\, a command is sent to the block with the '<output>' number. \n"..
"Up to four rules can be defined\\, whereby all rules are always checked when a command is received. \n"..
"The internal processing time for all commands is 100 ms. \n"..
"\n"..
"\n"..
"\n",

View File

@ -240,14 +240,15 @@ dofile(MP.."/logic/programmer.lua")
dofile(MP.."/logic/signallamp.lua")
dofile(MP.."/logic/sequencer.lua")
dofile(MP.."/logic/timer.lua")
dofile(MP.."/logic/lua_logic.lua")
dofile(MP.."/logic/lua_logic.lua") -- old
dofile(MP.."/logic/logic_block.lua") -- new
dofile(MP.."/logic/node_detector.lua")
dofile(MP.."/logic/player_detector.lua")
dofile(MP.."/logic/cart_detector.lua")
dofile(MP.."/logic/gateblock.lua")
dofile(MP.."/logic/doorblock.lua")
dofile(MP.."/logic/doorcontroller.lua")
dofile(MP.."/logic/doorcontroller2.lua")
dofile(MP.."/logic/doorcontroller.lua") -- old
dofile(MP.."/logic/doorcontroller2.lua") -- new
dofile(MP.."/logic/collector.lua")
if minetest.global_exists("mesecon") then
dofile(MP.."/logic/mesecons_converter.lua")

View File

@ -289,7 +289,7 @@ minetest.register_lbm({
if mem.liquid and mem.liquid.amount then
local nvm = techage.get_nvm(pos)
nvm.liquid = nvm.liquid or {}
nvm.liquid.amount = mem.liquid.amount
nvm.liquid.amount = math.max(mem.liquid.amount, 0)
nvm.liquid.name = mem.liquid.name
--tubelib2.del_mem(pos)
end

View File

@ -540,11 +540,42 @@ Liquid Sampler=Flüssigkeitensammler
no usable water=Kein brauchbares Wasser
### logic_block.lua ###
'~@=' means: not equal@n='~@=' bedeutet: ungleich@n
@n<input-expression> is a boolean expression@nwhere input numbers are evaluated.@n=@n<input-expression> ist ein boolescher Ausdruck,@nbei dem Eingabenummern ausgewertet werden.@n
@n<output> is the block number to which the@ncommand should be sent.@n=@n<output> ist die Blocknummer, an die der Befehl@ngesendet werden soll.@n
@nAll rules are checked with each received@ncommand.=@nAlle Regeln werden mit jedem empfangenen@nBefehl überprüft.
@nExamples:@n1234 @=@= true@n1234 @=@= false@n1234 @=@= true and 2345 @=@= false@n2345 ~@= 3456@n=@nBeispiele:@n1234 @=@= true@n1234 @=@= false@n1234 @=@= true and 2345 @=@= false@n2345 ~@= 3456@n
@nRule:@n<output> @= true/false if <input-expression> is true@n=@nRegel:@n<output> @= true/false if <input-expression> is true@n
@nThe following applies to inputs/outputs:@ntrue is 'on' and false is 'off'@n=@nFür alle Eingänge/Ausgänge gilt:@ntrue ist 'on' und false ist 'off'@n
@nThe internal processing time for all@ncommands is 100 ms.=@nDie interne Durchlaufzeit für alle@nKommandos beträgt 100 ms.
@nValid operators:@nand or true false @=@= ~@= ( )@n=@nGültige Operatoren:@nand or true false @=@= ~@= ( )@n
Help= Hilfe
Inputs=Eingänge
Outputs=Ausgänge
Rules=Regeln
Send an 'on'/'off' command if the@nexpression becomes true.@n=Sende ein 'on'/'off' Kommando, wenn der @nAusdruck wahr wird.@n
Syntax=Syntax
### logic_block.lua ###
### lua_logic.lua ###
TA3 Logic Block=TA3 Logikblock
Update=Update
### logic_block.lua ###
### lua_logic.lua ###
### power_terminal2.lua ###
@ -1041,3 +1072,6 @@ This is not the surface of the ocean!=Das ist nicht die Meeresoberfläche!
[TA4 Wind Turbine]=[TA4 Windkraftanlage]
biome and no ocean!=Biom und keine Meer (ocean)!
is a suitable place for a wind turbine!=ist ein geeigneter Ort für eine Windkraftanlage!
##### not used anymore #####

View File

@ -540,11 +540,42 @@ Liquid Sampler=
no usable water=
### logic_block.lua ###
'~@=' means: not equal@n=
@n<input-expression> is a boolean expression@nwhere input numbers are evaluated.@n=
@n<output> is the block number to which the@ncommand should be sent.@n=
@nAll rules are checked with each received@ncommand.=
@nExamples:@n1234 @=@= true@n1234 @=@= false@n1234 @=@= true and 2345 @=@= false@n2345 ~@= 3456@n=
@nRule:@n<output> @= true/false if <input-expression> is true@n=
@nThe following applies to inputs/outputs:@ntrue is 'on' and false is 'off'@n=
@nThe internal processing time for all@ncommands is 100 ms.=
@nValid operators:@nand or true false @=@= ~@= ( )@n=
Help=
Inputs=
Outputs=
Rules=
Send an 'on'/'off' command if the@nexpression becomes true.@n=
Syntax=
### logic_block.lua ###
### lua_logic.lua ###
TA3 Logic Block=
Update=
### logic_block.lua ###
### lua_logic.lua ###
### power_terminal2.lua ###

325
logic/logic_block.lua Normal file
View File

@ -0,0 +1,325 @@
--[[
TechAge
=======
Copyright (C) 2017-2021 Joachim Stolberg
AGPL v3
See LICENSE.txt for more information
Logic Block 2
]]--
-- for lazy programmers
local M = minetest.get_meta
local S = techage.S
local logic = techage.logic
local NUM_RULES = 4
local HELP = S("Send an 'on'/'off' command if the\nexpression becomes true.\n") ..
S("\nRule:\n<output> = true/false if <input-expression> is true\n") ..
S("\n<output> is the block number to which the\ncommand should be sent.\n") ..
S("\nThe following applies to inputs/outputs:\ntrue is 'on' and false is 'off'\n") ..
S("\n<input-expression> is a boolean expression\nwhere input numbers are evaluated.\n") ..
S("\nExamples:\n1234 == true\n1234 == false\n1234 == true and 2345 == false\n2345 ~= 3456\n") ..
S("\nValid operators:\nand or true false == ~= ( )\n") ..
S("'~=' means: not equal\n") ..
S("\nAll rules are checked with each received\ncommand.") ..
S("\nThe internal processing time for all\ncommands is 100 ms.")
-- mem.io_tbl = {
-- i123 = true, -- "on" received
-- i124 = false, -- "off" received
-- o456 = false, -- last output val
-- }
local ValidSymbols = {
["and"] = true,
["or"] = true,
["true"] = true,
["false"] = true,
["=="] = true,
["~="] = true,
["("] = true,
[")"] = true,
}
local Dropdown = {
[""] = 1,
["true"] = 2,
["false"] = 3
}
local function check_expr(expr)
local origin = expr
-- Add blanks for the syntax check
expr = expr:gsub("==", " == ")
expr = expr:gsub("~=", " ~= ")
expr = expr:gsub("%(", " ( ")
expr = expr:gsub("%)", " ) ")
-- First syntax check
for sym in expr:gmatch("[^%s]+") do
if not ValidSymbols[sym] and string.find(sym, '^[0-9]+$') == nil then
return "Unexpected symbol '"..sym.."'"
end
end
-- Second syntax check
local code, _ = loadstring("return " .. expr)
if not code then
return "Syntax error in '" .. origin .. "'"
end
end
local function check_num(num, player_name)
if not techage.check_numbers(num, player_name) then
return "Invalid node number '"..num.."'"
end
end
local function send(pos, num, val)
local own_num = M(pos):get_string("node_number")
local nvm = techage.get_nvm(pos)
nvm.io_tbl = nvm.io_tbl or {}
nvm.io_tbl["o" .. num] = val == "on" and true or false
techage.send_single(own_num, num, val)
end
local function check_syntax(line, owner, outp, expr)
local err = check_num(outp, owner)
if not err then
err = check_expr(expr)
if not err then
return true, "ok"
end
end
return false, "Error(" .. line .. "): " .. err
end
local function compile(nvm, str)
if str then
local code, _ = loadstring(str)
if code then
nvm.error = "ok"
return code
else
nvm.error = "Unknown compile error"
end
end
end
local function get_code(pos, nvm)
local meta = M(pos)
local mem = techage.get_mem(pos)
local tbl = {}
local owner = M(pos):get_string("owner")
for i = 1,NUM_RULES do
local outp = meta:get_string("outp" .. i)
local val = meta:get_string("val" .. i)
local expr = meta:get_string("expr" .. i)
if outp ~= "" and val ~= "" and expr ~= "" then
local res, err = check_syntax(i, owner, outp, expr)
if res then
val = val == "true" and "on" or "off"
-- add prefix 'i' to all numbers
expr = string.gsub(expr, '([0-9]+)', "i%1")
tbl[#tbl + 1] = "if "..expr.." then send(pos, "..outp..", '"..val.."') end"
else
nvm.error = err
mem.code = nil
return
end
end
end
local str = table.concat(tbl, "\n")
local code = compile(nvm, str)
nvm.io_tbl.send = send
nvm.io_tbl.pos = pos
setfenv(code, nvm.io_tbl)
return code
end
local function execute(pos)
local nvm = techage.get_nvm(pos)
local mem = techage.get_mem(pos)
mem.code = mem.code or get_code(pos, nvm)
if mem.code then
local res, _ = pcall(mem.code)
if not res then
nvm.error = "Unknown runtime error"
end
end
end
local function data(nvm)
local inp = {}
local outp = {}
for k,v in pairs(nvm.io_tbl) do
if k ~= "send" and k ~= "pos" then
if k:byte(1) == 105 then -- 'i'
inp[#inp+1] = k:sub(2) .. " = " .. dump(v)
else
outp[#outp+1] = k:sub(2) .. " = " .. dump(v)
end
end
end
return table.concat(inp, ", "), table.concat(outp, ", ")
end
local function rules(meta)
local tbl = {}
tbl[#tbl + 1] = "label[-0.2,0;<outp>]"
tbl[#tbl + 1] = "label[1.4,0;=]"
tbl[#tbl + 1] = "label[1.8,0;<bool>]"
tbl[#tbl + 1] = "label[3.5,0;if]"
tbl[#tbl + 1] = "label[4.2,0;<inp expression> is true]"
for i = 1,NUM_RULES do
local y1 = (i * 0.9) - 0.1
local y2 = (i * 0.9) - 0.2
local y3 = (i * 0.9) - 0.3
local outp = meta:get_string("outp" .. i)
local val = meta:get_string("val" .. i)
local expr = meta:get_string("expr" .. i)
val = Dropdown[val] or 1
tbl[#tbl + 1] = "field[0," .. y1 .. ";1.6,1;outp" .. i ..";;" .. outp .. "]"
tbl[#tbl + 1] = "label[1.4," .. y2 .. ";=]"
tbl[#tbl + 1] = "dropdown[1.8," .. y3 .. ";1.6,1;val" .. i ..";,true,false;" .. val .. "]"
tbl[#tbl + 1] = "label[3.5," .. y2 .. ";if]"
tbl[#tbl + 1] = "field[4.2," .. y1 .. ";5,1;expr" .. i ..";;" .. expr .. "]"
end
return table.concat(tbl, "")
end
local function formspec(pos, meta)
local nvm = techage.get_nvm(pos)
local err = nvm.error or "ok"
err = minetest.formspec_escape(err)
nvm.io_tbl = nvm.io_tbl or {}
local inputs, outputs = data(nvm)
return "size[9.4,7.7]" ..
"tabheader[0,0;tab;"..S("Rules") .. "," .. S("Help")..";1;;true]" ..
"container[0.4,0.1]" ..
rules(meta) ..
"container_end[]" ..
"label[0,4.5;" .. S("Inputs") .. ":]" ..
"label[2,4.5;" .. inputs .."]" ..
"label[0,5.1;" .. S("Outputs") .. ":]" ..
"label[2,5.1;" .. outputs .."]" ..
"label[0,5.7;" .. S("Syntax") .. ":]" ..
"label[2,5.7;" .. err .. "]" ..
"button[1.5,7.0;3,1;update;" .. S("Update") .. "]" ..
"button[5,7.0;3,1;store;" .. S("Store") .. "]"
end
local function formspec_help()
return "size[9.4,7.7]" ..
"tabheader[0,0;tab;"..S("Rules") .. "," .. S("Help")..";2;;true]" ..
"textarea[0.3,0.3;9.3,8;;;"..minetest.formspec_escape(HELP).."]"
end
minetest.register_node("techage:ta3_logic2", {
description = S("TA3 Logic Block"),
tiles = {
-- up, down, right, left, back, front
"techage_filling_ta3.png^techage_frame_ta3_top.png",
"techage_filling_ta3.png^techage_frame_ta3_top.png",
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_logic.png",
},
after_place_node = function(pos, placer)
local meta = M(pos)
local nvm = techage.get_nvm(pos)
nvm.io_tbl = {}
logic.after_place_node(pos, placer, "techage:ta3_logic2", S("TA3 Logic Block"))
logic.infotext(meta, S("TA3 Logic Block"))
meta:set_string("formspec", formspec(pos, meta))
meta:set_string("owner", placer:get_player_name())
end,
on_receive_fields = function(pos, formname, fields, player)
if minetest.is_protected(pos, player:get_player_name()) then
return
end
local meta = M(pos)
if fields.store then
for i = 1,NUM_RULES do
meta:set_string("outp" .. i, fields["outp" .. i] or "")
meta:set_string("val" .. i, fields["val" .. i] or "")
meta:set_string("expr" .. i, fields["expr" .. i] or "")
end
end
if fields.tab == "2" then
meta:set_string("formspec", formspec_help())
else
local nvm = techage.get_nvm(pos)
get_code(pos, nvm)
meta:set_string("formspec", formspec(pos, meta))
end
end,
on_timer = function(pos)
execute(pos)
return false
end,
on_rightclick = function(pos, node, clicker)
if minetest.is_protected(pos, clicker:get_player_name()) then
return
end
local meta = M(pos)
local nvm = techage.get_nvm(pos)
get_code(pos, nvm)
meta:set_string("formspec", formspec(pos, meta))
end,
after_dig_node = function(pos, oldnode, oldmetadata)
techage.remove_node(pos, oldnode, oldmetadata)
techage.del_mem(pos)
end,
paramtype2 = "facedir",
groups = {choppy=2, cracky=2, crumbly=2},
is_ground_content = false,
sounds = default.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "techage:ta3_logic2",
recipe = {
{"", "group:wood", ""},
{"techage:vacuum_tube", "default:copper_ingot", "techage:vacuum_tube"},
{"", "group:wood", ""},
},
})
techage.register_node({"techage:ta3_logic2"}, {
on_recv_message = function(pos, src, topic, payload)
local nvm = techage.get_nvm(pos)
nvm.io_tbl = nvm.io_tbl or {}
if topic == "on" then
nvm.io_tbl["i" .. src] = true
elseif topic == "off" then
nvm.io_tbl["i" .. src] = false
else
return "unsupported"
end
minetest.get_node_timer(pos):start(0.1)
end,
})

View File

@ -215,18 +215,20 @@ minetest.register_node("techage:ta3_logic", {
paramtype2 = "facedir",
groups = {choppy=2, cracky=2, crumbly=2},
is_ground_content = false,
drop = "techage:ta3_logic2",
sounds = default.node_sound_wood_defaults(),
})
minetest.register_craft({
output = "techage:ta3_logic",
recipe = {
{"", "group:wood", ""},
{"", "default:copper_ingot", "techage:vacuum_tube"},
{"", "group:wood", ""},
},
})
-- Deprecated and replaced by "techage:ta3_logic2"
--minetest.register_craft({
-- output = "techage:ta3_logic",
-- recipe = {
-- {"", "group:wood", ""},
-- {"", "default:copper_ingot", "techage:vacuum_tube"},
-- {"", "group:wood", ""},
-- },
--})
techage.register_node({"techage:ta3_logic"}, {
on_recv_message = function(pos, src, topic, payload)

View File

@ -522,31 +522,44 @@ Hinweis: Mit dem Programmer können Blocknummern sehr einfach eingesammelt und k
### TA3 Logikblock / Logic Block
Den TA3 Logikblock kann man so programmieren, dass ein oder mehrere Eingangssignale zu einem Ausgangssignal verknüpft und gesendet werden. Dieser Block kann daher diverse Logik-Elemente wie AND, OR, NOT, XOR usw. ersetzen.
Eingangssignale für den Logikblock sind `on`/`off` Kommandos. Ein `on` ist ein logisches `true`, ein `off` entspricht dem `false`.
Eingangssignale werden über die Nummer referenziert, also bspw. `n123` für das Signal vom Sender mit der Nummer 123.
Den TA3 Logikblock kann man so programmieren, dass ein oder mehrere Eingangskommandos zu einem Ausgangskommando verknüpft und gesendet werden. Dieser Block kann daher diverse Logik-Elemente wie AND, OR, NOT, XOR usw. ersetzen.
Eingangkommandos für den Logikblock sind `on`/`off` Kommandos. Ein `on` ist ein logisches `true`, ein `off` entspricht dem `false`.
Eingangskommandos werden über die Nummer referenziert, also bspw. `1234` für das Kommando vom Sender mit der Nummer 1234.
Das gleiche gilt für Ausgangskommandos.
**Beispiele für den IF Ausdruck**
Eine Regel ist wie folgt aufgebaut:
```
<output> = true/false if <input-expression> is true
```
- `<output>` ist die Nummer des Blocks, zu dem das Kommando gesendet werden soll.
- `<input-expression>` ist ein boolescher Ausdruck, bei dem Eingabenummern ausgewertet werden.
**Beispiele für den Input Ausdruck**
Signal negieren (NOT):
not n123
1234 == false
Logisches UND (AND):
n123 and n345
1234 == true and 2345 == true
Logisches ODER (OR):
n123 or n345
1234 == true or 2345 == true
Ist der `if`-Ausdruck wahr (true), wird der `then` Zweig ausgeführt, anderenfalls der `else` Zweig.
Bei `then` und `else` kann entweder `true`, `false`, oder nichts eingegeben werden:
- bei `true` wird `on` gesendet
- bei `false` wird `off` gesendet
- wird nichts eingegeben, wird auch nichts gesendet
Folgende Operatoren sind zulässig: `and` `or` `true` `false` `==` `~=` `(` `)`
Den oder die Ziel-Blöcke für das Ausgangssignal muss man im Zielnummern-Feld eingeben.
Ist der Ausdruck wahr (true), wird ein Kommando an den Block mit der `<output>` Nummer gesendet.
Es können bis zu vier Regeln definiert werden, wobei immer alle Regeln geprüft werden, wenn ein Kommando empfangen wird.
Die interne Durchlaufzeit aller Kommandos beträgt 100 ms.
[ta3_logic|image]

View File

@ -509,31 +509,42 @@ Note: With the programmer, block numbers can be easily collected and configured.
### TA3 Logic Block
The TA3 logic block can be programmed so that one or more input signals are linked to one output signal and sent. This block can therefore replace various logic elements such as AND, OR, NOT, XOR etc.
Input signals for the logic block are `on` / `off` commands. An `on` is a logical `true`, an `off` corresponds to the `false`.
Input signals are referenced by the number, e.g. `n123` for the signal from the transmitter with the number 123.
The TA3 logic block can be programmed in such a way that one or more input commands are linked to one output command and sent. This block can therefore replace various logic elements such as AND, OR, NOT, XOR etc.
Input commands for the logic block are `on` /` off` commands. An `on` is a logical ` true`, an `off` corresponds to the` false`.
Input commands are referenced via the number, e.g. `1234` for the command from the sender with the number 1234.
The same applies to output commands.
** Examples for the IF expression **
A rule is structured as follows:
```
<output> = true/false if <input-expression> is true
```
- `<output>` is the block number to which the command should be sent.
- `<input-expression>` is a boolean expression where input numbers are evaluated.
**Examples for the input expression**
Negate signal (NOT):
not n123
1234 == false
Logical AND:
n123 and n345
1234 == true and 2345 == true
Logical OR:
n123 or n345
1234 == true or 2345 == true
If the `if` expression is true, the `then` branch is executed, otherwise the `else` branch.
With `then` and `else` you can either enter `true`, `false`, or nothing:
- `true` will lead to a `on` command
- `false` will lead to a `off` command
- if nothing is entered, nothing is sent
The following operators are allowed: `and` `or` `true` `false` `==` `~=` `(` `)`
The target block or blocks for the output signal must be entered in the target number field.
If the expression is true, a command is sent to the block with the `<output>` number.
Up to four rules can be defined, whereby all rules are always checked when a command is received.
The internal processing time for all commands is 100 ms.
[ta3_logic|image]