**AUTHOR**      :  Brian Ha (2018 Summer Intern)  
**MENTOR**      :  Gene Massion  
**MBARI TEAM**  :  Chemical Sensor Group  
**PROJECT**     :  Coastal Profiling Floats (CPF)  

## Overview
---
This repository holds the code for the MBARI Coastal Profiling Float (CPF) Mission Control Software (MCS) system. 


## 3rd-Party Python Dependencies
---

Package | Version Number
--------| --------------
[simplekml](https://pypi.org/project/simplekml/) | 1.3.0
[dash](https://dash.plot.ly/)  | 0.21.1
dash-html-components | 0.11.0
dash-core-components | 0.24.1
[plotly](https://plot.ly/) | 2.7.0


## How to Deploy an Update to the CPF MCS System
---
**NOTE:** This is **NOT** a guide for deploying the CPF MCS system from scratch. That requires IS support. Please see IS tickets 26142 and 26145 for more.  
**NOTE:** This guide assumes the user is familiar with command line text editors like "vim" or "nano".

1. Login to the CPF virtual machine (VM) via command line. Note: the CPF VM runs the CentOS 7 Linux distribution. It is regularly patched by IS.
	* If using Windows:
		1. Download, install, and open the SSH client "[PuTTY](https://www.putty.org/)". 
		2. For Host Name, enter "cpf.mbari.org". For Port, enter "22". For Connection type, select SSH. Click "Open".
		3. If you receive a PuTTY security alert, click "Yes" to add the host key to the PuTTY cache. This should only happen the first time you connect.
		4. Enter your username when prompted and password (if prompted). If you have an issue, contact IS.
	* If using macOS:
		1. Open up a terminal window (Hold the Command button and press the Space Bar. Type in "terminal" and press Enter.)
		2. Enter "ssh <insert_your_username_here>@cpf.mbari.org"
		3. Enter your username when prompted and password (if prompted). 
		4. If you receive an authenticity warning, enter "yes" to continue connecting. This should only happen the first time you connect. If you still have an issue, contact IS.
2. Become the cpfadmin user by entering "sudo -u cpfadmin -i". If you have an issue with this step, contact IS.
3. Activate the cpf_mcs virtual environment by entering "source /usr/lib/python3.6/cpf_mcs/bin/activate".
4. Uninstall the old cpf_mcs package by entering "pip3.6 uninstall cpf_mcs".
5. Install the new cpf_mcs package.
	* Enter the following: "pip3.6 install git+https://<insert_your_username_here>@bitbucket.org/mbari/cpf_mcs.git"
	* Enter your password if prompted
	* NOTE: The package should be installed at /usr/lib/python3.6/cpf_mcs/lib/python3.6/site-packages
	* NOTE: All 3rd-party dependencies listed above will also be installed automatically.
6. Verify the website is being served successfully by visiting "https://cpf.mbari.org/" in a web browser.
7. Setup a Cron job to invoke the SBD processor once every minute.
	* The default text editor in CentOS 7 is "vim". If you prefer to use nano, enter "export EDITOR=nano".
	* Enter "crontab -e" to edit a crontab file.
	* Enter "* * * * * /usr/lib/python3.6/cpf_mcs/bin/python /usr/lib/python3.6/cpf_mcs/lib/python3.6/site-packages/cpf_mcs/run_sbd_processor.py"
	* Save the crontab file. Look up how to do this using vim or nano if you don't know how.
8. Verify the SBD processor is functional. 