| ... | ... | @@ -10,7 +10,7 @@ The User interacts with the BMON applicaton through a web browser. The Django s |
|
|
|
|
|
|
|
## 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. Here is list of the directories contained in the `bmsapp` 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. Here is a list of the directories contained in the `bmsapp` application:
|
|
|
|
|
|
|
|
```
|
|
|
|
. : Main directory with Django models.py, views.py, urls.py files
|
| ... | ... | @@ -59,3 +59,46 @@ Some of the important functions in the `views.py` module are: |
|
|
|
### Sensor Reading Database
|
|
|
|
|
|
|
|
All interactions with the Sensor Reading Database occur through the `BMSdata` class located in the [[bmsdata.py module|https://github.com/alanmitchell/bmon/blob/master/bmsapp/readingdb/bmsdata.py]]. The class contains methods for storage of sensor readings, retrieval of sensor readings, and database backup operations. For an installed BMON system, the first sensor reading database operation will cause the creation of the SQLite database, which will be stored in the `bmon/bmsapp/readingdb/data` directory. When the `BMSdata.backup_db()` method is called, the backup files of the SQLite database are placed in the `bmon/bmsapp/readingdb/data/bak` directory; backup files older than a certain number of days (a method parameter) are deleted when a new backup file is stored.
|
|
|
|
|
|
|
|
To use a different database technology, the only part of the BMON application that would need to be changed is the `bmsdata.py` file, as all access to the database occurrs through that file.
|
|
|
|
|
|
|
|
### Report/Chart Classes
|
|
|
|
|
|
|
|
Each report or chart type generated by BMON is mapped to a Python class located in the `bmon/bmsapp/reports` directory. In the [[basechart.py file|https://github.com/alanmitchell/bmon/blob/master/bmsapp/reports/basechart.py]], you can see how each single building chart is mapped to a particular class that is used to render the chart:
|
|
|
|
|
|
|
|
```python
|
|
|
|
# These are the possible chart types currently implemented, in the order they will be
|
|
|
|
# presented to the User.
|
|
|
|
BLDG_CHART_TYPES = [
|
|
|
|
BldgChartType(0, 'Dashboard', 'dashboard.Dashboard'),
|
|
|
|
BldgChartType(1, 'Current Sensor Values', 'currentvalues.CurrentValues'),
|
|
|
|
BldgChartType(2, 'Plot Sensor Values over Time', 'timeseries.TimeSeries'),
|
|
|
|
BldgChartType(3, 'Hourly Profile of a Sensor', 'hourlyprofile.HourlyProfile'),
|
|
|
|
BldgChartType(4, 'Histogram of a Sensor', 'histogram.Histogram'),
|
|
|
|
BldgChartType(5, 'Sensor X vs Y Scatter Plot', 'xyplot.XYplot'),
|
|
|
|
BldgChartType(6, 'Download Sensor Data to Excel', 'exportdata.ExportData')
|
|
|
|
]
|
|
|
|
```
|
|
|
|
|
|
|
|
The last constructor parameter gives the class that is used to create the chart. For example, the Histogram chart is created by the `Histogram` class located in the [[`histogram`|https://github.com/alanmitchell/bmon/blob/master/bmsapp/reports/histogram.py]] module.
|
|
|
|
|
|
|
|
For charts/reports that present data from multiple buildings, the mapping from chart type to class occurs in the [[models.py file|https://github.com/alanmitchell/bmon/blob/master/bmsapp/models.py]], in the definition of the `MultiBuildingChart` class:
|
|
|
|
|
|
|
|
```python
|
|
|
|
class MultiBuildingChart(models.Model):
|
|
|
|
'''
|
|
|
|
One particular chart that utilizes data from a group of buildings
|
|
|
|
'''
|
|
|
|
|
|
|
|
# descriptive title of the Chart
|
|
|
|
title = models.CharField(max_length=60, unique=True)
|
|
|
|
|
|
|
|
MULTI_CHART_CHOICES = (
|
|
|
|
('currentvalues_multi.CurrentValuesMulti', 'Current Sensor Values'),
|
|
|
|
('normalizedbyddbyft2.NormalizedByDDbyFt2', 'Energy / Degree-Day / ft2'),
|
|
|
|
('normalizedbyft2.NormalizedByFt2', 'Energy / ft2'),
|
|
|
|
)
|
|
|
|
... more code
|
|
|
|
```
|
|
|
|
|
|
|
|
You can see that the Multi-building Current Sensor Values report is produced by the [[`currentvalues_multi.CurrentValuesMulti`|https://github.com/alanmitchell/bmon/blob/master/bmsapp/reports/currentvalues_multi.py]] class. |
|
|
\ No newline at end of file |