327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
|
#:title "Test Steps"
(let ((stepsdat (iup:label "Test steps ........................................."
#:expand "YES"
#:size "200x150"
#:alignment "ALEFT:ATOP")))
(hash-table-set! widgets "Test Steps" (lambda (testdat)
(let* ((currval (iup:attribute stepsdat "TITLE"))
(fmtstr "~15a~8a~8a~8a~20a")
(steps (db:get-steps-for-test db test-id))
;; organise the steps for better readability
(comprsteps (let ((res (make-hash-table)))
(for-each
(lambda (step)
(let ((record (hash-table-ref/default
res
(db:step-get-stepname step)
;; stepname start end status
(vector (db:step-get-stepname step) "" "" "" ""))))
(case (string->symbol (db:step-get-state step))
((start)(vector-set! record 1 (db:step-get-event_time step))
(vector-set! record 3 (db:step-get-status step)))
((end) (vector-set! record 2 (db:step-get-event_time step))
(vector-set! record 3 (db:step-get-status step)))
(else (vector-set! record 1 (db:step-get-event_time step)))
(vector-set! record 2 (db:step-get-state step))
(vector-set! record 3 (db:step-get-status step))
(vector-set! record 4 (db:step-get-event_time step)))
(hash-table-set! res (db:step-get-stepname step) record)))
steps)
res))
(newval (string-intersperse
(append
(list
(format #f fmtstr "Stepname" "Start" "End" "Status" "Time")
(format #f fmtstr "========" "=====" "======" "======" "=========="))
(map (lambda (x)
;; take advantage of the \n on time->string
(format #f fmtstr
(vector-ref x 0)
(seconds->time-string (vector-ref x 1))
(vector-ref x 2)
(vector-ref x 3)
(vector-ref x 4)))
(sort (hash-table-values comprsteps)
(lambda (a b)(< (vector-ref 1 a)(vector-ref 1 b))))))
"\n")))
(if (not (equal? currval newval))
(iup:attribute-set! stepsdat "TITLE" newval)))))
stepsdat)))))
(iup:show self)
(iup:callback-set! *tim* "ACTION_CB"
(lambda (x)
|
|
>
|
|
>
>
>
>
|
>
|
>
|
|
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
|
#:title "Test Steps"
(let ((stepsdat (iup:label "Test steps ........................................."
#:expand "YES"
#:size "200x150"
#:alignment "ALEFT:ATOP")))
(hash-table-set! widgets "Test Steps" (lambda (testdat)
(let* ((currval (iup:attribute stepsdat "TITLE"))
(fmtstr "~25a~10a~10a~15a~20a")
(steps (db:get-steps-for-test db test-id))
;; organise the steps for better readability
(comprsteps (let ((res (make-hash-table)))
(for-each
(lambda (step)
(let ((record (hash-table-ref/default
res
(db:step-get-stepname step)
;; stepname start end status
(vector (db:step-get-stepname step) "" "" "" ""))))
(case (string->symbol (db:step-get-state step))
((start)(vector-set! record 1 (db:step-get-event_time step))
(vector-set! record 3 (if (equal? (vector-ref record 3) "")
(db:step-get-status step))))
((end) (vector-set! record 2 (db:step-get-event_time step))
(vector-set! record 3 (db:step-get-status step))
(vector-set! record 4 (let ((startt (vector-ref record 1))
(endt (vector-ref record 2)))
(if (and (number? startt)(number? endt))
(seconds->hr-min-sec (- endt startt)) "-1"))))
(else (vector-set! record 1 (db:step-get-event_time step)))
(vector-set! record 2 (db:step-get-state step))
(vector-set! record 3 (db:step-get-status step))
(vector-set! record 4 (db:step-get-event_time step)))
(hash-table-set! res (db:step-get-stepname step) record)))
steps)
res))
(newval (string-intersperse
(append
(list
(format #f fmtstr "Stepname" "Start" "End" "Status" "Time")
(format #f fmtstr "========" "=====" "======" "======" "=========="))
(map (lambda (x)
;; take advantage of the \n on time->string
(format #f fmtstr
(vector-ref x 0)
(let ((s (vector-ref x 1)))
(if (number? s)(seconds->time-string s) s))
(let ((s (vector-ref x 2)))
(if (number? s)(seconds->time-string s) s))
(vector-ref x 3)
(vector-ref x 4)))
(sort (hash-table-values comprsteps)
(lambda (a b)(< (vector-ref a 1)(vector-ref b 1))))))
"\n")))
(if (not (equal? currval newval))
(iup:attribute-set! stepsdat "TITLE" newval)))))
stepsdat)))))
(iup:show self)
(iup:callback-set! *tim* "ACTION_CB"
(lambda (x)
|