#!/bin/sh
#------------------------------------------------------------------------------
# OPT_EMBEDDED  /etc/rrdtool/aewin.val                             __FLI4LVER__
# Creation:     2005-12-23 gdw
# Last Update:  $Id$
# 
# rrdtool aewin Datenerfassung
#------------------------------------------------------------------------------

[ -z "$RDTOOL_CONF_LOADED" ] && . /var/run/rrdtool.conf

local source=aewin
eval local idx='$RRDTOOL_'$source'_ID'
eval local options='$RRDTOOL_'$idx'_OPTIONS_STRING'

for item in $options
do
    local db_file=$RRDTOOL_DB_PATH/$source/$item.rrd
    case "$item" in
    "temperature")
       	value1=`cat /sys/class/hwmon/hwmon0/device/temp2_input | sed 's/^\([0-9]\+\)\([0-9]\{3\}\)/\1.\2/'`
        value2=`cat /sys/class/hwmon/hwmon0/device/temp1_input | sed 's/^\([0-9]\+\)\([0-9]\{3\}\)/\1.\2/'`
        rrdtool update $db_file \
        N:$value1:$value2
        ;;
    "voltage")
    	V5=`cat /sys/class/hwmon/hwmon0/device/in3_input`
	VCC=`cat /sys/class/hwmon/hwmon0/device/in7_input`
	value0=`cat /sys/class/hwmon/hwmon0/device/in0_input | sed 's/^\([0-9]\)\([0-9]\)/\1.\2/'`
	value1=`cat /sys/class/hwmon/hwmon0/device/in1_input | sed 's/^\([0-9]\)\([0-9]\)/\1.\2/'`
	value2=`cat /sys/class/hwmon/hwmon0/device/in2_input | sed 's/^\([0-9]\)\([0-9]\)/\1.\2/'`
	value3=`expr $V5 \* 168 | sed 's/^\([0-9]\)\([0-9]\{3\}\).*/\1.\2/'`
	value4=`expr $VCC \* 168 | sed 's/^\([0-9]\)\([0-9]\{3\}\).*/\1.\2/'`
	value5=`cat /sys/class/hwmon/hwmon0/device/in8_input | sed 's/^\([0-9]\)\([0-9]\)/\1.\2/'`
        rrdtool update $db_file \
        N:$value0:$value1:$value2:$value3:$value4:$value5
        ;;
    esac
done
