Modules, Virtual Devices & DevChans..
RichieG
Junior Member
Hey guys..
I'm starting to take a more modular approach to my programming, (was inspired by some of the AMX modules for Polycom, which included a user interface module)., and i'm running into a few problems.
Basically, what all i really want to do, is have all my modules setup so that all I have to do is pass a Touch Panel and a Device to them, and they will be controlled to my standard.
ie..
In Main.axi
DEFINE_DEVICE:
dvTP = 10001:1:1 // Main touch panel functions
dvTP_ControlledDevice = 10001:2:1 // functions for the device i want to control..
dvControlledDevice = 5001:1:1 // actual RS232 port for device
DEFINE MODULE 'My Module' Blah (dvTP_ControlledDevice, dvControlledDevice)
in MyModule:
DEFINE_MODULE 'My Module' (dvTP, dvDevice)
ok.. so that all works fine...
Now suppose I want to declare a DEV_CHAN in the Module, which references dvTP..
ie..
DEFINE_VARIABLE
DEV_CHAN Interface_Buttons[] = {{dvTP, Button_1},
{dvTP, Button_2}}
This won't compile, because it claims that dvTP isn't a Constant.
So to get around this... i've put in :
DEFINE_DEVICE:
vdTP = 33001:1:1
DEFINE_VARIABLE
DEV_CHAN Interface_Buttons[] = {{vdTP, Button_1},
{vdTP, Button_2}}
DEFINE_COMBINE
(vdTP, dvTP)
Now, this compiles fine.. But i'm not extremely happy with it..
It basically means that i'm going to have to select a range of numbers for all my Virtual Devices (say.. from 35001 - 36000), and increment the number each time i add a new Module to my libary.
This is OK, but i would prefer a more dynamic way to do it.
Any ideas?
I'm starting to take a more modular approach to my programming, (was inspired by some of the AMX modules for Polycom, which included a user interface module)., and i'm running into a few problems.
Basically, what all i really want to do, is have all my modules setup so that all I have to do is pass a Touch Panel and a Device to them, and they will be controlled to my standard.
ie..
In Main.axi
DEFINE_DEVICE:
dvTP = 10001:1:1 // Main touch panel functions
dvTP_ControlledDevice = 10001:2:1 // functions for the device i want to control..
dvControlledDevice = 5001:1:1 // actual RS232 port for device
DEFINE MODULE 'My Module' Blah (dvTP_ControlledDevice, dvControlledDevice)
in MyModule:
DEFINE_MODULE 'My Module' (dvTP, dvDevice)
ok.. so that all works fine...
Now suppose I want to declare a DEV_CHAN in the Module, which references dvTP..
ie..
DEFINE_VARIABLE
DEV_CHAN Interface_Buttons[] = {{dvTP, Button_1},
{dvTP, Button_2}}
This won't compile, because it claims that dvTP isn't a Constant.
So to get around this... i've put in :
DEFINE_DEVICE:
vdTP = 33001:1:1
DEFINE_VARIABLE
DEV_CHAN Interface_Buttons[] = {{vdTP, Button_1},
{vdTP, Button_2}}
DEFINE_COMBINE
(vdTP, dvTP)
Now, this compiles fine.. But i'm not extremely happy with it..
It basically means that i'm going to have to select a range of numbers for all my Virtual Devices (say.. from 35001 - 36000), and increment the number each time i add a new Module to my libary.
This is OK, but i would prefer a more dynamic way to do it.
Any ideas?
Comments
-
you can create virtual devices in a dynamic way:
DEFINE_DEVICE
vdTP = DYNAMIC_VIRTUAL_DEVICE
The DYNAMIC_VIRTUAL_DEVICE will create a virtual device in a range from 36865 and up. Adding more devices in this way will just add up to the 36865.
Hope this helps,
Marc -
Re: Modules, Virtual Devices & DevChans..Originally posted by RichieG
DEFINE_VARIABLE
DEV_CHAN Interface_Buttons[] = {{dvTP, Button_1},
{dvTP, Button_2}}
This won't compile, because it claims that dvTP isn't a Constant.
Well, there's a NetLinx subtelty at work here. Only constants are allowed in variable initializers. dvTP is not since it is a module parameter. Hence the complain.
What you can do:
DEVINE VARIABLE
DEV_CHAN Interface_Buttons[2];
DEFINE_START
Interface_Buttons[1].device = dvTP:
Interface_Buttons[1].channel = Button_1;
...
Unless you use REBUILD_EVENTS, the assignation HAS to happen in define start otherwise any events on the devchans won't work.
Hope this helps
Fred -
I generally just pass an array of integers comprised of the button channels as a parameter as well. This also makes it possible to change those channels per job in the event of panel design constraints and/or conflicts with pre-existing stuff. The module acts off the index in the array rather than the actual button channel. I usually take it a step further and pass my panel in an array as well, even if there is just one in the job. If the code it written for this, it makes it trivial to add new panels later in the job.
-
ASSIGNATION? Is that a word? -LOL
As for modules I do the same thing. One INT array for buttons one DEV array for panels, then pass it on through. -
Originally posted by Irvine_Kyle
ASSIGNATION? Is that a word?[/QUOTE
From webster.com (from their FAQ: Merriam-Webster is America's foremost publisher of language-related reference works):
Main Entry: as?sig?na?tion
Function: noun
1 : the act of assigning or the assignment made
2 : an appointment of time and place for a meeting; especially : TRYST <returned from an assignation with his mistress -- W. B. Yeats>
and the verb "assign" mentioned in 1.:
Main Entry: as?sign
Function: transitive verb
Etymology: Middle English, from Old French assigner, from Latin assignare, from ad- + signare to mark, from signum mark, sign
1 : to transfer (property) to another especially in trust or for the benefit of creditors
2 a : to appoint to a post or duty <assigned them to light duty> <assigned me two clerks> b : to appoint as a duty or task <assigns 20 pages for homework>
3 : to fix or specify in correspondence or relationship <assign counsel to the defendant> <assign a value to the variable>
4 a : to ascribe as a motive, reason, or cause especially after deliberation b : to consider to belong to (a specified period of time)
Item 3 specifically covers the case we're discussing (giving a value to a variable).
So yes, that's a word, and I'd even go as far as to say it is a very appropriate one for the context.
Don't you think one learns a lot reading these forums? :-)
Fred -
SO IS A PERSON OR THING THAT IS DOING THE ASSIGNATION THE UMM ASSIGNATOR?
-
Webster says assigner or assignor.
-
Thanks for all your help guys, you've given me a few idea's..
I'll try a few things, and see what works best for me.. -
Virtual Device 41000????
Lately it seems like many of the duet module I am using all have their virtual devices around the 40000:1:0 range.
The autopatch module help file says "NetLinx virtual devices for Duet modules are constrained to the range 41000:1:0 to 42000:1:0"
However tech note 310 says,"32768-36863 Virtual devices Actual range used by master"
Can someone explain what is going on here? What is the max value for virtual devices and can you only use 41000 up to 42000 for defining a virtual device for the autopatch module? -
32768-36863 is the range for Netlinx virtual devices.Lately it seems like many of the duet module I am using all have their virtual devices around the 40000:1:0 range.
The autopatch module help file says "NetLinx virtual devices for Duet modules are constrained to the range 41000:1:0 to 42000:1:0"
However tech note 310 says,"32768-36863 Virtual devices Actual range used by master"
Can someone explain what is going on here? What is the max value for virtual devices and can you only use 41000 up to 42000 for defining a virtual device for the autopatch module?
41000-42000 is the range for DUET virtual devices according to the DUET module docs that I?ve read although the sample code always seems to start at 41001.
Tech note 310 was written before the birth of DUET.
If you are using a DUET module then you have to use the DUET virtual device range. A Netlinx module has to use the Netlinx virtual device range. The system treats DUET virtual devices numbers differently then Netlinx virtual device numbers.
HTH -
Thank You Joe. Great info
-
Once there was a man, a dragon man, assigninating the countryside...Irvine_Kyle wrote: »SO IS A PERSON OR THING THAT IS DOING THE ASSIGNATION THE UMM ASSIGNATOR? -
Once there was a man, a dragon man, assigninating the countryside...
... thatch-roofed cottages ... -
burninating the peasantsDHawthorne wrote: »... thatch-roofed cottages ... -
Basically, what all i really want to do, is have all my modules setup so that all I have to do is pass a Touch Panel and a Device to them, and they will be controlled to my standard.DHawthorne wrote: »I generally just pass an array of integers comprised of the button channels as a parameter as well.
It is not very "Modular" to have your devchans declared inside your module. DHawthorne is correct!!!! Everything that needs to change, and or be flexable needs to be declared in your main program and passed into your module. Like DevChans, Device List, etc... DYNAMIC_VIRTUAL_DEVICE was developed for other reasons and I personally do not believe it should be used in a module except for that orginal purpose, which I wont discuss here...
// Pick your poison...MODULE_NAME='Blah Blah Blah UI' (DEV vdvCommDev, DEV dvPanelArray[], INTEGER nButtonArray[], INTEGER nVarTextArray[])
MODULE_NAME='Blah Blah Blah UI' (DEV vdvCommDev, DEV dvPanel, INTEGER nButtonArray[], INTEGER nVarTextArray[])
MODULE_NAME='Blah Blah Blah UI' (DEV vdvCommDev, DEVCHAN dcButtonArray[], DEVCHAN dcVarTextArray[])
-
MODULE_NAME='Blah Blah Blah UI' (DEV vdvCommDev, DEV dvPanelArray[], INTEGER nButtonArray[], INTEGER nVarTextArray[])
MODULE_NAME='Blah Blah Blah UI' (DEV vdvCommDev, DEV dvPanel, INTEGER nButtonArray[], INTEGER nVarTextArray[])
MODULE_NAME='Blah Blah Blah UI' (DEV vdvCommDev, DEVCHAN dcButtonArray[], DEVCHAN dcVarTextArray[])
What aboutMODULE_NAME='Blah Blah Blah UI' (DEV vdvCommDev[], DEV dvPanelArray[], INTEGER nButtonArray[], INTEGER nVarTextArray[])
Paul
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums