#!/bin/bash SUBDIR=Infrastructure ThisDev=PwSp source Commons.sh ChargingFlag=0 function Init() { CommonInit LogIt "$DOWNTO ${FUNCNAME[0]}" echo "Slow">$SHM/Charging echo ":STOP;RUN"|$oscilosc_w1;sleep 1;echo ":STOP"|$oscilosc_w1 LogIt "$UPFROM ${FUNCNAME[0]}" } ChargingResistors=0 function Prepare() { LogIt "$DOWNTO ${FUNCNAME[0]}" UBtRequest=$1;UEtRequest=$2 HVon;ChargingFlag=1; if [ $UBtRequest -gt 200 ]; then ChargResOFF; fi StatusScanGo #https://www.socscistatistics.com/tests/regression/default.aspx #1300:99,800:90,200:80 #BtSlowLine=95 # Hrana na pomale nabijeni .... BtSlowLine=`echo "0.01725*$UBtRequest + 76.43956"|bc|xargs printf '%4.0f\n'` LogIt "U_Bt: $UBtRequest, Hrana: $BtSlowLine" EtSlowLine=85 # Hrana na pomale nabijeni .... LogIt "U_Et: $UEtRequest, Hrana: $EtSlowLine" #LogIt "PIDs: $PID1, $PID2" while [ $ChargingFlag -eq 1 ]; do UBt=`tail -1 $SHMdir/U@Bt|xargs printf '%4.0f\n'` StatusBt=`tail -1 $SHMdir/Status@Bt` Ucd=`tail -1 $SHMdir/U@Et|xargs printf '%4.0f\n'` StatusEt=`tail -1 $SHMdir/Status@Et` if [ "$StatusEt" = "Charged" ] && [ "$StatusBt" = "Charged" ];then Finito;ChargingFlag=0;fi if [ $UBt -gt $(($UBtRequest*$BtSlowLine/100)) ] && [ $ChargingResistors == 0 ] && [ "$StatusBt" = "Charging" ]; then LogIt "Bt slow PowSup";ChargResON;fi if [ $Ucd -gt $(($UEtRequest*$EtSlowLine/100)) ] && [ $ChargingResistors == 0 ] && [ "$StatusEt" = "Charging" ]; then LogIt "Et slow PowSup";ChargResON;fi if [ "$StatusEt" = "Charged" ] && [ $ChargingResistors == 1 ] && [ $UBt -lt $(($UBtRequest*$BtSlowLine/100)) ]; then LogIt "Bt boost PowSup";ChargResOFF;fi sleep 1 done HVoff LogIt "$UPFROM ${FUNCNAME[0]}" } function Finito() { #for i in `seq 4`; do kill $PID$i;done #Priste ... kill $PID1;kill $PID2;kill $PID3;kill $PID4 } PID1=0;PID2=0;PID3=0;PID4=0 function StatusScanGo() { ssh -T golem@Bt "tail -f "$SHM"/OscRespondStream" >> $SHMdir/U@Bt & PID1=$! ssh -T golem@Bt "tail -f "$SHM"/Status 2> /dev/null" >> $SHMdir/Status@Bt & PID2=$! ssh -T golem@Et "tail -f "$SHM"/OscRespondStream" >> $SHMdir/U@Et & PID3=$! ssh -T golem@Et "tail -f "$SHM"/Status 2> /dev/null" >> $SHMdir/Status@Et & PID4=$! } function Arming() { LogIt "$PASSING ${FUNCNAME[0]}" } function Final() { LogIt "$PASSING ${FUNCNAME[0]}" echo ":STOP"|$oscilosc_w1 GetScreenShot } function PostDisch() { LogIt "$PASSING ${FUNCNAME[0]}" } function Emergency() { #PwSpPap 3L HVoff LogIt "$DOWNTO ${FUNCNAME[0]}" $SHMtouch/Emergency LogIt "$UPFROM ${FUNCNAME[0]}" } function HVon() { LogIt "HV power supply on" HVlightON UnPiRelayON 8 sleep 1 #PwSpPap 3H } function HVoff() { #PwSpPap 3L sleep 0.2 UnPiRelayOFF 8 LogIt "HV power supply off" HVlightOFF ChargResON } function ChargResOFF() { LogIt "$PASSING ${FUNCNAME[0]}" ChargingResistors=0 PwSpPap 6H; sleep 1 PwSpPap 7H; sleep 1 PwSpPap 8H; sleep 1 echo "Fast">$SHM/Charging #echo "*B1OS6H"|telnet PowSupPap 10001 1>&- 2>&-;sleep 1 #echo "*B1OS7H"|telnet PowSupPap 10001 1>&- 2>&-;sleep 1 #echo "*B1OS8H"|telnet PowSupPap 10001 1>&- 2>&-;sleep 1 } function ChargResON() { LogIt "$PASSING ${FUNCNAME[0]}" ChargingResistors=1 PwSpPap 6L PwSpPap 7L PwSpPap 8L echo "Slow">$SHM/Charging #echo "*B1OS6L"|telnet PowSupPap 10001 1>&- 2>&- #echo "*B1OS7L"|telnet PowSupPap 10001 1>&- 2>&- #echo "*B1OS8L"|telnet PowSupPap 10001 1>&- 2>&- } function HVlightON() { UnPiRelayON 7 } function HVlightOFF() { UnPiRelayOFF 7 }