New and Needy
Nomski
Posts: 4
Hi guys, I'm new to all this and I'm trying to figure out how to do this AMX programming malarky!
I'm using an NI700 a tablet by Hannspad with TPControl on the demo licence and I'm trying to control an NEC300W projector. I'm not doing to badly, i've got the thing switching on and off and switching inputs. What I can't quite figure out is how see the responses from the projector so I can start doing some feedback.
Is there a simple way to see what the projector is responding with after I send it a string? As far as I know all this info goes to data.text but can't seem to monitor the data.
Help would be gratefully received!
I'm using an NI700 a tablet by Hannspad with TPControl on the demo licence and I'm trying to control an NEC300W projector. I'm not doing to badly, i've got the thing switching on and off and switching inputs. What I can't quite figure out is how see the responses from the projector so I can start doing some feedback.
Is there a simple way to see what the projector is responding with after I send it a string? As far as I know all this info goes to data.text but can't seem to monitor the data.
Help would be gratefully received!
0
Comments
Or, program a string handler into a data event.
This is all explained in the documentation.
+add your device in the list. Deselect the notification messages for "All" devices and select only the In and Out Strings for your device
you should know how to do that if you had the Programmer I and Programmer II courses. Or even if you don't:
Kostas
Somewhere in the miasma that is these forums there is a reference to a Netlinx primer, but I can't find it and the search function in these forums sucks so bad that I have little hope of finding it. Perhaps someone not quite so brain dead as I will post a link.
It's Friday afternoon. If you've never seen an AMX system, and even if you can't spell it, if someone gave you a basic system to program by Monday, you should be able to figure it out with the documentation easily available on the web site. If you can't, hire somebody.
Call me Curt.
Harold
edit:
I have attached a zip file which contains a pdf of a document that was available on the AMX site back in 2004. It wasn't a help to me at the time, but it may be to you as it explains a whole lot of Netlinx programming concepts, including at least a bit about string handlers in data events.
Ok so I've got a lot further thanks to Hedberg's PDF gift. I am now able to use the first location in data.text or a buffer to get button feedback on my panel. The odd bit is that none of the other locations work. I.e.in the watch window I can see what is in my buffer and it's 22 individual hex bytes. I know which ones are the ones I need and to test them I am using a little switch case to try and get a location to turn on a button. It's not pretty but I'm just trying to get it to work so I know I'm getting something right.
data_event [dvProj]
{
STRING:
{
cmybuffer = data.text
SWITCH (cmybuffer[2])
{
case 'BF': on [dvtp,1]
case '$BF': on [dvtp,2]
case 'OH MY GOD WHY ISN'T THIS WORKING!': on [dvtp,3]
}
}
}
In the watch window I can see the 22 byte response and the only one that reacts to anything is byte number 1. So, if my bit of testing code says" says:
data_event [dvProj]
{
STRING:
{
cmybuffer = data.text
SWITCH (cmybuffer[1])
{
case 'BF': on [dvtp,1]
case '$BF': on [dvtp,2]
case ' ': on [dvtp,3]
}
}
}
It works on button 3.
Anything else doesn't work. The second location in the buffer (according to the watch window) is "BF" and with or without the $ sign it simply doesn't work.
Any ideas? I'm losing my mind!
Check page 60 in the manual.
Thanks you so much, I was pulling my hair out! On page 60 it says;
"the SWITCH expression is tested against each CASE value (which must be a numeric constant or a
string literal)."
So surely that means that you can use the ' ' for string literals? Either way, it works now so I'm very happy!
Just got to do some level events and I'm laughing, cue more epic trauma!
I'm sorry if I appear stupid but I do really appreciate the help I've had on here so far.
So, with the tip from JJames, your code will be:
or even:
Kostas
P.S. While you were writing your response i was also writing my post So, it really nice to know your code worked !
That won't cause compiler errors. You can have a single character and multiple characters as long as you put them in the order that you did with the single character at the end.
This will cause a compiler error:
Just remember smallest at the bottom.
If you are looking to match strings of varying length, SWITCH..CASE seems to be the fastest. Here are some benchmark results: http://www.amxforums.com/showthread.php?5307
You have to look at the last set of results for the strings of various lengths results.
If you have a situation where there are multiple conditions, but only 1 or 2 occur the majority of the time, it might be faster to use a SELECT..ACTIVE.
Jeff
I made also some tests myself but not as thoroughly as yours. Only with numeric data types and for quite large arrays. My results showed me that SWITCH..CASE was slightly slowest than the other 2 methods. IF..ELSE and SELECT..ACTIVE were the same (something like comparing 0.0002 to 0.0003).
Totally agree with you. And also i agree with what you pointed out in the thread you suggested to me:
At the end of the day i am using different methods for different things.
SWITCH..CASE for collapsing results
SELECT..ACTIVE when i mix a lot of conditions and evaluated expressions in the same block
and
IF..ELSE for quick comparisons.
Kostas