From 883dcc68b435b12b1ae76744bf9f70ac6da66a11 Mon Sep 17 00:00:00 2001
From: Emanuele Laface <emanuele.laface@esss.se>
Date: Fri, 14 Jun 2019 10:28:35 +0200
Subject: [PATCH] Doppler added to the Instruments screen

---
 PythonServer/pos-python-server.py   |  28 +++----
 WebSites/instruments/dashboard.json | 115 ++++++++++++++++++----------
 2 files changed, 89 insertions(+), 54 deletions(-)

diff --git a/PythonServer/pos-python-server.py b/PythonServer/pos-python-server.py
index 186c74b..fcdba3b 100755
--- a/PythonServer/pos-python-server.py
+++ b/PythonServer/pos-python-server.py
@@ -359,20 +359,22 @@ class epicsQuery(Thread):
                         instruments_return_dict[pv]['value']=''
                         continue
 
-            try:            
-                if instruments['LEBT-010:PBI-Dpl-001:IMG1-ArrayData'].connected:
-                    imarray = tile(instruments['LEBT-010:PBI-Dpl-001:IMG1-ArrayData'].value, (256,1))
-                else:
-                    imarray = zeros((256,1024))
-            except:
-                imarray = zeros((256,1024))
-            plt.imsave('/var/www/data/tmp-dpl.png', imarray, cmap='hot')
-            os.rename('/var/www/data/tmp-dpl.png', '/var/www/data/dpl.png')
+                    try:            
+                        if instruments['LEBT-010:PBI-Dpl-001:IMG1-ArrayData'].connected:
+                            imarray = tile(instruments['LEBT-010:PBI-Dpl-001:IMG1-ArrayData'].value, (256,1))
+                        else:
+                            imarray = zeros((256,1024))
+                    except:
+                        imarray = zeros((256,1024))
+                    plt.imsave('/var/www/data/tmp-dpl.png', imarray, cmap='hot')
+                    os.rename('/var/www/data/tmp-dpl.png', '/var/www/data/dpl.png')
+
+                    if pv=='LEBT-010:PBI-Dpl-001:FIT1-Y_RBV':
+                        y_data=list(instruments[pv].value)
+                        x_data=list(linspace(instruments['LEBT-010:PBI-Dpl-001:SPECT-MinWavelength'].value, instruments['LEBT-010:PBI-Dpl-001:SPECT-MaxWavelength'].value,  len(y_data)))
+                        instruments_return_dict[pv]['value']=list(zip(x_data,y_data))
+                        continue
         
-#        instruments['LEBT-010:PBI-Dpl-001:FIT1-Y_RBV']=epics.PV('LEBT-010:PBI-Dpl-001:FIT1-Y_RBV', auto_monitor=True)
-#        instruments['LEBT-010:PBI-Dpl-001:SPECT-MinWavelength']=epics.PV('LEBT-010:PBI-Dpl-001:SPECT-MinWavelength', auto_monitor=True)
-#        instruments['LEBT-010:PBI-Dpl-001:SPECT-Wavelength_RBV']=epics.PV('LEBT-010:PBI-Dpl-001:SPECT-Wavelength_RBV', auto_monitor=True)
-#        instruments['LEBT-010:PBI-Dpl-001:SPECT-MaxWavelength']=epics.PV('LEBT-010:PBI-Dpl-001:SPECT-MaxWavelength', auto_monitor=True)
 #        instruments['LEBT-010:PBI-Dpl-001:FIT1-FracProton']=epics.PV('LEBT-010:PBI-Dpl-001:FIT1-FracProton', auto_monitor=True)
 #        instruments['LEBT-010:PBI-Dpl-001:FIT1-FracH2']=epics.PV('LEBT-010:PBI-Dpl-001:FIT1-FracH2', auto_monitor=True)
 #        instruments['LEBT-010:PBI-Dpl-001:FIT1-FracH3']=epics.PV('LEBT-010:PBI-Dpl-001:FIT1-FracH3', auto_monitor=True)
diff --git a/WebSites/instruments/dashboard.json b/WebSites/instruments/dashboard.json
index a0213b9..6d0f417 100644
--- a/WebSites/instruments/dashboard.json
+++ b/WebSites/instruments/dashboard.json
@@ -109,6 +109,45 @@
 				}
 			]
 		},
+		{
+			"title": "Permanent Tank Vertical NPM",
+			"width": 1,
+			"row": {
+				"1": 35,
+				"3": 17,
+				"4": 17,
+				"9": 17,
+				"10": 17
+			},
+			"col": {
+				"1": 1,
+				"3": 2,
+				"4": 2,
+				"9": 2,
+				"10": 2
+			},
+			"col_width": 1,
+			"widgets": [
+				{
+					"type": "html",
+					"settings": {
+						"html": "<img width=\"100%\" height=\"100%\" id=\"npmvImage\", src=\"/data/npm-vimage.png\"></img>\n<script>\n    setInterval(function() { \n        var npmvImage = document.getElementById('npmvImage'); \n        npmvImage.src = '/data/npm-vimage.png?rnd=' + Math.random(); \n    }, 1000); \n</script>",
+						"height": 4
+					}
+				},
+				{
+					"type": "flot_extended_plugin",
+					"settings": {
+						"plot_type": "line",
+						"legend": false,
+						"height": 4,
+						"value": "[{label: 'Vertical Profile', data:datasources[\"Instruments\"][\"LEBT-010:PBI-NPM-002:VCAMFITS-Y_RBV\"][\"value\"]}]",
+						"yticks": "[]",
+						"zoom": "xy"
+					}
+				}
+			]
+		},
 		{
 			"title": "Commissioning Tank Horizontal NPM",
 			"width": 1,
@@ -199,41 +238,36 @@
 			]
 		},
 		{
-			"title": "Permanent Tank Vertical NPM",
+			"title": "Permanent Tank Emittance Meter",
 			"width": 1,
 			"row": {
-				"1": 35,
-				"3": 17,
-				"4": 17,
-				"9": 17,
-				"10": 17
+				"1": 89,
+				"2": 53,
+				"3": 53,
+				"4": 35,
+				"9": 35,
+				"10": 35,
+				"11": 35,
+				"13": 35
 			},
 			"col": {
 				"1": 1,
-				"3": 2,
-				"4": 2,
+				"2": 1,
+				"3": 1,
+				"4": 1,
 				"9": 2,
-				"10": 2
+				"10": 2,
+				"11": 2,
+				"13": 2
 			},
-			"col_width": 1,
+			"col_width": 2,
 			"widgets": [
 				{
 					"type": "html",
 					"settings": {
-						"html": "<img width=\"100%\" height=\"100%\" id=\"npmvImage\", src=\"/data/npm-vimage.png\"></img>\n<script>\n    setInterval(function() { \n        var npmvImage = document.getElementById('npmvImage'); \n        npmvImage.src = '/data/npm-vimage.png?rnd=' + Math.random(); \n    }, 1000); \n</script>",
+						"html": "<img width=\"100%\" height=\"100%\" id=\"emuvImage\", src=\"/data/emu-vimage.png\"></img>\n<script>\n    setInterval(function() { \n        var emuvImage = document.getElementById('emuvImage'); \n        emuvImage.src = '/data/emu-vimage.png?rnd=' + Math.random(); \n    }, 1000); \n</script>",
 						"height": 4
 					}
-				},
-				{
-					"type": "flot_extended_plugin",
-					"settings": {
-						"plot_type": "line",
-						"legend": false,
-						"height": 4,
-						"value": "[{label: 'Vertical Profile', data:datasources[\"Instruments\"][\"LEBT-010:PBI-NPM-002:VCAMFITS-Y_RBV\"][\"value\"]}]",
-						"yticks": "[]",
-						"zoom": "xy"
-					}
 				}
 			]
 		},
@@ -270,35 +304,34 @@
 			]
 		},
 		{
-			"title": "Permanent Tank Emittance Meter",
+			"title": "Doppler Shift",
 			"width": 1,
 			"row": {
-				"1": 89,
-				"2": 53,
-				"3": 53,
-				"4": 35,
-				"9": 35,
-				"10": 35,
-				"11": 35,
-				"13": 35
+				"4": 45,
+				"12": 45
 			},
 			"col": {
-				"1": 1,
-				"2": 1,
-				"3": 1,
 				"4": 1,
-				"9": 2,
-				"10": 2,
-				"11": 2,
-				"13": 2
+				"12": 1
 			},
-			"col_width": 2,
+			"col_width": 4,
 			"widgets": [
 				{
 					"type": "html",
 					"settings": {
-						"html": "<img width=\"100%\" height=\"100%\" id=\"emuvImage\", src=\"/data/emu-vimage.png\"></img>\n<script>\n    setInterval(function() { \n        var emuvImage = document.getElementById('emuvImage'); \n        emuvImage.src = '/data/emu-vimage.png?rnd=' + Math.random(); \n    }, 1000); \n</script>",
-						"height": 4
+						"html": "<img width=\"100%\" height=\"100%\" id=\"dplImage\", src=\"/data/dpl.png\"></img>\n<script>\nsetInterval(function() { \nvar dplImage = document.getElementById('dplImage'); \ndplImage.src = '/data/dpl.png?rnd=' + Math.random(); \n}, 1000); \n</script>",
+						"height": 2
+					}
+				},
+				{
+					"type": "flot_extended_plugin",
+					"settings": {
+						"plot_type": "line",
+						"legend": true,
+						"height": 4,
+						"value": "[{label: \"H\"+\"+\".sup()+\" = \"+datasources[\"Instruments\"][\"LEBT-010:PBI-Dpl-001:FIT1-FracProton\"][\"value\"]+\" %<BR>\"\n  +\"H\"+\"+\".sup()+\"2\".sub()+\" = \"+datasources[\"Instruments\"][\"LEBT-010:PBI-Dpl-001:FIT1-FracH2\"][\"value\"]+\" %<BR>\"\n  +\"H\"+\"+\".sup()+\"3\".sub()+\" = \"+datasources[\"Instruments\"][\"LEBT-010:PBI-Dpl-001:FIT1-FracH3\"][\"value\"]+\" %\",\n  data:datasources[\"Instruments\"][\"LEBT-010:PBI-Dpl-001:FIT1-Y_RBV\"][\"value\"]}]",
+						"yticks": "[]",
+						"zoom": "xy"
 					}
 				}
 			]
-- 
GitLab