View Full Version : Why won't this LUA script run?
windtrader
January 3rd, 2005, 10:29 PM
Hi all,
As I am refining my CCF, I am using more LUA and decided to move it all into the ccfname.LUA file. I did have trouble with timing in the Tonto code and had to add delays to provide sufficient timing for IR devices to finish processing a caoomand before sending another.
I am having a lot of trouble with timing problems in the LUA version, at least it seems timing related. The following is quite simple but does not work properly. The initial CCFload seems to work.
When I press a button that calls the DVDStart() function, it does get there and does the first Girder action but does not do the rest. I have taken out the condition and it still won't process the Girder commands without stopping after the first one.
I tried the alarm event plugin and also the SLEEP_Time functions but it seems control does not return to the LUA script after doing the wait.
I'm at a loss what to try next.
function OnCCFLoad()
NetRemote.SetVariable("Lexicon_Status","Off")
NetRemote.SetVariable("HDTV_Status","Off")
NetRemote.SetVariable("TV_Status","Off")
NetRemote.SetVariable("Music_Status","Off")
NetRemote.SetVariable("DVD_Status","Off")
NetRemote.SetVariable("1271_Status","Off")
end
function DVDStart()
if NetRemote.GetVariable("DVD_Status") == "Off" then
NetRemote.ExecuteAction(-1,0,1,"Lexicon.Source.DVD") -- Set DVD source
NetRemote.ExecuteAction(-1,0,1,"ZP.GroupOn") -- Activate Zoom Player Group
NetRemote.ExecuteAction(-1,0,1,"ZP.On") -- Start Zoom Player
NetRemote.ExecuteAction(-1,0,1,"PJ.InputA") -- Select HTPC Input on 1271
NetRemote.ExecuteAction(-1,0,1,"PJ.AR178") -- Set 178 AR on 1271
NetRemote.SetVariable("DVD_Status","On") -- Set DVD status
NetRemote.SetVariable("Lexicon_Status","On") -- Set Lexicon status on
NetRemote.SetVariable("Lexicon.SourceIndex","1") -- Lexicon DVD source flag
end
end
Jlee
January 3rd, 2005, 11:14 PM
I've had this problem before. I think it's a known outstanding issue when triggering multiple Girder actions. You would be better off sending only 1 Girder action which triggers multiple events (or triggers a single script containing multiple tasks) in Girder.
windtrader
January 3rd, 2005, 11:19 PM
Thanks for the help. I was thinking about moving it further back to Girder as it would actually be better placed there. I'm sure that would take care of the problem.
What is odd is I really read through many posts and never came across this being a problem. I saw many notes talking about ways to wait/delay processing between commands. I just assumed that the problem I was having was the reason for the need for the "wait".
Ben S
January 4th, 2005, 05:44 AM
Windtrader - Marcel and I have been working on these timing issues, and believe we have a fix. If you upgrade to 1.0.16.0, the fix should be there.
mhwlng
January 4th, 2005, 07:37 AM
eeeh, Ben that's not quite right :D
I just tried it and I have 3 girder actions in a row
NetRemote.ExecuteAction(-1,0,1,"BACKGROUND.RESCAN(800)");
NetRemote.ExecuteAction(-1,0,1,"MCAL.ALRESCAN(39)");
NetRemote.ExecuteAction(-1,0,1,"LDJ.RESCAN(12)");
the 3rd one is never executed.
all 3 girder functions contain lots of feedback back to NR...
so you still need to do all your 'stuff' in a single girder action like
NetRemote.ExecuteAction(-1,0,1,"SCANALL(800,12,39)");
then in girder you can do something like :
local tab={}
LUA_Parse( pld2,tab,",")
background.ReScan(pld1,tab[1])
MediaCenter.ALReScan(pld1,tab[3]) -- Rescan artist list
LDJ.ReScan(pld1,tab[2]) -- ReScan the DVD collection
Marcel
Ben S
January 4th, 2005, 07:53 AM
Oh! My bad!
Trust Marcel on this one, he's the NR <-> Girder guru.
windtrader
January 4th, 2005, 07:53 AM
If you upgrade to 1.0.16.0, the fix should be there.
eeeh, Ben that's not quite right WTF - are y'all just trying to make me crazzi?? ! :P
I actually did load the latest before posting and it did not work in my situation. I did find that if I had the first Girder call followed by a number of other non-Girder CCF commands then another Girder call, it would sometimes execute the second one.
Either way, I'm moving the code into Girder - probably the best place for it anyway.
Thanks for the help guys.
Don
windtrader
January 4th, 2005, 06:33 PM
@marcel/ben
I moved the code back into Girder and all the variables are defined and used in the Girder space. Now, I am trying to transfer values of NR and Girder variables between the two environments.
From what I read in the Wiki, plugin section, as quoted below, I would need to execute multiple NR execute actions to make this work. The problem with this is it creates the same issue I had that made me move to code further back into Girder.
So, what other method can I employ to pass Girder and NR variable to each other without executing multiple executeactions?
Don
Registering variables for feedback
Every NetRemote variable (text and images) you want to manipulate from Girder has to be registered in Girder for feedback. You may do this when your CCF gets loaded, when your panel gets loaded or any time you like, as long as it is before you try to manipulate the contents of the variable from Girder.
* Variable registered on a button: Use the IR code 5001 0000 0000 0002 FFFF 0000 0000 0000 on the button and put the variable's name in the name field of the IR command.
* Use the LUA-NetRemote.ExecuteAction(-1,0,0,VARNAME)-Command to register a variable. E.g., NetRemote.ExecuteAction(-1,0,0,"Cover") registeres the variable Cover.
Manipulation the contents of a variable
If you have registered a variable for feedback (see above), the contents of this variable (either text or image) can be manipulated from LUA script in Girder:
* For setting a text variable, use NetRemote.SendLabel?(VARNAME,CONTENT), e.g. NetRemote.SendLabel?("Title","Antz") will set the variable Title to the content Antz.
* For setting an image from girder, use NetRemote.SendImage?(IMGVARNAME,CONTENT). At present, CONTENT can only be a file reference to an image file (jpg, gif or png). Starting from release 1.0 the CONTENT can be a image URL as well.
o Note that any backslash characters (\) has to be "escaped". So you have to use "c:\\images\\image.jpg" (notice the double backslash characters!).
For the use of variables in your ccf files, see the Variables section for details.
Rob H
January 5th, 2005, 01:42 AM
@marcel/ben
Registering variables for feedback
* Variable registered on a button: Use the IR code 5001 0000 0000 0002 FFFF 0000 0000 0000 on the button and put the variable's name in the name field of the IR command.
* Use the LUA-NetRemote.ExecuteAction(-1,0,0,VARNAME)-Command to register a variable. E.g., NetRemote.ExecuteAction(-1,0,0,"Cover") registeres the variable Cover.
Those are two different ways of accomplishing the same thing, you only need to use one of them. If you don't want the variables to be displayed then you just need to put the buttons on a panel that has no jumps to it
windtrader
January 5th, 2005, 09:32 AM
Thanks rah
I set up a demo ccf to test the NR-Girder variable passing. It does not work. This is what I have so far.
Netremote button 1
action IR NetRemote.ExecuteAction(-1,0,1,"setvar")
5001 0000 0000 0002 fc19 0007 0000 0000
Netremote button 2
name: {testvar}
action: delay 100
Netremote button 3
name:register-variable
action: IR {testvar}
5001 0000 0000 0002 ffff 0000 0000 0000
Girder
command - setvar
Variable Manipulation Script - NetRemote.SendNabel("testvar","XXXXX");
Test scenario - Register the NR variable named testvar with Girder, have Girder (in VMS/LUA) set it to a value, then display the value back in Netremote.
Press button 1 - I see Girder receives the command from NR and goes to the proper command.
Press button 2 nothing happens, no value set.[/b]
Rob H
January 5th, 2005, 09:54 AM
Netremote button 3
name:register-variable
action: IR {testvar}
5001 0000 0000 0002 ffff 0000 0000 0000
That name shouldn't be in braces.
Girder
command - setvar
Variable Manipulation Script - NetRemote.SendNabel("testvar","XXXXX");
Is that a straight copy? That should of course be SendLabel.
Test scenario - Register the NR variable named testvar with Girder, have Girder (in VMS/LUA) set it to a value, then display the value back in Netremote.
Press button 1 - I see Girder receives the command from NR and goes to the proper command.
That's a start. Make sure you either use the logger plugin or have a script window open so you can see any error messages.
Press button 2 nothing happens, no value set.[/b]
I wouldn't expect it to, since that button only has a delay.
Just thought, you do have NetRemote Feedback.lua in the Girder\lua directory don't you?
windtrader
January 5th, 2005, 10:46 AM
Just thought, you do have NetRemote Feedback.lua in the Girder\lua directory don't you?
OK - saving the best for last heh? Well, I gots no lua directory. This is new news to me. I had not come across any reference for this requirement. I DL'd and read docs. Not clearly stated what is needed to install but I created a LUA subdir under Girder and placed the NetRemote Feeback.LUA there.
Took care of the other bits.
spelling error - fixed
removed brackets
Logging plugin is really nice - boy it's pretty hard seeing what is going on in the dark!
When I start NR and load CCF - I don't see any log showing the registration of the variable. It does not work yet but I am much closer. I'll keep hacking away.
Thanks ALOT!
EDIT - I tried the samples in the NR-feedback zip and they don't work. I could not find any register coding and the IR commands were different than what is being used now. Maybe this is based on an old version of something.
EDIT 2:
Girder is not accepting this VMS-LUA command. It seems maybe like the registration is not working. ; The log entry follows:
NetRemote.SendLabel("testvar","XXXXX")
12:58:35.004 Wednesday, January 05, 2005 LUA: call main
12:58:35.004 Wednesday, January 05, 2005 LUA: --> call C _ERRORMESSAGE global
12:58:35.004 Wednesday, January 05, 2005 ALERT: error: attempt to index global `NetRemote' (a nil value)
12:58:35.004 Wednesday, January 05, 2005 ALERT: stack traceback:
12:58:35.004 Wednesday, January 05, 2005 ALERT: 1: main of (none)
12:58:35.004 Wednesday, January 05, 2005 LUA: return C _ERRORMESSAGE global
EDIT 3
I've done more testing with the logger turned on.
I dno not see any Girder action taking place when I try to set the variable for feedback. I have tried three different methods and they all return the above message indicating that mayb the variable is not registered.
I tried using the NetRemote executeaction in the button name and as a function in a .LUA file,
I tried calling a NR LUA function that executed the netremote action
I reviewed JLee and Marcle's CCF, GML, and comments and doubled checked everyting including making sure the proper LUA and plugins were in the right places on both the client and server.
'm pretty stuck guys!
Ben S
January 6th, 2005, 10:55 AM
Sorry for not posting earlier.
For Girder to NetRemote feedback to work:
A) LUAEvents must be enabled.
B) lua directory must exist in Girder directory
C) NetRemote Feedback.lua must be in the Girder/lua directory.
Now you should be able to try the feedback test file (and gml) and get images and variables to NetRemote from Girder.
For NetRemote to Girder feedback to work:
There are two ways to send a variable to Girder whenever the value changes.
1) Register a variable for feedback to Girder.
Create a button (it can be transparent), with the first action being a Girder action like this:
IR Name: Variable name to register feedback for
IR Code: 5001 0000 0000 0002 FFFF 9999 9999 0000
Now whenever the variable changes, the action will be sent to Girder with the variable name as the EVENT, and the value as the payload.
2) Send events from lua
function OnVariableChange(varname,varvalue)
if (varname == 'MyVariable') then
NetRemote.ExecuteAction(-1,0,1,'SetMyVariable('..varvalue..')');
end;
end;
Do these things accomplish what you are trying to do?
windtrader
January 6th, 2005, 10:56 AM
12:58:35.004 Wednesday, January 05, 2005 LUA: call main
12:58:35.004 Wednesday, January 05, 2005 LUA: --> call C _ERRORMESSAGE global
12:58:35.004 Wednesday, January 05, 2005 ALERT: error: attempt to index global `NetRemote' (a nil value)
12:58:35.004 Wednesday, January 05, 2005 ALERT: stack traceback:
12:58:35.004 Wednesday, January 05, 2005 ALERT: 1: main of (none)
12:58:35.004 Wednesday, January 05, 2005 LUA: return C _ERRORMESSAGE global
I got rid of this errof after loading a new version of the LUAEvents plugin. I was running the original 1.0.0 and now the 1.0.3 made this error go away.
However, I am still unable to get the variable registered. If the register event shoud be logged, there is nothing showing up there.
windtrader
January 6th, 2005, 12:06 PM
For Girder to NetRemote feedback to work:
A) LUAEvents must be enabled.
B) lua directory must exist in Girder directory
C) NetRemote Feedback.lua must be in the Girder directory.
Now you should be able to try the feedback test file (and gml) and get images and variables to NetRemote from Girder.
OK! Finally, I have the GIrder to NR feedback working as it should.
btw - I did have NetRemote Feedback in the LUA sub directory, not the Girder directory and it worked.
THANKS!
NR to Girder
IR Name: Variable name to register feedback for
IR Code: 5001 0000 0000 0002 FFFF 9999 9999 0000
I think the problem is I used zeros instead of 9999 . Either I got mixed up or saw zeros being used in some example or post. I'll give this a try.
Don
Ben S
January 6th, 2005, 12:28 PM
[quote]OK! Finally, I have the GIrder to NR feedback working as it should.
Awesome!
btw - I did have NetRemote Feedback in the LUA sub directory, not the Girder directory and it worked.
Yes, my bad. It should go in the lua directory (corrected in post above).
windtrader
January 6th, 2005, 04:23 PM
Ben,
OK! I finally got a demo running that handles variables on both sides and passes them back and forth.
Looking back I can see all the information is there but it is really spread around in bits and pieces.
I am putting some notes together, really a compilation of what is around, for myself If I have to do this set up again. I'll post it so others might avoid some of the headbanging I went through. Lucky for me I got it sorted.. Take a look at me last night!.
Rob H
January 6th, 2005, 04:49 PM
Might be a good addition to the Wiki
Promixis
January 6th, 2005, 05:13 PM
When you get it together, I will send it to Eric who is maintaining the Pro guide.
windtrader
January 6th, 2005, 11:21 PM
For NetRemote to Girder feedback to work:
There are two ways to send a variable to Girder whenever the value changes.
1) Register a variable for feedback to Girder.
Create a button (it can be transparent), with the first action being a Girder action like this:
Code:
IR Name: Variable name to register feedback for
IR Code: 5001 0000 0000 0002 FFFF 9999 9999 0000
Now whenever the variable changes, the action will be sent to Girder with the variable name as the EVENT, and the value as the payload.
:( :(
False alarm. I thought I had both directions sorted out. I am attaching the basic feedbacktest sample with one minor mod. I added a button to toggle the TEST_LABEL_1 between 0 and 1, thus changing the variable. I also removed the image 1 and 2 buttons.
Based on the the prior comment that an action will be sent to Girder upon variable change, I turned on logger and watched it.
When the NR client starts up and runs feedbacktest.ccf, I do see a series of entries and the last is an EVENT with the client IP in pld1 and 30000 in pld2. When I click the toggle button, I see the value change in the button labeled TEST_LABEL_1 but do not see any logger entry.
Also, I don't see any variable entry in the Girder list for TEST_LABEL_1. Should there be an entry in the girder variable list for those that are registered by NR?.
I guess I am still lost as to how to define a variable in NR and have it received and made available by Girder for processing.
I've run a lot of tests and I am certain I can get the value passed from Girder to NR.
Sorry for the heavy hand holding but rest assured it is far more painful in my seat than yours. I've spent ALOT of time on this and feel like I am going in circles. Hum... I wonder if I just admitted how stupid I am. Ohwell.
Your truley,
Frustrated and tired and going to bed
Ben S
January 11th, 2005, 05:28 PM
Okay, attached is the gml and ccf.
I don't see anywhere here where you've defined a button with the 0x9999,0x9999 parameters (that registers a variable for girder feedback).
Change to the gml: Added a command with event of TEST_LABEL_1
Change to the ccf: Changed the IR code for the first button to be 0xFFFF,0x9999,0x9999 to and IR name TEST_LABEL_1, this tells NetRemote to send the value to Girder when it is changed in any way other than by Girder.
windtrader
January 11th, 2005, 09:30 PM
Thanks so much for replying and doing the extra work to show this example. I see now how the payload has the variable name and value and how Girder grabs this data. I'll make sure my notes clearly reference this example.
Since my last message , I've just finished getting all code except that which is UI specifc into Girder. I've learned a hell of a lot more about LUA and how Girder and NR works. The logger is a really great feature once you figure out everything it is telling you.
By lightening up the client, I was able to build the NR app nearly entirely with the execute Girder command. I did create many variables in Girder that get processed and passed back to NR.
It is certainly not the easiest development environment (NR and Girder) as they lack many fairly basic syntax, debug, and test tools. It took me a lot longer to sort out, especially when one has bad typing like I do.
Anyway, I have it pretty much complete now except for determining if the SLIDER will work for setting the master volume. And the graphics can always use more improvement .
I'll take a break tomorrow and try to pull my notes together.
Thanks again, Don
Powered by vBulletin® Version 4.1.8 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.