益泰 发表于 2023-6-29 17:15:53

请问哪出错:判断参数D1值,改内部参数0101的值

请问哪出错:判断参数D1值,改内部参数0101的值
--数据类型定义
VT_LW = 1    --变量地址
VT_RW = 2    --FLASH存储
VT_0x = 10    --线圈
VT_1x = 11    --输入点
VT_3x = 12    --输入寄存器
VT_4x = 13    --保持寄存器


function on_init()
end

function on_run(0)
set_run_cycle(10)
local value = get_uint32(13, 0x00D1)
        if value == 0
                then
                set_bit(2, 0x1100, 1)
                else
                set_bit(2, 0x1100, 0)
                end
        if value == 1
                then
                set_bit(2, 0x1101, 1)
                else
                set_bit(2, 0x1101, 0)
                end
        if value == 2
                then
                set_bit(2, 0x1102, 1)
                else
                set_bit(2, 0x1102, 0)
                end
        if value == 3
                then
                set_bit(2, 0x1103, 1)
                else
                set_bit(2, 0x1103, 0)
                end       
end

If后要接end 发表于 2023-6-29 18:58:56

function on_run(screen),官网提供的回调函数,形参不能修改

益泰 发表于 2023-6-29 20:03:07

请问local value = get_uint32(13, 0x00D1)是不是有错,0x00D1会为0,
function on_run(screen)--screen
set_run_cycle(100)
local value = get_uint32(13, 0x00D1)
        if value == 0
                then
                set_bit(1, 0x1100, 1)
                else
                set_bit(1, 0x1100, 0)
                end
        if value == 1
                then
                set_bit(1, 0x1101, 1)
                else
                set_bit(1, 0x1101, 0)
                end
        if value == 2
                then
                set_bit(1, 0x1102, 1)
                else
                set_bit(1, 0x1102, 0)
                end
        if value == 3
                then
                set_bit(1, 0x1103, 1)
                else
                set_bit(1, 0x1103, 0)
                end       
end

益泰 发表于 2023-6-29 20:23:28

谢谢大家,问题找到,能通过了
页: [1]
查看完整版本: 请问哪出错:判断参数D1值,改内部参数0101的值