Safe Haskell | None |
---|---|
Language | Haskell2010 |
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
- module Ham.Qso
- logToFile :: Log -> FilePath -> IO ()
- logFromFile :: FilePath -> IO (Maybe Log)
- configToFile :: LogConfig -> FilePath -> IO ()
- configFromFile :: FilePath -> IO (Maybe LogConfig)
- type HamLog = RWST LogConfig [Text] LogState IO
- data LogState = LogState {}
- emptyLogState :: LogState
- data LogConfigV3 = LogConfigV3 {}
- type LogConfig = LogConfigV3
- configLogFile :: Lens' LogConfigV3 FilePath
- configQsoDefaults :: Lens' LogConfigV3 QsoDefaults
- defaultConfig :: LogConfig
- evalHamLog :: LogConfig -> LogState -> HamLog a -> IO (a, [Text])
- execHamLog :: LogConfig -> LogState -> HamLog a -> IO (LogState, [Text])
- runHamLog :: LogConfig -> LogState -> HamLog a -> IO (a, LogState, [Text])
- readLog :: HamLog ()
- writeLog :: HamLog ()
- addQso :: Qso -> HamLog ()
- newQsoNow :: HamLog Qso
- fillFromCAT :: Qso -> HamLog Qso
- updateQso :: Int -> Qso -> HamLog ()
- deleteQso :: Int -> HamLog ()
- sortLog :: Ord a => (Qso -> a) -> HamLog ()
- currentUtcTime :: HamLog UTCTime
- filterCallsign :: Text -> HamLog (Seq Qso)
- isDuplicate :: Text -> HamLog Bool
- findQsos :: Text -> Maybe Band -> Maybe QsoMode -> HamLog (Seq Qso)
- findDuplicateQsos :: Qso -> HamLog (Seq Duplicate)
- data Duplicate = Duplicate {}
- getQsoList :: HamLog [Qso]
- getQsoSeq :: HamLog (Seq Qso)
- asks :: (Monoid w, Monad m) => (r -> a) -> RWST r w s m a
- cat :: CAT IO a -> HamLog (Either CATError (a, [Text]))
- lookupFcc :: Text -> HamLog (Maybe FccResult)
- lookupFccName :: Text -> HamLog Text
- data Log = Log {}
- addQsoToLog :: Log -> Qso -> Log
- sortLog_ :: Ord a => Log -> (Qso -> a) -> Log
- emptyLog :: Log
- makeCabrillo :: Cabrillo -> HamLog CabrilloLog
Documentation
module Ham.Qso
Reading and writing log and configuration.
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.
LogState | |
|
Configuration
data LogConfigV3 Source #
Configuration for a log, version 2.
LogConfigV3 | |
|
Instances
Show LogConfigV3 Source # | |
Defined in Ham.Internal.Log.V3 showsPrec :: Int -> LogConfigV3 -> ShowS # show :: LogConfigV3 -> String # showList :: [LogConfigV3] -> ShowS # | |
ToJSON LogConfigV3 Source # | |
Defined in Ham.Internal.Log.V3 toJSON :: LogConfigV3 -> Value # toEncoding :: LogConfigV3 -> Encoding # toJSONList :: [LogConfigV3] -> Value # toEncodingList :: [LogConfigV3] -> Encoding # | |
FromJSON LogConfigV3 Source # | |
Defined in Ham.Internal.Log.V3 parseJSON :: Value -> Parser LogConfigV3 # parseJSONList :: Value -> Parser [LogConfigV3] # |
type LogConfig = LogConfigV3 Source #
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
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.
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.
Helpers
currentUtcTime :: HamLog UTCTime Source #
Get the current UTC time up to seconds.
Queries
Return a sequence of all QSOs with a given callsign.
Checks if there is already at least one entry with the given callsign. DEPRECATED. Use findDuplicateQsos.
:: 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.
Duplicate | |
|
getQsoList :: HamLog [Qso] Source #
Get a list of QSOs. Use qsoSeq for better performance.
Interacting with a radio via CAT
Getting information from the FCC database.
lookupFccName :: Text -> HamLog Text Source #
Get the operator's name for a given callsign from the FCC.
The Log
A log.
A log contains a set of Qso
s
Exporting
makeCabrillo :: Cabrillo -> HamLog CabrilloLog Source #
Make a cabrillo log from the current log, given a cabrillo configuration.