Sandbox/Dirigent/Commons.sh
#!/bin/bash
#RASPs="Chamb Et Bt Disch"
RASPs="Et Bt PwSp"
BUONs="PS DAS"
OSCs="EtOsc BtOsc PwSpOsc"
DASs="Tektr6Standard"
ARDs="Trigger"
PAPs="PowSupPap"
VIRTDevs=""
ALLDevs="$RASPs $OSCs $PAPs"
#ALLDevs="$RASPs $OSCs $DASs $PAPs"
INFRASTRDevs="$RASPs $VIRTDevs"
GM="golem@golem"
sshGM="ssh $GM"
XTERM="xterm -T $Dev -e ssh golem@$Dev"
LogBook="Shots/$ShotNo/$ThisDev.lgb"
DataB="psql -qAt -U golem golem_database"
SHM="/dev/shm/golem/0"
SHMdir="$SHM/$SUBDIR/$ThisDev"
SHMstring="$sshGM tee -a $SHM/$SUBDIR/$ThisDev"
SHMtouch="$sshGM touch $SHM/$SUBDIR/$ThisDev"
SHMrm="$sshGM rm $SHM/$SUBDIR/$ThisDev"
SHMgetValue="$sshGM cat $SHMdir"
LOC_LGB="$sshGM tee -a $SHM/$SUBDIR/$ThisDev/logbook 1>/dev/null"
GLOB_LGB="$sshGM tee -a $SHM/logbook"
NULL="1>/dev/null"
Ev2NULL="1>/dev/null 2>/dev/null"
DirigentDir="/GW/Sandbox/Dirigent"
#oscilosc="nc -w 1 "$ThisDev"Osc 5555"
oscilosc_stream="netcat "$ThisDev"Osc 5555"
oscilosc_w1="netcat -w 1 "$ThisDev"Osc 5555"
#oscilosc="socat -t 1 - TCP:"$ThisDev"Osc:5555"
#RUNinBACKGR="&> /dev/null"
RUNinBACKGR="&"
DOWNTO="Diving into"
UPFROM="Ascending from"
function Et()
{
ssh golem@Et "source Et.sh; $@"
}
function Bt()
{
ssh golem@Bt "source Bt.sh; $@"
}
function PwSp()
{
ssh golem@golem "cd $DirigentDir/;source PwSp.sh; $@"
}
function CommonInit()
{
$sshGM mkdir -p $SHMdir;
rm -rf $SHMdir;mkdir -p $SHMdir;
}
function LogIt()
{
echo `date '+%H:%M:%S'`\\t ${FUNCNAME[1]} $1 |$LOC_LGB
echo -e `date '+%H:%M:%S'`\\t $ThisDev/${FUNCNAME[1]}:\\t $1 |$GLOB_LGB
}
function critical_error()
{
LogIt "Critical error: $1 ... Stopped"
echo pack [label .error -text {Critical error: $1 ... stopped}]|wish
}
function RelayON()
{
echo "import lib as lib;lib.gpio_low($1)"|python
}
function RelayOFF()
{
echo "import lib as lib;lib.gpio_high($1)"|python
}
function GetScreenShot()
{
LogIt "Acquiring OSC screenshot .."
echo ":DISPLAY:DATA? ON,OFF,PNG" |$oscilosc| dd bs=1 skip=11 of=Shot/"$ThisDev"Osc.png status=none &> /dev/null
scp Shot/"$ThisDev"Osc.png $GM:$SHMdir/
}
function ps_grep_awk_kill ()
{
ps -Af|grep $1|awk '{ print $2 }'|xargs kill
}