I have a problem to register UAQ that does not exist during first time initialisation.
The function ApocSubscribe registers all UAQs that are known.
ApocSubscribe(sid, SUBS_ITEM_COUNT, subs, 100, 1, (ModuleFrequency<=0||ModuleFrequency>=1000)?1:(1000/ModuleFrequency), 0);
If I attach sign sensor, the particular signs are not accessible until they are not sight for first time.
I have found one solution, to resize subscribe array every time when any used sensor enlarges:
if(FrontSensorQuantities<signInfraDetCount || RearSensorQuantities<signInfraDetCount ||
LeftLineCount>SubsLeftLineCount || RightLineCount>SubsRightLineCount)
{
//ApocSubscribe(sid, 0, NULL, 0, 0, 0, 0); // Detach all subscriptions?
tApoSubscription *subs2 = subs + SUBS_ITEM_COUNT;
FrontSensorQuantities = PrepareSignQuantities(subs2, FRONT_Sign, signInfraDetCount);
subs2 += FrontSensorQuantities*SUBS_SIGN_PROP_COUNT;
RearSensorQuantities = PrepareSignQuantities(subs2, REAR_Sign, signInfraDetCount);
subs2 += RearSensorQuantities*SUBS_SIGN_PROP_COUNT;
SubsLeftLineCount = PrepareLineQuantities(subs2, LEFT_Line, LeftLineCount);
subs2 += SubsLeftLineCount*SUBS_LINE_PROP_COUNT;
SubsRightLineCount = PrepareLineQuantities(subs2, RIGHT_Line, RightLineCount);
subs2 += SubsRightLineCount*SUBS_LINE_PROP_COUNT;
i = subs2 - subs;
i = ApocSubscribe(sid, i, subs, 100, 1, (ModuleFrequency<=0||ModuleFrequency>=1000)?1:(1000/ModuleFrequency), 0);
if(i != 0)
{
fprintf(stderr,"ApocSubscribe() failed with error code %d!\n", i);
}
}
This seems to be too clumsy. May be that this is the only way, how to do this task.
Is it neccessary to detach all registered subscriptions first?
ApocSubscribe(sid, 0, NULL, 0, 0, 0, 0); // Detach all subscriptions?
It seems that one application could use only one list of subscriptions.