Commit a3866bb9 authored by Bas Lijnse's avatar Bas Lijnse

Implemented logging in SAR example

git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@955 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent ade74256
......@@ -3,6 +3,8 @@ implementation module SAR
import iTasks
import CommonDomain
derive bimap (,), Maybe
Start :: *World -> *World
Start world = startEngine searchAndRescueExample world
......@@ -18,13 +20,19 @@ searchAndRescueExample
}
:: LogEntry =
{ incident :: IncidentNR
{ logNr :: Int
, incident :: IncidentNR
, date :: Date
, time :: Time
, user :: UserName
, message :: Note
}
derive gPrint Incident, LogEntry
derive gParse Incident, LogEntry
derive gVisualize Incident, LogEntry
derive gUpdate Incident, LogEntry
// Incident management
manageIncident :: Task Void
manageIncident = return Void
......@@ -35,12 +43,33 @@ manageIncident = return Void
deploySARHeli :: Task Void
deploySARHeli = return Void
// Logging
addLogEntry :: IncidentNR Note -> Task Void
addLogEntry incident message = return Void
addLogEntry incident message
= getContextWorker -&&- (getCurrentDate -&&- getCurrentTime)
>>= \(user,(date,time)) ->
dbCreateItem {LogEntry | logNr = 0, incident = incident, date = date, time = time, user = user, message = message}
>>| stop
viewLog :: IncidentNR -> Task Void
viewLog incident = return Void
viewLog incident
= readDB databaseId
>>= \logs ->
showMessageAbout ("Log for incident " +++ toString incident) [l \\ l <- logs | l.LogEntry.incident == incident]
// Databases
instance DB Incident
where
databaseId = mkDBid "Incidents"
getItemId i = DBRef i.Incident.incidentNr
setItemId (DBRef r) i = {Incident| i & incidentNr = r}
instance DB LogEntry
where
databaseId = mkDBid "Log"
getItemId l = DBRef l.LogEntry.logNr
setItemId (DBRef r) l = {LogEntry| l & logNr = r}
// Databases
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment