Can a device only have one buffer message?
mjones2620
Junior Member
Trying to read/write to a file for names & numbers. I have tried creating a buffer which didn't work, and data.text clears out other messages as they come in. Never the less, this doesn't work:
How can I hold a value in one buffer without clearing the other? Is this possible?
BUTTON_EVENT[dcNAMES]
{
PUSH:
{
nCURRENT_NAME = GET_LAST(dcNAMES)
TO[BUTTON.INPUT]
}
HOLD[20]:
{
SEND_COMMAND dvTP,"'@AKB-',uPRESETS[nCURRENT_NAME].cNAMES"
}
RELEASE:
{
WAIT_UNTIL(nDONE)
{
uPRESETS[nCURRENT_NAME].cNAMES = cDATA
SEND_COMMAND dvTP_VTC,"'^TXT-',ITOA(nCURRENT_NAME + 499),',0,',uPRESETS[nCURRENT_NAME].cNAMES"
fnWRITE_FILE('VTC Presets.csv')
}
}
}
BUTTON_EVENT[dcNUMBERS]
{
PUSH:
{
nCURRENT_NUM = GET_LAST(dcNUMBERS)
TO[BUTTON.INPUT]
}
HOLD[20]:
{
SEND_COMMAND dvTP,"'@AKP-',ITOA(uPRESETS[nCURRENT_NUM].nNUMBERS)"
}
RELEASE:
{
WAIT_UNTIL(nDONE)
{
uPRESETS[nCURRENT_NUM].nNUMBERS = nDATA
SEND_COMMAND dvTP_VTC, "'^TXT-',ITOA(nCURRENT_NUM + 603),',0,',uPRESETS[nCURRENT_NUM].nNUMBERS"
fnWRITE_FILE('VTC Presets.csv')
}
}
}
How can I hold a value in one buffer without clearing the other? Is this possible?
Comments
-
You can put the get_last statement in both the Hold and release events too.
-
Not sure what you are trying to do here, but I would strongly advise against using wait_until in a button event. Its not incorrect but can lead to some difficult to find bugs. Having written AMX code for 10 years, I've never used it once, nor needed to.
Paul -
ericmedley wrote: »You can put the get_last statement in both the Hold and release events too.
Ahhh, this worked. THANKS! -
Not sure what you are trying to do here, but I would strongly advise against using wait_until in a button event. Its not incorrect but can lead to some difficult to find bugs. Having written AMX code for 10 years, I've never used it once, nor needed to.
Paul
I'm parsing the message in the keyboard/keypad and I don't want it to write to file until after the message is parsed. Putting the Get_last in my release statement worked.
This was code tweaked from my P2 class... they tought us WAIT_UNTIL. I kind of like it. -
mjones2620 wrote: »I'm parsing the message in the keyboard/keypad and I don't want it to write to file until after the message is parsed. Putting the Get_last in my release statement worked.
This was code tweaked from my P2 class... they tought us WAIT_UNTIL. I kind of like it.
I would agree with a_riot42. If you are parsing for a data string from a UI upon keypad/keyboard entry, I'd probably initiate it in the data_event and then call a function. For example: what happens if the user hits abort on the keypad? Or the panel goes offline? Stuff like that...
I'm glad the fix worked.
-
ericmedley wrote: »I would agree with a_riot42. If you are parsing for a data string from a UI upon keypad/keyboard entry, I'd probably initiate it in the data_event and then call a function. For example: what happens if the user hits abort on the keypad? Or the panel goes offline? Stuff like that...
I'm glad the fix worked.
If user hits abort I am using the CANCEL_ALL_WAITS function. -
mjones2620 wrote: »If user hits abort I am using the CANCEL_ALL_WAITS function.
I wouldn't recommend that. What if you need a wait elsewhere that shouldn't be affected? And what if one gets added 6 months from now, and you forget the cancel_all is in there? -
mjones2620 wrote: »If user hits abort I am using the CANCEL_ALL_WAITS function.
Cancel_all_waits and wait_until should be forgotten and never used. As soon as you think you need them to make something work you should throw out what you've written, get a good night's sleep and start from scratch in the morning.
-
If you're trying to use a single data event handler to process multiple devs you could do something like this for populating and processing your buffers:
DEFINE_DEVICE dvDevice_1 = 5001:1:0; dvDevice_2 = 5001:2:0; dvDevice_3 = 5001:3:0; DEFINE_CONSTANT NUM_DEVs = 3; DEV dvDev_Arry[NUM_DEVs]= { dvDevice_1 ,dvDevice_2 ,dvDevice_3 } DEFINE_VARIABLE CHAR cDev_Buffers[NUM_DEVs][2048]; DATA_EVENT[dvDev_Arry] { ONLINE: { //initialize devs } STRING: { STACK_VAR INTEGER nIndx; nIndx = GET_LAST(dvDev_Arry); cDev_Buffers[nIndx] = "cDev_Buffers[nIndx],DATA.TEXT"; if(find_string(cDev_Buffers[nIndx],"$0D,$0A",1)) { //pass the index to the parsing function so you know which dev you're processing fnParseBuffer(nIndx,REMOVE_STRING(cDev_Buffers[nIndx],"$0D,$0A",1)); } } }
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
