Wiki

Esta página apresenta as principais características da web app.

Banco de dados

UML Schema

Esta web app utiliza o seguinte esquema de banco relacional:

SQL Alchemy Schema

Resumo da declaração de todos os modelos

$ make shell
>>> tables.schema

expositions : <class 'app.models.exposition.Exposition'>

[Column('id', Integer(), table=<expositions>, primary_key=True, nullable=False),
 Column('name', String(length=30), table=<expositions>, nullable=False)]

sensors : <class 'app.models.sensor.Sensor'>

[Column('id', Integer(), table=<sensors>, primary_key=True, nullable=False),
 Column('board_id', Integer(), ForeignKey('boards.id'), table=<sensors>),
 Column('nickname', String(length=20), table=<sensors>),
 Column('description', String(length=300), table=<sensors>),
 Column('unity_measurement_id', Integer(), ForeignKey('unitymeasurements.id'), table=<sensors>, nullable=False)]

boards : <class 'app.models.board.Board'>

[Column('id', Integer(), table=<boards>, primary_key=True, nullable=False),
 Column('user_id', Integer(), ForeignKey('users.id'), table=<boards>, nullable=False),
 Column('exposition_id', Integer(), ForeignKey('expositions.id'), table=<boards>, nullable=False),
 Column('nickname', String(length=30), table=<boards>, nullable=False),
 Column('latitude', String(length=30), table=<boards>),
 Column('longitude', String(length=30), table=<boards>),
 Column('description', String(length=1000), table=<boards>),
 Column('_userhash', String(length=128), table=<boards>)]

measurements : <class 'app.models.measurement.Measurement'>

[Column('id', Integer(), table=<measurements>, primary_key=True, nullable=False),
 Column('name', String(length=50), table=<measurements>, nullable=False),
 Column('label_br', String(length=50), table=<measurements>, nullable=False),
 Column('label_en', String(length=50), table=<measurements>, nullable=False)]

roles : <class 'app.models.role.Role'>

[Column('id', Integer(), table=<roles>, primary_key=True, nullable=False),
 Column('name', String(length=30), table=<roles>, nullable=False)]

users : <class 'app.models.user.User'>

[Column('id', Integer(), table=<users>, primary_key=True, nullable=False),
 Column('username', String(length=30), table=<users>, nullable=False),
 Column('email', String(length=200), table=<users>, nullable=False),
 Column('password_hash', String(length=128), table=<users>),
 Column('confirmed', Boolean(), table=<users>, default=ColumnDefault(False))]

unities : <class 'app.models.unity.Unity'>

[Column('id', Integer(), table=<unities>, primary_key=True, nullable=False),
 Column('label', String(length=30), table=<unities>, nullable=False),
 Column('latex_label', String(length=150), table=<unities>)]

rawsensordata : <class 'app.models.rawsensordata.RawSensorData'>

[Column('id', Integer(), table=<rawsensordata>, primary_key=True, nullable=False),
 Column('sensor_id', Integer(), ForeignKey('sensors.id'), table=<rawsensordata>),
 Column('datetime', DateTime(), table=<rawsensordata>),
 Column('value', String(length=50), table=<rawsensordata>)]

unitymeasurements : <class 'app.models.unitymeasurement.UnityMeasurement'>

[Column('id', Integer(), table=<unitymeasurements>, primary_key=True, nullable=False),
 Column('measurement_id', Integer(), ForeignKey('measurements.id'), table=<unitymeasurements>, nullable=False),
 Column('unity_id', Integer(), ForeignKey('unities.id'), table=<unitymeasurements>, nullable=False)]

DB INIT

Dados cadastrados na inicialização do banco de dados:

ROLES:

    - name: admin
    - name: inspector
    - name: user

EXPOSITIONS:

    - name: indoor
    - name: outdoor

UNITIES:

    - label: "ºC" 
    - label: "ºF" 
    - label: "K" 
    - label: "Pa" 
    - label: "hPa" 
    - label: "mmHg" 
    - label: "atm" 
    - label: "%" 
    - label: "u.a." 
    - label: "lux" 

MEASUREMENTS:

    - name: ATMOSPHERIC_TEMPERATURE
      label_en: Atmospheric Temperature
      label_br: Temperatura atmosférica
      unities: ["ºC", "ºF", "K", "u.a."]

    - name: AIR_RELATIVE_HUMIDITY
      label_en: Relative Humidity of Air
      label_br: Umidade relativa do ar
      unities: ["%", "u.a."]

    - name: ATMOSPHERIC_PRESSURE
      label_en: Atmospheric Pressure
      label_br: Pressão atmosférica
      unities: ["Pa", "hPa", "mmHg", "atm", "u.a."]

    - name: LUMINOSITY
      label_en: Luminosity
      label_br: Luminosidade ambiente
      unities: ["u.a.", "lux"]

DEFAULT_SENSORS:

    - nickname: DHT22_TEMP
      measurement_name: ATMOSPHERIC_TEMPERATURE
      unity_label: "ºC" 
      description: |
          https://www.sparkfun.com/datasheets/Sensors/Temperature/DHT22.pdf

    - nickname: DHT22_AH
      measurement_name: AIR_RELATIVE_HUMIDITY
      unity_label: "%" 
      description: |
          https://www.sparkfun.com/datasheets/Sensors/Temperature/DHT22.pdf

    - nickname: BMP085_PRESSURE
      measurement_name: ATMOSPHERIC_PRESSURE
      unity_label: "Pa" 
      description: |
          http://www.adafruit.com/datasheets/BMP085_DataSheet_Rev.1.0_01July2008.pdf

    - nickname: LDR
      measurement_name: LUMINOSITY
      unity_label: "u.a." 
      description: |
          http://www.biltek.tubitak.gov.tr/gelisim/elektronik/dosyalar/40/LDR_NSL19_M51.pdf

db_schema.png (68.3 kB) Nelso G. Jost, 10/02/2016 01:23

db_schema.svg (18.3 kB) Nelso G. Jost, 10/02/2016 01:23