Skip to content

Commit 05b817f

Browse files
timcanhambocchino
andauthored
Work/dp catalog (#2713)
* Starting on FDD for DpCatalog * More DpCatalog SDD edits * More refined DpCatalog requirements * Starting prototype code * Working on DpCatalog build command * More DpCatalog work * More DpCatalog work * More work on reading DP headers * More work... * Continued work * Spelling fixes * More spelling fixes * First run of init unit test * One DP works * Refactor unit test helpers * Working on multiple DPs * More work on multiple DPs * Fixed filesRead bug * More merge fixes * Adding DPs to SignalGen * Adding DP components * Added DP directory to DpWriter * First working version of Data Products! * Added missing FileDownlink connection * Added early proto warning to SDD. * Switched to Fw::FileNameString * Fixed unit test compile * Add missing override keyword * Fix unit test override * Fixed format specifiers * Reformat code * Revise DpWriter uts * Revise dp writer * Revise dp writer * Removed extra ; * Fix markdown broken links * Updated SDD to force CI to run again * Adding async DP request example * Working on async example * Still working on async DP * Remove test printf * Another merge with F Prime devel * Working on binary tree implementation * Work in progress. Doesn't work yet * Still working * debug launch config * fixed pre-launch run step * Some progress on algo * 2 and 3 nodes work * Refactored some code * Tree traverse seems to work! * One transmitted test * Fixed NULL to nullptr * Fixed spelling * Fixed memory alignment * Starting on state file * Fixed spelling - AGAIN * Added reading of the state file * Added function to get state for DP from state file * Added state file data pruning function * Code to update the state file * Debugging DpCat * More work on DPs * Working on state file * Added to spelling expect.txt * fix double 'the' * Testing with DpManager/SignalGen * Some compile fixes * Adding more test cases * Fixed downlink bug * Fix SignalGen unit test * Updated SDD and some CI error fixes * Fix SDD typo * Working on docs * Docs/comments updates * Fix typo --------- Co-authored-by: Robert L. Bocchino Jr. <[email protected]>
1 parent 5c6eb7e commit 05b817f

22 files changed

+1354
-190
lines changed

.github/actions/spelling/excludes.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
(?:^|/)pyproject.toml
1212
(?:^|/)requirements(?:-dev|-doc|-test|)\.txt$
1313
(?:^|/)vendor/
14+
(?:^|/)launch\.json$
1415
/doc/xml/
1516
/html/
1617
/third-party/

.github/actions/spelling/expect.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ DPWRITER
247247
DRAINBUFFERS
248248
drv
249249
dspal
250+
Dstate
250251
Duerschmid
251252
duey
252253
dumparch
@@ -346,6 +347,7 @@ gencode
346347
genfile
347348
GENHUB
348349
genshi
350+
getblocks
349351
getchildren
350352
getcontext
351353
getdata
@@ -665,6 +667,7 @@ parseable
665667
PASSIVERATEGROUP
666668
PASSIVERATEGROUPIMPLTESTER
667669
pathmaker
670+
patsubst
668671
pbuild
669672
pcmake
670673
pcomp
@@ -819,6 +822,7 @@ SENDPARTIAL
819822
seqgen
820823
serializables
821824
setaffinity
825+
setblocks
822826
setdata
823827
setid
824828
setinheritsched

Ref/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ channels/
77
events/
88
dict/
99
DpCat
10-
10+
seq

Ref/SignalGen/Commands.fppi

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@ Signal Generator Settings
2-
async command SignalGen_Settings(
2+
async command Settings(
33
Frequency: U32
44
Amplitude: F32
55
Phase: F32
@@ -8,16 +8,24 @@ async command SignalGen_Settings(
88
opcode 0x00
99

1010
@ Toggle Signal Generator On/Off.
11-
async command SignalGen_Toggle \
11+
async command Toggle \
1212
opcode 1
1313

1414
@ Skip next sample
15-
async command SignalGen_Skip \
15+
async command Skip \
1616
opcode 2
1717

18+
enum DpReqType {
19+
IMMEDIATE
20+
ASYNC
21+
}
22+
23+
1824
@ Signal Generator Settings
19-
async command SignalGen_Dp(
20-
records: U32
21-
) \
25+
async command Dp(
26+
reqType: DpReqType
27+
records: U32
28+
$priority: U32
29+
) \
2230
opcode 3
2331

Ref/SignalGen/Events.fppi

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@ Signal Generator Settings Changed
2-
event SignalGen_SettingsChanged(
2+
event SettingsChanged(
33
Frequency: U32
44
Amplitude: F32
55
Phase: F32
@@ -9,30 +9,54 @@ event SignalGen_SettingsChanged(
99
id 0 \
1010
format "Set Frequency(Hz) {}, Amplitude {f}, Phase {f}, Signal Type {}"
1111

12-
event SignalGen_DpStarted(
12+
event DpStarted(
1313
records: U32
1414
) \
1515
severity activity low \
1616
id 1 \
1717
format "Writing {} DP records"
1818

19-
event SignalGen_DpComplete(
19+
event DpComplete(
2020
records: U32
2121
bytes: U32
2222
) \
2323
severity activity low \
2424
id 2 \
2525
format "Writing {} DP records {} bytes total"
2626

27-
event SignalGen_DpRecordFull(
27+
event DpRecordFull(
2828
records: U32
2929
bytes: U32
3030
) \
3131
severity warning low \
3232
id 3 \
3333
format "DP container full with {} records and {} bytes. Closing DP."
3434

35-
event SignalGen_DpsNotConnected \
35+
event DpsNotConnected \
3636
severity warning high \
3737
id 4 \
3838
format "DP Ports not connected!"
39+
40+
event DpMemoryFail \
41+
severity warning high \
42+
id 5 \
43+
format "Failed to acquire a DP buffer"
44+
45+
event InSufficientDpRecords \
46+
severity warning high \
47+
id 6 \
48+
format "Need to request at least one record"
49+
50+
event DpMemRequested(
51+
$size: U32
52+
) \
53+
severity activity low \
54+
id 7 \
55+
format "Requesting {} bytes for DP"
56+
57+
event DpMemReceived(
58+
$size: U32
59+
) \
60+
severity activity low \
61+
id 8 \
62+
format "Received {} bytes for DP"

Ref/SignalGen/SignalGen.cpp

Lines changed: 74 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ namespace Ref {
4141
skipOne(false),
4242
m_dpInProgress(false),
4343
m_numDps(0),
44-
m_currDp(0)
44+
m_currDp(0),
45+
m_dpPriority(0)
4546
{}
4647

4748

@@ -134,15 +135,22 @@ namespace Ref {
134135

135136
// if a Data product is being generated, store a record
136137
if (this->m_dpInProgress) {
138+
// printf("DP1: %u %u %lu %u\n",
139+
// this->m_dpContainer.getBuffer().getSize(),
140+
// SignalInfo::SERIALIZED_SIZE,
141+
// this->m_dpContainer.getDataSize(),
142+
// this->m_dpContainer.getBuffer().getSerializeRepr().getBuffLeft()
143+
// );
137144
Fw::SerializeStatus stat = this->m_dpContainer.serializeRecord_DataRecord(sigInfo);
138145
this->m_currDp++;
139146
this->m_dpBytes += SignalInfo::SERIALIZED_SIZE;
147+
// printf("DP2: %u %u %lu\n",this->m_dpContainer.getBuffer().getSize(),this->m_dpBytes,this->m_dpContainer.getDataSize());
140148
// check for full data product
141149
if (Fw::SerializeStatus::FW_SERIALIZE_NO_ROOM_LEFT == stat) {
142-
this->log_WARNING_LO_SignalGen_DpRecordFull(this->m_currDp,this->m_dpBytes);
150+
this->log_WARNING_LO_DpRecordFull(this->m_currDp,this->m_dpBytes);
143151
this->cleanupAndSendDp();
144152
} else if (this->m_currDp == this->m_numDps) { // if we reached the target number of DPs
145-
this->log_ACTIVITY_LO_SignalGen_DpComplete(this->m_numDps,this->m_dpBytes);
153+
this->log_ACTIVITY_LO_DpComplete(this->m_numDps,this->m_dpBytes);
146154
this->cleanupAndSendDp();
147155
}
148156

@@ -153,7 +161,7 @@ namespace Ref {
153161
this->ticks += 1;
154162
}
155163

156-
void SignalGen::SignalGen_Settings_cmdHandler(
164+
void SignalGen::Settings_cmdHandler(
157165
FwOpcodeType opCode, /*!< The opcode*/
158166
U32 cmdSeq, /*!< The command sequence number*/
159167
U32 Frequency,
@@ -175,12 +183,12 @@ namespace Ref {
175183
this->sigPairHistory[i].settime(0.0f);
176184
this->sigPairHistory[i].setvalue(0.0f);
177185
}
178-
this->log_ACTIVITY_LO_SignalGen_SettingsChanged(this->signalFrequency, this->signalAmplitude, this->signalPhase, this->sigType);
186+
this->log_ACTIVITY_LO_SettingsChanged(this->signalFrequency, this->signalAmplitude, this->signalPhase, this->sigType);
179187
this->tlmWrite_Type(SigType);
180188
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
181189
}
182190

183-
void SignalGen::SignalGen_Toggle_cmdHandler(
191+
void SignalGen::Toggle_cmdHandler(
184192
FwOpcodeType opCode, /*!< The opcode*/
185193
U32 cmdSeq /*!< The command sequence number*/
186194
)
@@ -190,7 +198,7 @@ namespace Ref {
190198
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
191199
}
192200

193-
void SignalGen::SignalGen_Skip_cmdHandler(
201+
void SignalGen::Skip_cmdHandler(
194202
FwOpcodeType opCode, /*!< The opcode*/
195203
U32 cmdSeq /*!< The command sequence number*/
196204
)
@@ -199,34 +207,64 @@ namespace Ref {
199207
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
200208
}
201209

202-
void SignalGen ::
203-
SignalGen_Dp_cmdHandler(
204-
FwOpcodeType opCode,
205-
U32 cmdSeq,
206-
U32 records
207-
)
210+
void SignalGen::Dp_cmdHandler(
211+
FwOpcodeType opCode,
212+
U32 cmdSeq,
213+
Ref::SignalGen_DpReqType reqType,
214+
U32 records,
215+
U32 priority
216+
)
208217
{
218+
// at least one record
219+
if (0 == records) {
220+
this->log_WARNING_HI_InSufficientDpRecords();
221+
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::VALIDATION_ERROR);
222+
return;
223+
}
224+
209225
// make sure DPs are available
210226
if (
211227
not this->isConnected_productGetOut_OutputPort(0)
212228
) {
213-
this->log_WARNING_HI_SignalGen_DpsNotConnected();
229+
this->log_WARNING_HI_DpsNotConnected();
214230
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
215231
return;
216232
}
217233

218-
// get DP buffer
219-
this->dpGet_DataContainer(records*SIZE_OF_DataRecord_RECORD,this->m_dpContainer);
220-
this->m_dpInProgress = true;
234+
// get DP buffer. Use sync or async request depending on
235+
// requested type
236+
FwSizeType dpSize = records*(SignalInfo::SERIALIZED_SIZE + sizeof(FwDpIdType));
221237
this->m_numDps = records;
222238
this->m_currDp = 0;
223-
this->log_ACTIVITY_LO_SignalGen_DpStarted(records);
224-
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
239+
this->m_dpPriority = static_cast<FwDpPriorityType>(priority);
240+
this->log_ACTIVITY_LO_DpMemRequested(dpSize);
241+
if (Ref::SignalGen_DpReqType::IMMEDIATE == reqType) {
242+
Fw::Success stat = this->dpGet_DataContainer(dpSize,this->m_dpContainer);
243+
// make sure we got the memory we wanted
244+
if (Fw::Success::FAILURE == stat) {
245+
this->log_WARNING_HI_DpMemoryFail();
246+
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
247+
} else {
248+
this->m_dpInProgress = true;
249+
this->log_ACTIVITY_LO_DpStarted(records);
250+
this->log_ACTIVITY_LO_DpMemReceived(this->m_dpContainer.getBuffer().getSize());
251+
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
252+
// override priority with requested priority
253+
this->m_dpContainer.setPriority(this->m_dpPriority);
254+
}
255+
} else if (Ref::SignalGen_DpReqType::ASYNC == reqType) {
256+
this->dpRequest_DataContainer(dpSize);
257+
this->cmdResponse_out(opCode, cmdSeq, Fw::CmdResponse::OK);
258+
} else {
259+
// should never get here
260+
FW_ASSERT(0,reqType.e);
261+
}
262+
225263
}
226264

227265
void SignalGen::cleanupAndSendDp() {
228266
this->dpSend(this->m_dpContainer);
229-
this->m_dpInProgress = 0;
267+
this->m_dpInProgress = false;
230268
this->m_dpBytes = 0;
231269
this->m_numDps = 0;
232270
this->m_currDp = 0;
@@ -244,8 +282,22 @@ namespace Ref {
244282
Fw::Success::T status
245283
)
246284
{
247-
// TODO
248-
}
249285

286+
// Make sure we got the buffer we wanted or quit
287+
if (Fw::Success::SUCCESS == status) {
288+
this->m_dpContainer = container;
289+
this->m_dpInProgress = true;
290+
// set previously requested priority
291+
this->m_dpContainer.setPriority(this->m_dpPriority);
292+
this->log_ACTIVITY_LO_DpStarted(this->m_numDps);
293+
} else {
294+
this->log_WARNING_HI_DpMemoryFail();
295+
// cleanup
296+
this->m_dpInProgress = false;
297+
this->m_dpBytes = 0;
298+
this->m_numDps = 0;
299+
this->m_currDp = 0;
300+
}
301+
}
250302

251303
};

Ref/SignalGen/SignalGen.hpp

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ namespace Ref {
3131
void schedIn_handler(
3232
NATIVE_INT_TYPE portNum, /*!< The port number*/
3333
U32 context /*!< The call order*/
34-
);
34+
) final;
3535

36-
void SignalGen_Settings_cmdHandler(
36+
void Settings_cmdHandler(
3737
FwOpcodeType opCode, /*!< The opcode*/
3838
U32 cmdSeq, /*!< The command sequence number*/
3939
U32 Frequency,
@@ -42,23 +42,26 @@ namespace Ref {
4242
Ref::SignalType SigType
4343
) final;
4444

45-
void SignalGen_Toggle_cmdHandler(
45+
void Toggle_cmdHandler(
4646
FwOpcodeType opCode, /*!< The opcode*/
4747
U32 cmdSeq /*!< The command sequence number*/
4848
) final;
49-
void SignalGen_Skip_cmdHandler(
49+
50+
void Skip_cmdHandler(
5051
FwOpcodeType opCode, /*!< The opcode*/
5152
U32 cmdSeq /*!< The command sequence number*/
5253
) final;
5354

5455
//! Handler implementation for command SignalGen_Dp
5556
//!
5657
//! Signal Generator Settings
57-
void SignalGen_Dp_cmdHandler(
58-
FwOpcodeType opCode, //!< The opcode
59-
U32 cmdSeq, //!< The command sequence number
60-
U32 records
61-
) final;
58+
void Dp_cmdHandler(
59+
FwOpcodeType opCode, //!< The opcode
60+
U32 cmdSeq, //!< The command sequence number
61+
Ref::SignalGen_DpReqType reqType,
62+
U32 records,
63+
U32 priority
64+
) final;
6265

6366
// ----------------------------------------------------------------------
6467
// Handler implementations for data products
@@ -103,6 +106,11 @@ namespace Ref {
103106
U32 m_numDps; //!< number of DPs to store
104107
U32 m_currDp; //!< current DP number
105108
U32 m_dpBytes; //!< currently serialized records
109+
FwDpPriorityType m_dpPriority; //!< stored priority for current DP
110+
111+
// for async DP
112+
FwOpcodeType m_opCode;
113+
U32 m_cmdSeq;
106114

107115
};
108116
};

0 commit comments

Comments
 (0)