Index: mtut.scm ================================================================== --- mtut.scm +++ mtut.scm @@ -772,10 +772,11 @@ (conc pktsdir "/" uuid ".pkt") (lambda () (print pkt)))))) ;; (use trace)(trace create-run-pkt) +(define (contains list x) (cond ((null? list) #f) ((eq? (car list) x) #t) (else (contains (cdr list) x)))) ;; collect all needed data and create run pkts for contours with changed inputs ;; (define (generate-run-pkts mtconf toppath) (let ((std-runname (conc "sched" (time->string (seconds->local-time (current-seconds)) "%M%H%d")))) @@ -972,11 +973,42 @@ (cadr parts) runkey)) (new-runname (if (> num-parts 2) (caddr parts) std-runname)) - (last-run 9) ;; I think we can do a more valid calculation for this based on the run started packets for this particular area and target + (area-pkts (find-pkts pdb '(runstart) `((c . ,contour) + (t . ,runkey) + (G . ,area )))) + (runstarts (filter (lambda (my-pkt) + ;;(print my-pkt) + (not (contains (map + (lambda (c) + ;;(print "C: " c "PKT: " my-pkt) + (let* ((ctype (car c)) + (rx (cdr c)) + ;;(foo2 (print "Ctype: " ctype " RX: " rx)) + (pkt (alist-ref 'pkt my-pkt)) + (apkt (pkt->alist pkt)) + (cdat (alist-ref ctype apkt))) + (if rx + (if (string-match "t" (symbol->string ctype) ) + (begin (if #f (print "RX: " rx " CDAT: " (string-join (take (string-split cdat "/") 3) "/"))) (if cdat (string-match rx (string-join (take (string-split cdat "/") 3) "/")) #f)) + (begin (if #f (print "RX: " rx " CDAT: " cdat)) (if cdat (string-match rx cdat) #f))) #f) + + )) + `((c . ,contour) (t . ,runkey) (G . ,area))) #f))) + area-pkts)) + + ;;(test (pp runstarts)) + (rspkts (common:get-pkt-alists runstarts)) + ;; starttimes is for run start times and is used to know when the last run was launched + (starttimes (common:get-pkt-times rspkts)) ;; sort by age (youngest first) and delete duplicates by target + (last-run (if (null? starttimes) ;; if '() then it has never been run, else get the max + 0 + (apply max (map cdr starttimes)))) + + ;; (last-run 9) ;; I think we can do a more valid calculation for this based on the run started packets for this particular area and target (reason "Area-script-triggered") (mode-patt #f) (tag-expr #f) (sched #f) (message (if (null? rem-lines) @@ -1267,10 +1299,11 @@ (construct-sdat 'P uuid 'T (case (string->symbol action) ((run) "runstart") ((sync) "syncstart") ;; example of translating run -> runstart (else action)) + 'G (alist-ref 'G pkta) 'c (alist-ref 'c pkta) ;; THIS IS WRONG! SHOULD BE 'c 't (alist-ref 't pkta))))) (write-pkt pktsdir ack-uuid ack-pkt)))) (begin ;; access denied! Mark as such (mark-processed pdb (list (alist-ref 'id pktdat)))