Select Git revision
generateStationStreams.sh
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
generateStationStreams.sh 3.26 KiB
#!/bin/bash
#
# Usage (to commit new StationStreams.parset):
# ./generateStationStreams.sh > StationStreams.parset
#
# Usage (post-rollout on live test system):
# export LOFARROOT=/path/to/lofarroot
# "$LOFARROOT/sbin/generateStationStreams.sh" > "$LOFARROOT/etc/parset-additions.d/default/StationStreams.parset"
#
# Thus if $LOFARROOT is set, the 3 required files below will be accessed under:
# $LOFARROOT/etc/StaticMetaData/
#
# Requires:
# RSPConnections_Cobalt.dat
#
# These files are symlinks under GPUProc, but can be found in:
# MAC/Deployment/data/StaticMetaData
#
# $Id$
if [ "$LOFARROOT" != "" ]; then
export in_prefix="$LOFARROOT/etc/StaticMetaData/" # must have trailing slash
fi
# always generate/sort entries in the same order for equality testing
export LC_ALL=C
echo "# StationStreams.parset This file is generated by generateStationStreams.sh"
cat "${in_prefix}RSPConnections_Cobalt.dat" | sort | awk '
#
# Make sure that for each antenna field, there is one line
# per RSP board. We do this by repeating the same line for
# each station that has fewer than 4 (typically 1) line.
#
BEGIN {
prevstat = "";
prevboard = "";
prevline = "";
rsp_seen = 0;
}
/RSP/ {
stat = $1;
board = $2;
line = $0;
if (stat == prevstat && board == prevboard) {
rsp_seen++;
} else {
for (i = 0; i < 4 - rsp_seen; ++i)
print prevline;
rsp_seen = 1;
};
print line;
prevline = line;
prevstat = stat;
prevboard = board;
}' | perl -ne '
/^(\w+) RSP_([01])\s+([^ \t\n]+)\s+([^ \t\n]+)/ || next;
# Each station is represented by 4 lines, one for each
# RSP board. We parse 4 lines, collect the destination
# IPs, and continue based on the last line for the
# rest of the information.
$station = $1;
$board = $2;
$iface = $3;
$ip = $4;
$station =~ /^[A-Z][A-Z]([0-9]+)/;
$stationnr = $1;
$intl = $stationnr >= 600;
if ($rspNr <= 0 || $rspNr >= 4) {
# new station
$ips = {};
$rspNr = 0;
}
$ips{$rspNr} = $intl ? $ip : $iface;
next if ++$rspNr < 4;
$baseport = 10000 + $stationnr * 10;
$portstr = sprintf "[udp:%s:%d, udp:%s:%d, udp:%s:%d, udp:%s:%d]",
$ips{0}, $baseport + ($board * 6) + 0,
$ips{1}, $baseport + ($board * 6) + 1,
$ips{2}, $baseport + ($board * 6) + 2,
$ips{3}, $baseport + ($board * 6) + 3;
$iface =~ /(cbt[0-9]+)-10GB0([1234])/;
$host = $1;
$socket = ($2 - 1)/2; # 10GB01, 10GB02 = socket 0, 10GB03, 10GB04 = socket 1
$receiver = sprintf "%s_%u", $host, $socket;
if ($board == 0) {
printf "PIC.Core.%sLBA.RSP.receiver = %s\n",$station,$receiver;
printf "PIC.Core.%sLBA.RSP.ports = %s\n",$station,$portstr;
printf "PIC.Core.%sHBA.RSP.receiver = %s\n",$station,$receiver;
printf "PIC.Core.%sHBA.RSP.ports = %s\n",$station,$portstr;
if ($station =~ /^CS/) {
printf "PIC.Core.%sHBA0.RSP.receiver = %s\n",$station,$receiver;
printf "PIC.Core.%sHBA0.RSP.ports = %s\n",$station,$portstr;
} else {
# print "\n";
}
}
if ($board == 1) {
printf "PIC.Core.%sHBA1.RSP.receiver = %s\n",$station,$receiver;
printf "PIC.Core.%sHBA1.RSP.ports = %s\n",$station,$portstr;
# print "\n";
}
' | sort | uniq
# Remove duplicate entries, because RSPConnections_Cobalt.dat now can have
# multiple lines per station (one for each RSP board), which contains
# information that we already obtain from RSP+IP.dat