CPF Configuration

Overview

The CPF stores its configuration as an XML file at \SD\config.xml on the SD card. On startup, SystemConfigManager reads this file and populates all mission and hardware parameters in memory. If the file does not exist, a new one is created from the built-in defaults.

SystemConfigManager is a singleton that extends MissionConfig. MissionConfig defines all properties and their validation limits. SystemConfigManager adds file I/O, the default values, and the sleep/wake persistence logic.

File Format

The config file is a flat XML document. Each parameter is a single <item> element with key and value attributes, all wrapped in a <cpf> root element:

<?xml version="1.0" encoding="utf-8"?>
<cpf>
  <item key="platformname" value="CPF003" />
  <item key="engrloggerverbositylevel" value="4" />
  <item key="missionparkdepth" value="150.00" />
  ...
</cpf>

Keys are case-insensitive on read. Values are always stored as strings and parsed back to their appropriate type on load.

Loading and Saving

The default config path is \SD\config.xml. It is loaded automatically at startup. If the file is missing or corrupt, the firmware recreates it from defaults and logs the event.

To save a modified config from within a running mission, call SaveConfigFile() on the SystemConfigManager instance. The resetprofile factory mode command loads defaults, resets sleep state, and saves the file in one step.

The config is also saved automatically by the state machine before the system goes to sleep, capturing the current state for wake-up resumption.


Parameter Reference

Parameters are grouped by function. The Key column is the exact string used in the XML file.

System

Key Type Default Limits Description
platformname string CPF003 Unique identifier for this float. Used in log file names and remote logins. No spaces. Example: CPF001.
engrloggerverbositylevel int 4 0–5 Verbosity of engineering log messages sent to the Bluetooth console. 0 = silent, 1 = minimum, 5 = maximum.
debuggerverbositylevel int 4 0–5 Verbosity of messages sent to an attached software debugger. Has no effect during normal operation.
systemdatasampleperiod int (sec) 10 1–1200 Period in seconds between acquisition of core vehicle health data (voltage, current, pressure).
premissiondelayperiod int (sec) 30 0–1200 Delay in seconds before the mission state machine begins after power-on.

Bellows Calibration

The string potentiometer ADC reading is converted to bellows fill percentage using a linear calibration:

fill% = (ADC_counts - StringPotIntercept) / StringPotInverseSlope
Key Type Default Limits Description
stringpotinverseslope float 7668560.96 none Inverse slope for converting ADC counts to percent fill. Saved to 4 decimal places.
stringpotintercept float 18.706119 none Intercept for the string pot voltage-to-fill conversion. Saved to 4 decimal places.

Bellows Limits & Buoyancy Control

Key Type Default Limits Description
bellowslowerlimit float (%) 3.0 0–100 Minimum allowed bellows fill in percent. The pump will not drive below this.
bellowsupperlimit float (%) 97.0 0–100 Maximum allowed bellows fill in percent. The pump will not drive above this.
sosetbellowsposition float (%) 45.0 0–100 Target bellows fill when entering Surface Ops mode.
sosetbellowsjv int (JV) 200000 ±200000 Elmo jog velocity used for bellows adjustments during Surface Ops.
rmsetbellowsposition float (%) 5.0 0–100 Target bellows fill when entering Recovery mode.
abretractfastjv int (JV) 200000 ±200000 Pump speed during fast air-bladder retract phase.
abretractslowjv int (JV) 200000 ±200000 Pump speed during slow air-bladder retract phase.
abpressurethreshold float (dbar) 0.3 0–10 Minimum pressure in decibars to transition from AB-retract state to Descend.

Anchoring & Deanchoring

These parameters tune the detection of bottom contact (anchoring) and departure from bottom (deanchoring).

Key Type Default Limits Description
deanchorjv int (JV) 150000 ±200000 Elmo jog velocity used during deanchoring.
deanchorvelocitylimit float (dbar/s) 0.05 -1–1 Minimum upward pressure velocity (dbar/s) to consider the float deanchored.
deanchorpressureminimum float (dbar) 5.0 0.1–10 Minimum pressure change from the anchored position before deanchoring is tested.
deanchorpressurecountthreshold int 10 1–200 Number of consecutive samples meeting deanchor criteria before declaring deanchored.
anchorpressurecountthreshold int 4 1–200 Number of consecutive samples meeting anchor criteria before declaring anchored.
anchorpressureminimum float (dbar) 4.0 0–10 Minimum pressure at which anchoring detection is active.
anchorvelocitylimit float (dbar/s) 0.025 -1–1 Maximum vertical velocity when determining the float has reached bottom. Saved to 4 decimal places.
exitanchorpressurethreshold float (dbar) 5.0 1–10 Maximum tolerated pressure change between sensor updates while anchored. Used to confirm stable bottom contact.
approachvelocity float (dbar/s) 0.01 -1–1 Target vertical velocity when approaching a depth setpoint.

CTD (SBE41)

Key Type Default Limits Description
sbe41commandmodesampleperiod int (ms) 3000 2600–60000 Sample period for the SBE41 in command/sample mode, in milliseconds.
sbe41cpsampleperiod int (ms) 1000 1000–3000 Sample period for the SBE41 in continuous profile (CP) mode, in milliseconds.
cpmode int 1 0 or 1 Enables (1) or disables (0) CP mode during the Ascend state.
cppressurecutoff float (dbar) 1.0 1–20 CP mode stops sampling below this pressure.
cprunpumptime int (sec) 2 0–1200 Seconds to run the pump before starting CP mode to flush the CTD.

Mission Parameters

Key Type Default Limits Description
missionparkdepth float (dbar) 150.0 0–150 Target parking depth in decibars.
missionparktimehours int (hrs) 2 0–100 Hours component of the park duration. Used together with missionparktimeminutes.
missionparktimeminutes int (min) 0 0–1000 Minutes component of the park duration.
missionparksampleperiodminutes int (min) 120 0–1000 Time between instrument samples while parked.
missiondurationhours int (hrs) 2 0–1000 Maximum total mission duration in hours. The mission ends when this is exceeded.
missionmaxprofiles int 100 0–1000 Maximum number of profiles to complete before ending the mission.1

Sleep / Wake Persistence

These items are written automatically by the firmware before sleeping and read back on wake-up to resume the mission. Do not edit these manually unless you know what you are doing. The resetprofile factory mode command resets them all to their defaults.

Key Type Description
laststate int Integer value of the CPFStates enum for the state active when the system slept. 0 = SMNotRunning (clean start).
lastprofilenum int Profile number that was active when the system slept.
lastdatadir string Path to the working data directory at the time of sleep, e.g. \SD\CPF003_001.
lastparkstarttime long DateTime.Ticks value recorded when the park phase began. Used to calculate remaining park time on wake.
nextwakeuptime long DateTime.Ticks value of the scheduled next wake-up.
missionstarttime long DateTime.Ticks value recorded when the mission was started. Used to track total mission elapsed time.

Default Values

The following defaults are set by SystemConfigManager.CreateStandardConfig() when no config file is present:

platformname             = CPF003
engrloggerverbositylevel = 4
debuggerverbositylevel   = 4
systemdatasampleperiod   = 10 sec
premissiondelayperiod    = 30 sec
stringpotinverseslope    = 7668560.96
stringpotintercept       = 18.706119
bellowslowerlimit        = 3.0 %
bellowsupperlimit        = 97.0 %
sosetbellowsposition     = 45.0 %
sosetbellowsjv           = 200000
rmsetbellowsposition     = 5.0 %
abretractfastjv          = 200000
abretractslowjv          = 200000
abpressurethreshold      = 0.3 dbar
deanchorjv               = 150000
deanchorvelocitylimit    = 0.05 dbar/s
deanchorpressureminimum  = 5.0 dbar
deanchorpressurecountthreshold = 10
anchorpressurecountthreshold   = 4
anchorpressureminimum    = 4.0 dbar
anchorvelocitylimit      = 0.025 dbar/s
exitanchorpressurethreshold    = 5.0 dbar
approachvelocity         = 0.01 dbar/s
cppressurecutoff         = 1.0 dbar
cprunpumptime            = 2 sec
cpmode                   = 1 (enabled)
sbe41commandmodesampleperiod   = 3000 ms
sbe41cpsampleperiod      = 1000 ms
missionparkdepth         = 150 dbar
missionparktimehours     = 2
missionparktimeminutes   = 0
missionparksampleperiodminutes = 120
missiondurationhours     = 2
missionmaxprofiles       = 100

  1. missionmaxprofiles is written to the config file but is not currently parsed on load (no matching case in MissionConfig.Set()). It takes effect only via BTConsole console commands at runtime.