Skip to content

Commit

Permalink
Checkpoint.
Browse files Browse the repository at this point in the history
Working on busted calls.
  • Loading branch information
W6OP committed Oct 7, 2020
1 parent fb89ac5 commit e1629d1
Show file tree
Hide file tree
Showing 9 changed files with 116 additions and 56 deletions.
89 changes: 86 additions & 3 deletions AnalysisEngine/LogAnalyzer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Objects.SqlClient;
using System.Linq;
using System.Security.AccessControl;
using System.Security.Cryptography;
Expand Down Expand Up @@ -216,6 +217,12 @@ public void PreAnalyzeContestLogs(List<ContestLog> contestLogList, Dictionary<st
if (ActiveContest == ContestName.HQP)
{
SearchForIncorrectEntity(qso);
// probably should only look at valid QSOS
// may combine this withMatchQSOs()
if (qso.Status != QSOStatus.InvalidQSO)
{
SearchHQPBustedCallSigns(qso);
}
}
else
{
Expand All @@ -224,13 +231,12 @@ public void PreAnalyzeContestLogs(List<ContestLog> contestLogList, Dictionary<st
}
}

MatchQSOs(qsoList, contestLogList, call);
//MatchQSOs(qsoList, contestLogList, call);

MarkDuplicateQSOs(qsoList);

validQsos = contestLog.QSOCollection.Where(q => q.Status == QSOStatus.ValidQSO).Count();
//Console.WriteLine("Pre - forward: " + contestLog.LogOwner + " : " + validQsos.ToString());


// ReportProgress with Callsign
OnProgressUpdate?.Invoke(call, contestLog.QSOCollection.Count.ToString(), validQsos.ToString(), progress);
}
Expand Down Expand Up @@ -560,6 +566,83 @@ private void MatchQSOs(List<QSO> qsoList, List<ContestLog> contestLogList, strin
}
}

private void SearchCWOpenBustedCallSigns(QSO qso)
{

}

/// <summary>
/// Need to look through every log and find the match for this QSO.
/// If there are no matches either the call is busted or it is a unique
/// call. If the QSO has a time match but the calls don't match we need
/// to do some work to see if the call is busted.
///
/// Get a list of all logs from the CallDictionary that have this call sign in it
/// Now we can query the QSODictionary for each QSO that may match
///
/// We can also flag some duplicates here
/// </summary>
/// <param name="contestLog"></param>
/// <param name="qso"></param>
private void SearchHQPBustedCallSigns(QSO qso)
{
List<QSO> matches;
List<KeyValuePair<string, List<QSO>>> qsos;

// all logs with this operator call sign
List<ContestLog> contestLogs = CallDictionary[qso.OperatorCall];

// List of List<QSO> from the list of contest logs that match this operator call sign
qsos = contestLogs.SelectMany(z => z.QSODictionary).Where(x => x.Key == qso.OperatorCall).ToList();

// this can have more entries than qsos because the list is flattened
matches = qsos.SelectMany(x => x.Value)
.Where(y => y.ContactCall == qso.OperatorCall && y.OperatorCall == qso.ContactCall && y.Band == qso.Band && y.Mode == qso.Mode && Math.Abs(y.QSODateTime.Subtract(qso.QSODateTime).TotalMinutes) <= 1)
.ToList();

// found a match so we mark both as matches and add matching QSO
if (matches.Count == 1)
{
qso.MatchingQSO = matches[0];
matches[0].MatchingQSO = qso;
return;
}

// match not found so lets widen the search
if (matches.Count == 0)
{
matches = qsos.SelectMany(x => x.Value)
.Where(y => y.ContactCall == qso.OperatorCall && y.OperatorCall == qso.ContactCall && y.Band == qso.Band && y.Mode == qso.Mode && Math.Abs(y.QSODateTime.Subtract(qso.QSODateTime).TotalMinutes) <= 5)
.ToList();
}

// found a single match so we mark both as matches and add matching QSO
if (matches.Count == 1)
{
qso.MatchingQSO = matches[0];
matches[0].MatchingQSO = qso;
return;
}

// multiple matches found so need to narrow the search
// these are probably dupes
if (matches.Count > 1)
{
qso.MatchingQSO = matches[0];
matches[0].MatchingQSO = qso;
matches[1].QSOIsDupe = true;

// have QSO class handle this
qso.DuplicateQsoList.Add(matches[1]);

}

foreach (QSO o in matches)
{
Console.WriteLine(qso.ContactCall + ":" + o.OperatorCall + ":" + o.QSODateTime);
}
}

/// <summary>
/// Search every log for a match to this QSO without the call sign
/// </summary>
Expand Down
25 changes: 22 additions & 3 deletions AnalysisEngine/LogProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,22 +202,41 @@ public string BuildContestLog(FileInfo fileInfo, List<ContestLog> contestLogs, S
/// By building bthses dictionaries I save significant time in the
/// LogAnalyzer() linq queries. I only have to query a subset
/// of all the contest logs.
///
/// The CallDictionary contains every log that contains a specific call sign
/// The QSO Dictionary contains all QSOs in a log keyed by call sign
/// </summary>
/// <param name="contestLog"></param>
private void BuildDictionaries(ContestLog contestLog)
{
List<ContestLog> contestLogs;
List<QSO> qsos;

foreach (QSO qso in contestLog.QSOCollection)
{
// QSODictionary
if (contestLog.QSODictionary.ContainsKey(qso.ContactCall))
{
qsos = contestLog.QSODictionary[qso.ContactCall];
qsos.Add(qso);
}
else
{
qsos = new List<QSO>
{
qso
};
contestLog.QSODictionary.Add(qso.ContactCall, qsos);
}

// Call
if (CallDictionary.ContainsKey(qso.ContactCall))
{
contestLogs = CallDictionary[qso.ContactCall];
if (!contestLogs.Contains(contestLog))
{
contestLogs.Add(contestLog);
}
}
}
else
{
Expand Down Expand Up @@ -984,7 +1003,7 @@ from line in lineList
QsoDate = split[3],
QsoTime = CheckTime(split[4], line),
OperatorCall = ParseCallSign(split[5], out prefix, out suffix).ToUpper(),
OperatortPrefix = prefix,
OperatorPrefix = prefix,
OperatorSuffix = suffix,
SentSerialNumber = ConvertSerialNumber(split[6], line),
OperatorName = CheckActiveContest(split[7], "OperatorName").ToUpper(),
Expand Down Expand Up @@ -1017,7 +1036,7 @@ from line in lineList
QsoDate = split[3],
QsoTime = CheckTime(split[4], line),
OperatorCall = ParseCallSign(split[5], out prefix, out suffix).ToUpper(),
OperatortPrefix = prefix,
OperatorPrefix = prefix,
OperatorSuffix = suffix,
OperatorName = CheckActiveContest(split[6], "OperatorName").ToUpper(),
OperatorEntity = CheckActiveContest(split[6], "OperatorEntity").ToUpper(),
Expand Down
56 changes: 7 additions & 49 deletions Cabrillo/ContestLog.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections.Generic;

namespace W6OP.ContestLogAnalyzer
{
Expand All @@ -15,13 +11,10 @@ public ContestLog()
{
HQPMultipliers = 0;
NonHQPMultipliers = 0;
}

/// <summary>
/// Comments I add while I am anlyzing the logs. May be from when I first load
/// or anywhere along the line.
/// </summary>
//public List<string> AnalyzerComments { get; set; } = new List<string>();
QSOCollection = new List<QSO>();
QSODictionary = new Dictionary<string, List<QSO>>();
}

/// <summary>
/// Call sign of the log owner.
Expand Down Expand Up @@ -73,44 +66,12 @@ public LogHeader LogHeader

public bool SO2R { get; set; }

/// <summary>
/// Top level country - Used in HQP
/// Applied to US and Canadian stations so I can check the state or province
///
/// I don't think this is ever looked at or used.
/// </summary>
//public string RealOperatorEntity { get; set; }

/// <summary>
/// List of all the QSOs in this log.
/// </summary>
public List<QSO> QSOCollection { get; set; } = new List<QSO>();

/// <summary>
/// List of all the XQSOs in this log.
/// </summary>
// public List<QSO> QSOCollectionX { get; set; } = new List<QSO>();
public List<QSO> QSOCollection { get; set; }

/// <summary>
/// A list of all of the logs that have a reference to the call represented by this log.
/// </summary>
//private Dictionary<string, ContestLog> _MatchLogs;
//public Dictionary<string, ContestLog> MatchLogs { get; set; } = new Dictionary<string, ContestLog>();


/// <summary>
/// List of logs that do not have a QSO with this operator.
/// </summary>
//private Dictionary<string, ContestLog> _OtherLogs;
//public Dictionary<string, ContestLog> OtherLogs { get; set; } = new Dictionary<string, ContestLog>();


/// <summary>
/// Logs that need review.
/// </summary>
//private Dictionary<string, ContestLog> _ReviewLogs;
//public Dictionary<string, ContestLog> ReviewLogs { get; set; } = new Dictionary<string, ContestLog>();

public Dictionary<string, List<QSO>> QSODictionary { get; set; }

/// <summary>
/// Indicates the log meets the criteria necessary to be analysed.
Expand Down Expand Up @@ -159,9 +120,6 @@ public LogHeader LogHeader

private HashSet<string> _Entities = new HashSet<string>();
public HashSet<string> Entities { get => _Entities; set => _Entities = value; }





} // end class
}
2 changes: 1 addition & 1 deletion Cabrillo/QSO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ public bool SessionIsValid
// the raw text of the qso line
public string RawQSO { get; set; }

public string OperatortPrefix { get; set; }
public string OperatorPrefix { get; set; }
public string OperatorSuffix { get; set; }
public string ContactPrefix { get; set; }
public string ContactSuffix { get; set; }
Expand Down
Binary file modified Deploy/AnalysisEngine.dll
Binary file not shown.
Binary file modified Deploy/Cabrillo.dll
Binary file not shown.
Binary file modified Deploy/LogAnalyzerCommon.dll
Binary file not shown.
Binary file modified Deploy/PrintEngine.dll
Binary file not shown.
Binary file modified Deploy/ScoreEngine.dll
Binary file not shown.

0 comments on commit e1629d1

Please sign in to comment.