@@ -1,6 +1,6 | |||
|
1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
|
2 | 2 | <!DOCTYPE QtCreatorProject> |
|
3 |
<!-- Written by Qt Creator 2.4.1, 2012-12-10T1 |
|
|
3 | <!-- Written by Qt Creator 2.4.1, 2012-12-10T15:32:54. --> | |
|
4 | 4 | <qtcreator> |
|
5 | 5 | <data> |
|
6 | 6 | <variable>ProjectExplorer.Project.ActiveTarget</variable> |
@@ -153,4 +153,3 unsigned int bridge::Read(unsigned int * | |||
|
153 | 153 | emit appendToLog(QString("*** STOP *** READ ")); |
|
154 | 154 | return count; |
|
155 | 155 | } |
|
156 |
@@ -14,10 +14,10 public: | |||
|
14 | 14 | ~bridge(); |
|
15 | 15 | unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0); |
|
16 | 16 | unsigned int Read(unsigned int *Value,unsigned int count,unsigned int address=0); |
|
17 | virtual unsigned int WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication); | |
|
17 | //virtual unsigned int WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication); | |
|
18 | 18 | virtual unsigned int WriteBLOCK(char *data,unsigned int nbBytes,unsigned int address=0) = 0; |
|
19 | 19 | virtual unsigned int ReadBLOCK(unsigned int nbBytes,unsigned int address=0) = 0; |
|
20 | virtual unsigned int getLinkStatus(unsigned char link) = 0; | |
|
20 | //virtual unsigned int getLinkStatus(unsigned char link) = 0; | |
|
21 | 21 | |
|
22 | 22 | unsigned char rmapTargetLogicalAddress ; |
|
23 | 23 | unsigned char rmapSourceLogicalAddress ; |
@@ -41,9 +41,9 signals: | |||
|
41 | 41 | void ccsdsPacketAvailable(unsigned char*, unsigned int); |
|
42 | 42 | |
|
43 | 43 | public slots: |
|
44 | unsigned int Open(); | |
|
45 | unsigned int Close(); | |
|
46 | virtual int receiveSPWPacket(unsigned char requestID) = 0; | |
|
44 | //unsigned int Open(); | |
|
45 | //unsigned int Close(); | |
|
46 | //virtual int receiveSPWPacket(unsigned char requestID) = 0; | |
|
47 | 47 | void commandCodeHasChanged(RMAP_command_codes code) {this->commandCode = code;} |
|
48 | 48 | void targetHasChanged(int target) {rmapTargetLogicalAddress = (unsigned char) target;} |
|
49 | 49 | void sourceHasChanged(int target) {rmapSourceLogicalAddress = (unsigned char) target;} |
@@ -9,6 +9,8 gresb::gresb(QWidget *parent) : | |||
|
9 | 9 | RMAPReceive_SOCKET = new QTcpSocket; |
|
10 | 10 | GRESBStatusQuery_SOCKET = new QTcpSocket; |
|
11 | 11 | |
|
12 | rmapPacketSEMAPHORE = new QSemaphore; | |
|
13 | ccsdsPacketSEMAPHORE = new QSemaphore; | |
|
12 | 14 | rmapPacket = (char*) malloc(RMAP_MAX_PACKET_LENGTH); |
|
13 | 15 | ccsdsPacket = (unsigned char*) malloc(CCSDS_MAX_PACKET_LENGTH); |
|
14 | 16 | spwPacket = (char*) malloc( qMax(RMAP_MAX_PACKET_LENGTH, CCSDS_MAX_PACKET_LENGTH) ); |
@@ -72,6 +74,13 gresb::gresb(QWidget *parent) : | |||
|
72 | 74 | |
|
73 | 75 | this->setLayout(connectionLayout); |
|
74 | 76 | |
|
77 | connect(RMAPSend_SOCKET, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(RMAPSendConnectionState(QAbstractSocket::SocketState))); | |
|
78 | connect(RMAPReceive_SOCKET, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(RMAPReceiveConnectionState(QAbstractSocket::SocketState))); | |
|
79 | connect(GRESBStatusQuery_SOCKET, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(GRESBConnectionState(QAbstractSocket::SocketState))); | |
|
80 | connect(gresbStatusQueryRetryButton, SIGNAL(clicked()), this, SLOT(reTestSPWLink())); | |
|
81 | connect(spwLinkStatusEnquiry->readSPWStatusButton, SIGNAL(clicked()), this, SLOT(GRESBStatusQuery())); | |
|
82 | connect(this->RMAPReceive_SOCKET, SIGNAL(readyRead()), this, SLOT(receiveSPWPacket())); | |
|
83 | ||
|
75 | 84 | connect(gresbStatusQueryAbortButton, SIGNAL(clicked()), gresbStatusQueryDialog, SLOT(reject())); |
|
76 | 85 | connect(this->RMAPReceive_SOCKET, SIGNAL(readyRead()), this, SLOT(receiveSPWPacket())); |
|
77 | 86 | } |
@@ -231,7 +240,7 unsigned int gresb::WriteBLOCK(char *dat | |||
|
231 | 240 | |
|
232 | 241 | RMAPCommand = new RMAP(commandCode, |
|
233 | 242 | rmapTargetLogicalAddress, |
|
234 | rmapSourceLogicalAddress, | |
|
243 | rmapSourceLogicalAddressSpinBox->value(), | |
|
235 | 244 | address, |
|
236 | 245 | nbBytes, |
|
237 | 246 | data); |
@@ -346,7 +355,7 unsigned int gresb::ReadBLOCK(unsigned i | |||
|
346 | 355 | { |
|
347 | 356 | RMAPCommand = new RMAP(read_Inc, |
|
348 | 357 | rmapTargetLogicalAddress, |
|
349 | rmapSourceLogicalAddress, | |
|
358 | rmapSourceLogicalAddressSpinBox->value(), | |
|
350 | 359 | address, |
|
351 | 360 | nbBytes, |
|
352 | 361 | NULL); |
@@ -355,7 +364,7 unsigned int gresb::ReadBLOCK(unsigned i | |||
|
355 | 364 | { |
|
356 | 365 | RMAPCommand = new RMAP(read_Single, |
|
357 | 366 | rmapTargetLogicalAddress, |
|
358 | rmapSourceLogicalAddress, | |
|
367 | rmapSourceLogicalAddressSpinBox->value(), | |
|
359 | 368 | address, |
|
360 | 369 | nbBytes, |
|
361 | 370 | NULL); |
@@ -685,3 +694,106 void gresb::processCCSDSPacket(unsigned | |||
|
685 | 694 | ccsdsPacketSEMAPHORE->acquire(); |
|
686 | 695 | emit sendMessage(message); |
|
687 | 696 | } |
|
697 | ||
|
698 | void gresb::reTestSPWLink() // SLOT | |
|
699 | { | |
|
700 | if (GRESBStatusQueryRequest(LinkStatus, spwLinkSpinBox->value()) == 0) | |
|
701 | { | |
|
702 | gresbStatusQueryDialog->accept(); | |
|
703 | } | |
|
704 | } | |
|
705 | ||
|
706 | void gresb::RMAPSendConnectionState(QAbstractSocket::SocketState socketState) // SLOT | |
|
707 | { | |
|
708 | rmapSendStateLabel->setText(""); | |
|
709 | QString socketMessage = "RMAP Send Socket State: "; | |
|
710 | switch(socketState) | |
|
711 | { | |
|
712 | case QAbstractSocket::UnconnectedState : | |
|
713 | socketMessage.append("0 => Unconnected"); | |
|
714 | break; | |
|
715 | case 1: | |
|
716 | socketMessage.append("1 => HostLookup"); | |
|
717 | break; | |
|
718 | case 2: | |
|
719 | socketMessage.append("2 => Connecting"); | |
|
720 | break; | |
|
721 | case 3: | |
|
722 | socketMessage.append("3 => Connected"); | |
|
723 | break; | |
|
724 | case 4: | |
|
725 | socketMessage.append("4 => Bound"); | |
|
726 | break; | |
|
727 | case 5: | |
|
728 | socketMessage.append("5 => Closing"); | |
|
729 | break; | |
|
730 | case 6: | |
|
731 | socketMessage.append("6 => Listening"); | |
|
732 | break; | |
|
733 | } | |
|
734 | rmapSendStateLabel->setText(socketMessage); | |
|
735 | emit appendToLog(socketMessage); | |
|
736 | } | |
|
737 | ||
|
738 | void gresb::RMAPReceiveConnectionState(QAbstractSocket::SocketState socketState) // SLOT | |
|
739 | { | |
|
740 | rmapReceiveStateLabel->setText(""); | |
|
741 | QString socketMessage = "RMAP Receive Socket State: "; | |
|
742 | switch(socketState) | |
|
743 | { | |
|
744 | case QAbstractSocket::UnconnectedState : | |
|
745 | socketMessage.append("0 => Unconnected"); | |
|
746 | break; | |
|
747 | case 1: | |
|
748 | socketMessage.append("1 => HostLookup"); | |
|
749 | break; | |
|
750 | case 2: | |
|
751 | socketMessage.append("2 => Connecting"); | |
|
752 | break; | |
|
753 | case 3: | |
|
754 | socketMessage.append("3 => Connected"); | |
|
755 | break; | |
|
756 | case 4: | |
|
757 | socketMessage.append("4 => Bound"); | |
|
758 | break; | |
|
759 | case 5: | |
|
760 | socketMessage.append("5 => Closing"); | |
|
761 | break; | |
|
762 | case 6: | |
|
763 | socketMessage.append("6 => Listening"); | |
|
764 | break; | |
|
765 | } | |
|
766 | rmapReceiveStateLabel->setText(socketMessage); | |
|
767 | emit appendToLog(socketMessage); | |
|
768 | } | |
|
769 | ||
|
770 | void gresb::GRESBConnectionState(QAbstractSocket::SocketState socketState) // SLOT | |
|
771 | { | |
|
772 | gresbStatusQueryLabel->setText(""); | |
|
773 | QString socketMessage = "GRESB status query socket (port 3010): "; | |
|
774 | switch(socketState) | |
|
775 | { | |
|
776 | case QAbstractSocket::UnconnectedState : | |
|
777 | socketMessage.append("0 => Unconnected"); | |
|
778 | break; | |
|
779 | case 1: | |
|
780 | socketMessage.append("1 => HostLookup"); | |
|
781 | break; | |
|
782 | case 2: | |
|
783 | socketMessage.append("2 => Connecting"); | |
|
784 | break; | |
|
785 | case 3: | |
|
786 | socketMessage.append("3 => Connected"); | |
|
787 | break; | |
|
788 | case 4: | |
|
789 | socketMessage.append("4 => Bound"); | |
|
790 | break; | |
|
791 | case 5: | |
|
792 | socketMessage.append("5 => Closing"); | |
|
793 | break; | |
|
794 | case 6: | |
|
795 | socketMessage.append("6 => Listening"); | |
|
796 | break; | |
|
797 | } | |
|
798 | gresbStatusQueryLabel->setText(socketMessage); | |
|
799 | } |
@@ -24,7 +24,6 public: | |||
|
24 | 24 | unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0); |
|
25 | 25 | unsigned int Read(unsigned int *Value,unsigned int count,unsigned int address=0); |
|
26 | 26 | unsigned int WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication); |
|
27 | //unsigned int getLinkStatus(unsigned char link); | |
|
28 | 27 | |
|
29 | 28 | signals: |
|
30 | 29 | void sendMessage(QString message); |
@@ -38,9 +37,12 public slots: | |||
|
38 | 37 | void Close(); |
|
39 | 38 | int receiveSPWPacket(unsigned char requestID=0); |
|
40 | 39 | void processCCSDSPacket(unsigned char *ccsdsPacket, unsigned int size); |
|
40 | void reTestSPWLink(); | |
|
41 | void RMAPSendConnectionState(QAbstractSocket::SocketState socketState); | |
|
42 | void RMAPReceiveConnectionState(QAbstractSocket::SocketState socketState); | |
|
43 | void GRESBConnectionState(QAbstractSocket::SocketState socketState); | |
|
41 | 44 | void commandCodeHasChanged(RMAP_command_codes code) {this->commandCode = code;} |
|
42 | 45 | void targetHasChanged(int target) {rmapTargetLogicalAddress = (unsigned char) target;} |
|
43 | void sourceHasChanged(int target) {rmapSourceLogicalAddress = (unsigned char) target;} | |
|
44 | 46 | |
|
45 | 47 | private slots: |
|
46 | 48 | int GRESBStatusQuery(); |
This diff has been collapsed as it changes many lines, (717 lines changed) Show them Hide them | |||
@@ -31,11 +31,7 rmapplugin::rmapplugin(QWidget *parent) | |||
|
31 | 31 | this->UI = new rmapPluginUI(); |
|
32 | 32 | this->setWindowTitle(tr("RMAP and SPW Communication")); |
|
33 | 33 | this->setWidget((QWidget*)this->UI); |
|
34 | RMAPSend_SOCKET = new QTcpSocket; | |
|
35 | RMAPReceive_SOCKET = new QTcpSocket; | |
|
36 | GRESBStatusQuery_SOCKET = new QTcpSocket; | |
|
37 | spwPacketReceiverOBJECT = new spwpacketreceiver; | |
|
38 | spwPacketReceiverOBJECT->gresbReceptionSocket = RMAPReceive_SOCKET; | |
|
34 | ||
|
39 | 35 | timeCode = 0; |
|
40 | 36 | time_COARSE = 0; |
|
41 | 37 | time_FINE = 0; |
@@ -49,32 +45,26 rmapplugin::rmapplugin(QWidget *parent) | |||
|
49 | 45 | |
|
50 | 46 | connect(UI->rmapOpenCommunicationButton, SIGNAL(clicked()), this, SLOT(openBridge())); |
|
51 | 47 | connect(UI->rmapCloseCommunicationButton, SIGNAL(clicked()), this, SLOT(closeBridge())); |
|
52 | connect(RMAPSend_SOCKET, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(RMAPSendConnectionState(QAbstractSocket::SocketState))); | |
|
53 | connect(RMAPReceive_SOCKET, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(RMAPReceiveConnectionState(QAbstractSocket::SocketState))); | |
|
54 | connect(GRESBStatusQuery_SOCKET, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(GRESBConnectionState(QAbstractSocket::SocketState))); | |
|
55 | connect(UI->gresbStatusQueryRetryButton, SIGNAL(clicked()), this, SLOT(reTestSPWLink())); | |
|
56 | connect(this->UI->spwLinkStatusEnquiry->readSPWStatusButton, SIGNAL(clicked()), this, SLOT(GRESBStatusQuery())); | |
|
57 | connect(this->RMAPReceive_SOCKET, SIGNAL(readyRead()), this->spwPacketReceiverOBJECT, SLOT(receiveSPWPacket())); | |
|
58 | 48 | |
|
59 | 49 | // CCSDS |
|
60 | 50 | connect(this->UI->sendCCSDSCommandButton, SIGNAL(clicked()), this, SLOT(sendCCSDS())); |
|
61 | 51 | connect(this->UI->send_TC_LFR_UPDATE_TIME_Button, SIGNAL(clicked()), this, SLOT(send_TC_LFR_UPDATE_TIME())); |
|
62 | 52 | connect(this->UI->reset_TC_LFR_UPDATE_TIME_Button, SIGNAL(clicked()), this, SLOT(reset_TC_LFR_UPDATE_TIME())); |
|
63 | 53 | |
|
64 | // CONSOLE | |
|
65 | connect(this->spwPacketReceiverOBJECT, SIGNAL(sendMessage(QString)), this, SLOT(displayOnConsole(QString))); | |
|
66 | connect(this->UI->starDundee, SIGNAL(sendMessage(QString)), this, SLOT(displayOnConsole(QString))); | |
|
67 | ||
|
68 | 54 | // spectralMAtricesDMASimulator |
|
69 | 55 | connect(this->UI->spectralMatricesDMASimulator, SIGNAL(rmapplugginRead(uint*,uint,uint)), this, SLOT(Read(uint*,uint,uint))); |
|
70 | 56 | connect(this->UI->spectralMatricesDMASimulator, SIGNAL(rmapplugginWrite(uint*,uint,uint)), this, SLOT(Write(uint*,uint,uint))); |
|
71 | 57 | connect(this->UI->spectralMatricesDMASimulator, SIGNAL(sendMessage(QString)), this, SLOT(displayOnConsole(QString))); |
|
72 | 58 | |
|
73 | 59 | // GRESB |
|
74 |
connect(this, SIGNAL( |
|
|
60 | connect(this->UI->gresbBridge, SIGNAL(sendMessage(QString)), this, SLOT(displayOnConsole(QString))); | |
|
61 | connect(this->UI->gresbBridge, SIGNAL(isOpen(bool)), this, SLOT(activatePlugin(bool))); | |
|
62 | connect(this->UI->gresbBridge, SIGNAL(RMAP_write_reply_setText(QString)), this, SLOT(RMAP_write_reply_setText(QString))); | |
|
63 | connect(this->UI->gresbBridge, SIGNAL(appendToLog(QString)), this, SLOT(appendToLog(QString))); | |
|
75 | 64 | |
|
76 | 65 | // Star Dundee |
|
77 |
connect(this->UI->starDundee, SIGNAL( |
|
|
66 | connect(this->UI->starDundee, SIGNAL(sendMessage(QString)), this, SLOT(displayOnConsole(QString))); | |
|
67 | connect(this->UI->starDundee, SIGNAL(isOpen(bool)), this, SLOT(activatePlugin(bool))); | |
|
78 | 68 | connect(this->UI->starDundee, SIGNAL(RMAP_write_reply_setText(QString)), this, SLOT(RMAP_write_reply_setText(QString))); |
|
79 | 69 | connect(this->UI->starDundee, SIGNAL(appendToLog(QString)), this, SLOT(appendToLog(QString))); |
|
80 | 70 | |
@@ -94,7 +84,7 unsigned int rmapplugin::Write(unsigned | |||
|
94 | 84 | switch(currentBridge) |
|
95 | 85 | { |
|
96 | 86 | case selectedBridgeIsGRESB : |
|
97 |
result = Write |
|
|
87 | result = UI->gresbBridge->Write(Value, count, address); | |
|
98 | 88 | break; |
|
99 | 89 | case selectedBridgeIsStarDundee : |
|
100 | 90 | result = UI->starDundee->Write(Value, count, address); |
@@ -112,7 +102,7 unsigned int rmapplugin::Read(unsigned i | |||
|
112 | 102 | switch(currentBridge) |
|
113 | 103 | { |
|
114 | 104 | case selectedBridgeIsGRESB : |
|
115 |
result = Read |
|
|
105 | result = UI->gresbBridge->Read(Value, count, address); | |
|
116 | 106 | break; |
|
117 | 107 | case selectedBridgeIsStarDundee : |
|
118 | 108 | result = UI->starDundee->Read(Value, count, address); |
@@ -124,320 +114,6 unsigned int rmapplugin::Read(unsigned i | |||
|
124 | 114 | return result; |
|
125 | 115 | } |
|
126 | 116 | |
|
127 | unsigned int rmapplugin::WriteGRESB(unsigned int *Value, unsigned int count, unsigned int address) | |
|
128 | { | |
|
129 | unsigned int remainingCount = count; | |
|
130 | unsigned int iOffset = 0; | |
|
131 | QString console_message; | |
|
132 | char* data; | |
|
133 | ||
|
134 | if(spwPacketReceiverOBJECT->rmapPacketSEMAPHORE->available()!=0) | |
|
135 | { | |
|
136 | APPENDTOLOG("WARNING === in function WRITE of rmapplugin *** RMAP request already running, WRITE access stopped"); | |
|
137 | return 1; | |
|
138 | } | |
|
139 | ||
|
140 | UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: unavailable"); | |
|
141 | ||
|
142 | data = (char*) malloc(READ_WRITE_MAX_COUNTS*4); | |
|
143 | ||
|
144 | APPENDTOLOG(QString("*** START *** WRITE ")+ QString::number(count) + QString(" word(s) @0x")+ QString::number(address,16)); | |
|
145 | ||
|
146 | while (remainingCount > READ_WRITE_MAX_COUNTS) | |
|
147 | { | |
|
148 | for (int i = 0; i<READ_WRITE_MAX_COUNTS; i++) | |
|
149 | { | |
|
150 | data[i*4+3] = (char) ((unsigned int) Value[i+iOffset]); | |
|
151 | data[i*4+2] = (char) ((unsigned int) Value[i+iOffset]>>8); | |
|
152 | data[i*4+1] = (char) ((unsigned int) Value[i+iOffset]>>16); | |
|
153 | data[i*4+0] = (char) ((unsigned int) Value[i+iOffset]>>24); | |
|
154 | } | |
|
155 | ||
|
156 | console_message.sprintf("remainingCount: %d => ", remainingCount); | |
|
157 | APPENDTOLOG(console_message + QString("Write ")+ QString::number(READ_WRITE_MAX_COUNTS*4) + QString(" byte(s) @0x")+ QString::number(address,16)); | |
|
158 | ||
|
159 | if(WriteBLOCK(data, READ_WRITE_MAX_COUNTS*4, address)==0) | |
|
160 | { | |
|
161 | APPENDTOLOG("WARNING === in function WRITE of rmapplugin *** RMAP write command failed"); | |
|
162 | return 1; | |
|
163 | } | |
|
164 | ||
|
165 | remainingCount = remainingCount - READ_WRITE_MAX_COUNTS; | |
|
166 | address = address + READ_WRITE_MAX_COUNTS * 4; | |
|
167 | iOffset = iOffset + READ_WRITE_MAX_COUNTS; | |
|
168 | } | |
|
169 | ||
|
170 | if (remainingCount > 0) | |
|
171 | { | |
|
172 | for (unsigned int i = 0; i<remainingCount; i++) | |
|
173 | { | |
|
174 | data[i*4+3] = (char) ((unsigned int) Value[i+iOffset]); | |
|
175 | data[i*4+2] = (char) ((unsigned int) Value[i+iOffset]>>8); | |
|
176 | data[i*4+1] = (char) ((unsigned int) Value[i+iOffset]>>16); | |
|
177 | data[i*4+0] = (char) ((unsigned int) Value[i+iOffset]>>24); | |
|
178 | } | |
|
179 | ||
|
180 | console_message.sprintf("remainingCount: %d => ", remainingCount); | |
|
181 | APPENDTOLOG(console_message + QString("Write ")+ QString::number(remainingCount*4) + QString(" byte(s) @0x")+ QString::number(address,16)); | |
|
182 | ||
|
183 | if (WriteBLOCK(data, remainingCount*4, address)==0) | |
|
184 | { | |
|
185 | APPENDTOLOG("WARNING === in function WRITE of rmapplugin *** RMAP write command failed"); | |
|
186 | return 1; | |
|
187 | } | |
|
188 | } | |
|
189 | ||
|
190 | APPENDTOLOG(QString("*** STOP *** WRITE")); | |
|
191 | free(data); | |
|
192 | return count; | |
|
193 | } | |
|
194 | ||
|
195 | unsigned int rmapplugin::ReadGRESB(unsigned int *Value, unsigned int count, unsigned int address) | |
|
196 | { | |
|
197 | unsigned int remainingCount = count; | |
|
198 | unsigned int iOffset = 0; | |
|
199 | QString console_message; | |
|
200 | ||
|
201 | if(spwPacketReceiverOBJECT->rmapPacketSEMAPHORE->available()!=0) | |
|
202 | { | |
|
203 | APPENDTOLOG("WARNING === in function READ of rmapplugin *** RMAP request already running, READ access stopped"); | |
|
204 | return 1; | |
|
205 | } | |
|
206 | APPENDTOLOG(QString("*** START *** READ ")+ QString::number(count) + QString(" word(s) @0x")+ QString::number(address,16)); | |
|
207 | ||
|
208 | while (remainingCount > READ_WRITE_MAX_COUNTS) | |
|
209 | { | |
|
210 | console_message.sprintf("remainingCount: %d => ", remainingCount); | |
|
211 | APPENDTOLOG(console_message + QString("Read ")+ QString::number(4*READ_WRITE_MAX_COUNTS) + QString(" byte(s) @0x")+ QString::number(address,16)); | |
|
212 | ||
|
213 | if (ReadBLOCK(READ_WRITE_MAX_COUNTS*4, address)==0) | |
|
214 | { | |
|
215 | APPENDTOLOG("WARNING === in function READ of rmapplugin *** RMAP packet not received"); | |
|
216 | return 1; | |
|
217 | } | |
|
218 | ||
|
219 | for(int i=0;i<READ_WRITE_MAX_COUNTS;i++) | |
|
220 | { | |
|
221 | Value[i+iOffset] = (unsigned char) spwPacketReceiverOBJECT->rmapPacket[i*4+RMAP_READ_REPLY_HEADER_LENGTH]; | |
|
222 | for(int j=1;j<4;j++) | |
|
223 | { | |
|
224 | Value[i+iOffset]= ((unsigned char)(spwPacketReceiverOBJECT->rmapPacket[i*4+j+RMAP_READ_REPLY_HEADER_LENGTH])) + Value[i+iOffset]*256; | |
|
225 | } | |
|
226 | } | |
|
227 | ||
|
228 | remainingCount = remainingCount - READ_WRITE_MAX_COUNTS; | |
|
229 | address = address + READ_WRITE_MAX_COUNTS * 4; | |
|
230 | iOffset = iOffset + READ_WRITE_MAX_COUNTS; | |
|
231 | spwPacketReceiverOBJECT->acquireRMAPSemaphore(); | |
|
232 | } | |
|
233 | ||
|
234 | if (remainingCount > 0) | |
|
235 | { | |
|
236 | console_message.sprintf("remainingCount: %d => ", remainingCount); | |
|
237 | APPENDTOLOG(console_message + QString("Read ")+ QString::number(4*remainingCount) + QString(" byte(s) @0x")+ QString::number(address,16)); | |
|
238 | ||
|
239 | if (ReadBLOCK(4*remainingCount, address)==0) | |
|
240 | { | |
|
241 | APPENDTOLOG("WARNING === in function READ of rmapplugin *** RMAP packet not received"); | |
|
242 | return 1; | |
|
243 | } | |
|
244 | ||
|
245 | for(unsigned int i=0;i<remainingCount;i++) | |
|
246 | { | |
|
247 | Value[i+iOffset] = (unsigned char) spwPacketReceiverOBJECT->rmapPacket[i*4+RMAP_READ_REPLY_HEADER_LENGTH]; | |
|
248 | for(int j=1;j<4;j++) | |
|
249 | { | |
|
250 | Value[i+iOffset]= ((unsigned char)(spwPacketReceiverOBJECT->rmapPacket[i*4+j+RMAP_READ_REPLY_HEADER_LENGTH])) + Value[i+iOffset]*256; | |
|
251 | } | |
|
252 | } | |
|
253 | spwPacketReceiverOBJECT->acquireRMAPSemaphore(); | |
|
254 | } | |
|
255 | ||
|
256 | APPENDTOLOG(QString("*** STOP *** READ ")); | |
|
257 | return count; | |
|
258 | } | |
|
259 | ||
|
260 | unsigned int rmapplugin::WriteBLOCK(char *data, unsigned int nbBytes, unsigned int address) | |
|
261 | { | |
|
262 | QTime RMAPTimeout; | |
|
263 | RMAP *RMAPCommand; | |
|
264 | int errorCode; | |
|
265 | QString console_message; | |
|
266 | ||
|
267 | if (GRESBStatusQueryRequest(LinkStatus, UI->spwLinkSpinBox->value()) == 1) | |
|
268 | { | |
|
269 | RMAP_DISCONNECT(); | |
|
270 | return 1; | |
|
271 | } | |
|
272 | ||
|
273 | RMAPCommand = new RMAP(UI->getCommandCode(), | |
|
274 | UI->rmapTargetLogicalAddressSpinBox->value(), | |
|
275 | UI->rmapSourceLogicalAddressSpinBox->value(), | |
|
276 | address, | |
|
277 | nbBytes, | |
|
278 | data); | |
|
279 | ||
|
280 | // SEND GRESB HEADER | |
|
281 | RMAPSend_SOCKET->write((char*) ((void*) &RMAPCommand->GRESBHeader), 4); | |
|
282 | // SEND SPACEWIRE PACKET HEADER | |
|
283 | RMAPSend_SOCKET->write((char*) ((void*) &RMAPCommand->RMAPHeader), sizeof(RMAPCommand->RMAPHeader)); | |
|
284 | // SEND DATA | |
|
285 | RMAPSend_SOCKET->write( data, nbBytes); | |
|
286 | // SEND DATA CRC | |
|
287 | RMAPSend_SOCKET->write((char*) ((void*) &RMAPCommand->dataCRC), 1); | |
|
288 | RMAPTimeout.start(); | |
|
289 | while(RMAPSend_SOCKET->bytesToWrite() > 0) | |
|
290 | { | |
|
291 | RMAPSend_SOCKET->waitForBytesWritten(100); | |
|
292 | if(RMAPTimeout.elapsed()>1000) | |
|
293 | { | |
|
294 | APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** sending Write RMAP Command timeout"); | |
|
295 | return 0; | |
|
296 | } | |
|
297 | } | |
|
298 | ||
|
299 | if (UI->RMAP_write_reply->isChecked()) | |
|
300 | { | |
|
301 | // WAIT FOR THE RMAP REPLY PACKET | |
|
302 | errorCode = spwPacketReceiverOBJECT->receiveSPWPacket(1); | |
|
303 | if (errorCode<=0) | |
|
304 | { | |
|
305 | APPENDTOLOG("WARNING === in function WriteBLOCK of rmapplugin *** RMAP packet reception failed with code " + QString::number(errorCode)); | |
|
306 | return 0; | |
|
307 | } | |
|
308 | if(spwPacketReceiverOBJECT->rmapPacketSize != 8) | |
|
309 | { | |
|
310 | console_message.sprintf("WARNING === in function WRITE (with reply) of rmapplugin *** write reply format not compliant\n"); | |
|
311 | APPENDTOLOG(console_message); | |
|
312 | return 0; | |
|
313 | } | |
|
314 | switch (spwPacketReceiverOBJECT->rmapPacket[3]) // byte 4 is the status byte in the reply | |
|
315 | { | |
|
316 | case 0: | |
|
317 | UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 0 Successfull"); | |
|
318 | break; | |
|
319 | case 1: | |
|
320 | APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** General error code"); | |
|
321 | UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 1 General error code"); | |
|
322 | break; | |
|
323 | case 2: | |
|
324 | APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** Unused RMAP packet type or command code"); | |
|
325 | UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 2 Unused RMAP packet type or command code"); | |
|
326 | break; | |
|
327 | case 3: | |
|
328 | APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** Invalid key"); | |
|
329 | UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 3 Invalid key"); | |
|
330 | break; | |
|
331 | case 4: | |
|
332 | APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** Invalid data CRC"); | |
|
333 | UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 4 Invalid data CRC"); | |
|
334 | break; | |
|
335 | case 5: | |
|
336 | APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** Early EOP"); | |
|
337 | UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 5 Early EOP"); | |
|
338 | break; | |
|
339 | case 6: | |
|
340 | APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** Too much data"); | |
|
341 | UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 6 Too much data"); | |
|
342 | break; | |
|
343 | case 7: | |
|
344 | APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** EEP"); | |
|
345 | UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 7 EEP"); | |
|
346 | break; | |
|
347 | case 8: | |
|
348 | APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** Reserved"); | |
|
349 | UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 8 Reserved"); | |
|
350 | break; | |
|
351 | case 9: | |
|
352 | APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** Verify buffer overrun"); | |
|
353 | UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 9 Verify buffer overrun"); | |
|
354 | break; | |
|
355 | case 10: | |
|
356 | APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** RMAP command not implemented or not authorised"); | |
|
357 | UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 10 RMAP command not implemented or not authorised"); | |
|
358 | break; | |
|
359 | case 11: | |
|
360 | APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** RMW data length error"); | |
|
361 | UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 11 RMAP RMW data length error"); | |
|
362 | break; | |
|
363 | case 12: | |
|
364 | APPENDTOLOG("WARNING === in function WRITE (with reply) of rmapplugin *** Invalid target logical address"); | |
|
365 | UI->RMAP_write_reply->setText("reply to the write command required\nlast reply status: 12 Invalid target logical address"); | |
|
366 | break; | |
|
367 | } | |
|
368 | spwPacketReceiverOBJECT->acquireRMAPSemaphore(); | |
|
369 | } | |
|
370 | return nbBytes; | |
|
371 | } | |
|
372 | ||
|
373 | unsigned int rmapplugin::ReadBLOCK(unsigned int nbBytes, unsigned int address) | |
|
374 | { | |
|
375 | int errorCode; | |
|
376 | RMAP *RMAPCommand; | |
|
377 | QTime RMAPTimeout; | |
|
378 | unsigned int dataLength; | |
|
379 | if (GRESBStatusQueryRequest(LinkStatus, UI->spwLinkSpinBox->value()) == 1) | |
|
380 | { | |
|
381 | RMAP_DISCONNECT(); | |
|
382 | return 1; | |
|
383 | } | |
|
384 | ||
|
385 | if (nbBytes > 4) | |
|
386 | { | |
|
387 | RMAPCommand = new RMAP(read_Inc, | |
|
388 | UI->rmapTargetLogicalAddressSpinBox->value(), | |
|
389 | UI->rmapSourceLogicalAddressSpinBox->value(), | |
|
390 | address, | |
|
391 | nbBytes, | |
|
392 | NULL); | |
|
393 | } | |
|
394 | else | |
|
395 | { | |
|
396 | RMAPCommand = new RMAP(read_Single, | |
|
397 | UI->rmapTargetLogicalAddressSpinBox->value(), | |
|
398 | UI->rmapSourceLogicalAddressSpinBox->value(), | |
|
399 | address, | |
|
400 | nbBytes, | |
|
401 | NULL); | |
|
402 | } | |
|
403 | ||
|
404 | // SEND THE GRESB HEADER FOR THE RMAP READ COMMAND | |
|
405 | RMAPSend_SOCKET->write((char*) ((void*) &RMAPCommand->GRESBHeader), 4); | |
|
406 | // SEND THE SPACEWIRE PACKET FOR THE RMAP READ COMMAND | |
|
407 | RMAPSend_SOCKET->write((char*) ((void*) &RMAPCommand->RMAPHeader), sizeof(RMAPCommand->RMAPHeader)); | |
|
408 | RMAPSend_SOCKET->waitForBytesWritten(100); | |
|
409 | RMAPTimeout.start(); | |
|
410 | // write timeout | |
|
411 | while(RMAPSend_SOCKET->bytesToWrite() > 0) | |
|
412 | { | |
|
413 | RMAPSend_SOCKET->waitForBytesWritten(100); | |
|
414 | if(RMAPTimeout.elapsed()>1000) | |
|
415 | { | |
|
416 | APPENDTOLOG("WARNING === in function READ of rmapplugin *** sending Read RMAP Command timeout\n"); | |
|
417 | return 0; | |
|
418 | } | |
|
419 | } | |
|
420 | ||
|
421 | // RECEIVE THE INCOMING RMAP PACKET | |
|
422 | errorCode = spwPacketReceiverOBJECT->receiveSPWPacket(1); // request ID 1 is for RMAP packet | |
|
423 | if (errorCode<=0) | |
|
424 | { | |
|
425 | APPENDTOLOG("WARNING === in function ReadBLOCK of rmapplugin *** RMAP packet reception failed with code " + QString::number(errorCode)); | |
|
426 | return 0; | |
|
427 | } | |
|
428 | dataLength = spwPacketReceiverOBJECT->rmapPacketSize - RMAP_READ_REPLY_HEADER_LENGTH - RMAP_DATA_CRC_LENGTH; | |
|
429 | if(dataLength != nbBytes) | |
|
430 | { | |
|
431 | APPENDTOLOG("WARNING === in function READ of rmapplugin *** number of data received (" | |
|
432 | +QString::number(dataLength) | |
|
433 | +") not equal to number of data requested (" | |
|
434 | +QString::number(READ_WRITE_MAX_COUNTS*4) | |
|
435 | +")"); | |
|
436 | return 0; | |
|
437 | } | |
|
438 | return dataLength; | |
|
439 | } | |
|
440 | ||
|
441 | 117 | //////// |
|
442 | 118 | // SLOTS |
|
443 | 119 | |
@@ -447,7 +123,7 unsigned int rmapplugin::WriteSPW(char * | |||
|
447 | 123 | switch(currentBridge) |
|
448 | 124 | { |
|
449 | 125 | case selectedBridgeIsGRESB : |
|
450 |
result = WriteSPW |
|
|
126 | result = UI->gresbBridge->WriteSPW(Value, count, targetLogicalAddress, userApplication); | |
|
451 | 127 | break; |
|
452 | 128 | case selectedBridgeIsStarDundee : |
|
453 | 129 | result = UI->starDundee->WriteSPW(Value, count, targetLogicalAddress, userApplication); |
@@ -459,59 +135,6 unsigned int rmapplugin::WriteSPW(char * | |||
|
459 | 135 | return result; |
|
460 | 136 | } |
|
461 | 137 | |
|
462 | unsigned int rmapplugin::WriteSPWGRESB(char *Value, unsigned int count, char targetLogicalAddress, char userApplication) | |
|
463 | { | |
|
464 | char protocoleIdentifier = 0x02; | |
|
465 | char reserved = 0x00; | |
|
466 | char gresbProtocole = 0x00; | |
|
467 | unsigned char size[3]; | |
|
468 | unsigned int spwPacketSize = count + 4; | |
|
469 | QTime SPWTimeout; | |
|
470 | ||
|
471 | if (count>248) | |
|
472 | { | |
|
473 | APPENDTOLOG("WARNING === in function WRITE of rmapplugin *** CCSDS packet size > 248 bytes\n"); | |
|
474 | return 1; | |
|
475 | } | |
|
476 | ||
|
477 | APPENDTOLOG(QString("*** START *** Send CCSDS packet of ")+ QString::number(count) + QString(" byte(s)")); | |
|
478 | ||
|
479 | if (GRESBStatusQueryRequest(LinkStatus, UI->spwLinkSpinBox->value()) == 1) | |
|
480 | { | |
|
481 | RMAP_DISCONNECT(); | |
|
482 | APPENDTOLOG("WARNING === in function WRITE of rmapplugin *** SPW link not running\n"); | |
|
483 | return 1; | |
|
484 | } | |
|
485 | ||
|
486 | // SEND GRESB HEADER | |
|
487 | size[0] = (unsigned char) ((unsigned int) spwPacketSize>>16); | |
|
488 | size[1] = (unsigned char) ((unsigned int) spwPacketSize>>8); | |
|
489 | size[2] = (unsigned char) ((unsigned int) spwPacketSize); | |
|
490 | RMAPSend_SOCKET->write(&gresbProtocole, 1); | |
|
491 | RMAPSend_SOCKET->write((char*) size, 3); | |
|
492 | // SEND SPW HEADER | |
|
493 | RMAPSend_SOCKET->write(&targetLogicalAddress, 1); | |
|
494 | RMAPSend_SOCKET->write(&protocoleIdentifier, 1); | |
|
495 | RMAPSend_SOCKET->write(&reserved, 1); | |
|
496 | RMAPSend_SOCKET->write(&userApplication, 1); | |
|
497 | // SEND CCSDS PACKET | |
|
498 | RMAPSend_SOCKET->write(Value, count); | |
|
499 | SPWTimeout.start(); | |
|
500 | while(RMAPSend_SOCKET->bytesToWrite() > 0) | |
|
501 | { | |
|
502 | RMAPSend_SOCKET->waitForBytesWritten(100); | |
|
503 | if(SPWTimeout.elapsed()>1000) | |
|
504 | { | |
|
505 | APPENDTOLOG("WARNING === in function WRITE of rmapplugin *** sending CCSDS packet timeout\n"); | |
|
506 | return 1; | |
|
507 | } | |
|
508 | } | |
|
509 | ||
|
510 | APPENDTOLOG(QString("*** CCSDS packet sent")); | |
|
511 | ||
|
512 | return count; | |
|
513 | } | |
|
514 | ||
|
515 | 138 | void rmapplugin::sendCCSDS() // SLOT |
|
516 | 139 | { |
|
517 | 140 | unsigned int nbBYTES_application_data = 8; |
@@ -557,6 +180,36 void rmapplugin::sendCCSDS() // SLOT | |||
|
557 | 180 | free(tab); |
|
558 | 181 | } |
|
559 | 182 | |
|
183 | void rmapplugin::openBridge() | |
|
184 | { | |
|
185 | switch(currentBridge) | |
|
186 | { | |
|
187 | case selectedBridgeIsGRESB : | |
|
188 | this->UI->gresbBridge->Open(); | |
|
189 | break; | |
|
190 | case selectedBridgeIsStarDundee : | |
|
191 | this->UI->starDundee->Open(); | |
|
192 | break; | |
|
193 | default: | |
|
194 | break; | |
|
195 | } | |
|
196 | } | |
|
197 | ||
|
198 | void rmapplugin::closeBridge() | |
|
199 | { | |
|
200 | switch(currentBridge) | |
|
201 | { | |
|
202 | case selectedBridgeIsGRESB : | |
|
203 | this->UI->gresbBridge->Close(); | |
|
204 | break; | |
|
205 | case selectedBridgeIsStarDundee : | |
|
206 | this->UI->starDundee->Close(); | |
|
207 | break; | |
|
208 | default: | |
|
209 | break; | |
|
210 | } | |
|
211 | } | |
|
212 | ||
|
560 | 213 | void rmapplugin::send_TC_LFR_UPDATE_TIME() |
|
561 | 214 | { |
|
562 | 215 | unsigned int nbBYTES_application_data = 6; // Time at CUC format is on 48 bits / 6 bytes |
@@ -610,194 +263,6 void rmapplugin::reset_TC_LFR_UPDATE_TIM | |||
|
610 | 263 | time_FINE = 0; |
|
611 | 264 | } |
|
612 | 265 | |
|
613 | void rmapplugin::openBridge() | |
|
614 | { | |
|
615 | switch(currentBridge) | |
|
616 | { | |
|
617 | case selectedBridgeIsGRESB : | |
|
618 | RMAP_CONNECT(); | |
|
619 | break; | |
|
620 | case selectedBridgeIsStarDundee : | |
|
621 | this->UI->starDundee->Open(); | |
|
622 | break; | |
|
623 | default: | |
|
624 | break; | |
|
625 | } | |
|
626 | } | |
|
627 | ||
|
628 | void rmapplugin::closeBridge() | |
|
629 | { | |
|
630 | switch(currentBridge) | |
|
631 | { | |
|
632 | case selectedBridgeIsGRESB : | |
|
633 | RMAP_DISCONNECT(); | |
|
634 | break; | |
|
635 | case selectedBridgeIsStarDundee : | |
|
636 | this->UI->starDundee->Close(); | |
|
637 | break; | |
|
638 | default: | |
|
639 | break; | |
|
640 | } | |
|
641 | } | |
|
642 | ||
|
643 | void rmapplugin::RMAP_CONNECT() // SLOT | |
|
644 | { | |
|
645 | bool spwRunning = true; | |
|
646 | RMAPSend_SOCKET->connectToHost( QHostAddress(UI->gresbBridgeIPDialogBox->getGRESBIP()), | |
|
647 | 3000 + UI->gresbVirtualLinkSpinBox->value()*2, | |
|
648 | QIODevice::WriteOnly); | |
|
649 | RMAPReceive_SOCKET->connectToHost( QHostAddress(UI->gresbBridgeIPDialogBox->getGRESBIP()), | |
|
650 | 3000 + UI->gresbVirtualLinkSpinBox->value()*2+1, | |
|
651 | QIODevice::ReadOnly); | |
|
652 | GRESBStatusQuery_SOCKET->connectToHost( QHostAddress(UI->gresbBridgeIPDialogBox->getGRESBIP()), | |
|
653 | 3010, | |
|
654 | QIODevice::ReadWrite); | |
|
655 | GRESBStatusQuery_SOCKET->waitForConnected(10000); | |
|
656 | RMAPReceive_SOCKET->readAll(); // read all remaining data from the reception socket | |
|
657 | // initialize SPW packet semaphores | |
|
658 | while (spwPacketReceiverOBJECT->rmapPacketSEMAPHORE->available()!=0) spwPacketReceiverOBJECT->rmapPacketSEMAPHORE->acquire(); | |
|
659 | while (spwPacketReceiverOBJECT->ccsdsPacketSEMAPHORE->available()!=0) spwPacketReceiverOBJECT->ccsdsPacketSEMAPHORE->acquire(); | |
|
660 | if (GRESBStatusQueryRequest(LinkStatus, UI->spwLinkSpinBox->value()) != 0) | |
|
661 | { | |
|
662 | spwRunning = UI->gresbStatusQueryDialog->exec(); | |
|
663 | } | |
|
664 | if (spwRunning == false) RMAP_DISCONNECT(); | |
|
665 | else | |
|
666 | { | |
|
667 | APPENDTOLOG(QString("SpaceWire running on virtual link ")+ QString::number(UI->spwLinkSpinBox->value())); | |
|
668 | emit this->activateSig(true); | |
|
669 | emit gresbIsOpen(true); | |
|
670 | } | |
|
671 | } | |
|
672 | ||
|
673 | void rmapplugin::RMAP_DISCONNECT() // SLOT | |
|
674 | { | |
|
675 | RMAPSend_SOCKET->disconnectFromHost(); | |
|
676 | RMAPReceive_SOCKET->disconnectFromHost(); | |
|
677 | GRESBStatusQuery_SOCKET->disconnectFromHost(); | |
|
678 | emit this->activateSig(false); | |
|
679 | emit gresbIsOpen(false); | |
|
680 | } | |
|
681 | ||
|
682 | void rmapplugin::RMAPSendConnectionState(QAbstractSocket::SocketState socketState) // SLOT | |
|
683 | { | |
|
684 | UI->rmapSendStateLabel->setText(""); | |
|
685 | QString socketMessage = "RMAP Send Socket State: "; | |
|
686 | switch(socketState) | |
|
687 | { | |
|
688 | case QAbstractSocket::UnconnectedState : | |
|
689 | socketMessage.append("0 => Unconnected"); | |
|
690 | UI->rmapOpenCommunicationButton->setEnabled(true); | |
|
691 | UI->rmapCloseCommunicationButton->setEnabled(false); | |
|
692 | emit this->activateSig(false); | |
|
693 | break; | |
|
694 | case 1: | |
|
695 | socketMessage.append("1 => HostLookup"); | |
|
696 | break; | |
|
697 | case 2: | |
|
698 | socketMessage.append("2 => Connecting"); | |
|
699 | break; | |
|
700 | case 3: | |
|
701 | socketMessage.append("3 => Connected"); | |
|
702 | UI->rmapOpenCommunicationButton->setEnabled(false); | |
|
703 | UI->rmapCloseCommunicationButton->setEnabled(true); | |
|
704 | break; | |
|
705 | case 4: | |
|
706 | socketMessage.append("4 => Bound"); | |
|
707 | break; | |
|
708 | case 5: | |
|
709 | socketMessage.append("5 => Closing"); | |
|
710 | break; | |
|
711 | case 6: | |
|
712 | socketMessage.append("6 => Listening"); | |
|
713 | break; | |
|
714 | } | |
|
715 | UI->rmapSendStateLabel->setText(socketMessage); | |
|
716 | APPENDTOLOG(socketMessage); | |
|
717 | } | |
|
718 | ||
|
719 | void rmapplugin::RMAPReceiveConnectionState(QAbstractSocket::SocketState socketState) // SLOT | |
|
720 | { | |
|
721 | UI->rmapReceiveStateLabel->setText(""); | |
|
722 | QString socketMessage = "RMAP Receive Socket State: "; | |
|
723 | switch(socketState) | |
|
724 | { | |
|
725 | case QAbstractSocket::UnconnectedState : | |
|
726 | socketMessage.append("0 => Unconnected"); | |
|
727 | break; | |
|
728 | case 1: | |
|
729 | socketMessage.append("1 => HostLookup"); | |
|
730 | break; | |
|
731 | case 2: | |
|
732 | socketMessage.append("2 => Connecting"); | |
|
733 | break; | |
|
734 | case 3: | |
|
735 | socketMessage.append("3 => Connected"); | |
|
736 | break; | |
|
737 | case 4: | |
|
738 | socketMessage.append("4 => Bound"); | |
|
739 | break; | |
|
740 | case 5: | |
|
741 | socketMessage.append("5 => Closing"); | |
|
742 | break; | |
|
743 | case 6: | |
|
744 | socketMessage.append("6 => Listening"); | |
|
745 | break; | |
|
746 | } | |
|
747 | UI->rmapReceiveStateLabel->setText(socketMessage); | |
|
748 | APPENDTOLOG(socketMessage); | |
|
749 | } | |
|
750 | ||
|
751 | void rmapplugin::GRESBConnectionState(QAbstractSocket::SocketState socketState) // SLOT | |
|
752 | { | |
|
753 | UI->gresbStatusQueryLabel->setText(""); | |
|
754 | QString socketMessage = "GRESB status query socket (port 3010): "; | |
|
755 | switch(socketState) | |
|
756 | { | |
|
757 | case QAbstractSocket::UnconnectedState : | |
|
758 | socketMessage.append("0 => Unconnected"); | |
|
759 | break; | |
|
760 | case 1: | |
|
761 | socketMessage.append("1 => HostLookup"); | |
|
762 | break; | |
|
763 | case 2: | |
|
764 | socketMessage.append("2 => Connecting"); | |
|
765 | break; | |
|
766 | case 3: | |
|
767 | socketMessage.append("3 => Connected"); | |
|
768 | break; | |
|
769 | case 4: | |
|
770 | socketMessage.append("4 => Bound"); | |
|
771 | break; | |
|
772 | case 5: | |
|
773 | socketMessage.append("5 => Closing"); | |
|
774 | break; | |
|
775 | case 6: | |
|
776 | socketMessage.append("6 => Listening"); | |
|
777 | break; | |
|
778 | } | |
|
779 | UI->gresbStatusQueryLabel->setText(socketMessage); | |
|
780 | } | |
|
781 | ||
|
782 | void rmapplugin::reTestSPWLink() // SLOT | |
|
783 | { | |
|
784 | if (GRESBStatusQueryRequest(LinkStatus, UI->spwLinkSpinBox->value()) == 0) | |
|
785 | { | |
|
786 | UI->gresbStatusQueryDialog->accept(); | |
|
787 | } | |
|
788 | } | |
|
789 | ||
|
790 | int rmapplugin::GRESBStatusQuery() // SLOT | |
|
791 | { | |
|
792 | GRESBStatusQueryRequest(LinkStatus, 0); | |
|
793 | GRESBStatusQueryRequest(LinkStatus, 1); | |
|
794 | GRESBStatusQueryRequest(LinkStatus, 2); | |
|
795 | GRESBStatusQueryRequest(LinkStatistics, 0); | |
|
796 | GRESBStatusQueryRequest(LinkStatistics, 1); | |
|
797 | GRESBStatusQueryRequest(LinkStatistics, 2); | |
|
798 | return 0; | |
|
799 | } | |
|
800 | ||
|
801 | 266 | void rmapplugin::RMAP_write_reply_setText(QString text) |
|
802 | 267 | { |
|
803 | 268 | this->UI->RMAP_write_reply->setText(text); |
@@ -811,108 +276,6 void rmapplugin::appendToLog(QString tex | |||
|
811 | 276 | ///////////////////// |
|
812 | 277 | // INTERNAL FUNCTIONS |
|
813 | 278 | |
|
814 | int rmapplugin::GRESBStatusQueryRequest(GresbStatusQueryOption option, char link) | |
|
815 | { | |
|
816 | gresb_status_query_t statusQueryCommand; | |
|
817 | gresb_link_status_reply_t linkStatusReply; | |
|
818 | gresb_link_statistics_reply_t linkStatisticsReply; | |
|
819 | QTime statusQueryTimeout; | |
|
820 | QString console_message; | |
|
821 | ||
|
822 | statusQueryCommand.protocolIdentifier = (char) 0x02; | |
|
823 | statusQueryCommand.reserved1 = (char) 0x00; | |
|
824 | statusQueryCommand.reserved0 = (char) 0x00; | |
|
825 | statusQueryCommand.option = (char) option; | |
|
826 | statusQueryCommand.value3 = (char) 0x00; | |
|
827 | statusQueryCommand.value2 = (char) 0x00; | |
|
828 | statusQueryCommand.value1 = (char) 0x00; | |
|
829 | statusQueryCommand.value0 = (char) link; | |
|
830 | ||
|
831 | GRESBStatusQuery_SOCKET->write((char*) ((void*) &statusQueryCommand), sizeof(statusQueryCommand)); | |
|
832 | GRESBStatusQuery_SOCKET->flush(); | |
|
833 | GRESBStatusQuery_SOCKET->waitForBytesWritten(1000); | |
|
834 | ||
|
835 | statusQueryTimeout.start(); | |
|
836 | while(GRESBStatusQuery_SOCKET->bytesToWrite() > 0) | |
|
837 | { | |
|
838 | GRESBStatusQuery_SOCKET->waitForBytesWritten(100); | |
|
839 | if(statusQueryTimeout.elapsed()>1000) | |
|
840 | { | |
|
841 | APPENDTOLOG("WARNING === in function GRESBStatusQueryRequest of rmapplugin *** sending StatusQueryCommand timeout"); | |
|
842 | return 1; | |
|
843 | } | |
|
844 | } | |
|
845 | ||
|
846 | switch (option) | |
|
847 | { | |
|
848 | case LinkStatus: | |
|
849 | { | |
|
850 | statusQueryTimeout.start(); | |
|
851 | while(GRESBStatusQuery_SOCKET->bytesAvailable() < (int) sizeof(linkStatusReply)) | |
|
852 | { | |
|
853 | GRESBStatusQuery_SOCKET->waitForReadyRead(100); | |
|
854 | if(statusQueryTimeout.elapsed()>1000) | |
|
855 | { | |
|
856 | console_message.sprintf("GRESBStatusQueryRequest / LinkStatus => error timeout bytesAvailable()\n"); | |
|
857 | APPENDTOLOG(console_message); | |
|
858 | return 1; | |
|
859 | } | |
|
860 | } | |
|
861 | GRESBStatusQuery_SOCKET->read((char*) ((void*) &linkStatusReply), (int) sizeof(linkStatusReply)); | |
|
862 | console_message.sprintf("%x", linkStatusReply.byte0); | |
|
863 | UI->spwLinkStatusEnquiry->statusQueryTable->item(0, link)->setText(console_message); | |
|
864 | console_message.sprintf("%d", linkStatusReply.byte1); | |
|
865 | UI->spwLinkStatusEnquiry->statusQueryTable->item(1, link)->setText(console_message); | |
|
866 | if (linkStatusReply.byte0 == 0) return 1; | |
|
867 | break; | |
|
868 | } | |
|
869 | case LinkStatistics: | |
|
870 | { | |
|
871 | statusQueryTimeout.start(); | |
|
872 | while(GRESBStatusQuery_SOCKET->bytesAvailable() < (int) sizeof(linkStatisticsReply)) | |
|
873 | { | |
|
874 | GRESBStatusQuery_SOCKET->waitForReadyRead(100); | |
|
875 | if(statusQueryTimeout.elapsed()>1000) | |
|
876 | { | |
|
877 | console_message.sprintf("GRESBStatusQueryRequest / LinkStatistics => error timeout bytesAvailable()\n"); | |
|
878 | APPENDTOLOG(console_message); | |
|
879 | return 1; | |
|
880 | } | |
|
881 | } | |
|
882 | GRESBStatusQuery_SOCKET->read((char*) ((void*) &linkStatisticsReply), sizeof(linkStatisticsReply)); | |
|
883 | console_message.sprintf("%d", charTab_TO_int(linkStatisticsReply.sizeOfDataTransmitted)); | |
|
884 | UI->spwLinkStatusEnquiry->statusQueryTable->item(9, link)->setText(console_message); | |
|
885 | console_message.sprintf("%d", charTab_TO_int(linkStatisticsReply.numberOfPacketsTransmitted)); | |
|
886 | UI->spwLinkStatusEnquiry->statusQueryTable->item(8, link)->setText(console_message); | |
|
887 | console_message.sprintf("%d", charTab_TO_int(linkStatisticsReply.numberOfTruncatedPacketsReceived)); | |
|
888 | UI->spwLinkStatusEnquiry->statusQueryTable->item(6, link)->setText(console_message); | |
|
889 | console_message.sprintf("%d", charTab_TO_int(linkStatisticsReply.numberOfPacketsWithEEPReceived)); | |
|
890 | UI->spwLinkStatusEnquiry->statusQueryTable->item(5, link)->setText(console_message); | |
|
891 | console_message.sprintf("%d", charTab_TO_int(linkStatisticsReply.sizeOfDataReceived)); | |
|
892 | UI->spwLinkStatusEnquiry->statusQueryTable->item(4, link)->setText(console_message); | |
|
893 | console_message.sprintf("%d", charTab_TO_int(linkStatisticsReply.numberOfPacketsReceived)); | |
|
894 | UI->spwLinkStatusEnquiry->statusQueryTable->item(3, link)->setText(console_message); | |
|
895 | break; | |
|
896 | } | |
|
897 | case NodeAddressStatistics: | |
|
898 | { | |
|
899 | break; | |
|
900 | } | |
|
901 | case GetRoute: | |
|
902 | { | |
|
903 | break; | |
|
904 | } | |
|
905 | } | |
|
906 | return 0; | |
|
907 | } | |
|
908 | ||
|
909 | int rmapplugin::charTab_TO_int(char *charTab) | |
|
910 | { | |
|
911 | int result = 0; | |
|
912 | result = (charTab[0]<<24) +(charTab[1]<<16) +(charTab[2]<<8) + charTab[3]; | |
|
913 | return result; | |
|
914 | } | |
|
915 | ||
|
916 | 279 | void rmapplugin::gresbSelection(bool flag) |
|
917 | 280 | { |
|
918 | 281 | if (flag == true) UI->selection_GROUPBOX->setEnabled(false); |
@@ -50,44 +50,27 class rmapplugin : public lppmonplugin | |||
|
50 | 50 | public: |
|
51 | 51 | explicit rmapplugin(QWidget *parent = 0); |
|
52 | 52 | ~rmapplugin(); |
|
53 | int GRESBStatusQueryRequest(GresbStatusQueryOption option, char link); | |
|
54 | int charTab_TO_int(char *charTab); | |
|
55 | unsigned int ReadGRESB(unsigned int *Value,unsigned int count,unsigned int address=0); | |
|
56 | unsigned int WriteGRESB(unsigned int *Value,unsigned int count,unsigned int address=0); | |
|
57 | unsigned int WriteSPWGRESB(char *Value, unsigned int count, char targetLogicalAddress, char userApplication); | |
|
58 | 53 | |
|
59 | 54 | public slots: |
|
60 | 55 | unsigned int Write(unsigned int *Value,unsigned int count,unsigned int address=0); |
|
61 | 56 | unsigned int Read(unsigned int *Value,unsigned int count,unsigned int address=0); |
|
57 | unsigned int WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication); | |
|
58 | void openBridge(); | |
|
59 | void closeBridge(); | |
|
62 | 60 | // |
|
63 | unsigned int WriteSPW(char *Value, unsigned int count, char targetLogicalAddress, char userApplication); | |
|
64 | 61 | void sendCCSDS(); |
|
65 | 62 | void send_TC_LFR_UPDATE_TIME(); |
|
66 | 63 | void reset_TC_LFR_UPDATE_TIME(); |
|
67 | int GRESBStatusQuery(); | |
|
68 | 64 | void displayOnConsole(QString message) {this->UI->console->append(message);} |
|
69 | 65 | // |
|
70 | void RMAP_CONNECT(); | |
|
71 | void RMAP_DISCONNECT(); | |
|
72 | void openBridge(); | |
|
73 | void closeBridge(); | |
|
74 | int RMAPSendReadCommand(); | |
|
75 | int RMAPSendWriteCommand(); | |
|
76 | void reTestSPWLink(); | |
|
77 | // | |
|
78 | void RMAPSendConnectionState(QAbstractSocket::SocketState socketState); | |
|
79 | void RMAPReceiveConnectionState(QAbstractSocket::SocketState socketState); | |
|
80 | void GRESBConnectionState(QAbstractSocket::SocketState socketState); | |
|
81 | // | |
|
82 | 66 | void gresbSelection(bool flag); |
|
83 | void activatePluginViaStarDundee(bool flag) {emit activateSig(flag);} | |
|
84 | 67 | void RMAP_write_reply_setText(QString text); |
|
85 | 68 | void appendToLog(QString text); |
|
69 | // | |
|
70 | void activatePlugin(bool flag) {emit activateSig(flag);} | |
|
86 | 71 | void bridgeHasChanged(selectedBridge bridge) {currentBridge = bridge;} |
|
87 | 72 | |
|
88 | 73 | signals: |
|
89 | void ccsdsPacketReadyRead(char *ccsdsPacket, unsigned int size); | |
|
90 | void gresbIsOpen(bool); | |
|
91 | 74 | |
|
92 | 75 | private: |
|
93 | 76 | selectedBridge currentBridge; |
@@ -100,8 +83,6 private: | |||
|
100 | 83 | unsigned int time_COARSE; |
|
101 | 84 | unsigned int time_FINE; |
|
102 | 85 | spwpacketreceiver* spwPacketReceiverOBJECT; |
|
103 | unsigned int WriteBLOCK(char *data,unsigned int nbBytes,unsigned int address=0); | |
|
104 | unsigned int ReadBLOCK(unsigned int nbBytes,unsigned int address=0); | |
|
105 | 86 | char timeCode; |
|
106 | 87 | }; |
|
107 | 88 |
@@ -31,7 +31,6 rmapPluginUI::rmapPluginUI(QWidget *pare | |||
|
31 | 31 | QWidget* spwTabWidgetPage2 = new QWidget; |
|
32 | 32 | QWidget* spwTabWidgetPage3 = new QWidget; |
|
33 | 33 | QWidget* spwTabWidgetPage4 = new QWidget; |
|
34 | QWidget* spwTabWidgetPage5 = new QWidget; | |
|
35 | 34 | bridgeWidget = new QWidget; |
|
36 | 35 | mainLayout = new QVBoxLayout; |
|
37 | 36 | connectionLayout = new QGridLayout; |
@@ -52,8 +51,6 rmapPluginUI::rmapPluginUI(QWidget *pare | |||
|
52 | 51 | spwLinkLabel = new QLabel(tr("SPW Link: ")); |
|
53 | 52 | rmapSourceLogicalAddressLabel = new QLabel(tr("RMAP Source Logical Address: ")); |
|
54 | 53 | rmapTargetLogicalAddressLabel = new QLabel(tr("RMAP Target Logical Address: ")); |
|
55 | rmapSendStateLabel = new QLabel(tr("RMAP Send Socket State: waiting for connection")); | |
|
56 | rmapReceiveStateLabel = new QLabel(tr("RMAP Receive Socket State: waiting for connection")); | |
|
57 | 54 | logFileName = new QLabel; |
|
58 | 55 | gresbStatusQueryLabel = new QLabel(tr("Status query socket (port 3010): waiting for connection")); |
|
59 | 56 | gresbStatusQueryDialogLabel = new QLabel(tr("sockets opened but SpaceWire link not running")); |
@@ -105,18 +102,6 rmapPluginUI::rmapPluginUI(QWidget *pare | |||
|
105 | 102 | |
|
106 | 103 | logFileEn = false; |
|
107 | 104 | |
|
108 | connectionLayout->addWidget(gresbBridgeIPLabel, 0, 0, 0); | |
|
109 | connectionLayout->addWidget(gresbBridgeIPDialogBox, 0, 1, 0); | |
|
110 | connectionLayout->addWidget(gresbVirtualLinkLabel, 1, 0, 0); | |
|
111 | connectionLayout->addWidget(gresbVirtualLinkSpinBox, 1, 1, 0); | |
|
112 | connectionLayout->addWidget(spwLinkLabel, 2, 0, 0); | |
|
113 | connectionLayout->addWidget(spwLinkSpinBox, 2, 1, 0); | |
|
114 | connectionLayout->addWidget(rmapSourceLogicalAddressLabel, 3, 0, 0); | |
|
115 | connectionLayout->addWidget(rmapSourceLogicalAddressSpinBox, 3, 1, 0); | |
|
116 | connectionLayout->addWidget(rmapSendStateLabel, 4, 0, 1, 2); | |
|
117 | connectionLayout->addWidget(rmapReceiveStateLabel, 5, 0, 1, 2); | |
|
118 | connectionLayout->addWidget(gresbStatusQueryLabel, 6, 0, 1, 2); | |
|
119 | ||
|
120 | 105 | connectionLayout->setRowStretch(7, 1); |
|
121 | 106 | connectionLayout->setColumnStretch(2, 1); |
|
122 | 107 | |
@@ -136,8 +121,7 rmapPluginUI::rmapPluginUI(QWidget *pare | |||
|
136 | 121 | generalParameters_LAYOUT->setRowStretch(5, 1); |
|
137 | 122 | generalParameters_LAYOUT->setColumnStretch(2, 1); |
|
138 | 123 | |
|
139 |
gresb_GROUPBOX->setLayout( |
|
|
140 | //gresb_GROUPBOX->setLayout(gresbBridge->layout()); | |
|
124 | gresb_GROUPBOX->setLayout(gresbBridge->layout()); | |
|
141 | 125 | gresb_GROUPBOX->setVisible(false); |
|
142 | 126 | stardundee_GROUPBOX->setLayout(starDundee->layout()); |
|
143 | 127 | stardundee_GROUPBOX->setVisible(false); |
@@ -166,35 +150,34 rmapPluginUI::rmapPluginUI(QWidget *pare | |||
|
166 | 150 | spwTabWidget->addTab(spwTabWidgetPage2, tr("status")); |
|
167 | 151 | spwTabWidget->addTab(spwTabWidgetPage3, tr("console")); |
|
168 | 152 | spwTabWidget->addTab(spwTabWidgetPage4, tr("DMA")); |
|
169 | spwTabWidget->addTab(spwTabWidgetPage5, tr("gresb")); | |
|
170 | 153 | |
|
171 | 154 | spwTabWidgetPage0->setLayout(selectionLayout); |
|
172 | 155 | spwTabWidgetPage1->setLayout(ccsdsLayout); |
|
173 | 156 | spwTabWidgetPage2->setLayout(this->spwLinkStatusEnquiry->mainLayout); |
|
174 | 157 | spwTabWidgetPage3->setLayout(consoleLayout); |
|
175 | 158 | spwTabWidgetPage4->setLayout(spectralMatricesDMASimulator->mainLayout); |
|
176 | spwTabWidgetPage5->setLayout(gresbBridge->layout()); | |
|
159 | ||
|
177 | 160 | mainLayout->addWidget(spwTabWidget); |
|
178 | 161 | setLayout(mainLayout); |
|
179 | 162 | |
|
180 | // GRESB STATUS QUERY DIALOG | |
|
181 | gresbStatusQueryDialogLayout = new QGridLayout; | |
|
182 | gresbStatusQueryDialogLayout->addWidget(gresbStatusQueryDialogLabel, 0, 0, 1, 2); | |
|
183 | gresbStatusQueryDialogLayout->addWidget(gresbStatusQueryRetryButton, 1, 0, 0); | |
|
184 | gresbStatusQueryDialogLayout->addWidget(gresbStatusQueryAbortButton, 1, 1, 0); | |
|
185 | gresbStatusQueryDialog->setLayout(gresbStatusQueryDialogLayout); | |
|
186 | ||
|
187 | connect(gresbStatusQueryAbortButton, SIGNAL(clicked()), gresbStatusQueryDialog, SLOT(reject())); | |
|
163 | //connect(gresbStatusQueryAbortButton, SIGNAL(clicked()), gresbStatusQueryDialog, SLOT(reject())); | |
|
188 | 164 | connect(this->clearConsoleButton, SIGNAL(clicked()), this->console, SLOT(clear())); |
|
165 | // briges | |
|
189 | 166 | connect(this->selectGRESB_BUTTON, SIGNAL(clicked()), this, SLOT(selectionBetweenGresbAndStarDundee())); |
|
190 | 167 | connect(this->selectStarDundee_BUTTON, SIGNAL(clicked()), this, SLOT(selectionBetweenGresbAndStarDundee())); |
|
191 | 168 | connect(this->starDundee, SIGNAL(isOpen(bool)), this, SLOT(isOpen(bool))); |
|
169 | connect(this->gresbBridge, SIGNAL(isOpen(bool)), this, SLOT(isOpen(bool))); | |
|
170 | ||
|
192 | 171 | connect(this->rmapTargetLogicalAddressSpinBox, SIGNAL(valueChanged(int)), this->starDundee, SLOT(targetHasChanged(int))); |
|
172 | connect(this->rmapTargetLogicalAddressSpinBox, SIGNAL(valueChanged(int)), this->gresbBridge, SLOT(targetHasChanged(int))); | |
|
193 | 173 | |
|
194 | 174 | // command code |
|
195 | 175 | connect(this->RMAP_write_reply, SIGNAL(clicked()), this, SLOT(getCommandCode())); |
|
196 | 176 | connect(this->RMAP_write_verify, SIGNAL(clicked()), this, SLOT(getCommandCode())); |
|
197 |
connect(this, SIGNAL(commandCodeHasChanged(RMAP_command_codes)), |
|
|
177 | connect(this, SIGNAL(commandCodeHasChanged(RMAP_command_codes)), | |
|
178 | this->starDundee, SLOT(commandCodeHasChanged(RMAP_command_codes))); | |
|
179 | connect(this, SIGNAL(commandCodeHasChanged(RMAP_command_codes)), | |
|
180 | this->gresbBridge, SLOT(commandCodeHasChanged(RMAP_command_codes))); | |
|
198 | 181 | |
|
199 | 182 | getCommandCode(); // init the command code value |
|
200 | 183 | rmapTargetLogicalAddressSpinBox->setValue(254); |
General Comments 0
You need to be logged in to leave comments.
Login now