From: marko Date: Mon, 23 Jun 2008 19:46:24 +0000 (+0000) Subject: Add a ramp function generator in event scheduler. X-Git-Url: https://git.entuzijast.net/?a=commitdiff_plain;h=6926f6e3cd5c1cb7d5a9c4a0d828eea0e60c1346;p=imunes.git Add a ramp function generator in event scheduler. So far, it is possible to schedule changes to link parameters (bandwidth, delay, BER, duplicate) and attributes (width, color) to constant values or periodic functions (rand or ramp). Example: link l1 { nodes {n1 n2} bandwidth 256000 events { 1 width ramp 5 2 1 3 color rand 0 16777216 1 5 bandwidth rand 128000 256000 2 30 width 3 35 color red } } At t = 1s after the experiment is started, the width attribute of link l1 will be set to 5, and will increase by 2 each second, until t = 30s when it will be set to constant value of 3. At t = 3s the color attribute of link l1 will randomly change each second, until t = 35s when the color will be set to "red". Ar t = 5s bandwidth will begin to take random values between 128000 and 256000 each 2 seconds, and this process will continue for the entire duration of the experiment. All changes trigged by the event scheduled will be visible in the GUI. Bug found by: Submitted by: Reviewed by: Approved by: Obtained from: --- diff --git a/eventsched.tcl b/eventsched.tcl index 2ac478d..a3c9fcf 100644 --- a/eventsched.tcl +++ b/eventsched.tcl @@ -23,7 +23,7 @@ # SUCH DAMAGE. # -# $Id: eventsched.tcl,v 1.3 2008/06/23 17:02:52 marko Exp $ +# $Id: eventsched.tcl,v 1.4 2008/06/23 19:46:24 marko Exp $ set sched_init_done 0 @@ -71,6 +71,21 @@ proc evsched {} { set need_sort 1 } } + } elseif { [lindex $params 0] == "ramp" } { + set start [lindex $params 1] + set step [lindex $params 2] + set next [expr $deadline + [lindex $params 3]] + set value [expr round($start + $step)] + if { $next > $deadline } { + set nextev \ + [lsearch $eventqueue "* $class $object $target *"] + if { $nextev == -1 || \ + [lindex [lindex $eventqueue $nextev] 0] > $next } { + lappend eventqueue \ + "$next [lrange $event 1 4] $value [lrange $params 2 end]" + set need_sort 1 + } + } } else { set value [lindex $params 0] }