Class LevelMeter5_4_VR_420Module

Inheritance Relationships

Base Type

Class Documentation

class LevelMeter5_4_VR_420Module : public Module

This class represents the 5 Level Meters Module connected via eMOD bus to controller module. This module is a four capacitive, Namur and PNP probes plus five resistive probes plus an analogic input with potentiometer plus an 4-20mA input.

Class example 1


Public Types

enum ResistiveSensorID

Values:

enumerator kResistiveSensor1
enumerator kResistiveSensor2
enumerator kResistiveSensor3
enumerator kResistiveSensor4
enumerator kResistiveSensor5
enum CurrentSensorID

Values:

enumerator kCurrentSensor1
enumerator kCurrentSensor2
enumerator kCurrentSensor3
enumerator kCurrentSensor4
enum PotentiometerID

Values:

enumerator kPotentiometer1
enum Input420ID

Values:

enumerator k420Input1
typedef void (*LevelMeter5_4_VR_420ModuleCallback_Type)(const uint8_t *data, uint16_t data_len, uint8_t id_function, void *ctx)

Callback function type, for the configOnNewDataEvent (see below).

Param meter_num

[in] sensor number, from 1 to 9, that triggers a new data event.

Param new_status

[in] new status from the meter_num sensor, indicating: 0 = sensor is not detecting; or 1 = sensor detection.

Public Functions

LevelMeter5_4_VR_420Module()
~LevelMeter5_4_VR_420Module()
EmodRet init(const LevelMeter5_4_VR_420ModuleCallback_Type callback_func = nullptr, void *callback_context = nullptr, const uint8_t variant = 1)

Initialize module. It is important to emphasize that it is mandatory to call this method and must be called always after instantiating the module. It can be called several times, each of which the module is initialized again.

Parameters
  • callback_func(optional) -- [in] function that will be called when a configured event occurs.

  • callback_context(optional) -- [in] context that will be passed to the callback function.

  • variant(optional) -- [in] identifies the module in case more than one module of the same type are present.

EmodRet init(const uint8_t variant)
EmodRet configResistiveSensorPolarity(const uint16_t sensor_mask, const uint8_t polarity)

Configures Resistive Sensor polarity.

Parameters
  • sensor_mask -- [in] resistive sensor mask to configure (one or many), as enumerated above in the constants section.

  • polarity -- [in] polarity;

EmodRet configCurrentSensorPolarity(const uint16_t sensor_mask, const uint8_t polarity)

Configures Current Sensor polarity.

Parameters
  • sensor_mask -- [in] current sensor mask to configure (one or many), as enumerated above in the constants section.

  • polarity -- [in] polarity to configure;

EmodRet configAllResistiveSensorPolarity(const uint8_t polarity)

Configures All Resistive Sensors with common polarity.

Parameters

polarity -- [in] polarity to configure;

EmodRet configAllCurrentSensorPolarity(const uint8_t polarity)

Configures All Current Sensors with common polarity.

Parameters

polarity -- [in] polarity to configure;

EmodRet getResistiveSensorPolarity(const ResistiveSensorID sensor, uint8_t *polarity)

Gets Resistive Sensor polarity.

Parameters
  • sensor -- [in] resistive sensor id to get polarity, as enumerated above in the constants section.

  • polarity -- [out] present polarity;

EmodRet getCurrentSensorPolarity(const CurrentSensorID sensor, uint8_t *polarity)

Gets Current Sensor polarity.

Parameters
  • sensor -- [in] current sensor id to get polarity, as enumerated above in the constants section.

  • polarity -- [out] present polarity;

EmodRet getAllResistiveSensorPolarity(uint8_t polarities[kNumberOfResistiveSensors])

Gets All Resistive Sensor polarities.

Parameters

polarities -- [out] array of length 5 containing the polarities of all resistive sensors;

EmodRet getAllCurrentSensorPolarity(uint8_t polarities[kNumberOfCurrentSensors])

Gets All Current Sensor polarities.

Parameters

polarities -- [out] array of length 4 containing the polarities of all resistive sensors;

EmodRet setResistiveSensorThreshold(const ResistiveSensorID sensor, const uint16_t detect_resistance, const uint16_t refill_resistance)

Configures the detection and refill resistance threshold for a resistive sensor.

Parameters
  • sensor -- [in] resistive sensor number to configure, as enumerated above in the constants section.

  • detect_resistance -- [in] below this low limit value, sensor is detecting the liquid presence.

  • refill_resistance -- [in] above this high limit value, sensor is detecting the liquid absence.

EmodRet setAllResistiveSensorThreshold(const uint16_t detect_resistance, const uint16_t refill_resistance)

Configures the detection and refill resistance threshold for all resistive sensors.

Parameters
  • detect_resistance -- [in] below this low limit value, sensor is detecting the liquid presence.

  • refill_resistance -- [in] above this high limit value, sensor is detecting the liquid absence.

EmodRet setResistiveSensorSensitivity(const ResistiveSensorID sensor, const uint16_t refill_resistance)

Configures the refill resistance threshold for a resistive sensor. The detection resistance is computed as the 50% of the refill resistance.

Parameters
  • sensor -- [in] resistive sensor number to configure, as enumerated above in the constants section.

  • refill_resistance -- [in] above this high limit value, sensor is detecting the liquid absence.

EmodRet setAllResistiveSensorSensitivity(const uint16_t refill_resistance)

Configures the refill resistance threshold for all resistive sensors. The detection resistance is computed as the 50% of the refill resistance.

Parameters

refill_resistance -- [in] above this high limit value, sensor is detecting the liquid absence.

EmodRet setCurrentSensorType(const CurrentSensorID sensor, const LevelMeterType type)

Configures the type of current sensor.

Parameters
  • sensor -- [in] current sensor number to configure, as enumerated above in the constants section.

  • type -- [in] can be Namur, Capacitive or PNP, as enumerated above in the constants section.

EmodRet setAllCurrentSensorType(const LevelMeterType type)

Configures the type of all current sensor.

Parameters

type -- [in] can be Namur, Capacitive or PNP, as enumerated above in the constants section.

EmodRet getResistiveLevelStatus(const ResistiveSensorID sensor, uint8_t *status)

Gets the status of a resistive sensor.

Parameters
  • sensor -- [in] resistive sensor number to get the status, as enumerated above in the constants section.

  • status -- [out] When 0 polarity 0 = sensor is detecting absence, 1 = sensor is detecting presence. When 1 polarity telling the opposite.

EmodRet getCurrentLevelStatus(const CurrentSensorID sensor, uint8_t *status)

Gets the status of a current sensor.

Parameters
  • sensor -- [in] current sensor number to get the status, as enumerated above in the constants section.

  • status -- [out] When 0 polarity 0 = sensor is detecting absence, 1 = sensor is detecting presence. When 1 polarity telling the opposite.

EmodRet getAllResistiveLevelStatus(uint8_t status[kNumberOfResistiveSensors])

Gets the status of all Resistive sensors.

Parameters

status -- [out] array of length 5. When 0 polarity 0 = sensor is detecting absence, 1 = sensor is detecting presence. When 1 polarity telling the opposite.

EmodRet getAllCurrentLevelStatus(uint8_t status[kNumberOfCurrentSensors])

Gets the status of all Current sensors.

Parameters

status -- [out] array of length 4. When 0 polarity 0 = sensor is detecting absence, 1 = sensor is detecting presence. When 1 polarity telling the opposite.

EmodRet getPotentiometerInput(uint16_t *data)

Gets the value of the Potentiometer Input in %.

Parameters

data -- [out] value ranging from 0 to 100.

EmodRet get420Input(uint16_t *data)

Gets the value of the 4-20 mA input.

Parameters

data -- [out] value ranging from 0 to 20000 µA.

EmodRet configEventOnNewData()

Configures module for calling init callback_func when new data arrives on any of its resistive or current sensors. We use 1 to 5 for resistive sensors and 6 to 9 for current sensors.

EmodRet configEventAtTimeIntervalLevel(const uint32_t time_interval)

Configures module for calling init callback_func at specified period.

Parameters

time_interval -- [in] period in milliseconds. Minimum value is 500ms.

EmodRet configEventWithinRangePotentiometer(const uint32_t low_limit, const uint32_t high_limit)

Configures module for calling init callback_func when input value enters the specified range.

Parameters
  • low_limit -- [in] low limit of the range in %.

  • high_limit -- [in] high limit of the range in %.

EmodRet configEventOutOfRangePotentiometer(const uint32_t low_limit, const uint32_t high_limit)

Configures module for calling init callback_func when input value gets out of the specified range.

Parameters
  • low_limit -- [in] low limit of the range in %.

  • high_limit -- [in] high limit of the range in %.

EmodRet configEventOnValueChangePotentiometer(const uint32_t threshold)

Configures module for calling init callback_func when input changes its value by a specified amount.

Parameters

threshold -- [in] amount of % that triggers the event.

EmodRet configEventAtTimeIntervalPotentiometer(const uint32_t time_interval)

Configures module for calling init callback_func at specified period.

Parameters

time_interval -- [in] period in milliseconds. Minimum value is 500ms.

EmodRet configEventWithinRange420(const uint32_t low_limit, const uint32_t high_limit)

Configures module for calling init callback_func when 4-20 input value enters the specified range.

Parameters
  • low_limit -- [in] low limit of the range in µA.

  • high_limit -- [in] high limit of the range in µA.

EmodRet configEventOutOfRange420(const uint32_t low_limit, const uint32_t high_limit)

Configures module for calling init callback_func when 4-20 input value gets out of the specified range.

Parameters
  • low_limit -- [in] low limit of the range in µA.

  • high_limit -- [in] high limit of the range in µA.

EmodRet configEventOnValueChange420(const uint32_t threshold)

Configures module for calling init callback_func when input changes its value by a specified amount.

Parameters

threshold -- [in] amount of mA that triggers the event.

EmodRet configEventAtTimeInterval420(const uint32_t time_interval)

Configures module for calling init callback_func at specified period.

Parameters

time_interval -- [in] period in milliseconds. Minimum value is 500ms.

EmodRet resetEventConfig(void)

Resets all previously configured events.

Public Static Attributes

static constexpr int kNumberOfResistiveSensors = 5
static constexpr int kNumberOfCurrentSensors = 4
static constexpr int kNumberOfPotentiometers = 1
static constexpr int kNumberOf420Inputs = 1
static constexpr uint16_t kMaxRefillResistance = 100
static constexpr uint16_t kMinDetectResistance = 1
static constexpr uint16_t kResistiveSensorAll = 0x001f
static constexpr uint16_t kCurrentSensorAll = 0x000f

Protected Functions

EmodRet initFunctions()
uint8_t getFunctionsOffsetId()

Protected Attributes

LevelMeterFunctions *level_meters_