Lua Domain Configuration Configuration

I have 5000 data item definition definitions that we expect them to be constructed as

-- Name of the device
VARIABLE Name { 
   type=Float,
   length=20,
   <<few more definition here>>
}

-- The device running elapsed time since its last boot
VARIABLE BootTime {
   type=Integer,       
   <<few more definition here>>
}

I will read the value "Name", "BootTime" from a device using a communication protocol using a protocol in which we use the above property.

I want the variable to also have properties for the pre_processor and post_processor functions.

  • How to define a structure like this in Lua? If this strcuture is not possible, then what cabinet structure is possible in Lua

  • I want to overload the statement for these Variable definitions so that I can do,

    I can configure BootTime = 23456789 or As arithmetic, as BootTime + 100 (milliseconds) Or a comparison, for example, if BootTime> 23456789 then do something

+3
1

VARIABLE, Lua, ( __index ).

Integer="Integer"
setmetatable(_G,
        { __index = function(t,n)
                        return function (x) _G[n]=x.value end
                end })
BootTime {
        type=Integer,
        value=10000
}
print(BootTime+2345)

VARIABLE, , , Lua, VARIABLE.BootTime VARIABLE"BootTime" VARIABLE[BootTime], Lua .

+2

Source: https://habr.com/ru/post/1770484/


All Articles