FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
SensorCtd Class Reference
+ Inheritance diagram for SensorCtd:
+ Collaboration diagram for SensorCtd:

Classes

struct  Channel
 The instrument imperfections of one measured channel. More...
 
struct  Reading
 One held instrument reading. More...
 
struct  Settings
 Everything that makes one instrument out of the shared sensor machinery. More...
 

Public Member Functions

 SensorCtd (std::string simObjectName, ISimObjectCreator *creator)
 
 SensorCtd (std::string simObjectName, const Settings &settings)
 
void OdeFcn (const double dT, const double *const adX, double *const adXDot) const override
 Writes the three lag derivatives and nothing else.
 
void AcceptedStep (const double dT, const double *const adX) override
 
void InitialConditionSetup (const double dT, const double *const adCurrentIC, double *const adUpdatedIC, ISimObjectCreator *const creator) override
 
void FinalSetup (const double dT, const double *const adX, ISimObjectCreator *const creator) override
 
bool SampleIfDue (double t, double temperature, double salinity, double depth, const double position[3])
 
void Update (double temperature, double salinity, double depth, const double position[3])
 
const ReadingHeldReading () const
 The reading currently held on the output ports.
 
const SettingsGetSettings () const
 The settings the instrument was built with.
 
double NextSampleTime () const
 The time at which the next sample is due, s.
 

Static Public Member Functions

static double LagDerivative (double fieldValue, double lagState, double timeConstant)
 
static double MeasuredValueOf (double lagState, double fieldValue, double timeConstant)
 
static double Quantize (double value, double resolution)
 
static double PressureOf (double depth)
 
static double Perturb (double trueValue, const Channel &channel, SensorNoise &noise)
 

Protected Member Functions

const double * OutTemperature (const double dT, const double *const adX)
 The measured water temperature, degC.
 
const double * OutSalinity (const double dT, const double *const adX)
 The measured salinity, PSU.
 
const double * OutDepth (const double dT, const double *const adX)
 The measured depth of the sensor head, m.
 
const double * OutPressure (const double dT, const double *const adX)
 The measured pressure, dbar.
 
const double * OutMeasurement (const double dT, const double *const adX)
 The three measurements as [Salinity, Temperature, Depth].
 
const double * OutPosition (const double dT, const double *const adX)
 The NED position the held sample was taken at, m.
 

Constructor & Destructor Documentation

◆ SensorCtd() [1/2]

SensorCtd::SensorCtd ( std::string  simObjectName,
ISimObjectCreator *  creator 
)

Constructs the sensor from the simulation input file.

Parameters
simObjectNameThe name of this object in the simulation.
creatorThe creator of this object.

◆ SensorCtd() [2/2]

SensorCtd::SensorCtd ( std::string  simObjectName,
const Settings settings 
)

Constructs the sensor with its settings given directly.

No ports and no states are registered, so OdeFcn, AcceptedStep and InitialConditionSetup all do nothing and the instrument must be driven through SampleIfDue or Update instead. This constructor exists so that the sampling and the imperfection model can be unit tested without a host simulation, which matters because ISimObjectCreator has some thirty pure virtuals and FhSim exports no mock.

Parameters
simObjectNameThe name of this object.
settingsThe instrument settings.

Member Function Documentation

◆ AcceptedStep()

void SensorCtd::AcceptedStep ( const double  dT,
const double *const  adX 
)
override

Takes any samples that have fallen due since the previous accepted step.

Parameters
dTThe current simulation time, s.
adXThe state vector.

◆ FinalSetup()

void SensorCtd::FinalSetup ( const double  dT,
const double *const  adX,
ISimObjectCreator *const  creator 
)
override

Resolves the environment and the two scalar field handles.

Parameters
dTThe initial simulation time, s.
adXThe state vector.
creatorThe creator of this object.

◆ InitialConditionSetup()

void SensorCtd::InitialConditionSetup ( const double  dT,
const double *const  adCurrentIC,
double *const  adUpdatedIC,
ISimObjectCreator *const  creator 
)
override

Seeds the three lag states with the field values at the start position.

Parameters
dTThe initial simulation time, s.
adCurrentICThe initial conditions known so far.
adUpdatedICThe initial conditions this object can supply.
creatorThe creator of this object.

◆ LagDerivative()

static double SensorCtd::LagDerivative ( double  fieldValue,
double  lagState,
double  timeConstant 
)
static

The derivative of one first-order instrument lag.

Parameters
fieldValueThe value of the field at the sensor head.
lagStateThe current lagged value.
timeConstantThe lag time constant, s. Zero or less means no lag.
Returns
The state derivative, which is zero when there is no lag.

◆ MeasuredValueOf()

static double SensorCtd::MeasuredValueOf ( double  lagState,
double  fieldValue,
double  timeConstant 
)
static

Picks the value a channel measures, which bypasses the state when there is no lag.

Parameters
lagStateThe current lagged value.
fieldValueThe value of the field at the sensor head.
timeConstantThe lag time constant, s.
Returns
The lagged value, or the field value when the time constant is zero.

◆ Perturb()

static double SensorCtd::Perturb ( double  trueValue,
const Channel channel,
SensorNoise noise 
)
static

Applies one channel's bias, noise and quantisation.

Parameters
trueValueThe lagged, true value.
channelThe channel's imperfections.
noiseThe random generator; a deterministic one leaves the value alone.
Returns
The value the instrument reports.

◆ PressureOf()

static double SensorCtd::PressureOf ( double  depth)
static

Converts a depth to the nominal pressure this class reports.

Parameters
depthThe depth below the mean water level, m.
Returns
The pressure, dbar.

◆ Quantize()

static double SensorCtd::Quantize ( double  value,
double  resolution 
)
static

Rounds a value to a multiple of a quantisation step.

Parameters
valueThe value to quantise.
resolutionThe quantisation step. Zero or less leaves the value alone.
Returns
The quantised value.

◆ SampleIfDue()

bool SensorCtd::SampleIfDue ( double  t,
double  temperature,
double  salinity,
double  depth,
const double  position[3] 
)

Takes every sample that is due at a time, and holds the last one.

Parameters
tThe current simulation time, s.
temperatureThe lagged temperature at the sensor head, degC.
salinityThe lagged salinity at the sensor head, PSU.
depthThe lagged depth of the sensor head, m.
positionThe NED position of the sensor head, m.
Returns
True when at least one sample was taken, so the held reading changed.

◆ Update()

void SensorCtd::Update ( double  temperature,
double  salinity,
double  depth,
const double  position[3] 
)

Takes one sample unconditionally, applying the bias, the noise and the quantisation.

Parameters
temperatureThe lagged temperature at the sensor head, degC.
salinityThe lagged salinity at the sensor head, PSU.
depthThe lagged depth of the sensor head, m.
positionThe NED position of the sensor head, m.

The documentation for this class was generated from the following file: