Skip to content

Commit

Permalink
Initial release
Browse files Browse the repository at this point in the history
  • Loading branch information
slafi committed Oct 9, 2019
0 parents commit 1cd0d99
Show file tree
Hide file tree
Showing 17 changed files with 966 additions and 0 deletions.
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2019 Sabeur Lafi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
103 changes: 103 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Project Title

One Paragraph of project description goes here

## Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

## Application Configuration

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

| Parameter | Description | Default Value |
| :-------------: |:-------------| :-----:|
| host | The MQTT broker hostname | mqtt.helium.com |
| port | The MQTT broker host port | 18103 |
| username | The username attached to the Helium account | |
| secret | The password attached to the Helium account | |
| mac_address | The Helium atom MAC address | |
| topic | The MQTT topic attached to the Helium atom | |
| database | The name of the SQLite database | voltazero_database.db |
| db_mode | The mode of the SQLite database<br/> 1. *create*: if the SQLite database does not exist, create it<br/> 2. *append*: if the SQLite exists append it. If not, report an access error | create |
| time_window | The time interval used by the viewer to show telemetry (in seconds) | 300 |

### Prerequisites

What things you need to install the software and how to install them

```
Give examples
```

### Installing

A step by step series of examples that tell you how to get a development env running

Say what the step will be

```
Give the example
```

And repeat

```
until finished
```

End with an example of getting some data out of the system or using it for a little demo

## Running the tests

Explain how to run the automated tests for this system

### Break down into end to end tests

Explain what these tests test and why

```
Give an example
```

### And coding style tests

Explain what these tests test and why

```
Give an example
```

## Deployment

Add additional notes about how to deploy this on a live system

## Built With

* [Dropwizard](http://www.dropwizard.io/1.0.2/docs/) - The web framework used
* [Maven](https://maven.apache.org/) - Dependency Management
* [ROME](https://rometools.github.io/rome/) - Used to generate RSS Feeds

## Contributing

Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us.

## Versioning

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/your/project/tags).

## Authors

* **Billie Thompson** - *Initial work* - [PurpleBooth](https://github.com/PurpleBooth)

See also the list of [contributors](https://github.com/your/project/contributors) who participated in this project.

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details

## Acknowledgments

* Hat tip to anyone whose code was used
* Inspiration
* etc
74 changes: 74 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
from multiprocessing import Process, Queue

import os
import sys
import threading
import time

# Import custom subpackages
from core import config, monitor
from common import utils, logger, recorder, database


import pkgutil
import os.path

if __name__ == '__main__':

## Clear console
utils.clear_console()

## Initialize the logger
logger = logger.get_logger('voltazero_monitor')

dirpath = os.getcwd()
print(f"Current directory is: {dirpath}")
print(f"Main ID: {os.getpid()}")

## Initialization
config_file = "./core/config.json"

## Setup telemetry queue
q = Queue()

## Read app config
appConfig = config.AppConfig(config_file)
rc = appConfig.load_app_config()

if rc == -1:
print(f'The configuration file cannot be found!')
sys.exit()
elif rc == -2:
print(f'An exception has occured. Application will stop!')
sys.exit()

## Establish connectivity to the MQTT broker
pmonitor = monitor.Monitor(appConfig, q, client_id="cp100")
pmonitor.start()

## Initialize and start database recorder
precorder = recorder.Recorder(q, appConfig, interval=60.0, batch_size=20)
precorder.start()

time.sleep(60)

## Stop the monitor process
pmonitor.terminate()
pmonitor.join()

## Stop the recorder thread
precorder.stop()
precorder.join()

## Load data from the queue
data = []

while not q.empty():
data.append(q.get())

print(data)

## Launch telemetry viewer
#p = Process(target=f, args=('bob',))
#p.start()
#p.join()
2 changes: 2 additions & 0 deletions common/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

from common import *
Loading

0 comments on commit 1cd0d99

Please sign in to comment.