Using iogen to set an Applicationvariable

Questions and information about Crank Software's Storyboard Engine

Moderator: jamiev

Using iogen to set an Applicationvariable

Postby timmac » Fri Apr 13, 2012 12:36 pm

Hello,

I am able to use iogen to send a gre.quit event to my application and it works fine.

I read the StoryboardIO chapter in CrankStoryBoard.pdf, but I am not sure how to set
an application variable, errorCode, to a certain value via iogen. I tried the following:

iogen WW_UI_Simulator.gapp notarget ${app:errorCode}=163384

and

iogen WW_UI_Simulator.gapp notarget ${app:errorCode 163384}

with no luck. How do I correctly set an Application variable?

Thanks,

Tim
timmac
 
Posts: 42
Joined: Wed Mar 14, 2012 1:21 pm

Re: Using iogen to set an Applicationvariable

Postby jason » Fri Apr 13, 2012 1:04 pm

Are you launching your application from the simulator in Designer?

If so the gapp file name is generated using a tempfile name when you click simulate in Designer, so it's not easy to connect to the channel since the gapp filename is the default Storyboard IO channel. To get around this issue we added an option in launch configuration to hard code your default SBIO channel so you don't have this issue. (see attached)

Regards,
Jason
Attachments
2012-04-13_14-00-24.jpg
Launch Config
2012-04-13_14-00-24.jpg (176.82 KiB) Viewed 2588 times
User avatar
jason
 
Posts: 152
Joined: Mon Nov 02, 2009 4:53 pm

Re: Using iogen to set an Applicationvariable

Postby timmac » Fri Apr 13, 2012 1:20 pm

Jason,

Yes I am and I have WW_UI_Simulator.gapp in the field that you pointed out.

I am able to connect to the app and send it a gre.quit event and sure enough the app quits.

I do not get any errors when I try to set my application variables, but I do not see the result I would expect.

Is the usage of iogen the way I am trying it correct for application variables:

iogen WW_UI_Simulator.gapp no_target ${app:varName}=newValue

Thanks,

Tim
timmac
 
Posts: 42
Joined: Wed Mar 14, 2012 1:21 pm

Re: Using iogen to set an Applicationvariable

Postby jason » Fri Apr 13, 2012 1:42 pm

Sorry, I read your your post too quickly and thought you were getting an error code from iogen, not setting a variable called errorCode :) sorry

You can do what you are asking but it's a little tricky. This is what it should look like

./iogen WW_UI_Simulator.gapp errorCode greio.iodata_set 4s1 163384

Main reason it's tricky is you have to look at iodata.h to figue out the event name.

Regards,
Jason
User avatar
jason
 
Posts: 152
Joined: Mon Nov 02, 2009 4:53 pm

Re: Using iogen to set an Applicationvariable

Postby timmac » Fri Apr 13, 2012 2:40 pm

No problem Jason.

Okay - now I get a "Verification OK!" after executing iogen in the fashion you describe, but I do not see errorCode changing.

I have a 1second timer routine going off and I added:

print(errorCode) to it and after executing:

iogen WW_UI_Simulator.gapp errorCode greio.iodata_set 4s1 16384

It is still printing 0 to the console (the value I set in my gre_init function). I also tried other application variables with no success.

Thanks,

Tim
timmac
 
Posts: 42
Joined: Wed Mar 14, 2012 1:21 pm

Re: Using iogen to set an Applicationvariable

Postby jason » Fri Apr 13, 2012 4:02 pm

I think the question is what are you trying to do with errorCode? Display it as a string on the screen or evaluate it Lua

I'm guessing evaluate it in Lua, otherwise you'll need to send the data as a string to have it displayed immediately.

Currently you are setting the value into Storyboard's data manager as a 4 byte signed integer. So to print out the value in Lua you'd need to get the value from the data manager first

data = {}
data = gre.get_data("errorCode")
print("errorCode = "..tostring(data["errorCode"])

Another way all together to do this is just create your own custom event "errorEvent" and send the data with it.

./iogen WW_UI_Simulator.gapp no_target errorEvent 4s1:errorCode 163384

And then you'd create a custom event called in "errorEvent" in the add action dialog and have it call your Lua function.... which would look like this:

function cb_error_event(mapargs)
local ev = mapargs["context_event_data"]
print("errorCode = "..tostring(ev["errorCode"]))
end
User avatar
jason
 
Posts: 152
Joined: Mon Nov 02, 2009 4:53 pm

Re: Using iogen to set an Applicationvariable

Postby timmac » Fri Apr 13, 2012 4:29 pm

Jason,

Obviously I have some learning to do on LUA and the Storyboard architecture.

Why would print(errorCode) work when I initialized the errorCode to 16384 in gre_init?

Also, for all of my application variables, I need to use the gre.get/set_data routines in order to modify
the variable from any Lua function? I was treating them as global variables - so I take it that
is not the case?

Thanks again,

Tim
timmac
 
Posts: 42
Joined: Wed Mar 14, 2012 1:21 pm

Re: Using iogen to set an Applicationvariable

Postby jason » Sat Apr 14, 2012 9:51 pm

I think the big thing to understand is there are 2 type of variables :

1 - Storyboard Variables - Created in Designer and can be used to manipulate controls on screen
http://cranksoftware.com/cranksoftware/docs/v1.3/ch01s02.html#d0e226

2 - Lua Variables - Created in Lua and good for tracking state, but only by using gre.set_data() can it change anything displayed on the screen.

If you created errorCode variable in your Lua init function and didn't define it as "local" it would automatically be consider a global in Lua's context, so when you did a print(errorCode) in another function the value would be correct.

If you use Storyboard IO to set a variable from another application you will be setting a Storyboard Variable. So if you want access to it Lua you'll need to do a gre.get_data() to get the value. There is no way from Storyboard IO to directly manipulate a Lua Variable. The best way to send data to a Lua function, that isn't needed for manipulating something displayed on the screen, is to create a custom event and send it as event data to the Lua function.

Hope this helps
Jason
User avatar
jason
 
Posts: 152
Joined: Mon Nov 02, 2009 4:53 pm

Re: Using iogen to set an Applicationvariable

Postby timmac » Mon Apr 16, 2012 7:24 am

Jason,

Thanks for the excellent explanation!

Storyboard with all of its' features (LUA scripting, Storyboard IO, etc..) is very powerful.

Thanks again,

Tim
timmac
 
Posts: 42
Joined: Wed Mar 14, 2012 1:21 pm

Re: Using iogen to set an Applicationvariable

Postby timmac » Sun Apr 22, 2012 5:25 pm

How do you create a Custom Event in Storyboard Designer?

I guess I am confused how to link this custom event with the iogen call.

In Storyboard Designer I am able to create a new action, but it needs to be tied to one of
the default events (gre.init, timer.tick, gre.keydown, etc).

Is this where you create a custom event in Storyboard Designer?

Thanks!
timmac
 
Posts: 42
Joined: Wed Mar 14, 2012 1:21 pm

Next

Return to Storyboard Engine

Who is online

Users browsing this forum: No registered users and 0 guests

cron