From 9066f1d95f809e960e653a7a48c60c36ad2adb1f Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Sat, 20 Oct 2018 14:26:33 +0200 Subject: [PATCH] started writing wrapper shell script for obsoleting villas-signal --- tools/villas-signal.sh | 86 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100755 tools/villas-signal.sh diff --git a/tools/villas-signal.sh b/tools/villas-signal.sh new file mode 100755 index 000000000..8e0433b63 --- /dev/null +++ b/tools/villas-signal.sh @@ -0,0 +1,86 @@ +#!/bin/bash +# Wrapper around villas-pipe which uses the signal generator node-type +# +# @author Steffen Vogel +# @copyright 2018, Institute for Automation of Complex Power Systems, EONERC +# @license GNU General Public License (version 3) +# +# VILLASnode +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +################################################################################### + +function usage() { + echo "Usage: villas-signal [OPTIONS] SIGNAL" + echo " SIGNAL is on of the following signal types:" + echo " mixed" + echo " random" + echo " sine" + echo " triangle" + echo " square" + echo " ramp" + echo " constants" + echo " counter" + echo "" + echo " OPTIONS is one or more of the following options:" + echo " -d LVL set debug level" + echo " -f FMT set the format" + echo " -v NUM specifies how many values a message should contain" + echo " -r HZ how many messages per second" + echo " -n non real-time mode. do not throttle output." + echo " -F HZ the frequency of the signal" + echo " -a FLT the amplitude" + echo " -D FLT the standard deviation for 'random' signals" + echo " -o OFF the DC bias" + echo " -l NUM only send LIMIT messages and stop" + echo + echo "VILLASnode $(villas-node -v)" + echo " Copyright 2014-2018, Institute for Automation of Complex Power Systems, EONERC" + echo " Steffen Vogel " + exit 1 +} + +OPTS=() + +while getopts "v:r:f:l:a:D:no:h" OPT; do + case $OPT in + n) OPTS+=("-o realtime=false") ;; + l) OPTS+=("-o limit=$OPTARG") ;; + v) OPTS+=("-o values=$OPTARG") ;; + r) OPTS+=("-o rate=$OPTARG") ;; + o) OPTS+=("-o offset=$OPTARG") ;; + f) OPTS+=("-o frequency=$OPTARG") ;; + a) OPTS+=("-o amplitude=$OPTARG") ;; + D) OPTS+=("-o stddev=$OPTARG") ;; + h) + usage + exit 0 + ;; + \?) + echo "Invalid option: -$OPTARG" >&2 + usage + exit 1 + ;; + esac +done + +# and shift them away +shift $((OPTIND - 1)) + +if (( $# != 1 )); then + usage + exit 1 +fi + +echo villas-pipe -r -t signal -o signal=$1 ${OPTS[@]}