#!/bin/bash
# Commands:
# snmpset - sets the selected attribute of a single channel
# snmpget - prints the selected atribute of a single channel
# snmpwalk - prints the selected attribute of all channels
#
# Attributes:
# outputVoltage - float(F), R/W
# outputCurrent - float(F), R/W
# outputMeasurementSenseVoltage - float(F), R
# outputMeasurementCurrent - float(F), R
# outputSwitch - integer(i), R/W
# outputVoltageRiseRate - float(F), R/W
# outputStatus - bits, R
#ip=194.249.156.124
#ip=f9mpod.ijs.si
#if [$1 -lt 99]; then
# if [$2 -lt 74]; then
# echo "Setting bias to " $2
# snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputVoltage.$1 F $2
# else
# echo "Bias voltage needs to be smaller than 74V."
# fi
#else if [$1 -gt 99]; then
# if [$2 -lt 35]; then
# echo "Setting bias to " $2
# snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputVoltage.$1 F $2
# else
# echo "Bias voltage needs to be smaller than 35V."
# fi
#fi
function reset_all
{
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.1 i 10
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.2 i 10
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.3 i 10
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.4 i 10
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.5 i 10
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.6 i 10
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.7 i 10
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.8 i 10
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.101 i 10
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.102 i 10
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.103 i 10
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.104 i 10
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.105 i 10
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.106 i 10
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.107 i 10
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.108 i 10
exit 0
}
ip=f9mpod.ijs.si
# save all arguments to array args
args=("$@")
argcnt=0
outSel=-1
outVolt=-1
outSw=-1
resetOut=-1
getOut=-1
# search the arguments for valid options
for ARG in "${args[@]}"; do
if [ "$ARG" == "--resetall" ]; then
reset_all
elif [ "$ARG" == "-g" ]; then
getOut=1
elif [ "$ARG" == "-r" ]; then
resetOut=${args[$argcnt+1]}
elif [ "$ARG" == "-o" ]; then
outSel=${args[$argcnt+1]}
elif [ "$ARG" == "-v" ]; then
outVolt=${args[$argcnt+1]}
elif [ "$ARG" == "-s" ]; then
outSw=${args[$argcnt+1]}
fi
(( argcnt++ ))
done
if [ $resetOut != -1 ]; then
if [ $resetOut -ge 1 -a $resetOut -le 8 ] || [ $resetOut -ge 101 -a $resetOut -le 108 ]; then
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.$resetOut i 10
else
echo "Please select output between 1 and 8 (channel 1) or 101 and 108 (output 2)."
fi
else
if [ $outSel != -1 ]; then
# limit the channels to the correct value
if [ $outSel -ge 1 -a $outSel -le 8 ] || [ $outSel -ge 101 -a $outSel -le 108 ]; then
if [ $outVolt != -1 ]; then
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputVoltage.$outSel F $outVolt
fi
if [ $outSw != -1 ]; then
snmpset -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.$outSel i $outSw
fi
if [ $getOut != -1 ]; then
snmpget -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputVoltage.$outSel
snmpget -v 2c -M +. -m +WIENER-CRATE-MIB -c guru $ip outputSwitch.$outSel
fi
else
echo "Please select output between 1 and 8 (channel 1) or 101 and 108 (output 2)."
fi
fi
fi
exit 0