How do I include a module?
dmurray14
Posts: 80
Hey guys,
Trying to make a module out of the code here: http://www.ryanwright.com/automation/amx_cm11a_v1.0.txt
But I'm really confused. What do I need to do to be able to include this as a module and modify the X10_COMMAND string from my main source?
Thanks!
Dan
Trying to make a module out of the code here: http://www.ryanwright.com/automation/amx_cm11a_v1.0.txt
But I'm really confused. What do I need to do to be able to include this as a module and modify the X10_COMMAND string from my main source?
Thanks!
Dan
0
Comments
Remove the define_device from the code and add:
put the corresponding module definition in your mainline:
In your external code send a command like so:
You will probably want to send commands from inside a control module rather than from the mainline so put vX10 in the header of the control module too.
I think that answers your question but the module definitely isn't how I would code it.
The code was written for Axcess not NetLinx. It still mostly works in NetLinx but it is designed to be an include in a single mainline rather than a module. That's why, for instance, all the variables begin with X10_ which is unnecessary if you are in a module called X10, but necessary if you are sharing code space with a bunch of other includes.
That's also why everything is in define_start and define_program when NetLinx conventions put almost everything in the define_event while the actual code lives in define_functions.
The SET BAUD command needs to be in the online event of the physical device and will not work otherwise.
I would also add some sort of a command queue. I think that as the code stands, if you send the module three commands in a row, the first will get sent to the unit, the second will be delayed while the module waits for the reply to the first, and the third will overwrite the second causing it to be lost.
I would also consider adding modest WAITs to the define_program code chunks.
(NB above code uncompiled and untested.)
Thanks,
Dan
(Did I really just write that?)