933 lines
27 KiB
INI
933 lines
27 KiB
INI
{
|
|
"controllers": [
|
|
{
|
|
"protocol": "AllenBradley MicroCip",
|
|
"name": "tankalarms",
|
|
"args": {
|
|
"connectTimeOut": 2000,
|
|
"slot": 0
|
|
},
|
|
"samplePeriod": 10,
|
|
"expired": 10000,
|
|
"endpoint": "192.168.1.20:44818",
|
|
"desc": "",
|
|
"enable": 1,
|
|
"enableDebug": 0,
|
|
"enablepollCycle": 0,
|
|
"samplePeriod2": 60,
|
|
"_id": "0000674f338664ad"
|
|
}
|
|
],
|
|
"measures": [
|
|
{
|
|
"name": "water_level",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "FLOAT",
|
|
"addr": "WaterTxLevel",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "ro",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "",
|
|
"offset": "",
|
|
"pollCycle": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "0000674f33862f3a"
|
|
},
|
|
{
|
|
"name": "water_batt_volts",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "FLOAT",
|
|
"addr": "WaterTxBatVolts",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "ro",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "",
|
|
"offset": "",
|
|
"pollCycle": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "0001674f33862351"
|
|
},
|
|
{
|
|
"name": "water_rssi",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "FLOAT",
|
|
"addr": "WaterTxRSSI",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "ro",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "",
|
|
"offset": "",
|
|
"pollCycle": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "0002674f33869b82"
|
|
},
|
|
{
|
|
"name": "water_hihi_spt",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "FLOAT",
|
|
"addr": "WaterTx_HHSP",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "rw",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "",
|
|
"offset": "",
|
|
"pollCycle": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "0003674f338670be"
|
|
},
|
|
{
|
|
"name": "water_hi_spt",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "FLOAT",
|
|
"addr": "WaterTx_HSp",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "rw",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "1.0",
|
|
"offset": "0.0",
|
|
"pollCycle": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "0004674f3386c74f"
|
|
},
|
|
{
|
|
"name": "water_hihi_alm",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "BIT",
|
|
"addr": "WaterTx_HHAlrm",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "ro",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "",
|
|
"offset": "",
|
|
"pollCycle": 0,
|
|
"bitMap": 0,
|
|
"reverseBit": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "0005674f3386ef72"
|
|
},
|
|
{
|
|
"name": "water_hi_alm",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "BIT",
|
|
"addr": "WaterTx_HAlrm",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "ro",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "",
|
|
"offset": "",
|
|
"pollCycle": 0,
|
|
"bitMap": 0,
|
|
"reverseBit": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "0006674f3386dd97"
|
|
},
|
|
{
|
|
"name": "water_batt_lolo_alm",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "BIT",
|
|
"addr": "WaterTxBatVolts_LLAlrm",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "ro",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "",
|
|
"offset": "",
|
|
"pollCycle": 0,
|
|
"bitMap": 0,
|
|
"reverseBit": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "0007674f3386ef6a"
|
|
},
|
|
{
|
|
"name": "water_comm_fail_alm",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "BIT",
|
|
"addr": "WaterTx_RF_CommFail",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "ro",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "",
|
|
"offset": "",
|
|
"pollCycle": 0,
|
|
"bitMap": 0,
|
|
"reverseBit": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "0008674f33860c33"
|
|
},
|
|
{
|
|
"name": "oil_level",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "FLOAT",
|
|
"addr": "OilTxLevel",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "ro",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "",
|
|
"offset": "",
|
|
"pollCycle": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "0009674f3386f84f"
|
|
},
|
|
{
|
|
"name": "oil_batt_volts",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "FLOAT",
|
|
"addr": "OilTxBatVolts",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "ro",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "",
|
|
"offset": "",
|
|
"pollCycle": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "000a674f3386f123"
|
|
},
|
|
{
|
|
"name": "oil_rssi",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "FLOAT",
|
|
"addr": "OilTxRSSI",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "ro",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "",
|
|
"offset": "",
|
|
"pollCycle": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "000b674f338617ef"
|
|
},
|
|
{
|
|
"name": "oil_hihi_spt",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "FLOAT",
|
|
"addr": "OilTx_HHSP",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "rw",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "",
|
|
"offset": "",
|
|
"pollCycle": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "000c674f3386d216"
|
|
},
|
|
{
|
|
"name": "oil_hi_spt",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "FLOAT",
|
|
"addr": "OilTx_HSp",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "rw",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "1.0",
|
|
"offset": "0.0",
|
|
"pollCycle": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "000d674f3386fb35"
|
|
},
|
|
{
|
|
"name": "oil_hihi_alm",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "BIT",
|
|
"addr": "OilTx_HHAlrm",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "ro",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "",
|
|
"offset": "",
|
|
"pollCycle": 0,
|
|
"bitMap": 0,
|
|
"reverseBit": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "000e674f3386d44b"
|
|
},
|
|
{
|
|
"name": "oil_hi_alm",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "BIT",
|
|
"addr": "OilTx_HAlrm",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "ro",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "",
|
|
"offset": "",
|
|
"pollCycle": 0,
|
|
"bitMap": 0,
|
|
"reverseBit": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "000f674f33864f85"
|
|
},
|
|
{
|
|
"name": "oil_batt_lolo_alm",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "BIT",
|
|
"addr": "OilTxBatVolts_LLAlrm",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "ro",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "",
|
|
"offset": "",
|
|
"pollCycle": 0,
|
|
"bitMap": 0,
|
|
"reverseBit": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "0010674f33869677"
|
|
},
|
|
{
|
|
"name": "oil_comm_fail_alm",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "BIT",
|
|
"addr": "OilTx_RF_CommFail",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "ro",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "",
|
|
"offset": "",
|
|
"pollCycle": 0,
|
|
"bitMap": 0,
|
|
"reverseBit": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "0011674f3386e6a2"
|
|
},
|
|
{
|
|
"name": "alarmreset",
|
|
"ctrlName": "tankalarms",
|
|
"group": "default",
|
|
"uploadType": "periodic",
|
|
"dataType": "BIT",
|
|
"addr": "Reset",
|
|
"decimal": 2,
|
|
"len": 1,
|
|
"readWrite": "rw",
|
|
"unit": "",
|
|
"desc": "",
|
|
"transformType": 0,
|
|
"maxValue": "",
|
|
"minValue": "",
|
|
"maxScaleValue": "",
|
|
"minScaleValue": "",
|
|
"gain": "",
|
|
"offset": "",
|
|
"pollCycle": 0,
|
|
"bitMap": 0,
|
|
"reverseBit": 0,
|
|
"storageLwTSDB": 0,
|
|
"_id": "0012674f33866e4e"
|
|
}
|
|
],
|
|
"alarmLables": [
|
|
"default"
|
|
],
|
|
"alarms": [
|
|
{
|
|
"name": "water_hihi_alm",
|
|
"ctrlName": "tankalarms",
|
|
"measureName": "water_hihi_alm",
|
|
"alarmLevel": 5,
|
|
"cond1": {
|
|
"op": "eq",
|
|
"value": "1.0"
|
|
},
|
|
"condOp": "none",
|
|
"cond2": {
|
|
"op": "eq",
|
|
"value": ""
|
|
},
|
|
"content": "Water Tank HiHi",
|
|
"alarmLable": "default",
|
|
"_id": "0000674f3386b1d1"
|
|
},
|
|
{
|
|
"name": "water_hi_alm",
|
|
"ctrlName": "tankalarms",
|
|
"measureName": "water_hi_alm",
|
|
"alarmLevel": 5,
|
|
"cond1": {
|
|
"op": "eq",
|
|
"value": "1.0"
|
|
},
|
|
"condOp": "none",
|
|
"cond2": {
|
|
"op": "eq",
|
|
"value": ""
|
|
},
|
|
"content": "Water Tank Hi",
|
|
"alarmLable": "default",
|
|
"_id": "0001674f33862f1f"
|
|
},
|
|
{
|
|
"name": "water_batt_lolo_alm",
|
|
"ctrlName": "tankalarms",
|
|
"measureName": "water_batt_lolo_alm",
|
|
"alarmLevel": 5,
|
|
"cond1": {
|
|
"op": "eq",
|
|
"value": "1.0"
|
|
},
|
|
"condOp": "none",
|
|
"cond2": {
|
|
"op": "eq",
|
|
"value": ""
|
|
},
|
|
"content": "Water Tank Battery LoLo",
|
|
"alarmLable": "default",
|
|
"_id": "0002674f33864ec5"
|
|
},
|
|
{
|
|
"name": "water_comm_fail_alm",
|
|
"ctrlName": "tankalarms",
|
|
"measureName": "water_comm_fail_alm",
|
|
"alarmLevel": 5,
|
|
"cond1": {
|
|
"op": "eq",
|
|
"value": "1.0"
|
|
},
|
|
"condOp": "none",
|
|
"cond2": {
|
|
"op": "eq",
|
|
"value": ""
|
|
},
|
|
"content": "Water Tank Comms Fail",
|
|
"alarmLable": "default",
|
|
"_id": "0003674f3386df5f"
|
|
},
|
|
{
|
|
"name": "oil_hihi_alm",
|
|
"ctrlName": "tankalarms",
|
|
"measureName": "oil_hihi_alm",
|
|
"alarmLevel": 5,
|
|
"cond1": {
|
|
"op": "eq",
|
|
"value": "1.0"
|
|
},
|
|
"condOp": "none",
|
|
"cond2": {
|
|
"op": "eq",
|
|
"value": ""
|
|
},
|
|
"content": "Oil Tank HiHi",
|
|
"alarmLable": "default",
|
|
"_id": "0004674f338600c5"
|
|
},
|
|
{
|
|
"name": "oil_hi_alm",
|
|
"ctrlName": "tankalarms",
|
|
"measureName": "oil_hi_alm",
|
|
"alarmLevel": 5,
|
|
"cond1": {
|
|
"op": "eq",
|
|
"value": "1.0"
|
|
},
|
|
"condOp": "none",
|
|
"cond2": {
|
|
"op": "eq",
|
|
"value": ""
|
|
},
|
|
"content": "Oil Tank Hi",
|
|
"alarmLable": "default",
|
|
"_id": "0005674f3386dbaa"
|
|
},
|
|
{
|
|
"name": "oil_batt_lolo_alm",
|
|
"ctrlName": "tankalarms",
|
|
"measureName": "oil_batt_lolo_alm",
|
|
"alarmLevel": 5,
|
|
"cond1": {
|
|
"op": "eq",
|
|
"value": "1.0"
|
|
},
|
|
"condOp": "none",
|
|
"cond2": {
|
|
"op": "eq",
|
|
"value": ""
|
|
},
|
|
"content": "Oil Tank Battery LoLo",
|
|
"alarmLable": "default",
|
|
"_id": "0006674f3386740e"
|
|
},
|
|
{
|
|
"name": "oil_comm_fail_alm",
|
|
"ctrlName": "tankalarms",
|
|
"measureName": "oil_comm_fail_alm",
|
|
"alarmLevel": 5,
|
|
"cond1": {
|
|
"op": "eq",
|
|
"value": "1.0"
|
|
},
|
|
"condOp": "none",
|
|
"cond2": {
|
|
"op": "eq",
|
|
"value": ""
|
|
},
|
|
"content": "Oil Tank Comms Fail",
|
|
"alarmLable": "default",
|
|
"_id": "0007674f3386a6ba"
|
|
}
|
|
],
|
|
"groups": [
|
|
{
|
|
"name": "default",
|
|
"uploadInterval": 600,
|
|
"LwTSDBSize": 1000,
|
|
"strategy": 1,
|
|
"historyDataMode": "gateway",
|
|
"historyDataPath": "/var/user/data/dbhome/device_supervisor/LwTSDB",
|
|
"enablePerOnchange": 0,
|
|
"_id": "0000674f3386c809"
|
|
}
|
|
],
|
|
"misc": {
|
|
"maxAlarmRecordSz": 2000,
|
|
"logLvl": "INFO",
|
|
"coms": [
|
|
{
|
|
"name": "rs232",
|
|
"baud": 9600,
|
|
"bits": 8,
|
|
"parityChk": "n",
|
|
"stopbits": 1
|
|
},
|
|
{
|
|
"name": "rs485",
|
|
"baud": 19200,
|
|
"bits": 8,
|
|
"parityChk": "n",
|
|
"stopbits": 1
|
|
}
|
|
],
|
|
"cacheMode": "gateway",
|
|
"cachePath": "/var/user/data/dbhome/device_supervisor/offlinedata",
|
|
"cacheSize": 10000,
|
|
"debugLogMode": "gateway",
|
|
"debugLogPath": "/var/user/data/dbhome/device_supervisor/debugLog",
|
|
"debugLogSize": 2000,
|
|
"logNum": 2,
|
|
"logSize": 1
|
|
},
|
|
"clouds": [
|
|
{
|
|
"cacheSize": 10000,
|
|
"enable": 1,
|
|
"name": "default",
|
|
"type": "Standard MQTT",
|
|
"args": {
|
|
"host": "hp.henrypump.cloud",
|
|
"port": 1883,
|
|
"clientId": "faskens-fee-bm",
|
|
"auth": 1,
|
|
"tls": 0,
|
|
"cleanSession": 0,
|
|
"mqttVersion": "v3.1.1",
|
|
"keepalive": 60,
|
|
"key": "",
|
|
"cert": "",
|
|
"rootCA": "",
|
|
"verifyServer": 0,
|
|
"verifyClient": 0,
|
|
"username": "faskensmqtt",
|
|
"passwd": "faskensmqtt@1903",
|
|
"authType": 1,
|
|
"willQos": 0,
|
|
"willRetain": 0,
|
|
"willTopic": "",
|
|
"willPayload": "",
|
|
"tlsAuth": "caSelfSigned"
|
|
},
|
|
"uploadRules": [],
|
|
"_id": "0000674f338649b5"
|
|
}
|
|
],
|
|
"quickfaas": {
|
|
"genericFuncs": [],
|
|
"uploadFuncs": [
|
|
{
|
|
"qos": 1,
|
|
"funcName": "sendData",
|
|
"script": "# Enter your python code.\nimport json, os\nfrom datetime import datetime as dt\nfrom common.Logger import logger\nfrom quickfaas.remotebus import publish\nfrom quickfaas.global_dict import get as get_params\nfrom quickfaas.global_dict import _set_global_args\n\ndef reboot():\n #basic = Basic()\n logger.info(\"!\" * 10 + \"REBOOTING DEVICE\" + \"!\"*10)\n r = os.popen(\"kill -s SIGHUP `cat /var/run/python/supervisord.pid`\").read()\n logger.info(f\"REBOOT : {r}\")\n\ndef checkFileExist(filename):\n path = \"/var/user/files\"\n if not os.path.exists(path):\n logger.info(\"no folder making files folder in var/user\")\n os.makedirs(path)\n with open(path + \"/\" + filename, \"a\") as f:\n json.dump({}, f)\n if not os.path.exists(path + \"/\" + filename):\n logger.info(\"no creds file making creds file\")\n with open(path + \"/\" + filename, \"a\") as f:\n json.dump({}, f)\n\ndef convertDStoJSON(ds):\n j = dict()\n for x in ds:\n j[x[\"key\"]] = x[\"value\"]\n return j\n\ndef convertJSONtoDS(j):\n d = []\n for key in j.keys():\n d.append({\"key\": key, \"value\": j[key]})\n return d\n\ndef checkCredentialConfig():\n logger.info(\"CHECKING CONFIG\")\n cfgpath = \"/var/user/cfg/device_supervisor/device_supervisor.cfg\"\n credspath = \"/var/user/files/creds.json\"\n cfg = dict()\n with open(cfgpath, \"r\") as f:\n cfg = json.load(f)\n clouds = cfg.get(\"clouds\")\n logger.info(clouds)\n #if not configured then try to configure from stored values\n if clouds[0][\"args\"][\"clientId\"] == \"unknown\" or clouds[0][\"args\"][\"username\"] == \"unknown\" or not clouds[0][\"args\"][\"passwd\"] or clouds[0][\"args\"][\"passwd\"] == \"unknown\":\n checkFileExist(\"creds.json\")\n with open(credspath, \"r\") as c:\n creds = json.load(c)\n if creds:\n logger.info(\"updating config with stored data\")\n clouds[0][\"args\"][\"clientId\"] = creds[\"clientId\"]\n clouds[0][\"args\"][\"username\"] = creds[\"userName\"]\n clouds[0][\"args\"][\"passwd\"] = creds[\"password\"]\n cfg[\"clouds\"] = clouds\n cfg = checkParameterConfig(cfg)\n with open(cfgpath, \"w\", encoding='utf-8') as n:\n json.dump(cfg, n, indent=1, ensure_ascii=False)\n reboot()\n else:\n #assuming clouds is filled out, if data is different then assume someone typed in something new and store it, if creds is empty fill with clouds' data\n checkFileExist(\"creds.json\")\n with open(credspath, \"r\") as c:\n logger.info(\"updating stored file with new data\")\n cfg = checkParameterConfig(cfg)\n with open(cfgpath, \"w\", encoding='utf-8') as n:\n json.dump(cfg, n, indent=1, ensure_ascii=False)\n creds = json.load(c)\n if creds:\n if creds[\"clientId\"] != clouds[0][\"args\"][\"clientId\"]:\n creds[\"clientId\"] = clouds[0][\"args\"][\"clientId\"]\n if creds[\"userName\"] != clouds[0][\"args\"][\"username\"]:\n creds[\"userName\"] = clouds[0][\"args\"][\"username\"]\n if creds[\"password\"] != clouds[0][\"args\"][\"passwd\"]:\n creds[\"password\"] = clouds[0][\"args\"][\"passwd\"]\n else:\n creds[\"clientId\"] = clouds[0][\"args\"][\"clientId\"]\n creds[\"userName\"] = clouds[0][\"args\"][\"username\"]\n creds[\"password\"] = clouds[0][\"args\"][\"passwd\"]\n with open(credspath, \"w\") as cw:\n json.dump(creds,cw)\n\ndef checkParameterConfig(cfg):\n logger.info(\"Checking Parameters!!!!\")\n paramspath = \"/var/user/files/params.json\"\n cfgparams = convertDStoJSON(cfg.get(\"labels\"))\n #check stored values \n checkFileExist(\"params.json\")\n with open(paramspath, \"r\") as f:\n logger.info(\"Opened param storage file\")\n params = json.load(f)\n if params:\n if cfgparams != params:\n #go through each param\n #if not \"unknown\" and cfg and params aren't the same take from cfg likely updated manually\n #if key in cfg but not in params copy to params\n logger.info(\"equalizing params between cfg and stored\")\n for key in cfgparams.keys():\n try:\n if cfgparams[key] != params[key] and cfgparams[key] != \"unknown\":\n params[key] = cfgparams[key]\n except:\n params[key] = cfgparams[key]\n cfg[\"labels\"] = convertJSONtoDS(params)\n _set_global_args(convertJSONtoDS(params))\n with open(paramspath, \"w\") as p:\n json.dump(params, p)\n else:\n with open(paramspath, \"w\") as p:\n logger.info(\"initializing param file with params in memory\")\n json.dump(convertDStoJSON(get_params()), p)\n cfg[\"labels\"] = get_params()\n \n return cfg\n\n\n\n\ndef sendData(message):\n payload = {}\n payload[\"ts\"] = (round(dt.timestamp(dt.now())/600)*600)*1000\n payload[\"values\"] = {}\n try:\n checkCredentialConfig()\n except Exception as e:\n logger.error(e)\n for measure in message[\"measures\"]:\n try:\n logger.debug(measure)\n payload[\"values\"][measure[\"name\"]] = measure[\"value\"]\n except Exception as e:\n logger.error(e)\n publish(__topic__, json.dumps(payload), __qos__)",
|
|
"name": "sendData",
|
|
"trigger": "measure_event",
|
|
"topic": "v1/devices/me/telemetry",
|
|
"cloudName": "default",
|
|
"groups": [
|
|
"default"
|
|
],
|
|
"msgType": 0
|
|
},
|
|
{
|
|
"name": "sendAlarms",
|
|
"trigger": "warning_event",
|
|
"topic": "v1/devices/me/telemetry",
|
|
"qos": 1,
|
|
"funcName": "sendAlarm",
|
|
"script": "# Enter your python code.\nimport json, time\nfrom common.Logger import logger\nfrom quickfaas.remotebus import publish\n\n\ndef sendAlarm(message):\n logger.info(message)\n payload = {}\n payload[\"ts\"] = time.time()*1000\n payload[\"values\"] = {message[\"measureName\"]: message[\"value\"]}\n publish(__topic__, json.dumps(payload), __qos__)",
|
|
"alarms": [
|
|
"water_hihi_alm",
|
|
"water_hi_alm",
|
|
"water_batt_lolo_alm",
|
|
"water_comm_fail_alm",
|
|
"oil_hihi_alm",
|
|
"oil_hi_alm",
|
|
"oil_batt_lolo_alm",
|
|
"oil_comm_fail_alm"
|
|
],
|
|
"msgType": 0,
|
|
"cloudName": "default"
|
|
}
|
|
],
|
|
"downloadFuncs": [
|
|
{
|
|
"name": "Receive Command",
|
|
"topic": "v1/devices/me/rpc/request/+",
|
|
"qos": 1,
|
|
"funcName": "receiveCommand",
|
|
"payload_type": "JSON",
|
|
"script": "import json, time\nfrom quickfaas.measure import recall, write\nfrom quickfaas.remotebus import publish\nfrom common.Logger import logger\n\ndef sync():\n #get new values and send\n payload = {}\n topic = \"v1/devices/me/telemetry\"\n try:\n data = recall()#json.loads(recall().decode(\"utf-8\"))\n except Exception as e:\n logger.error(e)\n logger.debug(data)\n for controller in data:\n for measure in controller[\"measures\"]:\n #publish measure\n payload[measure[\"name\"]] = measure[\"value\"]\n logger.debug(\"Sending on topic: {}\".format(topic))\n logger.debug(\"Sending value: {}\".format(payload))\n publish(topic, json.dumps(payload), 1)\ndef writeplctag(value):\n #value in the form {\"measurement\": <measurement_name>, \"value\": <value to write>}\n try:\n #value = json.loads(value.replace(\"'\",'\"'))\n logger.debug(value)\n #payload format: [{\"name\": \"tankalarms\", \"measures\": [{\"name\": \"manualfrequencysetpoint\", \"value\": 49}]}]\n message = [{\"name\": \"tankalarms\", \"measures\":[{\"name\":value[\"measurement\"], \"value\": value[\"value\"]}]}]\n resp = write(message) \n logger.debug(\"RETURN FROM WRITE: {}\".format(resp))\n return True\n except Exception as e:\n logger.debug(e)\n return False\n \ndef receiveCommand(topic, payload):\n try:\n logger.debug(topic)\n logger.debug(json.loads(payload))\n p = json.loads(payload)\n command = p[\"method\"]\n commands = {\n \"sync\": sync,\n \"writeplctag\": writeplctag,\n } \n if command == \"setPLCTag\":\n try:\n result = commands[\"writeplctag\"](p[\"params\"])\n logger.debug(result)\n except Exception as e:\n logger.error(e)\n #logger.debug(command)\n ack(topic.split(\"/\")[-1])\n time.sleep(5)\n sync()\n except Exception as e:\n logger.debug(e)\n \n\ndef ack(msgid):\n #logger.debug(msgid)\n #logger.debug(mac)\n #logger.debug(name)\n #logger.debug(value)\n publish(\"v1/devices/me/rpc/response/\" + str(msgid), json.dumps({\"msg\": {\"time\": time.time()}, \"metadata\": \"\", \"msgType\": \"\"}), 1)\n\n\n",
|
|
"msgType": 0,
|
|
"cloudName": "default",
|
|
"trigger": "command_event"
|
|
},
|
|
{
|
|
"name": "receiveAttributes",
|
|
"topic": "v1/devices/me/attributes",
|
|
"qos": 1,
|
|
"funcName": "receiveAttributes",
|
|
"payload_type": "Plaintext",
|
|
"script": "# Enter your python code.\nfrom common.Logger import logger\nimport json, time\nfrom quickfaas.measure import recall, write\nfrom quickfaas.remotebus import publish\n\ndef writeplctag(value):\n #value in the form {\"measurement\": <measurement_name>, \"value\": <value to write>}\n try:\n #value = json.loads(value.replace(\"'\",'\"'))\n logger.debug(value)\n #payload format: [{\"name\": \"advvfdipp\", \"measures\": [{\"name\": \"manualfrequencysetpoint\", \"value\": 49}]}]\n message = [{\"name\": \"tankalarms\", \"measures\":[{\"name\":value[\"measurement\"], \"value\": value[\"value\"]}]}]\n resp = write(message) \n logger.debug(\"RETURN FROM WRITE: {}\".format(resp))\n return True\n except Exception as e:\n logger.debug(e)\n return False\n\ndef receiveAttributes(topic, payload):\n logger.debug(topic)\n logger.debug(json.loads(payload))\n #payload format: {'tankalarms.water_hihi_spt': 12}\n payload = json.loads(payload)\n measures = list(payload.keys())\n logger.debug(measures)\n if \"tankalarms.\" in measures[0]:\n measure = measures[0].split(\".\")[1]\n else:\n measure = measures[0]\n logger.debug(measure)\n writeplctag({\"measurement\": measure, \"value\": payload[measures[0]]})\n \n ",
|
|
"msgType": 0,
|
|
"cloudName": "default",
|
|
"trigger": "command_event"
|
|
}
|
|
]
|
|
},
|
|
"labels": [
|
|
{
|
|
"key": "SN",
|
|
"value": "GF5022404048280",
|
|
"_id": "0000674f338695da"
|
|
},
|
|
{
|
|
"key": "MAC",
|
|
"value": "ec:6e:79:02:69:4b",
|
|
"_id": "0001674f33862af2"
|
|
}
|
|
],
|
|
"modbusSlave": {
|
|
"enable": 0,
|
|
"protocol": "Modbus-TCP",
|
|
"port": 502,
|
|
"slaveAddr": 1,
|
|
"int16Ord": "ab",
|
|
"int32Ord": "abcd",
|
|
"float32Ord": "abcd",
|
|
"maxConnection": 5,
|
|
"useRawvalue": 1,
|
|
"mapping_table": []
|
|
},
|
|
"modbusRTUSlave": {
|
|
"enable": 0,
|
|
"protocol": "Modbus-RTU",
|
|
"coms": "rs485",
|
|
"slaveAddr": 1,
|
|
"int16Ord": "ab",
|
|
"int32Ord": "abcd",
|
|
"float32Ord": "abcd",
|
|
"useRawvalue": 1,
|
|
"mapping_table": []
|
|
},
|
|
"iec104Server": {
|
|
"enable": 0,
|
|
"cotSize": 2,
|
|
"port": 2404,
|
|
"serverList": [
|
|
{
|
|
"asduAddr": 1
|
|
}
|
|
],
|
|
"kValue": 12,
|
|
"wValue": 8,
|
|
"t0": 30,
|
|
"t1": 15,
|
|
"t2": 10,
|
|
"t3": 20,
|
|
"maximumLink": 5,
|
|
"timeSet": 1,
|
|
"byteOrder": "abcd",
|
|
"useRawvalue": 1,
|
|
"asduLen": 2,
|
|
"mapping_table": []
|
|
},
|
|
"iec101Server": {
|
|
"enable": 0,
|
|
"coms": "rs485",
|
|
"mode": "UnBalance",
|
|
"protocolMode": 0,
|
|
"linkLen": 2,
|
|
"linkAddr": 1,
|
|
"asduLen": 2,
|
|
"ioaLen": 3,
|
|
"cotLen": 2,
|
|
"serverList": [
|
|
{
|
|
"asduAddr": 1
|
|
}
|
|
],
|
|
"linkTimeOut": 2000,
|
|
"timeSet": 1,
|
|
"idleTimeOut": 10000,
|
|
"byteOrder": "abcd",
|
|
"useRawvalue": 1,
|
|
"mappingTable": {
|
|
"YX": [],
|
|
"YC": [],
|
|
"YK": []
|
|
}
|
|
},
|
|
"iec104Client": {
|
|
"enable": 0,
|
|
"connectType": 2,
|
|
"serverAddr": "ipower.inhandcloud.cn",
|
|
"serverPort": 2404,
|
|
"communicationCode": "",
|
|
"protocol": 1,
|
|
"asduAddr": 1,
|
|
"tls": 0,
|
|
"mapping_table": {
|
|
"YX": [],
|
|
"YC": [],
|
|
"YK": []
|
|
}
|
|
},
|
|
"opcuaServer": {
|
|
"enable": 0,
|
|
"port": 4840,
|
|
"maximumLink": 5,
|
|
"securityMode": 0,
|
|
"identifierType": "String",
|
|
"certificate": "None",
|
|
"privateKey": "None",
|
|
"pubsub": 0,
|
|
"useRawvalue": 1,
|
|
"mapping_table": []
|
|
},
|
|
"sl651Slave": {
|
|
"enable": 0,
|
|
"centerAaddr": 1,
|
|
"remoteAddr": "",
|
|
"addrCode": "",
|
|
"password": "",
|
|
"platform_list": [],
|
|
"useRawvalue": 1,
|
|
"mapping_table": []
|
|
},
|
|
"hj212Client": {
|
|
"enable": 0,
|
|
"useRawvalue": 1,
|
|
"platform_list": [],
|
|
"block_list": [],
|
|
"mapping_table": []
|
|
},
|
|
"bacnetServer": {
|
|
"enable": 0,
|
|
"protocol": "BACnet/IP",
|
|
"deviceId": 0,
|
|
"port": 47808,
|
|
"bbmdEnable": 0,
|
|
"useRawvalue": 1,
|
|
"mapping_table": []
|
|
},
|
|
"Dnp3Server": {
|
|
"enable": 0,
|
|
"protocol": "Dnp3-TCP",
|
|
"slaveAddr": 1,
|
|
"masterAddr": 2,
|
|
"port": 20000,
|
|
"useRawvalue": 1,
|
|
"enableUnsol": 0,
|
|
"maxFrasize": 4096,
|
|
"layerTimeout": 1000,
|
|
"linkRetry": 5,
|
|
"enableLink": 0,
|
|
"mapping_table": []
|
|
},
|
|
"southMetadata": {},
|
|
"bindMetadata": {
|
|
"version": "",
|
|
"timestamp": ""
|
|
},
|
|
"bindConfig": {
|
|
"enable": 0,
|
|
"bind": {
|
|
"modelId": "",
|
|
"modelName": "",
|
|
"srcId": "",
|
|
"srcName": "",
|
|
"devId": "",
|
|
"devName": ""
|
|
},
|
|
"varGroups": [],
|
|
"variables": [],
|
|
"alerts": []
|
|
},
|
|
"templates": {},
|
|
"version": "3.0.1"
|
|
} |