| ... | ... | @@ -5,3 +5,31 @@ The diagram below shows the overall structure of the application. |
|
|
|
[[images/BMON_architecture.png]]
|
|
|
|
|
|
|
|
Sensors such as [[Monnit Wireless Sensors|http://www.monnit.com/]] post data across the Internet to the BMON Django application located on the web server. The sensor readings are stored in a [[SQLite|https://www.sqlite.org/]] database dedicated to those readings. The Django application utilizes a separate database to store other objects needed by the BMON system, such as building information, sensor descriptions, alert conditions, etc. This database is the standard Django database that is generated from the [[Models|https://docs.djangoproject.com/en/1.8/topics/db/models/]] in the Django application.
|
|
|
|
|
|
|
|
The User interacts with the BMON applicaton through a web browser. The Django server app supplies HTML documents and associated JavaScript to the user's browser. The browser application issues AJAX requests back to the server to supply data to the charts and reports used to analyze the sensor data. As well as viewing and analyzing sensor data, a user can log into the BMON application through the [[Django Admin interface|https://docs.djangoproject.com/en/1.8/intro/tutorial02/]] and configure the applcation. Adding buildings, sensors, alert conditions, etc. is done through the Admin interface.
|
|
|
|
|
|
|
|
## Details on Django Server Application
|
|
|
|
|
|
|
|
This section presents some further details on the Django Server application. In Django vocabulary, the BMON Django Project consists of one [[application|https://docs.djangoproject.com/en/1.8/ref/applications/]], the `bmsapp` application. Thus, the important code files for the application are found in the `bmon/bmsapp` directory.
|
|
|
|
|
|
|
|
### views.py Module
|
|
|
|
|
|
|
|
As is the convention in Django, the [[views.py|https://github.com/alanmitchell/bmon/blob/master/bmsapp/views.py]] module provides functions that are accessed by HTTP requests; the [[urls.py module|https://github.com/alanmitchell/bmon/blob/master/bmsapp/urls.py]] maps URLs to these functions.
|
|
|
|
|
|
|
|
Some of the important functions in the `views.py` module are:
|
|
|
|
|
|
|
|
**For Storing Sensor Readings**
|
|
|
|
|
|
|
|
**`store_reading()`**: Stores one sensor reading in the sensor reading database.
|
|
|
|
|
|
|
|
**`store_readings()`**: Stores multiple sensor readings in the sensor reading database.
|
|
|
|
|
|
|
|
**For Providing Content to the Browser Application**
|
|
|
|
|
|
|
|
**`reports()`**: Returns the main Reports page which is used to configure and view all of the charts and reports provided by the BMON application. The Django template used to create the page is the [[`reports.html` template|https://github.com/alanmitchell/bmon/blob/master/bmsapp/templates/bmsapp/reports.html]].
|
|
|
|
|
|
|
|
**`get_report_results()`**: The Reports page in the browser is a [[Single Page Application|https://en.wikipedia.org/wiki/Single-page_application]]. When the User makes a change to the input controls on that page that affects the report or chart, this function is called by the browser to request the new report or chart content. More explanation of the data format returned in provided in the Client Application section of this document.
|
|
|
|
|
|
|
|
**`bldg_list()`**: This function returns a list of buildings to display to the user for selection.
|
|
|
|
|
|
|
|
**`chart_sensor_list()`**: |
|
|
\ No newline at end of file |