ham-0.1.0.0

Safe HaskellNone
LanguageHaskell2010

Ham.Log

Contents

Description

Ham radio logging and other operations. This module provides a monad that abstracts some of the work necessary for logging ham radio contacts, as well as doing related tasks.

Synopsis

Documentation

module Ham.Qso

Reading and writing log and configuration.

logToFile :: Log -> FilePath -> IO () Source #

Write a log to a file in JSON format.

logFromFile :: FilePath -> IO (Maybe Log) Source #

Read a log from a file in JSON format.

configToFile :: LogConfig -> FilePath -> IO () Source #

Write the log configuration to a text file.

configFromFile :: FilePath -> IO (Maybe LogConfig) Source #

Read the log configuration from a text file.

The HamLog monad.

type HamLog = RWST LogConfig [Text] LogState IO Source #

Log monad. You would normally run the monad for example with evalHamLog, and use the monadic actions such as readLog, newQsoNow, writeLog, etc. to modify the log and QSOs.

data LogState Source #

Constructors

LogState 

Fields

Configuration

data LogConfigV3 Source #

Configuration for a log, version 2.

Constructors

LogConfigV3 

Fields

Running the monad

evalHamLog :: LogConfig -> LogState -> HamLog a -> IO (a, [Text]) Source #

Run a HamLog action and return the result and potential logging text.

execHamLog :: LogConfig -> LogState -> HamLog a -> IO (LogState, [Text]) Source #

Run a HamLog action and return the final state and potential logging text.

runHamLog :: LogConfig -> LogState -> HamLog a -> IO (a, LogState, [Text]) Source #

Run a HamLog action and return the result, final state, and potential logging text.

Reading and writing logs

readLog :: HamLog () Source #

Read the log database from the file set in _configLogFile entry of the LogConfig. The log is then set to the _stateLog entry of the current LogState.

writeLog :: HamLog () Source #

Write the log database to the file set in _configLogFile entry of the LogConfig.

Manipulating QSOs.

addQso :: Qso -> HamLog () Source #

Add the given QSO at the front of the current log.

newQsoNow :: HamLog Qso Source #

Create a new QSO with the current UTC time as reported by the operating system, and set the default values from the _configQsoDefaults values. uses fillFromCAT to fill some values from a connected radio, if any.

fillFromCAT :: Qso -> HamLog Qso Source #

Try to get a few values from a CAT connected radio. If the function is turned off (_stateUseCat is False), then the input is going to be returned unchanged. The same is true if there is an error while retrieving data from the radio. Note that when the functionality is turned on and there is an error, it may take a few seconds for the function to return. A message will be set in the Writer layer of HamLog, so that you can get the messages back with evalHamLog, execHamLog, or runHamLog.

updateQso :: Int -> Qso -> HamLog () Source #

Update the QSO at the given position in the log with the given QSO.

deleteQso :: Int -> HamLog () Source #

Delete the QSO at the given position in the log.

sortLog :: Ord a => (Qso -> a) -> HamLog () Source #

Sort the log according to the given key.

Helpers

currentUtcTime :: HamLog UTCTime Source #

Get the current UTC time up to seconds.

Queries

filterCallsign Source #

Arguments

:: Text

The Callsign to find.

-> HamLog (Seq Qso)

Returns a sequence of Qsos.

Return a sequence of all QSOs with a given callsign.

isDuplicate Source #

Arguments

:: Text

The Callsign to find.

-> HamLog Bool 

Checks if there is already at least one entry with the given callsign. DEPRECATED. Use findDuplicateQsos.

findQsos Source #

Arguments

:: Text

The callsign to find.

-> Maybe Band

Band to check for

-> Maybe QsoMode

Mode to check for

-> HamLog (Seq Qso) 

Find qsos containing the given information.

data Duplicate Source #

Constructors

Duplicate 

Fields

Instances
Show Duplicate Source # 
Instance details

Defined in Ham.Log

getQsoList :: HamLog [Qso] Source #

Get a list of QSOs. Use qsoSeq for better performance.

getQsoSeq :: HamLog (Seq Qso) Source #

Get the sequence of stored QSOs.

asks :: (Monoid w, Monad m) => (r -> a) -> RWST r w s m a #

Retrieve a function of the current environment.

Interacting with a radio via CAT

cat :: CAT IO a -> HamLog (Either CATError (a, [Text])) Source #

Run a CAT action.

Getting information from the FCC database.

lookupFcc :: Text -> HamLog (Maybe FccResult) Source #

Get the FCC information for a given callsign.

lookupFccName :: Text -> HamLog Text Source #

Get the operator's name for a given callsign from the FCC.

The Log

data Log Source #

A log. A log contains a set of Qsos

Constructors

Log 

Fields

Instances
Show Log Source # 
Instance details

Defined in Ham.Internal.Log.Log

Methods

showsPrec :: Int -> Log -> ShowS #

show :: Log -> String #

showList :: [Log] -> ShowS #

ToJSON Log Source # 
Instance details

Defined in Ham.Internal.Log.Log

FromJSON Log Source # 
Instance details

Defined in Ham.Internal.Log.Log

addQsoToLog :: Log -> Qso -> Log Source #

Add a QSO to the beginning of the log list.

sortLog_ :: Ord a => Log -> (Qso -> a) -> Log Source #

emptyLog :: Log Source #

An empty log.

Exporting

makeCabrillo :: Cabrillo -> HamLog CabrilloLog Source #

Make a cabrillo log from the current log, given a cabrillo configuration.