New files
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
0,
|
||||
0,
|
||||
100,
|
||||
100
|
||||
],
|
||||
"reference_marker_width": 100.0,
|
||||
"reference_marker_height": 100.0,
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"name": "Alvra_spatial_encoding",
|
||||
"source": "SARES11-SPEC125-M1"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
0,
|
||||
0,
|
||||
100,
|
||||
100
|
||||
],
|
||||
"reference_marker_width": 100.0,
|
||||
"reference_marker_height": 100.0,
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"name": "Alvra_spectral_encoding",
|
||||
"source": "SARES11-SPEC125-M2"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
0,
|
||||
0,
|
||||
100,
|
||||
100
|
||||
],
|
||||
"reference_marker_width": 100.0,
|
||||
"reference_marker_height": 100.0,
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 3,
|
||||
"source_type": "epics",
|
||||
"name": "Bernina_DSD_screen",
|
||||
"source": "SARES20-DSDPPRM",
|
||||
"type": "Bernina"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
0,
|
||||
0,
|
||||
100,
|
||||
100
|
||||
],
|
||||
"reference_marker_width": 100.0,
|
||||
"reference_marker_height": 100.0,
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"name": "Bernina_spatial_encoding",
|
||||
"source": "SARES20-CAMS142-M4"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
-576,
|
||||
-1271,
|
||||
-176,
|
||||
-871
|
||||
],
|
||||
"reference_marker_width": 100.0,
|
||||
"reference_marker_height": 100.0,
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"name": "Bernina_spectral_encoding",
|
||||
"source": "SARES20-CAMS142-M5"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
0,
|
||||
0,
|
||||
100,
|
||||
100
|
||||
],
|
||||
"reference_marker_width": 100.0,
|
||||
"reference_marker_height": 100.0,
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "bsread",
|
||||
"name": "SARES11-SPEC125-M1",
|
||||
"prefix": "SARES11-SPEC125-M1",
|
||||
"source": "SARES11-SPEC125-M1"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
0,
|
||||
0,
|
||||
100,
|
||||
100
|
||||
],
|
||||
"reference_marker_width": 100.0,
|
||||
"reference_marker_height": 100.0,
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "bsread",
|
||||
"name": "SARES11-SPEC125-M2",
|
||||
"prefix": "SARES11-SPEC125-M2",
|
||||
"source": "SARES11-SPEC125-M2"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"camera_calibration": null,
|
||||
"mirror_x": false,
|
||||
"mirror_y": true,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"name": "SARES11-XMI125-C4P1",
|
||||
"source": "SARES11-XMI125-C4P1"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"camera_calibration": null,
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"source": "SARES11-XPR125-C4P2",
|
||||
"name": "SARES11-XPR125-C4P2"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
953,
|
||||
593,
|
||||
967,
|
||||
607
|
||||
],
|
||||
"reference_marker_width": 57.0,
|
||||
"reference_marker_height": 45.0,
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"prefix": "SARES20-CAMS142-C2",
|
||||
"name": "SARES20-CAMS142-C2",
|
||||
"source": "SARES20-CAMS142-C2"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"camera_calibration": null,
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"prefix": "SARES20-CAMS142-C3",
|
||||
"name": "SARES20-CAMS142-C3",
|
||||
"source": "SARES20-CAMS142-C3"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
318,
|
||||
133,
|
||||
418,
|
||||
233
|
||||
],
|
||||
"reference_marker_width": 73.0,
|
||||
"reference_marker_height": 73.0,
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"prefix": "SARES20-CAMS142-M1",
|
||||
"name": "SARES20-CAMS142-M1",
|
||||
"source": "SARES20-CAMS142-M1"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
196,
|
||||
263,
|
||||
272,
|
||||
339
|
||||
],
|
||||
"reference_marker_width": 40.625,
|
||||
"reference_marker_height": 47.92,
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 3,
|
||||
"source_type": "epics",
|
||||
"prefix": "SARES20-CAMS142-M2",
|
||||
"name": "SARES20-CAMS142-M2",
|
||||
"source": "SARES20-CAMS142-M2"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
599,
|
||||
1415,
|
||||
631,
|
||||
1515
|
||||
],
|
||||
"reference_marker_width": 500.0,
|
||||
"reference_marker_height": 500.0,
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"prefix": "SARES20-CAMS142-M3",
|
||||
"name": "SARES20-CAMS142-M3",
|
||||
"source": "SARES20-CAMS142-M3"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"reference_marker_width": 1.0,
|
||||
"reference_marker_height": 1.0,
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "bsread",
|
||||
"prefix": "SARES20-CAMS142-M4",
|
||||
"name": "SARES20-CAMS142-M4",
|
||||
"source": "SARES20-CAMS142-M4"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1
|
||||
],
|
||||
"reference_marker_width": 1.0,
|
||||
"reference_marker_height": 1.0,
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "bsread",
|
||||
"prefix": "SARES20-CAMS142-M5",
|
||||
"name": "SARES20-CAMS142-M5",
|
||||
"source": "SARES20-CAMS142-M5"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"camera_calibration": null,
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"prefix": "SARES20-PROF141-M1",
|
||||
"name": "SARES20-PROF141-M1",
|
||||
"source": "SARES20-PROF141-M1"
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"camera_calibration": null,
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"prefix": "SARES20-PROF146-M1",
|
||||
"name": "SARES20-PROF146-M1",
|
||||
"source": "SARES20-PROF146-M1"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
468,
|
||||
41,
|
||||
1142,
|
||||
1844
|
||||
],
|
||||
"reference_marker_width": 6000.0,
|
||||
"reference_marker_height": 16000.0,
|
||||
"angle_horizontal": 8.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": true,
|
||||
"mirror_y": true,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"name": "SATBD01-DSCR120",
|
||||
"source": "SATBD01-DSCR120"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
810,
|
||||
558,
|
||||
1146,
|
||||
1454
|
||||
],
|
||||
"reference_marker_width": 6000.0,
|
||||
"reference_marker_height": 16000.0,
|
||||
"angle_horizontal": 8.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": true,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"source": "SATBD01-DSCR210",
|
||||
"name": "SATBD01-DSCR210"
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "SATFE10-PSCR066",
|
||||
"camera_calibration": {
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0,
|
||||
"reference_marker_height": 100.0,
|
||||
"reference_marker": [
|
||||
0,
|
||||
0,
|
||||
100,
|
||||
100
|
||||
],
|
||||
"reference_marker_width": 100.0
|
||||
},
|
||||
"source": "SATFE10-PSCR066",
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"mirror_x": false
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "SATFE10-PSCR070",
|
||||
"camera_calibration": {
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0,
|
||||
"reference_marker_height": 100.0,
|
||||
"reference_marker": [
|
||||
0,
|
||||
0,
|
||||
100,
|
||||
100
|
||||
],
|
||||
"reference_marker_width": 100.0
|
||||
},
|
||||
"source": "SATFE10-PSCR070",
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"mirror_x": false
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
594,
|
||||
339,
|
||||
965,
|
||||
712
|
||||
],
|
||||
"reference_marker_width": 3000.0,
|
||||
"reference_marker_height": 3000.0,
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": true,
|
||||
"mirror_y": true,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"name": "SATSY03-DLAC080-CAM1",
|
||||
"source": "SATSY03-DLAC080-CAM1"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
61,
|
||||
9,
|
||||
1136,
|
||||
1197
|
||||
],
|
||||
"reference_marker_width": 16000.0,
|
||||
"reference_marker_height": 16000.0,
|
||||
"angle_horizontal": 15.8,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": true,
|
||||
"mirror_y": true,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"source": "SINDI02-DSCR075",
|
||||
"name": "SINDI02-DSCR075"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
86,
|
||||
16,
|
||||
1155,
|
||||
1185
|
||||
],
|
||||
"reference_marker_width": 16000.0,
|
||||
"reference_marker_height": 16000.0,
|
||||
"angle_horizontal": 15.8,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": true,
|
||||
"mirror_y": true,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"source": "SINSB05-DSCR140",
|
||||
"name": "SINSB05-DSCR140"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
0,
|
||||
0,
|
||||
100,
|
||||
100
|
||||
],
|
||||
"reference_marker_width": 100.0,
|
||||
"reference_marker_height": 100.0,
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": false,
|
||||
"mirror_y": true,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"name": "SLAAR11-LAMIC-C451",
|
||||
"source": "SLAAR11-LAMIC-C451"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
0,
|
||||
0,
|
||||
100,
|
||||
100
|
||||
],
|
||||
"reference_marker_width": 100.0,
|
||||
"reference_marker_height": 100.0,
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"name": "SLAAR11-LCAM-C421",
|
||||
"source": "SLAAR11-LCAM-C421"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
0,
|
||||
0,
|
||||
100,
|
||||
100
|
||||
],
|
||||
"reference_marker_width": 100.0,
|
||||
"reference_marker_height": 100.0,
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"source": "SLAAR11-LCAM-C432",
|
||||
"name": "SLAAR11-LCAM-C432"
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"camera_calibration": {
|
||||
"reference_marker": [
|
||||
0,
|
||||
0,
|
||||
100,
|
||||
100
|
||||
],
|
||||
"reference_marker_width": 100.0,
|
||||
"reference_marker_height": 100.0,
|
||||
"angle_horizontal": 0.0,
|
||||
"angle_vertical": 0.0
|
||||
},
|
||||
"mirror_x": false,
|
||||
"mirror_y": false,
|
||||
"rotate": 0,
|
||||
"source_type": "epics",
|
||||
"prefix": "SLG-LCAM-C071",
|
||||
"name": "SLG-LCAM-C071",
|
||||
"source": "SLG-LCAM-C071"
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{}
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"http://sf-daqsync-01.psi.ch:8880": {
|
||||
"expanding": true,
|
||||
"instances": [
|
||||
]
|
||||
},
|
||||
"http://sf-daqsync-03.psi.ch:8880": {
|
||||
"expanding": true,
|
||||
"instances": [
|
||||
]
|
||||
},
|
||||
"http://sf-daqsync-04.psi.ch:8880": {
|
||||
"expanding": true,
|
||||
"instances": [
|
||||
]
|
||||
},
|
||||
"http://sf-daqsync-05.psi.ch:8880": {
|
||||
"expanding": true,
|
||||
"instances": [
|
||||
"SARES11-SPEC125-M1",
|
||||
"SARES11-SPEC125-M2"
|
||||
]
|
||||
},
|
||||
"http://sf-daqsync-06.psi.ch:8880": {
|
||||
"expanding": false,
|
||||
"instances": [
|
||||
"SARES20-CAMS142-M4",
|
||||
"SARES20-CAMS142-M5"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,367 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Server Management</title>
|
||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var base = 'api/v1/proxy/';
|
||||
|
||||
function appendTableRow(table, rowData) {
|
||||
var lastRow = $('<tr/>').appendTo(table.find('tbody:last'));
|
||||
$.each(rowData, function(colIndex, c) {
|
||||
lastRow.append($('<td/>').html(c));
|
||||
});
|
||||
|
||||
return lastRow;
|
||||
}
|
||||
|
||||
function setTableCell(value, tableName, row, col) {
|
||||
var cell = $('#' + tableName + ' tbody tr:eq(' + row + ') td:eq(' + col + ')')[0]
|
||||
cell.innerHTML = value
|
||||
}
|
||||
|
||||
|
||||
function getRows(table){
|
||||
var rows = table.find('tbody').find('tr').length
|
||||
return rows
|
||||
}
|
||||
|
||||
function clear(table){
|
||||
//return $('#servers_table tr').length -1;
|
||||
table.find("tbody").empty()
|
||||
}
|
||||
|
||||
function isDict(v) {
|
||||
return typeof v==='object' && v!==null && !(v instanceof Array) && !(v instanceof Date);
|
||||
}
|
||||
|
||||
function isArray(v) {
|
||||
return (v instanceof Array)
|
||||
}
|
||||
|
||||
function dictToStr(dict, indent){
|
||||
var nested = true
|
||||
var ret = ""
|
||||
if (indent == undefined ){
|
||||
indent = "";
|
||||
ret = "<font size='2'><pre>"
|
||||
nested = false
|
||||
}
|
||||
|
||||
for (var key in dict) {
|
||||
var value = dict[key]
|
||||
if (isDict (value)){
|
||||
ret = ret + key + ":" + "\n"
|
||||
ret = ret + (dictToStr(value, /*"\t"*/ " "))
|
||||
} else {
|
||||
ret = ret + indent + key + ": " + /*JSON.stringify*/(value) + "\n"
|
||||
}
|
||||
}
|
||||
if (!nested){
|
||||
ret = ret+"</pre></font>"
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
function listToStr(lst, multiline, indent) {
|
||||
if (indent == undefined) {
|
||||
indent = "";
|
||||
}
|
||||
var separator = ', '
|
||||
var ret = ""
|
||||
if (multiline) {
|
||||
ret = "<font size='2'><pre>"
|
||||
separator = "\n"
|
||||
}
|
||||
if (isArray(lst)) {
|
||||
for (var i = 0; i < lst.length; i++) {
|
||||
ret = ret + indent + lst[i]
|
||||
if (i< lst.length-1) {
|
||||
ret = ret + separator
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ret = ret + indent + lst + separator
|
||||
}
|
||||
if (multiline) {
|
||||
ret = ret+"</pre></font>"
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
function dateToStr(date){
|
||||
//ret = "<pre>"
|
||||
//ret = ret + date.split(" ").join("\n")x
|
||||
//ret = ret+"</pre>"
|
||||
|
||||
//return date.split(" ").join("\n\t")
|
||||
|
||||
return date.split(" ").slice(0,2).join(" ")
|
||||
}
|
||||
|
||||
|
||||
function formatNum(n, force_decimals){
|
||||
if (force_decimals == undefined) {
|
||||
force_decimals = true
|
||||
}
|
||||
if (n) {
|
||||
if (n >= 1e12) {
|
||||
return (n / 1e12).toFixed(2) + "T"
|
||||
} else if (n >= 1e9) {
|
||||
return (n / 1e9).toFixed(2) + "G"
|
||||
} else if (n >= 1e6) {
|
||||
return (n / 1e6).toFixed(2) + "M"
|
||||
} else if (n >= 1e3) {
|
||||
return (n / 1e3).toFixed(2) + "K"
|
||||
} else if (!Number.isInteger(n) || force_decimals) {
|
||||
return (n).toFixed(2)
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
function deleteInstance(key){
|
||||
$.delete(base + key).error(function (xhr, textStatus, errorThrown) {
|
||||
$("#scripterror").show()
|
||||
$("#scripterror").html(xhr.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
function deleteAllInstances(server_index){
|
||||
$.delete(base + "server/" + server_index).error(function (xhr, textStatus, errorThrown) {
|
||||
$("#scripterror").show()
|
||||
$("#scripterror").html(xhr.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
function showLogs(server){
|
||||
window.open(server + "/api/v1/logs/txt");
|
||||
}
|
||||
|
||||
|
||||
function getServers() {
|
||||
$.get(base + 'servers', function (data) {
|
||||
var version = data["version"]
|
||||
var servers = data["servers"]
|
||||
var load = data["load"]
|
||||
var cpu = data["cpu"]
|
||||
var memory = data["memory"]
|
||||
var tx = data["tx"]
|
||||
var rx = data["rx"]
|
||||
var instances = data["instances"]
|
||||
var table = $("#servers_table")
|
||||
|
||||
for (var i = 0; i < servers.length; i++) {
|
||||
instances[i] = listToStr(instances[i], false)
|
||||
if (load[i] >=1000) {
|
||||
load[i] = "off"
|
||||
}
|
||||
if (getRows(table) <= i){
|
||||
var row = appendTableRow(table, [servers[i], version[i], load[i],
|
||||
formatNum(cpu[i]), formatNum(memory[i]), formatNum(tx[i]), formatNum(rx[i]), instances[i]])
|
||||
var callback = 'onclick="showLogs(\'' + servers[i]+ '\')"'
|
||||
row.append($('<td align="center"><button ' + callback + '>Logs</button></td>'))
|
||||
var callback = 'onclick="deleteAllInstances(\'' + i + '\')"'
|
||||
row.append($('<td align="center"><button ' + callback + '>Stop</button></td>'))
|
||||
} else {
|
||||
|
||||
setTableCell(servers[i] , "servers_table", i, 0)
|
||||
setTableCell(version[i] , "servers_table", i, 1)
|
||||
setTableCell(load[i], "servers_table", i, 2)
|
||||
setTableCell(formatNum(cpu[i]), "servers_table", i, 3)
|
||||
setTableCell(formatNum(memory[i]), "servers_table", i, 4)
|
||||
setTableCell(formatNum(tx[i]), "servers_table", i, 5)
|
||||
setTableCell(formatNum(rx[i]), "servers_table", i, 6)
|
||||
setTableCell(instances[i], "servers_table", i, 7)
|
||||
}
|
||||
}
|
||||
}).error(function (xhr, textStatus, errorThrown) {
|
||||
$("#scripterror").show()
|
||||
$("#scripterror").html(xhr.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
//Adding $.delete and $.put functions
|
||||
jQuery.each( [ "put", "delete" ], function( i, method ) {
|
||||
jQuery[ method ] = function( url, data, callback, type ) {
|
||||
if ( jQuery.isFunction( data ) ) {
|
||||
type = type || callback;
|
||||
callback = data;
|
||||
data = undefined;
|
||||
}
|
||||
|
||||
return jQuery.ajax({
|
||||
url: url,
|
||||
type: method,
|
||||
dataType: type,
|
||||
data: data,
|
||||
success: callback
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
function getInstances() {
|
||||
$.get(base + 'info', function (data) {
|
||||
var table = $("#instances_table")
|
||||
clear(table)
|
||||
var info = data["info"]["active_instances"]
|
||||
|
||||
$.each(info, function(key, value) {
|
||||
//Compact display
|
||||
for (var k in value["statistics"]) {
|
||||
var cur = value["statistics"][k]
|
||||
value["statistics"][k] = formatNum(value["statistics"][k], false)
|
||||
}
|
||||
//Save columns
|
||||
if (value["camera_geometry"] != undefined) {
|
||||
value["statistics"]["geometry"] = value["camera_geometry"]
|
||||
}
|
||||
if (value["read_only"] != undefined) {
|
||||
value["statistics"]["read_only"] = value["read_only"]
|
||||
}
|
||||
value["statistics"]["active"] = value["is_stream_active"]
|
||||
value["statistics"]["camera"] = value["camera_name"]
|
||||
value["statistics"]["start"] = dateToStr(value["last_start_time"])
|
||||
|
||||
var statistics = dictToStr(value["statistics"])
|
||||
var config = dictToStr(value["config"])
|
||||
//var date = dateToStr(value["last_start_time"])
|
||||
|
||||
var instance = {}
|
||||
instance["name"] = key
|
||||
instance["host"] = value["host"]
|
||||
instance["stream"] = value["stream_address"]
|
||||
instance = dictToStr(instance)
|
||||
|
||||
var row = appendTableRow(table, [
|
||||
//key,
|
||||
//value["host"],
|
||||
//value["stream_address"],
|
||||
instance,
|
||||
//value["is_stream_active"],
|
||||
//value["camera_name"],
|
||||
//JSON.stringify(value["camera_geometry"]),
|
||||
//date,
|
||||
statistics,
|
||||
|
||||
config,
|
||||
]
|
||||
)
|
||||
var callback = 'onclick="deleteInstance(\'' + key + '\')"'
|
||||
row.append($('<td align="center"><button ' + callback + '>Stop</button></td>'))
|
||||
//row.append($('<button ' + callback + '/>').html("Stop"));
|
||||
});
|
||||
|
||||
|
||||
}).error(function (xhr, textStatus, errorThrown) {
|
||||
$("#scripterror").show()
|
||||
$("#scripterror").text(xhr.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function update() {
|
||||
getServers()
|
||||
getInstances()
|
||||
}
|
||||
|
||||
function timer() {
|
||||
if ($("#servers").is(":visible")) {
|
||||
update();
|
||||
}
|
||||
window.setTimeout(
|
||||
"timer()",
|
||||
2000
|
||||
);
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
//$("#scripterror").hide()
|
||||
//update()
|
||||
timer()
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<div id="msgid">
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<section>
|
||||
<h1>
|
||||
Servers <input type="button" value="Manager Logs" style="float: right;" onclick="window.open('/api/v1/logs/txt')" />
|
||||
</h1>
|
||||
|
||||
<div id="servers">
|
||||
<table id="servers_table" border="1" width="100%" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20%">Host</th>
|
||||
<th width="3%">Ver</th>
|
||||
<th width="1%">Load</th>
|
||||
<th width="1%">CPU</th>
|
||||
<th width="1%">Mem</th>
|
||||
<th width="1%">TX</th>
|
||||
<th width="1%">RX</th>
|
||||
<th width="70%">Active Instances</th>
|
||||
<th width="1%">Logs</th>
|
||||
<th width="1%">Stop</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="servers_table_rows">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<p><br>
|
||||
<section>
|
||||
<h1>
|
||||
Instances
|
||||
</h1>
|
||||
<div id="instances">
|
||||
<table id="instances_table" border="1" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="33%">Instance</th>
|
||||
<!--<th>Host</th>-->
|
||||
<!--<th>Stream Address</th>-->
|
||||
<!--<th>Active</th>-->
|
||||
<!--<th>Camera</th>-->
|
||||
<!--<th>Geometry</th>-->
|
||||
<!--<th>Start</th>-->
|
||||
<th width="33%">Info</th>
|
||||
<th width="33%">Config</th>
|
||||
<th width="1%">Stop</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="instances_table_rows">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<p><br>
|
||||
<section>
|
||||
<div id="scripterror" style="color:red">
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -0,0 +1,369 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Server Management</title>
|
||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var base = 'api/v1/proxy/';
|
||||
|
||||
function appendTableRow(table, rowData) {
|
||||
var lastRow = $('<tr/>').appendTo(table.find('tbody:last'));
|
||||
$.each(rowData, function(colIndex, c) {
|
||||
lastRow.append($('<td/>').html(c));
|
||||
});
|
||||
|
||||
return lastRow;
|
||||
}
|
||||
|
||||
function setTableCell(value, tableName, row, col) {
|
||||
var cell = $('#' + tableName + ' tbody tr:eq(' + row + ') td:eq(' + col + ')')[0]
|
||||
cell.innerHTML = value
|
||||
}
|
||||
|
||||
|
||||
function getRows(table){
|
||||
var rows = table.find('tbody').find('tr').length
|
||||
return rows
|
||||
}
|
||||
|
||||
function clear(table){
|
||||
//return $('#servers_table tr').length -1;
|
||||
table.find("tbody").empty()
|
||||
}
|
||||
|
||||
function isDict(v) {
|
||||
return typeof v==='object' && v!==null && !(v instanceof Array) && !(v instanceof Date);
|
||||
}
|
||||
|
||||
function isArray(v) {
|
||||
return (v instanceof Array)
|
||||
}
|
||||
|
||||
function dictToStr(dict, indent){
|
||||
var nested = true
|
||||
var ret = ""
|
||||
if (indent == undefined ){
|
||||
indent = "";
|
||||
ret = "<font size='2'><pre>"
|
||||
nested = false
|
||||
}
|
||||
|
||||
for (var key in dict) {
|
||||
var value = dict[key]
|
||||
if (isDict (value)){
|
||||
ret = ret + key + ":" + "\n"
|
||||
ret = ret + (dictToStr(value, /*"\t"*/ " "))
|
||||
} else {
|
||||
ret = ret + indent + key + ": " + /*JSON.stringify*/(value) + "\n"
|
||||
}
|
||||
}
|
||||
if (!nested){
|
||||
ret = ret+"</pre></font>"
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
function listToStr(lst, multiline, indent) {
|
||||
if (indent == undefined) {
|
||||
indent = "";
|
||||
}
|
||||
var separator = ', '
|
||||
var ret = ""
|
||||
if (multiline) {
|
||||
ret = "<font size='2'><pre>"
|
||||
separator = "\n"
|
||||
}
|
||||
if (isArray(lst)) {
|
||||
for (var i = 0; i < lst.length; i++) {
|
||||
ret = ret + indent + lst[i]
|
||||
if (i< lst.length-1) {
|
||||
ret = ret + separator
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ret = ret + indent + lst + separator
|
||||
}
|
||||
if (multiline) {
|
||||
ret = ret+"</pre></font>"
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
function dateToStr(date){
|
||||
//ret = "<pre>"
|
||||
//ret = ret + date.split(" ").join("\n")x
|
||||
//ret = ret+"</pre>"
|
||||
|
||||
//return date.split(" ").join("\n\t")
|
||||
|
||||
return date.split(" ").slice(0,2).join(" ")
|
||||
}
|
||||
|
||||
|
||||
function formatNum(n, force_decimals){
|
||||
if (force_decimals == undefined) {
|
||||
force_decimals = true
|
||||
}
|
||||
if (n) {
|
||||
if (n >= 1e12) {
|
||||
return (n / 1e12).toFixed(2) + "T"
|
||||
} else if (n >= 1e9) {
|
||||
return (n / 1e9).toFixed(2) + "G"
|
||||
} else if (n >= 1e6) {
|
||||
return (n / 1e6).toFixed(2) + "M"
|
||||
} else if (n >= 1e3) {
|
||||
return (n / 1e3).toFixed(2) + "K"
|
||||
} else if (!Number.isInteger(n) || force_decimals) {
|
||||
return (n).toFixed(2)
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
function deleteInstance(key){
|
||||
$.delete(base + key).error(function (xhr, textStatus, errorThrown) {
|
||||
$("#scripterror").show()
|
||||
$("#scripterror").html(xhr.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
function deleteAllInstances(server_index){
|
||||
$.delete(base + "server/" + server_index).error(function (xhr, textStatus, errorThrown) {
|
||||
$("#scripterror").show()
|
||||
$("#scripterror").html(xhr.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
function showLogs(server){
|
||||
window.open(server + "/api/v1/logs/txt");
|
||||
}
|
||||
|
||||
|
||||
function getServers() {
|
||||
$.get(base + 'servers', function (data) {
|
||||
var version = data["version"]
|
||||
var servers = data["servers"]
|
||||
var load = data["load"]
|
||||
var cpu = data["cpu"]
|
||||
var memory = data["memory"]
|
||||
var tx = data["tx"]
|
||||
var rx = data["rx"]
|
||||
var instances = data["instances"]
|
||||
var table = $("#servers_table")
|
||||
|
||||
for (var i = 0; i < servers.length; i++) {
|
||||
instances[i] = listToStr(instances[i], false)
|
||||
if (load[i] >=1000) {
|
||||
load[i] = "off"
|
||||
}
|
||||
if (getRows(table) <= i){
|
||||
var row = appendTableRow(table, [servers[i], version[i], load[i],
|
||||
formatNum(cpu[i]), formatNum(memory[i]), formatNum(tx[i]), formatNum(rx[i]), instances[i]])
|
||||
var callback = 'onclick="showLogs(\'' + servers[i]+ '\')"'
|
||||
row.append($('<td align="center"><button ' + callback + '>Logs</button></td>'))
|
||||
var callback = 'onclick="deleteAllInstances(\'' + i + '\')"'
|
||||
row.append($('<td align="center"><button ' + callback + '>Stop</button></td>'))
|
||||
} else {
|
||||
|
||||
setTableCell(servers[i] , "servers_table", i, 0)
|
||||
setTableCell(version[i] , "servers_table", i, 1)
|
||||
setTableCell(load[i], "servers_table", i, 2)
|
||||
setTableCell(formatNum(cpu[i]), "servers_table", i, 3)
|
||||
setTableCell(formatNum(memory[i]), "servers_table", i, 4)
|
||||
setTableCell(formatNum(tx[i]), "servers_table", i, 5)
|
||||
setTableCell(formatNum(rx[i]), "servers_table", i, 6)
|
||||
setTableCell(instances[i], "servers_table", i, 7)
|
||||
}
|
||||
}
|
||||
}).error(function (xhr, textStatus, errorThrown) {
|
||||
$("#scripterror").show()
|
||||
$("#scripterror").html(xhr.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
//Adding $.delete and $.put functions
|
||||
jQuery.each( [ "put", "delete" ], function( i, method ) {
|
||||
jQuery[ method ] = function( url, data, callback, type ) {
|
||||
if ( jQuery.isFunction( data ) ) {
|
||||
type = type || callback;
|
||||
callback = data;
|
||||
data = undefined;
|
||||
}
|
||||
|
||||
return jQuery.ajax({
|
||||
url: url,
|
||||
type: method,
|
||||
dataType: type,
|
||||
data: data,
|
||||
success: callback
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
function getInstances() {
|
||||
$.get(base + 'info', function (data) {
|
||||
var table = $("#instances_table")
|
||||
clear(table)
|
||||
var info = data["info"]["active_instances"]
|
||||
|
||||
$.each(info, function(key, value) {
|
||||
//Compact display
|
||||
for (var k in value["statistics"]) {
|
||||
var cur = value["statistics"][k]
|
||||
if(typeof cur == 'number'){
|
||||
value["statistics"][k] = formatNum(cur, false)
|
||||
}
|
||||
}
|
||||
//Save columns
|
||||
if (value["camera_geometry"] != undefined) {
|
||||
value["statistics"]["geometry"] = value["camera_geometry"]
|
||||
}
|
||||
if (value["read_only"] != undefined) {
|
||||
value["statistics"]["read_only"] = value["read_only"]
|
||||
}
|
||||
value["statistics"]["active"] = value["is_stream_active"]
|
||||
value["statistics"]["camera"] = value["camera_name"]
|
||||
value["statistics"]["start"] = dateToStr(value["last_start_time"])
|
||||
|
||||
var statistics = dictToStr(value["statistics"])
|
||||
var config = dictToStr(value["config"])
|
||||
//var date = dateToStr(value["last_start_time"])
|
||||
|
||||
var instance = {}
|
||||
instance["name"] = key
|
||||
instance["host"] = value["host"]
|
||||
instance["stream"] = value["stream_address"]
|
||||
instance = dictToStr(instance)
|
||||
|
||||
var row = appendTableRow(table, [
|
||||
//key,
|
||||
//value["host"],
|
||||
//value["stream_address"],
|
||||
instance,
|
||||
//value["is_stream_active"],
|
||||
//value["camera_name"],
|
||||
//JSON.stringify(value["camera_geometry"]),
|
||||
//date,
|
||||
statistics,
|
||||
|
||||
config,
|
||||
]
|
||||
)
|
||||
var callback = 'onclick="deleteInstance(\'' + key + '\')"'
|
||||
row.append($('<td align="center"><button ' + callback + '>Stop</button></td>'))
|
||||
//row.append($('<button ' + callback + '/>').html("Stop"));
|
||||
});
|
||||
|
||||
|
||||
}).error(function (xhr, textStatus, errorThrown) {
|
||||
$("#scripterror").show()
|
||||
$("#scripterror").text(xhr.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function update() {
|
||||
getServers()
|
||||
getInstances()
|
||||
}
|
||||
|
||||
function timer() {
|
||||
if ($("#servers").is(":visible")) {
|
||||
update();
|
||||
}
|
||||
window.setTimeout(
|
||||
"timer()",
|
||||
2000
|
||||
);
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
//$("#scripterror").hide()
|
||||
//update()
|
||||
timer()
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<div id="msgid">
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<section>
|
||||
<h1>
|
||||
Servers <input type="button" value="Manager Logs" style="float: right;" onclick="window.open('/api/v1/logs/txt')" />
|
||||
</h1>
|
||||
|
||||
<div id="servers">
|
||||
<table id="servers_table" border="1" width="100%" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20%">Host</th>
|
||||
<th width="3%">Ver</th>
|
||||
<th width="1%">Load</th>
|
||||
<th width="1%">CPU</th>
|
||||
<th width="1%">Mem</th>
|
||||
<th width="1%">TX</th>
|
||||
<th width="1%">RX</th>
|
||||
<th width="70%">Active Instances</th>
|
||||
<th width="1%">Logs</th>
|
||||
<th width="1%">Stop</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="servers_table_rows">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<p><br>
|
||||
<section>
|
||||
<h1>
|
||||
Instances
|
||||
</h1>
|
||||
<div id="instances">
|
||||
<table id="instances_table" border="1" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="33%">Instance</th>
|
||||
<!--<th>Host</th>-->
|
||||
<!--<th>Stream Address</th>-->
|
||||
<!--<th>Active</th>-->
|
||||
<!--<th>Camera</th>-->
|
||||
<!--<th>Geometry</th>-->
|
||||
<!--<th>Start</th>-->
|
||||
<th width="33%">Info</th>
|
||||
<th width="33%">Config</th>
|
||||
<th width="1%">Stop</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="instances_table_rows">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<p><br>
|
||||
<section>
|
||||
<div id="scripterror" style="color:red">
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": null,
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"function": "psen_min_processing",
|
||||
"camera_name": "SARES11-SPEC125-M1",
|
||||
"name": "SARES11-SPEC125-M1_psen_db",
|
||||
"mode": "PUSH",
|
||||
"roi_signal": [
|
||||
0,
|
||||
2048,
|
||||
270,
|
||||
60
|
||||
],
|
||||
"roi_background": [
|
||||
0,
|
||||
2048,
|
||||
200,
|
||||
150
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": null,
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "store",
|
||||
"camera_name": "SARES11-SPEC125-M1",
|
||||
"name": "SARES11-SPEC125-M1_psen_ib",
|
||||
"stream_port": 0
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": null,
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"include": [
|
||||
"x_center_of_mass",
|
||||
"y_center_of_mass",
|
||||
"x_fit_mean",
|
||||
"y_fit_mean"
|
||||
],
|
||||
"camera_name": "SARES11-SPEC125-M2",
|
||||
"name": "SARES11-SPEC125-M2_acd"
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": null,
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"function": "psen_min_processing",
|
||||
"camera_name": "SARES11-SPEC125-M2",
|
||||
"name": "SARES11-SPEC125-M2_psen_db",
|
||||
"mode": "PUSH",
|
||||
"roi_background": [
|
||||
0,
|
||||
2048,
|
||||
400,
|
||||
500
|
||||
],
|
||||
"roi_signal": [
|
||||
0,
|
||||
2048,
|
||||
1150,
|
||||
500
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": null,
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "store",
|
||||
"camera_name": "SARES11-SPEC125-M2",
|
||||
"name": "SARES11-SPEC125-M2_psen_ib",
|
||||
"stream_port": 0
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": [
|
||||
0,
|
||||
1020,
|
||||
650,
|
||||
350
|
||||
],
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"camera_name": "SARES20-CAMS142-M4_BS",
|
||||
"name": "SARES20-CAMS142-M4_BSP"
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": null,
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"function": "psen_min_processing",
|
||||
"camera_name": "SARES20-CAMS142-M4",
|
||||
"name": "SARES20-CAMS142-M4_psen_db",
|
||||
"mode": "PUSH",
|
||||
"roi_background": [
|
||||
0,
|
||||
2048,
|
||||
200,
|
||||
200
|
||||
],
|
||||
"roi_signal": [
|
||||
0,
|
||||
2048,
|
||||
1,
|
||||
200
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": null,
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"function":"psen",
|
||||
"camera_name": "SARES20-CAMS142-M4",
|
||||
"name": "SARES20-CAMS142-M4_psen_dw",
|
||||
"mode": "PUSH",
|
||||
"buffer_size":100,
|
||||
"no_client_timeout":30,
|
||||
"queue_size":1
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": null,
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "store",
|
||||
"camera_name": "SARES20-CAMS142-M4",
|
||||
"name": "SARES20-CAMS142-M4_psen_ib",
|
||||
"stream_port": 0
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": null,
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"function":"psen_min_processing",
|
||||
"camera_name": "SARES20-CAMS142-M5",
|
||||
"name": "SARES20-CAMS142-M5_psen_db",
|
||||
"mode": "PUSH"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": null,
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"function":"psen",
|
||||
"camera_name": "SARES20-CAMS142-M5",
|
||||
"name": "SARES20-CAMS142-M5_psen_dw",
|
||||
"mode": "PUSH",
|
||||
"buffer_size":100,
|
||||
"no_client_timeout":30,
|
||||
"queue_size":1
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": null,
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "store",
|
||||
"camera_name": "SARES20-CAMS142-M5",
|
||||
"name": "SARES20-CAMS142-M5_psen_ib",
|
||||
"stream_port": 0
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": null,
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"include": [
|
||||
"intensity",
|
||||
"x_center_of_mass",
|
||||
"x_fit_mean",
|
||||
"y_center_of_mass",
|
||||
"y_fit_mean"
|
||||
],
|
||||
"camera_name": "SARFE10-PPRM053",
|
||||
"name": "SARFE10-PPRM053_acd"
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": null,
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"include": [
|
||||
"intensity",
|
||||
"x_center_of_mass",
|
||||
"x_fit_mean",
|
||||
"y_center_of_mass",
|
||||
"y_fit_mean"
|
||||
],
|
||||
"camera_name": "SATFE10-PSCR066",
|
||||
"name": "SATFE10-PSCR066_acd"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": null,
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"include": [
|
||||
"x_center_of_mass",
|
||||
"y_center_of_mass",
|
||||
"x_fit_mean",
|
||||
"y_fit_mean"
|
||||
],
|
||||
"camera_name": "SATFE10-PSCR070",
|
||||
"name": "SATFE10-PSCR070_acd"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": [
|
||||
1,
|
||||
1024,
|
||||
1,
|
||||
1024
|
||||
],
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"camera_name": "SLAAR11-LCAM-C422",
|
||||
"name": "SLAAR11-PBPC145_XPOS"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": [
|
||||
0,
|
||||
1020,
|
||||
650,
|
||||
350
|
||||
],
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"name": "SLAAR11-PSEN119_R1",
|
||||
"camera_name": "SLAAR21-PSEN119_Spec_ROI"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": [
|
||||
0,
|
||||
1024,
|
||||
500,
|
||||
500
|
||||
],
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"name": "SLAAR11-PSEN119_R2",
|
||||
"camera_name": "SLAAR21-PSEN119_Spec_ROI"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": [
|
||||
0,
|
||||
1024,
|
||||
950,
|
||||
50
|
||||
],
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"name": "SLAAR11-PSEN119_TEMP1",
|
||||
"camera_name": "SLAAR21-PSEN119_Spec_ROI"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": [
|
||||
150,
|
||||
50,
|
||||
100,
|
||||
52
|
||||
],
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"camera_name": "SLAAR21-LCAM-C561",
|
||||
"name": "SLAAR21-PSEN135_R1"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": [
|
||||
150,
|
||||
50,
|
||||
100,
|
||||
50
|
||||
],
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"camera_name": "SLAAR21-LCAM-C561",
|
||||
"name": "SLAAR21-PSEN135_R2"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": null,
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"include": [
|
||||
"x_center_of_mass",
|
||||
"y_center_of_mass",
|
||||
"x_fit_mean",
|
||||
"y_fit_mean"
|
||||
],
|
||||
"camera_name": "SLG-LCAM-C041",
|
||||
"name": "SLG-LCAM-C041_acd"
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": null,
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"include": [
|
||||
"x_center_of_mass",
|
||||
"y_center_of_mass",
|
||||
"x_fit_mean",
|
||||
"y_fit_mean"
|
||||
],
|
||||
"camera_name": "SLG-LCAM-C044",
|
||||
"name": "SLG-LCAM-C044_acd"
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"image_background_enable": false,
|
||||
"image_background": null,
|
||||
"image_threshold": null,
|
||||
"image_region_of_interest": [
|
||||
10,
|
||||
10,
|
||||
600,
|
||||
100
|
||||
],
|
||||
"image_good_region": null,
|
||||
"image_slices": null,
|
||||
"pipeline_type": "processing",
|
||||
"name": "TestBSPL",
|
||||
"camera_name": "TestBS"
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
import json
|
||||
from logging import getLogger
|
||||
|
||||
import numpy
|
||||
from cam_server.pipeline.data_processing import functions
|
||||
|
||||
_logger = getLogger(__name__)
|
||||
|
||||
_return_value = None
|
||||
def process_image(image, timestamp, x_axis, y_axis, parameters, image_background_array=None):
|
||||
global _return_value
|
||||
|
||||
|
||||
if _return_value is not None:
|
||||
return _return_value
|
||||
|
||||
|
||||
# Make a copy if the original image (can be used by multiple pipelines)
|
||||
image = numpy.array(image)
|
||||
|
||||
|
||||
# Add return values
|
||||
return_value = dict()
|
||||
|
||||
if image_background_array is not None:
|
||||
image = functions.subtract_background(image, image_background_array)
|
||||
|
||||
image_threshold = parameters.get("image_threshold")
|
||||
if image_threshold is not None and image_threshold > 0:
|
||||
functions.apply_threshold(image, image_threshold)
|
||||
|
||||
image_region_of_interest = parameters.get("image_region_of_interest")
|
||||
if image_region_of_interest:
|
||||
offset_x, size_x, offset_y, size_y = image_region_of_interest
|
||||
image = functions.get_region_of_interest(image, offset_x, size_x, offset_y, size_y)
|
||||
|
||||
# Apply roi to geometry x_axis and y_axis
|
||||
x_axis = x_axis[offset_x:offset_x + size_x]
|
||||
y_axis = y_axis[offset_y:offset_y + size_y]
|
||||
|
||||
(min_value, max_value) = functions.get_min_max(image)
|
||||
|
||||
(x_profile, y_profile) = functions.get_x_y_profile(image)
|
||||
|
||||
x_fit = functions.gauss_fit(x_profile, x_axis)
|
||||
y_fit = functions.gauss_fit(y_profile, y_axis)
|
||||
|
||||
x_fit_gauss_function, x_fit_offset, x_fit_amplitude, x_fit_mean, x_fit_standard_deviation, x_center_of_mass, x_rms = x_fit
|
||||
y_fit_gauss_function, y_fit_offset, y_fit_amplitude, y_fit_mean, y_fit_standard_deviation, y_center_of_mass, y_rms = y_fit
|
||||
|
||||
# Could be also y_profile.sum() -> it should give the same result.
|
||||
intensity = x_profile.sum()
|
||||
|
||||
# Add return values
|
||||
return_value["function"] = 3
|
||||
return_value["x_axis"] = x_axis
|
||||
return_value["y_axis"] = y_axis
|
||||
return_value["image"] = image
|
||||
return_value["timestamp"] = timestamp
|
||||
return_value["min_value"] = min_value
|
||||
return_value["max_value"] = max_value
|
||||
return_value["x_profile"] = x_profile
|
||||
return_value["y_profile"] = y_profile
|
||||
return_value["intensity"] = intensity
|
||||
|
||||
# Needed for config traceability.
|
||||
return_value["processing_parameters"] = json.dumps(parameters)
|
||||
|
||||
# TODO Provide - Center of mass of profile
|
||||
# TODO Provide - RMS of profile
|
||||
return_value["x_center_of_mass"] = x_center_of_mass
|
||||
return_value["x_rms"] = x_rms
|
||||
return_value["y_center_of_mass"] = y_center_of_mass
|
||||
return_value["y_rms"] = y_rms
|
||||
|
||||
# Fitting results
|
||||
return_value["x_fit_gauss_function"] = x_fit_gauss_function
|
||||
return_value["x_fit_offset"] = x_fit_offset
|
||||
return_value["x_fit_amplitude"] = x_fit_amplitude
|
||||
return_value["x_fit_standard_deviation"] = x_fit_standard_deviation
|
||||
return_value["x_fit_mean"] = x_fit_mean
|
||||
|
||||
return_value["y_fit_gauss_function"] = y_fit_gauss_function
|
||||
return_value["y_fit_offset"] = y_fit_offset
|
||||
return_value["y_fit_amplitude"] = y_fit_amplitude
|
||||
return_value["y_fit_standard_deviation"] = y_fit_standard_deviation
|
||||
return_value["y_fit_mean"] = y_fit_mean
|
||||
|
||||
image_good_region = parameters.get("image_good_region")
|
||||
if image_good_region:
|
||||
try:
|
||||
|
||||
def initialize_good_region_values():
|
||||
# Initialize the good region parameters.
|
||||
return_value["good_region"] = None
|
||||
return_value["gr_x_axis"] = None
|
||||
return_value["gr_y_axis"] = None
|
||||
return_value["gr_x_profile"] = None
|
||||
return_value["gr_y_profile"] = None
|
||||
|
||||
return_value["gr_x_fit_gauss_function"] = None
|
||||
return_value["gr_x_fit_offset"] = None
|
||||
return_value["gr_x_fit_amplitude"] = None
|
||||
return_value["gr_x_fit_standard_deviation"] = None
|
||||
return_value["gr_x_fit_mean"] = None
|
||||
|
||||
return_value["gr_y_fit_gauss_function"] = None
|
||||
return_value["gr_y_fit_offset"] = None
|
||||
return_value["gr_y_fit_amplitude"] = None
|
||||
return_value["gr_y_fit_standard_deviation"] = None
|
||||
return_value["gr_y_fit_mean"] = None
|
||||
return_value["gr_intensity"] = None
|
||||
|
||||
slices = parameters.get("image_slices")
|
||||
if slices:
|
||||
return_value["slice_orientation"] = slices["orientation"]
|
||||
initialize_slices_values(slices["number_of_slices"])
|
||||
|
||||
def initialize_slices_values(number_of_slices):
|
||||
return_value["slice_amount"] = number_of_slices
|
||||
return_value["slice_length"] = None
|
||||
|
||||
for i in range(number_of_slices):
|
||||
return_value["slice_%s_center_x" % i] = None
|
||||
return_value["slice_%s_center_y" % i] = None
|
||||
return_value["slice_%s_standard_deviation" % i] = None
|
||||
return_value["slice_%s_intensity" % i] = None
|
||||
|
||||
return_value["coupling"] = None
|
||||
return_value["coupling_slope"] = None
|
||||
return_value["coupling_offset"] = None
|
||||
|
||||
# Good region and slices should be None if cannot be calculated.
|
||||
initialize_good_region_values()
|
||||
|
||||
threshold = image_good_region["threshold"]
|
||||
gfscale = image_good_region["gfscale"]
|
||||
|
||||
# Get the good region
|
||||
good_region_x_start, good_region_x_end = functions.get_good_region_profile(x_profile, threshold, gfscale)
|
||||
good_region_y_start, good_region_y_end = functions.get_good_region_profile(y_profile, threshold, gfscale)
|
||||
|
||||
# Clip good region
|
||||
good_region = image[good_region_y_start:good_region_y_end, good_region_x_start:good_region_x_end]
|
||||
|
||||
good_region_x_axis = x_axis[good_region_x_start:good_region_x_end]
|
||||
good_region_y_axis = y_axis[good_region_y_start:good_region_y_end]
|
||||
|
||||
# Get profiles of the good region
|
||||
(good_region_x_profile, good_region_y_profile) = functions.get_x_y_profile(good_region)
|
||||
|
||||
# Could be also good_region_y_profile.sum() -> it should give the same result.
|
||||
good_region_intensity = good_region_x_profile.sum()
|
||||
|
||||
# Fit the profiles
|
||||
good_region_x_fit = functions.gauss_fit(good_region_x_profile, good_region_x_axis)
|
||||
good_region_y_fit = functions.gauss_fit(good_region_y_profile, good_region_y_axis)
|
||||
|
||||
gr_x_fit_gauss_function, gr_x_fit_offset, gr_x_fit_amplitude, gr_x_fit_mean, gr_x_fit_standard_deviation, _, _ = good_region_x_fit
|
||||
gr_y_fit_gauss_function, gr_y_fit_offset, gr_y_fit_amplitude, gr_y_fit_mean, gr_y_fit_standard_deviation, _, _ = good_region_y_fit
|
||||
|
||||
# Add return values
|
||||
return_value["good_region"] = [good_region_x_start, good_region_y_start, good_region_x_end,
|
||||
good_region_y_end]
|
||||
return_value["gr_x_axis"] = good_region_x_axis
|
||||
return_value["gr_y_axis"] = good_region_y_axis
|
||||
return_value["gr_x_profile"] = good_region_x_profile
|
||||
return_value["gr_y_profile"] = good_region_y_profile
|
||||
|
||||
return_value["gr_x_fit_gauss_function"] = gr_x_fit_gauss_function
|
||||
return_value["gr_x_fit_offset"] = gr_x_fit_offset
|
||||
return_value["gr_x_fit_amplitude"] = gr_x_fit_amplitude
|
||||
return_value["gr_x_fit_standard_deviation"] = gr_x_fit_standard_deviation
|
||||
return_value["gr_x_fit_mean"] = gr_x_fit_mean
|
||||
|
||||
return_value["gr_y_fit_gauss_function"] = gr_y_fit_gauss_function
|
||||
return_value["gr_y_fit_offset"] = gr_y_fit_offset
|
||||
return_value["gr_y_fit_amplitude"] = gr_y_fit_amplitude
|
||||
return_value["gr_y_fit_standard_deviation"] = gr_y_fit_standard_deviation
|
||||
return_value["gr_y_fit_mean"] = gr_y_fit_mean
|
||||
return_value["gr_intensity"] = good_region_intensity
|
||||
|
||||
image_slices = parameters.get("image_slices")
|
||||
|
||||
if image_slices:
|
||||
|
||||
scale = image_slices["scale"]
|
||||
slice_number = image_slices["number_of_slices"]
|
||||
orientation = image_slices["orientation"]
|
||||
|
||||
# Adjust the number of slices to be odd.
|
||||
if slice_number % 2 == 0:
|
||||
# Add a middle slice if number of slices is even - as middle slice is half/half on center
|
||||
_logger.info('Add additional middle slice')
|
||||
slice_number += 1
|
||||
initialize_slices_values(slice_number)
|
||||
|
||||
try:
|
||||
x_slice_data, x_slice_length = functions.get_x_slices_data(good_region, good_region_x_axis,
|
||||
good_region_y_axis, gr_x_fit_mean,
|
||||
gr_x_fit_standard_deviation,
|
||||
scaling=scale,
|
||||
number_of_slices=slice_number)
|
||||
|
||||
y_slice_data, y_slice_length = functions.get_y_slices_data(good_region, good_region_x_axis,
|
||||
good_region_y_axis, gr_y_fit_mean,
|
||||
gr_y_fit_standard_deviation,
|
||||
scaling=scale,
|
||||
number_of_slices=slice_number)
|
||||
|
||||
if orientation == "vertical":
|
||||
slice_data = y_slice_data
|
||||
slice_length = y_slice_length
|
||||
|
||||
elif orientation == "horizontal":
|
||||
slice_data = x_slice_data
|
||||
slice_length = x_slice_length
|
||||
|
||||
else:
|
||||
raise ValueError("Invalid slice orientation '%s'." % orientation)
|
||||
|
||||
return_value["slice_length"] = slice_length
|
||||
|
||||
# Add return values
|
||||
counter = 0
|
||||
for data in slice_data:
|
||||
return_value["slice_%s_center_x" % counter] = data[0][0]
|
||||
return_value["slice_%s_center_y" % counter] = data[0][1]
|
||||
return_value["slice_%s_standard_deviation" % counter] = data[1]
|
||||
return_value["slice_%s_intensity" % counter] = data[2]
|
||||
counter += 1
|
||||
|
||||
# Calculate x/y coupling, always out of horizontal (x axis) slices.
|
||||
x = []
|
||||
y = []
|
||||
for data in x_slice_data:
|
||||
x.append(float(data[0][0])) # x
|
||||
y.append(float(data[0][1])) # y
|
||||
|
||||
slope, offset = functions.linear_fit(x, y)
|
||||
return_value["coupling"] = slope * (gr_x_fit_standard_deviation ** 2)
|
||||
return_value["coupling_slope"] = slope
|
||||
return_value["coupling_offset"] = offset
|
||||
|
||||
except: # Except for slices
|
||||
_logger.debug('Unable to apply slices')
|
||||
|
||||
except: # Except for good region
|
||||
_logger.debug('Unable to detect good region')
|
||||
|
||||
_return_value = return_value
|
||||
return return_value
|
||||
@@ -0,0 +1,273 @@
|
||||
import json
|
||||
from logging import getLogger
|
||||
|
||||
import numpy
|
||||
from cam_server.pipeline.data_processing import functions
|
||||
|
||||
_logger = getLogger(__name__)
|
||||
|
||||
_return_value = None
|
||||
def process_image(image, timestamp, x_axis, y_axis, parameters, image_background_array=None):
|
||||
global _return_value
|
||||
oimage=image
|
||||
# Make a copy if the original image (can be used by multiple pipelines)
|
||||
image = numpy.array(image)
|
||||
|
||||
if _return_value is not None:
|
||||
return _return_value
|
||||
# Add return values
|
||||
return_value = dict()
|
||||
|
||||
if image_background_array is not None:
|
||||
image = functions.subtract_background(image, image_background_array)
|
||||
|
||||
image_threshold = parameters.get("image_threshold")
|
||||
if image_threshold is not None and image_threshold > 0:
|
||||
functions.apply_threshold(image, image_threshold)
|
||||
|
||||
image_region_of_interest = parameters.get("image_region_of_interest")
|
||||
if image_region_of_interest:
|
||||
offset_x, size_x, offset_y, size_y = image_region_of_interest
|
||||
image = functions.get_region_of_interest(image, offset_x, size_x, offset_y, size_y)
|
||||
|
||||
# Apply roi to geometry x_axis and y_axis
|
||||
x_axis = x_axis[offset_x:offset_x + size_x]
|
||||
y_axis = y_axis[offset_y:offset_y + size_y]
|
||||
|
||||
(min_value, max_value) = functions.get_min_max(image)
|
||||
|
||||
(x_profile, y_profile) = functions.get_x_y_profile(image)
|
||||
|
||||
x_fit = functions.gauss_fit(x_profile, x_axis)
|
||||
y_fit = functions.gauss_fit(y_profile, y_axis)
|
||||
|
||||
x_fit_gauss_function, x_fit_offset, x_fit_amplitude, x_fit_mean, x_fit_standard_deviation, x_center_of_mass, x_rms = x_fit
|
||||
y_fit_gauss_function, y_fit_offset, y_fit_amplitude, y_fit_mean, y_fit_standard_deviation, y_center_of_mass, y_rms = y_fit
|
||||
|
||||
# Could be also y_profile.sum() -> it should give the same result.
|
||||
intensity = x_profile.sum()
|
||||
|
||||
# Add return values
|
||||
return_value["function"] =5
|
||||
|
||||
return_value["ao_dtype"] = str(oimage.dtype)
|
||||
return_value["ao_flags"] = str(oimage.flags )
|
||||
return_value["ao_size"] = str(oimage.size)
|
||||
return_value["ao_itemsize"] = str(oimage.itemsize)
|
||||
return_value["ao_nbytes"] = str(oimage.nbytes)
|
||||
return_value["ao_ndim"] = str(oimage.ndim)
|
||||
return_value["ao_shape"] = str(oimage.shape )
|
||||
return_value["ao_strides"] = str(oimage.strides )
|
||||
return_value["ao_ctypes"] = str(oimage.ctypes)
|
||||
return_value["ao_base"] = str(oimage.base)
|
||||
|
||||
|
||||
return_value["a_dtype"] = str(image.dtype)
|
||||
return_value["a_flags"] = str(image.flags )
|
||||
return_value["a_size"] = str(image.size)
|
||||
return_value["a_itemsize"] = str(image.itemsize)
|
||||
return_value["a_nbytes"] = str(image.nbytes)
|
||||
return_value["a_ndim"] = str(image.ndim)
|
||||
return_value["a_shape"] = str(image.shape )
|
||||
return_value["a_strides"] = str(image.strides )
|
||||
return_value["a_ctypes"] = str(image.ctypes)
|
||||
return_value["a_base"] = str(image.base)
|
||||
|
||||
|
||||
return_value["x_axis"] = x_axis
|
||||
return_value["y_axis"] = y_axis
|
||||
return_value["image"] = image
|
||||
return_value["timestamp"] = timestamp
|
||||
return_value["min_value"] = min_value
|
||||
return_value["max_value"] = max_value
|
||||
return_value["x_profile"] = x_profile
|
||||
return_value["y_profile"] = y_profile
|
||||
return_value["intensity"] = intensity
|
||||
|
||||
# Needed for config traceability.
|
||||
return_value["processing_parameters"] = json.dumps(parameters)
|
||||
|
||||
# TODO Provide - Center of mass of profile
|
||||
# TODO Provide - RMS of profile
|
||||
return_value["x_center_of_mass"] = x_center_of_mass
|
||||
return_value["x_rms"] = x_rms
|
||||
return_value["y_center_of_mass"] = y_center_of_mass
|
||||
return_value["y_rms"] = y_rms
|
||||
|
||||
# Fitting results
|
||||
return_value["x_fit_gauss_function"] = x_fit_gauss_function
|
||||
return_value["x_fit_offset"] = x_fit_offset
|
||||
return_value["x_fit_amplitude"] = x_fit_amplitude
|
||||
return_value["x_fit_standard_deviation"] = x_fit_standard_deviation
|
||||
return_value["x_fit_mean"] = x_fit_mean
|
||||
|
||||
return_value["y_fit_gauss_function"] = y_fit_gauss_function
|
||||
return_value["y_fit_offset"] = y_fit_offset
|
||||
return_value["y_fit_amplitude"] = y_fit_amplitude
|
||||
return_value["y_fit_standard_deviation"] = y_fit_standard_deviation
|
||||
return_value["y_fit_mean"] = y_fit_mean
|
||||
|
||||
image_good_region = parameters.get("image_good_region")
|
||||
if image_good_region:
|
||||
try:
|
||||
|
||||
def initialize_good_region_values():
|
||||
# Initialize the good region parameters.
|
||||
return_value["good_region"] = None
|
||||
return_value["gr_x_axis"] = None
|
||||
return_value["gr_y_axis"] = None
|
||||
return_value["gr_x_profile"] = None
|
||||
return_value["gr_y_profile"] = None
|
||||
|
||||
return_value["gr_x_fit_gauss_function"] = None
|
||||
return_value["gr_x_fit_offset"] = None
|
||||
return_value["gr_x_fit_amplitude"] = None
|
||||
return_value["gr_x_fit_standard_deviation"] = None
|
||||
return_value["gr_x_fit_mean"] = None
|
||||
|
||||
return_value["gr_y_fit_gauss_function"] = None
|
||||
return_value["gr_y_fit_offset"] = None
|
||||
return_value["gr_y_fit_amplitude"] = None
|
||||
return_value["gr_y_fit_standard_deviation"] = None
|
||||
return_value["gr_y_fit_mean"] = None
|
||||
return_value["gr_intensity"] = None
|
||||
|
||||
slices = parameters.get("image_slices")
|
||||
if slices:
|
||||
return_value["slice_orientation"] = slices["orientation"]
|
||||
initialize_slices_values(slices["number_of_slices"])
|
||||
|
||||
def initialize_slices_values(number_of_slices):
|
||||
return_value["slice_amount"] = number_of_slices
|
||||
return_value["slice_length"] = None
|
||||
|
||||
for i in range(number_of_slices):
|
||||
return_value["slice_%s_center_x" % i] = None
|
||||
return_value["slice_%s_center_y" % i] = None
|
||||
return_value["slice_%s_standard_deviation" % i] = None
|
||||
return_value["slice_%s_intensity" % i] = None
|
||||
|
||||
return_value["coupling"] = None
|
||||
return_value["coupling_slope"] = None
|
||||
return_value["coupling_offset"] = None
|
||||
|
||||
# Good region and slices should be None if cannot be calculated.
|
||||
initialize_good_region_values()
|
||||
|
||||
threshold = image_good_region["threshold"]
|
||||
gfscale = image_good_region["gfscale"]
|
||||
|
||||
# Get the good region
|
||||
good_region_x_start, good_region_x_end = functions.get_good_region_profile(x_profile, threshold, gfscale)
|
||||
good_region_y_start, good_region_y_end = functions.get_good_region_profile(y_profile, threshold, gfscale)
|
||||
|
||||
# Clip good region
|
||||
good_region = image[good_region_y_start:good_region_y_end, good_region_x_start:good_region_x_end]
|
||||
|
||||
good_region_x_axis = x_axis[good_region_x_start:good_region_x_end]
|
||||
good_region_y_axis = y_axis[good_region_y_start:good_region_y_end]
|
||||
|
||||
# Get profiles of the good region
|
||||
(good_region_x_profile, good_region_y_profile) = functions.get_x_y_profile(good_region)
|
||||
|
||||
# Could be also good_region_y_profile.sum() -> it should give the same result.
|
||||
good_region_intensity = good_region_x_profile.sum()
|
||||
|
||||
# Fit the profiles
|
||||
good_region_x_fit = functions.gauss_fit(good_region_x_profile, good_region_x_axis)
|
||||
good_region_y_fit = functions.gauss_fit(good_region_y_profile, good_region_y_axis)
|
||||
|
||||
gr_x_fit_gauss_function, gr_x_fit_offset, gr_x_fit_amplitude, gr_x_fit_mean, gr_x_fit_standard_deviation, _, _ = good_region_x_fit
|
||||
gr_y_fit_gauss_function, gr_y_fit_offset, gr_y_fit_amplitude, gr_y_fit_mean, gr_y_fit_standard_deviation, _, _ = good_region_y_fit
|
||||
|
||||
# Add return values
|
||||
return_value["good_region"] = [good_region_x_start, good_region_y_start, good_region_x_end,
|
||||
good_region_y_end]
|
||||
return_value["gr_x_axis"] = good_region_x_axis
|
||||
return_value["gr_y_axis"] = good_region_y_axis
|
||||
return_value["gr_x_profile"] = good_region_x_profile
|
||||
return_value["gr_y_profile"] = good_region_y_profile
|
||||
|
||||
return_value["gr_x_fit_gauss_function"] = gr_x_fit_gauss_function
|
||||
return_value["gr_x_fit_offset"] = gr_x_fit_offset
|
||||
return_value["gr_x_fit_amplitude"] = gr_x_fit_amplitude
|
||||
return_value["gr_x_fit_standard_deviation"] = gr_x_fit_standard_deviation
|
||||
return_value["gr_x_fit_mean"] = gr_x_fit_mean
|
||||
|
||||
return_value["gr_y_fit_gauss_function"] = gr_y_fit_gauss_function
|
||||
return_value["gr_y_fit_offset"] = gr_y_fit_offset
|
||||
return_value["gr_y_fit_amplitude"] = gr_y_fit_amplitude
|
||||
return_value["gr_y_fit_standard_deviation"] = gr_y_fit_standard_deviation
|
||||
return_value["gr_y_fit_mean"] = gr_y_fit_mean
|
||||
return_value["gr_intensity"] = good_region_intensity
|
||||
|
||||
image_slices = parameters.get("image_slices")
|
||||
|
||||
if image_slices:
|
||||
|
||||
scale = image_slices["scale"]
|
||||
slice_number = image_slices["number_of_slices"]
|
||||
orientation = image_slices["orientation"]
|
||||
|
||||
# Adjust the number of slices to be odd.
|
||||
if slice_number % 2 == 0:
|
||||
# Add a middle slice if number of slices is even - as middle slice is half/half on center
|
||||
_logger.info('Add additional middle slice')
|
||||
slice_number += 1
|
||||
initialize_slices_values(slice_number)
|
||||
|
||||
try:
|
||||
x_slice_data, x_slice_length = functions.get_x_slices_data(good_region, good_region_x_axis,
|
||||
good_region_y_axis, gr_x_fit_mean,
|
||||
gr_x_fit_standard_deviation,
|
||||
scaling=scale,
|
||||
number_of_slices=slice_number)
|
||||
|
||||
y_slice_data, y_slice_length = functions.get_y_slices_data(good_region, good_region_x_axis,
|
||||
good_region_y_axis, gr_y_fit_mean,
|
||||
gr_y_fit_standard_deviation,
|
||||
scaling=scale,
|
||||
number_of_slices=slice_number)
|
||||
|
||||
if orientation == "vertical":
|
||||
slice_data = y_slice_data
|
||||
slice_length = y_slice_length
|
||||
|
||||
elif orientation == "horizontal":
|
||||
slice_data = x_slice_data
|
||||
slice_length = x_slice_length
|
||||
|
||||
else:
|
||||
raise ValueError("Invalid slice orientation '%s'." % orientation)
|
||||
|
||||
return_value["slice_length"] = slice_length
|
||||
|
||||
# Add return values
|
||||
counter = 0
|
||||
for data in slice_data:
|
||||
return_value["slice_%s_center_x" % counter] = data[0][0]
|
||||
return_value["slice_%s_center_y" % counter] = data[0][1]
|
||||
return_value["slice_%s_standard_deviation" % counter] = data[1]
|
||||
return_value["slice_%s_intensity" % counter] = data[2]
|
||||
counter += 1
|
||||
|
||||
# Calculate x/y coupling, always out of horizontal (x axis) slices.
|
||||
x = []
|
||||
y = []
|
||||
for data in x_slice_data:
|
||||
x.append(float(data[0][0])) # x
|
||||
y.append(float(data[0][1])) # y
|
||||
|
||||
slope, offset = functions.linear_fit(x, y)
|
||||
return_value["coupling"] = slope * (gr_x_fit_standard_deviation ** 2)
|
||||
return_value["coupling_slope"] = slope
|
||||
return_value["coupling_offset"] = offset
|
||||
|
||||
except: # Except for slices
|
||||
_logger.debug('Unable to apply slices')
|
||||
|
||||
except: # Except for good region
|
||||
_logger.debug('Unable to detect good region')
|
||||
|
||||
_return_value = return_value
|
||||
return return_value
|
||||
@@ -0,0 +1,274 @@
|
||||
import json
|
||||
from logging import getLogger
|
||||
|
||||
import numpy
|
||||
from cam_server.pipeline.data_processing import functions
|
||||
|
||||
_logger = getLogger(__name__)
|
||||
|
||||
_return_value = None
|
||||
def process_image(image, timestamp, x_axis, y_axis, parameters, image_background_array=None):
|
||||
global _return_value
|
||||
oimage=image
|
||||
# Make a copy if the original image (can be used by multiple pipelines)
|
||||
#image = numpy.array(image,subok=True)
|
||||
#image = numpy.copy(image)
|
||||
image = numpy.ndarray.copy(image, order='F')
|
||||
#if _return_value is not None:
|
||||
# return _return_value
|
||||
# Add return values
|
||||
return_value = dict()
|
||||
|
||||
if image_background_array is not None:
|
||||
image = functions.subtract_background(image, image_background_array)
|
||||
|
||||
image_threshold = parameters.get("image_threshold")
|
||||
if image_threshold is not None and image_threshold > 0:
|
||||
functions.apply_threshold(image, image_threshold)
|
||||
|
||||
image_region_of_interest = parameters.get("image_region_of_interest")
|
||||
if image_region_of_interest:
|
||||
offset_x, size_x, offset_y, size_y = image_region_of_interest
|
||||
image = functions.get_region_of_interest(image, offset_x, size_x, offset_y, size_y)
|
||||
|
||||
# Apply roi to geometry x_axis and y_axis
|
||||
x_axis = x_axis[offset_x:offset_x + size_x]
|
||||
y_axis = y_axis[offset_y:offset_y + size_y]
|
||||
|
||||
(min_value, max_value) = functions.get_min_max(image)
|
||||
|
||||
(x_profile, y_profile) = functions.get_x_y_profile(image)
|
||||
|
||||
x_fit = functions.gauss_fit(x_profile, x_axis)
|
||||
y_fit = functions.gauss_fit(y_profile, y_axis)
|
||||
|
||||
x_fit_gauss_function, x_fit_offset, x_fit_amplitude, x_fit_mean, x_fit_standard_deviation, x_center_of_mass, x_rms = x_fit
|
||||
y_fit_gauss_function, y_fit_offset, y_fit_amplitude, y_fit_mean, y_fit_standard_deviation, y_center_of_mass, y_rms = y_fit
|
||||
|
||||
# Could be also y_profile.sum() -> it should give the same result.
|
||||
intensity = x_profile.sum()
|
||||
|
||||
# Add return values
|
||||
return_value["function"] =7
|
||||
|
||||
return_value["ao_dtype"] = str(oimage.dtype)
|
||||
return_value["ao_flags"] = str(oimage.flags )
|
||||
return_value["ao_size"] = str(oimage.size)
|
||||
return_value["ao_itemsize"] = str(oimage.itemsize)
|
||||
return_value["ao_nbytes"] = str(oimage.nbytes)
|
||||
return_value["ao_ndim"] = str(oimage.ndim)
|
||||
return_value["ao_shape"] = str(oimage.shape )
|
||||
return_value["ao_strides"] = str(oimage.strides )
|
||||
return_value["ao_ctypes"] = str(oimage.ctypes)
|
||||
return_value["ao_base"] = str(oimage.base)
|
||||
|
||||
|
||||
return_value["a_dtype"] = str(image.dtype)
|
||||
return_value["a_flags"] = str(image.flags )
|
||||
return_value["a_size"] = str(image.size)
|
||||
return_value["a_itemsize"] = str(image.itemsize)
|
||||
return_value["a_nbytes"] = str(image.nbytes)
|
||||
return_value["a_ndim"] = str(image.ndim)
|
||||
return_value["a_shape"] = str(image.shape )
|
||||
return_value["a_strides"] = str(image.strides )
|
||||
return_value["a_ctypes"] = str(image.ctypes)
|
||||
return_value["a_base"] = str(image.base)
|
||||
|
||||
|
||||
return_value["x_axis"] = x_axis
|
||||
return_value["y_axis"] = y_axis
|
||||
return_value["image"] = image
|
||||
return_value["timestamp"] = timestamp
|
||||
return_value["min_value"] = min_value
|
||||
return_value["max_value"] = max_value
|
||||
return_value["x_profile"] = x_profile
|
||||
return_value["y_profile"] = y_profile
|
||||
return_value["intensity"] = intensity
|
||||
|
||||
# Needed for config traceability.
|
||||
return_value["processing_parameters"] = json.dumps(parameters)
|
||||
|
||||
# TODO Provide - Center of mass of profile
|
||||
# TODO Provide - RMS of profile
|
||||
return_value["x_center_of_mass"] = x_center_of_mass
|
||||
return_value["x_rms"] = x_rms
|
||||
return_value["y_center_of_mass"] = y_center_of_mass
|
||||
return_value["y_rms"] = y_rms
|
||||
|
||||
# Fitting results
|
||||
return_value["x_fit_gauss_function"] = x_fit_gauss_function
|
||||
return_value["x_fit_offset"] = x_fit_offset
|
||||
return_value["x_fit_amplitude"] = x_fit_amplitude
|
||||
return_value["x_fit_standard_deviation"] = x_fit_standard_deviation
|
||||
return_value["x_fit_mean"] = x_fit_mean
|
||||
|
||||
return_value["y_fit_gauss_function"] = y_fit_gauss_function
|
||||
return_value["y_fit_offset"] = y_fit_offset
|
||||
return_value["y_fit_amplitude"] = y_fit_amplitude
|
||||
return_value["y_fit_standard_deviation"] = y_fit_standard_deviation
|
||||
return_value["y_fit_mean"] = y_fit_mean
|
||||
|
||||
image_good_region = parameters.get("image_good_region")
|
||||
if image_good_region:
|
||||
try:
|
||||
|
||||
def initialize_good_region_values():
|
||||
# Initialize the good region parameters.
|
||||
return_value["good_region"] = None
|
||||
return_value["gr_x_axis"] = None
|
||||
return_value["gr_y_axis"] = None
|
||||
return_value["gr_x_profile"] = None
|
||||
return_value["gr_y_profile"] = None
|
||||
|
||||
return_value["gr_x_fit_gauss_function"] = None
|
||||
return_value["gr_x_fit_offset"] = None
|
||||
return_value["gr_x_fit_amplitude"] = None
|
||||
return_value["gr_x_fit_standard_deviation"] = None
|
||||
return_value["gr_x_fit_mean"] = None
|
||||
|
||||
return_value["gr_y_fit_gauss_function"] = None
|
||||
return_value["gr_y_fit_offset"] = None
|
||||
return_value["gr_y_fit_amplitude"] = None
|
||||
return_value["gr_y_fit_standard_deviation"] = None
|
||||
return_value["gr_y_fit_mean"] = None
|
||||
return_value["gr_intensity"] = None
|
||||
|
||||
slices = parameters.get("image_slices")
|
||||
if slices:
|
||||
return_value["slice_orientation"] = slices["orientation"]
|
||||
initialize_slices_values(slices["number_of_slices"])
|
||||
|
||||
def initialize_slices_values(number_of_slices):
|
||||
return_value["slice_amount"] = number_of_slices
|
||||
return_value["slice_length"] = None
|
||||
|
||||
for i in range(number_of_slices):
|
||||
return_value["slice_%s_center_x" % i] = None
|
||||
return_value["slice_%s_center_y" % i] = None
|
||||
return_value["slice_%s_standard_deviation" % i] = None
|
||||
return_value["slice_%s_intensity" % i] = None
|
||||
|
||||
return_value["coupling"] = None
|
||||
return_value["coupling_slope"] = None
|
||||
return_value["coupling_offset"] = None
|
||||
|
||||
# Good region and slices should be None if cannot be calculated.
|
||||
initialize_good_region_values()
|
||||
|
||||
threshold = image_good_region["threshold"]
|
||||
gfscale = image_good_region["gfscale"]
|
||||
|
||||
# Get the good region
|
||||
good_region_x_start, good_region_x_end = functions.get_good_region_profile(x_profile, threshold, gfscale)
|
||||
good_region_y_start, good_region_y_end = functions.get_good_region_profile(y_profile, threshold, gfscale)
|
||||
|
||||
# Clip good region
|
||||
good_region = image[good_region_y_start:good_region_y_end, good_region_x_start:good_region_x_end]
|
||||
|
||||
good_region_x_axis = x_axis[good_region_x_start:good_region_x_end]
|
||||
good_region_y_axis = y_axis[good_region_y_start:good_region_y_end]
|
||||
|
||||
# Get profiles of the good region
|
||||
(good_region_x_profile, good_region_y_profile) = functions.get_x_y_profile(good_region)
|
||||
|
||||
# Could be also good_region_y_profile.sum() -> it should give the same result.
|
||||
good_region_intensity = good_region_x_profile.sum()
|
||||
|
||||
# Fit the profiles
|
||||
good_region_x_fit = functions.gauss_fit(good_region_x_profile, good_region_x_axis)
|
||||
good_region_y_fit = functions.gauss_fit(good_region_y_profile, good_region_y_axis)
|
||||
|
||||
gr_x_fit_gauss_function, gr_x_fit_offset, gr_x_fit_amplitude, gr_x_fit_mean, gr_x_fit_standard_deviation, _, _ = good_region_x_fit
|
||||
gr_y_fit_gauss_function, gr_y_fit_offset, gr_y_fit_amplitude, gr_y_fit_mean, gr_y_fit_standard_deviation, _, _ = good_region_y_fit
|
||||
|
||||
# Add return values
|
||||
return_value["good_region"] = [good_region_x_start, good_region_y_start, good_region_x_end,
|
||||
good_region_y_end]
|
||||
return_value["gr_x_axis"] = good_region_x_axis
|
||||
return_value["gr_y_axis"] = good_region_y_axis
|
||||
return_value["gr_x_profile"] = good_region_x_profile
|
||||
return_value["gr_y_profile"] = good_region_y_profile
|
||||
|
||||
return_value["gr_x_fit_gauss_function"] = gr_x_fit_gauss_function
|
||||
return_value["gr_x_fit_offset"] = gr_x_fit_offset
|
||||
return_value["gr_x_fit_amplitude"] = gr_x_fit_amplitude
|
||||
return_value["gr_x_fit_standard_deviation"] = gr_x_fit_standard_deviation
|
||||
return_value["gr_x_fit_mean"] = gr_x_fit_mean
|
||||
|
||||
return_value["gr_y_fit_gauss_function"] = gr_y_fit_gauss_function
|
||||
return_value["gr_y_fit_offset"] = gr_y_fit_offset
|
||||
return_value["gr_y_fit_amplitude"] = gr_y_fit_amplitude
|
||||
return_value["gr_y_fit_standard_deviation"] = gr_y_fit_standard_deviation
|
||||
return_value["gr_y_fit_mean"] = gr_y_fit_mean
|
||||
return_value["gr_intensity"] = good_region_intensity
|
||||
|
||||
image_slices = parameters.get("image_slices")
|
||||
|
||||
if image_slices:
|
||||
|
||||
scale = image_slices["scale"]
|
||||
slice_number = image_slices["number_of_slices"]
|
||||
orientation = image_slices["orientation"]
|
||||
|
||||
# Adjust the number of slices to be odd.
|
||||
if slice_number % 2 == 0:
|
||||
# Add a middle slice if number of slices is even - as middle slice is half/half on center
|
||||
_logger.info('Add additional middle slice')
|
||||
slice_number += 1
|
||||
initialize_slices_values(slice_number)
|
||||
|
||||
try:
|
||||
x_slice_data, x_slice_length = functions.get_x_slices_data(good_region, good_region_x_axis,
|
||||
good_region_y_axis, gr_x_fit_mean,
|
||||
gr_x_fit_standard_deviation,
|
||||
scaling=scale,
|
||||
number_of_slices=slice_number)
|
||||
|
||||
y_slice_data, y_slice_length = functions.get_y_slices_data(good_region, good_region_x_axis,
|
||||
good_region_y_axis, gr_y_fit_mean,
|
||||
gr_y_fit_standard_deviation,
|
||||
scaling=scale,
|
||||
number_of_slices=slice_number)
|
||||
|
||||
if orientation == "vertical":
|
||||
slice_data = y_slice_data
|
||||
slice_length = y_slice_length
|
||||
|
||||
elif orientation == "horizontal":
|
||||
slice_data = x_slice_data
|
||||
slice_length = x_slice_length
|
||||
|
||||
else:
|
||||
raise ValueError("Invalid slice orientation '%s'." % orientation)
|
||||
|
||||
return_value["slice_length"] = slice_length
|
||||
|
||||
# Add return values
|
||||
counter = 0
|
||||
for data in slice_data:
|
||||
return_value["slice_%s_center_x" % counter] = data[0][0]
|
||||
return_value["slice_%s_center_y" % counter] = data[0][1]
|
||||
return_value["slice_%s_standard_deviation" % counter] = data[1]
|
||||
return_value["slice_%s_intensity" % counter] = data[2]
|
||||
counter += 1
|
||||
|
||||
# Calculate x/y coupling, always out of horizontal (x axis) slices.
|
||||
x = []
|
||||
y = []
|
||||
for data in x_slice_data:
|
||||
x.append(float(data[0][0])) # x
|
||||
y.append(float(data[0][1])) # y
|
||||
|
||||
slope, offset = functions.linear_fit(x, y)
|
||||
return_value["coupling"] = slope * (gr_x_fit_standard_deviation ** 2)
|
||||
return_value["coupling_slope"] = slope
|
||||
return_value["coupling_offset"] = offset
|
||||
|
||||
except: # Except for slices
|
||||
_logger.debug('Unable to apply slices')
|
||||
|
||||
except: # Except for good region
|
||||
_logger.debug('Unable to detect good region')
|
||||
|
||||
_return_value = return_value
|
||||
return return_value
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"SARES11-SPEC125-M1_psen_db": "SARES11-SPEC125-M1_psen_db1",
|
||||
"SARES11-SPEC125-M1_psen_ib": "SARES11-SPEC125-M1_psen_ib1",
|
||||
"SARES11-SPEC125-M2_psen_db": "SARES11-SPEC125-M2_psen_db1",
|
||||
"SARES11-SPEC125-M2_psen_ib": "SARES11-SPEC125-M2_psen_ib1",
|
||||
"SARES20-CAMS142-M4_psen_db": "SARES20-CAMS142-M4_psen_db1",
|
||||
"SARES20-CAMS142-M4_psen_ib": "SARES20-CAMS142-M4_psen_ib1",
|
||||
"SARES20-CAMS142-M5_psen_db": "SARES20-CAMS142-M5_psen_db1",
|
||||
"SARES20-CAMS142-M5_psen_ib": "SARES20-CAMS142-M5_psen_ib1"
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"http://sf-daqsync-01.psi.ch:8881": {
|
||||
"cameras": [
|
||||
],
|
||||
"expanding": true,
|
||||
"instances": [
|
||||
]
|
||||
},
|
||||
"http://sf-daqsync-03.psi.ch:8881": {
|
||||
"cameras": [
|
||||
],
|
||||
"expanding": true,
|
||||
"instances": [
|
||||
]
|
||||
},
|
||||
"http://sf-daqsync-04.psi.ch:8881": {
|
||||
"cameras": [
|
||||
],
|
||||
"expanding": true,
|
||||
"instances": [
|
||||
]
|
||||
},
|
||||
"http://sf-daqsync-05.psi.ch:8881": {
|
||||
"cameras": [
|
||||
],
|
||||
"expanding": true,
|
||||
"instances": [
|
||||
"SARES11-SPEC125-M1_psen_ib:9000",
|
||||
"SARES11-SPEC125-M1_psen_db:9001",
|
||||
"SARES11-SPEC125-M2_psen_ib:9010",
|
||||
"SARES11-SPEC125-M2_psen_db:9011"
|
||||
]
|
||||
},
|
||||
"http://sf-daqsync-06.psi.ch:8881": {
|
||||
"cameras": [
|
||||
],
|
||||
"expanding": true,
|
||||
"instances": [
|
||||
"SARES20-CAMS142-M4_psen_ib:9000",
|
||||
"SARES20-CAMS142-M4_psen_db:9001",
|
||||
"SARES20-CAMS142-M5_psen_ib:9010",
|
||||
"SARES20-CAMS142-M5_psen_db:9011"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,367 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Server Management</title>
|
||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var base = 'api/v1/proxy/';
|
||||
|
||||
function appendTableRow(table, rowData) {
|
||||
var lastRow = $('<tr/>').appendTo(table.find('tbody:last'));
|
||||
$.each(rowData, function(colIndex, c) {
|
||||
lastRow.append($('<td/>').html(c));
|
||||
});
|
||||
|
||||
return lastRow;
|
||||
}
|
||||
|
||||
function setTableCell(value, tableName, row, col) {
|
||||
var cell = $('#' + tableName + ' tbody tr:eq(' + row + ') td:eq(' + col + ')')[0]
|
||||
cell.innerHTML = value
|
||||
}
|
||||
|
||||
|
||||
function getRows(table){
|
||||
var rows = table.find('tbody').find('tr').length
|
||||
return rows
|
||||
}
|
||||
|
||||
function clear(table){
|
||||
//return $('#servers_table tr').length -1;
|
||||
table.find("tbody").empty()
|
||||
}
|
||||
|
||||
function isDict(v) {
|
||||
return typeof v==='object' && v!==null && !(v instanceof Array) && !(v instanceof Date);
|
||||
}
|
||||
|
||||
function isArray(v) {
|
||||
return (v instanceof Array)
|
||||
}
|
||||
|
||||
function dictToStr(dict, indent){
|
||||
var nested = true
|
||||
var ret = ""
|
||||
if (indent == undefined ){
|
||||
indent = "";
|
||||
ret = "<font size='2'><pre>"
|
||||
nested = false
|
||||
}
|
||||
|
||||
for (var key in dict) {
|
||||
var value = dict[key]
|
||||
if (isDict (value)){
|
||||
ret = ret + key + ":" + "\n"
|
||||
ret = ret + (dictToStr(value, /*"\t"*/ " "))
|
||||
} else {
|
||||
ret = ret + indent + key + ": " + /*JSON.stringify*/(value) + "\n"
|
||||
}
|
||||
}
|
||||
if (!nested){
|
||||
ret = ret+"</pre></font>"
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
function listToStr(lst, multiline, indent) {
|
||||
if (indent == undefined) {
|
||||
indent = "";
|
||||
}
|
||||
var separator = ', '
|
||||
var ret = ""
|
||||
if (multiline) {
|
||||
ret = "<font size='2'><pre>"
|
||||
separator = "\n"
|
||||
}
|
||||
if (isArray(lst)) {
|
||||
for (var i = 0; i < lst.length; i++) {
|
||||
ret = ret + indent + lst[i]
|
||||
if (i< lst.length-1) {
|
||||
ret = ret + separator
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ret = ret + indent + lst + separator
|
||||
}
|
||||
if (multiline) {
|
||||
ret = ret+"</pre></font>"
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
function dateToStr(date){
|
||||
//ret = "<pre>"
|
||||
//ret = ret + date.split(" ").join("\n")x
|
||||
//ret = ret+"</pre>"
|
||||
|
||||
//return date.split(" ").join("\n\t")
|
||||
|
||||
return date.split(" ").slice(0,2).join(" ")
|
||||
}
|
||||
|
||||
|
||||
function formatNum(n, force_decimals){
|
||||
if (force_decimals == undefined) {
|
||||
force_decimals = true
|
||||
}
|
||||
if (n) {
|
||||
if (n >= 1e12) {
|
||||
return (n / 1e12).toFixed(2) + "T"
|
||||
} else if (n >= 1e9) {
|
||||
return (n / 1e9).toFixed(2) + "G"
|
||||
} else if (n >= 1e6) {
|
||||
return (n / 1e6).toFixed(2) + "M"
|
||||
} else if (n >= 1e3) {
|
||||
return (n / 1e3).toFixed(2) + "K"
|
||||
} else if (!Number.isInteger(n) || force_decimals) {
|
||||
return (n).toFixed(2)
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
function deleteInstance(key){
|
||||
$.delete(base + key).error(function (xhr, textStatus, errorThrown) {
|
||||
$("#scripterror").show()
|
||||
$("#scripterror").html(xhr.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
function deleteAllInstances(server_index){
|
||||
$.delete(base + "server/" + server_index).error(function (xhr, textStatus, errorThrown) {
|
||||
$("#scripterror").show()
|
||||
$("#scripterror").html(xhr.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
function showLogs(server){
|
||||
window.open(server + "/api/v1/logs/txt");
|
||||
}
|
||||
|
||||
|
||||
function getServers() {
|
||||
$.get(base + 'servers', function (data) {
|
||||
var version = data["version"]
|
||||
var servers = data["servers"]
|
||||
var load = data["load"]
|
||||
var cpu = data["cpu"]
|
||||
var memory = data["memory"]
|
||||
var tx = data["tx"]
|
||||
var rx = data["rx"]
|
||||
var instances = data["instances"]
|
||||
var table = $("#servers_table")
|
||||
|
||||
for (var i = 0; i < servers.length; i++) {
|
||||
instances[i] = listToStr(instances[i], false)
|
||||
if (load[i] >=1000) {
|
||||
load[i] = "off"
|
||||
}
|
||||
if (getRows(table) <= i){
|
||||
var row = appendTableRow(table, [servers[i], version[i], load[i],
|
||||
formatNum(cpu[i]), formatNum(memory[i]), formatNum(tx[i]), formatNum(rx[i]), instances[i]])
|
||||
var callback = 'onclick="showLogs(\'' + servers[i]+ '\')"'
|
||||
row.append($('<td align="center"><button ' + callback + '>Logs</button></td>'))
|
||||
var callback = 'onclick="deleteAllInstances(\'' + i + '\')"'
|
||||
row.append($('<td align="center"><button ' + callback + '>Stop</button></td>'))
|
||||
} else {
|
||||
|
||||
setTableCell(servers[i] , "servers_table", i, 0)
|
||||
setTableCell(version[i] , "servers_table", i, 1)
|
||||
setTableCell(load[i], "servers_table", i, 2)
|
||||
setTableCell(formatNum(cpu[i]), "servers_table", i, 3)
|
||||
setTableCell(formatNum(memory[i]), "servers_table", i, 4)
|
||||
setTableCell(formatNum(tx[i]), "servers_table", i, 5)
|
||||
setTableCell(formatNum(rx[i]), "servers_table", i, 6)
|
||||
setTableCell(instances[i], "servers_table", i, 7)
|
||||
}
|
||||
}
|
||||
}).error(function (xhr, textStatus, errorThrown) {
|
||||
$("#scripterror").show()
|
||||
$("#scripterror").html(xhr.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
//Adding $.delete and $.put functions
|
||||
jQuery.each( [ "put", "delete" ], function( i, method ) {
|
||||
jQuery[ method ] = function( url, data, callback, type ) {
|
||||
if ( jQuery.isFunction( data ) ) {
|
||||
type = type || callback;
|
||||
callback = data;
|
||||
data = undefined;
|
||||
}
|
||||
|
||||
return jQuery.ajax({
|
||||
url: url,
|
||||
type: method,
|
||||
dataType: type,
|
||||
data: data,
|
||||
success: callback
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
function getInstances() {
|
||||
$.get(base + 'info', function (data) {
|
||||
var table = $("#instances_table")
|
||||
clear(table)
|
||||
var info = data["info"]["active_instances"]
|
||||
|
||||
$.each(info, function(key, value) {
|
||||
//Compact display
|
||||
for (var k in value["statistics"]) {
|
||||
var cur = value["statistics"][k]
|
||||
value["statistics"][k] = formatNum(value["statistics"][k], false)
|
||||
}
|
||||
//Save columns
|
||||
if (value["camera_geometry"] != undefined) {
|
||||
value["statistics"]["geometry"] = value["camera_geometry"]
|
||||
}
|
||||
if (value["read_only"] != undefined) {
|
||||
value["statistics"]["read_only"] = value["read_only"]
|
||||
}
|
||||
value["statistics"]["active"] = value["is_stream_active"]
|
||||
value["statistics"]["camera"] = value["camera_name"]
|
||||
value["statistics"]["start"] = dateToStr(value["last_start_time"])
|
||||
|
||||
var statistics = dictToStr(value["statistics"])
|
||||
var config = dictToStr(value["config"])
|
||||
//var date = dateToStr(value["last_start_time"])
|
||||
|
||||
var instance = {}
|
||||
instance["name"] = key
|
||||
instance["host"] = value["host"]
|
||||
instance["stream"] = value["stream_address"]
|
||||
instance = dictToStr(instance)
|
||||
|
||||
var row = appendTableRow(table, [
|
||||
//key,
|
||||
//value["host"],
|
||||
//value["stream_address"],
|
||||
instance,
|
||||
//value["is_stream_active"],
|
||||
//value["camera_name"],
|
||||
//JSON.stringify(value["camera_geometry"]),
|
||||
//date,
|
||||
statistics,
|
||||
|
||||
config,
|
||||
]
|
||||
)
|
||||
var callback = 'onclick="deleteInstance(\'' + key + '\')"'
|
||||
row.append($('<td align="center"><button ' + callback + '>Stop</button></td>'))
|
||||
//row.append($('<button ' + callback + '/>').html("Stop"));
|
||||
});
|
||||
|
||||
|
||||
}).error(function (xhr, textStatus, errorThrown) {
|
||||
$("#scripterror").show()
|
||||
$("#scripterror").text(xhr.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function update() {
|
||||
getServers()
|
||||
getInstances()
|
||||
}
|
||||
|
||||
function timer() {
|
||||
if ($("#servers").is(":visible")) {
|
||||
update();
|
||||
}
|
||||
window.setTimeout(
|
||||
"timer()",
|
||||
2000
|
||||
);
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
//$("#scripterror").hide()
|
||||
//update()
|
||||
timer()
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<div id="msgid">
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<section>
|
||||
<h1>
|
||||
Servers <input type="button" value="Manager Logs" style="float: right;" onclick="window.open('/api/v1/logs/txt')" />
|
||||
</h1>
|
||||
|
||||
<div id="servers">
|
||||
<table id="servers_table" border="1" width="100%" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20%">Host</th>
|
||||
<th width="3%">Ver</th>
|
||||
<th width="1%">Load</th>
|
||||
<th width="1%">CPU</th>
|
||||
<th width="1%">Mem</th>
|
||||
<th width="1%">TX</th>
|
||||
<th width="1%">RX</th>
|
||||
<th width="70%">Active Instances</th>
|
||||
<th width="1%">Logs</th>
|
||||
<th width="1%">Stop</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="servers_table_rows">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<p><br>
|
||||
<section>
|
||||
<h1>
|
||||
Instances
|
||||
</h1>
|
||||
<div id="instances">
|
||||
<table id="instances_table" border="1" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="33%">Instance</th>
|
||||
<!--<th>Host</th>-->
|
||||
<!--<th>Stream Address</th>-->
|
||||
<!--<th>Active</th>-->
|
||||
<!--<th>Camera</th>-->
|
||||
<!--<th>Geometry</th>-->
|
||||
<!--<th>Start</th>-->
|
||||
<th width="33%">Info</th>
|
||||
<th width="33%">Config</th>
|
||||
<th width="1%">Stop</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="instances_table_rows">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<p><br>
|
||||
<section>
|
||||
<div id="scripterror" style="color:red">
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -0,0 +1,369 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Server Management</title>
|
||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
var base = 'api/v1/proxy/';
|
||||
|
||||
function appendTableRow(table, rowData) {
|
||||
var lastRow = $('<tr/>').appendTo(table.find('tbody:last'));
|
||||
$.each(rowData, function(colIndex, c) {
|
||||
lastRow.append($('<td/>').html(c));
|
||||
});
|
||||
|
||||
return lastRow;
|
||||
}
|
||||
|
||||
function setTableCell(value, tableName, row, col) {
|
||||
var cell = $('#' + tableName + ' tbody tr:eq(' + row + ') td:eq(' + col + ')')[0]
|
||||
cell.innerHTML = value
|
||||
}
|
||||
|
||||
|
||||
function getRows(table){
|
||||
var rows = table.find('tbody').find('tr').length
|
||||
return rows
|
||||
}
|
||||
|
||||
function clear(table){
|
||||
//return $('#servers_table tr').length -1;
|
||||
table.find("tbody").empty()
|
||||
}
|
||||
|
||||
function isDict(v) {
|
||||
return typeof v==='object' && v!==null && !(v instanceof Array) && !(v instanceof Date);
|
||||
}
|
||||
|
||||
function isArray(v) {
|
||||
return (v instanceof Array)
|
||||
}
|
||||
|
||||
function dictToStr(dict, indent){
|
||||
var nested = true
|
||||
var ret = ""
|
||||
if (indent == undefined ){
|
||||
indent = "";
|
||||
ret = "<font size='2'><pre>"
|
||||
nested = false
|
||||
}
|
||||
|
||||
for (var key in dict) {
|
||||
var value = dict[key]
|
||||
if (isDict (value)){
|
||||
ret = ret + key + ":" + "\n"
|
||||
ret = ret + (dictToStr(value, /*"\t"*/ " "))
|
||||
} else {
|
||||
ret = ret + indent + key + ": " + /*JSON.stringify*/(value) + "\n"
|
||||
}
|
||||
}
|
||||
if (!nested){
|
||||
ret = ret+"</pre></font>"
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
function listToStr(lst, multiline, indent) {
|
||||
if (indent == undefined) {
|
||||
indent = "";
|
||||
}
|
||||
var separator = ', '
|
||||
var ret = ""
|
||||
if (multiline) {
|
||||
ret = "<font size='2'><pre>"
|
||||
separator = "\n"
|
||||
}
|
||||
if (isArray(lst)) {
|
||||
for (var i = 0; i < lst.length; i++) {
|
||||
ret = ret + indent + lst[i]
|
||||
if (i< lst.length-1) {
|
||||
ret = ret + separator
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ret = ret + indent + lst + separator
|
||||
}
|
||||
if (multiline) {
|
||||
ret = ret+"</pre></font>"
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
function dateToStr(date){
|
||||
//ret = "<pre>"
|
||||
//ret = ret + date.split(" ").join("\n")x
|
||||
//ret = ret+"</pre>"
|
||||
|
||||
//return date.split(" ").join("\n\t")
|
||||
|
||||
return date.split(" ").slice(0,2).join(" ")
|
||||
}
|
||||
|
||||
|
||||
function formatNum(n, force_decimals){
|
||||
if (force_decimals == undefined) {
|
||||
force_decimals = true
|
||||
}
|
||||
if (n) {
|
||||
if (n >= 1e12) {
|
||||
return (n / 1e12).toFixed(2) + "T"
|
||||
} else if (n >= 1e9) {
|
||||
return (n / 1e9).toFixed(2) + "G"
|
||||
} else if (n >= 1e6) {
|
||||
return (n / 1e6).toFixed(2) + "M"
|
||||
} else if (n >= 1e3) {
|
||||
return (n / 1e3).toFixed(2) + "K"
|
||||
} else if (!Number.isInteger(n) || force_decimals) {
|
||||
return (n).toFixed(2)
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
function deleteInstance(key){
|
||||
$.delete(base + key).error(function (xhr, textStatus, errorThrown) {
|
||||
$("#scripterror").show()
|
||||
$("#scripterror").html(xhr.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
function deleteAllInstances(server_index){
|
||||
$.delete(base + "server/" + server_index).error(function (xhr, textStatus, errorThrown) {
|
||||
$("#scripterror").show()
|
||||
$("#scripterror").html(xhr.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
function showLogs(server){
|
||||
window.open(server + "/api/v1/logs/txt");
|
||||
}
|
||||
|
||||
|
||||
function getServers() {
|
||||
$.get(base + 'servers', function (data) {
|
||||
var version = data["version"]
|
||||
var servers = data["servers"]
|
||||
var load = data["load"]
|
||||
var cpu = data["cpu"]
|
||||
var memory = data["memory"]
|
||||
var tx = data["tx"]
|
||||
var rx = data["rx"]
|
||||
var instances = data["instances"]
|
||||
var table = $("#servers_table")
|
||||
|
||||
for (var i = 0; i < servers.length; i++) {
|
||||
instances[i] = listToStr(instances[i], false)
|
||||
if (load[i] >=1000) {
|
||||
load[i] = "off"
|
||||
}
|
||||
if (getRows(table) <= i){
|
||||
var row = appendTableRow(table, [servers[i], version[i], load[i],
|
||||
formatNum(cpu[i]), formatNum(memory[i]), formatNum(tx[i]), formatNum(rx[i]), instances[i]])
|
||||
var callback = 'onclick="showLogs(\'' + servers[i]+ '\')"'
|
||||
row.append($('<td align="center"><button ' + callback + '>Logs</button></td>'))
|
||||
var callback = 'onclick="deleteAllInstances(\'' + i + '\')"'
|
||||
row.append($('<td align="center"><button ' + callback + '>Stop</button></td>'))
|
||||
} else {
|
||||
|
||||
setTableCell(servers[i] , "servers_table", i, 0)
|
||||
setTableCell(version[i] , "servers_table", i, 1)
|
||||
setTableCell(load[i], "servers_table", i, 2)
|
||||
setTableCell(formatNum(cpu[i]), "servers_table", i, 3)
|
||||
setTableCell(formatNum(memory[i]), "servers_table", i, 4)
|
||||
setTableCell(formatNum(tx[i]), "servers_table", i, 5)
|
||||
setTableCell(formatNum(rx[i]), "servers_table", i, 6)
|
||||
setTableCell(instances[i], "servers_table", i, 7)
|
||||
}
|
||||
}
|
||||
}).error(function (xhr, textStatus, errorThrown) {
|
||||
$("#scripterror").show()
|
||||
$("#scripterror").html(xhr.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
//Adding $.delete and $.put functions
|
||||
jQuery.each( [ "put", "delete" ], function( i, method ) {
|
||||
jQuery[ method ] = function( url, data, callback, type ) {
|
||||
if ( jQuery.isFunction( data ) ) {
|
||||
type = type || callback;
|
||||
callback = data;
|
||||
data = undefined;
|
||||
}
|
||||
|
||||
return jQuery.ajax({
|
||||
url: url,
|
||||
type: method,
|
||||
dataType: type,
|
||||
data: data,
|
||||
success: callback
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
function getInstances() {
|
||||
$.get(base + 'info', function (data) {
|
||||
var table = $("#instances_table")
|
||||
clear(table)
|
||||
var info = data["info"]["active_instances"]
|
||||
|
||||
$.each(info, function(key, value) {
|
||||
//Compact display
|
||||
for (var k in value["statistics"]) {
|
||||
var cur = value["statistics"][k]
|
||||
if(typeof cur == 'number'){
|
||||
value["statistics"][k] = formatNum(cur, false)
|
||||
}
|
||||
}
|
||||
//Save columns
|
||||
if (value["camera_geometry"] != undefined) {
|
||||
value["statistics"]["geometry"] = value["camera_geometry"]
|
||||
}
|
||||
if (value["read_only"] != undefined) {
|
||||
value["statistics"]["read_only"] = value["read_only"]
|
||||
}
|
||||
value["statistics"]["active"] = value["is_stream_active"]
|
||||
value["statistics"]["camera"] = value["camera_name"]
|
||||
value["statistics"]["start"] = dateToStr(value["last_start_time"])
|
||||
|
||||
var statistics = dictToStr(value["statistics"])
|
||||
var config = dictToStr(value["config"])
|
||||
//var date = dateToStr(value["last_start_time"])
|
||||
|
||||
var instance = {}
|
||||
instance["name"] = key
|
||||
instance["host"] = value["host"]
|
||||
instance["stream"] = value["stream_address"]
|
||||
instance = dictToStr(instance)
|
||||
|
||||
var row = appendTableRow(table, [
|
||||
//key,
|
||||
//value["host"],
|
||||
//value["stream_address"],
|
||||
instance,
|
||||
//value["is_stream_active"],
|
||||
//value["camera_name"],
|
||||
//JSON.stringify(value["camera_geometry"]),
|
||||
//date,
|
||||
statistics,
|
||||
|
||||
config,
|
||||
]
|
||||
)
|
||||
var callback = 'onclick="deleteInstance(\'' + key + '\')"'
|
||||
row.append($('<td align="center"><button ' + callback + '>Stop</button></td>'))
|
||||
//row.append($('<button ' + callback + '/>').html("Stop"));
|
||||
});
|
||||
|
||||
|
||||
}).error(function (xhr, textStatus, errorThrown) {
|
||||
$("#scripterror").show()
|
||||
$("#scripterror").text(xhr.responseText)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function update() {
|
||||
getServers()
|
||||
getInstances()
|
||||
}
|
||||
|
||||
function timer() {
|
||||
if ($("#servers").is(":visible")) {
|
||||
update();
|
||||
}
|
||||
window.setTimeout(
|
||||
"timer()",
|
||||
2000
|
||||
);
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
//$("#scripterror").hide()
|
||||
//update()
|
||||
timer()
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<div id="msgid">
|
||||
</div>
|
||||
|
||||
<p>
|
||||
<section>
|
||||
<h1>
|
||||
Servers <input type="button" value="Manager Logs" style="float: right;" onclick="window.open('/api/v1/logs/txt')" />
|
||||
</h1>
|
||||
|
||||
<div id="servers">
|
||||
<table id="servers_table" border="1" width="100%" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="20%">Host</th>
|
||||
<th width="3%">Ver</th>
|
||||
<th width="1%">Load</th>
|
||||
<th width="1%">CPU</th>
|
||||
<th width="1%">Mem</th>
|
||||
<th width="1%">TX</th>
|
||||
<th width="1%">RX</th>
|
||||
<th width="70%">Active Instances</th>
|
||||
<th width="1%">Logs</th>
|
||||
<th width="1%">Stop</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="servers_table_rows">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<p><br>
|
||||
<section>
|
||||
<h1>
|
||||
Instances
|
||||
</h1>
|
||||
<div id="instances">
|
||||
<table id="instances_table" border="1" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="33%">Instance</th>
|
||||
<!--<th>Host</th>-->
|
||||
<!--<th>Stream Address</th>-->
|
||||
<!--<th>Active</th>-->
|
||||
<!--<th>Camera</th>-->
|
||||
<!--<th>Geometry</th>-->
|
||||
<!--<th>Start</th>-->
|
||||
<th width="33%">Info</th>
|
||||
<th width="33%">Config</th>
|
||||
<th width="1%">Stop</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="instances_table_rows">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<p><br>
|
||||
<section>
|
||||
<div id="scripterror" style="color:red">
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user