Sofware Architecture

Interaction of modules
As NodeJS is based around a asynchronous paradigm, the we use the EventEmitter to communicate between modules. The communication from the server to the UI happens through Socket.IO that is based on the very same concept. This a message based concept where one module sends a message, identified by a string key and the payload (an object).

Communication between the Browser UI, NodeJS and Arduino
The communication is text based over serial.

NodeJS to Arduino:
 * sends commands in the format command(parameter)

Arduino to NodeJS 
 * sends data identified by a key and delimited by new line

NodeJS to/from Browser
 * Sends data/commands through Socket.IO with an identifier key and payload

Modules
Module: app.js

Description: This is the main startup module.

Responsibilities:
 * Setting up other modules
 * connecting the Socket.IO connections and setting up callback functions

Module: config.js

Description: Configuration values used in different modules

Module: OpenROVController.js

Description: Manages the connection to the Ardiono code

Responsibilities: Dependencies: ArduinoPhysics, StatusReader
 * initializes the proper setup of the serial connection to the Arduino via the script 'linux/setuart.sh'
 * opens the serial connection to the Arduino
 * parses the data comming in on the serial port from Arduino
 * sends the commands to the Arduino via serial (for motor actuation, tilt and light)

Module: OpenROVCamera.js

Description: Manages the video capture process Responsibilities:
 * Starting the mjpg_streamer programm with to stream the video
 * informing the UI about the start of the video process via SocketIO

Module: StatusReader.js

Description: Reads the status values sent from the Arduino on the serial connection Responsibilities:
 * parses the values read bz the OpenROVController.

Module: OpenROVArduinoFirmwareController.js

Description: Controlls the upload of an Arduino firmware zip file from the OpenROV Cockpit to the server and the status update of the Cockpit. Responsibilities: Dependencies: FirmwareInstaller
 * Retrieving the ZIP file data through Socket.IO
 * Saving the file on the BeagleBone
 * Updating the Cokpit (on the browser) with the state of the upload (actual upload, unpacking, compilation, install on the Arduino

Module: FirmwareInstaller.js

Description: Executes the file 'linux/firware-install.sh' and parses the status Responsibilities:
 * starting the shell script to install the Arduino code
 * communicate with the OpenROVArduinoFirmwareController to update the status on the Cockpit

*-Mock.js
As it is difficult to develop the UI without a BeagleBone and development on the BeagleBone is not very easy because you need to do so over the SSH connection, certain modules are mocked. A mock module has the same interface as the real one, but does not use Serial connection etc.

Arduino
To Be Done