eive-obsw/mission/devices/devicedefinitions/IMTQHandlerDefinitions.h

209 lines
7.1 KiB
C
Raw Normal View History

2021-03-17 11:14:48 +01:00
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_IMTQDEFINITIONS_H_
#define MISSION_DEVICES_DEVICEDEFINITIONS_IMTQDEFINITIONS_H_
namespace IMTQ {
static const DeviceCommandId_t NONE = 0x0;
static const DeviceCommandId_t GET_ENG_HK_DATA = 0x1;
static const DeviceCommandId_t START_ACTUATION_DIPOLE = 0x2;
2021-04-25 15:53:44 +02:00
static const DeviceCommandId_t GET_COMMANDED_DIPOLE = 0x3;
2021-04-26 07:56:02 +02:00
/** Generates new measurement of the magnetic field */
static const DeviceCommandId_t START_MTM_MEASUREMENT = 0x4;
/** Requests the calibrated magnetometer measurement */
static const DeviceCommandId_t GET_CAL_MTM_MEASUREMENT = 0x5;
/** Requests the raw values measured by the built-in MTM XEN1210 */
static const DeviceCommandId_t GET_RAW_MTM_MEASUREMENT = 0x6;
2021-04-26 14:25:23 +02:00
static const DeviceCommandId_t SELF_TEST = 0x7;
2021-03-17 11:14:48 +01:00
static const uint8_t GET_TEMP_REPLY_SIZE = 2;
static const uint8_t CFGR_CMD_SIZE = 3;
static const uint8_t POINTER_REG_SIZE = 1;
static const uint32_t ENG_HK_DATA_SET_ID = GET_ENG_HK_DATA;
2021-04-26 07:56:02 +02:00
static const uint32_t CAL_MTM_SET = GET_CAL_MTM_MEASUREMENT;
2021-03-17 11:14:48 +01:00
static const uint8_t SIZE_ENG_HK_COMMAND = 1;
2021-04-25 15:53:44 +02:00
static const uint8_t SIZE_STATUS_REPLY = 2;
2021-03-17 11:14:48 +01:00
static const uint8_t SIZE_ENG_HK_DATA_REPLY = 24;
2021-04-25 15:53:44 +02:00
static const uint8_t SIZE_GET_COMMANDED_DIPOLE_REPLY = 8;
2021-04-26 07:56:02 +02:00
static const uint8_t SIZE_GET_CAL_MTM_MEASUREMENT = 15;
static const uint8_t SIZE_GET_RAW_MTM_MEASUREMENT = 15;
2021-03-17 11:14:48 +01:00
static const uint8_t MAX_REPLY_SIZE = SIZE_ENG_HK_DATA_REPLY;
static const uint8_t MAX_COMMAND_SIZE = 9;
2021-04-26 07:56:02 +02:00
static const uint8_t ENG_HK_SET_POOL_ENTRIES = 11;
static const uint8_t CAL_MTM_POOL_ENTRIES = 4;
2021-03-17 11:14:48 +01:00
/**
* Command code definitions. Each command or reply of an IMTQ request will begin with one of
* the following command codes.
*/
namespace CC {
2021-04-26 07:56:02 +02:00
static const uint8_t START_MTM_MEASUREMENT = 0x4;
2021-03-17 11:14:48 +01:00
static const uint8_t START_ACTUATION_DIPOLE = 0x6;
static const uint8_t SOFTWARE_RESET = 0xAA;
static const uint8_t GET_ENG_HK_DATA = 0x4A;
2021-04-25 15:53:44 +02:00
static const uint8_t GET_COMMANDED_DIPOLE = 0x46;
2021-04-26 07:56:02 +02:00
static const uint8_t GET_RAW_MTM_MEASUREMENT = 0x42;
static const uint8_t GET_CAL_MTM_MEASUREMENT = 0x43;
2021-03-17 11:14:48 +01:00
};
enum IMTQPoolIds: lp_id_t {
DIGITAL_VOLTAGE_MV,
ANALOG_VOLTAGE_MV,
2021-04-26 07:56:02 +02:00
DIGITAL_CURRENT,
ANALOG_CURRENT,
COIL_X_CURRENT,
COIL_Y_CURRENT,
COIL_Z_CURRENT,
2021-03-17 11:14:48 +01:00
COIL_X_TEMPERATURE,
COIL_Y_TEMPERATURE,
COIL_Z_TEMPERATURE,
2021-04-26 07:56:02 +02:00
MCU_TEMPERATURE,
MTM_CAL_X,
MTM_CAL_Y,
MTM_CAL_Z,
ACTUATION_CAL_STATUS,
MTM_RAW_X,
MTM_RAW_Y,
MTM_RAW_Z,
ACTUATION_RAW_STATUS
2021-03-17 11:14:48 +01:00
};
class EngHkDataset:
2021-04-26 07:56:02 +02:00
public StaticLocalDataSet<ENG_HK_SET_POOL_ENTRIES> {
2021-03-17 11:14:48 +01:00
public:
EngHkDataset(HasLocalDataPoolIF* owner):
StaticLocalDataSet(owner, ENG_HK_DATA_SET_ID) {
}
EngHkDataset(object_id_t objectId):
StaticLocalDataSet(sid_t(objectId, ENG_HK_DATA_SET_ID)) {
}
lp_var_t<uint16_t> digitalVoltageMv = lp_var_t<uint16_t>(sid.objectId,
DIGITAL_VOLTAGE_MV, this);
lp_var_t<uint16_t> analogVoltageMv = lp_var_t<uint16_t>(sid.objectId,
ANALOG_VOLTAGE_MV, this);
2021-04-26 07:56:02 +02:00
lp_var_t<float> digitalCurrentmA = lp_var_t<float>(sid.objectId,
DIGITAL_CURRENT, this);
lp_var_t<float> analogCurrentmA = lp_var_t<float>(sid.objectId,
ANALOG_CURRENT, this);
lp_var_t<float> coilXCurrentmA = lp_var_t<float>(sid.objectId,
COIL_X_CURRENT, this);
lp_var_t<float> coilYCurrentmA = lp_var_t<float>(sid.objectId,
COIL_Y_CURRENT, this);
lp_var_t<float> coilZCurrentmA = lp_var_t<float>(sid.objectId,
COIL_Z_CURRENT, this);
2021-03-17 11:14:48 +01:00
/** All temperatures in [<5B>C] */
lp_var_t<uint16_t> coilXTemperature = lp_var_t<uint16_t>(sid.objectId,
2021-03-26 12:30:24 +01:00
COIL_X_TEMPERATURE, this);
2021-03-17 11:14:48 +01:00
lp_var_t<uint16_t> coilYTemperature = lp_var_t<uint16_t>(sid.objectId,
COIL_Y_TEMPERATURE, this);
lp_var_t<uint16_t> coilZTemperature = lp_var_t<uint16_t>(sid.objectId,
COIL_Z_TEMPERATURE, this);
lp_var_t<uint16_t> mcuTemperature = lp_var_t<uint16_t>(sid.objectId,
MCU_TEMPERATURE, this);
};
2021-04-26 07:56:02 +02:00
/**
* @brief This dataset holds the raw MTM measurements.
*/
class CalibratedMtmMeasurementSet:
public StaticLocalDataSet<CAL_MTM_POOL_ENTRIES> {
public:
CalibratedMtmMeasurementSet(HasLocalDataPoolIF* owner):
StaticLocalDataSet(owner, CAL_MTM_SET) {
}
CalibratedMtmMeasurementSet(object_id_t objectId):
StaticLocalDataSet(sid_t(objectId, CAL_MTM_SET)) {
}
/** The unit of all measurements is nT */
lp_var_t<int32_t> mtmXnT = lp_var_t<int32_t>(sid.objectId,
MTM_CAL_X, this);
lp_var_t<int32_t> mtmYnT = lp_var_t<int32_t>(sid.objectId,
MTM_CAL_Y, this);
lp_var_t<int32_t> mtmZnT = lp_var_t<int32_t>(sid.objectId,
MTM_CAL_Z, this);
/** 1 if coils were actuating during measurement otherwise 0 */
lp_var_t<uint8_t> coilActuationStatus = lp_var_t<uint8_t>(sid.objectId,
ACTUATION_CAL_STATUS, this);
};
/**
* @brief This dataset holds the last calibrated MTM measurement.
*/
class RawMtmMeasurementSet:
public StaticLocalDataSet<CAL_MTM_POOL_ENTRIES> {
public:
RawMtmMeasurementSet(HasLocalDataPoolIF* owner):
StaticLocalDataSet(owner, CAL_MTM_SET) {
}
RawMtmMeasurementSet(object_id_t objectId):
StaticLocalDataSet(sid_t(objectId, CAL_MTM_SET)) {
}
/** The unit of all measurements is nT */
lp_var_t<float> mtmXnT = lp_var_t<float>(sid.objectId,
MTM_RAW_X, this);
lp_var_t<float> mtmYnT = lp_var_t<float>(sid.objectId,
MTM_RAW_Y, this);
lp_var_t<float> mtmZnT = lp_var_t<float>(sid.objectId,
MTM_RAW_Z, this);
/** 1 if coils were actuating during measurement otherwise 0 */
lp_var_t<uint8_t> coilActuationStatus = lp_var_t<uint8_t>(sid.objectId,
ACTUATION_RAW_STATUS, this);
};
2021-03-17 11:14:48 +01:00
/**
* @brief This class can be used to ease the generation of an action message commanding the
* IMTQHandler to configure the magnettorquer with the desired dipoles.
2021-03-19 15:33:43 +01:00
*
* @details Deserialize the packet, write the deserialized data to the ipc store and store the
* the ipc store address in the action message.
2021-03-17 11:14:48 +01:00
*/
class CommandDipolePacket : public SerialLinkedListAdapter<SerializeIF> {
public:
CommandDipolePacket() {
setLinks();
}
private:
2021-03-19 15:33:43 +01:00
/**
* @brief Constructor
*
* @param xDipole The dipole of the x coil in 10^-4*Am^2
* @param yDipole The dipole of the y coil in 10^-4*Am^2
* @param zDipole The dipole of the z coil in 10^-4*Am^2
* @param duration The duration in milliseconds the dipole will be generated by the coils.
* When set to 0, the dipole will be generated until a new dipole actuation
* command is sent.
*/
2021-03-26 13:55:32 +01:00
CommandDipolePacket(uint16_t xDipole, uint16_t yDipole, uint16_t zDipole, uint16_t duration) :
2021-03-19 15:33:43 +01:00
xDipole(xDipole), yDipole(yDipole), zDipole(zDipole), duration(duration) {
}
2021-03-17 11:14:48 +01:00
void setLinks() {
2021-03-19 15:33:43 +01:00
setStart(&xDipole);
xDipole.setNext(&yDipole);
yDipole.setNext(&zDipole);
zDipole.setNext(&duration);
2021-03-17 11:14:48 +01:00
}
2021-03-19 15:33:43 +01:00
SerializeElement<uint16_t> xDipole;
SerializeElement<uint16_t> yDipole;
SerializeElement<uint16_t> zDipole;
SerializeElement<uint16_t> duration;
2021-03-17 11:14:48 +01:00
};
}
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_IMTQDEFINITIONS_H_ */