
Originally Posted by
FMode

lets have a look if I have understood...
Here comes the **** (B after A and B with missed B header) (ft=89,3):
(A) #4 100,1
(A) 91,6 102,1
xx
xx
xx
(B) 89,3 91,6
(B) 89,3 102,1
(B) 88,0 89,3
(next B) #4 89,3
...
This is a crappy A sequence because it contains ft (89,3)
so: discard
... I hope I'm wrong and that you have gotten something that I have not, but first of, there is now way of telling if 89.3 is valid or unvalid in the A sequence (or is there?..) Secondly, If I havn't received the B header yet, I don't know if the 83.9 belongs to another header or not.
What I could do though is to only save a complete sequence. But I don't really like throwing away data since I may take a really long time before I can get it complete...

Originally Posted by
FMode
or:
(A after B case) doesn't contain excatly 4 times ft (89,3) as stated in the B header.
so: discard
without errors looks it would like that:
(A) #4 100,1
(A) 91,6 102,1
(A) 88,0 #205
(B) #4 89,3
(B) 89,3 100,1
(B) 89,3 91,6
(B) 89,3 102,1
(B) 88,0 89,3
(next B) #4 89,3
...
This could actually be a way to go, but as stated above, I will be throwing away data that might be valid. Just to be correct though the B sequence will be:
(B) #7 89,3
(B) 89,3 100,1
(B) 89,3 91,6
(B) 89,3 102,1
since there will follow 7 frequencies, although only (n-1)/2 of them (3 in this case) are valid AF's.
Consider the case with two type A messages:
(A1) #5 100,1
(A1) 91,6 102,1
(A2) 88,0 107,0
(next A2) #3 89,3
There is no way in hell to stop the A2 frequencies to get into the A1 list.
They way I've implemented it is that if I detect an AF header, I change the "current af list" to the one specific for that header (or create a new one if its new). Subsequent frequencies are added according to the following code:
Code:
private AlternativeFrequency previousAlternativeFrequency;
private int tuningFrequency;
private Dictionary<int, AlternativeFrequency> alternativeFrequencies = new Dictionary<int, AlternativeFrequency>();
public void AddAlternativeFrequency(AlternativeFrequency af)
{
if (afMethod == AF_METHOD_UNKNOWN)
{
// Add frequency and try to find out which method is used
alternativeFrequencies.Add(af.Frequency, af);
afMethod = checkAFMethod();
}
else if (afMethod == AF_METHOD_A)
{
// All frequencies are added (except duplicates)
if (!alternativeFrequencies.ContainsKey(af.Frequency))
{
alternativeFrequencies.Add(af.Frequency, af);
}
}
else if (afMethod == AF_METHOD_B)
{
// Every other frequency is added (except duplicates)
// Check if regional variant or not
if (previousAlternativeFrequency != null)
{
if (previousAlternativeFrequency.ComparedTo(af) < 0)
{
// Normal AF
if (!previousAlternativeFrequency.Frequency.Equals(tuningFrequency))
{
af = previousAlternativeFrequency;
}
}
else if (previousAlternativeFrequency.ComparedTo(af) > 0)
{
// Regional variant AF
if (!previousAlternativeFrequency.Frequency.Equals(tuningFrequency))
{
af = previousAlternativeFrequency;
}
af.RegionalVariant = true;
}
if (!alternativeFrequencies.ContainsKey(af.Frequency))
{
alternativeFrequencies.Add(af.Frequency, af);
}
previousAlternativeFrequency = null;
}
else
{
previousAlternativeFrequency = af;
}
}
}
private int checkAFMethod()
{
int result = AF_METHOD_UNKNOWN;
if (alternativeFrequencies.Count >= 2)
{
if (alternativeFrequencies.ContainsKey(tuningFrequency))
{
result = AF_METHOD_B;
alternativeFrequencies.Remove(tuningFrequency);
}
else
{
result = AF_METHOD_A;
}
}
return result;
}
Keep it up!
Bookmarks