Code Monkey home page Code Monkey logo

rubix-point-server's Introduction

Rubix Point Server

Running in development

  • Use poetry to manage dependencies

  • Simple script to install

    ./setup.sh
  • Join venv

    poetry shell
  • Build local binary

    poetry run pyinstaller run.py -n rubix-point --clean --onefile \
        --add-data VERSION:. \
        --add-data config:config

    The output is: dist/rubix-point

Docker build

Build

./docker.sh

The output image is: rubix-point:dev

Run

docker volume create rubix-point-data
docker run --rm -it -p 1515:1515 -v rubix-point-data:/data --name rubix-point rubix-point:dev

Deploy on Production

  • Download release artifact
  • Review help and start
$ rubix-point -h
Usage: rubix-point [OPTIONS]

Options:
  -p, --port INTEGER              Port  [default: 1515]
  -g, --global-dir PATH           Global dir
  -d, --data-dir PATH             Application data dir
  -c, --config-dir PATH           Application config dir
  --prod                          Production mode
  -s, --setting-file TEXT         Rubix Point: setting json file
  -l, --logging-conf TEXT         Rubix Point: logging config file
  --workers INTEGER               Gunicorn: The number of worker processes for handling requests.
  --gunicorn-config TEXT      Gunicorn: config file(gunicorn.conf.py)
  --log-level [FATAL|ERROR|WARN|INFO|DEBUG]
                                  Logging level
  -h, --help                      Show this message and exit.

DOCS


Config

Development

cp config/config.example.json config/config.json

python run.py -s config/config.json

MQTT client

Topic structure:

<client_id>/<client_name>/<site_id>/<site_name>/<device_id>/<device_name>/rubix/points/value/<event>/...
<client_id>/<client_name>/<site_id>/<site_name>/<device_id>/<device_name>/rubix/points/value/cov/<all|value>/<Drivers>/<network_uuid>/<network_name>/<device_uuid>/<device_name>/<point_uuid>/<point_name>
<client_id>/<client_name>/<site_id>/<site_name>/<device_id>/<device_name>/rubix/points/value/model/<ModelEvent>/<model.uuid>
COV:
  <client_id>/<client_name>/<site_id>/<site_name>/<device_id>/<device_name>/rubix/points/value/cov/all/<driver>/<network_uuid>/<network_name>/<device_uuid>/<device_name>/<point_uuid>/<point_name>

  [optional] (value only)
  <client_id>/<client_name>/<site_id>/<site_name>/<device_id>/<device_name>/rubix/points/value/cov/value/<driver>/<network_uuid>/<network_name>/<device_uuid>/<device_name>/<point_uuid>/<point_name>

MODEL:
  <client_id>/<client_name>/<site_id>/<site_name>/<device_id>/<device_name>/rubix/points/value/model/<model>/<model.uuid>

Debug topic

<client_id>/<client_name>/<site_id>/<site_name>/<device_id>/<device_name>/rubix/points/debug

Debug topic example

+/+/+/+/+/+/rubix/points/debug

Example topics:

COV:

all points:
  <client_id>/<client_name>/<site_id>/<site_name>/<device_id>/<device_name>/rubix/points/value/cov/all/#

all modbus rtu points:
  <client_id>/<client_name>/<site_id>/<site_name>/<device_id>/<device_name>/rubix/points/value/cov/all/modbus/+/+/+/+/+/+

by point uuid:
  <client_id>/<client_name>/<site_id>/<site_name>/<device_id>/<device_name>/rubix/points/value/cov/all/+/+/+/+/+/<point_uuid>/+

by point name:
  <client_id>/<client_name>/<site_id>/<site_name>/<device_id>/<device_name>/rubix/points/value/cov/all/+/+/<network_name>/+/<device_name>/+/<point_name>

List:

points list:
  <client_id>/<client_name>/<site_id>/<site_name>/<device_id>/<device_name>/rubix/points/value/points
  
schedule list:
  <client_id>/<client_name>/<site_id>/<site_name>/<device_id>/<device_name>/rubix/points/value/schedules

Generic Points MQTT Listener

  • All generic point values are updated over MQTT
  • These COVs are then broadcast again over the normal MQTT clients as above

Topic structure:

<client_id>/<site_id>/<device_id>/rubix/points/listen/cov/name/<network_name>/<device_name>/<point_name>
<client_id>/<site_id>/<device_id>/rubix/points/listen/cov/uuid/<point_uuid>

Schedule Value

<client_id>/<site_id>/<device_id>/rubix/points/listen/schedules/<name|uuid>/<schedule_name|schedule_uuid>

rubix-point-server's People

Contributors

canuckmarc avatar enjuthulung avatar nubedev avatar raibnod avatar shiny380 avatar zero88 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

rubix-point-server's Issues

Get math function working on point

We need to be able to manipulate the point value before its sent over MQTT or the API

  • offset the value.
  • do some basic math, +, -, /, *

We dont need to update existing stored data

See existing modbus point node in wires as an example

image

image

image

DB unique fields

Please make

network

  • RTU comm port unique

device

  • modbus RTU address needs to be unique per network
  • modbus IP address needs to be unique per network

point

  • modbus RTU point address needs to be unique per function type

only save point data in db on COV

To save a few steps ist better to save the value in the db only on change.
But as a safe gard maybe resave the value evey 100th loop or evey 15 min whatever is easier

point_store table

When we save a new modbus read we are string in the point_store table

The issue is this will get full very fast. So we need a roll over or limit on max size

Add tags/units

Tags

Rules for tags

  • Force all tags to be lower case
  • if there is a gap add an underscore
  • no special characters

Enter Manual Tags

See point tags/units example.
Let user add tags. Will be like temp, humidity, light

Auto Tags

Add tags auto like network_name, device_name, point_name, protocal

units

Add field for units. Type string

Modbus Device Poll Endpoint

Allow endpoint to poll device
this will use the CALLABLE event to send the request from flash thread to modbus thread (there's an example commented out in the code already on how to do this)

  • request by
    • DEVICE uuid/name/address and
    • POINT uuid/name/register

gunicorn doesn't run the DB

seems like gunicorn doesn't run anything with the DB
no driver polling updates and no DB table initialisation if haven't ran manually already (python run.py)

Wires node

Requirements for Rubix Wires Point Node

User can have the abilltiy to
Search for the point name 2 ways

adding nodes into wires

I think to make this work we need to we need to get the point UUID on import

Option 1:

  • Filter networks
  • Filter devices
  • filter points

Option 2:

  • have 1 dropdown that list's all the points NETWORK NAME -> DEVICE NAME -> POINT NAME

See start of wires node
https://github.com/NubeIO/rubix-wires/tree/modbus/point-1WIP

Update bac-rest point over HTTP PATCH

All we will do is allow the user from wires to do a HTTP PATCH

Point value, point name over MQTT

The MQTT topic will listen for changes to the network, device or point

This could be updates the point name, point value (not sure if we need to handle update to the networks or devices)

See docs in the read me
https://github.com/NubeDev/bac-rest#mqtt-client

Transferring Wires flows:
- Keep bac-rest point creation separate to wires flow import for now
1. export and import bac-rest points
2. export and import wires flow
- if wires flow imported before points it will need to be restarted / updated in some way New

that way nothing needs to be stored in wires except point_name
even if large amount of points, only requests from bac-rest on startup

Possible influx bug when not enabled

checked on an install and seen it tried to connect to influx when it wasn't enabled

Dec 08 08:35:01 raspberrypi point-server[17975]: 2020-12-08 08:35:01,765 ERROR: src.services.histories.sync.influxdb> Connection Error: HTTPConnectionPool(host='0.0.0.0', port=8086): Max retries exceeded with url: /ping (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x73c1fd50>: Failed to establish a new connection: [Errno 111] Connection refused'))

config:

[settings]
enable_mqtt = true
enable_tcp = true
enable_rtu = false
enable_histories = false
enable_cleaner = false
enable_history_sync = false

...

[influx_db]
host = 0.0.0.0
port = 8086
database = db
username = username
password = password
verify_ssl = false
timeout = 5
retries = 3
timer = 1
measurement = history

Please update mod_point_store table

Strore modbus point value and point array in point_store table

Also return thses values over the rest-api call

mod_point_fault
mod_point_value
mod_point_last_poll_timestamp
mod_point_value_array
mod_point_write_ok

fix CORS

“Access-Control-Allow-Origin’

Non urgent

After PUT polling dosnt get reflected updates

if this is added it will work! db.session.close()
Not sure what is the correct way

        results = db.session.query(ModbusNetworkModel, ModbusDeviceModel, ModbusPointModel). \
            select_from(ModbusNetworkModel).filter_by(type=ModbusType.TCP) \
            .join(ModbusDeviceModel).filter_by(type=ModbusType.TCP) \
            .join(ModbusPointModel).all()
      !!!db.session.close()!!
        for network, device, point in results:
            print(9999)
            print(point.reg)
            poll_point(network, device, point, 'tcp')

Don't publish on PATCH when nothing changed

2020-12-17 20:50:06,595 INFO: werkzeug> 127.0.0.1 - - [17/Dec/2020 20:50:06] "PATCH /api/generic/points/70e0a228-e442-46ba-8d2b-d71e52089b78 HTTP/1.1" 200 -
2020-12-17 20:50:20,713 ERROR: src> Exception on /api/generic/points/70e0a228-e442-46ba-8d2b-d71e52089b78 [PATCH]
Traceback (most recent call last):
  File "/home/aidan/code/py-nube/rubix-point-server/src/source_drivers/generic/resources/point/point_singular.py", line 48, in patch
    return point.update(**data)
  File "/home/aidan/code/py-nube/rubix-point-server/src/models/point/model_point.py", line 91, in update
    super().update(**kwargs)
  File "/home/aidan/code/py-nube/rubix-point-server/src/models/model_base.py", line 51, in update
    EventDispatcher.dispatch_from_service(None, event, None)
  File "/home/aidan/code/py-nube/rubix-point-server/src/event_dispatcher.py", line 45, in dispatch_from_service
    service.add_event(event)
  File "/home/aidan/code/py-nube/rubix-point-server/src/services/event_service_base.py", line 72, in add_event
    self._run_event(event)
  File "/home/aidan/code/py-nube/rubix-point-server/src/services/mqtt_client/mqtt_client.py", line 123, in _run_event
    self.publish_update(event.data.get('model'), event.data.get('updates'))
  File "/home/aidan/code/py-nube/rubix-point-server/src/services/mqtt_client/mqtt_client.py", line 83, in publish_update
    raise Exception('Invalid MQTT publish arguments')
Exception: Invalid MQTT publish arguments
During handling of the above exception, another exception occurred:

Add config .ini config parser

  • Add support to parse configuration from .ini file
  • Read/Write data and configuration as our in house convention
    • Development: from inside project
    • Production: from /data/<project>

Schema update conflicts (Bug when using)

[SQL: SELECT points.uuid AS points_uuid, points.name AS points_name, points.device_uuid AS points_device_uuid, points.enable AS points_enable, points.history_enable AS points_history_enable, points.history_type AS points_history_type, points.history_interval AS points_history_interval, points.cov_threshold AS points_cov_threshold, points.writable AS points_writable, points.write_value AS points_write_value, points.driver AS points_driver, points.created_on AS points_created_on, points.updated_on AS points_updated_on, point_stores_1.point_uuid AS point_stores_1_point_uuid, point_stores_1.value AS point_stores_1_value, point_stores_1.value_array AS point_stores_1_value_array, point_stores_1.fault AS point_stores_1_fault, point_stores_1.fault_message AS point_stores_1_fault_message, point_stores_1.ts AS point_stores_1_ts 
FROM points LEFT OUTER JOIN point_stores AS point_stores_1 ON points.uuid = point_stores_1.point_uuid 
WHERE ? = points.device_uuid]
[parameters: ('ce7b5f4b-79dc-48dc-b74e-d44e9e1453f9',)]
(Background on this error at: http://sqlalche.me/e/13/e3q8)
2020-11-30 19:34:53,079 INFO: werkzeug> 49.180.47.223 - - [30/Nov/2020 19:34:53] "GET /api/modbus/networks HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
    cursor, statement, parameters, context
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: no such column: points.cov_threshold

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 468, in wrapper
    resp = resource(*args, **kwargs)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 583, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 680, in wrapper
    return marshal(resp, self.fields, self.envelope)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 631, in marshal
    if envelope else [marshal(d, fields) for d in data])
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 630, in <listcomp>
    return (OrderedDict([(envelope, [marshal(d, fields) for d in data])])
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 636, in marshal
    return OrderedDict([(envelope, OrderedDict(items))]) if envelope else OrderedDict(items)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 635, in <genexpr>
    for k, v in fields.items())
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/fields.py", line 200, in output
    return self.format(value)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/fields.py", line 193, in format
    for idx, val in enumerate(value)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/fields.py", line 193, in <listcomp>
    for idx, val in enumerate(value)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/fields.py", line 155, in output
    return marshal(value, self.nested)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 636, in marshal
    return OrderedDict([(envelope, OrderedDict(items))]) if envelope else OrderedDict(items)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 635, in <genexpr>
    for k, v in fields.items())
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/fields.py", line 197, in output
    value = get_value(key if self.attribute is None else self.attribute, data)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/fields.py", line 43, in get_value
    return _get_value_for_keys(key.split('.'), obj, default)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/fields.py", line 48, in _get_value_for_keys
    return _get_value_for_key(keys[0], obj, default)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/flask_restful/fields.py", line 60, in _get_value_for_key
    return getattr(obj, key, default)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/sqlalchemy/orm/attributes.py", line 287, in __get__
    return self.impl.get(instance_state(instance), dict_)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/sqlalchemy/orm/attributes.py", line 723, in get
    value = self.callable_(state, passive)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/sqlalchemy/orm/strategies.py", line 760, in _load_for_state
    session, state, primary_key_identity, passive
  File "<string>", line 1, in <lambda>
    
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/sqlalchemy/orm/strategies.py", line 902, in _emit_lazyload
    .with_post_criteria(set_default_params)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/sqlalchemy/ext/baked.py", line 544, in all
    return list(self)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/sqlalchemy/ext/baked.py", line 444, in __iter__
    return q._execute_and_instances(context)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3560, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1011, in execute
    return meth(self, multiparams, params)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1130, in _execute_clauseelement
    distilled_params,
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1317, in _execute_context
    e, statement, parameters, cursor, context
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1511, in _handle_dbapi_exception
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
    raise exception
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
    cursor, statement, parameters, context
  File "/home/pi/common-py-libs/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) no such column: points.cov_threshold
[SQL: SELECT points.uuid AS points_uuid, points.name AS points_name, points.device_uuid AS points_device_uuid, points.enable AS points_enable, points.history_enable AS points_history_enable, points.history_type AS points_history_type, points.history_interval AS points_history_interval, points.cov_threshold AS points_cov_threshold, points.writable AS points_writable, points.write_value AS points_write_value, points.driver AS points_driver, points.created_on AS points_created_on, points.updated_on AS points_updated_on, point_stores_1.point_uuid AS point_stores_1_point_uuid, point_stores_1.value AS point_stores_1_value, point_stores_1.value_array AS point_stores_1_value_array, point_stores_1.fault AS point_stores_1_fault, point_stores_1.fault_message AS point_stores_1_fault_message, point_stores_1.ts AS point_stores_1_ts 
FROM points LEFT OUTER JOIN point_stores AS point_stores_1 ON points.uuid = point_stores_1.point_uuid 
WHERE ? = points.device_uuid]
[parameters: ('ce7b5f4b-79dc-48dc-b74e-d44e9e1453f9',)]
(Background on this error at: http://sqlalche.me/e/13/e3q8)

Error on endpoint /api/system/ping

 File "/home/thuan/workspace/bac-rest/venv/lib/python3.8/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/thuan/workspace/bac-rest/venv/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/home/thuan/workspace/bac-rest/venv/lib/python3.8/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/thuan/workspace/bac-rest/venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/thuan/workspace/bac-rest/venv/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/thuan/workspace/bac-rest/venv/lib/python3.8/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/thuan/workspace/bac-rest/venv/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/thuan/workspace/bac-rest/venv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/thuan/workspace/bac-rest/venv/lib/python3.8/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/thuan/workspace/bac-rest/venv/lib/python3.8/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/thuan/workspace/bac-rest/venv/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/thuan/workspace/bac-rest/venv/lib/python3.8/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/thuan/workspace/bac-rest/venv/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/thuan/workspace/bac-rest/venv/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/thuan/workspace/bac-rest/venv/lib/python3.8/site-packages/flask_restful/__init__.py", line 468, in wrapper
    resp = resource(*args, **kwargs)
  File "/home/thuan/workspace/bac-rest/venv/lib/python3.8/site-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/home/thuan/workspace/bac-rest/venv/lib/python3.8/site-packages/flask_restful/__init__.py", line 583, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/thuan/workspace/bac-rest/src/system/resources/ping.py", line 34, in get
    'mqtt_client_status': MqttClient.get_instance().status(),
AttributeError: type object 'MqttClient' has no attribute 'get_instance'

Modbus Network/device/point database constraints

In general we need to make sure user doesn't add the same point address, device addess and network RTU port address

point

  • modbus RTU point address unique per function type

device

  • modbus RTU address unique per network
  • modbus IP address unique per network

network

  • RTU comm port unique

Store modbus array in DB

This is the arrary that needs to be point_store in the db
'array': [16901, 21845]

<pymodbus.register_read_message.ReadHoldingRegistersResponse object at 0x7f0455735690>, 'array': [16901, 21845]}

filter_by(...).update(...) is not working in inheritance

filter_by(...).update(...) is not working in inheritance
I think I might know the problem with this.
https://hackersandslackers.com/database-queries-sqlalchemy-orm/#:~:text=Unlike%20filter()%20%2C%20filter_by(),match%20the%20arguments%20we%20pass
Unlike filter(), filter_by() accepts keyword arguments (note the difference in syntax here: filter() checks a conditional against a column object whereas filter_by() finds columns which match the arguments we pass). filter_by() can only search for exact values and serves as a kind of shorthand for simple filtering queries.

gunicorn issue

Values dont seem to update in point store when systemd is set to

ExecStart=/home/pi/bac-rest/venv/bin/gunicorn -b 0.0.0.0:1515 --log-level=DEBUG -w 1 run:app

Works fine like this

ExecStart=/home/pi/bac-rest/venv/bin/python run.py

Point Data Types

Data types

  • enum
  • float
  • string
  • bool

Actions

  • read
  • write/write

Units

SI units (Would we also do conversion for unit types, like m/s to f/s)

Meta Tags

Like haystack tags or influx tags

Ping point

The ping point type i think has been removed
Also we need to a way to disable this feature as its not required to do this

https://github.com/NubeIO/rubix-point-server/blob/master/src/source_drivers/modbus/models/device.py#L22

Polling tread breaks database is locked

Seems it might be cause we are using threading
Maybe we need to consider postgress

Our future stack will support postgress as its used in chirpstack

MODBUS DEBUG: main looping function poll_point
@@@ START MODBUS POLL !!
MODBUS DEBUG: {'network': ModbusNetworkModel(bec30e14-53ee-4ef8-a631-a6065ee0d536), 'device': ModbusDeviceModel(a085510c-2c07-4598-8711-be438836dfbb), 'transport': <ModbusType.RTU: 0>, 'mod_device_addr_length': 2, 'mod_point_type': <ModbusPointType.READ_HOLDING_REGISTERS: 2>, 'mod_point_data_type': <ModbusDataType.RAW: 0>, 'mod_point_data_endian': <ModbusDataEndian.BEB_BEW: 4>, 'write_value': 0.0}
MODBUS DEBUG: inside read_holding_registers_handle try and read {'type': <ModbusPointType.READ_HOLDING_REGISTERS: 2>}
MODBUS read_analogue, check reg_length
MODBUS: in function  _set_data_length, check reg_length {'data_type': <ModbusDataType.RAW: 0>, 'reg_length': 2}
232323
MODBUS read_analogue, check reg_length result then do modbus read {'unit': 1, 'reg_start': 7, 'reg_length': 2, 'func': <ModbusPointType.READ_HOLDING_REGISTERS: 2>, 'read_holding_registers': <ModbusPoin2>, 'read_input_registers': <ModbusPointType.READ_DISCRETE_INPUTS: 1>}
MODBUS DO READ HOLDING {'read': ModbusIOException('No Response received from the remote unit/Unable to decode response', 3)}
MODBUS read_analogue, do modbus read read Modbus Error: [Input/Output] No Response received from the remote unit/Unable to decode response reg_type holding
connects to port: /dev/ttyUSB2; Type Register: holding; Exception: Modbus Error: [Input/Output] No Response received from the remote unit/Unable to decode response
MODBUS ERROR: in poll main function 'NoneType' object is not subscriptable
!!! END MODBUS POLL @@
127.0.0.1 - - [25/Oct/2020 00:24:20] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:20] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:21] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:22] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:22] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:22] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:22] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
127.0.0.1 - - [25/Oct/2020 00:24:22] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 200 -
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 771, in _commit_impl
    self.engine.dialect.do_commit(self.connection)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 546, in do_commit
    dbapi_connection.commit()
sqlite3.OperationalError: database is locked

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/home/pi/bac-rest/src/modbus/services/rtu_polling.py", line 44, in polling
    poll_point(network, device, point, ModbusType.RTU)
  File "/home/pi/bac-rest/src/modbus/services/modbus_functions/polling/poll.py", line 168, in poll_point
    point_store.save_to_db()
  File "/home/pi/bac-rest/src/modbus/models/point_store.py", line 23, in save_to_db
    db.session.commit()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/scoping.py", line 163, in do
    return getattr(self.registry(), name)(*args, **kwargs)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 1042, in commit
    self.transaction.commit()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 508, in commit
    t[1].commit()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1762, in commit
    self._do_commit()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1793, in _do_commit
    self.connection._commit_impl()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 773, in _commit_impl
    self._handle_dbapi_exception(e, None, None, None, None)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1511, in _handle_dbapi_exception
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
    raise exception
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 771, in _commit_impl
    self.engine.dialect.do_commit(self.connection)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 546, in do_commit
    dbapi_connection.commit()
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
(Background on this error at: http://sqlalche.me/e/13/e3q8)

127.0.0.1 - - [25/Oct/2020 00:24:27] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
    cursor, statement, parameters, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: database is locked

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 468, in wrapper
    resp = resource(*args, **kwargs)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 583, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/pi/bac-rest/src/modbus/resources/point/point_plural.py", line 57, in get
    .join(filtered_partition_table, filtered_partition_table.c.point_uuid == device_points.c.uuid) \
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3373, in all
    return list(self)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3535, in __iter__
    return self._execute_and_instances(context)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3560, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1011, in execute
    return meth(self, multiparams, params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1130, in _execute_clauseelement
    distilled_params,
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1317, in _execute_context
    e, statement, parameters, cursor, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1511, in _handle_dbapi_exception
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
    raise exception
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
    cursor, statement, parameters, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
[SQL: SELECT anon_1.uuid AS anon_1_uuid, anon_1.name AS anon_1_name, anon_1.reg AS anon_1_reg, anon_2.value AS anon_2_value, anon_2.fault AS anon_2_fault
FROM (SELECT mod_points.uuid AS uuid, mod_points.name AS name, mod_points.reg AS reg, mod_points.reg_length AS reg_length, mod_points.type AS type, mod_points.enable AS enable, mod_points.write_value A_type AS data_type, mod_points.data_endian AS data_endian, mod_points.data_round AS data_round, mod_points.data_offset AS data_offset, mod_points.timeout AS timeout, mod_points.timeout_global AS timeouuplicates AS prevent_duplicates, mod_points.prevent_duplicates_global AS prevent_duplicates_global, mod_points.created_on AS created_on, mod_points.updated_on AS updated_on, mod_points.device_uuid AS d
FROM mod_points
WHERE mod_points.device_uuid = ?) AS anon_1 JOIN (SELECT anon_3.id AS id, anon_3.value AS value, anon_3.value_array AS value_array, anon_3.fault AS fault, anon_3.fault_message AS fault_message, anon_3. point_uuid, anon_3.rank AS rank
FROM (SELECT mod_points_store.id AS id, mod_points_store.value AS value, mod_points_store.value_array AS value_array, mod_points_store.fault AS fault, mod_points_store.fault_message AS fault_message, mpoints_store.point_uuid AS point_uuid, rank() OVER (PARTITION BY mod_points_store.point_uuid ORDER BY mod_points_store.ts DESC) AS rank
FROM mod_points_store) AS anon_3
WHERE anon_3.rank = ?) AS anon_2 ON anon_2.point_uuid = anon_1.uuid]
[parameters: ('a085510c-2c07-4598-8711-be438836dfbb', 1)]
(Background on this error at: http://sqlalche.me/e/13/e3q8)
127.0.0.1 - - [25/Oct/2020 00:24:27] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
    cursor, statement, parameters, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: database is locked

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 468, in wrapper
    resp = resource(*args, **kwargs)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 583, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/pi/bac-rest/src/modbus/resources/point/point_plural.py", line 57, in get
    .join(filtered_partition_table, filtered_partition_table.c.point_uuid == device_points.c.uuid) \
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3373, in all
    return list(self)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3535, in __iter__
    return self._execute_and_instances(context)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3560, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1011, in execute
    return meth(self, multiparams, params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1130, in _execute_clauseelement
    distilled_params,
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1317, in _execute_context
    e, statement, parameters, cursor, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1511, in _handle_dbapi_exception
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
    raise exception
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
    cursor, statement, parameters, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
[SQL: SELECT anon_1.uuid AS anon_1_uuid, anon_1.name AS anon_1_name, anon_1.reg AS anon_1_reg, anon_2.value AS anon_2_value, anon_2.fault AS anon_2_fault
FROM (SELECT mod_points.uuid AS uuid, mod_points.name AS name, mod_points.reg AS reg, mod_points.reg_length AS reg_length, mod_points.type AS type, mod_points.enable AS enable, mod_points.write_value A_type AS data_type, mod_points.data_endian AS data_endian, mod_points.data_round AS data_round, mod_points.data_offset AS data_offset, mod_points.timeout AS timeout, mod_points.timeout_global AS timeouuplicates AS prevent_duplicates, mod_points.prevent_duplicates_global AS prevent_duplicates_global, mod_points.created_on AS created_on, mod_points.updated_on AS updated_on, mod_points.device_uuid AS d
FROM mod_points
WHERE mod_points.device_uuid = ?) AS anon_1 JOIN (SELECT anon_3.id AS id, anon_3.value AS value, anon_3.value_array AS value_array, anon_3.fault AS fault, anon_3.fault_message AS fault_message, anon_3. point_uuid, anon_3.rank AS rank
FROM (SELECT mod_points_store.id AS id, mod_points_store.value AS value, mod_points_store.value_array AS value_array, mod_points_store.fault AS fault, mod_points_store.fault_message AS fault_message, mpoints_store.point_uuid AS point_uuid, rank() OVER (PARTITION BY mod_points_store.point_uuid ORDER BY mod_points_store.ts DESC) AS rank
FROM mod_points_store) AS anon_3
WHERE anon_3.rank = ?) AS anon_2 ON anon_2.point_uuid = anon_1.uuid]
[parameters: ('a085510c-2c07-4598-8711-be438836dfbb', 1)]
(Background on this error at: http://sqlalche.me/e/13/e3q8)
127.0.0.1 - - [25/Oct/2020 00:24:28] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
    cursor, statement, parameters, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: database is locked

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 468, in wrapper
    resp = resource(*args, **kwargs)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 583, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/pi/bac-rest/src/modbus/resources/point/point_plural.py", line 57, in get
    .join(filtered_partition_table, filtered_partition_table.c.point_uuid == device_points.c.uuid) \
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3373, in all
    return list(self)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3535, in __iter__
    return self._execute_and_instances(context)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3560, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1011, in execute
    return meth(self, multiparams, params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1130, in _execute_clauseelement
    distilled_params,
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1317, in _execute_context
    e, statement, parameters, cursor, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1511, in _handle_dbapi_exception
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
    raise exception
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
    cursor, statement, parameters, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
[SQL: SELECT anon_1.uuid AS anon_1_uuid, anon_1.name AS anon_1_name, anon_1.reg AS anon_1_reg, anon_2.value AS anon_2_value, anon_2.fault AS anon_2_fault
FROM (SELECT mod_points.uuid AS uuid, mod_points.name AS name, mod_points.reg AS reg, mod_points.reg_length AS reg_length, mod_points.type AS type, mod_points.enable AS enable, mod_points.write_value A_type AS data_type, mod_points.data_endian AS data_endian, mod_points.data_round AS data_round, mod_points.data_offset AS data_offset, mod_points.timeout AS timeout, mod_points.timeout_global AS timeouuplicates AS prevent_duplicates, mod_points.prevent_duplicates_global AS prevent_duplicates_global, mod_points.created_on AS created_on, mod_points.updated_on AS updated_on, mod_points.device_uuid AS d
FROM mod_points
WHERE mod_points.device_uuid = ?) AS anon_1 JOIN (SELECT anon_3.id AS id, anon_3.value AS value, anon_3.value_array AS value_array, anon_3.fault AS fault, anon_3.fault_message AS fault_message, anon_3. point_uuid, anon_3.rank AS rank
FROM (SELECT mod_points_store.id AS id, mod_points_store.value AS value, mod_points_store.value_array AS value_array, mod_points_store.fault AS fault, mod_points_store.fault_message AS fault_message, mpoints_store.point_uuid AS point_uuid, rank() OVER (PARTITION BY mod_points_store.point_uuid ORDER BY mod_points_store.ts DESC) AS rank
FROM mod_points_store) AS anon_3
WHERE anon_3.rank = ?) AS anon_2 ON anon_2.point_uuid = anon_1.uuid]
[parameters: ('a085510c-2c07-4598-8711-be438836dfbb', 1)]
(Background on this error at: http://sqlalche.me/e/13/e3q8)
127.0.0.1 - - [25/Oct/2020 00:24:28] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
    cursor, statement, parameters, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: database is locked

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 468, in wrapper
    resp = resource(*args, **kwargs)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 583, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/pi/bac-rest/src/modbus/resources/point/point_plural.py", line 57, in get
    .join(filtered_partition_table, filtered_partition_table.c.point_uuid == device_points.c.uuid) \
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3373, in all
    return list(self)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3535, in __iter__
    return self._execute_and_instances(context)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3560, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1011, in execute
    return meth(self, multiparams, params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1130, in _execute_clauseelement
    distilled_params,
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1317, in _execute_context
    e, statement, parameters, cursor, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1511, in _handle_dbapi_exception
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
    raise exception
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
    cursor, statement, parameters, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
[SQL: SELECT anon_1.uuid AS anon_1_uuid, anon_1.name AS anon_1_name, anon_1.reg AS anon_1_reg, anon_2.value AS anon_2_value, anon_2.fault AS anon_2_fault
FROM (SELECT mod_points.uuid AS uuid, mod_points.name AS name, mod_points.reg AS reg, mod_points.reg_length AS reg_length, mod_points.type AS type, mod_points.enable AS enable, mod_points.write_value A_type AS data_type, mod_points.data_endian AS data_endian, mod_points.data_round AS data_round, mod_points.data_offset AS data_offset, mod_points.timeout AS timeout, mod_points.timeout_global AS timeouuplicates AS prevent_duplicates, mod_points.prevent_duplicates_global AS prevent_duplicates_global, mod_points.created_on AS created_on, mod_points.updated_on AS updated_on, mod_points.device_uuid AS d
FROM mod_points
WHERE mod_points.device_uuid = ?) AS anon_1 JOIN (SELECT anon_3.id AS id, anon_3.value AS value, anon_3.value_array AS value_array, anon_3.fault AS fault, anon_3.fault_message AS fault_message, anon_3. point_uuid, anon_3.rank AS rank
FROM (SELECT mod_points_store.id AS id, mod_points_store.value AS value, mod_points_store.value_array AS value_array, mod_points_store.fault AS fault, mod_points_store.fault_message AS fault_message, mpoints_store.point_uuid AS point_uuid, rank() OVER (PARTITION BY mod_points_store.point_uuid ORDER BY mod_points_store.ts DESC) AS rank
FROM mod_points_store) AS anon_3
WHERE anon_3.rank = ?) AS anon_2 ON anon_2.point_uuid = anon_1.uuid]
[parameters: ('a085510c-2c07-4598-8711-be438836dfbb', 1)]
(Background on this error at: http://sqlalche.me/e/13/e3q8)
127.0.0.1 - - [25/Oct/2020 00:24:29] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 500 -
127.0.0.1 - - [25/Oct/2020 00:24:29] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
    cursor, statement, parameters, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: database is locked

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 468, in wrapper
    resp = resource(*args, **kwargs)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 583, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/pi/bac-rest/src/modbus/resources/point/point_plural.py", line 57, in get
    .join(filtered_partition_table, filtered_partition_table.c.point_uuid == device_points.c.uuid) \
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3373, in all
    return list(self)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3535, in __iter__
    return self._execute_and_instances(context)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3560, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1011, in execute
    return meth(self, multiparams, params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1130, in _execute_clauseelement
    distilled_params,
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1317, in _execute_context
    e, statement, parameters, cursor, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1511, in _handle_dbapi_exception
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
    raise exception
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
    cursor, statement, parameters, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
[SQL: SELECT anon_1.uuid AS anon_1_uuid, anon_1.name AS anon_1_name, anon_1.reg AS anon_1_reg, anon_2.value AS anon_2_value, anon_2.fault AS anon_2_fault
FROM (SELECT mod_points.uuid AS uuid, mod_points.name AS name, mod_points.reg AS reg, mod_points.reg_length AS reg_length, mod_points.type AS type, mod_points.enable AS enable, mod_points.write_value A_type AS data_type, mod_points.data_endian AS data_endian, mod_points.data_round AS data_round, mod_points.data_offset AS data_offset, mod_points.timeout AS timeout, mod_points.timeout_global AS timeouuplicates AS prevent_duplicates, mod_points.prevent_duplicates_global AS prevent_duplicates_global, mod_points.created_on AS created_on, mod_points.updated_on AS updated_on, mod_points.device_uuid AS d
FROM mod_points
WHERE mod_points.device_uuid = ?) AS anon_1 JOIN (SELECT anon_3.id AS id, anon_3.value AS value, anon_3.value_array AS value_array, anon_3.fault AS fault, anon_3.fault_message AS fault_message, anon_3. point_uuid, anon_3.rank AS rank
FROM (SELECT mod_points_store.id AS id, mod_points_store.value AS value, mod_points_store.value_array AS value_array, mod_points_store.fault AS fault, mod_points_store.fault_message AS fault_message, mpoints_store.point_uuid AS point_uuid, rank() OVER (PARTITION BY mod_points_store.point_uuid ORDER BY mod_points_store.ts DESC) AS rank
FROM mod_points_store) AS anon_3
WHERE anon_3.rank = ?) AS anon_2 ON anon_2.point_uuid = anon_1.uuid]
[parameters: ('a085510c-2c07-4598-8711-be438836dfbb', 1)]
(Background on this error at: http://sqlalche.me/e/13/e3q8)
127.0.0.1 - - [25/Oct/2020 00:24:29] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
    cursor, statement, parameters, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: database is locked

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 468, in wrapper
    resp = resource(*args, **kwargs)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 583, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/pi/bac-rest/src/modbus/resources/point/point_plural.py", line 57, in get
    .join(filtered_partition_table, filtered_partition_table.c.point_uuid == device_points.c.uuid) \
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3373, in all
    return list(self)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3535, in __iter__
    return self._execute_and_instances(context)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3560, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1011, in execute
    return meth(self, multiparams, params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1130, in _execute_clauseelement
    distilled_params,
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1317, in _execute_context
    e, statement, parameters, cursor, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1511, in _handle_dbapi_exception
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
    raise exception
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
    cursor, statement, parameters, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
[SQL: SELECT anon_1.uuid AS anon_1_uuid, anon_1.name AS anon_1_name, anon_1.reg AS anon_1_reg, anon_2.value AS anon_2_value, anon_2.fault AS anon_2_fault
FROM (SELECT mod_points.uuid AS uuid, mod_points.name AS name, mod_points.reg AS reg, mod_points.reg_length AS reg_length, mod_points.type AS type, mod_points.enable AS enable, mod_points.write_value A_type AS data_type, mod_points.data_endian AS data_endian, mod_points.data_round AS data_round, mod_points.data_offset AS data_offset, mod_points.timeout AS timeout, mod_points.timeout_global AS timeouuplicates AS prevent_duplicates, mod_points.prevent_duplicates_global AS prevent_duplicates_global, mod_points.created_on AS created_on, mod_points.updated_on AS updated_on, mod_points.device_uuid AS d
FROM mod_points
WHERE mod_points.device_uuid = ?) AS anon_1 JOIN (SELECT anon_3.id AS id, anon_3.value AS value, anon_3.value_array AS value_array, anon_3.fault AS fault, anon_3.fault_message AS fault_message, anon_3. point_uuid, anon_3.rank AS rank
FROM (SELECT mod_points_store.id AS id, mod_points_store.value AS value, mod_points_store.value_array AS value_array, mod_points_store.fault AS fault, mod_points_store.fault_message AS fault_message, mpoints_store.point_uuid AS point_uuid, rank() OVER (PARTITION BY mod_points_store.point_uuid ORDER BY mod_points_store.ts DESC) AS rank
FROM mod_points_store) AS anon_3
WHERE anon_3.rank = ?) AS anon_2 ON anon_2.point_uuid = anon_1.uuid]
[parameters: ('a085510c-2c07-4598-8711-be438836dfbb', 1)]
(Background on this error at: http://sqlalche.me/e/13/e3q8)
Traceback (most recent call last):
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
    cursor, statement, parameters, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: database is locked

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 468, in wrapper
    resp = resource(*args, **kwargs)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 583, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/pi/bac-rest/src/modbus/resources/point/point_plural.py", line 57, in get
    .join(filtered_partition_table, filtered_partition_table.c.point_uuid == device_points.c.uuid) \
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3373, in all
    return list(self)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3535, in __iter__
    return self._execute_and_instances(context)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3560, in _execute_and_instances
    result = conn.execute(querycontext.statement, self._params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1011, in execute
    return meth(self, multiparams, params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/sql/elements.py", line 298, in _execute_on_connection
    return connection._execute_clauseelement(self, multiparams, params)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1130, in _execute_clauseelement
    distilled_params,
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1317, in _execute_context
    e, statement, parameters, cursor, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1511, in _handle_dbapi_exception
    sqlalchemy_exception, with_traceback=exc_info[2], from_=e
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/util/compat.py", line 182, in raise_
    raise exception
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
    cursor, statement, parameters, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
[SQL: SELECT anon_1.uuid AS anon_1_uuid, anon_1.name AS anon_1_name, anon_1.reg AS anon_1_reg, anon_2.value AS anon_2_value, anon_2.fault AS anon_2_fault
FROM (SELECT mod_points.uuid AS uuid, mod_points.name AS name, mod_points.reg AS reg, mod_points.reg_length AS reg_length, mod_points.type AS type, mod_points.enable AS enable, mod_points.write_value A_type AS data_type, mod_points.data_endian AS data_endian, mod_points.data_round AS data_round, mod_points.data_offset AS data_offset, mod_points.timeout AS timeout, mod_points.timeout_global AS timeouuplicates AS prevent_duplicates, mod_points.prevent_duplicates_global AS prevent_duplicates_global, mod_points.created_on AS created_on, mod_points.updated_on AS updated_on, mod_points.device_uuid AS d
FROM mod_points
WHERE mod_points.device_uuid = ?) AS anon_1 JOIN (SELECT anon_3.id AS id, anon_3.value AS value, anon_3.value_array AS value_array, anon_3.fault AS fault, anon_3.fault_message AS fault_message, anon_3. point_uuid, anon_3.rank AS rank
FROM (SELECT mod_points_store.id AS id, mod_points_store.value AS value, mod_points_store.value_array AS value_array, mod_points_store.fault AS fault, mod_points_store.fault_message AS fault_message, mpoints_store.point_uuid AS point_uuid, rank() OVER (PARTITION BY mod_points_store.point_uuid ORDER BY mod_points_store.ts DESC) AS rank
FROM mod_points_store) AS anon_3
WHERE anon_3.rank = ?) AS anon_2 ON anon_2.point_uuid = anon_1.uuid]
[parameters: ('a085510c-2c07-4598-8711-be438836dfbb', 1)]
(Background on this error at: http://sqlalche.me/e/13/e3q8)
127.0.0.1 - - [25/Oct/2020 00:24:29] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 272, in error_router
    return original_handler(e)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_cors/extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/_compat.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 468, in wrapper
    resp = resource(*args, **kwargs)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask_restful/__init__.py", line 583, in dispatch_request
    resp = meth(*args, **kwargs)
  File "/home/pi/bac-rest/src/modbus/resources/point/point_plural.py", line 57, in get
    .join(filtered_partition_table, filtered_partition_table.c.point_uuid == device_points.c.uuid) \
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3373, in all
    return list(self)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3535, in __iter__
    return self._execute_and_instances(context)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3557, in _execute_and_instances
    querycontext, self._connection_from_session, close_with_result=True
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3572, in _get_bind_args
    mapper=self._bind_mapper(), clause=querycontext.statement, **kw
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/query.py", line 3550, in _connection_from_session
    conn = self.session.connection(**kw)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 1141, in connection
    execution_options=execution_options,
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 1147, in _connection_for_bind
    engine, execution_options
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 409, in _connection_for_bind
    self._assert_active()
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/session.py", line 283, in _assert_active
    "This session is in 'prepared' state; no further "
sqlalchemy.exc.InvalidRequestError: This session is in 'prepared' state; no further SQL can be emitted within this transaction.
127.0.0.1 - - [25/Oct/2020 00:24:30] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 500 -
127.0.0.1 - - [25/Oct/2020 00:24:30] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 500 -
127.0.0.1 - - [25/Oct/2020 00:24:30] "GET /api/modbus/a085510c-2c07-4598-8711-be438836dfbb/points_store HTTP/1.1" 500 -
Traceback (most recent call last):
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/base.py", line 1277, in _execute_context
    cursor, statement, parameters, context
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/engine/default.py", line 593, in do_execute
    cursor.execute(statement, parameters)
sqlite3.OperationalError: database is locked

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/flask/app.py", line 2464, in __call__


On delete of modbus network the polling will not restart

@@@ START MODBUS POLL !!!
MODBUS DEBUG: {'network': ModbusNetwork(uuid = fc0c024d-24ff-43f4-9af2-4f5b7cec52f9), 'device': ModbusDevice(uuid = ae6b55f4-aa2f-4ed4-a942-e2586b42e61d), 'transport': <ModbusType.RTU: 0>, 'mod_device_address': 20, 'reg': 21765, 'mod_point_reg_length': 5, 'mod_point_type': <ModbusPointType.READ_HOLDING_REGISTERS: 2>, 'mod_point_data_type': <ModbusDataType.RAW: 0>, 'mod_point_data_endian': <ModbusDataEndian.BEB_BEW: 4>, 'write_value': 0.0}
MODBUS DEBUG: inside read_holding_registers_handle try and read {'type': <ModbusPointType.READ_HOLDING_REGISTERS: 2>}
MODBUS read_analogue, check reg_length
MODBUS: in function  _set_data_length, check reg_length {'data_type': <ModbusDataType.RAW: 0>, 'reg_length': 5}
MODBUS read_analogue, check reg_length result then do modbus read {'unit': 20, 'reg_start': 21765, 'reg_length': 5, 'func': <ModbusPointType.READ_HOLDING_REGISTERS: 2>, 'read_holding_registers': <ModbusPointType.READ_HOLDING_REGISTERS: 2>, 'read_input_registers': <ModbusPointType.READ_DISCRETE_INPUTS: 1>}
DEBUG:pymodbus.transaction:Current transaction state - TRANSACTION_COMPLETE
DEBUG:pymodbus.transaction:Running transaction 172
DEBUG:pymodbus.transaction:SEND: 0x14 0x3 0x55 0x5 0x0 0x5 0x86 0xc1
DEBUG:pymodbus.framer.rtu_framer:Changing state to IDLE - Last Frame End - 1604536010.072183, Current Time stamp - 1604536011.215416
DEBUG:pymodbus.client.sync:New Transaction state 'SENDING'
DEBUG:pymodbus.transaction:Changing transaction state from 'SENDING' to 'WAITING FOR REPLY'
DEBUG:pymodbus.transaction:Changing transaction state from 'WAITING FOR REPLY' to 'PROCESSING REPLY'
DEBUG:pymodbus.transaction:RECV: 0x14 0x3 0xa 0x0 0x73 0x0 0x74 0x0 0x88 0x7f 0xff 0x7f 0xff 0xfa 0x9d
DEBUG:pymodbus.framer.rtu_framer:Getting Frame - 0x3 0xa 0x0 0x73 0x0 0x74 0x0 0x88 0x7f 0xff 0x7f 0xff
DEBUG:pymodbus.factory:Factory Response[ReadHoldingRegistersResponse: 3]
DEBUG:pymodbus.framer.rtu_framer:Frame advanced, resetting header!!
DEBUG:pymodbus.transaction:Adding transaction 20
DEBUG:pymodbus.transaction:Getting transaction 20
DEBUG:pymodbus.transaction:Changing transaction state from 'PROCESSING REPLY' to 'TRANSACTION_COMPLETE'
MODBUS DO READ HOLDING {'read': <pymodbus.register_read_message.ReadHoldingRegistersResponse object at 0x740fe150>}
MODBUS read_analogue, do modbus read read ReadRegisterResponse (5) reg_type holding
MODBUS _assertion, after modbus read read ReadRegisterResponse (5) reg_type holding
MODBUS DEBUG: inside read_holding_registers_handle AFTER read {'type': <ModbusPointType.READ_HOLDING_REGISTERS: 2>, 'val': 115, 'array': [115, 116, 136, 32767, 32767]}
MODBUS DEBUG: READ/WRITE WAS DONE TRANSPORT TYPE & VAL {'transport': <ModbusType.RTU: 0>, 'val': 115}
!!! END MODBUS POLL @@@
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:26:52] "OPTIONS /api/modbus/networks/fc0c024d-24ff-43f4-9af2-4f5b7cec52f9 HTTP/1.1" 200 -
MODBUS DEBUG: main looping function poll_point
@@@ START MODBUS POLL !!!
MODBUS DEBUG: {'network': ModbusNetwork(uuid = fc0c024d-24ff-43f4-9af2-4f5b7cec52f9), 'device': ModbusDevice(uuid = ae6b55f4-aa2f-4ed4-a942-e2586b42e61d), 'transport': <ModbusType.RTU: 0>, 'mod_device_address': 20, 'reg': 21764, 'mod_point_reg_length': 5, 'mod_point_type': <ModbusPointType.READ_HOLDING_REGISTERS: 2>, 'mod_point_data_type': <ModbusDataType.RAW: 0>, 'mod_point_data_endian': <ModbusDataEndian.BEB_BEW: 4>, 'write_value': 0.0}
MODBUS DEBUG: inside read_holding_registers_handle try and read {'type': <ModbusPointType.READ_HOLDING_REGISTERS: 2>}
MODBUS read_analogue, check reg_length
MODBUS: in function  _set_data_length, check reg_length {'data_type': <ModbusDataType.RAW: 0>, 'reg_length': 5}
MODBUS read_analogue, check reg_length result then do modbus read {'unit': 20, 'reg_start': 21764, 'reg_length': 5, 'func': <ModbusPointType.READ_HOLDING_REGISTERS: 2>, 'read_holding_registers': <ModbusPointType.READ_HOLDING_REGISTERS: 2>, 'read_input_registers': <ModbusPointType.READ_DISCRETE_INPUTS: 1>}
DEBUG:pymodbus.transaction:Current transaction state - TRANSACTION_COMPLETE
DEBUG:pymodbus.transaction:Running transaction 173
DEBUG:pymodbus.transaction:SEND: 0x14 0x3 0x55 0x4 0x0 0x5 0xd7 0x1
DEBUG:pymodbus.framer.rtu_framer:Changing state to IDLE - Last Frame End - 1604536011.40231, Current Time stamp - 1604536012.572885
DEBUG:pymodbus.client.sync:New Transaction state 'SENDING'
DEBUG:pymodbus.transaction:Changing transaction state from 'SENDING' to 'WAITING FOR REPLY'
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:26:52] "DELETE /api/modbus/networks/fc0c024d-24ff-43f4-9af2-4f5b7cec52f9 HTTP/1.1" 204 -
DEBUG:pymodbus.transaction:Changing transaction state from 'WAITING FOR REPLY' to 'PROCESSING REPLY'
DEBUG:pymodbus.transaction:RECV: 0x14 0x3 0xa 0x7f 0xff 0x0 0x74 0x0 0x74 0x0 0x88 0x7f 0xff 0x5 0x9a
DEBUG:pymodbus.framer.rtu_framer:Getting Frame - 0x3 0xa 0x7f 0xff 0x0 0x74 0x0 0x74 0x0 0x88 0x7f 0xff
DEBUG:pymodbus.factory:Factory Response[ReadHoldingRegistersResponse: 3]
DEBUG:pymodbus.framer.rtu_framer:Frame advanced, resetting header!!
DEBUG:pymodbus.transaction:Adding transaction 20
DEBUG:pymodbus.transaction:Getting transaction 20
DEBUG:pymodbus.transaction:Changing transaction state from 'PROCESSING REPLY' to 'TRANSACTION_COMPLETE'
MODBUS DO READ HOLDING {'read': <pymodbus.register_read_message.ReadHoldingRegistersResponse object at 0x74a24e70>}
MODBUS read_analogue, do modbus read read ReadRegisterResponse (5) reg_type holding
MODBUS _assertion, after modbus read read ReadRegisterResponse (5) reg_type holding
MODBUS DEBUG: inside read_holding_registers_handle AFTER read {'type': <ModbusPointType.READ_HOLDING_REGISTERS: 2>, 'val': 32767, 'array': [32767, 116, 116, 136, 32767]}
MODBUS DEBUG: READ/WRITE WAS DONE TRANSPORT TYPE & VAL {'transport': <ModbusType.RTU: 0>, 'val': 32767}
!!! END MODBUS POLL @@@
MODBUS DEBUG: main looping function poll_point
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.7/threading.py", line 865, in run
    self._target(*self._args, **self._kwargs)
  File "/home/pi/bac-rest/src/source_drivers/modbus/services/rtu_polling.py", line 47, in polling
    poll_point(network, device, point, ModbusType.RTU)
  File "/home/pi/bac-rest/src/source_drivers/modbus/services/modbus_functions/polling/poll.py", line 44, in poll_point
    reg = point.reg
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/attributes.py", line 287, in __get__
    return self.impl.get(instance_state(instance), dict_)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/attributes.py", line 718, in get
    value = state._load_expired(state, passive)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/state.py", line 652, in _load_expired
    self.manager.deferred_scalar_loader(self, toload)
  File "/home/pi/bac-rest/venv/lib/python3.7/site-packages/sqlalchemy/orm/loading.py", line 1016, in load_scalar_attributes
    raise orm_exc.ObjectDeletedError(state)
sqlalchemy.orm.exc.ObjectDeletedError: Instance '<ModbusPointModel at 0x740cfc10>' has been deleted, or its row is otherwise not present.

INFO:werkzeug:192.168.0.11 - - [05/Nov/2020 11:26:56] "GET /api/modbus/devices HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:04] "POST /api/modbus/networks HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:04] "POST /api/modbus/devices HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:05] "POST /api/modbus/points HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:05] "POST /api/modbus/points HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:06] "POST /api/modbus/points HTTP/1.1" 200 -
INFO:werkzeug:192.168.0.11 - - [05/Nov/2020 11:27:06] "GET /api/modbus/devices HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:06] "POST /api/modbus/points HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:07] "POST /api/modbus/points HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:08] "POST /api/modbus/points HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:08] "POST /api/modbus/devices HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:09] "POST /api/modbus/points HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:09] "POST /api/modbus/points HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:10] "POST /api/modbus/points HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:10] "POST /api/modbus/points HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:11] "POST /api/modbus/points HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:12] "POST /api/modbus/points HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:13] "POST /api/modbus/devices HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:13] "POST /api/modbus/points HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:14] "POST /api/modbus/points HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:14] "POST /api/modbus/points HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:15] "POST /api/modbus/points HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:15] "POST /api/modbus/points HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:16] "POST /api/modbus/points HTTP/1.1" 200 -
INFO:werkzeug:192.168.0.11 - - [05/Nov/2020 11:27:16] "GET /api/modbus/devices HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:26] "GET /api/modbus/networks HTTP/1.1" 200 -
INFO:werkzeug:192.168.0.11 - - [05/Nov/2020 11:27:26] "GET /api/modbus/devices HTTP/1.1" 200 -
INFO:werkzeug:24.69.156.9 - - [05/Nov/2020 11:27:34] "GET /api/modbus/networks HTTP/1.1" 200 -
INFO:werkzeug:49.181.153.31 - - [05/Nov/2020 11:27:35] "GET /api/modbus/networks HTTP/1.1" 200 -
INFO:werkzeug:192.168.0.11 - - [05/Nov/2020 11:27:36] "GET /api/modbus/devices HTTP/1.1" 200 -
INFO:werkzeug:49.181.153.31 - - [05/Nov/2020 11:27:39] "GET /api/modbus/networks HTTP/1.1" 200 -
INFO:werkzeug:192.168.0.11 - - [05/Nov/2020 11:27:46] "GET /api/modbus/devices HTTP/1.1" 200 -
INFO:werkzeug:192.168.0.11 - - [05/Nov/2020 11:27:56] "GET /api/modbus/devices HTTP/1.1" 200 -
INFO:werkzeug:192.168.0.11 - - [05/Nov/2020 11:28:06] "GET /api/modbus/devices HTTP/1.1" 200 -
INFO:schedule:Running job Every 5 minutes do clean() (last run: [never], next run: 2020-11-05 11:28:07)

Periodic Point Publish

Publish point values (same as COV event) for all points periodically

May not be needed. Discussion required

  • Nice to have so everything stays up to date...

    • MQTT by default will retain the latest value for every topic and send this on ANY connection reset meaning periodic publishing could prevent us from finding any bugs in any of the services
  • Need way to tell if services go down / haven't received update for long time

    • Periodic pushes might prevent this from being detectable depending on how it's implemented
      • global service level would not allow for detection

      • source_driver level would allow for detection (EventServiceBase._internal_timeout_thread will need tweaking for multiple timeouts. i.e. normal poll loop and point re-publish loop)

        • i.e. driver publishes points on a loop for example 60 point = 1 hour loop = 1 point every minute
      • This will create unnecessary histories unless unless handled for (might be hacking and over complicated to handle)

    • REST endpoint might be better way to detect service status

Add console logger

  • Remove existing stdout prints &
  • Add console logger which should able to filter in logs according to the level of logger settings

API for stack setting

Add end point for updating the same settings in the config file
Not test and my work already

Modbus client connection rework

client connection get/add is happening on a per point level. This is bad if lots of points and connection cannot be established

  • Move to per network level to check if connection to network is possible
  • implement device ping_point to ping device before attempting all points in device

MQTT retain on connection drop issue

If retain is true I think the mqtt lib will store all pubs locally if connection to broker drops
This is dangerous as if we have X COV changes to turn on/off equipment this will publish X COVs instantly, potentially rapidly powering the equipment on and off

  • Need to retain only latest update somehow

Add polling stats

We need some polling status that are avalible from an API call.
These can be reset on start of the app and dont need to be stored in the DB

For example

  • start time of first poll
  • start time & finish of current poll and time taken to complete a loop time of all devices and points
  • Poll loop count
  • Poll fails/success for points

Disable if not enabled

Modbus, Please disable from polling

mod_network_enable
mod_device_enable
mod_point_enable

Add in polling time

User can set how often we run a polling cycle
We need 2 settings:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.