# Henry POC
## Written in Java for Intel Edison Board

# Edison Configuration
After configuring the Intel Edison via the config utility, software should be installed:

## SD Card Configuration
The Mongo DB will be stored on the SD card. This will ensure that the OS partition does not fill up. Insert an SD Card formatted to FAT32 into the SD card slot.
```
mkdir /media/sdcard/db
mkdir /data
ln -s /media/sdcard/db /data/db
```




## Mongo DB
We'll be installing version 2.6.12 since it's the last version to support 32-bit OS.
```
cd ~
wget https://fastdl.mongodb.org/linux/mongodb-linux-i686-2.6.12.tgz
mkdir ~/bin
cd ~/bin
tar -xvzf ../mongodb-linux-i686-2.6.12.tgz
```

Create a systemd script at /etc/systemd/system/mongod.service with the contents:
```
[Unit]
Description=Mongo is a scalable, document-oriented database.
After=syslog.target network.target

[Service]
ExecStart=/home/root/bin/mongodb-linux-i686-2.6.12/bin/mongod --journal

[Install]
WantedBy=multi-user.target
```

Enable the systemd script with:
```
systemctl enable mongod.service
```

# Local Web API


## Endpoint `/command?cmd=<command>&user=<username>`
- Attempts to give the command to the unit.
- Allowed values:
    - start
    - stop
- returns `{"status": <string: runStatus>}`

## Endpoint `/update?wellconfig`
- Updates the well configuration with values stored in
    1. wellConfig.json
    2. MongoDB database (configured via website)
- returns `{"configUpdated": <bool: updatestatus>}`

## Endpoint `/update?setpoint=<variable name>`
- Updates the value of the variable name supplied from values in the database.
- Allowed values:
    - fluidOilRatio
    - fluidWaterRatio
    - fluidGasRatio
    - pumpOffFillPercentSetpoint
    - pumpOffStrokesSetpoint
    - pumpOffDowntimeMinutesSetpoint
    - timerOffMinutesSetpoint
    - timerRunMinutesSetpoint
- returns `{<string: variable name>: <double: variable value>}`

## Endpoint `/mode?mode=<commanded mode>&user=<username>`
- Attempts to change to mode of the unit to the commanded mode.
- Allowed values:
    - manual
    - poc
    - timer
- returns `{"runMode": <string: runMode>}`

## Endpoint `/shake`
- Used to verify the POC is active
- returns `{"shake": "shook"}`
