2022-10-31 21:26:10 -04:00
|
|
|
#!/bin/bash -l
|
|
|
|
|
|
|
|
source ~/FSUDAQ/FSUDAQ.sh
|
|
|
|
|
|
|
|
|
2022-11-02 15:43:23 -04:00
|
|
|
echo "======================================= making elog Entry"
|
|
|
|
echo ${DataPath}
|
|
|
|
echo ${ExpName}
|
|
|
|
echo ${ElogIP}
|
2022-10-31 21:26:10 -04:00
|
|
|
|
2022-11-02 15:43:23 -04:00
|
|
|
elogIDFile=${DataPath}"/elogID.txt"
|
|
|
|
source ${elogIDFile}
|
2022-10-31 21:26:10 -04:00
|
|
|
|
2022-11-02 15:43:23 -04:00
|
|
|
echo ${ElogID}
|
|
|
|
isStart=$1
|
|
|
|
Comment=$2
|
2022-10-31 21:26:10 -04:00
|
|
|
|
2022-11-02 15:43:23 -04:00
|
|
|
elogFileName=${DataPath}"/elogText.txt"
|
|
|
|
|
|
|
|
echo ${isStart}
|
|
|
|
echo ${Comment}
|
|
|
|
|
2022-11-02 19:01:06 -04:00
|
|
|
#Get file size
|
|
|
|
RUN=${lastRunID}
|
|
|
|
runLen=${#lastRunID}
|
|
|
|
if [ ${runLen} -eq 1 ]; then
|
|
|
|
RUN="00"${RUN}
|
|
|
|
elif [ ${runLen} -eq 2 ]; then
|
|
|
|
RUN="0"${RUN}
|
|
|
|
fi;
|
|
|
|
|
|
|
|
|
2022-11-02 15:43:23 -04:00
|
|
|
if [ ${isStart} == "1" ]; then
|
|
|
|
|
|
|
|
#make text file for elog text
|
2022-11-02 19:01:06 -04:00
|
|
|
echo "************************************************************************** <br />" > ${elogFileName}
|
|
|
|
echo "Run-${RUN} start at $(date) <br />" >> ${elogFileName}
|
|
|
|
echo "Start Run Comment : "${Comment}" <br />">> ${elogFileName}
|
|
|
|
echo "-------------------------------------------------------------------------- <br />" >> ${elogFileName}
|
|
|
|
|
2022-11-02 15:43:23 -04:00
|
|
|
|
|
|
|
#push to elog
|
2022-11-02 19:01:06 -04:00
|
|
|
IDStr=$(elog -h ${ElogIP} -l ${ExpName} -u GeneralFox fsuphysics888 -a Author="GeneralFox" -a Category="Run" -a RunNo=${lastRunID} -a Subject="Run Log" -n 2 -m ${elogFileName})
|
|
|
|
|
|
|
|
echo "==========="${IDStr}
|
2022-11-02 15:43:23 -04:00
|
|
|
|
|
|
|
IDStr=$(echo ${IDStr} | tail -1 | awk '{print $4}')
|
|
|
|
|
2022-11-02 19:01:06 -04:00
|
|
|
echo ".............."${IDStr}
|
2022-11-02 15:43:23 -04:00
|
|
|
|
|
|
|
if [ ${IDStr:0:3} == "ID=" ] && [[ ${IDStr:3} =~ ${re} ]]; then
|
|
|
|
elogIDStr="Elog"${IDStr}
|
|
|
|
echo "Elog is succefully pushed at ${elogIDStr}"
|
|
|
|
echo ${elogIDStr} >> ${elogIDFile}
|
|
|
|
fi
|
|
|
|
|
|
|
|
else
|
|
|
|
|
2022-11-02 19:01:06 -04:00
|
|
|
elogFileName2=${DataPath}"/elogText2.txt"
|
2022-11-02 15:43:23 -04:00
|
|
|
|
|
|
|
#download elog entry
|
|
|
|
echo "====== getting elog entry"
|
|
|
|
elog -h ${ElogIP} -l elog/${ExpName} -u GeneralFox fsuphysics888 -w ${ElogID} > ${elogFileName2}
|
|
|
|
|
|
|
|
echo "======================="
|
2022-11-02 19:01:06 -04:00
|
|
|
#cat ${elogFileName2}
|
2022-11-02 15:43:23 -04:00
|
|
|
|
2022-11-02 19:01:06 -04:00
|
|
|
echo "remove header"
|
|
|
|
cutLineNum=$(grep -n "==============" ${elogFileName2} | cut -d: -f1)
|
|
|
|
#check encoding
|
|
|
|
encoding=$(grep "Encoding" ${elogFileName2} | awk '{print $2}')
|
|
|
|
if [ $encoding = "plain" ]; then encodingID=1 ; fi
|
|
|
|
if [ $encoding = "HTML" ]; then encodingID=2 ; fi
|
|
|
|
if [ $encoding = "ELcode" ]; then encodingID=0 ; fi
|
|
|
|
#remove all header
|
|
|
|
sed -i "1,${cutLineNum}d" ${elogFileName2}
|
|
|
|
|
|
|
|
echo "Run Stop at $(date) <br />" >> ${elogFileName2}
|
|
|
|
|
|
|
|
#Comment
|
|
|
|
echo "End Run Comment : "${Comment}" <br />" >> ${elogFileName2}
|
|
|
|
|
|
|
|
totalFileSize=$(du -hc ${DataPath}"/data/"${ExpName}_run${RUN}* | tail -1| awk {'print $1'})
|
|
|
|
echo "File Size : "${totalFileSize}" <br />">> ${elogFileName2}
|
|
|
|
echo "************************************************************************** <br />" >> ${elogFileName2}
|
|
|
|
|
|
|
|
cat ${elogFileName2}
|
|
|
|
|
|
|
|
elog -h ${ElogIP} -p 8080 -l ${ExpName} -u GeneralFox fsuphysics888 -e ${ElogID} -n ${encodingID} -m ${elogFileName2}
|
2022-11-02 15:43:23 -04:00
|
|
|
|
|
|
|
fi
|