entermode.cpp
270 lines
| 10.5 KiB
| text/x-c
|
CppLexer
/ rmapplugin / entermode.cpp
r46 | #include "entermode.h" | |||
EnterMode::EnterMode(QWidget *parent) : | ||||
QWidget(parent) | ||||
{ | ||||
button_enterModeStandby = new QPushButton(tr("STANDBY")); | ||||
button_enterModeNormal = new QPushButton(tr("NORMAL")); | ||||
button_enterModeBurst = new QPushButton(tr("BURST")); | ||||
button_enterModeSBM1 = new QPushButton(tr("SBM1")); | ||||
button_enterModeSBM2 = new QPushButton(tr("SBM2")); | ||||
r50 | button_reset = new QPushButton(tr("RESET")); | |||
button_updateInfo = new QPushButton(tr("UPDATE_INFO")); | ||||
button_enableCalibration = new QPushButton(tr("ENABLE_CAL")); | ||||
button_disableCalibration = new QPushButton(tr("DISABLE_CAL")); | ||||
button_updateTime = new QPushButton(tr("UPDATE_TIME")); | ||||
r46 | mainLayout = new QGridLayout(); | |||
overallLayout = new QGridLayout(); | ||||
r50 | layout_updateTime = new QVBoxLayout(); | |||
layout_otherTC = new QVBoxLayout(); | ||||
arbitraryTime = new ArbitraryTime(0); | ||||
layout_otherTC->addWidget(button_reset); | ||||
layout_otherTC->addWidget(button_updateInfo); | ||||
layout_otherTC->addWidget(button_enableCalibration); | ||||
layout_otherTC->addWidget(button_disableCalibration); | ||||
layout_otherTC->addStretch(); | ||||
layout_updateTime->addWidget(button_updateTime); | ||||
layout_updateTime->addWidget(arbitraryTime); | ||||
layout_updateTime->addStretch(); | ||||
r46 | groupBox = new QGroupBox(tr("ENTER_MODE")); | |||
r50 | groupBox_updateTime = new QGroupBox(tr("UPDATE_TIME")); | |||
groupBox_otherTC = new QGroupBox(tr("OTHER TC")); | ||||
r46 | ||||
mainLayout->addWidget(button_enterModeStandby, 0, 0, 1, 1); | ||||
mainLayout->addWidget(button_enterModeNormal, 1, 0, 1, 1); | ||||
mainLayout->addWidget(button_enterModeBurst, 2, 0, 1, 1); | ||||
mainLayout->addWidget(button_enterModeSBM1, 3, 0, 1, 1); | ||||
mainLayout->addWidget(button_enterModeSBM2, 4, 0, 1, 1); | ||||
mainLayout->setColumnStretch(1, 1); | ||||
mainLayout->setRowStretch(5, 1); | ||||
groupBox->setLayout(mainLayout); | ||||
r50 | groupBox_otherTC->setLayout(layout_otherTC); | |||
groupBox_updateTime->setLayout(layout_updateTime); | ||||
r46 | ||||
parameterDump = new ParameterDump(); | ||||
r50 | connect(this->button_reset, SIGNAL(clicked()), this, SLOT(sendReset())); | |||
r46 | connect(this->button_enterModeStandby, SIGNAL(clicked()), this, SLOT(enterModeStandby())); | |||
connect(this->button_enterModeNormal, SIGNAL(clicked()), this, SLOT(enterModeNormal())); | ||||
connect(this->button_enterModeBurst, SIGNAL(clicked()), this, SLOT(enterModeBurst())); | ||||
connect(this->button_enterModeSBM1, SIGNAL(clicked()), this, SLOT(enterModeSBM1())); | ||||
connect(this->button_enterModeSBM2, SIGNAL(clicked()), this, SLOT(enterModeSBM2())); | ||||
r50 | connect(this->button_updateInfo, SIGNAL(clicked()), this, SLOT(sendUpdateInfo())); | |||
connect(this->button_enableCalibration, SIGNAL(clicked()), this, SLOT(sendEnableCalibration())); | ||||
connect(this->button_disableCalibration, SIGNAL(clicked()), this, SLOT(sendDisableCalibration())); | ||||
connect(this->button_updateTime, SIGNAL(clicked()), this->arbitraryTime, SLOT(sendCurrentTimeToSend())); | ||||
r46 | overallLayout->addWidget(groupBox, 0, 0, 1, 1); | |||
r50 | overallLayout->addWidget(groupBox_updateTime, 1, 0, 1, 1); | |||
overallLayout->addWidget(groupBox_otherTC, 2, 0, 1, 1); | ||||
r46 | ||||
this->setLayout(overallLayout); | ||||
} | ||||
void EnterMode::sendEnterMode( unsigned char mode) | ||||
{ | ||||
Packet_TC_LFR_ENTER_MODE_t packet; | ||||
unsigned char crcAsTwoBytes[2]; | ||||
packet.packetID[0] = (unsigned char) (TC_LFR_PACKET_ID >> 8); | ||||
packet.packetID[1] = (unsigned char) (TC_LFR_PACKET_ID ); | ||||
packet.packetSequenceControl[0] = (unsigned char) (TC_LFR_PACKET_SEQUENCE_CONTROL >> 8); | ||||
packet.packetSequenceControl[1] = (unsigned char) (TC_LFR_PACKET_SEQUENCE_CONTROL ); | ||||
packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_LFR_ENTER_MODE >> 8); | ||||
packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_LFR_ENTER_MODE ); | ||||
packet.ccsdsSecHeaderFlag_pusVersion_ack = 0x19; | ||||
packet.serviceType = TC_TYPE_DEFAULT; | ||||
packet.serviceSubType = TC_SUBTYPE_ENTER_MODE; | ||||
packet.sourceID = SID_DEFAULT; | ||||
packet.spare = 0x00; | ||||
packet.mode = mode; | ||||
packet.enterModeTime[0] = 0x00; | ||||
packet.enterModeTime[1] = 0x00; | ||||
packet.enterModeTime[2] = 0x00; | ||||
packet.enterModeTime[3] = 0x00; | ||||
packet.enterModeTime[4] = 0x00; | ||||
packet.enterModeTime[5] = 0x00; | ||||
parameterDump->GetCRCAsTwoBytes((unsigned char*) &packet, crcAsTwoBytes, | ||||
PACKET_LENGTH_TC_LFR_ENTER_MODE + CCSDS_TC_TM_PACKET_OFFSET - 2); | ||||
packet.crc[0] = crcAsTwoBytes[0]; | ||||
packet.crc[1] = crcAsTwoBytes[1]; | ||||
emit WriteSPWSig((char*) &packet, PACKET_LENGTH_TC_LFR_ENTER_MODE + CCSDS_TC_TM_PACKET_OFFSET, | ||||
CCSDS_NODE_ADDRESS, CCSDS_USER_APP); | ||||
} | ||||
void EnterMode::enterModeStandby() | ||||
{ | ||||
sendEnterMode( 0 ); | ||||
} | ||||
void EnterMode::enterModeNormal() | ||||
{ | ||||
sendEnterMode( 1 ); | ||||
} | ||||
r50 | ||||
r46 | void EnterMode::enterModeBurst() | |||
{ | ||||
sendEnterMode( 2 ); | ||||
} | ||||
r50 | ||||
r46 | void EnterMode::enterModeSBM1() | |||
{ | ||||
sendEnterMode( 3 ); | ||||
} | ||||
r50 | ||||
r46 | void EnterMode::enterModeSBM2() | |||
{ | ||||
sendEnterMode( 4 ); | ||||
} | ||||
r50 | ||||
void EnterMode::sendReset() | ||||
{ | ||||
Packet_TC_LFR_RESET_t packet; | ||||
unsigned char crcAsTwoBytes[2]; | ||||
packet.packetID[0] = (unsigned char) (TC_LFR_PACKET_ID >> 8); | ||||
packet.packetID[1] = (unsigned char) (TC_LFR_PACKET_ID ); | ||||
packet.packetSequenceControl[0] = (unsigned char) (TC_LFR_PACKET_SEQUENCE_CONTROL >> 8); | ||||
packet.packetSequenceControl[1] = (unsigned char) (TC_LFR_PACKET_SEQUENCE_CONTROL ); | ||||
packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_LFR_RESET >> 8); | ||||
packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_LFR_RESET ); | ||||
packet.ccsdsSecHeaderFlag_pusVersion_ack = 0x19; | ||||
packet.serviceType = TC_TYPE_DEFAULT; | ||||
packet.serviceSubType = TC_SUBTYPE_RESET; | ||||
packet.sourceID = SID_DEFAULT; | ||||
parameterDump->GetCRCAsTwoBytes((unsigned char*) &packet, crcAsTwoBytes, | ||||
PACKET_LENGTH_TC_LFR_RESET + CCSDS_TC_TM_PACKET_OFFSET - 2); | ||||
packet.crc[0] = crcAsTwoBytes[0]; | ||||
packet.crc[1] = crcAsTwoBytes[1]; | ||||
emit WriteSPWSig((char*) &packet, PACKET_LENGTH_TC_LFR_RESET + CCSDS_TC_TM_PACKET_OFFSET, | ||||
CCSDS_NODE_ADDRESS, CCSDS_USER_APP); | ||||
} | ||||
void EnterMode::sendUpdateInfo() | ||||
{ | ||||
Packet_TC_LFR_UPDATE_INFO_t packet; | ||||
unsigned char crcAsTwoBytes[2]; | ||||
packet.packetID[0] = (unsigned char) (TC_LFR_PACKET_ID >> 8); | ||||
packet.packetID[1] = (unsigned char) (TC_LFR_PACKET_ID ); | ||||
packet.packetSequenceControl[0] = (unsigned char) (TC_LFR_PACKET_SEQUENCE_CONTROL >> 8); | ||||
packet.packetSequenceControl[1] = (unsigned char) (TC_LFR_PACKET_SEQUENCE_CONTROL ); | ||||
packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_LFR_UPDATE_INFO >> 8); | ||||
packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_LFR_UPDATE_INFO ); | ||||
packet.ccsdsSecHeaderFlag_pusVersion_ack = 0x19; | ||||
packet.serviceType = TC_TYPE_DEFAULT; | ||||
packet.serviceSubType = TC_SUBTYPE_UPDATE_INFO; | ||||
packet.sourceID = SID_DEFAULT; | ||||
packet.set1 = 0x00; | ||||
packet.set2 = 0x00; | ||||
packet.set3_bias_setting_set1[0] = 0x00; | ||||
packet.set3_bias_setting_set1[1] = 0x00; | ||||
packet.set3_bias_setting_set1[2] = 0x00; | ||||
packet.set3_bias_setting_set1[3] = 0x00; | ||||
packet.set3_bias_setting_set1[4] = 0x00; | ||||
packet.set3_bias_setting_set2[5] = 0x00; | ||||
packet.set3_bias_voltage[0] = 0x00; | ||||
packet.set3_bias_voltage[1] = 0x00; | ||||
packet.set3_bias_voltage[2] = 0x00; | ||||
packet.set3_bias_voltage[3] = 0x00; | ||||
packet.set4[0] = 0x00; | ||||
packet.set4[1] = 0x00; | ||||
packet.set4[2] = 0x00; | ||||
packet.set4[3] = 0x00; | ||||
packet.set4[4] = 0x00; | ||||
packet.set4[5] = 0x00; | ||||
packet.set4[6] = 0x00; | ||||
packet.set4[7] = 0x00; | ||||
packet.set5 = 0x00; | ||||
packet.set6 = 0x00; | ||||
packet.set7[0] = 0x00; | ||||
packet.set7[1] = 0x00; | ||||
packet.set7[2] = 0x00; | ||||
packet.set7[3] = 0x00; | ||||
packet.set7[4] = 0x00; | ||||
packet.set7[5] = 0x00; | ||||
packet.set7[6] = 0x00; | ||||
packet.set7[7] = 0x00; | ||||
parameterDump->GetCRCAsTwoBytes((unsigned char*) &packet, crcAsTwoBytes, | ||||
PACKET_LENGTH_TC_LFR_UPDATE_INFO + CCSDS_TC_TM_PACKET_OFFSET - 2); | ||||
packet.crc[0] = crcAsTwoBytes[0]; | ||||
packet.crc[1] = crcAsTwoBytes[1]; | ||||
emit WriteSPWSig((char*) &packet, PACKET_LENGTH_TC_LFR_UPDATE_INFO + CCSDS_TC_TM_PACKET_OFFSET, | ||||
CCSDS_NODE_ADDRESS, CCSDS_USER_APP); | ||||
} | ||||
void EnterMode::sendEnableCalibration() | ||||
{ | ||||
Packet_TC_LFR_ENABLE_DISABLE_CALIBRATION_t packet; | ||||
unsigned char crcAsTwoBytes[2]; | ||||
packet.packetID[0] = (unsigned char) (TC_LFR_PACKET_ID >> 8); | ||||
packet.packetID[1] = (unsigned char) (TC_LFR_PACKET_ID ); | ||||
packet.packetSequenceControl[0] = (unsigned char) (TC_LFR_PACKET_SEQUENCE_CONTROL >> 8); | ||||
packet.packetSequenceControl[1] = (unsigned char) (TC_LFR_PACKET_SEQUENCE_CONTROL ); | ||||
packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_LFR_ENABLE_CALIBRATION >> 8); | ||||
packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_LFR_ENABLE_CALIBRATION ); | ||||
packet.ccsdsSecHeaderFlag_pusVersion_ack = 0x19; | ||||
packet.serviceType = TC_TYPE_DEFAULT; | ||||
packet.serviceSubType = TC_SUBTYPE_ENABLE_CALIBRATION; | ||||
packet.sourceID = SID_DEFAULT; | ||||
parameterDump->GetCRCAsTwoBytes((unsigned char*) &packet, crcAsTwoBytes, | ||||
PACKET_LENGTH_TC_LFR_ENABLE_CALIBRATION + CCSDS_TC_TM_PACKET_OFFSET - 2); | ||||
packet.crc[0] = crcAsTwoBytes[0]; | ||||
packet.crc[1] = crcAsTwoBytes[1]; | ||||
emit WriteSPWSig((char*) &packet, PACKET_LENGTH_TC_LFR_ENABLE_CALIBRATION + CCSDS_TC_TM_PACKET_OFFSET, | ||||
CCSDS_NODE_ADDRESS, CCSDS_USER_APP); | ||||
} | ||||
void EnterMode::sendDisableCalibration() | ||||
{ | ||||
Packet_TC_LFR_ENABLE_DISABLE_CALIBRATION_t packet; | ||||
unsigned char crcAsTwoBytes[2]; | ||||
packet.packetID[0] = (unsigned char) (TC_LFR_PACKET_ID >> 8); | ||||
packet.packetID[1] = (unsigned char) (TC_LFR_PACKET_ID ); | ||||
packet.packetSequenceControl[0] = (unsigned char) (TC_LFR_PACKET_SEQUENCE_CONTROL >> 8); | ||||
packet.packetSequenceControl[1] = (unsigned char) (TC_LFR_PACKET_SEQUENCE_CONTROL ); | ||||
packet.packetLength[0] = (unsigned char) (PACKET_LENGTH_TC_LFR_DISABLE_CALIBRATION >> 8); | ||||
packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_LFR_DISABLE_CALIBRATION ); | ||||
packet.ccsdsSecHeaderFlag_pusVersion_ack = 0x19; | ||||
packet.serviceType = TC_TYPE_DEFAULT; | ||||
packet.serviceSubType = TC_SUBTYPE_DISABLE_CALIBRATION; | ||||
packet.sourceID = SID_DEFAULT; | ||||
parameterDump->GetCRCAsTwoBytes((unsigned char*) &packet, crcAsTwoBytes, | ||||
PACKET_LENGTH_TC_LFR_DISABLE_CALIBRATION + CCSDS_TC_TM_PACKET_OFFSET - 2); | ||||
packet.crc[0] = crcAsTwoBytes[0]; | ||||
packet.crc[1] = crcAsTwoBytes[1]; | ||||
emit WriteSPWSig((char*) &packet, PACKET_LENGTH_TC_LFR_DISABLE_CALIBRATION + CCSDS_TC_TM_PACKET_OFFSET, | ||||
CCSDS_NODE_ADDRESS, CCSDS_USER_APP); | ||||
} | ||||