Home AMX User Forum NetLinx Studio

XML Question

The XML tools in netlinx look to be serialization type tools. Is anybody aware if I can decode a standard XML file for display on a touchpanel? (This is for streaming an EPG)

Comments

  • champchamp Posts: 261
    No

    Unfortunitely you can only read an XML file originally made with VARIABLE_TO_XML because the result is a structure and you can't TYPE_CAST a structure.

    Using VARIABLE_TO_XML you can turn a structure into XML and then put it on a file. You can get that file off the master and edit the attributes in a text editor, FTP it back onto the master, read it using XML_TO_VARIABLE and there is your new info.

    I'd love a more flexible XML parser like other languages have, but I'm sure AMX have decided that java has the libraries already so if we are that keen then we can do it with DUET.

    So I'm afraid you have to write the parser yourself for the specific EPG you want to read unless some friendly forum member posts one.
  • mpullinmpullin Posts: 949
    Sorry for the thread necromancy, but this is a very valuable post for understanding the true nature of XML_TO_VARIABLE. I'm trying to take an XML file that I have no control over and pull it into variables in my program. Currently I get error -2 every time.

    Does anyone know if there is a Duet module written for XML parsing yet, or will I have to do my own parsing?
  • hodeyphodeyp Posts: 104
    no need for a duet parsing module as duet is java and java has all of the xml tools you would ever need.

    What we really need is a generic netlinx xml parser. its a bit confusing at present with AMX promoting the use of DUET for device modules but netlinx being used to pull everything together. I am presuming at some point the netlinx piece will go away and the controllers will just speak java?
  • jjamesjjames Posts: 2,908
    I don't have a module or anything, but I use this simple little piece of code to parse RSS/XML.
    c_ICONS[6][1] = 
    		REMOVE_STRING(cCURRENT_CONDITIONS,'</icon>',FIND_STRING(cCURRENT_CONDITIONS,'<icon>',1))
    	REMOVE_STRING(c_ICONS[6][1],'<icon>',1)
    	REMOVE_STRING(c_ICONS[6][1],'</icon>',
    		FIND_STRING(c_ICONS[6][1],'</icon>',1))
    
  • dbfreqdbfreq Posts: 9
    Limitations of TCP / XML

    Is it possible to construct a string for a serial command on another machine (complete with d/p/s) and pass it to an NI via TCP (via XML, HTTP Post, etc.), have the NI relay the command to a physical device at the specified d/p/s and pass the physical device's response back to the machine that sent the original command, using either Netlinx or Java?

    Thanks.
  • viningvining Posts: 4,368
    dbfreq wrote:
    Is it possible to construct a string for a serial command on another machine (complete with d/p/s) and pass it to an NI via TCP (via XML, HTTP Post, etc.), have the NI relay the command to a physical device at the specified d/p/s and pass the physical device's response back to the machine that sent the original command, using either Netlinx or Java?
    Depends on the original machine. If the original machine is capable of both sending and recieviing strings and you have the capability to write in what ever language that machine uses and have the access to modify or add to its running script then yes. The Netlinx side can definitely do it.
  • dbfreqdbfreq Posts: 9
    I think I confused myself earlier. I was under the impression that information needed to be passed to an NI via XML. A little more reading and I now think that if a computer is connected to an NI via TCP, the two can maintain a connection and pass ASCII strings back-and-forth without encoding and decoding XML. Is this correct?

    My aim is to do as much processing and variable storage on the PC as possible (essentially just using the NI as a conduit or an interpreter to help the computer speak to the physical devices attached to the NI). Can I, on the PC:

    1. Create a button called Power ON.
    2. Write code such that once the button is pressed, a string is compiled and sent to the NI to turn on a serial-controlled device.
    3. Have the NI automatically push feedback it receives from serial devices back to the computer over the TCP connection?

    If so, is the string the computer needs to compile and pass to the NI any different than what would be written in NetLinx Studio? For example, if I want to power on a receiver using 'P1P1' and the receiver is connected to the first serial port of an NI-3101 on a single master system, what would the string to be compiled by the PC need to look like?

    I'm sorry if any of this is just plain wrong or silly, but this is all very new to me and I'm trying to get my head around it as quickly as possible.

    Thanks.
  • viningvining Posts: 4,368
    You could create something in HTML w/ Flash (search for for forum links) or HTML w/ PHP or possibly use the AMX virtual keypad that runs on a PC w/ feedback. The simplest is to just VNC into a TP from a PC or use the G3 web control (search for for forum links).

    How deep do you want to get? It sounds like the virtual keypad app would do want you want if you don't have a TP to VNC into.
  • Chip MoodyChip Moody Posts: 727
    If you're talking about writing a PC application that's essentially acting like a front end for a processor, you can do it any way you like - there's no wrong or right - just a matter of which will be easier to implement for/by you.

    If you're more comfortable with PC code, you can come up with a little Netlinx program that takes commands (of your syntax/formatting) and perhaps re-interprets/translates them before sending them out a com port to a device. If you're just as good with Netlinx, you might want to just write a fully-functioning Netlinx program and create a simple simple simple PC application that behaves more like a touch panel - when you click a button on the PC app, it sends a "button xyz was pushed" message to the Netlinx program. Same thing goes for the release of a button. Feedback would work the same - your Netlinx code determines that your display has powered on (for example) and sends a "light up button xyz" message to your PC app. The app gets that and says "okay, cool - I'll light up the 'power' button"...

    Ultimately though, it's your call.

    It also sounds like there's a possibility that you're making way too much work for yourself by needing to write two programs. Could you get away with connecting devices to a PC and controlling them by a single app running on the PC? Com ports are easy to come by. You can get IR driver cards and relay cards as well. No one here but you knows what you're trying to accomplish, so that may or may not be an option for you to consider.

    - Chip
  • dbfreqdbfreq Posts: 9
    Thanks for the response.

    I'm interested in writing an app using Objective-C / Cocoa for Mac OS X. I'm much more comfortable writing in Obj-C than NetLinx (we're an AMX dealer, but we sub out our programming, so I don't know much about it).

    There's another device on the market called a Waci, by Aurora Multimedia. It takes HTTP Posts and fires IR, relay, serial, etc., through to connected components. I was playing with this for a while, but don't really like the polling required to update status in the Obj-C program. When I found out that you could communicate with an AMX controller via TCP/IP, I thought that would be a more reliable, faster connection with less mess. So, I'm hoping to find a formula for creating strings to send to the AMX controller that would cause it to send IR/Serial/relays, etc. to connected equipment. Something like:

    [Send_String dvRCVR, 'P1P0']

    To send the string 'P1P0' to the serial port connected to a receiver (this would hopefully also return the receiver's response without being prompted for it). Or,

    [Send_IR dvVCR, 'play']

    to send the play command to the IR port connected to the VCR's IR emitter.

    Creating formulaic strings and storing and retrieving variables in Obj-C would be much easier and faster for me, so, I'm trying to keep the NI as dumb as possible.

    I've seen some serial cards and USB devices for OS X, but haven't been able to find a PCI or USB device with multiple IR emitters.
Sign In or Register to comment.