From 7642b47a8f164a06b2f8ac92dba0b04cbc0d12f3 Mon Sep 17 00:00:00 2001
From: "emanuele.laface@esss.se" <emanuele.laface@esss.se>
Date: Fri, 18 Mar 2022 20:40:07 +0100
Subject: [PATCH] WS

---
 WebSites/instruments/dashboard.json | 56 +++++++++++++++++++++++++++++
 WebSites/pos/dashboard.json         |  4 +--
 2 files changed, 58 insertions(+), 2 deletions(-)

diff --git a/WebSites/instruments/dashboard.json b/WebSites/instruments/dashboard.json
index eaedca1..aeb0038 100644
--- a/WebSites/instruments/dashboard.json
+++ b/WebSites/instruments/dashboard.json
@@ -88,6 +88,52 @@
 					}
 				}
 			]
+		},
+		{
+			"title": "MEBT Wire Scanner 2",
+			"width": 1,
+			"row": {
+				"4": 35
+			},
+			"col": {
+				"4": 1
+			},
+			"col_width": 2,
+			"widgets": [
+				{
+					"type": "flot_extended_plugin",
+					"settings": {
+						"plot_type": "line",
+						"legend": true,
+						"height": 6,
+						"value": "ws2hx = datasources[\"WS\"][\"MEBT-010:PBI-WS-002:Positions_H\"][\"value\"];\nws2hy = datasources[\"WS\"][\"MEBT-010:PBI-WS-002:BeamProfile_H\"][\"value\"];\nws2h = [];\n\nws2vx = datasources[\"WS\"][\"MEBT-010:PBI-WS-002:Positions_V\"][\"value\"];\nws2vy = datasources[\"WS\"][\"MEBT-010:PBI-WS-002:BeamProfile_V\"][\"value\"];\nws2v = [];\n\nfor (i=0; i < ws2hx.length; i++) {\n\tws2h.push([ws2hx[i], ws2hy[i]]);\n}\nfor (i=0; i < ws2vx.length; i++) {\n\tws2v.push([ws2vx[i], ws2vy[i]]);\n}\n\nws2data = [{label: 'Horizontal', data: ws2h, color: \"red\"},\n           {label: 'Vertical', data: ws2v, color: \"yellow\"}];\n\nreturn ws2data;",
+						"zoom": "xy"
+					}
+				}
+			]
+		},
+		{
+			"title": "MEBT Wire Scanner 3",
+			"width": 1,
+			"row": {
+				"4": 35
+			},
+			"col": {
+				"4": 3
+			},
+			"col_width": 2,
+			"widgets": [
+				{
+					"type": "flot_extended_plugin",
+					"settings": {
+						"plot_type": "line",
+						"legend": true,
+						"height": 6,
+						"value": "ws3hx = datasources[\"WS\"][\"MEBT-010:PBI-WS-003:Positions_H\"][\"value\"];\nws3hy = datasources[\"WS\"][\"MEBT-010:PBI-WS-003:BeamProfile_H\"][\"value\"];\nws3h = [];\n\nws3vx = datasources[\"WS\"][\"MEBT-010:PBI-WS-003:Positions_V\"][\"value\"];\nws3vy = datasources[\"WS\"][\"MEBT-010:PBI-WS-003:BeamProfile_V\"][\"value\"];\nws3v = [];\n\nfor (i=0; i < ws3hx.length; i++) {\n\tws3h.push([ws3hx[i], ws3hy[i]]);\n}\nfor (i=0; i < ws3vx.length; i++) {\n\tws3v.push([ws3vx[i], ws3vy[i]]);\n}\n\nws3data = [{label: 'Horizontal', data: ws3h, color: \"red\"},\n           {label: 'Vertical', data: ws3v, color: \"yellow\"}];\n\nreturn ws3data;",
+						"zoom": "xy"
+					}
+				}
+			]
 		}
 	],
 	"datasources": [
@@ -118,6 +164,16 @@
 				"refresh": 10,
 				"method": "GET"
 			}
+		},
+		{
+			"name": "WS",
+			"type": "JSON",
+			"settings": {
+				"url": "/data/api/v2/pvget/MEBT-010:PBI-WS-002:Positions_H,MEBT-010:PBI-WS-002:BeamProfile_H,MEBT-010:PBI-WS-002:Positions_V,MEBT-010:PBI-WS-002:BeamProfile_V,MEBT-010:PBI-WS-003:Positions_H,MEBT-010:PBI-WS-003:BeamProfile_H,MEBT-010:PBI-WS-003:Positions_V,MEBT-010:PBI-WS-003:BeamProfile_V",
+				"use_thingproxy": true,
+				"refresh": 10,
+				"method": "GET"
+			}
 		}
 	],
 	"columns": 4
diff --git a/WebSites/pos/dashboard.json b/WebSites/pos/dashboard.json
index d19d144..3b0ad79 100644
--- a/WebSites/pos/dashboard.json
+++ b/WebSites/pos/dashboard.json
@@ -50,7 +50,7 @@
 					"type": "indicator",
 					"settings": {
 						"value": "power = datasources[\"dtl\"][\"DTL-010:RFS-DIG-101:AI2-SMonAvg-Mag\"][\"value\"]-datasources[\"dtl\"][\"DTL-010:RFS-DIG-101:AI3-SMonAvg-Mag\"][\"value\"]+datasources[\"dtl\"][\"DTL-010:RFS-DIG-101:AI4-SMonAvg-Mag\"][\"value\"]-datasources[\"dtl\"][\"DTL-010:RFS-DIG-101:AI5-SMonAvg-Mag\"][\"value\"];\n\nif (power > 1) {\n    return 1;\n}\nelse {\n    return 0;\n}\n",
-						"on_text": "power = datasources[\"dtl\"][\"DTL-010:RFS-DIG-101:AI2-SMonAvg-Mag\"][\"value\"]-datasources[\"dtl\"][\"DTL-010:RFS-DIG-101:AI3-SMonAvg-Mag\"][\"value\"]+datasources[\"dtl\"][\"DTL-010:RFS-DIG-101:AI4-SMonAvg-Mag\"][\"value\"]-datasources[\"dtl\"][\"DTL-010:RFS-DIG-101:AI5-SMonAvg-Mag\"][\"value\"];\n\nreturn \"Average Power: \"+String(power.toFixed(3))+\" kW\";",
+						"on_text": "power = datasources[\"dtl\"][\"DTL-010:RFS-DIG-101:AI2-SMonAvg-Mag\"][\"value\"]-datasources[\"dtl\"][\"DTL-010:RFS-DIG-101:AI3-SMonAvg-Mag\"][\"value\"]+datasources[\"dtl\"][\"DTL-010:RFS-DIG-101:AI4-SMonAvg-Mag\"][\"value\"]-datasources[\"dtl\"][\"DTL-010:RFS-DIG-101:AI5-SMonAvg-Mag\"][\"value\"];\n\nreturn \"Power: \"+String(power.toFixed(3))+\" kW\";",
 						"off_text": "DTL Off"
 					}
 				},
@@ -368,7 +368,7 @@
 					"type": "indicator",
 					"settings": {
 						"value": "timelength = datasources[\"rfq\"][\"RFQ-010:RFS-EVR-101:RFSyncWdt-SP\"][\"value\"]/1000;\npwxdata = datasources[\"rfq\"][\"RFQ-010:RFS-DIG-101:Dwn6-XAxis.[0:100:-1]\"][\"value\"];\npwydata = datasources[\"rfq\"][\"RFQ-010:RFS-DIG-101:Dwn6-Cmp0.[0:100:-1]\"][\"value\"];\n\npower = datasources[\"rfq\"][\"RFQ-010:RFS-DIG-101:AI2-SMonAvg-Mag\"][\"value\"]-datasources[\"rfq\"][\"RFQ-010:RFS-DIG-101:AI3-SMonAvg-Mag\"][\"value\"]+datasources[\"rfq\"][\"RFQ-010:RFS-DIG-101:AI4-SMonAvg-Mag\"][\"value\"]-datasources[\"rfq\"][\"RFQ-010:RFS-DIG-101:AI5-SMonAvg-Mag\"][\"value\"];\n\npwdata = 0;\ncounts = 0;\n\ntimestamp = datasources[\"rfq\"][\"RFQ-010:RFS-DIG-101:Dwn6-Cmp0.[0:100:-1]\"][\"timeStamp\"][\"secondsPastEpoch\"];\nnow = Math.floor((new Date()).getTime() / 1000);\nenable = 1;\nif (now - timestamp > 60) {\n    enable = 0;\n}\n\nfor (i=0; i < pwxdata.length; i++) {\n    if (pwxdata[i] > timelength) {\n        break;\n    }\n\tpwdata += enable*pwydata[i];\n    counts += 1;\n}\n\nif (counts == 0) {\n    return 0;\n}\n\nif (pwdata/counts < 3) {\n    return 0;\n}\n\nreturn 1;",
-						"on_text": "power = datasources[\"rfq\"][\"RFQ-010:RFS-DIG-101:AI2-SMonAvg-Mag\"][\"value\"]-datasources[\"rfq\"][\"RFQ-010:RFS-DIG-101:AI3-SMonAvg-Mag\"][\"value\"]+datasources[\"rfq\"][\"RFQ-010:RFS-DIG-101:AI4-SMonAvg-Mag\"][\"value\"]-datasources[\"rfq\"][\"RFQ-010:RFS-DIG-101:AI5-SMonAvg-Mag\"][\"value\"];\n\nreturn \"Average Power: \"+String(power.toFixed(3))+\" kW\";",
+						"on_text": "power = datasources[\"rfq\"][\"RFQ-010:RFS-DIG-101:AI2-SMonAvg-Mag\"][\"value\"]-datasources[\"rfq\"][\"RFQ-010:RFS-DIG-101:AI3-SMonAvg-Mag\"][\"value\"]+datasources[\"rfq\"][\"RFQ-010:RFS-DIG-101:AI4-SMonAvg-Mag\"][\"value\"]-datasources[\"rfq\"][\"RFQ-010:RFS-DIG-101:AI5-SMonAvg-Mag\"][\"value\"];\n\nreturn \"Power: \"+String(power.toFixed(3))+\" kW\";",
 						"off_text": "RFQ Off"
 					}
 				},
-- 
GitLab