I'm having a an odd problem within my screen PLC script. I don't know if it's a Lua issue or something about the PLC script.
I have two local modules that I have created, SigLib.mcc and MyStdMill.mcc. Both I import using a require in the screen startup script. I make SigLib calls in the screen startup and signal scripts, and it works flawlessly. I only make MyStdMill calls in the screen PLC script. Even though debugging shows the table containing the module is there (it has a non zero value), all my function calls cause an error since they are nil value.
I thought that anything imported in the screen startup script should be seen in the PLC script. Is this not the case?
-Freeman
-- Startup script
function GetMachDir ()
local inst = mc.mcGetInstance();
return mc.mcCntlGetMachDir (inst);
end
local machDir = GetMachDir();
package.path = "./?.lua;" ..
machDir .. "/?.dll;" ..
machDir .. "/Modules/?.mcc;" ..
machDir .. "/Profiles/MyStdMill/Modules/?.mcc"
SigLib = require "SigLib"
MySM = require "MyStdMill"
-- PLC script
MySM.plcScreenSetName(inst)
MySM.plcAxisScaling(inst, 'droMySMScaleX', 'iRegs0/xScale')
MySM.plcAxisScaling(inst, 'droMySMScaleY', 'iRegs0/yScale')
MySM.plcAxisScaling(inst, 'droMySMScaleZ', 'iRegs0/zScale')
MySM.plcAxisScaling(inst, 'droMySMScaleA', 'iRegs0/aScale')
-- MystdMill.mcc Module
local MyStdMill = {}
function MyStdMill.plcScreenSetName (inst)
-- code abbreviated
end
function MyStdMill.plcAxisScaling(inst, dro, reg)
-- code abbreviated
end
return MyStdMill