REBUILD_EVENT Problems
Spire_Jeff
Posts: 1,917
First, here is the code:
Now the problem... As you see, I put in a wait 30 in front of the REBUILD_EVENT command to try and fix things. This function is called 3 to 10 times at boot (depending on the job). When this is called, the processor seems to hang for 10 minutes or more. It is really just rebuilding the events as far as I can tell. I had to severely delay the call of this function because it was causing the processor to miss a bunch of the commands sent to modules in the device ONLINE event. This meant a bunch of settings for the modules were lost and the modules did not initialize properly.
Does anyone have any tips for taming the REBUILD_EVENTS command? From the documentation, I thought that it was restricted to the variable(s) within the {}s that contain it, but it seems like it must be rebuilding everything with the time it is taking.
Any help is appreciated,
Jeff
define_function fnInitFavDevice(dev myFBDev, dev myControlDev,integer myDevIndex, integer myEnterChan, integer myDashChan, char myFileName[], integer myDevType){ nFavDevInsertPtr++ if(nFavDevInsertPtr and nFavDevInsertPtr < 31){ vdvFbBoxes[nFavDevInsertPtr] = myFBDev; dvBoxes[nFavDevInsertPtr] = myControlDev; nBoxMode[nFavDevInsertPtr] = myDevIndex; nDevDashBtn[myDevIndex] = myDashChan; nDevEnterBtn[myDevIndex] = myEnterChan; nDevType[myDevIndex] = myDevType; sDevFilenames[myDevIndex] = myFileName; wait 30 REBUILD_EVENT(); //This should fix the channel event to populate favs on devices as they are selected. #warn 'Check here if probs when selecting devices with favs'; fnReadFromFile(myDevIndex); } }
Now the problem... As you see, I put in a wait 30 in front of the REBUILD_EVENT command to try and fix things. This function is called 3 to 10 times at boot (depending on the job). When this is called, the processor seems to hang for 10 minutes or more. It is really just rebuilding the events as far as I can tell. I had to severely delay the call of this function because it was causing the processor to miss a bunch of the commands sent to modules in the device ONLINE event. This meant a bunch of settings for the modules were lost and the modules did not initialize properly.
Does anyone have any tips for taming the REBUILD_EVENTS command? From the documentation, I thought that it was restricted to the variable(s) within the {}s that contain it, but it seems like it must be rebuilding everything with the time it is taking.
Any help is appreciated,
Jeff
0
Comments
Was REBUILD_EVENT() taking along time when using the wait or when not using the wait? I've never used a wait with rebuild_event so I wonder if it sees the braces with the wait in place, when it executes maybe it can't see above the wait and if it doesn't see anything specific to rebuild maybe then it goes ahead and rebuilds all the event tables?
As for the wait 30, I was using that to prevent multiple REBUILD_EVENT runs. The code that calls the function uses a wait 3000 which starts after the virtual device comes online. When that happens, it calls the function a bunch of times, and I wanted to rebuild only after the last change to the array. I changed my function to reflect this. I also added the send_string 0 commands to get an actual runtime. Here is the readout from the diagnostics window:
As you can see, the REBUILD is taking almost 8 minutes. During this time, no NetLinx code is executed, but it seems that the Java code keeps on ticking (the Carrier is a Duet module).
Any thoughts?
Also, here is the calling code, in case this helps:
Thanks,
Jeff
Paul
I think I need it because the devices are set in code, not in the variable declaration. The code is not run until after the processor has booted, but it is not changed on the fly. Based on the code, the compiler could make a good guess at what is going to be in the variables as it would not change from compile time to execution, I just didn't think the compiler did that much optimization.
Jeff
= 5 minutes. Is that what you intended, or only 30 seconds?
You may also want to try moving the rebuild event statement for the affected device out to a function along with the equate in an attempt to reduce the scope of the event table changes:
Why are they set in code if they never change?
Paul
They change from job to job and when a client adds/removes devices. This more about convenience for me and others and if it really takes this long to rebuild the events, I can live with it. I just wanted to make sure I am not doing something wrong. Now that I have it so the processor isn't broken because of the code, I can wait the extra few minutes as it only occurs during the boot sequence.
I did intend for 5 minutes. The processor takes some time to boot and I wanted to make sure I was well past the point of other boot code executing. I had problems when the rebuild happened too soon (mainly, modules that are passed parameters never receiving the parameters).
Jeff
Paul
Thanks for all of the help. In the least, this thread forced me to rewrite the function to only run rebuild_events once and (according to documentation) on the appropriate variable.
Jeff
WAIT x
You might want to consider a:
WAIT_UNTIL (nInitialized)
Where nInitialized is a variable that is set to 1 when you know your other startup code is ready to go.
You might also want to consider offloading the DUET modules to another processor and see if that helps.
I don’t know enough about your code but you may also want to look at using preprocessor directives if you haven’t already. Something like:
I would have thought that as long as the variable didn't change, it would still work.
The other alternative would be to leave the array in question alone and track it a different way using another array of integers. This is what I typically do. I don't like to mess with the event table at runtime so rather than manipulate devices in arrays that are also used in event declarations, I manipulate an array of integers that corresponds to the array of devices. This may be hard to refactor into a running system though without a lot of work.
Paul
IIRC there was an interesting quirk with the lockup, in that it would not occur on the reboot immediately after after a code transfer, but would occur on subsequent reboots. Bizarre.
Roger McLean
Swinburne University