For with Wait problem!
Andre Silva
Posts: 19
Hello,
I'm trying to send 163 send_string with a interval time of 0.3 to 0.5 seconds but I'm having problems with the WAIT statement.
As NetLinx Help says:
"(...)When a wait statement is executed, it is added to a list of currently active wait requests and the program continues running.(...)"
Here is my Code:
TIMELINE_EVENT[BIAMP_TL_POLL_TIME_ID]
{
SWITCH(TIMELINE.SEQUENCE)
{
CASE 1:
{
LOCAL_VAR INTEGER nCount
FOR(nCount = 101; nCount <= 163 ; nCount++)
{
WAIT 3
{
GetVolBiamp(ITOA(nCount),1,1)
}
}
}
}
}
So my problem is that when the FOR statement start it get right trough the WAIT statement because it takes less than 0.3 seconds to be executed and the only send_string it sends is the last one, the 164 one.
Is there anyway possible to do that without having to type the WAIT statement between a send_strings?
Example.:
TIMELINE_EVENT[BIAMP_TL_POLL_TIME_ID]
{
SWITCH(TIMELINE.SEQUENCE)
{
CASE 1:
{
WAIT 3
{
GetVolBiamp('101',1,1)
WAIT 3
{
GetVolBiamp('102',1,1)
//and repeating this structure until 163...
}
}
}
}
}
}
Thank you.
I'm trying to send 163 send_string with a interval time of 0.3 to 0.5 seconds but I'm having problems with the WAIT statement.
As NetLinx Help says:
"(...)When a wait statement is executed, it is added to a list of currently active wait requests and the program continues running.(...)"
Here is my Code:
TIMELINE_EVENT[BIAMP_TL_POLL_TIME_ID]
{
SWITCH(TIMELINE.SEQUENCE)
{
CASE 1:
{
LOCAL_VAR INTEGER nCount
FOR(nCount = 101; nCount <= 163 ; nCount++)
{
WAIT 3
{
GetVolBiamp(ITOA(nCount),1,1)
}
}
}
}
}
So my problem is that when the FOR statement start it get right trough the WAIT statement because it takes less than 0.3 seconds to be executed and the only send_string it sends is the last one, the 164 one.
Is there anyway possible to do that without having to type the WAIT statement between a send_strings?
Example.:
TIMELINE_EVENT[BIAMP_TL_POLL_TIME_ID]
{
SWITCH(TIMELINE.SEQUENCE)
{
CASE 1:
{
WAIT 3
{
GetVolBiamp('101',1,1)
WAIT 3
{
GetVolBiamp('102',1,1)
//and repeating this structure until 163...
}
}
}
}
}
}
Thank you.
0
Comments
You could also create a recursive function, a function that calls itself, after the wait expires to call your GetVolBiamp function, increment by 1 then call this recursvice functioin to run again if the end hasn't been reached. Be carefull though and make sure there's a definite way out of the loop!
Here's 2 TL examples that I would possibly do that may work for you. I would likely do the 2nd since that sets a busy flag when a string is sent so subsequent strings won't fall on deaf ears (a device not ready).