cabrillo

package module
v0.0.0-...-06324d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 13, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

README

go-cabrillo

GoDoc Go Report Card

A package to manipulate Cabrillo formatted radio contest logs.

TODO

Lots of templates and examples here

Documentation

Index

Constants

View Source
const (
	CategoryAssisted    = "ASSISTED"
	CategoryBand        = "BAND"
	CategoryMode        = "MODE"
	CategoryOperator    = "OPERATOR"
	CategoryPower       = "POWER"
	CategoryStation     = "STATION"
	CategoryTime        = "TIME"
	CategoryTransmitter = "TRANSMITTER"
	CategoryOverlay     = "OVERLAY"
)

Various constants for category names.

Variables

This section is empty.

Functions

This section is empty.

Types

type Address

type Address struct {
	// Maximum of 6 lines
	Address       []string
	City          string
	StateProvince string
	PostalCode    string
	Country       string
}

Address represents someone's physical address.

type Category

type Category struct {
	Name  string
	Value string
}

Category is a key-value pair of data.

type CategoryValidationRule

type CategoryValidationRule struct {
	Field             string
	PermissibleValues []string
}

CategoryValidationRule is a rule to validate a category. Some categories have fixed lists of permissible values. This likely needs to be changed into an interface.

func DefaultRules

func DefaultRules() []CategoryValidationRule

DefaultRules tries to capture a default list of rules from the Cabrillo spec definition.

func (*CategoryValidationRule) Evaluate

func (r *CategoryValidationRule) Evaluate(cat Category) error

Evaluate runs the rule annd determines if the specific instance of Catetgory fulfills the rule.

type ExtensibleField

type ExtensibleField struct {
	Name   string
	Values []string
}

ExtensibleField represents a line prefixed by "X-" in the log other than "X-QSO". Each entry in Values represents a separate line on which the field was found. Thus if you had: X-COMMENT: some comment X-COMMENT: some other comment You would end up with one ExtensibleField with Name="COMMENT" with two entries in Values.

type Info

type Info struct {
	Callsign     string
	SignalReport RST
	Exchange     string
}

Info stores information about the sender or receiver participating in a QSO.

type Log

type Log struct {
	Address          Address
	CallSign         string
	Categories       []Category
	Certificate      bool
	ClaimedScore     int
	Club             string
	Contest          string
	CreatedBy        string
	Email            string
	ExtensibleFields []ExtensibleField
	GridLocator      string
	Location         string
	Name             string
	OffTimes         []OffTime
	//TODO: when generating the line, each line is a max of 75 chars long. Use multiple lines. Host station prefixed with `@`
	Operators []string
	QSOs      []QSO
	SoapBox   []string
	Version   string
	XQSOs     []QSO
}

Log is a data structure representing an entire Cabrillo formatted Log file. Data can be parsed into the structure. The long-term plan is to be able to generate a Cabrillo formatted log file from the data structure.

func ParseLog

func ParseLog(r io.Reader, opts ...ParserOption) (Log, error)

ParseLog attempts to parse the data from the reader into a Log structure.

func (*Log) AddCategory

func (l *Log) AddCategory(name, value string) error

AddCategory adds a category to the existing Log.

func (*Log) AddExtensibleField

func (l *Log) AddExtensibleField(name, value string)

AddExtensibleField adds an extenisble field to the existing Log. If the field has been added previously, appends to the existing field.

func (*Log) Category

func (l *Log) Category(name string) string

Category returns the value for the specified category or an empty string if a value has not been specified for that category.

func (*Log) ExtendedField

func (l *Log) ExtendedField(name string) []string

ExtendedField returns the values for the specified extended field.

type OffTime

type OffTime struct {
	Begin time.Time
	End   time.Time
}

OffTime is used to indicate off-time. OFFTIME: 2002-03-22 0300 2002-03-22 0743 yyyy-mm-dd nnnn yyyy-mm-dd nnnn -----begin----- ------end------

type ParserOption

type ParserOption func(*options)

ParserOption is used to customize the log parser.

func WithExchangeFields

func WithExchangeFields(exchangeFields int) ParserOption

WithExchangeFields sets how many space delimited fields to expect in the exchange column.

type QSO

type QSO struct {
	Frequency   string
	Mode        string
	Timestamp   time.Time
	TxInfo      Info
	RxInfo      Info
	Transmitter int
}

QSO represents a contact.

func NewQSO

func NewQSO(line string, exchangeFields int) (QSO, error)

NewQSO parses a line from a cabrillo log into a QSQ struct. exchangeFields specifies the number of fields in the exchange. If the exchange was only a serial number, this should be set to 1. If the exchange is a name, serial number, and QTH all delimited by spaces, set this to 3.

type RST

type RST struct {
	Readability int
	Strength    int
	Tone        int
}

RST is a signal report.

func NewRST

func NewRST(report string) (RST, error)

NewRST parses a signal report ("59" or "599", etc.) and returns it as an RST.

func (RST) String

func (r RST) String() string

String fullfills the stringer interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL