Skip to content
Snippets Groups Projects
Commit 9c738379 authored by Mario's avatar Mario
Browse files

-c necessary *only* when *creating* cfg files from scratch

parent 3fb29329
No related branches found
No related tags found
No related merge requests found
Pipeline #2580882 passed
......@@ -231,7 +231,7 @@ fi
nChips="$(jq -j --arg b ${module_id} '.modules."\($b)".chips | length' $MODULECFG)"
cfgdir=$SOBASE/configs/rd53a/$module_id
CNCT_FILE=$cfgdir/connectivity.json
if [ $createConfig == 1 ] ; then
rm -rf $cfgdir
......@@ -359,133 +359,125 @@ if [ $createConfig == 1 ] ; then
fi
# Generate chip cfg files
for (( i=0; i<$nChips; i++ ))
do
CNCT_FILE=$cfgdir/connectivity.json
echo ""
echo "------------------------"
# create default chipConfig.json
chipName="$(jq -j --argjson a ${i} --arg b ${module_id} '.modules."\($b)".chips[$a].connectivity.name' $MODULECFG)"
echo -e "[ info ][so] Creating config file for chip \"$(green $chipName)\": $cfgdir/$chipName.json"
$YARRBASE/bin/createConfig -t RD53A -n $chipName -o $cfgdir/$chipName.json #> /dev/null
done
# Modify retrieved Yarr config files according to config.json
# Generate controller cfg file
CRTL_FILE=$cfgdir/controller.json
cp $YARRBASE/configs/controller/specCfg-rd53a.json $CRTL_FILE
specNum=$(jq -j --arg b ${module_id} '.modules."\($b)".specNum' $MODULECFG)
if [ "$specNum" != "null" ]; then
jq --argjson v $specNum '.ctrlCfg.cfg.specNum = $v' $CRTL_FILE > currentValue && mv currentValue $CRTL_FILE
fi
# Chip config file
JSON_FILE=$cfgdir/$chipName.json
fi
echo ""
jq -r --argjson a ${i} --arg b ${module_id} '.modules."\($b)".chips[$a].GlobalConfig | keys[] as $k | "\($k) \(.[$k])"' $MODULECFG |
while IFS=" " read -r -a value; do
key=${value[0]}
val=${value[1]}
currentValue=$(jq --arg k ${key} '.RD53A.GlobalConfig."\($k)"' $JSON_FILE)
if [ "$currentValue" == "null" ];
then
jq --argjson v $val --arg k $key '.RD53A.GlobalConfig."\($k)" = $v' $JSON_FILE > currentValue && mv currentValue $JSON_FILE
echo -e "[ warn ][so] Added key $(darkblue \"$key\") with value $(darkblue \"$val\") in the chip config file (GlobalConfig section)"
elif [ "$currentValue" != $val ];
then
jq --argjson v $val --arg k $key '.RD53A.GlobalConfig."\($k)" = $v' $JSON_FILE > currentValue && mv currentValue $JSON_FILE
echo -e "[ info ][so] Changed $(darkblue \"$key\") from $(darkblue \"$currentValue\") to $(darkblue \"$val\") in the chip config file (GlobalConfig section)"
fi
done
echo ""
# Modify config files according to config.json
for (( i=0; i<$nChips; i++ ))
do
# Parameter section
jq -r --argjson a ${i} --arg b ${module_id} '.modules."\($b)".chips[$a].Parameter | keys[] as $k | "\($k) \(.[$k])"' $MODULECFG |
while IFS=" " read -r -a value; do
key=${value[0]}
val=${value[1]}
# Chip config file
chipName="$(jq -j --argjson a ${i} --arg b ${module_id} '.modules."\($b)".chips[$a].connectivity.name' $MODULECFG)"
JSON_FILE=$cfgdir/$chipName.json
currentValue=$(jq -r --arg k ${key} '.RD53A.Parameter."\($k)"' $JSON_FILE)
echo -e "[ info ][so] Looking for cfg updates in chip $i's configs..."
jq -r --argjson a ${i} --arg b ${module_id} '.modules."\($b)".chips[$a].GlobalConfig | keys[] as $k | "\($k) \(.[$k])"' $MODULECFG |
while IFS=" " read -r -a value; do
key=${value[0]}
val=${value[1]}
if [ "$currentValue" == "null" ];
then
jq --argjson v $val --arg k $key '.RD53A.Parameter."\($k)" = $v' $JSON_FILE > currentValue && mv currentValue $JSON_FILE
echo -e "[ warn ][so] Added key $(darkblue \"$key\") with value $(darkblue \"$val\") in the chip config file (Parameter section)"
currentValue=$(jq --arg k ${key} '.RD53A.GlobalConfig."\($k)"' $JSON_FILE)
elif [ "$currentValue" != "$val" ];
then
if ! [[ "$val" =~ ^[0-9]+$ ]] ; then
jq --arg v $val --arg k $key '.RD53A.Parameter."\($k)" = "\($v)"' $JSON_FILE > currentValue && mv currentValue $JSON_FILE
if [ "$currentValue" == "null" ];
then
jq --argjson v $val --arg k $key '.RD53A.GlobalConfig."\($k)" = $v' $JSON_FILE > currentValue && mv currentValue $JSON_FILE
echo -e "[ warn ][so] Added key $(darkblue \"$key\") with value $(darkblue \"$val\") in the chip config file (GlobalConfig section)"
else
jq --argjson v $val --arg k $key '.RD53A.Parameter."\($k)" = $v' $JSON_FILE > currentValue && mv currentValue $JSON_FILE
fi
echo -e "[ info ][so] Changed $(darkblue \"$key\") from $(darkblue \"$currentValue\") to $(darkblue \"$val\") in the chip config file (Parameter section)"
fi
done
elif [ "$currentValue" != $val ];
then
jq --argjson v $val --arg k $key '.RD53A.GlobalConfig."\($k)" = $v' $JSON_FILE > currentValue && mv currentValue $JSON_FILE
echo -e "[ info ][so] Changed $(darkblue \"$key\") from $(darkblue \"$currentValue\") to $(darkblue \"$val\") in the chip config file (GlobalConfig section)"
fi
done
# Connectivity file:
echo ""
echo -e "[ info ][so] Linking chip cfg file in the connectivity file (chip $i)"
jq -e --argjson a ${i} --arg v $JSON_FILE '.chips[$a].config = "\($v)"' $CNCT_FILE > currentValue && mv currentValue $CNCT_FILE
# Parameter section
jq -r --argjson a ${i} --arg b ${module_id} '.modules."\($b)".chips[$a].Parameter | keys[] as $k | "\($k) \(.[$k])"' $MODULECFG |
while IFS=" " read -r -a value; do
key=${value[0]}
val=${value[1]}
jq -r --argjson a ${i} --arg b ${module_id} '.modules."\($b)".chips[$a].connectivity | keys[] as $k | "\($k) \(.[$k])"' $MODULECFG |
while IFS=" " read -r -a value; do
key=${value[0]}
val=${value[1]}
currentValue=$(jq -r --arg k ${key} '.RD53A.Parameter."\($k)"' $JSON_FILE)
currentValue=$(jq -r --argjson a ${i} --arg k ${key} '.chips[$a]."\($k)"' $CNCT_FILE)
if [ "$currentValue" == "null" ];
then
jq --argjson v $val --arg k $key '.RD53A.Parameter."\($k)" = $v' $JSON_FILE > currentValue && mv currentValue $JSON_FILE
echo -e "[ warn ][so] Added key $(darkblue \"$key\") with value $(darkblue \"$val\") in the chip config file (Parameter section)"
if [ "$currentValue" == "null" ];
then
jq --argjson a ${i} --argjson v $val --arg k $key '.chips[$a]."\($k)" = $v' $CNCT_FILE > currentValue && mv currentValue $CNCT_FILE
echo -e "[ warn ][so] Added key $(darkblue \"$key\") with value $(darkblue \"$val\") in the connectivity file (chip $i)"
elif [ "$currentValue" != "$val" ];
then
if ! [[ "$val" =~ ^[0-9]+$ ]] ; then
jq --argjson a ${i} --arg v $val --arg k $key '.chips[$a]."\($k)" = "\($v)"' $CNCT_FILE > currentValue && mv currentValue $CNCT_FILE
else
jq --argjson a ${i} --argjson v $val --arg k $key '.chips[$a]."\($k)" = $v' $CNCT_FILE > currentValue && mv currentValue $CNCT_FILE
fi
elif [ "$currentValue" != "$val" ];
then
if ! [[ "$val" =~ ^[0-9]+$ ]] ; then
jq --arg v $val --arg k $key '.RD53A.Parameter."\($k)" = "\($v)"' $JSON_FILE > currentValue && mv currentValue $JSON_FILE
echo -e "[ info ][so] Changed $(darkblue \"$key\") from $(darkblue \"$currentValue\") to $(darkblue \"$val\") in the connectivity file (chip $i)"
else
jq --argjson v $val --arg k $key '.RD53A.Parameter."\($k)" = $v' $JSON_FILE > currentValue && mv currentValue $JSON_FILE
fi
done
echo -e "[ info ][so] Changed $(darkblue \"$key\") from $(darkblue \"$currentValue\") to $(darkblue \"$val\") in the chip config file (Parameter section)"
fi
done
# Connectivity file:
jq -e --argjson a ${i} --arg v $JSON_FILE '.chips[$a].config = "\($v)"' $CNCT_FILE > currentValue && mv currentValue $CNCT_FILE
jq -r --argjson a ${i} --arg b ${module_id} '.modules."\($b)".chips[$a].connectivity | keys[] as $k | "\($k) \(.[$k])"' $MODULECFG |
while IFS=" " read -r -a value; do
key=${value[0]}
val=${value[1]}
currentValue=$(jq -r --argjson a ${i} --arg k ${key} '.chips[$a]."\($k)"' $CNCT_FILE)
if [ "$currentValue" == "null" ];
then
jq --argjson a ${i} --argjson v $val --arg k $key '.chips[$a]."\($k)" = $v' $CNCT_FILE > currentValue && mv currentValue $CNCT_FILE
echo -e "[ warn ][so] Added key $(darkblue \"$key\") with value $(darkblue \"$val\") in the connectivity file (chip $i)"
# Create an entry with the module serial number (to associate the config
# files to in localdb)
jq '. += {"module"}' $CNCT_FILE > sotmp && mv sotmp $CNCT_FILE
jq --arg a ${module_id} '.module += {"serialNumber": "\($a)"}' $CNCT_FILE > sotmp && mv sotmp $CNCT_FILE
jq '.module += {"componentType": "module"}' $CNCT_FILE > sotmp && mv sotmp $CNCT_FILE
elif [ "$currentValue" != "$val" ];
then
if ! [[ "$val" =~ ^[0-9]+$ ]] ; then
jq --argjson a ${i} --arg v $val --arg k $key '.chips[$a]."\($k)" = "\($v)"' $CNCT_FILE > currentValue && mv currentValue $CNCT_FILE
else
jq --argjson a ${i} --argjson v $val --arg k $key '.chips[$a]."\($k)" = $v' $CNCT_FILE > currentValue && mv currentValue $CNCT_FILE
fi
echo -e "[ info ][so] Changed $(darkblue \"$key\") from $(darkblue \"$currentValue\") to $(darkblue \"$val\") in the connectivity file (chip $i)"
fi
done
# Controller file
CRTL_FILE=$cfgdir/controller.json
cp $YARRBASE/configs/controller/specCfg-rd53a.json $CRTL_FILE
specNum=$(jq -j --arg b ${module_id} '.modules."\($b)".specNum' $MODULECFG)
if [ "$specNum" != "null" ]; then
jq --argjson v $specNum '.ctrlCfg.cfg.specNum = $v' $CRTL_FILE > currentValue && mv currentValue $CRTL_FILE
fi
# Create an entry with the module serial number (to associate the config
# files to in localdb)
jq '. += {"module"}' $CNCT_FILE > sotmp && mv sotmp $CNCT_FILE
jq --arg a ${module_id} '.module += {"serialNumber": "\($a)"}' $CNCT_FILE > sotmp && mv sotmp $CNCT_FILE
jq '.module += {"componentType": "module"}' $CNCT_FILE > sotmp && mv sotmp $CNCT_FILE
echo ""
done
echo "[ warn ][so] I hope these settings are correct:"
echo "------------------------"
cat $cfgdir/connectivity.json | jq .
echo "------------------------"
echo "------------------------"
cat $cfgdir/connectivity.json | jq .
echo "------------------------"
echo "[ warn ][so] Are these settings correct?"
unset answer
while [ -z "${answer}" ]; do
read -p "[y/n]: " answer
done
if [[ ${answer} != "y" ]]; then
echo "[ error ][so] Please modify the configuration in $MODULECFG and try again."
exit
fi
fi
if [ $dcsOnOff == 1 ] ;then
echo -e "\n[ info ][so] Turning ON the PS..."
......@@ -532,7 +524,6 @@ for i in $(seq 1 $nScans); do
obj="$(echo -e "${obj}" | tr -d '[:space:]')"
comm="$SOBASE/scanLauncher.sh -m ${module_id} -s $obj ${dcsOpt} ${localdbOpt} ${qcOpt} ${syncOption}"
echo $comm
echo -e "[ info ] |\n[ info ] | - $(echo $obj | jq -r '.[0]')\n[ info ] |"
if [ $quietMode -gt 0 ];
then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment