IRcap — File Browser

ircap871-mircscripts_2799 / ircap871-mircscripts_2799 / s / sbar / sba.bandw.mrc

sba.bandw.mrc — 3.45 KB — Download this file

;IRcap8 1b95aaee6c2fbcbfab1c9edcdf7618d5

alias sba.BANDW {
  sbatit $calc($1 - 12) $m(sbared)
  if ($2 < 60) { return }

  unset %sba.bandw* %tmp.bandw*
  %sba.bandw = 6 $1 $calc($gettok(%sbarra,1,32) - 16) $calc($2 - 20)
  cua @sba %sba.bandw $gettok(%gui.cc,4,44) $gettok(%gui.cc,5,44) $gettok(%gui.cc,3,44)

  if (!$timer(sba.bandw)) { .timerSBA.bandw -oi 0 1 bandwtrafico }
}

alias bandwtrafico {
  tokenize 32 %sba.bandw | if (!$1) return
  if (%bandwtope < 0) || (!%bandwtope) { %bandwtope = 128 }

  dametrafico | var %d = $gettok($result,1,32) , %u =  $gettok($result,2,32) , %t =  $gettok($result,3-,32) | if (%d < 0) { %d = 0 } | if (%u < 0) { %u = 0 }

  %sba.bandwut = %t

  inc %sba.bandwD %d
  inc %sba.bandwU %u
  inc %sba.bandwM
  var %r = 4 |  if (%sba.bandwM >= %r) { %d = $calc(%sba.bandwD / %r) | %u = $calc(%sba.bandwU / %r) | unset %sba.bandwM %sba.bandwD %sba.bandwU }
  else return

  var %a = $calc($4 / 32) | %a = $int($calc(%d * %a))

  drawscroll -n @sba -4 0 $calc($1 + 4) $calc($2 + 4) $calc($3 - 6) $calc($4 - 7)

  var %x = $calc($1 + 4) , %y = $calc($2 + 4) , %h = $calc($3 - 8) , %i = $calc(($4 - 8) / 4) , %n = %bandwtope , %c = $gettok(%gui.cc,5,44) , %f = $gettok(%gui.cc,3,44)
  inc %y %i | dec %n $int($calc(%bandwtope / 4))
  drawrect -nrc @sba %c 1 %x %y %h 1 | drawtext -bnr @sba %c %f Arial 9 %x $calc(%y - 5) %n | inc %y %i | dec %n $int($calc(%bandwtope / 4))
  drawrect -nrc @sba %c 1 %x %y %h 1 | drawtext -bnr @sba %c %f Arial 9 %x $calc(%y - 5) %n | inc %y %i | dec %n $int($calc(%bandwtope / 4))
  drawrect -nrc @sba %c 1 %x %y %h 1 | drawtext -bnr @sba %c %f Arial 9 %x $calc(%y - 5) %n | inc %y %i | dec %n $int($calc(%bandwtope / 4))
  drawrect -nrc @sba %c 1 %x %y %h 1 

  var %cb = $rgb(20,160,20) , %cs = $rgb(190,20,20)

  drawrect -fnr @sba $gettok(%gui.cc,3,44) 1 $calc($1 + $3 - 6) $calc($2 + 4) 4 $calc($4 - 7)
  drawtext -nrb @sba %cb %f Arial 9 $calc($1 + 4) $calc($2 + 2) $m(542) $+ : $int(%d) KB/s.
  drawtext -nrb @sba %cs %f Arial 9 $calc($1 + 4) $calc($2 + 12) $m(543) $+ : $int(%u) KB/s.

  var %a = $calc((($4 - 8) / %bandwtope) * %d) , %y = $calc($2 + $4 - 4 - %a) 
  if (%y < $calc($2 + 4)) { %y = $calc($2 + 4) }
  drawline -cnr @sba %cb 1 $calc($1 + $3 - 4) %y $calc($1 + $3 - 8) %tmp.bandw.ulta
  %tmp.bandw.ulta = %y

  var %a = $calc((($4 - 8) / %bandwtope) * %u) , %y = $calc($2 + $4 - 4 - %a) 
  if (%y < $calc($2 + 4)) { %y = $calc($2 + 4) }
  drawline -cnr @sba %cs 1 $calc($1 + $3 - 4) %y $calc($1 + $3 - 8) %tmp.bandw.ultd
  %tmp.bandw.ultd = %y

  drawline @sba
}


#sba.bandw off
menu @sbarra {
  $m(544) ( %bandwtope KB/s ): %bandwtope = $$?=" $mg(sbared) "
}
#sba.bandw end

#bandw1 on
alias -l dametrafico {
  .comopen C1 WbemScripting.SWbemLocator | var %a = $com(C1,ConnectServer,3, dispatch* C2) | .comclose C1
  %a = $com(C2, InstancesOf,3,string,Win32_PerfRawData_Tcpip_NetworkInterface,dispatch* C3) | .comclose C2
  var %t = $comval(C3, 1, BytesReceivedPersec) $comval(C3, 1, BytesSentPersec) | .comclose C3
  if (!%sba.bandwut) { %sba.bandwut = %t }
  return $int($calc(($gettok(%t,1,32) - $gettok(%sba.bandwut,1,32)) / 1024)) $int($calc(($gettok(%t,2,32) - $gettok(%sba.bandwut,2,32)) / 1024)) %t
}
#bandw1 end

#bandw2 off
alias -l dametrafico var %t = $dll(s\sbar\band.dll,band,_) | return $gettok(%t,4,32) $gettok(%t,5,32) %t
#bandw2 end

on 1:start: .disable #bandw1 #bandw2 | if ($exists(s\sbar\band.dll)) .enable #bandw2 | else .enable #bandw1

;EOF