harleydude
June 12th, 2007, 10:43 AM
I pulled this code from the USBUIRT.Lua component file
local status,loaded = gir.PluginStatus(PluginID)
if not loaded then
gir.LoadPlugin (PluginID) -- load
local t = win.GetElapsedMilliseconds ()
while t + 3000 < win.GetElapsedMilliseconds () do
win.Sleep (200)
status,loaded = gir.PluginStatus(PluginID)
if status > 0 or loaded then
break
end
end
end
if status == 3 then
self:Event (self.Events.Error,'Unable to start the USBUIRT plugin')
end
The above works fine for the USBUIRT Plugin, however I believe there is a bit of a logic problem in the code, if t is set to GetElapsedMilliseconds then t + 3000 will not be less than GetElapsedMilliseconds upon entering the while loop. I changed the < to a > and got the results intended. However, I still having problems with the following code.
-- local xAPID = 261 is set higher up in the code
print ('Checking xAP Plugin Load Status')
local status,loaded = gir.PluginStatus(xAPID)
print ('Status',status,loaded)
if not loaded then
print ('Not loaded, attempting to load')
gir.LoadPlugin (xAPID) -- load
local t = win.GetElapsedMilliseconds ()
while t + 3000 > win.GetElapsedMilliseconds () do
win.Sleep (200)
status,loaded = gir.PluginStatus(xAPID)
print ('Status',status,loaded)
if status == 2 or loaded then
print('xAP Loaded')
break
end
end
end
print ('Loop completed',status,loaded)
if status == 3 then
self:Event (self.Events.Error,'Unable to start the xAP Automation plugin')
else
win.Sleep (1000)
self:Event (self.Events.Update,'xAP Automation plugin started')
xap.xApGirderDev = xap.NewDevice('promixis.girder','promixis.girder.' ..self.HostName,'FF430100')
xap.SetCB(function (...) return self:xApMessageDispatch(unpack(arg)) end)
end
When my component is enabled below is the Console output
Checking xAP Plugin Load Status
Status 0 false
Not loaded, attempting to load
Status 1 true
xAP Loaded
Loop completed 1 true
TreeScript (golua): ...Promixis\Girder5\luascript\components\xAPManage r.lua:194: attempt to index global `xap' (a nil value)
stack traceback:
...Promixis\Girder5\luascript\components\xAPManage r.lua:194: in function `Enable'
...iles\Promixis\Girder5\luascript\ComponentManage r.lua:305: in function `EnableComponent'
...\Girder5\/plugins/treescript/ComponentManager UI.lua:175: in function <...\Girder5\/plugins/treescript/ComponentManager UI.lua:159>
Below is 194 in my file:
xap.xApGirderDev = xap.NewDevice('promixis.girder','promixis.girder.' ..self.HostName,'FF430100')
However the xAP Automation plugin is loaded by the script. Since the above error does not allow my component to actually enable, I can tell CM to enable it and I see the following in the Console.
Checking xAP Plugin Load Status
Status 1 true
Loop completed 1 true
Everything looks good. I am clueless.
local status,loaded = gir.PluginStatus(PluginID)
if not loaded then
gir.LoadPlugin (PluginID) -- load
local t = win.GetElapsedMilliseconds ()
while t + 3000 < win.GetElapsedMilliseconds () do
win.Sleep (200)
status,loaded = gir.PluginStatus(PluginID)
if status > 0 or loaded then
break
end
end
end
if status == 3 then
self:Event (self.Events.Error,'Unable to start the USBUIRT plugin')
end
The above works fine for the USBUIRT Plugin, however I believe there is a bit of a logic problem in the code, if t is set to GetElapsedMilliseconds then t + 3000 will not be less than GetElapsedMilliseconds upon entering the while loop. I changed the < to a > and got the results intended. However, I still having problems with the following code.
-- local xAPID = 261 is set higher up in the code
print ('Checking xAP Plugin Load Status')
local status,loaded = gir.PluginStatus(xAPID)
print ('Status',status,loaded)
if not loaded then
print ('Not loaded, attempting to load')
gir.LoadPlugin (xAPID) -- load
local t = win.GetElapsedMilliseconds ()
while t + 3000 > win.GetElapsedMilliseconds () do
win.Sleep (200)
status,loaded = gir.PluginStatus(xAPID)
print ('Status',status,loaded)
if status == 2 or loaded then
print('xAP Loaded')
break
end
end
end
print ('Loop completed',status,loaded)
if status == 3 then
self:Event (self.Events.Error,'Unable to start the xAP Automation plugin')
else
win.Sleep (1000)
self:Event (self.Events.Update,'xAP Automation plugin started')
xap.xApGirderDev = xap.NewDevice('promixis.girder','promixis.girder.' ..self.HostName,'FF430100')
xap.SetCB(function (...) return self:xApMessageDispatch(unpack(arg)) end)
end
When my component is enabled below is the Console output
Checking xAP Plugin Load Status
Status 0 false
Not loaded, attempting to load
Status 1 true
xAP Loaded
Loop completed 1 true
TreeScript (golua): ...Promixis\Girder5\luascript\components\xAPManage r.lua:194: attempt to index global `xap' (a nil value)
stack traceback:
...Promixis\Girder5\luascript\components\xAPManage r.lua:194: in function `Enable'
...iles\Promixis\Girder5\luascript\ComponentManage r.lua:305: in function `EnableComponent'
...\Girder5\/plugins/treescript/ComponentManager UI.lua:175: in function <...\Girder5\/plugins/treescript/ComponentManager UI.lua:159>
Below is 194 in my file:
xap.xApGirderDev = xap.NewDevice('promixis.girder','promixis.girder.' ..self.HostName,'FF430100')
However the xAP Automation plugin is loaded by the script. Since the above error does not allow my component to actually enable, I can tell CM to enable it and I see the following in the Console.
Checking xAP Plugin Load Status
Status 1 true
Loop completed 1 true
Everything looks good. I am clueless.