X-Git-Url: https://git.rrq.au/?a=blobdiff_plain;f=control-logic.lsp;h=bdf291d858cae4fe80cad182a4e709473d6db2d2;hb=a0971e1ea5dd4963e51a5dd0c24d90c443c1dc84;hp=c842c06eee67d320d6270d87548e66ec80baf1b6;hpb=e952e4ea6aa01a7787597fe9fe363cae79e555e5;p=rrq%2Fhourglass.git diff --git a/control-logic.lsp b/control-logic.lsp index c842c06..bdf291d 100644 --- a/control-logic.lsp +++ b/control-logic.lsp @@ -9,7 +9,14 @@ (write-line 2 (join (map string args))) (exit 1)) -(constant 'NOW (date-value)) +(constant + 'NOW (date-value) + 'ACTDIR SITE:listener.activity.dir + 'CONTROL.DAT SITE:control.dat + 'EXTRA.DAT SITE:control.extra.dat + 'USAGE.DAT SITE:usage.dat + 'USAGE.TMP SITE:usage.tmp + ) # Set current time variables in local timezone (map set '(YEAR MONTH DATE HOUR MINUTE SECOND DOY DOW) @@ -20,10 +27,8 @@ DAY (list YEAR MONTH DATE) HM (list HOUR MINUTE) TOTAL '() - CONTROL.DAT "control.dat" - EXTRA.DAT "control-extra.dat" - USAGE.DAT "usage.dat" - USAGE.TMP ".usage.dat" + GAP SITE:control.activity.gap + CLIP SITE:control.activity.clip ) # Load CONTROL.DAT @@ -37,12 +42,6 @@ (list DOW (6 30) 120 (20 0))) ) -(setf - GAP (or (lookup 'gap CONTROL) 15) - CLIP (or (lookup 'clip CONTROL) 1000) - NET (or (lookup 'net CONTROL) "10.0.0.0/8") - ) - # Load the configured control mechanism (if (lookup 'control CONTROL) (load $it) (die "** Unknown control mechanism. Exiting!!")) @@ -67,15 +66,16 @@ ;;==== Utilities for activity data # Activity is lines of timestamps. Collect TOTAL as list of unique # time values (H M) within the start-end time span. + (define (log-name-fmt t) (format "%d%02d%02d-.*\\.dat" (0 3 (date-list t)))) (define (log-lines f) - (find-all "([0-9]+( \\S+)?).*" (read-file (string "activity/" f)) $1 0)) + (find-all "([0-9]+( \\S+)?).*" (read-file (format "%s/%s" ACTDIR f)) $1 0)) # Collect all timestamps of the UTC date of the given time stamp (define (logs t) - (flat (map log-lines (directory "activity" (log-name-fmt t))))) + (flat (map log-lines (directory ACTDIR (log-name-fmt t))))) # Translate timestamp into its local time (hour minute), if it's # within the applicable day, null otherwise.