sensors
Package to visualize picamera and wingbeat sensor data with a Bokeh application.
app_hooks.py
Contains functions that get called on server start and on creation respectively destruction of a client side session.
- sensors.app_hooks.load_config_file(output_terminal)[source]
Function gets called on server load respectively session creation, and checks for possible custom configuration yaml-files, loads and returns the corresponding dictionary.
- Parameters:
output_terminal (boolean) – flag for print output in terminal
- Returns:
dictionary containing various parameters for sensors
- Return type:
YAML dictionary
- sensors.app_hooks.on_server_loaded(server_context)[source]
Function gets called when a Bokeh server is instantiated. It loads the config.yaml information as dictionary and add it to Bokeh’s server_context attribute. If a custom config filename is specified and exists in custom_config_path its information is used instead of the config.yaml information. Initializes the devices and corresponding attributes are added to the config object to pass it to the Bokeh server instance.
- sensors.app_hooks.on_server_unloaded(server_context)[source]
Function gets called when a Bokeh server cleanly exits. Sets GPIO switch for LED to OFF.
- sensors.app_hooks.on_session_created(session_context)[source]
Function gets called when a new session is created. It gets the number of the currently opened sessions. The first opened session is flagged as master session and gains controls over the sensor devices. A flag for the master session and a counter for added ViewerTabs is added to session_context to pass it to the session instance. It loads the config.yaml information and overwrites the config in the server_context attribute. If a custom config filename is specified and exists in custom_config_path its information is used instead of the config.yaml information.
main.py
This file gets executed when a new client side session is created. The functions of app_hook.py
will already have returned the corresponding objects and variables that are needed to run this script.
- sensors.main.add_viewer_tab()[source]
Function gets called on button click. It adds an extra ViewerTab and updates the Bokeh visualization.
config.yaml
Dictionary that contains various parameters for the control of the picamera and the wingbeat sensor.
# Configuration file for Multisensors Bokeh App
# -------------------------------------------------------------------------------------------
# Configuration sensor
# -------------------------------------------------------------------------------------------
sensor_id: null # id of used sensor, integer
user_id: null # id of user, integer
# sensor location, postcode, name, gps data
postcode: null # integer
name: null # string
latitude: null # float
longitude: null # float
gps_masked: false # boolean
# -------------------------------------------------------------------------------------------
# Configuration Picamera and circular buffer
# -------------------------------------------------------------------------------------------
camera_res_preview: [320, 240] # resolution for browser preview stream
camera_fps: 20 # FPS Picamera
number_frames: 3 # [] number of images in sequence
video_resolution: [1440, 1080] # maximum resolution for h264 video with format 4:3
video_length: 1.5 # [s] approx. length of circular buffer for h264 video capture
analog_gain: 8 # [] analog gain of picamera
digital_gain: 4 # [] digital gain of picamera
white_balance: [3, 1.8] # [] automatic white balance value of Picamera (red, blue)
exposure_time: 23500 # [mus] exposure time of a single frame/image
# foldername created in /app to save image sequence
# root has to be /static to display images in data viewer
img_path: 'static/data/img'
# -------------------------------------------------------------------------------------------
# Configuration GPIO pins
# -------------------------------------------------------------------------------------------
GPIO_Switch: 25 # GPIO OUT pin used to switch LED ON/OFF
GPIO_IR_1: 4 # GPIO IN pin used to recognize IR barrier 1 interruption
GPIO_IR_2: 17 # GPIO IN pin used to recognize IR barrier 2 interruption
GPIO_IR_3: 27 # GPIO IN pin used to recognize IR barrier 3 interruption
GPIO_IR_4: 22 # GPIO IN pin used to recognize IR barrier 4 interruption
# -------------------------------------------------------------------------------------------
# Configuration wingbeat sensor
# -------------------------------------------------------------------------------------------
sampling_rate: 96000 # [Hz] Audio sampling rate
chunk_size: 8192 # [] number of samples per audio chunk
timeframe: 1500 # length of ringbuffer in ms
number_of_saved_chunks: 6 # number of chunks used to save triggered signal
number_of_chunks_to_wait: 5 # number of chunks to wait after trigger to save signal
decimation_factor: 12 # [Hz] Sampling rate decimation factor
wav_path: 'static/data/audio' # foldername created in /sensors to save temp wav files
# path to save wingbeat measurements with SingleSaveTab
custom_wb_path: 'home/pi/my_folder'
# -------------------------------------------------------------------------------------------
# Configuration Bokeh visualisation
# -------------------------------------------------------------------------------------------
# flag if TriggeredSaveTab or SingleSaveTab is created on start of Bokeh Multisensor App
wb_triggered_save: true # boolean, if true TriggeredSave, if false SingleSave