added is_virtual to point in myems-api
parent
e45de9c394
commit
f9b72c6997
|
@ -3400,7 +3400,7 @@
|
|||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"data\":{\"name\":\"ModbusPoint2\", \"data_source_id\":1, \"object_type\": \"ENERGY_VALUE\", \"units\":\"kWh\", \"high_limit\":999999999, \"low_limit\":0, \"ratio\":1,\"is_trend\":true, \"address\":\"{\\\"slave_id\\\":1, \\\"function_code\\\":3, \\\"offset\\\":1, \\\"number_of_registers\\\":2, \\\"data_format\\\":\\\"float\\\"}\", \"description\":null}}"
|
||||
"raw": "{\"data\":{\"name\":\"ModbusPoint2\", \"data_source_id\":1, \"object_type\": \"ENERGY_VALUE\", \"units\":\"kWh\", \"high_limit\":999999999, \"low_limit\":0, \"ratio\":1,\"is_trend\":true, \"is_virtual\":false, \"address\":\"{\\\"slave_id\\\":1, \\\"function_code\\\":3, \\\"offset\\\":1, \\\"number_of_registers\\\":2, \\\"data_format\\\":\\\"float\\\"}\", \"description\":null}}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{base_url}}/points",
|
||||
|
@ -3439,7 +3439,7 @@
|
|||
"header": [],
|
||||
"body": {
|
||||
"mode": "raw",
|
||||
"raw": "{\"data\":{\"name\":\"ModbusPoint1\", \"data_source_id\":1, \"object_type\": \"ENERGY_VALUE\", \"units\":\"kWh\", \"high_limit\":999999999, \"low_limit\":0, \"ratio\":100, \"is_trend\":true, \"address\":\"{\\\"slave_id\\\":1, \\\"function_code\\\":3, \\\"offset\\\":1, \\\"number_of_registers\\\":2, \\\"data_format\\\":\\\"float\\\"}\", \"description\":null}}"
|
||||
"raw": "{\"data\":{\"name\":\"ModbusPoint1\", \"data_source_id\":1, \"object_type\": \"ENERGY_VALUE\", \"units\":\"kWh\", \"high_limit\":999999999, \"low_limit\":0, \"ratio\":100, \"is_trend\":true, \"is_virtual\":false, \"address\":\"{\\\"slave_id\\\":1, \\\"function_code\\\":3, \\\"offset\\\":1, \\\"number_of_registers\\\":2, \\\"data_format\\\":\\\"float\\\"}\", \"description\":null}}"
|
||||
},
|
||||
"url": {
|
||||
"raw": "{{base_url}}/points/1",
|
||||
|
@ -7079,6 +7079,98 @@
|
|||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "GET Combined Equipment Efficiency Report",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/reports/combinedequipmentefficiency?combinedequipmentid=1000001&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"reports",
|
||||
"combinedequipmentefficiency"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "combinedequipmentid",
|
||||
"value": "1000001"
|
||||
},
|
||||
{
|
||||
"key": "periodtype",
|
||||
"value": "daily"
|
||||
},
|
||||
{
|
||||
"key": "baseperiodstartdatetime",
|
||||
"value": "2020-08-01T00:00:00"
|
||||
},
|
||||
{
|
||||
"key": "baseperiodenddatetime",
|
||||
"value": "2020-09-01T00:00:00"
|
||||
},
|
||||
{
|
||||
"key": "reportingperiodstartdatetime",
|
||||
"value": "2020-09-01T00:00:00"
|
||||
},
|
||||
{
|
||||
"key": "reportingperiodenddatetime",
|
||||
"value": "2020-10-01T00:00:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "GET Combined Equipment Efficiency Report (Quick Mode)",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/reports/combinedequipmentefficiency?combinedequipmentid=1000001&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00&quickmode=true",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"reports",
|
||||
"combinedequipmentefficiency"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "combinedequipmentid",
|
||||
"value": "1000001"
|
||||
},
|
||||
{
|
||||
"key": "periodtype",
|
||||
"value": "daily"
|
||||
},
|
||||
{
|
||||
"key": "baseperiodstartdatetime",
|
||||
"value": "2020-08-01T00:00:00"
|
||||
},
|
||||
{
|
||||
"key": "baseperiodenddatetime",
|
||||
"value": "2020-09-01T00:00:00"
|
||||
},
|
||||
{
|
||||
"key": "reportingperiodstartdatetime",
|
||||
"value": "2020-09-01T00:00:00"
|
||||
},
|
||||
{
|
||||
"key": "reportingperiodenddatetime",
|
||||
"value": "2020-10-01T00:00:00"
|
||||
},
|
||||
{
|
||||
"key": "quickmode",
|
||||
"value": "true"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "GET Dashboard",
|
||||
"request": {
|
||||
|
@ -7749,6 +7841,47 @@
|
|||
{
|
||||
"key": "reportingperiodenddatetime",
|
||||
"value": "2020-09-11T00:00:00"
|
||||
},
|
||||
{
|
||||
"key": "",
|
||||
"value": null,
|
||||
"disabled": true
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "GET Meter Trend Report (Quick Mode)",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/reports/metertrend?meterid=6&reportingperiodstartdatetime=2020-09-10T00:00:00&reportingperiodenddatetime=2020-09-11T00:00:00&quickmode=true",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"reports",
|
||||
"metertrend"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "meterid",
|
||||
"value": "6"
|
||||
},
|
||||
{
|
||||
"key": "reportingperiodstartdatetime",
|
||||
"value": "2020-09-10T00:00:00"
|
||||
},
|
||||
{
|
||||
"key": "reportingperiodenddatetime",
|
||||
"value": "2020-09-11T00:00:00"
|
||||
},
|
||||
{
|
||||
"key": "quickmode",
|
||||
"value": "true"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -8646,6 +8779,50 @@
|
|||
}
|
||||
},
|
||||
"response": []
|
||||
},
|
||||
{
|
||||
"name": "GET Equipment Efficiency Report Copy",
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"header": [],
|
||||
"url": {
|
||||
"raw": "{{base_url}}/reports/equipmentefficiency?equipmentid=1&periodtype=daily&baseperiodstartdatetime=2020-08-01T00:00:00&baseperiodenddatetime=2020-09-01T00:00:00&reportingperiodstartdatetime=2020-09-01T00:00:00&reportingperiodenddatetime=2020-10-01T00:00:00",
|
||||
"host": [
|
||||
"{{base_url}}"
|
||||
],
|
||||
"path": [
|
||||
"reports",
|
||||
"equipmentefficiency"
|
||||
],
|
||||
"query": [
|
||||
{
|
||||
"key": "equipmentid",
|
||||
"value": "1"
|
||||
},
|
||||
{
|
||||
"key": "periodtype",
|
||||
"value": "daily"
|
||||
},
|
||||
{
|
||||
"key": "baseperiodstartdatetime",
|
||||
"value": "2020-08-01T00:00:00"
|
||||
},
|
||||
{
|
||||
"key": "baseperiodenddatetime",
|
||||
"value": "2020-09-01T00:00:00"
|
||||
},
|
||||
{
|
||||
"key": "reportingperiodstartdatetime",
|
||||
"value": "2020-09-01T00:00:00"
|
||||
},
|
||||
{
|
||||
"key": "reportingperiodenddatetime",
|
||||
"value": "2020-10-01T00:00:00"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"response": []
|
||||
}
|
||||
]
|
||||
},
|
||||
|
|
|
@ -323,7 +323,7 @@ class DataSourcePointCollection:
|
|||
description='API.INVALID_DATA_SOURCE_ID')
|
||||
|
||||
cnx = mysql.connector.connect(**config.myems_system_db)
|
||||
cursor = cnx.cursor()
|
||||
cursor = cnx.cursor(dictionary=True)
|
||||
|
||||
cursor.execute(" SELECT name "
|
||||
" FROM tbl_data_sources "
|
||||
|
@ -338,7 +338,7 @@ class DataSourcePointCollection:
|
|||
# Get points of the data source
|
||||
# NOTE: there is no uuid in tbl_points
|
||||
query_point = (" SELECT id, name, object_type, "
|
||||
" units, high_limit, low_limit, ratio, is_trend, address, description "
|
||||
" units, high_limit, low_limit, ratio, is_trend, is_virtual, address, description "
|
||||
" FROM tbl_points "
|
||||
" WHERE data_source_id = %s "
|
||||
" ORDER BY name ")
|
||||
|
@ -347,16 +347,17 @@ class DataSourcePointCollection:
|
|||
|
||||
if rows_point is not None and len(rows_point) > 0:
|
||||
for row in rows_point:
|
||||
meta_result = {"id": row[0],
|
||||
"name": row[1],
|
||||
"object_type": row[2],
|
||||
"units": row[3],
|
||||
"high_limit": row[4],
|
||||
"low_limit": row[5],
|
||||
"ratio": float(row[6]),
|
||||
"is_trend": True if row[7] else False,
|
||||
"address": row[8],
|
||||
"description": row[9]}
|
||||
meta_result = {"id": row['id'],
|
||||
"name": row['name'],
|
||||
"object_type": row['object_type'],
|
||||
"units": row['units'],
|
||||
"high_limit": row['high_limit'],
|
||||
"low_limit": row['low_limit'],
|
||||
"ratio": float(row['ratio']),
|
||||
"is_trend": bool(row['is_trend']),
|
||||
"is_virtual": bool(row['is_virtual']),
|
||||
"address": row['address'],
|
||||
"description": row['description']}
|
||||
result.append(meta_result)
|
||||
|
||||
cursor.close()
|
||||
|
|
|
@ -31,7 +31,7 @@ class PointCollection:
|
|||
"uuid": row['uuid']}
|
||||
|
||||
query = (" SELECT id, name, data_source_id, object_type, units, "
|
||||
" high_limit, low_limit, ratio, is_trend, address, description "
|
||||
" high_limit, low_limit, ratio, is_trend, is_virtual, address, description "
|
||||
" FROM tbl_points ")
|
||||
cursor.execute(query)
|
||||
rows = cursor.fetchall()
|
||||
|
@ -50,7 +50,8 @@ class PointCollection:
|
|||
"high_limit": row['high_limit'],
|
||||
"low_limit": row['low_limit'],
|
||||
"ratio": float(row['ratio']),
|
||||
"is_trend": row['is_trend'],
|
||||
"is_trend": bool(row['is_trend']),
|
||||
"is_virtual": bool(row['is_virtual']),
|
||||
"address": row['address'],
|
||||
"description": row['description']}
|
||||
result.append(meta_result)
|
||||
|
@ -122,6 +123,12 @@ class PointCollection:
|
|||
description='API.INVALID_IS_TREND_VALUE')
|
||||
is_trend = new_values['data']['is_trend']
|
||||
|
||||
if 'is_virtual' not in new_values['data'].keys() or \
|
||||
not isinstance(new_values['data']['is_virtual'], bool):
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.INVALID_IS_VIRTUAL_VALUE')
|
||||
is_virtual = new_values['data']['is_virtual']
|
||||
|
||||
if 'address' not in new_values['data'].keys() or \
|
||||
not isinstance(new_values['data']['address'], str) or \
|
||||
len(str.strip(new_values['data']['address'])) == 0:
|
||||
|
@ -159,8 +166,8 @@ class PointCollection:
|
|||
|
||||
add_value = (" INSERT INTO tbl_points (name, data_source_id, "
|
||||
" object_type, units, high_limit, low_limit, ratio, "
|
||||
" is_trend, address, description) "
|
||||
" VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s) ")
|
||||
" is_trend, is_virtual, address, description) "
|
||||
" VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) ")
|
||||
cursor.execute(add_value, (name,
|
||||
data_source_id,
|
||||
object_type,
|
||||
|
@ -169,6 +176,7 @@ class PointCollection:
|
|||
low_limit,
|
||||
ratio,
|
||||
is_trend,
|
||||
is_virtual,
|
||||
address,
|
||||
description))
|
||||
new_id = cursor.lastrowid
|
||||
|
@ -211,7 +219,7 @@ class PointItem:
|
|||
"uuid": row['uuid']}
|
||||
|
||||
query = (" SELECT id, name, data_source_id, object_type, units, "
|
||||
" high_limit, low_limit, ratio, is_trend, address, description "
|
||||
" high_limit, low_limit, ratio, is_trend, is_virtual, address, description "
|
||||
" FROM tbl_points "
|
||||
" WHERE id = %s ")
|
||||
cursor.execute(query, (id_,))
|
||||
|
@ -232,6 +240,7 @@ class PointItem:
|
|||
"low_limit": row['low_limit'],
|
||||
"ratio": float(row['ratio']),
|
||||
"is_trend": bool(row['is_trend']),
|
||||
"is_virtual": bool(row['is_virtual']),
|
||||
"address": row['address'],
|
||||
"description": row['description']}
|
||||
resp.body = json.dumps(result)
|
||||
|
@ -443,6 +452,12 @@ class PointItem:
|
|||
description='API.INVALID_IS_TREND_VALUE')
|
||||
is_trend = new_values['data']['is_trend']
|
||||
|
||||
if 'is_virtual' not in new_values['data'].keys() or \
|
||||
not isinstance(new_values['data']['is_virtual'], bool):
|
||||
raise falcon.HTTPError(falcon.HTTP_400, title='API.BAD_REQUEST',
|
||||
description='API.INVALID_IS_VIRTUAL_VALUE')
|
||||
is_virtual = new_values['data']['is_virtual']
|
||||
|
||||
if 'address' not in new_values['data'].keys() or \
|
||||
not isinstance(new_values['data']['address'], str) or \
|
||||
len(str.strip(new_values['data']['address'])) == 0:
|
||||
|
@ -491,7 +506,7 @@ class PointItem:
|
|||
" SET name = %s, data_source_id = %s, "
|
||||
" object_type = %s, units = %s, "
|
||||
" high_limit = %s, low_limit = %s, ratio = %s, "
|
||||
" is_trend = %s, address = %s, description = %s "
|
||||
" is_trend = %s, is_virtual = %s, address = %s, description = %s "
|
||||
" WHERE id = %s ")
|
||||
cursor.execute(update_row, (name,
|
||||
data_source_id,
|
||||
|
@ -501,6 +516,7 @@ class PointItem:
|
|||
low_limit,
|
||||
ratio,
|
||||
is_trend,
|
||||
is_virtual,
|
||||
address,
|
||||
description,
|
||||
id_,))
|
||||
|
|
Loading…
Reference in New Issue