From 1ccae7ff59ae03d327b754b13d44887258bb8e28 Mon Sep 17 00:00:00 2001 From: Malgosia Sobolewska Date: Mon, 18 Dec 2023 18:12:48 -0500 Subject: [PATCH 1/3] Removed Ephin temp related msids from the display --- snap_format.pm | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/snap_format.pm b/snap_format.pm index 1d53f6f..5ec18be 100644 --- a/snap_format.pm +++ b/snap_format.pm @@ -67,13 +67,13 @@ $s .= sprintf " SCS 130 %4s -Y SA Temp %7.2f ACIS $s .= sprintf "Roll Mom. %8.3f SCS 131 %4s %26s Cold Rad %6.1f\n", ${$h{AOSYMOM1}}[1], ${$h{COSCS131S}}[1], "", ${$h{"1CRAT"}}[1]; #removed E1300 -$s .= sprintf "Pitch Mom. %8.3f SCS 132 %4s Ephin temp %7.2f Warm Rad %6.1f\n", - ${$h{AOSYMOM2}}[1], ${$h{COSCS132S}}[1], ${$h{"5EPHINT"}}[1], ${$h{"1WRAT"}}[1]; #removed EPH A-Leak +$s .= sprintf "Pitch Mom. %8.3f SCS 132 %4s %26s Warm Rad %6.1f\n", + ${$h{AOSYMOM2}}[1], ${$h{COSCS132S}}[1], "", ${$h{"1WRAT"}}[1]; #removed EPH A-Leak -$s .= sprintf "Yaw Mom. %8.3f SCS 133 %4s EIO temp %9.2f RadMon %4s\n", - ${$h{AOSYMOM3}}[1], ${$h{COSCS133S}}[1], ${$h{"5EIOT"}}[1], ${$h{CORADMEN}}[1]; +$s .= sprintf "Yaw Mom. %8.3f SCS 133 %4s %26s RadMon %4s\n", + ${$h{AOSYMOM3}}[1], ${$h{COSCS133S}}[1], "", ${$h{CORADMEN}}[1]; -$s .= sprintf "PMTANKP %8.3f SCS 107 %4s EPH temp %9.2f \n", ${$h{PMTANKP}}[1],${$h{COSCS107S}}[1],${$h{TEPHIN}}[1]; +$s .= sprintf "PMTANKP %8.3f SCS 107 %4s\n", ${$h{PMTANKP}}[1], ${$h{COSCS107S}}[1]; #$s .= sprintf "Gyro 2 Curr 1 %6.2f ", ${$h{AIRU2G1I}}[1]; ##$s .= sprintf "\nGyro 1 Curr 1 %6.2f Roll Bias %7.4f EPH 27I %9.2f", ${$h{AIRU1G1I}}[1], ${$h{AOGBIAS1}}[1]*206264.98, ${$h{"5HSE202"}}[1]; @@ -332,10 +332,8 @@ $s .= sprintf "Cold Rad %6.1f\n", $s .= sprintf ''; $s .= sprintf "Pitch Mom. %8.3f ", ${$h{AOSYMOM2}}[3], ${$h{AOSYMOM2}}[1]; -$s .= sprintf "SCS 132 %4s ", +$s .= sprintf "SCS 132 %4s %27s", ${$h{COSCS132S}}[3], ${$h{COSCS132S}}[1]; -$s .= sprintf "Ephin Temp%8.4f ", - ${$h{"5EPHINT"}}[3], ${$h{"5EPHINT"}}[1]; $s .= sprintf "Warm Rad %6.1f\n", ${$h{"1WRAT"}}[3], ${$h{"1WRAT"}}[1]; #$s .= sprintf "P4GM%11.1f\n", @@ -345,10 +343,8 @@ $s .= sprintf "Warm Rad %6.1f\n", $s .= sprintf ''; $s .= sprintf "Yaw Mom. %8.3f ", ${$h{AOSYMOM3}}[3], ${$h{AOSYMOM3}}[1]; -$s .= sprintf "SCS 133 %4s ", +$s .= sprintf "SCS 133 %4s %27s", ${$h{COSCS133S}}[3], ${$h{COSCS133S}}[1]; -$s .= sprintf "EIO Temp%10.4f ", - ${$h{"5EIOT"}}[3], ${$h{"5EIOT"}}[1]; $s .= sprintf "RadMon %4s\n", ${$h{CORADMEN}}[3], ${$h{CORADMEN}}[1]; @@ -358,10 +354,8 @@ $s .= sprintf "RadMon %4s\n", $s .= sprintf "PMTANKP %7.3f ", ${$h{PMTANKP}}[3], ${$h{PMTANKP}}[1]; -$s .= sprintf "SCS 107 %4s ", +$s .= sprintf "SCS 107 %4s \n", ${$h{COSCS107S}}[3], ${$h{COSCS107S}}[1]; -$s .= sprintf "EPH temp %9.2f \n", - ${$h{"TEPHIN"}}[3], ${$h{"TEPHIN"}}[1]; #$s .= sprintf "PMTANKP %8.3f %23sEPH temp %9.2f\n",${$h{PMTANKP}}[3],${$h{PMTANKP}}[1]," ",${$h{TEPHIN}}[3], ${$h{TEPHIN}}[1]; From 92652185acf34a7658fdb3e880e71c16ff1bac43 Mon Sep 17 00:00:00 2001 From: Malgosia Sobolewska Date: Tue, 26 Dec 2023 19:10:43 -0500 Subject: [PATCH 2/3] Added functionality to write chandra.snapshot in json format --- snap_format.pm | 8 ++++++++ tlogr_linux.pl | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/snap_format.pm b/snap_format.pm index 5ec18be..d4b68c2 100644 --- a/snap_format.pm +++ b/snap_format.pm @@ -1,5 +1,13 @@ # this module writes out the chandra snapshot +use JSON; + +sub write_json { + my %h = @_; + my $json = encode_json \%h; + return $json +} + sub write_txt { my %h = @_; diff --git a/tlogr_linux.pl b/tlogr_linux.pl index 25e51cc..b160a9e 100755 --- a/tlogr_linux.pl +++ b/tlogr_linux.pl @@ -24,6 +24,7 @@ #$web_dir = "/proj/ascwww/AXAF/extra/science/cgi-gen/mta/Snap"; $wap_dir = "/data/mta4/www/WL/Snap_dat"; $text_ver = "./chandra.snapshot"; +$JSON_OUT = "./chandra.snapshot.json"; $pool_ver = "/pool14/chandra/chandra_psi.snapshot"; $check_comm_file = "/home/mta/Snap/check_comm_fail"; # file to write if # check comm fails and alert is sent @@ -163,6 +164,7 @@ use snap_format; my $snap_text = write_txt(%h); +my $snap_json = write_json(%h); my $snap_html = write_htm(%h); #my $snap_wap = write_wap(%h); my $snap_curr_wap = write_curr_wap(%h); @@ -202,6 +204,11 @@ close SF; `cp $text_ver $pool_ver`; +open(SF, ">$JSON_OUT") + or die "Couldn't open $JSON_OUT for writing\n"; +print SF $snap_json; +close(SF); + #$snapf = "$work_dir/chandra.snapshot"; #open(SF,">$snapf") or die "Cannot create $snapf\n"; #print SF $snap_text; From e7944c6fc15fc3be3626eaa34b1ee6af766ef3f0 Mon Sep 17 00:00:00 2001 From: Malgosia Sobolewska Date: Tue, 6 Feb 2024 21:37:35 -0500 Subject: [PATCH 3/3] Improved formatting of the json output --- snap_format.pm | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/snap_format.pm b/snap_format.pm index d4b68c2..c74ea24 100644 --- a/snap_format.pm +++ b/snap_format.pm @@ -4,7 +4,30 @@ use JSON; sub write_json { my %h = @_; - my $json = encode_json \%h; + + my %status_assignments = (B => 'unchecked', + G => 'nominal', + Y => 'caution', + R => 'warning', + S => 'stale15min', + I => 'invalid'); + + my %new_hash; + + for my $msid (keys %h) { + my $status = 'unchecked'; + for my $stat (keys %status_assignments) { + if ($h{$msid}[2] eq $stat) { + $status = $status_assignments{$stat}; + } + } + + $new_hash{$msid} = {'time' => $h{$msid}[0], + 'value' => $h{$msid}[1], + 'status' => $status}; + } + + my $json = encode_json \%new_hash; return $json }