arbitrarytime.cpp
80 lines
| 2.9 KiB
| text/x-c
|
CppLexer
/ paulcommon / arbitrarytime.cpp
r50 | #include "arbitrarytime.h" | |||
ArbitraryTime::ArbitraryTime(char option, QWidget *parent) : | ||||
QWidget(parent) | ||||
{ | ||||
QRegExp timeToSendRegExp("[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]"); | ||||
validator = new QRegExpValidator(timeToSendRegExp); | ||||
packetToSend = new TCPacketToSend(); | ||||
timeToSend = new QLineEdit(); | ||||
main_HLAYOUT = new QHBoxLayout; | ||||
main_VLAYOUT = new QVBoxLayout; | ||||
timeToSend_LABEL = new QLabel("Arbitrary Time: 0x"); | ||||
timeToSend_LABEL->setAlignment(Qt::AlignRight); | ||||
timeToSend->setMaxLength(8); | ||||
timeToSend->setValidator(validator); | ||||
timeToSend->setText("80000000"); | ||||
currentTimeToSend = 0x80000000; | ||||
if (option == 1) | ||||
{ | ||||
main_HLAYOUT->addWidget(timeToSend_LABEL); | ||||
main_HLAYOUT->addWidget(timeToSend); | ||||
main_HLAYOUT->addStretch(); | ||||
this->setLayout(main_HLAYOUT); | ||||
} | ||||
else | ||||
{ | ||||
main_VLAYOUT->addWidget(timeToSend_LABEL); | ||||
main_VLAYOUT->addWidget(timeToSend); | ||||
main_VLAYOUT->addStretch(); | ||||
this->setLayout(main_VLAYOUT); | ||||
} | ||||
connect(this->timeToSend, SIGNAL(editingFinished()), | ||||
this, SLOT(editingFinishedSLOT())); | ||||
} | ||||
void ArbitraryTime::editingFinishedSLOT() | ||||
{ | ||||
currentTimeToSend = timeToSend->text().toLong(0, 16); | ||||
emit ( | ||||
timeToSendChanged( currentTimeToSend) | ||||
); | ||||
} | ||||
void ArbitraryTime::sendCurrentTimeToSend() | ||||
{ | ||||
Packet_TC_LFR_UPDATE_TIME_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_TIME >> 8); | ||||
packet.packetLength[1] = (unsigned char) (PACKET_LENGTH_TC_LFR_UPDATE_TIME ); | ||||
packet.ccsdsSecHeaderFlag_pusVersion_ack = 0x19; | ||||
packet.serviceType = TC_TYPE_LFR_UPDATE_TIME; | ||||
packet.serviceSubType = TC_SUBTYPE_UPDATE_TIME; | ||||
packet.sourceID = SID_DEFAULT; | ||||
packet.cp_rpw_time[0] = (unsigned char) (currentTimeToSend >> 24); | ||||
packet.cp_rpw_time[1] = (unsigned char) (currentTimeToSend >> 16); | ||||
packet.cp_rpw_time[2] = (unsigned char) (currentTimeToSend >> 8); | ||||
packet.cp_rpw_time[3] = (unsigned char) (currentTimeToSend); | ||||
packet.cp_rpw_time[4] = 0; // fine time MSB | ||||
packet.cp_rpw_time[5] = 0; // fine time LSB | ||||
packetToSend->GetCRCAsTwoBytes((unsigned char*) &packet, crcAsTwoBytes, | ||||
PACKET_LENGTH_TC_LFR_UPDATE_TIME + CCSDS_TC_TM_PACKET_OFFSET - 2); | ||||
packet.crc[0] = crcAsTwoBytes[0]; | ||||
packet.crc[1] = crcAsTwoBytes[1]; | ||||
emit WriteSPW((char*) &packet, PACKET_LENGTH_TC_LFR_UPDATE_TIME + CCSDS_TC_TM_PACKET_OFFSET, | ||||
CCSDS_NODE_ADDRESS, CCSDS_USER_APP); | ||||
} | ||||