Lay out a Cabrillo line the way a .udc file asks for it
`CabrilloString` names a field and a column width in turn. The line it makes follows N1MM: the operator's callsign in the first 13 columns, then every column padded to its width with one space after it, and a value longer than its column cut rather than pushed sideways. The cut is new for every contest, not just the user-defined ones — the columns are the sponsor's, not ours. `CabrilloVersion` is read too, so a contest whose sponsor still asks for 2.0 gets it in the header. A contest that lays out its own line can put the transmitter column where it wants it, or leave it out, so the writer no longer adds one at the end. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RoGtneMQaz4M9w7Kk49AVD
This commit is contained in:
@@ -23,7 +23,7 @@ public sealed class CabrilloWriter
|
||||
public string Write(CabrilloHeader header, IEnumerable<Qso> qsos)
|
||||
{
|
||||
StringBuilder text = new();
|
||||
text.Append("START-OF-LOG: 3.0\r\n");
|
||||
text.Append("START-OF-LOG: ").Append(contest.CabrilloVersion).Append("\r\n");
|
||||
Line(text, "CONTEST", header.Contest);
|
||||
Line(text, "CALLSIGN", header.Callsign);
|
||||
Line(text, "CATEGORY-OPERATOR", header.OperatorCategory);
|
||||
@@ -72,18 +72,23 @@ public sealed class CabrilloWriter
|
||||
line.Append(qso.TimestampUtc.ToString("HHmm", CultureInfo.InvariantCulture)).Append(' ');
|
||||
Append(line, exchange.Sent);
|
||||
Append(line, exchange.Received);
|
||||
if (contest.IsContact(qso))
|
||||
if (contest.IsContact(qso) && exchange.AddsTransmitter)
|
||||
{
|
||||
line.Append(qso.RadioNumber > 1 ? '1' : '0');
|
||||
}
|
||||
return line.ToString();
|
||||
}
|
||||
|
||||
/// Every column is the width the sponsor asks for and one space, and a
|
||||
/// value longer than its column is cut, which is what N1MM writes.
|
||||
private static void Append(StringBuilder line, IReadOnlyList<CabrilloField> fields)
|
||||
{
|
||||
foreach (CabrilloField field in fields)
|
||||
{
|
||||
line.Append(field.Value.PadRight(field.Width)).Append(' ');
|
||||
string value = field.Value.Length > field.Width
|
||||
? field.Value[..field.Width]
|
||||
: field.Value.PadRight(field.Width);
|
||||
line.Append(value).Append(' ');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user