From 8ed615459fe437e5ead18dd04724333872ba9103 Mon Sep 17 00:00:00 2001 From: hummypkg Date: Sun, 21 Aug 2016 18:32:48 +0000 Subject: [PATCH] improve in-progress check to accommodate padding git-svn-id: file:///root/webif/svn/pkg/webif/trunk@3197 2a923420-c742-0410-a762-8d5b09965624 --- webif/html/sched/list/index.jim | 8 +++++--- webif/lib/rsv.class | 32 +++++++++++++++++++++++++------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/webif/html/sched/list/index.jim b/webif/html/sched/list/index.jim index 22c15b9..c0d14dc 100755 --- a/webif/html/sched/list/index.jim +++ b/webif/html/sched/list/index.jim @@ -83,15 +83,16 @@ proc eventrow {event {table TBL_RESERVATION}} { set d [$event get nduration] set e $($s + $d) set n [clock seconds] + lassign [$event padded 1] sp ep - if {$n > $e && [$event get ersvtype] <= 3} { + if {$n > $e + $ep && [$event get ersvtype] <= 3} { set ended 1 incr num_ended } else { set ended 0 } - if {$d > 0 && $n >= $s && $n < $e} { + if {$d > 0 && $n >= $s - $sp && $n < $e + $ep} { set showing 1 } else { set showing 0 @@ -198,7 +199,8 @@ proc eventrow {event {table TBL_RESERVATION}} { } if {$table ne "pending" && $showing} { - set perc [expr [expr $n - $s] * 100 / $d] + set perc [expr [expr $n - ($s - $sp)] * 100 / \ + ($d + $sp + $ep)] puts "
" puts "" diff --git a/webif/lib/rsv.class b/webif/lib/rsv.class index 12a9951..15ce3c6 100755 --- a/webif/lib/rsv.class +++ b/webif/lib/rsv.class @@ -126,11 +126,19 @@ rsv method name {} { return $name } -rsv method padded {} { +rsv method padded {{l 0}} { if {$ulPreOffset > 0 || $ulPostOffset > 0} { - return 1 + if {$l} { + return [list $ulPreOffset $ulPostOffset] + } else { + return 1 + } } else { - return 0 + if {$l} { + return {0 0} + } else { + return 0 + } } } @@ -332,12 +340,22 @@ rsv method insert {{table pending} {force 0} {defer 0}} { set now [clock seconds] # In-progress check - if {$nsttime <= $now} { - if {$table ne "pending" && $nsttime + $nduration >= $now} { - # Still showing - OK if real-time scheduling addition. - if {$action != 0 || ![rsv rtsched]} { + if {$nsttime - $ulPreOffset <= $now} { + # Start time in the past + if {$nsttime + $nduration + $ulPostOffset >= $now} { + # Still showing + switch $action { + 0 { # Add + # Ok if real-time scheduling in use. + if {![rsv rtsched]} { + throw 20 "Event already in progress." + return + } + } + default { throw 20 "Event already in progress." return + } } } elseif {$action == 0} { throw 20 "Event has finished."