1713 lines
71 KiB
Plaintext
1713 lines
71 KiB
Plaintext
{
|
|
"custom": {
|
|
"delay": 2000,
|
|
"update": 2000
|
|
},
|
|
"params": {},
|
|
"propConfig": {
|
|
"custom.delay": {
|
|
"persistent": true
|
|
},
|
|
"custom.update": {
|
|
"persistent": true
|
|
}
|
|
},
|
|
"props": {
|
|
"defaultSize": {
|
|
"height": 1080,
|
|
"width": 1920
|
|
}
|
|
},
|
|
"root": {
|
|
"children": [
|
|
{
|
|
"children": [
|
|
{
|
|
"children": [
|
|
{
|
|
"meta": {
|
|
"name": "Label"
|
|
},
|
|
"position": {
|
|
"basis": "10px"
|
|
},
|
|
"props": {
|
|
"style": {
|
|
"classes": "Text-Styles/Ariel-Bold-White-12pt",
|
|
"fontSize": 20,
|
|
"textAlign": "center"
|
|
}
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_0"
|
|
},
|
|
"position": {
|
|
"basis": "800px"
|
|
},
|
|
"props": {
|
|
"style": {
|
|
"classes": "Labels/Label"
|
|
},
|
|
"text": "Import/Add Device"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_2"
|
|
},
|
|
"position": {
|
|
"basis": "145px"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_1"
|
|
},
|
|
"position": {
|
|
"basis": "800px"
|
|
},
|
|
"props": {
|
|
"style": {
|
|
"classes": "Labels/Label"
|
|
},
|
|
"text": "Export/Remove Device"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_4"
|
|
},
|
|
"position": {
|
|
"basis": "10px",
|
|
"grow": 1
|
|
},
|
|
"type": "ia.display.label"
|
|
}
|
|
],
|
|
"meta": {
|
|
"name": "FlexContainer_0"
|
|
},
|
|
"position": {
|
|
"basis": "32px",
|
|
"grow": 1,
|
|
"shrink": 0
|
|
},
|
|
"type": "ia.container.flex"
|
|
},
|
|
{
|
|
"children": [
|
|
{
|
|
"meta": {
|
|
"name": "Label_0"
|
|
},
|
|
"position": {
|
|
"basis": "10px"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"events": {
|
|
"component": {
|
|
"onEditCellCommit": {
|
|
"config": {
|
|
"script": "\t\n\t\n\tdef get_headers_index(headers,col):\n\t for i,value in enumerate(headers):\n\t if value \u003d\u003d col:\n\t\t \treturn i\n\t\n\t\n\tdata \u003d self.props.data\n\theaders \u003d system.dataset.getColumnHeaders(data)\n\tcol \u003d event.column\n\trow \u003d event.rowIndex\n\tvalue \u003d event.value\n\tcol_index \u003d get_headers_index(headers,col)\n\tself.props.data \u003d system.dataset.setValue(data, row, col_index, value)\n\t\n\t"
|
|
},
|
|
"scope": "G",
|
|
"type": "script"
|
|
}
|
|
}
|
|
},
|
|
"meta": {
|
|
"name": "AddTable"
|
|
},
|
|
"position": {
|
|
"basis": "800px"
|
|
},
|
|
"propConfig": {
|
|
"props.data": {
|
|
"onChange": {
|
|
"enabled": null,
|
|
"script": "\tpayload \u003d self.props.data\n\tsystem.perspective.sendMessage(\"addtable-data-update\", payload \u003d payload , scope \u003d \"view\")"
|
|
}
|
|
},
|
|
"props.selection.selectedRow": {
|
|
"onChange": {
|
|
"enabled": null,
|
|
"script": "\tif currentValue.value is not None:\n\t\tpayload \u003d currentValue.value\t\n\telse:\n\t\tpayload \u003d -1\n\tsystem.perspective.sendMessage(\"addtable-selection-update\", payload \u003d payload , scope \u003d \"view\")"
|
|
}
|
|
}
|
|
},
|
|
"props": {
|
|
"columns": [
|
|
{
|
|
"align": "center",
|
|
"boolean": "checkbox",
|
|
"dateFormat": "MM/DD/YYYY",
|
|
"editable": true,
|
|
"field": "Device Name",
|
|
"footer": {
|
|
"align": "center",
|
|
"justify": "left",
|
|
"style": {
|
|
"classes": ""
|
|
},
|
|
"title": ""
|
|
},
|
|
"header": {
|
|
"align": "center",
|
|
"justify": "left",
|
|
"style": {
|
|
"classes": ""
|
|
},
|
|
"title": ""
|
|
},
|
|
"justify": "auto",
|
|
"number": "value",
|
|
"numberFormat": "0,0.##",
|
|
"progressBar": {
|
|
"bar": {
|
|
"color": "",
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
},
|
|
"max": 100,
|
|
"min": 0,
|
|
"track": {
|
|
"color": "",
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
},
|
|
"value": {
|
|
"enabled": true,
|
|
"format": "0,0.##",
|
|
"justify": "center",
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
}
|
|
},
|
|
"render": "auto",
|
|
"resizable": true,
|
|
"sort": "none",
|
|
"sortable": true,
|
|
"strictWidth": false,
|
|
"style": {
|
|
"classes": ""
|
|
},
|
|
"toggleSwitch": {
|
|
"color": {
|
|
"selected": "",
|
|
"unselected": ""
|
|
}
|
|
},
|
|
"viewParams": {},
|
|
"viewPath": "",
|
|
"visible": true,
|
|
"width": ""
|
|
},
|
|
{
|
|
"align": "center",
|
|
"boolean": "checkbox",
|
|
"dateFormat": "MM/DD/YYYY",
|
|
"editable": true,
|
|
"field": "Hostname",
|
|
"footer": {
|
|
"align": "center",
|
|
"justify": "left",
|
|
"style": {
|
|
"classes": ""
|
|
},
|
|
"title": ""
|
|
},
|
|
"header": {
|
|
"align": "center",
|
|
"justify": "left",
|
|
"style": {
|
|
"classes": ""
|
|
},
|
|
"title": ""
|
|
},
|
|
"justify": "auto",
|
|
"number": "value",
|
|
"numberFormat": "0,0.##",
|
|
"progressBar": {
|
|
"bar": {
|
|
"color": "",
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
},
|
|
"max": 100,
|
|
"min": 0,
|
|
"track": {
|
|
"color": "",
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
},
|
|
"value": {
|
|
"enabled": true,
|
|
"format": "0,0.##",
|
|
"justify": "center",
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
}
|
|
},
|
|
"render": "auto",
|
|
"resizable": true,
|
|
"sort": "none",
|
|
"sortable": true,
|
|
"strictWidth": false,
|
|
"style": {
|
|
"classes": ""
|
|
},
|
|
"toggleSwitch": {
|
|
"color": {
|
|
"selected": "",
|
|
"unselected": ""
|
|
}
|
|
},
|
|
"viewParams": {},
|
|
"viewPath": "",
|
|
"visible": true,
|
|
"width": ""
|
|
},
|
|
{
|
|
"align": "center",
|
|
"boolean": "checkbox",
|
|
"dateFormat": "MM/DD/YYYY",
|
|
"editable": true,
|
|
"field": "Driver",
|
|
"footer": {
|
|
"align": "center",
|
|
"justify": "left",
|
|
"style": {
|
|
"classes": ""
|
|
},
|
|
"title": ""
|
|
},
|
|
"header": {
|
|
"align": "center",
|
|
"justify": "left",
|
|
"style": {
|
|
"classes": ""
|
|
},
|
|
"title": ""
|
|
},
|
|
"justify": "auto",
|
|
"number": "value",
|
|
"numberFormat": "0,0.##",
|
|
"progressBar": {
|
|
"bar": {
|
|
"color": "",
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
},
|
|
"max": 100,
|
|
"min": 0,
|
|
"track": {
|
|
"color": "",
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
},
|
|
"value": {
|
|
"enabled": true,
|
|
"format": "0,0.##",
|
|
"justify": "center",
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
}
|
|
},
|
|
"render": "view",
|
|
"resizable": true,
|
|
"sort": "none",
|
|
"sortable": true,
|
|
"strictWidth": false,
|
|
"style": {
|
|
"classes": ""
|
|
},
|
|
"toggleSwitch": {
|
|
"color": {
|
|
"selected": "",
|
|
"unselected": ""
|
|
}
|
|
},
|
|
"viewParams": {},
|
|
"viewPath": "Main-Views/Device-Manager/DriverDropDown",
|
|
"visible": true,
|
|
"width": ""
|
|
}
|
|
],
|
|
"data": {
|
|
"$": [
|
|
"ds",
|
|
192,
|
|
1638525899295
|
|
],
|
|
"$columns": [
|
|
{
|
|
"data": [
|
|
"IEC_Test"
|
|
],
|
|
"name": "Device Name",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"data": [
|
|
"lsdcknsncls"
|
|
],
|
|
"name": "Hostname",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"data": [
|
|
"S7300"
|
|
],
|
|
"name": "Driver",
|
|
"type": "String"
|
|
}
|
|
]
|
|
},
|
|
"rows": {
|
|
"subviewExpansionMode": "single"
|
|
},
|
|
"selection": {
|
|
"data": [
|
|
{
|
|
"Driver": "S7300"
|
|
}
|
|
],
|
|
"enableColumnSelection": true,
|
|
"selectedColumn": "Driver",
|
|
"selectedRow": 0
|
|
}
|
|
},
|
|
"scripts": {
|
|
"customMethods": [],
|
|
"extensionFunctions": null,
|
|
"messageHandlers": [
|
|
{
|
|
"messageType": "update-addtable-data",
|
|
"pageScope": false,
|
|
"script": "\tself.props.data \u003d payload",
|
|
"sessionScope": false,
|
|
"viewScope": true
|
|
},
|
|
{
|
|
"messageType": "update-addtable-selectedrow",
|
|
"pageScope": false,
|
|
"script": "\tif payload \u003d\u003d -1:\n\t\tself.props.selection.selectedRow \u003d None",
|
|
"sessionScope": false,
|
|
"viewScope": true
|
|
},
|
|
{
|
|
"messageType": "addtable-dropdown-updaterow",
|
|
"pageScope": true,
|
|
"script": "\t#newData \u003d []\n\tsystem.perspective.print(\"DropDownMessage\")\n\thostname \u003d str(payload[\u0027Hostname\u0027])\n\tvalue \u003d payload[\u0027value\u0027]\n\tdata \u003d system.dataset.toPyDataSet(self.props.data)\n\tnewData \u003d data\n\tupdate \u003d False \n\tfor row in range(data.getRowCount()):\n\t\tsystem.perspective.print(\"Looping\")\n\t\tif data[row][\u0027Hostname\u0027] \u003d\u003d hostname:\n\t\t\tsystem.perspective.print(\"New Data\")\n\t\t\tnewData \u003d system.dataset.updateRow(data , row , {\"Driver\": value})\n\t\t\tbreak\n\t\t\n\tself.props.data \u003d newData\n",
|
|
"sessionScope": false,
|
|
"viewScope": true
|
|
}
|
|
]
|
|
},
|
|
"type": "ia.display.table"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_3"
|
|
},
|
|
"position": {
|
|
"basis": "10px"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"children": [
|
|
{
|
|
"custom": {
|
|
"file_data": ""
|
|
},
|
|
"events": {
|
|
"component": {
|
|
"onFileReceived": {
|
|
"config": {
|
|
"script": "\tsystem.perspective.print(\"uploading\")\n\tself.custom.file_data \u003d event.file.getString()\n\t\n\n"
|
|
},
|
|
"scope": "G",
|
|
"type": "script"
|
|
}
|
|
}
|
|
},
|
|
"meta": {
|
|
"name": "FileUpload"
|
|
},
|
|
"position": {
|
|
"basis": "30px",
|
|
"shrink": 0
|
|
},
|
|
"propConfig": {
|
|
"custom.file_data": {
|
|
"onChange": {
|
|
"enabled": null,
|
|
"script": "\tif currentValue.value :\n\t\ttmp \u003d currentValue.value.replace(\"\\n\", \",\").replace(\u0027\"\u0027, \u0027\u0027)\n\t\t\n\t\tdata \u003d tmp.split(\",\")\n\t\theaders \u003d data[0:3]\n\t\tvalues \u003d []\n\t\tprint(headers)\n\t\n\t\tfor i in range(0,(len(data)-3),3):\n\t\t\tif i \u003d\u003d 0:\n\t\t\t\tpass\n\t\t\telse:\n\t\t\t\tvalue \u003d [data[i] , data[i+1] , data[i+2]]\n\t\t\t\t#value \u003d {\"Device name\":data[i] , \"Hostname\": data[i+1], \"Driver\":data[i+2]}\n\t\t\t\tprint(len(value))\n\t\t\t\tvalues.append(value)\n\t\t\n\t\n\t\tnew_data \u003d system.dataset.toDataSet(headers,values)\n\t\t#new_data \u003d values\n\t\tsystem.perspective.sendMessage(\"update-addtable-data\", payload \u003d new_data, scope \u003d \"view\")\n\t\tself.custom.file_data \u003d \"\""
|
|
}
|
|
}
|
|
},
|
|
"props": {
|
|
"fileUploadIcon": {
|
|
"color": "#000000",
|
|
"name": "Import"
|
|
},
|
|
"style": {
|
|
"backgroundColor": "#BAB6B6",
|
|
"classes": ""
|
|
},
|
|
"supportedFileTypes": [
|
|
"csv"
|
|
]
|
|
},
|
|
"type": "ia.input.fileupload"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_0"
|
|
},
|
|
"position": {
|
|
"basis": "10px"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"custom": {
|
|
"AddTableData": {
|
|
"$": [
|
|
"ds",
|
|
192,
|
|
1638525899295
|
|
],
|
|
"$columns": [
|
|
{
|
|
"data": [
|
|
"IEC_Test"
|
|
],
|
|
"name": "Device Name",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"data": [
|
|
"lsdcknsncls"
|
|
],
|
|
"name": "Hostname",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"data": [
|
|
"S7300"
|
|
],
|
|
"name": "Driver",
|
|
"type": "String"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"events": {
|
|
"component": {
|
|
"onActionPerformed": {
|
|
"config": {
|
|
"script": "\tdata \u003d self.custom.AddTableData\n\tpayload \u003d system.dataset.addRow(data,[\"\",\"\",\"\"])\n\tsystem.perspective.sendMessage(\"update-addtable-data\", payload\u003dpayload, scope\u003d\"view\")"
|
|
},
|
|
"scope": "G",
|
|
"type": "script"
|
|
}
|
|
}
|
|
},
|
|
"meta": {
|
|
"name": "Button_0"
|
|
},
|
|
"position": {
|
|
"basis": "30px",
|
|
"shrink": 0
|
|
},
|
|
"props": {
|
|
"image": {
|
|
"icon": {
|
|
"path": "material/add"
|
|
}
|
|
},
|
|
"style": {
|
|
"classes": "Buttons/PB_1"
|
|
},
|
|
"text": "Add Row"
|
|
},
|
|
"scripts": {
|
|
"customMethods": [],
|
|
"extensionFunctions": null,
|
|
"messageHandlers": [
|
|
{
|
|
"messageType": "addtable-data-update",
|
|
"pageScope": false,
|
|
"script": "\t# implement your handler here\n\tself.custom.AddTableData \u003d payload",
|
|
"sessionScope": false,
|
|
"viewScope": true
|
|
}
|
|
]
|
|
},
|
|
"type": "ia.input.button"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label"
|
|
},
|
|
"position": {
|
|
"basis": "10px"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"custom": {
|
|
"AddTableData": {
|
|
"$": [
|
|
"ds",
|
|
192,
|
|
1638525899295
|
|
],
|
|
"$columns": [
|
|
{
|
|
"data": [
|
|
"IEC_Test"
|
|
],
|
|
"name": "Device Name",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"data": [
|
|
"lsdcknsncls"
|
|
],
|
|
"name": "Hostname",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"data": [
|
|
"S7300"
|
|
],
|
|
"name": "Driver",
|
|
"type": "String"
|
|
}
|
|
]
|
|
},
|
|
"SelectedRow": 0
|
|
},
|
|
"events": {
|
|
"component": {
|
|
"onActionPerformed": {
|
|
"config": {
|
|
"script": "\trow_to_delete \u003d self.custom.SelectedRow\n\tdataset \u003d self.custom.AddTableData\n\trows \u003d dataset.getRowCount()\n\tsystem.perspective.print(\"The row is \"+ str(row_to_delete))\n\tsystem.perspective.print(\"The number of row(s) is \"+ str(rows))\n\tif row_to_delete is not None:\n\t\tif row_to_delete or (row_to_delete \u003d\u003d 0 and rows \u003e 1):\n\t\t\tsystem.perspective.print(\"Deleting \"+ str(row_to_delete))\n\t\t\tpayload \u003d system.dataset.deleteRow(dataset,row_to_delete)\n\t\telif row_to_delete \u003d\u003d 0 and rows \u003d\u003d 1:\n\t\t\tsystem.perspective.print(\"Deleting \"+ str(row_to_delete))\n\t\t\tpayload \u003d system.dataset.updateRow(dataset,row_to_delete,{\"Device Name\":\"\",\"Hostname\":\"\",\"Driver\":\"\"}) \n\t\t\t\n\t\tsystem.perspective.sendMessage(\"update-addtable-data\", payload\u003dpayload, scope\u003d\"view\")\n\t\tsystem.perspective.sendMessage(\"update-addtable-selectedrow\", payload\u003d -1, scope\u003d\"view\")\n\t\n\t"
|
|
},
|
|
"scope": "G",
|
|
"type": "script"
|
|
}
|
|
}
|
|
},
|
|
"meta": {
|
|
"name": "Button_1"
|
|
},
|
|
"position": {
|
|
"basis": "30px",
|
|
"shrink": 0
|
|
},
|
|
"props": {
|
|
"image": {
|
|
"icon": {
|
|
"path": "material/remove"
|
|
}
|
|
},
|
|
"style": {
|
|
"classes": "Buttons/PB_1"
|
|
},
|
|
"text": "Delete Row"
|
|
},
|
|
"scripts": {
|
|
"customMethods": [],
|
|
"extensionFunctions": null,
|
|
"messageHandlers": [
|
|
{
|
|
"messageType": "addtable-data-update",
|
|
"pageScope": false,
|
|
"script": "\tself.custom.AddTableData \u003d payload",
|
|
"sessionScope": false,
|
|
"viewScope": true
|
|
},
|
|
{
|
|
"messageType": "addtable-selection-update",
|
|
"pageScope": false,
|
|
"script": "\tsystem.perspective.print(payload)\n\tif payload \u003d\u003d -1:\n\t\tself.custom.SelectedRow \u003d None\t\n\telse:\n\t\tself.custom.SelectedRow \u003d payload",
|
|
"sessionScope": false,
|
|
"viewScope": true
|
|
}
|
|
]
|
|
},
|
|
"type": "ia.input.button"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_1"
|
|
},
|
|
"position": {
|
|
"basis": "10px"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"custom": {
|
|
"AddTableData": {
|
|
"$": [
|
|
"ds",
|
|
192,
|
|
1638525899295
|
|
],
|
|
"$columns": [
|
|
{
|
|
"data": [
|
|
"IEC_Test"
|
|
],
|
|
"name": "Device Name",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"data": [
|
|
"lsdcknsncls"
|
|
],
|
|
"name": "Hostname",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"data": [
|
|
"S7300"
|
|
],
|
|
"name": "Driver",
|
|
"type": "String"
|
|
}
|
|
]
|
|
},
|
|
"Drivers": "{\"S7300\":\"\",\"S7400\":\"\",\"S71200\":\"\",\"S71500\":\"S7\", \"CompactLogix\":\"\",\"Legacy Allen-Bradley\":\"\",\"ControlLogix\":\"\", \"LogixDriver\":\"\",\"MicroLogix\":\"\"} "
|
|
},
|
|
"events": {
|
|
"component": {
|
|
"onActionPerformed": {
|
|
"config": {
|
|
"script": "\timport sys\n\timport re\n\tfrom java.lang import Exception\n\t\n\tdef drivers():\n\t\tdrivers_dict \u003d self.custom.Drivers\n\t\tdrivers_decode \u003d system.util.jsonDecode(drivers_dict)\n\t\treturn drivers_decode\n\t\n\tdef decode(tagPath):\n\t device_cfg \u003d system.tag.read(tagPath).value\n\t device_decode \u003d system.util.jsonDecode(device_cfg)\n\t return device_decode\n\t\n\t\n\tdef update_add_devices(device_list,drivers):\n\t\tfc \u003d system.tag.read(\"Configuration/FC\").value\n\t\tprefix \u003d fc\t\n\t\tdevices_data \u003d self.custom.AddTableData\n\t\tpy_devices \u003d system.dataset.toPyDataSet(devices_data)\n\t\tcurrent_device_list \u003d device_list.get(\"Devicestatus\",\"\")\n\t\tdevices_to_check \u003d [i for i in current_device_list]\n\t\tdevices_to_add \u003d {}\n\t\terror\u003d[]\n\t\tif py_devices:\n\t\t\tfor i,j in enumerate(py_devices):\n\t\t\t\trow \u003d[]\n\t\t\t\tname \u003d j[0]\n\t\t\t\thostname \u003d j[1]\n\t\t\t\tdriver \u003d j[2]\n\t\t\t\tsystem.perspective.print(drivers.get(j[2]))\t\n\t\t\t\tcheck_driver \u003d drivers.get(j[2],\"False\")\n\t\t\t\tif name.startswith(prefix):\n\t\t\t\t\tif name not in devices_to_check:\n\t\t\t\t\t\tif j[0] and j[1] and check_driver !\u003d \"False\":\n\t\t\t\t\t\t\trow.append(hostname)\n\t\t\t\t\t\t\trow.append(driver)\n\t\t\t\t\t\t\tdevices_to_add[name] \u003d row\n\t\t\t\t\t\telse:\n\t\t\t\t\t\t\terror.append(i)\n\t\t\t\t\telse:\n\t\t\t\t\t system.perspective.print(\"Device already exists: %s\" % (name))\n\t\t\t\t\t message \u003d {\"labelText\":\"Device already exists: %s\" % (name),\"acceptPB\":\"Ok\", \"cancelPB\":\"hide\",\"iconPath\":\"material/error\" }\n\t\t\t\t\t system.perspective.openPopup(\"Exists\",\u0027PopUp-Views/UserInfo\u0027, params \u003d {\u0027Message\u0027:message})\n\t\t\t\telse:\n\t\t\t\t\t system.perspective.print(\"Use the correct prefix: %s\" % (fc))\n\t\t\t\t\t message \u003d {\"labelText\":\"Use the correct prefix: %s\" % (fc),\"acceptPB\":\"Ok\", \"cancelPB\":\"hide\",\"iconPath\":\"material/error\" }\n\t\t\t\t\t system.perspective.openPopup(\"Exists\",\u0027PopUp-Views/UserInfo\u0027, params \u003d {\u0027Message\u0027:message})\n\t\t#\tdisplay_err\u003d\"\"\n\t\t#\tdisplay_err \u003d display_err.join(error)\n\t\t\tif error:\n\t\t\t\tdisplay_err \u003d str(error)\n\t\t\t\tsystem.perspective.print(\"Missing data in row: %s\" % (display_err))\n\t\t\t\tmessage \u003d {\"labelText\":\"Missing data in row: %s\" % (display_err),\"acceptPB\":\"Ok\", \"cancelPB\":\"hide\",\"iconPath\":\"material/error\" }\n\t\t\t\tsystem.perspective.openPopup(\"Exists\",\u0027PopUp-Views/UserInfo\u0027, params \u003d {\u0027Message\u0027:message})\n\t\t\tdevice_list[\"AddDevices\"] \u003d devices_to_add \n\t\t\tencode \u003d system.util.jsonEncode(device_list)\n\t\t\tsystem.tag.write(\"System/DeviceList\",encode)\n\t\n\ttry:\n\t\topc_drivers \u003d drivers()\n\t\tif system.tag.exists(\"System/DeviceStatus\"):\n\t\t\tcfg \u003d decode(\"System/DeviceStatus\")\n\t\t\tupdate_add_devices(cfg,opc_drivers)\n\texcept:\n\t exc_type, exc_obj, tb \u003d sys.exc_info()\n\t lineno \u003d tb.tb_lineno\n\t error_description\u003dstr(lineno)+\" , \"+str(exc_type)+\" , \"+str(exc_obj)\n\t system.perspective.print(error_description)"
|
|
},
|
|
"scope": "G",
|
|
"type": "script"
|
|
}
|
|
}
|
|
},
|
|
"meta": {
|
|
"name": "Button_2"
|
|
},
|
|
"position": {
|
|
"basis": "30px",
|
|
"shrink": 0
|
|
},
|
|
"props": {
|
|
"AddTableData": {
|
|
"$": [
|
|
"ds",
|
|
192,
|
|
1638376388559
|
|
],
|
|
"$columns": [
|
|
{
|
|
"data": [
|
|
"IECTest1",
|
|
"IECTest2"
|
|
],
|
|
"name": "Device Name",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"data": [
|
|
"IECTest1",
|
|
""
|
|
],
|
|
"name": "Hostname",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"data": [
|
|
"S71500",
|
|
""
|
|
],
|
|
"name": "Driver",
|
|
"type": "String"
|
|
}
|
|
]
|
|
},
|
|
"image": {
|
|
"icon": {
|
|
"path": "material/keyboard_return"
|
|
}
|
|
},
|
|
"style": {
|
|
"classes": "Buttons/PB_1"
|
|
},
|
|
"text": "Add Device"
|
|
},
|
|
"scripts": {
|
|
"customMethods": [],
|
|
"extensionFunctions": null,
|
|
"messageHandlers": [
|
|
{
|
|
"messageType": "addtable-data-update",
|
|
"pageScope": false,
|
|
"script": "\t\n\tself.custom.AddTableData \u003d payload",
|
|
"sessionScope": false,
|
|
"viewScope": true
|
|
}
|
|
]
|
|
},
|
|
"type": "ia.input.button"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_2"
|
|
},
|
|
"position": {
|
|
"basis": "10px"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"events": {
|
|
"dom": {
|
|
"onClick": {
|
|
"config": {
|
|
"script": "\theader \u003d [\"Device Name\",\"Hostname\",\"Driver\"]\n\ttable \u003d [[\"\",\"\",\"\"]]\n\tpayload \u003d system.dataset.toDataSet(header,table)\n\tsystem.perspective.sendMessage(\"update-addtable-data\", payload\u003dpayload, scope\u003d\"view\")\n\tsystem.perspective.sendMessage(\"update-addtable-selectedrow\", payload\u003d -1, scope\u003d\"view\")"
|
|
},
|
|
"scope": "G",
|
|
"type": "script"
|
|
}
|
|
}
|
|
},
|
|
"meta": {
|
|
"name": "Icon"
|
|
},
|
|
"position": {
|
|
"basis": "30px"
|
|
},
|
|
"props": {
|
|
"color": "#FFFFFF",
|
|
"path": "material/delete_forever",
|
|
"style": {
|
|
"borderBottomLeftRadius": 5,
|
|
"borderBottomRightRadius": 5,
|
|
"borderColor": "#AAAAAA",
|
|
"borderStyle": "solid",
|
|
"borderTopLeftRadius": 5,
|
|
"borderTopRightRadius": 5,
|
|
"borderWidth": 1,
|
|
"classes": "Buttons/PB_1"
|
|
}
|
|
},
|
|
"type": "ia.display.icon"
|
|
}
|
|
],
|
|
"meta": {
|
|
"name": "FlexContainer"
|
|
},
|
|
"position": {
|
|
"basis": "125px",
|
|
"shrink": 0
|
|
},
|
|
"props": {
|
|
"direction": "column"
|
|
},
|
|
"type": "ia.container.flex"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_2"
|
|
},
|
|
"position": {
|
|
"basis": "10px"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "DeleteTable"
|
|
},
|
|
"position": {
|
|
"basis": "800px"
|
|
},
|
|
"propConfig": {
|
|
"props.data": {
|
|
"onChange": {
|
|
"enabled": null,
|
|
"script": "\tpayload \u003d self.props.data\n\tsystem.perspective.sendMessage(\"deletetable-data-update\", payload \u003d payload , scope \u003d \"view\")"
|
|
}
|
|
},
|
|
"props.selection.selectedRow": {
|
|
"onChange": {
|
|
"enabled": null,
|
|
"script": "\tif currentValue.value is not None:\n\t\tpayload \u003d currentValue.value\t\n\telse:\n\t\tpayload \u003d -1\n\tsystem.perspective.sendMessage(\"deletetable-selection-update\", payload \u003d payload , scope \u003d \"view\")"
|
|
}
|
|
}
|
|
},
|
|
"props": {
|
|
"columns": [
|
|
{
|
|
"align": "center",
|
|
"boolean": "checkbox",
|
|
"dateFormat": "MM/DD/YYYY",
|
|
"editable": true,
|
|
"field": "Device Name",
|
|
"footer": {
|
|
"align": "center",
|
|
"justify": "left",
|
|
"style": {
|
|
"classes": ""
|
|
},
|
|
"title": ""
|
|
},
|
|
"header": {
|
|
"align": "center",
|
|
"justify": "left",
|
|
"style": {
|
|
"classes": ""
|
|
},
|
|
"title": ""
|
|
},
|
|
"justify": "auto",
|
|
"number": "value",
|
|
"numberFormat": "0,0.##",
|
|
"progressBar": {
|
|
"bar": {
|
|
"color": "",
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
},
|
|
"max": 100,
|
|
"min": 0,
|
|
"track": {
|
|
"color": "",
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
},
|
|
"value": {
|
|
"enabled": true,
|
|
"format": "0,0.##",
|
|
"justify": "center",
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
}
|
|
},
|
|
"render": "auto",
|
|
"resizable": true,
|
|
"sort": "none",
|
|
"sortable": true,
|
|
"strictWidth": false,
|
|
"style": {
|
|
"classes": ""
|
|
},
|
|
"toggleSwitch": {
|
|
"color": {
|
|
"selected": "",
|
|
"unselected": ""
|
|
}
|
|
},
|
|
"viewParams": {},
|
|
"viewPath": "",
|
|
"visible": true,
|
|
"width": ""
|
|
},
|
|
{
|
|
"align": "center",
|
|
"boolean": "checkbox",
|
|
"dateFormat": "MM/DD/YYYY",
|
|
"editable": true,
|
|
"field": "Hostname",
|
|
"footer": {
|
|
"align": "center",
|
|
"justify": "left",
|
|
"style": {
|
|
"classes": ""
|
|
},
|
|
"title": ""
|
|
},
|
|
"header": {
|
|
"align": "center",
|
|
"justify": "left",
|
|
"style": {
|
|
"classes": ""
|
|
},
|
|
"title": ""
|
|
},
|
|
"justify": "auto",
|
|
"number": "value",
|
|
"numberFormat": "0,0.##",
|
|
"progressBar": {
|
|
"bar": {
|
|
"color": "",
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
},
|
|
"max": 100,
|
|
"min": 0,
|
|
"track": {
|
|
"color": "",
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
},
|
|
"value": {
|
|
"enabled": true,
|
|
"format": "0,0.##",
|
|
"justify": "center",
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
}
|
|
},
|
|
"render": "auto",
|
|
"resizable": true,
|
|
"sort": "none",
|
|
"sortable": true,
|
|
"strictWidth": false,
|
|
"style": {
|
|
"classes": ""
|
|
},
|
|
"toggleSwitch": {
|
|
"color": {
|
|
"selected": "",
|
|
"unselected": ""
|
|
}
|
|
},
|
|
"viewParams": {},
|
|
"viewPath": "",
|
|
"visible": true,
|
|
"width": ""
|
|
},
|
|
{
|
|
"align": "center",
|
|
"boolean": "checkbox",
|
|
"dateFormat": "MM/DD/YYYY",
|
|
"editable": true,
|
|
"field": "Driver",
|
|
"footer": {
|
|
"align": "center",
|
|
"justify": "left",
|
|
"style": {
|
|
"classes": ""
|
|
},
|
|
"title": ""
|
|
},
|
|
"header": {
|
|
"align": "center",
|
|
"justify": "left",
|
|
"style": {
|
|
"classes": ""
|
|
},
|
|
"title": ""
|
|
},
|
|
"justify": "auto",
|
|
"number": "value",
|
|
"numberFormat": "0,0.##",
|
|
"progressBar": {
|
|
"bar": {
|
|
"color": "",
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
},
|
|
"max": 100,
|
|
"min": 0,
|
|
"track": {
|
|
"color": "",
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
},
|
|
"value": {
|
|
"enabled": true,
|
|
"format": "0,0.##",
|
|
"justify": "center",
|
|
"style": {
|
|
"classes": ""
|
|
}
|
|
}
|
|
},
|
|
"render": "auto",
|
|
"resizable": true,
|
|
"sort": "none",
|
|
"sortable": true,
|
|
"strictWidth": false,
|
|
"style": {
|
|
"classes": ""
|
|
},
|
|
"toggleSwitch": {
|
|
"color": {
|
|
"selected": "",
|
|
"unselected": ""
|
|
}
|
|
},
|
|
"viewParams": {},
|
|
"viewPath": "",
|
|
"visible": true,
|
|
"width": ""
|
|
}
|
|
],
|
|
"data": {
|
|
"$": [
|
|
"ds",
|
|
192,
|
|
1638468310855
|
|
],
|
|
"$columns": [
|
|
{
|
|
"data": [
|
|
"IEC_Test"
|
|
],
|
|
"name": "Device Name",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"data": [
|
|
"lsdcknsncls"
|
|
],
|
|
"name": "Hostname",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"data": [
|
|
"S7300"
|
|
],
|
|
"name": "Driver",
|
|
"type": "String"
|
|
}
|
|
]
|
|
},
|
|
"selection": {
|
|
"data": [
|
|
{
|
|
"Driver": "S7300"
|
|
}
|
|
],
|
|
"enableColumnSelection": true,
|
|
"selectedColumn": "Driver",
|
|
"selectedRow": 0
|
|
}
|
|
},
|
|
"scripts": {
|
|
"customMethods": [],
|
|
"extensionFunctions": null,
|
|
"messageHandlers": [
|
|
{
|
|
"messageType": "update-deletetable-data",
|
|
"pageScope": false,
|
|
"script": "\tself.props.data \u003d payload ",
|
|
"sessionScope": false,
|
|
"viewScope": true
|
|
},
|
|
{
|
|
"messageType": "update-deletetable-selectedrow",
|
|
"pageScope": false,
|
|
"script": "\tif payload \u003d\u003d -1:\n\t\tself.props.selection.selectedRow \u003d None",
|
|
"sessionScope": false,
|
|
"viewScope": true
|
|
}
|
|
]
|
|
},
|
|
"type": "ia.display.table"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_1"
|
|
},
|
|
"position": {
|
|
"basis": "10px"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"children": [
|
|
{
|
|
"events": {
|
|
"component": {
|
|
"onActionPerformed": {
|
|
"config": {
|
|
"script": "\timport sys\n\tfrom java.lang import Exception\n\t\n\tdef update_delete_table():\t\n\t\t\tprefix \u003d system.tag.read(\"Configuration/FC\").value\n\t\t\tdevices\u003d system.tag.read(\"System/DeviceStatus\").value\n\t\t\tdecode_devices\u003d system.util.jsonDecode(devices)\n\t\t\tdevice_status\u003d decode_devices.get(\"Devicestatus\",\"\")\n\t\t\ttable\u003d []\n\t\t\tif device_status:\n\t\t\t\tfor i in device_status:\n\t\t\t\t\trow \u003d[]\n\t\t\t\t\tname\u003d [i]\n\t\t\t\t\tif i.startswith(prefix):\n\t\t\t\t\t\trow\u003d device_status[i]\n\t\t\t\t\t\thostname \u003d [row[3]]\n\t\t\t\t\t\tdriver \u003d [row[2]]\n\t\t\t\t\t\tnew_row \u003d name + hostname + driver\n\t\t\t\t\t\ttable.append(new_row)\n\t\t\t\n\t\t\tif not len(table):\n\t\t\t\ttable.append([\"\",\"\",\"\"])\n\t\t\t\t\t\t\n\t\t\theader\u003d [\"Device Name\",\"Hostname\",\"Driver\"]\n\t\t\tdevice_dataset \u003d system.dataset.toDataSet(header,table)\n\t\t\tsystem.perspective.print(device_dataset)\n\t\t\tsystem.perspective.sendMessage(\"update-deletetable-data\", payload \u003d device_dataset , scope\u003d\"view\") \n\t\t\t\n#\ttry:\n\tif system.tag.exists(\"System/DeviceStatus\"):\n\t update_delete_table()\n#\texcept:\n#\t logger \u003d system.util.getLogger(\"Update_delete_table\")\n#\t exc_type, exc_obj, tb \u003d sys.exc_info()"
|
|
},
|
|
"scope": "G",
|
|
"type": "script"
|
|
}
|
|
}
|
|
},
|
|
"meta": {
|
|
"name": "Button"
|
|
},
|
|
"position": {
|
|
"basis": "30px",
|
|
"shrink": 0
|
|
},
|
|
"props": {
|
|
"image": {
|
|
"icon": {
|
|
"path": "material/update"
|
|
}
|
|
},
|
|
"style": {
|
|
"classes": "Buttons/PB_1"
|
|
},
|
|
"text": "Update"
|
|
},
|
|
"type": "ia.input.button"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_0"
|
|
},
|
|
"position": {
|
|
"basis": "10px"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"custom": {
|
|
"DeleteTableData": {
|
|
"$": [
|
|
"ds",
|
|
192,
|
|
1638468310856
|
|
],
|
|
"$columns": [
|
|
{
|
|
"data": [
|
|
"IEC_Test"
|
|
],
|
|
"name": "Device Name",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"data": [
|
|
"lsdcknsncls"
|
|
],
|
|
"name": "Hostname",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"data": [
|
|
"S7300"
|
|
],
|
|
"name": "Driver",
|
|
"type": "String"
|
|
}
|
|
]
|
|
},
|
|
"SelectedRow": 0
|
|
},
|
|
"events": {
|
|
"component": {
|
|
"onActionPerformed": {
|
|
"config": {
|
|
"script": "\timport sys\n\tfrom java.lang import Exception\n\t\n\tdef decode(tagPath):\n\t device_cfg \u003d system.tag.read(tagPath).value\n\t device_decode \u003d system.util.jsonDecode(device_cfg)\n\t return device_decode\n\t\n\t\n\tdef update_delete_devices(device_list):\n\t\trow_to_delete \u003d self.parent.parent.getChild(\u0027DeleteTable\u0027).props.selection.selectedRow\n\t\tdelete_data \u003d self.parent.parent.getChild(\u0027DeleteTable\u0027).props.data\n\t\tsystem.perspective.print(device_list)\n\t\tpy_devices \u003d system.dataset.toPyDataSet(delete_data)\n#\t\tsystem.perspective.print(py_devices)\n\t\trow \u003d[]\n\t\tif py_devices:\n\t\t\tfor i,j in enumerate(py_devices):\n\t\t\t\tif i \u003d\u003d row_to_delete:\n\t\t\t\t\tname \u003d j[0]\n\t\t\t\t\trow.append(name)\n\t\t\tdevice_list[\"Removedevices\"] \u003d row \n\t\t\tencode \u003d system.util.jsonEncode(device_list)\n\t\t\t#proceed \u003d system.gui.confirm(\"Device %s will be removed from the gateway, do you wish to proceed?\" % (name), \"Remove Device\",1)\n\t\t\t#if proceed:\n\t\t\t#system.tag.write(\"System/DeviceList\",encode)\n\t\t\tsystem.tag.writeBlocking([\"System/DeviceList\",], encode)\n\t\t\t\n#\ttry:\n\tcfg \u003d decode(\"System/DeviceList\")\n\tupdate_delete_devices(cfg)\n\t\t\n#\texcept:\n#\t logger \u003d system.util.getLogger(\"Device_Delete\")\n#\t exc_type, exc_obj, tb \u003d sys.exc_info()\n#\t lineno \u003d tb.tb_lineno\n#\t logger.error(\"Error: %s, %s, %s\" % (lineno, exc_type, exc_obj))\n#\t "
|
|
},
|
|
"scope": "G",
|
|
"type": "script"
|
|
}
|
|
}
|
|
},
|
|
"meta": {
|
|
"name": "Button_0"
|
|
},
|
|
"position": {
|
|
"basis": "30px",
|
|
"shrink": 0
|
|
},
|
|
"props": {
|
|
"image": {
|
|
"icon": {
|
|
"path": "material/remove"
|
|
}
|
|
},
|
|
"style": {
|
|
"classes": "Buttons/PB_1"
|
|
},
|
|
"text": "Remove Device"
|
|
},
|
|
"scripts": {
|
|
"customMethods": [],
|
|
"extensionFunctions": null,
|
|
"messageHandlers": [
|
|
{
|
|
"messageType": "deletetable-selection-update",
|
|
"pageScope": false,
|
|
"script": "\tif payload \u003d\u003d -1:\n\t\tself.custom.SelectedRow \u003d None\t\n\telse:\n\t\tself.custom.SelectedRow \u003d payload",
|
|
"sessionScope": false,
|
|
"viewScope": true
|
|
},
|
|
{
|
|
"messageType": "deletetable-data-update",
|
|
"pageScope": false,
|
|
"script": "\tself.custom.DeleteTableData \u003d payload",
|
|
"sessionScope": false,
|
|
"viewScope": true
|
|
}
|
|
]
|
|
},
|
|
"type": "ia.input.button"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label"
|
|
},
|
|
"position": {
|
|
"basis": "10px"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"custom": {
|
|
"DeleteTableData": {
|
|
"$": [
|
|
"ds",
|
|
192,
|
|
1638468310856
|
|
],
|
|
"$columns": [
|
|
{
|
|
"data": [
|
|
"IEC_Test"
|
|
],
|
|
"name": "Device Name",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"data": [
|
|
"lsdcknsncls"
|
|
],
|
|
"name": "Hostname",
|
|
"type": "String"
|
|
},
|
|
{
|
|
"data": [
|
|
"S7300"
|
|
],
|
|
"name": "Driver",
|
|
"type": "String"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"events": {
|
|
"dom": {
|
|
"onClick": {
|
|
"config": {
|
|
"script": "\timport sys\n\tfrom java.lang import Exception\n\t\n\tdef save_devices():\n\t\tdevices_to_save \u003d self.custom.DeleteTableData\n\t\tpy_devices \u003d system.dataset.toPyDataSet(devices_to_save)\n\t\tdevice_list \u003d []\n\t\tfor i,j in enumerate(py_devices):\n\t\t#check the required fields have data in them.\n\t\t\trow \u003d[]\n\t\t\tname \u003d j[0]\n\t\t\thostname \u003d j[1]\n\t\t\tdriver \u003d j[2]\n\t\t\trow.append(name)\n\t\t\trow.append(hostname)\n\t\t\trow.append(driver)\n\t\t\tdevice_list.append(row)\n\t\tHeader \u003d [\u0027Device Name\u0027,\u0027Hostname\u0027,\u0027Driver\u0027]\n\t\tdevice_dataset \u003d system.dataset.toDataSet(Header,device_list)\n\t\tcsv_file \u003d system.dataset.toCSV(device_dataset)\n\t\tsystem.perspective.download(filename\u003d \"myExport.csv\", data \u003d csv_file, contentType\u003d \"text/csv; charset\u003dutf-8\")\n#\t\tfilePath \u003d system.file.saveFile(\"myExport.csv\", \"csv\", \"Gateway Devices\") \n#\t\tif filePath:\n#\t\t system.file.writeFile(filePath, csv_file)\n\t\n\t\n#\ttry: \n\tsave_devices()\n#\texcept:\n#\t logger \u003d system.util.getLogger(\"save_devices\")\n#\t exc_type, exc_obj, tb \u003d sys.exc_info()\n#\t lineno \u003d tb.tb_lineno\n#\t logger.error(\"Error: %s, %s, %s\" % (lineno, exc_type, exc_obj))"
|
|
},
|
|
"scope": "G",
|
|
"type": "script"
|
|
}
|
|
}
|
|
},
|
|
"meta": {
|
|
"name": "Icon"
|
|
},
|
|
"position": {
|
|
"basis": "30px"
|
|
},
|
|
"props": {
|
|
"color": "#FFFFFF",
|
|
"path": "material/save",
|
|
"style": {
|
|
"borderBottomLeftRadius": 5,
|
|
"borderBottomRightRadius": 5,
|
|
"borderColor": "#AAAAAA",
|
|
"borderStyle": "solid",
|
|
"borderTopLeftRadius": 5,
|
|
"borderTopRightRadius": 5,
|
|
"borderWidth": 1,
|
|
"classes": "Buttons/PB_1"
|
|
}
|
|
},
|
|
"scripts": {
|
|
"customMethods": [],
|
|
"extensionFunctions": null,
|
|
"messageHandlers": [
|
|
{
|
|
"messageType": "deletetable-data-update",
|
|
"pageScope": false,
|
|
"script": "\tself.custom.DeleteTableData \u003d payload",
|
|
"sessionScope": false,
|
|
"viewScope": true
|
|
}
|
|
]
|
|
},
|
|
"type": "ia.display.icon"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_1"
|
|
},
|
|
"position": {
|
|
"basis": "10px"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"custom": {
|
|
"DeleteTableData": "value",
|
|
"SelectedRow": "value"
|
|
},
|
|
"events": {
|
|
"dom": {
|
|
"onClick": {
|
|
"config": {
|
|
"script": "\theader \u003d [\"Device Name\",\"Hostname\",\"Driver\"]\n\ttable \u003d [[\"\",\"\",\"\"]]\n\tdevice_dataset \u003d system.dataset.toDataSet(header,table)\n\tsystem.perspective.sendMessage(\"update-deletetable-data\", payload\u003ddevice_dataset, scope\u003d\"view\")\n\tsystem.perspective.sendMessage(\"update-deletetable-selectedrow\", payload\u003d -1, scope\u003d\"view\")"
|
|
},
|
|
"scope": "G",
|
|
"type": "script"
|
|
}
|
|
}
|
|
},
|
|
"meta": {
|
|
"name": "Icon_0"
|
|
},
|
|
"position": {
|
|
"basis": "30px"
|
|
},
|
|
"props": {
|
|
"color": "#FFFFFF",
|
|
"path": "material/delete_forever",
|
|
"style": {
|
|
"borderBottomLeftRadius": 5,
|
|
"borderBottomRightRadius": 5,
|
|
"borderColor": "#AAAAAA",
|
|
"borderStyle": "solid",
|
|
"borderTopLeftRadius": 5,
|
|
"borderTopRightRadius": 5,
|
|
"borderWidth": 1,
|
|
"classes": "Buttons/PB_1"
|
|
}
|
|
},
|
|
"type": "ia.display.icon"
|
|
}
|
|
],
|
|
"meta": {
|
|
"name": "FlexContainer_1"
|
|
},
|
|
"position": {
|
|
"basis": "125px",
|
|
"shrink": 0
|
|
},
|
|
"props": {
|
|
"direction": "column"
|
|
},
|
|
"scripts": {
|
|
"customMethods": [],
|
|
"extensionFunctions": null,
|
|
"messageHandlers": [
|
|
{
|
|
"messageType": "deletetable-selection-update",
|
|
"pageScope": true,
|
|
"script": "\tif payload \u003d\u003d -1:\n\t\tself.custom.SelectedRow \u003d None\t\n\telse:\n\t\tself.custom.SelectedRow \u003d payload",
|
|
"sessionScope": false,
|
|
"viewScope": false
|
|
}
|
|
]
|
|
},
|
|
"type": "ia.container.flex"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_4"
|
|
},
|
|
"position": {
|
|
"basis": "10px",
|
|
"grow": 1
|
|
},
|
|
"type": "ia.display.label"
|
|
}
|
|
],
|
|
"meta": {
|
|
"name": "FlexContainer"
|
|
},
|
|
"position": {
|
|
"basis": "198px",
|
|
"shrink": 0
|
|
},
|
|
"type": "ia.container.flex"
|
|
}
|
|
],
|
|
"meta": {
|
|
"name": "FlexContainer"
|
|
},
|
|
"position": {
|
|
"basis": "230px"
|
|
},
|
|
"props": {
|
|
"direction": "column"
|
|
},
|
|
"type": "ia.container.flex"
|
|
},
|
|
{
|
|
"children": [
|
|
{
|
|
"children": [
|
|
{
|
|
"meta": {
|
|
"name": "Label_4"
|
|
},
|
|
"position": {
|
|
"basis": "15px",
|
|
"shrink": 0
|
|
},
|
|
"props": {
|
|
"style": {
|
|
"classes": "Labels/Label",
|
|
"textAlign": "center"
|
|
},
|
|
"text": "\n"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label"
|
|
},
|
|
"position": {
|
|
"basis": "400px"
|
|
},
|
|
"props": {
|
|
"style": {
|
|
"classes": "Labels/Label_1",
|
|
"textAlign": "center"
|
|
},
|
|
"text": "Device Name"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_0"
|
|
},
|
|
"position": {
|
|
"basis": "400px"
|
|
},
|
|
"props": {
|
|
"style": {
|
|
"classes": "Labels/Label_1",
|
|
"textAlign": "center"
|
|
},
|
|
"text": "Driver"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_1"
|
|
},
|
|
"position": {
|
|
"basis": "200px"
|
|
},
|
|
"props": {
|
|
"style": {
|
|
"classes": "Labels/Label_1",
|
|
"textAlign": "center"
|
|
},
|
|
"text": "Enabled"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_2"
|
|
},
|
|
"position": {
|
|
"basis": "564px"
|
|
},
|
|
"props": {
|
|
"style": {
|
|
"classes": "Labels/Label_1",
|
|
"textAlign": "center"
|
|
},
|
|
"text": "Connection Status"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_3"
|
|
},
|
|
"position": {
|
|
"basis": "564px"
|
|
},
|
|
"props": {
|
|
"style": {
|
|
"classes": "Labels/Label_1",
|
|
"textAlign": "center"
|
|
},
|
|
"text": "Hostname"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "FlexContainer"
|
|
},
|
|
"position": {
|
|
"basis": "200px"
|
|
},
|
|
"props": {
|
|
"direction": "column",
|
|
"style": {
|
|
"overflow": "visible"
|
|
}
|
|
},
|
|
"type": "ia.container.flex"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_5"
|
|
},
|
|
"position": {
|
|
"basis": "15px",
|
|
"shrink": 0
|
|
},
|
|
"props": {
|
|
"style": {
|
|
"classes": "Labels/Label",
|
|
"textAlign": "center"
|
|
},
|
|
"text": "\n"
|
|
},
|
|
"type": "ia.display.label"
|
|
}
|
|
],
|
|
"custom": {
|
|
"update": "value",
|
|
"update_enable": "value"
|
|
},
|
|
"meta": {
|
|
"name": "FlexContainer"
|
|
},
|
|
"position": {
|
|
"basis": "100px"
|
|
},
|
|
"type": "ia.container.flex"
|
|
},
|
|
{
|
|
"children": [
|
|
{
|
|
"meta": {
|
|
"name": "Label_1"
|
|
},
|
|
"position": {
|
|
"basis": "10px"
|
|
},
|
|
"type": "ia.display.label"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "DeviceList"
|
|
},
|
|
"position": {
|
|
"grow": 1
|
|
},
|
|
"props": {
|
|
"direction": "column",
|
|
"path": "Main-Views/Device-Manager/Device",
|
|
"useDefaultViewWidth": false
|
|
},
|
|
"scripts": {
|
|
"customMethods": [],
|
|
"extensionFunctions": null,
|
|
"messageHandlers": [
|
|
{
|
|
"messageType": "update-devicelist-data",
|
|
"pageScope": false,
|
|
"script": "\tself.props.instances \u003d payload",
|
|
"sessionScope": false,
|
|
"viewScope": true
|
|
}
|
|
]
|
|
},
|
|
"type": "ia.display.flex-repeater"
|
|
},
|
|
{
|
|
"meta": {
|
|
"name": "Label_2"
|
|
},
|
|
"position": {
|
|
"basis": "10px"
|
|
},
|
|
"type": "ia.display.label"
|
|
}
|
|
],
|
|
"meta": {
|
|
"name": "FlexContainer_1"
|
|
},
|
|
"position": {
|
|
"basis": "784px"
|
|
},
|
|
"type": "ia.container.flex"
|
|
}
|
|
],
|
|
"meta": {
|
|
"name": "FlexContainer_0"
|
|
},
|
|
"position": {
|
|
"basis": "32px",
|
|
"grow": 1
|
|
},
|
|
"props": {
|
|
"direction": "column"
|
|
},
|
|
"type": "ia.container.flex"
|
|
}
|
|
],
|
|
"custom": {
|
|
"delay": 4000,
|
|
"run_update": true
|
|
},
|
|
"meta": {
|
|
"name": "root"
|
|
},
|
|
"propConfig": {
|
|
"custom.update": {
|
|
"binding": {
|
|
"config": {
|
|
"expression": "now({this.custom.delay})"
|
|
},
|
|
"type": "expr"
|
|
},
|
|
"onChange": {
|
|
"enabled": null,
|
|
"script": "\tdef update():\n\t\tdevices \u003d system.tag.read(\"System/DeviceStatus\").value\n\t\tfc \u003d system.tag.read(\"Configuration/FC\").value\n\t\tdecode_devices \u003d system.util.jsonDecode(devices)\n\t\tdevice_status \u003d decode_devices.get(\"Devicestatus\",\"\")\n\t\tsystem.perspective.print(device_status)\n\t\tinstance_style \u003d {\"classes\":\"DeviceManager/DeviceManagerRows\"}\n\t\tinstance_position \u003d {}\n\t\ttable_data \u003d []\n\t\tif device_status:\n\t\t\tfor i in device_status:\n\t\t\t\tif i.startswith(fc):\n\t\t\t\t\trow\u003d{}\n\t\t\t\t\trow[\"device_name\"]\u003d i\n\t\t\t\t\tdevice_items \u003d device_status.get(i)\n\t\t\t\t\tsystem.perspective.print(type(device_items))\n\t\t\t\t\tenabled \u003d device_items[0]\n\t\t\t\t\tstatus \u003d device_items[1]\n\t\t\t\t\tdriver \u003d device_items[2]\n\t\t\t\t\thost_name \u003d device_items[3]\n\t\t\t\t\t\n\t\t\t\t\trow[\"status\"] \u003d status\n\t\t\t\t\trow[\"enabled\"] \u003d enabled\n\t\t\t\t\trow[\"host_name\"] \u003d host_name\n\t\t\t\t\trow[\"driver\"] \u003d driver\n#\t\t\t\t\t\n\t\t\t\t\trow[\"instanceStyle\"]\u003d instance_style\n\t\t\t\t\trow[\"instancePosition\"]\u003d instance_position\n\t\t\t\t\ttable_data.append(row)\n#\t\t\t\n\t\t\t#self.getChild(\"FlexRepeater\").props.instances \u003d table_data\n\t\t\tsystem.perspective.sendMessage(\"update-devicelist-data\", payload \u003d table_data , scope\u003d\"view\")\n\t\telse:\n#\t\t\trow \u003d row_builder.build_row(status \u003d \"\", enabled \u003d \"\", host_name\u003d\"\", driver\u003d\"\",\n#\t\t\t \t\t\t\t\t\t\tinstanceStyle\u003d instance_style, instancePosition \u003d instance_position)\n#\t\t\ttable_data.append(row)\n\t\t\tsystem.perspective.sendMessage(\"update-devicelist-data\", payload \u003d [] , scope\u003d\"view\")\n\t\t\t\t\t\n\n\tif self.custom.run_update:\n\t\tif system.tag.exists(\"System/DeviceStatus\"):\n\t\t\tupdate()\n\t\t\t\t\t\t\n\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\n\t\t\n\t\t\n#\t\theader\u003d [\"device_name\",\"enabled\",\"status\",\"driver\",\"hostname\"]\n#\t\tdevice_dataset \u003d system.dataset.toDataSet(header,table)\n#\t\tsorted \u003d system.dataset.sort(device_dataset,\"device_name\",True)\n#\t\tevent.source.parent.getComponent(\u0027DeviceTable\u0027).templateParams \u003d sorted\n#\t\n#\tdef errors():\n#\t\terrors \u003d system.tag.read(\"System/DeviceMgrErrors\").value\n#\t\tevent.source.parent.Errors \u003d errors\n#\ttry:\n#\t\tif event.source.parent.getComponent(\u0027DeviceTable\u0027).runscript:\n#\t\t\tif system.tag.exists(\"System/DeviceStatus\"):\n#\t\t\t\tsystem.util.invokeAsynchronous(update)\n#\t\t\tif system.tag.exists(\"System/DeviceMgrErrors\"):\n#\t\t\t\tsystem.util.invokeAsynchronous(errors)\n#\t\n#\texcept:\n#\t\texc_type, exc_obj, tb \u003d sys.exc_info()\n#\t\tlineno \u003d tb.tb_lineno\n#\t\terror_description\u003dstr(lineno)+\" , \"+str(exc_type)+\" , \"+str(exc_obj)\n#\t\tsystem.gui.messageBox(error_description)"
|
|
}
|
|
}
|
|
},
|
|
"props": {
|
|
"direction": "column",
|
|
"style": {
|
|
"classes": "Background-Styles/Main-Background PopUp-Styles/Information-Device"
|
|
}
|
|
},
|
|
"type": "ia.container.flex"
|
|
}
|
|
} |