GithubHelp home page GithubHelp logo

openagriculturefoundation / openag-device-software Goto Github PK

View Code? Open in Web Editor NEW
192.0 42.0 49.0 49.26 MB

Software for running controlled grow environments on Linux / OSX machines and embedded linux devices such as Beaglebones and Raspberry Pis.

License: GNU General Public License v3.0

Python 79.83% HTML 10.15% Shell 8.41% JavaScript 1.53% Roff 0.07%

openag-device-software's People

Contributors

jakerye avatar rbaynes avatar srmoore avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

openag-device-software's Issues

device UI es el muerto

flash latest image onto BBB and ./update.sh on EDU-B-006 using the v0.1.1 tag
go to http://:8000 and see this:

TypeError at /dashboard/
'NoneType' object is not subscriptable
Request Method:	GET
Request URL:	http://172.17.2.103:8000/dashboard/
Django Version:	1.11.4
Exception Type:	TypeError
Exception Value:	
'NoneType' object is not subscriptable
Exception Location:	/home/debian/openag-device-software/app/viewers.py in get_environment_summary, line 228

app.log shows this:

[05/Jul/2018 12:58:25.733] DEBUG app.viewers: Getting environment summary
[05/Jul/2018 12:58:26.072] INFO app.common: Unable to get sensor variable info, `spectrum_key` does not exist

Create Slow Data Sync Thread

This thread will be spawned by the device manager thread. It will check the local db tables for entries without the is_synced flag set, build payloads and publish them over MQTT so they end up in our big query database.

100% pytest coverage

@rbaynes

  • Change how pytest works for the project.
  • Move the existing tests from the top level tests/ dir to the same folder as the code that is being tested.
  • add 90% more tests for full coverage.

Add option to load device config file to UI

Currently device config is set in device.py and after uncommenting a new config uuid the database state must be cleared by running with --no-device options and clearing the state model from the django admin console...This is not ideal...

It would be nice to be able to select the device config from a drop down on the dashboard and have that restart the device. This will be needed once we have users changing the device config without software contributor supervision.

Not highly pressing right now but is definitely on the horizon and will make development more convenient.

publish device status and heartbeat

  • In boot message, send the IP of wlan0 or eth0, whichever is active (see the getMAC() code)
  • Publish a regular status message with:
    • All Device Modes: NORMAL or the ERROR string from any peripheral.
    • Recipe:
      • Time Elapsed: 0 Days 2 Hours 6 Minutes
      • Time Remaining: 0 Days 9 Hours 54 Minutes
    • resources available
    • IoT status: dis / connected, UTC
    • internet connection status: dis / connected, UTC

Add a python code formatter to GH

Is there a way to do it on the GH side, so all commits are formatted the same?
In the old days, you could do a pre-commit hook, but that relies on each developer to set it up.

Jake likes: https://github.com/ambv/black

Manu likes: YAPF (black is an extension of YAPF, so let's use black)

Validate incoming recipes

  • Don't let unvalidated recipes make it into the database.
  • Compare recipe version to about.json recipe_version. Ignore if they don't match and log an error.

Upgrade to Django 2.2 (or whatever is the latest)

We are currently using Django 1.11. The big change in Django 2.0 is python3 is now used under the hood. There are a few minor changes to the routing system (e.g. removed regex in url path names) but migration should be pretty easy.

build debian package and host it ourselves

  1. create a debian package server in gcloud
  2. write scripts to make a debian package from the jbrain code with install and upgrade scripts
  3. change our default BBB image to have our package server in its sources.list
  4. push an updated jbrain apt package to the pkg. svr.
  5. change device update script to do apt-get install -y openag-device-software
  • Think about the process of notifying a user that an update for their device is available (in the cloud UI).
  • Only if a recipe is not running?
  • How does the cloud UI tell the device to do the upgrade?
    • pub sub message to brain
    • brain pauses all operations
    • brain does the apt-get, writing output to a log
    • brain runs a delayed script IN THE BACKGROUND, that will run sudo service rc.local restart
    • brain exits

Create Fast Data Sync Thread

This thread will by spawned by device manager. It will frequently share out 'real-time' state information. Ideally this is a web socket via a django channel but that might not be v1.0, need to think through this. For v1, it might be best to make frequent uploads to a low capacity, high access rate database.

Explore simulator.py for each peripheral

For I2C devices, this will replace the file stream and have 3 functions (read, write, read_write) and a byte queue.

  • Read will pull bytes out of the queue
  • Write will go to a conditional "lookup table" for adding bytes into queue
  • Read/write will write then return read response

Simulator is an object that can hold state (e.g. if a register bit enabled or not, unit reporting specifications, etc.)

Simulator will run from i2c.py but get passed in at the driver layer if simulation mode is enabled.

Add simulated control loop

Do this for a temperature controlled fan. Abstract controllers properly (e.g. common PID class, etc.). Will need to rework actuator concept a bit...controllers should be linked to specific actuator instances, not types. So controller will read the global temperature variable then send commands to Fan-1.

Add resource manager thread

  • Clear out old entries from database when disk space gets low.
  • Delete oldest images from disk when disk space gets low.
  • Add offline data storage support. When device reconnects, then send stored data.

Spectrum approximation algorithm is overly simplistic

Currently, the approximation just puts the individual channel spectral power distributions (SPDs) into a matrix (e.g. A = [[ch1], [ch2]]), and the desired SPD into a vector (e.g. b = [des]). Then solves Ax = b for x, by using a non-negative least squares approximation. This lends to an uneven distribution of power supplied from the channels once the spectrum is filled. For example, with a very low granularity of spectrum calibration for a red, blue, green, and white channel. The algorithm will only use the red, green, and blue channels to fill the spectrum. This can be improved by increasing the granularity of the calibration but in the case of repeated channels, the spectrum is satisfied with a single channel. This should be able to be improved by weighting the channels...just need to think through all of this a bit more...

reinstate /recipe endpoints

These endpoints became out of date with the migration to the /events based endpoint so we could have individual peripheral based events. Just need to modify the view the route to events instead of directly to the recipe manager

Add hardware specific test config

When bringing up new hardware it would be nice to have a standardized method to validate all hardware works as expected...once we have the i2c r/w simulator, automated tests should work seamlessly for testing on real hardware too...but!..not all devices have the same hardware config so we will need to setup config files for the tests specific to each device and include a link to them in the device config file (similar to what we do with the peripheral setup files)...that way at the end of the day, we will be able to run ./test.sh to run all automated tests (what gets integrated with CI) ...and ALSO be able to run ./test.sh --edu1 or ./test.sh --smhz1. Not a first priority issue as we get the core infrastructure up but is a HUGE win from a device reliability perspective.

Need to show status of IoT thread in UI?

if so, what should we show?

  • last ping time
  • if we are currently connected
  • last command received?
  • last published value?

What has to change in the IotManager class to expose this status? Just add some properties?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.