PDA

View Full Version : Slider info



Stevespaw
May 6th, 2008, 02:26 PM
WoHoo, I have tackeled a bit of Lua and am controlling my lighting system.

I now need to understand the slider functions. Can I do this in one step??


" a variable", " another variable", THIS SLIDER VALUE, " another variable".

All of this string feeds into the variable assigned to the slider.

Thanks,
Steve

Rob H
May 6th, 2008, 03:35 PM
I'm not sure I understand the question.

Stevespaw
May 6th, 2008, 04:07 PM
I understand that basic slider functions. I can set up the parameters and generate a variable, no problem.
Is there some secret syntax that I can add to that "slider" that will add other variable text strings before and after the "slider value" that get generated easily. I cannot add another action to the slider,(which would also work).

clearer?

Thanks,
Steve

Rob H
May 7th, 2008, 02:43 AM
The usual way of dealing with slider variables is to send events to e.g. Girder
To do this you need to register the slider variable for feedback - I prefer doing this with Lua in the .lua file as follows


NetRemote.RegisterVariableWatch('sliderVariableNam e', NetRemote.GetPlugin('Girder')) ;

This will then send events to Girder when the slider is adjusted. If you have more than one Girder plugin instance this will use the current instance that was in force at the time that RegisterVariableWatch was called.

Stevespaw
May 7th, 2008, 08:17 AM
Thanks for the reply Rob, This is not good for me.
I don't have a plugin :-(. I am using the same type of socket connection that others are using for sending rs-232 to the Globalcache. This makes the slider pretty worthless unless you have a plug-in, (From my limited knowledge after I adjust the slider variable I have to do another action to build the new text string to send. I am already doing a similar "watch" function now and it works. BUT, if I change to a different light slider i have to press another button first to "redirect" the slider value.

The best solution for me would be the ability to assign
more actions on "mouse up". This would be perfect. Maybe
someone smarter than me can think of a way to make this work.

Here is the simple funtion that I need:
Every command is a simple text string with 2 or 3 objects (some commands can have more appended options).

"command" "task#" "value"

command = predefined Functions in the system e.g. "load"
task = The Number assigned to the controlled item eg "738"
value = the value sent to the task eg "55"

load 738 55

This is the string I need to send on slider mouse up
Turns on light 738 (in my office) to 55%.

btn 3666

This presses a keypad button (#3666 is a kitchen lighting button) that is programmed in the system.

I can send values to anything in this way, thermostats etc. I need the same for RS-232 audio equipment. As more AV gear is IP enabled this will be a powerful tool. BUT I can't use a slider without more tools. (unless, of course, I don't know what i am doing which is possible. :-))

SLIDER Need #2
I coooooould live without this, but I also need the slider to set its position to a variable. ( I get this information ). Right now the slider goes back to zero when I press another button. This will be a big deal with audio commands.

Thanks for your help,
Steve

Rob H
May 7th, 2008, 08:37 AM
You could perhaps use the other form of NetRemote.RegisterVariableWatch which takes a function as the second parameter e.g.


NetRemote.RegisterVariableWatch('sliderVariableNam e',
function(var, value)
-- do something with the variable and value
end )

One thing to watch out for with this form is what happens if you set the value of the variable in code. The watch function will be called so you may need to put a test in there for this.

Stevespaw
May 7th, 2008, 09:44 AM
Right now I can't see how I can use this.

I need to change 3 variables on a slider TOUCH, with the 3rd one being the actual slider value. The problem is when there are several sliders on a page.

Otherwise I have to:
1. Make a Lua function for each slider ( not really what I wanted to do, I am trying to make this fairly universal using NR variables so I do not need to touch Lua when I am done.)

2. have a "take" buton with the slider that sets the variables for the slider and runs the function. (really ugly :-( )

3. Have a Slider per page that set the variables on page switch> ( uglier than above )

Any ideas ??

Thanks,
Steve

Rob H
May 7th, 2008, 10:13 AM
You can use a named function there e.g.


function HandleSlider(varName, value)
-- process value for varName
end

NetRemote.RegisterVariableWatch('var1', HandleSlider) ;
NetRemote.RegisterVariableWatch('var2', HandleSlider) ;
NetRemote.RegisterVariableWatch('var3', HandleSlider) ;

HandleSlider will be called with the name of the variable and the value

Stevespaw
May 7th, 2008, 10:56 AM
I think I get this, but how am I actually changing the variable on the touch? I see that I can trigger an acceptance of these variables but where will the variables be changed?
eg:
6 sliders on a page to control

4 lights ( slide to 50%)
1 Thermostat ( set to cool 72 degrees )
1 Audio Receiver ( Set volume to 35% )

I need to touch and generate these lines:

action = slide slider 1
load 745 50

action = slide slider 2
load 396 50

action = slide slider 3
load 4367 50

action = slide slider 4
load 20 50

action = slide slider 5
thermtemp 345 cool 72

action = slide slider 6
slider 978 35

Thanks
Steve

harleydude
May 7th, 2008, 11:07 AM
Expanding on Rob's example, it would look something like this.


function HandleSlider(varName, value)
-- process value for varName
local cmd = false
if varName == 'slider1' then
cmd = 'load 745 '..value
elseif varName == 'slider2' then
cmd = 'load 396 '..value
elseif varName == 'slider3' then
cmd = 'load 4367 '..value
end

-- do something with cmd
end

NetRemote.RegisterVariableWatch('slider1', HandleSlider) ;
NetRemote.RegisterVariableWatch('slider2', HandleSlider) ;
NetRemote.RegisterVariableWatch('slider3', HandleSlider) ;

When you change the value of a slider, the HandleSlider routine is called. varName will indicate which slider was changed and value contains the value of the slider variable. Be sure to change the slider1, slider2, etc names to match the name you have assigned to the sliders.

Stevespaw
May 7th, 2008, 11:47 AM
OK now I am getting it
I was just thinking about the if stuff, but I do not really know the syntax of Lua, I am struggling. I can learn by examples though :-)

( thanks for being patient )

What is the syntax for replacing "load 745" with 2 variables
eg "slider1command" and "slider1task" ?

Also, how do I load default NRvariables in NR on startup. Not Lua. ?
This way I can assign what each sliders does.

I am trying this code now.

Thanks again
Steve

Stevespaw
May 7th, 2008, 12:00 PM
OK how do I "do somthing with command"

My Lua function is

function VantageCmd(cmd)

Again I just don't know enough syntax yet.




OK forget it that was easy IT WORKS, WOOOHOOO

Now I just need to get those variables and I am cooking


Steve

harleydude
May 7th, 2008, 12:33 PM
What is the syntax for replacing "load 745" with 2 variables
eg "slider1command" and "slider1task" ?

Assuming slider1command and slider1task are NR variables

function HandleSlider(varName, value)
-- process value for varName
local cmd = false
if varName == 'slider1' then
local command = NetRemote.GetVariable('slider1command')
local task = NetRemote.GetVariable('slider1task')
cmd = command..' '..task..' '..value
elseif varName == 'slider2' then
local command = NetRemote.GetVariable('slider2command')
local task = NetRemote.GetVariable('slider2task')
cmd = command..' '..task..' '..value
elseif varName == 'slider3' then
local command = NetRemote.GetVariable('slider3command')
local task = NetRemote.GetVariable('slider3task')
cmd = command..' '..task..' '..value
end

-- do something with cmd
end

NetRemote.RegisterVariableWatch('slider1', HandleSlider) ;
NetRemote.RegisterVariableWatch('slider2', HandleSlider) ;
NetRemote.RegisterVariableWatch('slider3', HandleSlider) ;

Stevespaw
May 7th, 2008, 01:13 PM
I just figured out a variable method.
Here is what I ended up with for a project that has 15 sliders.
Is there any prblem with doing this?
Again, how do I initialize the variables in NR without making a button?

host commands are what we call the commands and Vids's are the task/load #'s


-- sliders

--load defaults
sl1host =NetRemote.GetVariable("sl1host")
sl1vid =NetRemote.GetVariable("sl1vid")
sl1value =NetRemote.GetVariable("sl1value")
sl2host =NetRemote.GetVariable("sl2host")
sl2vid =NetRemote.GetVariable("sl2vid")
sl2value =NetRemote.GetVariable("sl2value")
sl3host =NetRemote.GetVariable("sl3host")
sl3vid =NetRemote.GetVariable("sl3vid")
sl3value =NetRemote.GetVariable("sl3value")
sl4host =NetRemote.GetVariable("sl4host")
sl4vid =NetRemote.GetVariable("sl4vid")
sl4value =NetRemote.GetVariable("sl4value")
sl5host =NetRemote.GetVariable("sl5host")
sl5vid =NetRemote.GetVariable("sl5vid")
sl5value =NetRemote.GetVariable("sl5value")
sl6host =NetRemote.GetVariable("sl6host")
sl6vid =NetRemote.GetVariable("sl6vid")
sl6value =NetRemote.GetVariable("sl6value")
sl7host =NetRemote.GetVariable("sl7host")
sl7vid =NetRemote.GetVariable("sl7vid")
sl7value =NetRemote.GetVariable("sl7value")
sl8host =NetRemote.GetVariable("sl8host")
sl8vid =NetRemote.GetVariable("sl8vid")
sl8value =NetRemote.GetVariable("sl8value")
sl9host =NetRemote.GetVariable("sl9host")
sl9vid =NetRemote.GetVariable("sl9vid")
sl9value =NetRemote.GetVariable("sl9value")
sl10host =NetRemote.GetVariable("sl10host")
sl10vid =NetRemote.GetVariable("sl10vid")
sl10value =NetRemote.GetVariable("sl10value")
sl11host =NetRemote.GetVariable("sl11host")
sl11vid =NetRemote.GetVariable("sl11vid")
sl11value =NetRemote.GetVariable("sl11value")
sl12host =NetRemote.GetVariable("sl12host")
sl12vid =NetRemote.GetVariable("sl12vid")
sl12value =NetRemote.GetVariable("sl12value")
sl13host =NetRemote.GetVariable("sl13host")
sl13vid =NetRemote.GetVariable("sl13vid")
sl13value =NetRemote.GetVariable("sl13value")
sl14host =NetRemote.GetVariable("sl14host")
sl14vid =NetRemote.GetVariable("sl14vid")
sl14value =NetRemote.GetVariable("sl14value")
sl15host =NetRemote.GetVariable("sl15host")
sl15vid =NetRemote.GetVariable("sl15vid")
sl15value =NetRemote.GetVariable("sl15value")


function HandleSlider(varName, slidervalue)
-- process value for varName
local cmd = false
if varName == 'slider1' then
cmd = sl1host.. ' '.. sl1vid.. ' ' ..slidervalue
elseif varName == 'slider2' then
cmd = sl2host.. ' '.. sl2vid.. ' ' ..slidervalue
elseif varName == 'slider3' then
cmd = sl3host.. ' '.. sl3vid.. ' ' ..slidervalue
elseif varName == 'slider4' then
cmd = sl4host.. ' '.. sl4vid.. ' ' ..slidervalue
elseif varName == 'slider5' then
cmd = sl5host.. ' '.. sl5vid.. ' ' ..slidervalue
elseif varName == 'slider6' then
cmd = sl6host.. ' '.. sl6vid.. ' ' ..slidervalue
elseif varName == 'slider7' then
cmd = sl7host.. ' '.. sl7vid.. ' ' ..slidervalue
elseif varName == 'slider8' then
cmd = sl8host.. ' '.. sl8vid.. ' ' ..slidervalue
elseif varName == 'slider9' then
cmd = sl9host.. ' '.. sl9vid.. ' ' ..slidervalue
elseif varName == 'slider10' then
cmd = sl10host.. ' '.. sl10vid.. ' ' ..slidervalue
elseif varName == 'slider11' then
cmd = sl11host.. ' '.. sl11vid.. ' ' ..slidervalue
elseif varName == 'slider12' then
cmd = sl12host.. ' '.. sl12vid.. ' ' ..slidervalue
elseif varName == 'slider13' then
cmd = sl13host.. ' '.. sl13vid.. ' ' ..slidervalue
elseif varName == 'slider14' then
cmd = sl14host.. ' '.. sl14vid.. ' ' ..slidervalue
elseif varName == 'slider15' then
cmd = sl15host.. ' '.. sl15vid.. ' ' ..slidervalue

end

VantageCmd (cmd)
-- do something with cmd
end

NetRemote.RegisterVariableWatch('slider1', HandleSlider) ;
NetRemote.RegisterVariableWatch('slider2', HandleSlider) ;
NetRemote.RegisterVariableWatch('slider3', HandleSlider) ;
NetRemote.RegisterVariableWatch('slider4', HandleSlider) ;
NetRemote.RegisterVariableWatch('slider5', HandleSlider) ;
NetRemote.RegisterVariableWatch('slider6', HandleSlider) ;
NetRemote.RegisterVariableWatch('slider7', HandleSlider) ;
NetRemote.RegisterVariableWatch('slider8', HandleSlider) ;
NetRemote.RegisterVariableWatch('slider9', HandleSlider) ;
NetRemote.RegisterVariableWatch('slider10', HandleSlider) ;
NetRemote.RegisterVariableWatch('slider11', HandleSlider) ;
NetRemote.RegisterVariableWatch('slider12', HandleSlider) ;
NetRemote.RegisterVariableWatch('slider13', HandleSlider) ;
NetRemote.RegisterVariableWatch('slider14', HandleSlider) ;
NetRemote.RegisterVariableWatch('slider15', HandleSlider) ;


Thanks for the help!
Steve

harleydude
May 7th, 2008, 01:31 PM
You can use a collection of NetRemote.SetVariable(varName, value) to set the variables, but I have a question about that.


sl1host =NetRemote.GetVariable("sl1host")
sl1vid =NetRemote.GetVariable("sl1vid")
sl1value =NetRemote.GetVariable("sl1value")


Do the variables sl1host,sl1vid, sl1value show up in any NR screens?

Stevespaw
May 7th, 2008, 02:20 PM
I now have button that sets all 15 sets, this way I can change whatever I am controlling without ever going into lua.
Can I maybe have a hidden button load on NY start ??
I am putting this in the flatstyle panel as we speak, it is working.

I still need slider position feedback based on a variable.
Any ideas there?


Thanks
Steve

Stevespaw
May 7th, 2008, 02:40 PM
Oops spoke too soon.
I decided to close everything downm and retest.

Now the default variables are not loading. Even with my button that sets the variables for all.


Help?
Steve

Rob H
May 8th, 2008, 07:43 AM
What does that button do?

Stevespaw
May 8th, 2008, 07:52 AM
It does not do anything but set a long list of variables. I would like to make this so the I can go to one place place in NRD and "set" what control the sliders are assigned to.
Is there a way to load these hidden when the CCF loads?


Thanks
Steve

I really appreciate everyones help here, It is awesome how well this is working so far.

Rob H
May 8th, 2008, 08:38 AM
But what sort of variables? Lua variables or NetRemote variables?

I really need to see the whole picture.

Stevespaw
May 8th, 2008, 08:48 AM
My whole Lua code is above.
In the "set defaults" section. My desire is to copy variables that I set in NRD to matching Lua variables.

I have a button in NRD that does nothing, but in the "action designer" sets the text strings contained in these 45 variables.

Thanks

Rob H
May 8th, 2008, 09:05 AM
How are you setting variables in NRD?

Stevespaw
May 8th, 2008, 09:46 AM
4805

Right here

Rob H
May 9th, 2008, 03:07 AM
Personally I'd do all that in Lua - but as harleydude asked you earlier - do all those variables appear in buttons or frames either as displayed text or in state rules? If not then I'd just initialise them as Lua variables.

Stevespaw
May 9th, 2008, 08:26 AM
ok Now I get your HINT.

I wish someone had just said plainly: " NR variables must be displayed or used to be properly initialized". This needs to be stated in the help section with Netremote.Getvariable

Now for a bit of a rant:
As much I see the potential of this product I do not get the target market. I appreciate the help over the last couple of days, but I get the feeling that "I should just be able to work it out". I am not a programmer but I am a pretty bright guy. But the documentation is poor: eg;
I spent a whole day wondering why I could not get this to work from the information in the manual.


[val] = NetRemote.GetVariable([name])

Where does it say or even hint that I need to put Quotes on each side of the "name".? I only figured this out by looking at others examples.

If it wasn't for harleydudes extra help yesterday I would have never gotten my project to work. There need to be a library of examples like his.

Here was another case of poor dumentation; The watcher
The help file:

[Watcher] = NetRemote.RegisterVariableWatch([name], [func])

This indicates that I need to put or do something where the [Watcher] word is in this poor example - I could not figure out for hours what that should be, I finally looked through these forums and figured out that I did not need it. And again when is the indication that quotes are required around the "name" ??
And just when I think I have the quotes figured out, I struggled with single quotes required on others.

This example statement - which works great (thanks harleydude !)


if varName == 'slider1' then
cmd = sl1host.. ' '.. sl1vid.. ' ' ..slidervalue

could never be done correctly looking at the help- just the single quotes on 'slider1' and no quotes on slhost - would throw someone into a tailspin.

I do a lot of different things from flash programming to Autodesk scripts. I am pretty successful, but I rely heavily on help files with useful examples. You folks seem to think that someone has the time to be come a Lua expert, I am sure you are saying "READ THE MANUAL" " or "RTFM" but some proper examples would go a long way. I, like many other potential users do not have time to become Lua programmers. I think if you had a forum where people could post Lua example code it would be a great start.

Ok end of Rant

Thanks again for your help.
Steve

Rob H
May 9th, 2008, 12:12 PM
ok Now I get your HINT.

I wish someone had just said plainly: " NR variables must be displayed or used to be properly initialized". This needs to be stated in the help section with Netremote.Getvariable



Actually, that's not what we're saying at all. Our point was that you were doing more work than was necessary - there's no point having the variables set in NR if you're not going to display them or use them in a state rule.

Point taken about examples, we really do need more of them.

Re: Lua strings - there are three types of quotes used in Lua, single quotes i.e. 'a string', double quotes i.e. "another string" and bracket quotes i.e. [[a third string]]. Most of the time you're perfectly fine with either of the first two. Things start getting a little more complex when it comes to the backslash: in the first two forms of strings you have to use \\ to represent a backslash e.g. in path names. In the third form this is not required so is generally preferred for file pathnames. In other words, to represent the path C:\temp you'd use one of 'C:\\temp', "C:\\temp" or [[C:\temp]].

Stevespaw
May 9th, 2008, 01:23 PM
Actually, that's not what we're saying at all. Our point was that you were doing more work than was necessary - there's no point having the variables set in NR if you're not going to display them or use them in a state rule.

Actually this is the case, as soon as I just show the variables, ( As identifiers on the bottom of each slider ), everything works. After I press that button that loads them, the variables work perfectly now. Now I just need a button that loads once on the load of a CCF.

Steve

Rob H
May 9th, 2008, 01:29 PM
Then something seriously weird is happening in your CCF.

Stevespaw
May 9th, 2008, 02:19 PM
I don't think so really, I do not think that Lua can see a NR variable until it is used in someway, like naming a frame or button with that variable. If I just press that button (see jpg above) that assigns the variables, Lua does not see them. If I name a frame or button with any of those variables, Lua sees the "set" variable just fine.

This is how it seems to work in a very simple CFF with 3 buttons and a slider.

Steve

Rob H
May 9th, 2008, 02:42 PM
I guess that something weird may be happening with the way that these variables are being set by your button, but I really don't see how that's possible.

Can you post your simple CCF so I can take a look at this issue?