From 1fc43aa080efeabacdf0d39c39ec683171331a62 Mon Sep 17 00:00:00 2001
From: Lucio Zambon <lucio.zambon@elettra.eu>
Date: Thu, 2 May 2024 00:05:02 +0000
Subject: [PATCH] Update updater.php

---
 updater.php | 28 ++++++++++++++++++----------
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/updater.php b/updater.php
index e485767..a6f969e 100644
--- a/updater.php
+++ b/updater.php
@@ -67,13 +67,15 @@ if (isset($_REQUEST['read']) && !empty($_REQUEST['filename'])) {
 		die("[[".$d[34].'],['.$d[35]."]]");
 	} 
 	if ($_REQUEST['filename']=='sr.100.bpm.src') {
-		$f = file_get_contents('http://puma-01.elettra.eu/rchan.php?json&valueOnly&src=srv-tango-sre-01.ecs.elettra.trieste.it:20000/sr/feedback/profile_s-%3EGetGofBpmNames');
+		// $f = file_get_contents('http://puma-01.elettra.eu/rchan.php?json&valueOnly&src=srv-tango-sre-01.ecs.elettra.trieste.it:20000/sr/feedback/profile_s-%3EGetGofBpmNames');
+		$f = file_get_contents('http://puma-01.elettra.eu/rchan.php?json&valueOnly&src=srv-tango-sre-01.ecs.elettra.trieste.it:20000/sr/DIAGNOSTICS/bpm_s(BpmLabel)');
 		if (isset($_REQUEST['debug'])) print_r($f);
-		$d = json_decode(strtr($f, [',""'=>'', '"LGBPM_S2.1","LGBPM_S2.2",'=>'', '"LGBPM_S7.1","LGBPM_S7.2",'=>'']));
+		// $d = json_decode(strtr($f, [',""'=>'', '"LGBPM_S2.1","LGBPM_S2.2",'=>'', '"LGBPM_S7.1","LGBPM_S7.2",'=>'']));
+		$d = json_decode($f, true);
 		$h = $v = [];
 		foreach ($d as $name) {
-			$h[] = "srv-tango-sre-01:20000/sr/feedback/$name/HorPos";
-			$v[] = "srv-tango-sre-01:20000/sr/feedback/$name/VerPos";
+			$h[] = "\"srv-tango-sre-01:20000/sr/feedback/$name/HorPos\"";
+			$v[] = "\"srv-tango-sre-01:20000/sr/feedback/$name/VerPos\"";
 		}
 		die('[['.implode(',', $h).'],['.implode(',', $v).']]');
 	}
@@ -81,19 +83,25 @@ if (isset($_REQUEST['read']) && !empty($_REQUEST['filename'])) {
 		header('Content-Type: application/json');
 		list($trash, $f) = explode(':', strtr(file_get_contents('/run/panther/elettra.100.bpm'), array('e '=>'e')));
 		$d = explode(';', $f);
-		die("{\"preinjector\":{\"x\":[".implode(',', array_slice($d, 0, 7)).'],"y":['.implode(',', array_slice($d, 7, 7))."]},\"bts\":{\"x\":[".implode(',', array_slice($d, 14, 10)).'],"y":['.implode(',', array_slice($d, 24, 10))."]},\"sr\":{\"x\":[".$d[34].'],"y":['.$d[35]."]}}");
+		die("{\"preinjector\":{\"Hor\":[".implode(',', array_slice($d, 0, 7)).'],"Ver":['.implode(',', array_slice($d, 7, 7))."]},\"bts\":{\"Hor\":[".implode(',', array_slice($d, 14, 10)).'],"Ver":['.implode(',', array_slice($d, 24, 10))."]},\"sr\":{\"Hor\":[".$d[34].'],"Ver":['.$d[35]."]}}");
 	}
 	if ($_REQUEST['filename']=='elettra.100.bpm.src') {
-		$f = file_get_contents('http://puma-01.elettra.eu/rchan.php?json&valueOnly&src=srv-tango-sre-01.ecs.elettra.trieste.it:20000/sr/feedback/profile_s-%3EGetGofBpmNames');
-		$d = json_decode(strtr($f, [',""'=>'', '"LGBPM_S2.1","LGBPM_S2.2",'=>'', '"LGBPM_S7.1","LGBPM_S7.2",'=>'']));
+		header('Content-Type: application/json');
+		// $f = file_get_contents('http://puma-01.elettra.eu/rchan.php?json&valueOnly&src=srv-tango-sre-01.ecs.elettra.trieste.it:20000/sr/feedback/profile_s-%3EGetGofBpmNames');
+		$f = file_get_contents('http://puma-01.elettra.eu/rchan.php?json&valueOnly&src=srv-tango-sre-01.ecs.elettra.trieste.it:20000/sr/DIAGNOSTICS/bpm_s(BpmLabel)');
+		if (isset($_REQUEST['debug'])) print_r($f);
+		// $d = json_decode(strtr($f, [',""'=>'', '"LGBPM_S2.1","LGBPM_S2.2",'=>'', '"LGBPM_S7.1","LGBPM_S7.2",'=>'']));
+		$d = json_decode($f, true);
 		$h = $v = [];
 		foreach ($d as $name) {
-			$h[] = "srv-tango-sre-01:20000/sr/feedback/$name/HorPos";
-			$v[] = "srv-tango-sre-01:20000/sr/feedback/$name/VerPos";
+			$h[] = "\"srv-tango-sre-01:20000/sr/feedback/$name/HorPos\"";
+			$v[] = "\"srv-tango-sre-01:20000/sr/feedback/$name/VerPos\"";
 		}
 		list($trash, $f) = explode(':', file_get_contents('/run/panther/elettra.100.bpm.src'), 2);
 		$d = explode(',', $f);
-		die("[[".implode(',', array_slice($d, 0, 7)).','.implode(',', array_slice($d, 14, 10)).','.implode(',', $h).'],['.implode(',', array_slice($d, 7, 7)).','.implode(',', array_slice($d, 24, 10)).','.implode(',', $v)."]]");
+		die("{\"preinjector\":{\"Factor\":1000,\"Hor\":\n[\"".implode("\",\n\"", array_slice($d, 0, 7))."\"], \"Ver\":\n[\"".implode("\",\n\"", array_slice($d, 7, 7)).
+			"\"]},\n\"bts\":{\"Factor\":0.001,\"Hor\":\n[\"".implode("\",\n\"", array_slice($d, 14, 10))."\"],\"Ver\":\n[\"".implode("\",\n\"", array_slice($d, 24, 10)).
+			"\"]},\n\"sr\":{\"Factor\":1000,\"Hor\":[\n".implode(",\n", $h).'],"Ver":['.implode(',', $v)."\n]\n}\n}");
 	}
 	if ($_REQUEST['filename']=='fermi.1000.vlv') {
 		list($trash, $f) = explode(':', file_get_contents('/run/panther/padres.1000.vlv'));
-- 
GitLab