Subversion Repositories f9daq

Rev

Blame | Last modification | View Log | RSS feed

  1. #!/bin/bash
  2.  
  3. # Commands:
  4. #   snmpset - sets the selected attribute of a single channel
  5. #   snmpget - prints the selected atribute of a single channel
  6. #   snmpwalk - prints the selected attribute of all channels
  7. #
  8. # Attributes:
  9. #   outputVoltage - float(F), R/W
  10. #   outputCurrent - float(F), R/W
  11. #   outputMeasurementSenseVoltage - float(F), R
  12. #   outputMeasurementCurrent - float(F), R
  13. #   outputSwitch - integer(i), R/W
  14. #   outputVoltageRiseRate - float(F), R/W
  15. #   outputStatus - bits, R
  16.  
  17. #ip=194.249.156.124
  18. #ip=f9mpod.ijs.si
  19.  
  20. #if [$1 -lt 99]; then
  21. #  if [$2 -lt 74]; then
  22. #    echo "Setting bias to " $2
  23. #    snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputVoltage.$1 F $2
  24. #  else
  25. #    echo "Bias voltage needs to be smaller than 74V."
  26. #  fi
  27. #else if [$1 -gt 99]; then
  28. #  if [$2 -lt 35]; then
  29. #    echo "Setting bias to " $2
  30. #    snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputVoltage.$1 F $2
  31. #  else
  32. #    echo "Bias voltage needs to be smaller than 35V."
  33. #  fi
  34. #fi
  35.  
  36. ip=f9mpod.ijs.si
  37.  
  38. function reset_all
  39. {
  40.   snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.1 i 10
  41.   snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.2 i 10
  42.   snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.3 i 10
  43.   snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.4 i 10
  44.   snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.5 i 10
  45.   snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.6 i 10
  46.   snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.7 i 10
  47.   snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.8 i 10
  48.   snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.101 i 10
  49.   snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.102 i 10
  50.   snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.103 i 10
  51.   snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.104 i 10
  52.   snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.105 i 10
  53.   snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.106 i 10
  54.   snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.107 i 10
  55.   snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.108 i 10
  56.  
  57.   exit 0
  58. }
  59.  
  60. # save all arguments to array args
  61. args=("$@")
  62.  
  63. argcnt=0
  64. outSel=-1
  65. outVolt=-1
  66. outSw=-1
  67. resetOut=-1
  68. getOut=-1
  69.  
  70. # search the arguments for valid options
  71. for ARG in "${args[@]}"; do
  72.   if [ "$ARG" == "--resetall" ]; then
  73.     reset_all
  74.   elif [ "$ARG" == "-g" ]; then
  75.     getOut=1
  76.   elif [ "$ARG" == "-r" ]; then
  77.     resetOut=${args[$argcnt+1]}
  78.   elif [ "$ARG" == "-o" ]; then
  79.     outSel=${args[$argcnt+1]}
  80.   elif [ "$ARG" == "-v" ]; then
  81.     outVolt=${args[$argcnt+1]}
  82.   elif [ "$ARG" == "-s" ]; then
  83.     outSw=${args[$argcnt+1]}
  84.   fi
  85.   (( argcnt++ ))
  86. done
  87.  
  88. if [ $resetOut != -1 ]; then
  89.   if [ $resetOut -ge 1 -a $resetOut -le 8 ] || [ $resetOut -ge 101 -a $resetOut -le 108 ]; then
  90.     snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.$resetOut i 10
  91.   else
  92.     echo "Please select output between 1 and 8 (channel 1) or 101 and 108 (output 2)."
  93.   fi
  94. else
  95.   if [ $outSel != -1 ]; then
  96.     # limit the channels to the correct value
  97.     if [ $outSel -ge 1 -a $outSel -le 8 ] || [ $outSel -ge 101 -a $outSel -le 108 ]; then
  98.       if [ $outVolt != -1 ]; then
  99.         snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputVoltage.$outSel F $outVolt
  100.       fi
  101.       if [ $outSw != -1 ]; then
  102.         snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.$outSel i $outSw
  103.       fi
  104.       if [ $getOut != -1 ]; then
  105.         snmpget -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputVoltage.$outSel
  106.         snmpget -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.$outSel
  107.       fi
  108.     else
  109.       echo "Please select output between 1 and 8 (channel 1) or 101 and 108 (output 2)."
  110.     fi
  111.   fi
  112. fi
  113.  
  114. exit 0
  115.