##// END OF EJS Templates
ASM_F1 and ASM_F2 displays added to lfrsgse
ASM_F1 and ASM_F2 displays added to lfrsgse

File last commit:

r69:d8815b251eb0 default
r75:be11db85f112 default
Show More
entermode.cpp
311 lines | 12.2 KiB | text/x-c | CppLexer
#include "entermode.h"
EnterMode::EnterMode(QWidget *parent) :
QWidget(parent)
{
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 );
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"));
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"));
mainLayout = new QGridLayout();
overallLayout = new QGridLayout();
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();
groupBox = new QGroupBox(tr("ENTER_MODE"));
groupBox_updateTime = new QGroupBox(tr("UPDATE_TIME"));
groupBox_otherTC = new QGroupBox(tr("OTHER TC"));
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);
mainLayout->setColumnStretch(1, 1);
mainLayout->setRowStretch(8, 1);
groupBox->setLayout(mainLayout);
groupBox_otherTC->setLayout(layout_otherTC);
groupBox_updateTime->setLayout(layout_updateTime);
paulCommonCRC = new PaulCommonCRC();
connect(this->button_reset, SIGNAL(clicked()), this, SLOT(sendReset()));
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()));
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()));
overallLayout->addWidget(groupBox, 0, 0, 1, 1);
overallLayout->addWidget(groupBox_updateTime, 1, 0, 1, 1);
overallLayout->addWidget(groupBox_otherTC, 2, 0, 1, 1);
this->setLayout(overallLayout);
}
void EnterMode::sendEnterMode( unsigned char mode)
{
Packet_TC_LFR_ENTER_MODE_t packet;
unsigned char crcAsTwoBytes[2];
setTimeToSend(); // the time depends on the radio buttons selection
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_TC_RPW_INTERNAL;
packet.spare = 0x00;
packet.mode = mode;
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);
packet.enterModeTime[4] = 0x00;
packet.enterModeTime[5] = 0x00;
paulCommonCRC->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 );
}
void EnterMode::enterModeBurst()
{
sendEnterMode( 2 );
}
void EnterMode::enterModeSBM1()
{
sendEnterMode( 3 );
}
void EnterMode::enterModeSBM2()
{
sendEnterMode( 4 );
}
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_TC_RPW_INTERNAL;
paulCommonCRC->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_TC_RPW_INTERNAL;
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;
paulCommonCRC->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_TC_RPW_INTERNAL;
paulCommonCRC->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_TC_RPW_INTERNAL;
paulCommonCRC->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);
}
void EnterMode::lastTMTimeHasChanged( unsigned int lastTime )
{
lastTMTime = lastTime;
label_lastTMTime->setText("last TM coarse time:\n" + QString::number(lastTMTime, 16));
}
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;
}