卢阿:为什么';这条路线的循环难道没有结束吗? 我正在编写一个脚本,用于自动测试舞台灯光控制台(GrandMA2)的插件。由于插件需要一些用户输入,测试主要是关于输入模糊,因此插件要运行几次。这是通过使用一个协同程序来完成的,该程序运行测试脚本,并且每次运行主插件时都会产生效果。当主插件完成时,它恢复测试线程。重复执行此操作,直到测试文件中硬编码的所有输入值都被测试。这就是理论。实际上,插件有时只运行一次会出现问题。如果我关闭控制台软件,重新打开它(不保存文件),导入插件并再次在测试模式下启动它,它会运行2到3次。重复此操作,它现在运行4-5次,以此类推。但它的运行频率不足以测试所有值。最好的情况是,它在最后一次运行插件之前停止。 您可以看看下面的一些代码。但是如果您受到鼓励,您也可以在GitHub上阅读整个代码(https://github.com/kochjo/CueStep-Fader). 您只需注意文件“`CSF\u main.lua``和“`Test.lua`”。 这对插件本身并不重要,但我仍在学习编码,我想知道为什么会发生这种情况。…这让我抓狂**主文件中的代码片段:* local REQ_SUCCESS, Test = pcall(function() return require 'Test' end) -- do some other stuff.. function CSF_main(testmode) --[[ Requests user input for the number of steps and the CSF-name and executes all necessary functions in order. ]] if testmode and REQ_SUCCESS then TESTMODE = true elseif not REQ_SUCCESS then gma.echo('CSF plugin: Test script not found. Thus test mode is not available.') end -- do some other uninteresting stuff.. if TESTMODE then coroutine.resume(Test.test); gma.echo("resumed") end end return CSF_main

卢阿:为什么';这条路线的循环难道没有结束吗? 我正在编写一个脚本,用于自动测试舞台灯光控制台(GrandMA2)的插件。由于插件需要一些用户输入,测试主要是关于输入模糊,因此插件要运行几次。这是通过使用一个协同程序来完成的,该程序运行测试脚本,并且每次运行主插件时都会产生效果。当主插件完成时,它恢复测试线程。重复执行此操作,直到测试文件中硬编码的所有输入值都被测试。这就是理论。实际上,插件有时只运行一次会出现问题。如果我关闭控制台软件,重新打开它(不保存文件),导入插件并再次在测试模式下启动它,它会运行2到3次。重复此操作,它现在运行4-5次,以此类推。但它的运行频率不足以测试所有值。最好的情况是,它在最后一次运行插件之前停止。 您可以看看下面的一些代码。但是如果您受到鼓励,您也可以在GitHub上阅读整个代码(https://github.com/kochjo/CueStep-Fader). 您只需注意文件“`CSF\u main.lua``和“`Test.lua`”。 这对插件本身并不重要,但我仍在学习编码,我想知道为什么会发生这种情况。…这让我抓狂**主文件中的代码片段:* local REQ_SUCCESS, Test = pcall(function() return require 'Test' end) -- do some other stuff.. function CSF_main(testmode) --[[ Requests user input for the number of steps and the CSF-name and executes all necessary functions in order. ]] if testmode and REQ_SUCCESS then TESTMODE = true elseif not REQ_SUCCESS then gma.echo('CSF plugin: Test script not found. Thus test mode is not available.') end -- do some other uninteresting stuff.. if TESTMODE then coroutine.resume(Test.test); gma.echo("resumed") end end return CSF_main,lua,Lua,测试文件中的代码片段: Test.test = coroutine.create(function() --[[ The main function for the test. It runs CSF repeatedly (with param. 'testmode' set to true) until all inputs listed in Test.lua are tested. ]] local run = 1 whil

测试文件中的代码片段:

Test.test = coroutine.create(function()
    --[[
        The main function for the test. It runs CSF repeatedly (with param. 'testmode' set to true)
        until all inputs listed in Test.lua are tested.
    ]]
    local run = 1
    while not all_tested() do
        log("Run", run, 'Not all tested. Next one.')
        cmd('LUA "CSF_main(true)"') -- execute the main plugin again via the console API..
        coroutine.yield() -- wait for the current run of CSF to finish.
        log(nil, nil, "\n Resume yielding loop.")
        run = run+1
    end
    log(nil, nil, "Test completed.") -- this is never reached..
    LOGFILE:close()
end)
这是我在这里关于stackoverflow的第一个问题,我希望我能以某种方式解释所有问题,让那些不了解GrandMA2 lighting Desk及其lua API的人也能理解我的问题所在。
提前感谢所有为此牺牲时间的人

添加
print/log
coroutine.resume(Test.Test)call查看打印结果。要么控件无法进行
resume
调用,要么它无法恢复一个失效的协同路由(或者类似的东西)。我完全不明白为什么要使用协同路由。任务是并行运行测试吗?@AlexanderMashin我决定在一个协同程序中运行测试脚本,因为它使我有可能在主插件完成之前生成测试。我以前试图在没有协同程序的情况下完成它,但这导致了一个问题,测试脚本中的while循环继续调用主插件,即使之前的运行在此之前还没有完成。这是因为必须通过GrandMA2 cmd行调用
CSF_main
,然后与测试脚本并行运行。@PaulKulchenko感谢您的建议。我记录了resume调用的结果,结果表明,每次成功地恢复了协同路由。。对我来说,上次的
cmd(“LUA”CSF_main(true)”)
调用似乎不是由控制台执行的。也许我应该给MA技术支持部门写封邮件。。