-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
v0.8.2 : add data source logic and link it to variable, remove CalculatedVariable #109
v0.8.2 : add data source logic and link it to variable, remove CalculatedVariable #109
Conversation
a plugin can specify additional apps to add to INSTALLED_APPS in the __init__.py file of the plugin (in pyscada/pluginName) : add a list named : additional_installed_app = ["pyscada.otherAppX", "pyscada.otherAppY"] exemple in the pyscada-operations plugin.
DataSourceModel : Used to define a data source type. The data source base model have a foreign key to this model to specify the configuration : - the name, - can add, modify on select in the admin panel, - the model name of the inline having the specific config (fields, functions, manager). DataSource : The base model for all the data sources. A data source needs to inherit from this class, and should have the basic functions : - last_value, - read_multiple, - write_multiple, - get_first_element_timestamp, - get_last_element_timestamp. DjangoDatabase : Specify a table to store the values. The table model should have a manager similar to the RecordedDataManager (functions). The default data source added is the RecordedData table. To add new data source, look at the example in pyscada-operations.
To switch to the data source architecture, use the VariableManager function in order to : - filter Variable list by datasource (_get_variables_by_datasource) - read values from datasources (read_multiple) - write values to datasources (write_multiple) - get first timestamp recorded for a variable list (get_first_element_timestamp) - get last one (get_last_element_timestamp) Plugins and handlers should not use directly the RecordedDataManager but the VariableManager in order to talk to differents data sources. Look at the new way to save read data from GenericDevice and GenericDeviceHandler in pyscada/device.py and in the pyscada.operations plugin.
in order to not loose your calculated variables you should install pyscada.operations plugin before running the pyscada migration 108.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do the changes of this commit allow to keep existing data in the "old" RecordedData Database?
pyscada/apps.py
Outdated
}, | ||
) | ||
|
||
except ProgrammingError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should at least be logged
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ProgrammingError
and OperationalError
appears when migrations are not yet applied.
Do you think we should add log for this case ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes i think so, otherwise it is not visible for the user/admin what happend
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will do it on Monday.
pyscada/apps.py
Outdated
except ProgrammingError: | ||
pass | ||
except OperationalError: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should at least be logged
@@ -19,6 +19,8 @@ Device Protocol IDs | |||
- 15: `MeterBus (MBus) <https://github.com/pyscada/PyScada-MeterBus>`_ | |||
- 16: Generic dummy device | |||
- 17: `EMS <https://github.com/pyscada/PyScada-EMS>`_ | |||
- 18: `Operations <https://github.com/pyscada/PyScada-Operations>`_ | |||
- 19: `Aggregation <https://github.com/pyscada/PyScada-Operations>`_ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the URL seems to be wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is in my account, so the pyscada organization can fork it to make to link exist.
what do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay, fork is done
both apps have the same Repo so the URL is okay
Are you talking about the |
if i have a working pyscada installation with data in the RecordedData table, will this data be preserved and accessible after the update? |
Yes, default (here) is for each variable to use the first ( A plugin can add datasource using the DjangoDatabase model and define another table to use (as here for the A plugin can also, as the I will publish a simple plugin creating random data in the read function and logging values in the write function as an example. |
I add the logs for ProgrammingError and OperationalError while populating models Is it ok for merging ? |
Minor changes:
operations
andaggregation
protocolsWidgetCotent
update forCharts
INSTALLED_APPS
insettings.py
get_objects_for_html
Major changes:
DataSourceModel
(define how a data source appears in the admin),Datasource
(base for all datasource) andDjangoDatabase
(allows to define data sources as django models likeRecordedData
orRecordedDataOld
)VariableManager
(replacing theRecordedDataValueManager
to support data sources)CalculatedVariable
: moved to the PyScada-Operations plugin (aggregation protocol)