entermode.cpp
311 lines
| 12.2 KiB
| text/x-c
|
CppLexer
/ rmapplugin / entermode.cpp
r46 | #include "entermode.h" | |||
EnterMode::EnterMode(QWidget *parent) : | ||||
QWidget(parent) | ||||
{ | ||||
r62 | lastTMTime = 0x80000000; | |||
timeToSend = 0xffffffff; | ||||
label_lastTMTime = new QLabel(tr("last TM coarse time:\n-")); | ||||
radio_minus1 = new QRadioButton("-1"); | ||||
radio_plus0 = new QRadioButton("+0"); | ||||
radio_plus1 = new QRadioButton("+1"); | ||||
radio_plus2 = new QRadioButton("+2"); | ||||
radio_plus3 = new QRadioButton("+3"); | ||||
radio_plus4 = new QRadioButton("+4"); | ||||
radio_plus1->setChecked( true ); | ||||
r46 | 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(); | ||||
r57 | // arbitraryTime = new ArbitraryTime(0); | |||
r50 | ||||
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); | ||||
r57 | // layout_updateTime->addWidget(arbitraryTime); | |||
r50 | 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 | ||||
r62 | mainLayout->addWidget(button_enterModeStandby, 0, 0, 1, 3); | |||
mainLayout->addWidget(button_enterModeNormal, 1, 0, 1, 3); | ||||
mainLayout->addWidget(button_enterModeBurst, 2, 0, 1, 3); | ||||
mainLayout->addWidget(button_enterModeSBM1, 3, 0, 1, 3); | ||||
mainLayout->addWidget(button_enterModeSBM2, 4, 0, 1, 3); | ||||
mainLayout->addWidget(label_lastTMTime, 5, 0, 1, 3); | ||||
mainLayout->addWidget(radio_minus1, 6, 0, 1, 1); | ||||
mainLayout->addWidget(radio_plus0, 6, 1, 1, 1); | ||||
mainLayout->addWidget(radio_plus1, 6, 2, 1, 1); | ||||
mainLayout->addWidget(radio_plus2, 7, 0, 1, 1); | ||||
mainLayout->addWidget(radio_plus3, 7, 1, 1, 1); | ||||
mainLayout->addWidget(radio_plus4, 7, 2, 1, 1); | ||||
r46 | ||||
mainLayout->setColumnStretch(1, 1); | ||||
r62 | mainLayout->setRowStretch(8, 1); | |||
r46 | ||||
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())); | ||||
r57 | // connect(this->button_updateTime, SIGNAL(clicked()), this->arbitraryTime, SLOT(sendCurrentTimeToSend())); | |||
r50 | ||||
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]; | ||||
r62 | setTimeToSend(); // the time depends on the radio buttons selection | |||
r46 | 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; | ||||
r61 | packet.sourceID = SID_TC_RPW_INTERNAL; | |||
r46 | packet.spare = 0x00; | |||
packet.mode = mode; | ||||
r62 | packet.enterModeTime[0] = (unsigned char) (timeToSend >> 24); | |||
packet.enterModeTime[1] = (unsigned char) (timeToSend >> 16); | ||||
packet.enterModeTime[2] = (unsigned char) (timeToSend >> 8); | ||||
packet.enterModeTime[3] = (unsigned char) (timeToSend); | ||||
r46 | 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; | ||||
r61 | packet.sourceID = SID_TC_RPW_INTERNAL; | |||
r50 | ||||
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; | ||||
r61 | packet.sourceID = SID_TC_RPW_INTERNAL; | |||
r50 | ||||
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; | ||||
r61 | packet.sourceID = SID_TC_RPW_INTERNAL; | |||
r50 | ||||
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; | ||||
r61 | packet.sourceID = SID_TC_RPW_INTERNAL; | |||
r50 | ||||
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); | ||||
} | ||||
r62 | void EnterMode::lastTMTimeHasChanged( unsigned int lastTime ) | |||
{ | ||||
lastTMTime = lastTime; | ||||
label_lastTMTime->setText("last TM coarse time:\n" + QString::number(lastTMTime, 16)); | ||||
} | ||||
r50 | ||||
r62 | void EnterMode::setTimeToSend( ) | |||
{ | ||||
if (radio_minus1->isChecked()) | ||||
timeToSend = lastTMTime -1; | ||||
if (radio_plus0->isChecked()) | ||||
timeToSend = lastTMTime + 0; | ||||
if (radio_plus1->isChecked()) | ||||
timeToSend = lastTMTime + 1; | ||||
if (radio_plus2->isChecked()) | ||||
timeToSend = lastTMTime + 2; | ||||
if (radio_plus3->isChecked()) | ||||
timeToSend = lastTMTime + 3; | ||||
if (radio_plus4->isChecked()) | ||||
timeToSend = lastTMTime + 4; | ||||
} | ||||