F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
DpWriterComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title DpWriterComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for DpWriter component base class
5 // ======================================================================
6 
7 #include "Fw/Types/Assert.hpp"
9 #if FW_ENABLE_TEXT_LOGGING
10 #include "Fw/Types/String.hpp"
11 #endif
13 
14 namespace Svc {
15 
16  namespace {
17  enum MsgTypeEnum {
18  DPWRITER_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
19  BUFFERSENDIN_BUFFERSEND,
20  SCHEDIN_SCHED,
21  CMD_CLEAR_EVENT_THROTTLE,
22  };
23 
24  // Get the max size by constructing a union of the async input, command, and
25  // internal port serialization sizes
26  union BuffUnion {
27  BYTE bufferSendInPortSize[Fw::BufferSendPortBuffer::CAPACITY];
28  BYTE schedInPortSize[Svc::SchedPortBuffer::CAPACITY];
30  };
31 
32  // Define a message buffer class large enough to handle all the
33  // asynchronous inputs to the component
34  class ComponentIpcSerializableBuffer :
36  {
37 
38  public:
39 
40  enum {
41  // Offset into data in buffer: Size of message ID and port number
42  DATA_OFFSET = sizeof(FwEnumStoreType) + sizeof(FwIndexType),
43  // Max data size
44  MAX_DATA_SIZE = sizeof(BuffUnion),
45  // Max message size: Size of message id + size of port + max data size
46  SERIALIZATION_SIZE = DATA_OFFSET + MAX_DATA_SIZE
47  };
48 
49  ComponentIpcSerializableBuffer() : Fw::LinearBufferBase(m_buff, sizeof(m_buff)) {
50 
51  }
52 
53  private:
54  // Should be the max of all the input ports serialized sizes...
55  U8 m_buff[SERIALIZATION_SIZE];
56 
57  };
58  }
59 
60  // ----------------------------------------------------------------------
61  // Component initialization
62  // ----------------------------------------------------------------------
63 
66  FwSizeType queueDepth,
67  FwEnumStoreType instance
68  )
69  {
70  // Initialize base class
72 
73 #if !FW_DIRECT_PORT_CALLS
74  // Connect input port cmdIn
75  for (
76  FwIndexType port = 0;
77  port < static_cast<FwIndexType>(this->getNum_cmdIn_InputPorts());
78  port++
79  ) {
80  this->m_cmdIn_InputPort[port].init();
81  this->m_cmdIn_InputPort[port].addCallComp(
82  this,
83  m_p_cmdIn_in
84  );
85  this->m_cmdIn_InputPort[port].setPortNum(port);
86 
87 #if FW_OBJECT_NAMES == 1
88  Fw::ObjectName portName;
89  portName.format(
90  "%s_cmdIn_InputPort[%" PRI_FwIndexType "]",
91  this->m_objName.toChar(),
92  port
93  );
94  this->m_cmdIn_InputPort[port].setObjName(portName.toChar());
95 #endif
96  }
97 #endif
98 
99 #if !FW_DIRECT_PORT_CALLS
100  // Connect input port bufferSendIn
101  for (
102  FwIndexType port = 0;
103  port < static_cast<FwIndexType>(this->getNum_bufferSendIn_InputPorts());
104  port++
105  ) {
106  this->m_bufferSendIn_InputPort[port].init();
107  this->m_bufferSendIn_InputPort[port].addCallComp(
108  this,
109  m_p_bufferSendIn_in
110  );
111  this->m_bufferSendIn_InputPort[port].setPortNum(port);
112 
113 #if FW_OBJECT_NAMES == 1
114  Fw::ObjectName portName;
115  portName.format(
116  "%s_bufferSendIn_InputPort[%" PRI_FwIndexType "]",
117  this->m_objName.toChar(),
118  port
119  );
120  this->m_bufferSendIn_InputPort[port].setObjName(portName.toChar());
121 #endif
122  }
123 #endif
124 
125 #if !FW_DIRECT_PORT_CALLS
126  // Connect input port schedIn
127  for (
128  FwIndexType port = 0;
129  port < static_cast<FwIndexType>(this->getNum_schedIn_InputPorts());
130  port++
131  ) {
132  this->m_schedIn_InputPort[port].init();
133  this->m_schedIn_InputPort[port].addCallComp(
134  this,
135  m_p_schedIn_in
136  );
137  this->m_schedIn_InputPort[port].setPortNum(port);
138 
139 #if FW_OBJECT_NAMES == 1
140  Fw::ObjectName portName;
141  portName.format(
142  "%s_schedIn_InputPort[%" PRI_FwIndexType "]",
143  this->m_objName.toChar(),
144  port
145  );
146  this->m_schedIn_InputPort[port].setObjName(portName.toChar());
147 #endif
148  }
149 #endif
150 
151 #if !FW_DIRECT_PORT_CALLS
152  // Connect output port cmdRegIn
153  for (
154  FwIndexType port = 0;
155  port < static_cast<FwIndexType>(this->getNum_cmdRegIn_OutputPorts());
156  port++
157  ) {
158  this->m_cmdRegIn_OutputPort[port].init();
159 
160 #if FW_OBJECT_NAMES == 1
161  Fw::ObjectName portName;
162  portName.format(
163  "%s_cmdRegIn_OutputPort[%" PRI_FwIndexType "]",
164  this->m_objName.toChar(),
165  port
166  );
167  this->m_cmdRegIn_OutputPort[port].setObjName(portName.toChar());
168 #endif
169  }
170 #endif
171 
172 #if !FW_DIRECT_PORT_CALLS
173  // Connect output port cmdResponseOut
174  for (
175  FwIndexType port = 0;
176  port < static_cast<FwIndexType>(this->getNum_cmdResponseOut_OutputPorts());
177  port++
178  ) {
179  this->m_cmdResponseOut_OutputPort[port].init();
180 
181 #if FW_OBJECT_NAMES == 1
182  Fw::ObjectName portName;
183  portName.format(
184  "%s_cmdResponseOut_OutputPort[%" PRI_FwIndexType "]",
185  this->m_objName.toChar(),
186  port
187  );
188  this->m_cmdResponseOut_OutputPort[port].setObjName(portName.toChar());
189 #endif
190  }
191 #endif
192 
193 #if !FW_DIRECT_PORT_CALLS
194  // Connect output port eventOut
195  for (
196  FwIndexType port = 0;
197  port < static_cast<FwIndexType>(this->getNum_eventOut_OutputPorts());
198  port++
199  ) {
200  this->m_eventOut_OutputPort[port].init();
201 
202 #if FW_OBJECT_NAMES == 1
203  Fw::ObjectName portName;
204  portName.format(
205  "%s_eventOut_OutputPort[%" PRI_FwIndexType "]",
206  this->m_objName.toChar(),
207  port
208  );
209  this->m_eventOut_OutputPort[port].setObjName(portName.toChar());
210 #endif
211  }
212 #endif
213 
214 #if !FW_DIRECT_PORT_CALLS && FW_ENABLE_TEXT_LOGGING
215  // Connect output port textEventOut
216  for (
217  FwIndexType port = 0;
218  port < static_cast<FwIndexType>(this->getNum_textEventOut_OutputPorts());
219  port++
220  ) {
221  this->m_textEventOut_OutputPort[port].init();
222 
223 #if FW_OBJECT_NAMES == 1
224  Fw::ObjectName portName;
225  portName.format(
226  "%s_textEventOut_OutputPort[%" PRI_FwIndexType "]",
227  this->m_objName.toChar(),
228  port
229  );
230  this->m_textEventOut_OutputPort[port].setObjName(portName.toChar());
231 #endif
232  }
233 #endif
234 
235 #if !FW_DIRECT_PORT_CALLS
236  // Connect output port timeGetOut
237  for (
238  FwIndexType port = 0;
239  port < static_cast<FwIndexType>(this->getNum_timeGetOut_OutputPorts());
240  port++
241  ) {
242  this->m_timeGetOut_OutputPort[port].init();
243 
244 #if FW_OBJECT_NAMES == 1
245  Fw::ObjectName portName;
246  portName.format(
247  "%s_timeGetOut_OutputPort[%" PRI_FwIndexType "]",
248  this->m_objName.toChar(),
249  port
250  );
251  this->m_timeGetOut_OutputPort[port].setObjName(portName.toChar());
252 #endif
253  }
254 #endif
255 
256 #if !FW_DIRECT_PORT_CALLS
257  // Connect output port tlmOut
258  for (
259  FwIndexType port = 0;
260  port < static_cast<FwIndexType>(this->getNum_tlmOut_OutputPorts());
261  port++
262  ) {
263  this->m_tlmOut_OutputPort[port].init();
264 
265 #if FW_OBJECT_NAMES == 1
266  Fw::ObjectName portName;
267  portName.format(
268  "%s_tlmOut_OutputPort[%" PRI_FwIndexType "]",
269  this->m_objName.toChar(),
270  port
271  );
272  this->m_tlmOut_OutputPort[port].setObjName(portName.toChar());
273 #endif
274  }
275 #endif
276 
277 #if !FW_DIRECT_PORT_CALLS
278  // Connect output port deallocBufferSendOut
279  for (
280  FwIndexType port = 0;
281  port < static_cast<FwIndexType>(this->getNum_deallocBufferSendOut_OutputPorts());
282  port++
283  ) {
284  this->m_deallocBufferSendOut_OutputPort[port].init();
285 
286 #if FW_OBJECT_NAMES == 1
287  Fw::ObjectName portName;
288  portName.format(
289  "%s_deallocBufferSendOut_OutputPort[%" PRI_FwIndexType "]",
290  this->m_objName.toChar(),
291  port
292  );
293  this->m_deallocBufferSendOut_OutputPort[port].setObjName(portName.toChar());
294 #endif
295  }
296 #endif
297 
298 #if !FW_DIRECT_PORT_CALLS
299  // Connect output port dpWrittenOut
300  for (
301  FwIndexType port = 0;
302  port < static_cast<FwIndexType>(this->getNum_dpWrittenOut_OutputPorts());
303  port++
304  ) {
305  this->m_dpWrittenOut_OutputPort[port].init();
306 
307 #if FW_OBJECT_NAMES == 1
308  Fw::ObjectName portName;
309  portName.format(
310  "%s_dpWrittenOut_OutputPort[%" PRI_FwIndexType "]",
311  this->m_objName.toChar(),
312  port
313  );
314  this->m_dpWrittenOut_OutputPort[port].setObjName(portName.toChar());
315 #endif
316  }
317 #endif
318 
319 #if !FW_DIRECT_PORT_CALLS
320  // Connect output port procBufferSendOut
321  for (
322  FwIndexType port = 0;
323  port < static_cast<FwIndexType>(this->getNum_procBufferSendOut_OutputPorts());
324  port++
325  ) {
326  this->m_procBufferSendOut_OutputPort[port].init();
327 
328 #if FW_OBJECT_NAMES == 1
329  Fw::ObjectName portName;
330  portName.format(
331  "%s_procBufferSendOut_OutputPort[%" PRI_FwIndexType "]",
332  this->m_objName.toChar(),
333  port
334  );
335  this->m_procBufferSendOut_OutputPort[port].setObjName(portName.toChar());
336 #endif
337  }
338 #endif
339 
340  // Create the queue
341  Os::Queue::Status qStat = this->createQueue(
342  queueDepth,
343  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
344  );
345  FW_ASSERT(
346  Os::Queue::Status::OP_OK == qStat,
347  static_cast<FwAssertArgType>(qStat)
348  );
349  }
350 
351 #if !FW_DIRECT_PORT_CALLS
352 
353  // ----------------------------------------------------------------------
354  // Getters for special input ports
355  // ----------------------------------------------------------------------
356 
359  {
360  FW_ASSERT(
361  (0 <= portNum) && (portNum < this->getNum_cmdIn_InputPorts()),
362  static_cast<FwAssertArgType>(portNum)
363  );
364 
365  return &this->m_cmdIn_InputPort[portNum];
366  }
367 
368 #endif
369 
370 #if !FW_DIRECT_PORT_CALLS
371 
372  // ----------------------------------------------------------------------
373  // Getters for typed input ports
374  // ----------------------------------------------------------------------
375 
378  {
379  FW_ASSERT(
380  (0 <= portNum) && (portNum < this->getNum_bufferSendIn_InputPorts()),
381  static_cast<FwAssertArgType>(portNum)
382  );
383 
384  return &this->m_bufferSendIn_InputPort[portNum];
385  }
386 
389  {
390  FW_ASSERT(
391  (0 <= portNum) && (portNum < this->getNum_schedIn_InputPorts()),
392  static_cast<FwAssertArgType>(portNum)
393  );
394 
395  return &this->m_schedIn_InputPort[portNum];
396  }
397 
398 #endif
399 
400 #if !FW_DIRECT_PORT_CALLS
401 
402  // ----------------------------------------------------------------------
403  // Connect input ports to special output ports
404  // ----------------------------------------------------------------------
405 
408  FwIndexType portNum,
409  Fw::InputCmdRegPort* port
410  )
411  {
412  FW_ASSERT(
413  (0 <= portNum) && (portNum < this->getNum_cmdRegIn_OutputPorts()),
414  static_cast<FwAssertArgType>(portNum)
415  );
416 
417  this->m_cmdRegIn_OutputPort[portNum].addCallPort(port);
418  }
419 
422  FwIndexType portNum,
424  )
425  {
426  FW_ASSERT(
427  (0 <= portNum) && (portNum < this->getNum_cmdResponseOut_OutputPorts()),
428  static_cast<FwAssertArgType>(portNum)
429  );
430 
431  this->m_cmdResponseOut_OutputPort[portNum].addCallPort(port);
432  }
433 
436  FwIndexType portNum,
437  Fw::InputLogPort* port
438  )
439  {
440  FW_ASSERT(
441  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
442  static_cast<FwAssertArgType>(portNum)
443  );
444 
445  this->m_eventOut_OutputPort[portNum].addCallPort(port);
446  }
447 
448 #if FW_ENABLE_TEXT_LOGGING == 1
449 
450  void DpWriterComponentBase ::
451  set_textEventOut_OutputPort(
452  FwIndexType portNum,
454  )
455  {
456  FW_ASSERT(
457  (0 <= portNum) && (portNum < this->getNum_textEventOut_OutputPorts()),
458  static_cast<FwAssertArgType>(portNum)
459  );
460 
461  this->m_textEventOut_OutputPort[portNum].addCallPort(port);
462  }
463 
464 #endif
465 
468  FwIndexType portNum,
469  Fw::InputTimePort* port
470  )
471  {
472  FW_ASSERT(
473  (0 <= portNum) && (portNum < this->getNum_timeGetOut_OutputPorts()),
474  static_cast<FwAssertArgType>(portNum)
475  );
476 
477  this->m_timeGetOut_OutputPort[portNum].addCallPort(port);
478  }
479 
482  FwIndexType portNum,
483  Fw::InputTlmPort* port
484  )
485  {
486  FW_ASSERT(
487  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
488  static_cast<FwAssertArgType>(portNum)
489  );
490 
491  this->m_tlmOut_OutputPort[portNum].addCallPort(port);
492  }
493 
494 #endif
495 
496 #if !FW_DIRECT_PORT_CALLS
497 
498  // ----------------------------------------------------------------------
499  // Connect typed input ports to typed output ports
500  // ----------------------------------------------------------------------
501 
504  FwIndexType portNum,
506  )
507  {
508  FW_ASSERT(
509  (0 <= portNum) && (portNum < this->getNum_deallocBufferSendOut_OutputPorts()),
510  static_cast<FwAssertArgType>(portNum)
511  );
512 
513  this->m_deallocBufferSendOut_OutputPort[portNum].addCallPort(port);
514  }
515 
518  FwIndexType portNum,
520  )
521  {
522  FW_ASSERT(
523  (0 <= portNum) && (portNum < this->getNum_dpWrittenOut_OutputPorts()),
524  static_cast<FwAssertArgType>(portNum)
525  );
526 
527  this->m_dpWrittenOut_OutputPort[portNum].addCallPort(port);
528  }
529 
532  FwIndexType portNum,
534  )
535  {
536  FW_ASSERT(
537  (0 <= portNum) && (portNum < this->getNum_procBufferSendOut_OutputPorts()),
538  static_cast<FwAssertArgType>(portNum)
539  );
540 
541  this->m_procBufferSendOut_OutputPort[portNum].addCallPort(port);
542  }
543 
544 #endif
545 
546 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
547 
548  // ----------------------------------------------------------------------
549  // Connect serial input ports to special output ports
550  // ----------------------------------------------------------------------
551 
554  FwIndexType portNum,
555  Fw::InputSerializePort* port
556  )
557  {
558  FW_ASSERT(
559  (0 <= portNum) && (portNum < this->getNum_cmdRegIn_OutputPorts()),
560  static_cast<FwAssertArgType>(portNum)
561  );
562 
563  this->m_cmdRegIn_OutputPort[portNum].registerSerialPort(port);
564  }
565 
568  FwIndexType portNum,
569  Fw::InputSerializePort* port
570  )
571  {
572  FW_ASSERT(
573  (0 <= portNum) && (portNum < this->getNum_cmdResponseOut_OutputPorts()),
574  static_cast<FwAssertArgType>(portNum)
575  );
576 
577  this->m_cmdResponseOut_OutputPort[portNum].registerSerialPort(port);
578  }
579 
582  FwIndexType portNum,
583  Fw::InputSerializePort* port
584  )
585  {
586  FW_ASSERT(
587  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
588  static_cast<FwAssertArgType>(portNum)
589  );
590 
591  this->m_eventOut_OutputPort[portNum].registerSerialPort(port);
592  }
593 
594 #if FW_ENABLE_TEXT_LOGGING == 1
595 
596  void DpWriterComponentBase ::
597  set_textEventOut_OutputPort(
598  FwIndexType portNum,
599  Fw::InputSerializePort* port
600  )
601  {
602  FW_ASSERT(
603  (0 <= portNum) && (portNum < this->getNum_textEventOut_OutputPorts()),
604  static_cast<FwAssertArgType>(portNum)
605  );
606 
607  this->m_textEventOut_OutputPort[portNum].registerSerialPort(port);
608  }
609 
610 #endif
611 
614  FwIndexType portNum,
615  Fw::InputSerializePort* port
616  )
617  {
618  FW_ASSERT(
619  (0 <= portNum) && (portNum < this->getNum_timeGetOut_OutputPorts()),
620  static_cast<FwAssertArgType>(portNum)
621  );
622 
623  this->m_timeGetOut_OutputPort[portNum].registerSerialPort(port);
624  }
625 
628  FwIndexType portNum,
629  Fw::InputSerializePort* port
630  )
631  {
632  FW_ASSERT(
633  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
634  static_cast<FwAssertArgType>(portNum)
635  );
636 
637  this->m_tlmOut_OutputPort[portNum].registerSerialPort(port);
638  }
639 
640 #endif
641 
642 #if !FW_DIRECT_PORT_CALLS && FW_PORT_SERIALIZATION
643 
644  // ----------------------------------------------------------------------
645  // Connect serial input ports to typed output ports
646  // ----------------------------------------------------------------------
647 
650  FwIndexType portNum,
651  Fw::InputSerializePort* port
652  )
653  {
654  FW_ASSERT(
655  (0 <= portNum) && (portNum < this->getNum_deallocBufferSendOut_OutputPorts()),
656  static_cast<FwAssertArgType>(portNum)
657  );
658 
659  this->m_deallocBufferSendOut_OutputPort[portNum].registerSerialPort(port);
660  }
661 
664  FwIndexType portNum,
665  Fw::InputSerializePort* port
666  )
667  {
668  FW_ASSERT(
669  (0 <= portNum) && (portNum < this->getNum_dpWrittenOut_OutputPorts()),
670  static_cast<FwAssertArgType>(portNum)
671  );
672 
673  this->m_dpWrittenOut_OutputPort[portNum].registerSerialPort(port);
674  }
675 
678  FwIndexType portNum,
679  Fw::InputSerializePort* port
680  )
681  {
682  FW_ASSERT(
683  (0 <= portNum) && (portNum < this->getNum_procBufferSendOut_OutputPorts()),
684  static_cast<FwAssertArgType>(portNum)
685  );
686 
687  this->m_procBufferSendOut_OutputPort[portNum].registerSerialPort(port);
688  }
689 
690 #endif
691 
692  // ----------------------------------------------------------------------
693  // Command registration
694  // ----------------------------------------------------------------------
695 
698  {
700 
701  this->cmdRegIn_out(
702  0,
704  );
705  }
706 
707  // ----------------------------------------------------------------------
708  // Component construction and destruction
709  // ----------------------------------------------------------------------
710 
712  DpWriterComponentBase(const char* compName) :
713  Fw::ActiveComponentBase(compName)
714  {
715  this->m_InvalidBufferThrottle = 0;
716  this->m_BufferTooSmallForPacketThrottle = 0;
717  this->m_InvalidHeaderHashThrottle = 0;
718  this->m_InvalidHeaderThrottle = 0;
719  this->m_BufferTooSmallForDataThrottle = 0;
720  this->m_FileNameFormatErrorThrottle = 0;
721  this->m_FileOpenErrorThrottle = 0;
722  this->m_FileWriteErrorThrottle = 0;
723  }
724 
727  {
728 
729  }
730 
731 #if !FW_DIRECT_PORT_CALLS
732 
733  // ----------------------------------------------------------------------
734  // Connection status queries for special output ports
735  // ----------------------------------------------------------------------
736 
739  {
740  FW_ASSERT(
741  (0 <= portNum) && (portNum < this->getNum_cmdRegIn_OutputPorts()),
742  static_cast<FwAssertArgType>(portNum)
743  );
744 
745  return this->m_cmdRegIn_OutputPort[portNum].isConnected();
746  }
747 
750  {
751  FW_ASSERT(
752  (0 <= portNum) && (portNum < this->getNum_cmdResponseOut_OutputPorts()),
753  static_cast<FwAssertArgType>(portNum)
754  );
755 
756  return this->m_cmdResponseOut_OutputPort[portNum].isConnected();
757  }
758 
761  {
762  FW_ASSERT(
763  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
764  static_cast<FwAssertArgType>(portNum)
765  );
766 
767  return this->m_eventOut_OutputPort[portNum].isConnected();
768  }
769 
770 #if FW_ENABLE_TEXT_LOGGING == 1
771 
772  bool DpWriterComponentBase ::
773  isConnected_textEventOut_OutputPort(FwIndexType portNum) const
774  {
775  FW_ASSERT(
776  (0 <= portNum) && (portNum < this->getNum_textEventOut_OutputPorts()),
777  static_cast<FwAssertArgType>(portNum)
778  );
779 
780  return this->m_textEventOut_OutputPort[portNum].isConnected();
781  }
782 
783 #endif
784 
787  {
788  FW_ASSERT(
789  (0 <= portNum) && (portNum < this->getNum_timeGetOut_OutputPorts()),
790  static_cast<FwAssertArgType>(portNum)
791  );
792 
793  return this->m_timeGetOut_OutputPort[portNum].isConnected();
794  }
795 
798  {
799  FW_ASSERT(
800  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
801  static_cast<FwAssertArgType>(portNum)
802  );
803 
804  return this->m_tlmOut_OutputPort[portNum].isConnected();
805  }
806 
807 #endif
808 
809 #if !FW_DIRECT_PORT_CALLS
810 
811  // ----------------------------------------------------------------------
812  // Connection status queries for typed output ports
813  // ----------------------------------------------------------------------
814 
817  {
818  FW_ASSERT(
819  (0 <= portNum) && (portNum < this->getNum_deallocBufferSendOut_OutputPorts()),
820  static_cast<FwAssertArgType>(portNum)
821  );
822 
823  return this->m_deallocBufferSendOut_OutputPort[portNum].isConnected();
824  }
825 
828  {
829  FW_ASSERT(
830  (0 <= portNum) && (portNum < this->getNum_dpWrittenOut_OutputPorts()),
831  static_cast<FwAssertArgType>(portNum)
832  );
833 
834  return this->m_dpWrittenOut_OutputPort[portNum].isConnected();
835  }
836 
839  {
840  FW_ASSERT(
841  (0 <= portNum) && (portNum < this->getNum_procBufferSendOut_OutputPorts()),
842  static_cast<FwAssertArgType>(portNum)
843  );
844 
845  return this->m_procBufferSendOut_OutputPort[portNum].isConnected();
846  }
847 
848 #endif
849 
850  // ----------------------------------------------------------------------
851  // Port handler base-class functions for special input ports
852  //
853  // Call these functions directly to bypass the corresponding ports
854  // ----------------------------------------------------------------------
855 
858  FwIndexType portNum,
859  FwOpcodeType opCode,
860  U32 cmdSeq,
861  Fw::CmdArgBuffer& args
862  )
863  {
864 
865  const U32 idBase = this->getIdBase();
866  FW_ASSERT(opCode >= idBase, static_cast<FwAssertArgType>(opCode), static_cast<FwAssertArgType>(idBase));
867 
868  // Select base class function based on opcode
869  switch (opCode - idBase) {
872  opCode,
873  cmdSeq,
874  args
875  );
876  break;
877  }
878  default:
879  // Unknown opcode: ignore it
880  break;
881  }
882  }
883 
884  // ----------------------------------------------------------------------
885  // Port handler base-class functions for typed input ports
886  //
887  // Call these functions directly to bypass the corresponding ports
888  // ----------------------------------------------------------------------
889 
892  FwIndexType portNum,
893  Fw::Buffer& fwBuffer
894  )
895  {
896  // Make sure port number is valid
897  FW_ASSERT(
898  (0 <= portNum) && (portNum < this->getNum_bufferSendIn_InputPorts()),
899  static_cast<FwAssertArgType>(portNum)
900  );
901 
902  // Call pre-message hook
904  portNum,
905  fwBuffer
906  );
907  ComponentIpcSerializableBuffer msg;
909 
910  // Serialize message ID
911  _status = msg.serializeFrom(
912  static_cast<FwEnumStoreType>(BUFFERSENDIN_BUFFERSEND)
913  );
914  FW_ASSERT(
915  _status == Fw::FW_SERIALIZE_OK,
916  static_cast<FwAssertArgType>(_status)
917  );
918 
919  // Serialize port number
920  _status = msg.serializeFrom(portNum);
921  FW_ASSERT(
922  _status == Fw::FW_SERIALIZE_OK,
923  static_cast<FwAssertArgType>(_status)
924  );
925 
926  // Serialize argument fwBuffer
927  _status = msg.serializeFrom(fwBuffer);
928  FW_ASSERT(
929  _status == Fw::FW_SERIALIZE_OK,
930  static_cast<FwAssertArgType>(_status)
931  );
932 
933  // Send message
935  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
936 
937  FW_ASSERT(
938  qStatus == Os::Queue::OP_OK,
939  static_cast<FwAssertArgType>(qStatus)
940  );
941  }
942 
945  FwIndexType portNum,
946  U32 context
947  )
948  {
949  // Make sure port number is valid
950  FW_ASSERT(
951  (0 <= portNum) && (portNum < this->getNum_schedIn_InputPorts()),
952  static_cast<FwAssertArgType>(portNum)
953  );
954 
955  // Call pre-message hook
957  portNum,
958  context
959  );
960  ComponentIpcSerializableBuffer msg;
962 
963  // Serialize message ID
964  _status = msg.serializeFrom(
965  static_cast<FwEnumStoreType>(SCHEDIN_SCHED)
966  );
967  FW_ASSERT(
968  _status == Fw::FW_SERIALIZE_OK,
969  static_cast<FwAssertArgType>(_status)
970  );
971 
972  // Serialize port number
973  _status = msg.serializeFrom(portNum);
974  FW_ASSERT(
975  _status == Fw::FW_SERIALIZE_OK,
976  static_cast<FwAssertArgType>(_status)
977  );
978 
979  // Serialize argument context
980  _status = msg.serializeFrom(context);
981  FW_ASSERT(
982  _status == Fw::FW_SERIALIZE_OK,
983  static_cast<FwAssertArgType>(_status)
984  );
985 
986  // Send message
988  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
989 
990  FW_ASSERT(
991  qStatus == Os::Queue::OP_OK,
992  static_cast<FwAssertArgType>(qStatus)
993  );
994  }
995 
996  // ----------------------------------------------------------------------
997  // Pre-message hooks for typed async input ports
998  //
999  // Each of these functions is invoked just before processing a message
1000  // on the corresponding port. By default, they do nothing. You can
1001  // override them to provide specific pre-message behavior.
1002  // ----------------------------------------------------------------------
1003 
1006  FwIndexType portNum,
1007  Fw::Buffer& fwBuffer
1008  )
1009  {
1010  // Default: no-op
1011  }
1012 
1015  FwIndexType portNum,
1016  U32 context
1017  )
1018  {
1019  // Default: no-op
1020  }
1021 
1022 #if !FW_DIRECT_PORT_CALLS
1023 
1024  // ----------------------------------------------------------------------
1025  // Invocation functions for typed output ports
1026  // ----------------------------------------------------------------------
1027 
1030  FwIndexType portNum,
1031  Fw::Buffer& fwBuffer
1032  ) const
1033  {
1034  FW_ASSERT(
1035  (0 <= portNum) && (portNum < this->getNum_deallocBufferSendOut_OutputPorts()),
1036  static_cast<FwAssertArgType>(portNum)
1037  );
1038 
1039  FW_ASSERT(
1040  this->m_deallocBufferSendOut_OutputPort[portNum].isConnected(),
1041  static_cast<FwAssertArgType>(portNum)
1042  );
1043  this->m_deallocBufferSendOut_OutputPort[portNum].invoke(
1044  fwBuffer
1045  );
1046  }
1047 
1050  FwIndexType portNum,
1051  const Fw::StringBase& fileName,
1052  FwDpPriorityType priority,
1053  FwSizeType size
1054  ) const
1055  {
1056  FW_ASSERT(
1057  (0 <= portNum) && (portNum < this->getNum_dpWrittenOut_OutputPorts()),
1058  static_cast<FwAssertArgType>(portNum)
1059  );
1060 
1061  FW_ASSERT(
1062  this->m_dpWrittenOut_OutputPort[portNum].isConnected(),
1063  static_cast<FwAssertArgType>(portNum)
1064  );
1065  this->m_dpWrittenOut_OutputPort[portNum].invoke(
1066  fileName,
1067  priority,
1068  size
1069  );
1070  }
1071 
1074  FwIndexType portNum,
1075  Fw::Buffer& fwBuffer
1076  ) const
1077  {
1078  FW_ASSERT(
1079  (0 <= portNum) && (portNum < this->getNum_procBufferSendOut_OutputPorts()),
1080  static_cast<FwAssertArgType>(portNum)
1081  );
1082 
1083  FW_ASSERT(
1084  this->m_procBufferSendOut_OutputPort[portNum].isConnected(),
1085  static_cast<FwAssertArgType>(portNum)
1086  );
1087  this->m_procBufferSendOut_OutputPort[portNum].invoke(
1088  fwBuffer
1089  );
1090  }
1091 
1092 #endif
1093 
1094  // ----------------------------------------------------------------------
1095  // Command response
1096  // ----------------------------------------------------------------------
1097 
1100  FwOpcodeType opCode,
1101  U32 cmdSeq,
1102  Fw::CmdResponse response
1103  )
1104  {
1106  this->cmdResponseOut_out(0, opCode, cmdSeq, response);
1107  }
1108 
1109  // ----------------------------------------------------------------------
1110  // Command handler base-class functions
1111  //
1112  // Call these functions directly to bypass the command input port
1113  // ----------------------------------------------------------------------
1114 
1117  FwOpcodeType opCode,
1118  U32 cmdSeq,
1119  Fw::CmdArgBuffer& args
1120  )
1121  {
1122  // Call pre-message hook
1123  this->CLEAR_EVENT_THROTTLE_preMsgHook(opCode,cmdSeq);
1124 
1125  // Defer deserializing arguments to the message dispatcher
1126  // to avoid deserializing and reserializing just for IPC
1127  ComponentIpcSerializableBuffer msg;
1129 
1130  // Serialize for IPC
1131  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(CMD_CLEAR_EVENT_THROTTLE));
1132  FW_ASSERT (
1133  _status == Fw::FW_SERIALIZE_OK,
1134  static_cast<FwAssertArgType>(_status)
1135  );
1136 
1137  // Fake port number to make message dequeue work
1138  FwIndexType port = 0;
1139 
1140  _status = msg.serializeFrom(port);
1141  FW_ASSERT (
1142  _status == Fw::FW_SERIALIZE_OK,
1143  static_cast<FwAssertArgType>(_status)
1144  );
1145 
1146  _status = msg.serializeFrom(opCode);
1147  FW_ASSERT (
1148  _status == Fw::FW_SERIALIZE_OK,
1149  static_cast<FwAssertArgType>(_status)
1150  );
1151 
1152  _status = msg.serializeFrom(cmdSeq);
1153  FW_ASSERT (
1154  _status == Fw::FW_SERIALIZE_OK,
1155  static_cast<FwAssertArgType>(_status)
1156  );
1157 
1158  _status = msg.serializeFrom(args);
1159  FW_ASSERT (
1160  _status == Fw::FW_SERIALIZE_OK,
1161  static_cast<FwAssertArgType>(_status)
1162  );
1163 
1164  // Send message
1166  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1167 
1168  FW_ASSERT(
1169  qStatus == Os::Queue::OP_OK,
1170  static_cast<FwAssertArgType>(qStatus)
1171  );
1172  }
1173 
1174  // ----------------------------------------------------------------------
1175  // Pre-message hooks for async commands
1176  //
1177  // Each of these functions is invoked just before processing the
1178  // corresponding command. By default they do nothing. You can
1179  // override them to provide specific pre-command behavior.
1180  // ----------------------------------------------------------------------
1181 
1184  FwOpcodeType opCode,
1185  U32 cmdSeq
1186  )
1187  {
1188  // Defaults to no-op; can be overridden
1189  (void) opCode;
1190  (void) cmdSeq;
1191  }
1192 
1193  // ----------------------------------------------------------------------
1194  // Event logging functions
1195  // ----------------------------------------------------------------------
1196 
1199  {
1200  // Check throttle value
1201  if (this->m_InvalidBufferThrottle >= EVENTID_INVALIDBUFFER_THROTTLE) {
1202  return;
1203  }
1204  else {
1205  this->m_InvalidBufferThrottle++;
1206  }
1207 
1208  // Get the time
1209  Fw::Time _logTime;
1210  if (this->isConnected_timeGetOut_OutputPort(0)) {
1211  this->timeGetOut_out(0, _logTime);
1212  }
1213 
1214  const FwEventIdType _id = this->getIdBase() + EVENTID_INVALIDBUFFER;
1215 
1216  // Emit the event on the log port
1217  if (this->isConnected_eventOut_OutputPort(0)) {
1218  Fw::LogBuffer _logBuff;
1219 
1220 #if FW_AMPCS_COMPATIBLE
1222  // Serialize the number of arguments
1223  _status = _logBuff.serializeFrom(static_cast<U8>(0));
1224  FW_ASSERT(
1225  _status == Fw::FW_SERIALIZE_OK,
1226  static_cast<FwAssertArgType>(_status)
1227  );
1228 #endif
1229 
1230  this->eventOut_out(
1231  0,
1232  _id,
1233  _logTime,
1235  _logBuff
1236  );
1237  }
1238 
1239  // Emit the event on the text log port
1240 #if FW_ENABLE_TEXT_LOGGING
1241  if (this->isConnected_textEventOut_OutputPort(0)) {
1242 #if FW_OBJECT_NAMES == 1
1243  const char* _formatString =
1244  "(%s) %s: Received buffer is invalid";
1245 #else
1246  const char* _formatString =
1247  "%s: Received buffer is invalid";
1248 #endif
1249 
1250  Fw::TextLogString _logString;
1251  (void) _logString.format(
1252  _formatString,
1253 #if FW_OBJECT_NAMES == 1
1254  this->m_objName.toChar(),
1255 #endif
1256  "InvalidBuffer "
1257  );
1258 
1259  this->textEventOut_out(
1260  0,
1261  _id,
1262  _logTime,
1264  _logString
1265  );
1266  }
1267 #endif
1268  }
1269 
1272  FwSizeType bufferSize,
1273  U32 minSize
1274  )
1275  {
1276  // Check throttle value
1277  if (this->m_BufferTooSmallForPacketThrottle >= EVENTID_BUFFERTOOSMALLFORPACKET_THROTTLE) {
1278  return;
1279  }
1280  else {
1281  this->m_BufferTooSmallForPacketThrottle++;
1282  }
1283 
1284  // Get the time
1285  Fw::Time _logTime;
1286  if (this->isConnected_timeGetOut_OutputPort(0)) {
1287  this->timeGetOut_out(0, _logTime);
1288  }
1289 
1291 
1292  // Emit the event on the log port
1293  if (this->isConnected_eventOut_OutputPort(0)) {
1294  Fw::LogBuffer _logBuff;
1296 
1297 #if FW_AMPCS_COMPATIBLE
1298  // Serialize the number of arguments
1299  _status = _logBuff.serializeFrom(static_cast<U8>(2));
1300  FW_ASSERT(
1301  _status == Fw::FW_SERIALIZE_OK,
1302  static_cast<FwAssertArgType>(_status)
1303  );
1304 #endif
1305 
1306 #if FW_AMPCS_COMPATIBLE
1307  // Serialize the argument size
1308  _status = _logBuff.serializeFrom(
1309  static_cast<U8>(sizeof(FwSizeType))
1310  );
1311  FW_ASSERT(
1312  _status == Fw::FW_SERIALIZE_OK,
1313  static_cast<FwAssertArgType>(_status)
1314  );
1315 #endif
1316  _status = _logBuff.serializeFrom(bufferSize);
1317  FW_ASSERT(
1318  _status == Fw::FW_SERIALIZE_OK,
1319  static_cast<FwAssertArgType>(_status)
1320  );
1321 
1322 #if FW_AMPCS_COMPATIBLE
1323  // Serialize the argument size
1324  _status = _logBuff.serializeFrom(
1325  static_cast<U8>(sizeof(U32))
1326  );
1327  FW_ASSERT(
1328  _status == Fw::FW_SERIALIZE_OK,
1329  static_cast<FwAssertArgType>(_status)
1330  );
1331 #endif
1332  _status = _logBuff.serializeFrom(minSize);
1333  FW_ASSERT(
1334  _status == Fw::FW_SERIALIZE_OK,
1335  static_cast<FwAssertArgType>(_status)
1336  );
1337 
1338  this->eventOut_out(
1339  0,
1340  _id,
1341  _logTime,
1343  _logBuff
1344  );
1345  }
1346 
1347  // Emit the event on the text log port
1348 #if FW_ENABLE_TEXT_LOGGING
1349  if (this->isConnected_textEventOut_OutputPort(0)) {
1350 #if FW_OBJECT_NAMES == 1
1351  const char* _formatString =
1352  "(%s) %s: Received buffer has size %" PRIu64 "; minimum required size is %" PRIu32 "";
1353 #else
1354  const char* _formatString =
1355  "%s: Received buffer has size %" PRIu64 "; minimum required size is %" PRIu32 "";
1356 #endif
1357 
1358  Fw::TextLogString _logString;
1359  (void) _logString.format(
1360  _formatString,
1361 #if FW_OBJECT_NAMES == 1
1362  this->m_objName.toChar(),
1363 #endif
1364  "BufferTooSmallForPacket ",
1365  bufferSize,
1366  minSize
1367  );
1368 
1369  this->textEventOut_out(
1370  0,
1371  _id,
1372  _logTime,
1374  _logString
1375  );
1376  }
1377 #endif
1378  }
1379 
1382  FwSizeType bufferSize,
1383  U32 storedHash,
1384  U32 computedHash
1385  )
1386  {
1387  // Check throttle value
1388  if (this->m_InvalidHeaderHashThrottle >= EVENTID_INVALIDHEADERHASH_THROTTLE) {
1389  return;
1390  }
1391  else {
1392  this->m_InvalidHeaderHashThrottle++;
1393  }
1394 
1395  // Get the time
1396  Fw::Time _logTime;
1397  if (this->isConnected_timeGetOut_OutputPort(0)) {
1398  this->timeGetOut_out(0, _logTime);
1399  }
1400 
1401  const FwEventIdType _id = this->getIdBase() + EVENTID_INVALIDHEADERHASH;
1402 
1403  // Emit the event on the log port
1404  if (this->isConnected_eventOut_OutputPort(0)) {
1405  Fw::LogBuffer _logBuff;
1407 
1408 #if FW_AMPCS_COMPATIBLE
1409  // Serialize the number of arguments
1410  _status = _logBuff.serializeFrom(static_cast<U8>(3));
1411  FW_ASSERT(
1412  _status == Fw::FW_SERIALIZE_OK,
1413  static_cast<FwAssertArgType>(_status)
1414  );
1415 #endif
1416 
1417 #if FW_AMPCS_COMPATIBLE
1418  // Serialize the argument size
1419  _status = _logBuff.serializeFrom(
1420  static_cast<U8>(sizeof(FwSizeType))
1421  );
1422  FW_ASSERT(
1423  _status == Fw::FW_SERIALIZE_OK,
1424  static_cast<FwAssertArgType>(_status)
1425  );
1426 #endif
1427  _status = _logBuff.serializeFrom(bufferSize);
1428  FW_ASSERT(
1429  _status == Fw::FW_SERIALIZE_OK,
1430  static_cast<FwAssertArgType>(_status)
1431  );
1432 
1433 #if FW_AMPCS_COMPATIBLE
1434  // Serialize the argument size
1435  _status = _logBuff.serializeFrom(
1436  static_cast<U8>(sizeof(U32))
1437  );
1438  FW_ASSERT(
1439  _status == Fw::FW_SERIALIZE_OK,
1440  static_cast<FwAssertArgType>(_status)
1441  );
1442 #endif
1443  _status = _logBuff.serializeFrom(storedHash);
1444  FW_ASSERT(
1445  _status == Fw::FW_SERIALIZE_OK,
1446  static_cast<FwAssertArgType>(_status)
1447  );
1448 
1449 #if FW_AMPCS_COMPATIBLE
1450  // Serialize the argument size
1451  _status = _logBuff.serializeFrom(
1452  static_cast<U8>(sizeof(U32))
1453  );
1454  FW_ASSERT(
1455  _status == Fw::FW_SERIALIZE_OK,
1456  static_cast<FwAssertArgType>(_status)
1457  );
1458 #endif
1459  _status = _logBuff.serializeFrom(computedHash);
1460  FW_ASSERT(
1461  _status == Fw::FW_SERIALIZE_OK,
1462  static_cast<FwAssertArgType>(_status)
1463  );
1464 
1465  this->eventOut_out(
1466  0,
1467  _id,
1468  _logTime,
1470  _logBuff
1471  );
1472  }
1473 
1474  // Emit the event on the text log port
1475 #if FW_ENABLE_TEXT_LOGGING
1476  if (this->isConnected_textEventOut_OutputPort(0)) {
1477 #if FW_OBJECT_NAMES == 1
1478  const char* _formatString =
1479  "(%s) %s: Received a buffer of size %" PRIu64 " with an invalid header hash (stored %" PRIx32 ", computed %" PRIx32 ")";
1480 #else
1481  const char* _formatString =
1482  "%s: Received a buffer of size %" PRIu64 " with an invalid header hash (stored %" PRIx32 ", computed %" PRIx32 ")";
1483 #endif
1484 
1485  Fw::TextLogString _logString;
1486  (void) _logString.format(
1487  _formatString,
1488 #if FW_OBJECT_NAMES == 1
1489  this->m_objName.toChar(),
1490 #endif
1491  "InvalidHeaderHash ",
1492  bufferSize,
1493  storedHash,
1494  computedHash
1495  );
1496 
1497  this->textEventOut_out(
1498  0,
1499  _id,
1500  _logTime,
1502  _logString
1503  );
1504  }
1505 #endif
1506  }
1507 
1510  FwSizeType bufferSize,
1511  U32 errorCode
1512  )
1513  {
1514  // Check throttle value
1515  if (this->m_InvalidHeaderThrottle >= EVENTID_INVALIDHEADER_THROTTLE) {
1516  return;
1517  }
1518  else {
1519  this->m_InvalidHeaderThrottle++;
1520  }
1521 
1522  // Get the time
1523  Fw::Time _logTime;
1524  if (this->isConnected_timeGetOut_OutputPort(0)) {
1525  this->timeGetOut_out(0, _logTime);
1526  }
1527 
1528  const FwEventIdType _id = this->getIdBase() + EVENTID_INVALIDHEADER;
1529 
1530  // Emit the event on the log port
1531  if (this->isConnected_eventOut_OutputPort(0)) {
1532  Fw::LogBuffer _logBuff;
1534 
1535 #if FW_AMPCS_COMPATIBLE
1536  // Serialize the number of arguments
1537  _status = _logBuff.serializeFrom(static_cast<U8>(2));
1538  FW_ASSERT(
1539  _status == Fw::FW_SERIALIZE_OK,
1540  static_cast<FwAssertArgType>(_status)
1541  );
1542 #endif
1543 
1544 #if FW_AMPCS_COMPATIBLE
1545  // Serialize the argument size
1546  _status = _logBuff.serializeFrom(
1547  static_cast<U8>(sizeof(FwSizeType))
1548  );
1549  FW_ASSERT(
1550  _status == Fw::FW_SERIALIZE_OK,
1551  static_cast<FwAssertArgType>(_status)
1552  );
1553 #endif
1554  _status = _logBuff.serializeFrom(bufferSize);
1555  FW_ASSERT(
1556  _status == Fw::FW_SERIALIZE_OK,
1557  static_cast<FwAssertArgType>(_status)
1558  );
1559 
1560 #if FW_AMPCS_COMPATIBLE
1561  // Serialize the argument size
1562  _status = _logBuff.serializeFrom(
1563  static_cast<U8>(sizeof(U32))
1564  );
1565  FW_ASSERT(
1566  _status == Fw::FW_SERIALIZE_OK,
1567  static_cast<FwAssertArgType>(_status)
1568  );
1569 #endif
1570  _status = _logBuff.serializeFrom(errorCode);
1571  FW_ASSERT(
1572  _status == Fw::FW_SERIALIZE_OK,
1573  static_cast<FwAssertArgType>(_status)
1574  );
1575 
1576  this->eventOut_out(
1577  0,
1578  _id,
1579  _logTime,
1581  _logBuff
1582  );
1583  }
1584 
1585  // Emit the event on the text log port
1586 #if FW_ENABLE_TEXT_LOGGING
1587  if (this->isConnected_textEventOut_OutputPort(0)) {
1588 #if FW_OBJECT_NAMES == 1
1589  const char* _formatString =
1590  "(%s) %s: Received buffer of size %" PRIu64 "; deserialization of packet header failed with error code %" PRIu32 "";
1591 #else
1592  const char* _formatString =
1593  "%s: Received buffer of size %" PRIu64 "; deserialization of packet header failed with error code %" PRIu32 "";
1594 #endif
1595 
1596  Fw::TextLogString _logString;
1597  (void) _logString.format(
1598  _formatString,
1599 #if FW_OBJECT_NAMES == 1
1600  this->m_objName.toChar(),
1601 #endif
1602  "InvalidHeader ",
1603  bufferSize,
1604  errorCode
1605  );
1606 
1607  this->textEventOut_out(
1608  0,
1609  _id,
1610  _logTime,
1612  _logString
1613  );
1614  }
1615 #endif
1616  }
1617 
1620  FwSizeType bufferSize,
1621  U32 minSize
1622  )
1623  {
1624  // Check throttle value
1625  if (this->m_BufferTooSmallForDataThrottle >= EVENTID_BUFFERTOOSMALLFORDATA_THROTTLE) {
1626  return;
1627  }
1628  else {
1629  this->m_BufferTooSmallForDataThrottle++;
1630  }
1631 
1632  // Get the time
1633  Fw::Time _logTime;
1634  if (this->isConnected_timeGetOut_OutputPort(0)) {
1635  this->timeGetOut_out(0, _logTime);
1636  }
1637 
1639 
1640  // Emit the event on the log port
1641  if (this->isConnected_eventOut_OutputPort(0)) {
1642  Fw::LogBuffer _logBuff;
1644 
1645 #if FW_AMPCS_COMPATIBLE
1646  // Serialize the number of arguments
1647  _status = _logBuff.serializeFrom(static_cast<U8>(2));
1648  FW_ASSERT(
1649  _status == Fw::FW_SERIALIZE_OK,
1650  static_cast<FwAssertArgType>(_status)
1651  );
1652 #endif
1653 
1654 #if FW_AMPCS_COMPATIBLE
1655  // Serialize the argument size
1656  _status = _logBuff.serializeFrom(
1657  static_cast<U8>(sizeof(FwSizeType))
1658  );
1659  FW_ASSERT(
1660  _status == Fw::FW_SERIALIZE_OK,
1661  static_cast<FwAssertArgType>(_status)
1662  );
1663 #endif
1664  _status = _logBuff.serializeFrom(bufferSize);
1665  FW_ASSERT(
1666  _status == Fw::FW_SERIALIZE_OK,
1667  static_cast<FwAssertArgType>(_status)
1668  );
1669 
1670 #if FW_AMPCS_COMPATIBLE
1671  // Serialize the argument size
1672  _status = _logBuff.serializeFrom(
1673  static_cast<U8>(sizeof(U32))
1674  );
1675  FW_ASSERT(
1676  _status == Fw::FW_SERIALIZE_OK,
1677  static_cast<FwAssertArgType>(_status)
1678  );
1679 #endif
1680  _status = _logBuff.serializeFrom(minSize);
1681  FW_ASSERT(
1682  _status == Fw::FW_SERIALIZE_OK,
1683  static_cast<FwAssertArgType>(_status)
1684  );
1685 
1686  this->eventOut_out(
1687  0,
1688  _id,
1689  _logTime,
1691  _logBuff
1692  );
1693  }
1694 
1695  // Emit the event on the text log port
1696 #if FW_ENABLE_TEXT_LOGGING
1697  if (this->isConnected_textEventOut_OutputPort(0)) {
1698 #if FW_OBJECT_NAMES == 1
1699  const char* _formatString =
1700  "(%s) %s: Received buffer has size %" PRIu64 "; minimum required size is %" PRIu32 "";
1701 #else
1702  const char* _formatString =
1703  "%s: Received buffer has size %" PRIu64 "; minimum required size is %" PRIu32 "";
1704 #endif
1705 
1706  Fw::TextLogString _logString;
1707  (void) _logString.format(
1708  _formatString,
1709 #if FW_OBJECT_NAMES == 1
1710  this->m_objName.toChar(),
1711 #endif
1712  "BufferTooSmallForData ",
1713  bufferSize,
1714  minSize
1715  );
1716 
1717  this->textEventOut_out(
1718  0,
1719  _id,
1720  _logTime,
1722  _logString
1723  );
1724  }
1725 #endif
1726  }
1727 
1730  {
1731  // Check throttle value
1732  if (this->m_FileNameFormatErrorThrottle >= EVENTID_FILENAMEFORMATERROR_THROTTLE) {
1733  return;
1734  }
1735  else {
1736  this->m_FileNameFormatErrorThrottle++;
1737  }
1738 
1739  // Get the time
1740  Fw::Time _logTime;
1741  if (this->isConnected_timeGetOut_OutputPort(0)) {
1742  this->timeGetOut_out(0, _logTime);
1743  }
1744 
1745  const FwEventIdType _id = this->getIdBase() + EVENTID_FILENAMEFORMATERROR;
1746 
1747  // Emit the event on the log port
1748  if (this->isConnected_eventOut_OutputPort(0)) {
1749  Fw::LogBuffer _logBuff;
1751 
1752 #if FW_AMPCS_COMPATIBLE
1753  // Serialize the number of arguments
1754  _status = _logBuff.serializeFrom(static_cast<U8>(1));
1755  FW_ASSERT(
1756  _status == Fw::FW_SERIALIZE_OK,
1757  static_cast<FwAssertArgType>(_status)
1758  );
1759 #endif
1760 
1761 #if FW_AMPCS_COMPATIBLE
1762  // Serialize the argument size
1763  _status = _logBuff.serializeFrom(
1765  );
1766  FW_ASSERT(
1767  _status == Fw::FW_SERIALIZE_OK,
1768  static_cast<FwAssertArgType>(_status)
1769  );
1770 #endif
1771  _status = _logBuff.serializeFrom(status);
1772  FW_ASSERT(
1773  _status == Fw::FW_SERIALIZE_OK,
1774  static_cast<FwAssertArgType>(_status)
1775  );
1776 
1777  this->eventOut_out(
1778  0,
1779  _id,
1780  _logTime,
1782  _logBuff
1783  );
1784  }
1785 
1786  // Emit the event on the text log port
1787 #if FW_ENABLE_TEXT_LOGGING
1788  if (this->isConnected_textEventOut_OutputPort(0)) {
1789 #if FW_OBJECT_NAMES == 1
1790  const char* _formatString =
1791  "(%s) %s: Error %s formatting DP file name";
1792 #else
1793  const char* _formatString =
1794  "%s: Error %s formatting DP file name";
1795 #endif
1796 
1797  Fw::String statusStr;
1798  status.toString(statusStr);
1799 
1800  Fw::TextLogString _logString;
1801  (void) _logString.format(
1802  _formatString,
1803 #if FW_OBJECT_NAMES == 1
1804  this->m_objName.toChar(),
1805 #endif
1806  "FileNameFormatError ",
1807  statusStr.toChar()
1808  );
1809 
1810  this->textEventOut_out(
1811  0,
1812  _id,
1813  _logTime,
1815  _logString
1816  );
1817  }
1818 #endif
1819  }
1820 
1823  U32 status,
1824  const Fw::StringBase& file
1825  )
1826  {
1827  // Check throttle value
1828  if (this->m_FileOpenErrorThrottle >= EVENTID_FILEOPENERROR_THROTTLE) {
1829  return;
1830  }
1831  else {
1832  this->m_FileOpenErrorThrottle++;
1833  }
1834 
1835  // Get the time
1836  Fw::Time _logTime;
1837  if (this->isConnected_timeGetOut_OutputPort(0)) {
1838  this->timeGetOut_out(0, _logTime);
1839  }
1840 
1841  const FwEventIdType _id = this->getIdBase() + EVENTID_FILEOPENERROR;
1842 
1843  // Emit the event on the log port
1844  if (this->isConnected_eventOut_OutputPort(0)) {
1845  Fw::LogBuffer _logBuff;
1847 
1848 #if FW_AMPCS_COMPATIBLE
1849  // Serialize the number of arguments
1850  _status = _logBuff.serializeFrom(static_cast<U8>(2));
1851  FW_ASSERT(
1852  _status == Fw::FW_SERIALIZE_OK,
1853  static_cast<FwAssertArgType>(_status)
1854  );
1855 #endif
1856 
1857 #if FW_AMPCS_COMPATIBLE
1858  // Serialize the argument size
1859  _status = _logBuff.serializeFrom(
1860  static_cast<U8>(sizeof(U32))
1861  );
1862  FW_ASSERT(
1863  _status == Fw::FW_SERIALIZE_OK,
1864  static_cast<FwAssertArgType>(_status)
1865  );
1866 #endif
1867  _status = _logBuff.serializeFrom(status);
1868  FW_ASSERT(
1869  _status == Fw::FW_SERIALIZE_OK,
1870  static_cast<FwAssertArgType>(_status)
1871  );
1872 
1873  _status = file.serializeTo(
1874  _logBuff,
1875  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), 240)
1876  );
1877  FW_ASSERT(
1878  _status == Fw::FW_SERIALIZE_OK,
1879  static_cast<FwAssertArgType>(_status)
1880  );
1881 
1882  this->eventOut_out(
1883  0,
1884  _id,
1885  _logTime,
1887  _logBuff
1888  );
1889  }
1890 
1891  // Emit the event on the text log port
1892 #if FW_ENABLE_TEXT_LOGGING
1893  if (this->isConnected_textEventOut_OutputPort(0)) {
1894 #if FW_OBJECT_NAMES == 1
1895  const char* _formatString =
1896  "(%s) %s: Error %" PRIu32 " opening file %s";
1897 #else
1898  const char* _formatString =
1899  "%s: Error %" PRIu32 " opening file %s";
1900 #endif
1901 
1902  Fw::TextLogString _logString;
1903  (void) _logString.format(
1904  _formatString,
1905 #if FW_OBJECT_NAMES == 1
1906  this->m_objName.toChar(),
1907 #endif
1908  "FileOpenError ",
1909  status,
1910  file.toChar()
1911  );
1912 
1913  this->textEventOut_out(
1914  0,
1915  _id,
1916  _logTime,
1918  _logString
1919  );
1920  }
1921 #endif
1922  }
1923 
1926  U32 status,
1927  U32 bytesWritten,
1928  U32 bytesToWrite,
1929  const Fw::StringBase& file
1930  )
1931  {
1932  // Check throttle value
1933  if (this->m_FileWriteErrorThrottle >= EVENTID_FILEWRITEERROR_THROTTLE) {
1934  return;
1935  }
1936  else {
1937  this->m_FileWriteErrorThrottle++;
1938  }
1939 
1940  // Get the time
1941  Fw::Time _logTime;
1942  if (this->isConnected_timeGetOut_OutputPort(0)) {
1943  this->timeGetOut_out(0, _logTime);
1944  }
1945 
1946  const FwEventIdType _id = this->getIdBase() + EVENTID_FILEWRITEERROR;
1947 
1948  // Emit the event on the log port
1949  if (this->isConnected_eventOut_OutputPort(0)) {
1950  Fw::LogBuffer _logBuff;
1952 
1953 #if FW_AMPCS_COMPATIBLE
1954  // Serialize the number of arguments
1955  _status = _logBuff.serializeFrom(static_cast<U8>(4));
1956  FW_ASSERT(
1957  _status == Fw::FW_SERIALIZE_OK,
1958  static_cast<FwAssertArgType>(_status)
1959  );
1960 #endif
1961 
1962 #if FW_AMPCS_COMPATIBLE
1963  // Serialize the argument size
1964  _status = _logBuff.serializeFrom(
1965  static_cast<U8>(sizeof(U32))
1966  );
1967  FW_ASSERT(
1968  _status == Fw::FW_SERIALIZE_OK,
1969  static_cast<FwAssertArgType>(_status)
1970  );
1971 #endif
1972  _status = _logBuff.serializeFrom(status);
1973  FW_ASSERT(
1974  _status == Fw::FW_SERIALIZE_OK,
1975  static_cast<FwAssertArgType>(_status)
1976  );
1977 
1978 #if FW_AMPCS_COMPATIBLE
1979  // Serialize the argument size
1980  _status = _logBuff.serializeFrom(
1981  static_cast<U8>(sizeof(U32))
1982  );
1983  FW_ASSERT(
1984  _status == Fw::FW_SERIALIZE_OK,
1985  static_cast<FwAssertArgType>(_status)
1986  );
1987 #endif
1988  _status = _logBuff.serializeFrom(bytesWritten);
1989  FW_ASSERT(
1990  _status == Fw::FW_SERIALIZE_OK,
1991  static_cast<FwAssertArgType>(_status)
1992  );
1993 
1994 #if FW_AMPCS_COMPATIBLE
1995  // Serialize the argument size
1996  _status = _logBuff.serializeFrom(
1997  static_cast<U8>(sizeof(U32))
1998  );
1999  FW_ASSERT(
2000  _status == Fw::FW_SERIALIZE_OK,
2001  static_cast<FwAssertArgType>(_status)
2002  );
2003 #endif
2004  _status = _logBuff.serializeFrom(bytesToWrite);
2005  FW_ASSERT(
2006  _status == Fw::FW_SERIALIZE_OK,
2007  static_cast<FwAssertArgType>(_status)
2008  );
2009 
2010  _status = file.serializeTo(
2011  _logBuff,
2012  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), 240)
2013  );
2014  FW_ASSERT(
2015  _status == Fw::FW_SERIALIZE_OK,
2016  static_cast<FwAssertArgType>(_status)
2017  );
2018 
2019  this->eventOut_out(
2020  0,
2021  _id,
2022  _logTime,
2024  _logBuff
2025  );
2026  }
2027 
2028  // Emit the event on the text log port
2029 #if FW_ENABLE_TEXT_LOGGING
2030  if (this->isConnected_textEventOut_OutputPort(0)) {
2031 #if FW_OBJECT_NAMES == 1
2032  const char* _formatString =
2033  "(%s) %s: Error %" PRIu32 " while writing %" PRIu32 " of %" PRIu32 " bytes to %s";
2034 #else
2035  const char* _formatString =
2036  "%s: Error %" PRIu32 " while writing %" PRIu32 " of %" PRIu32 " bytes to %s";
2037 #endif
2038 
2039  Fw::TextLogString _logString;
2040  (void) _logString.format(
2041  _formatString,
2042 #if FW_OBJECT_NAMES == 1
2043  this->m_objName.toChar(),
2044 #endif
2045  "FileWriteError ",
2046  status,
2047  bytesWritten,
2048  bytesToWrite,
2049  file.toChar()
2050  );
2051 
2052  this->textEventOut_out(
2053  0,
2054  _id,
2055  _logTime,
2057  _logString
2058  );
2059  }
2060 #endif
2061  }
2062 
2065  U32 bytes,
2066  const Fw::StringBase& file
2067  ) const
2068  {
2069  // Get the time
2070  Fw::Time _logTime;
2071  if (this->isConnected_timeGetOut_OutputPort(0)) {
2072  this->timeGetOut_out(0, _logTime);
2073  }
2074 
2075  const FwEventIdType _id = this->getIdBase() + EVENTID_FILEWRITTEN;
2076 
2077  // Emit the event on the log port
2078  if (this->isConnected_eventOut_OutputPort(0)) {
2079  Fw::LogBuffer _logBuff;
2081 
2082 #if FW_AMPCS_COMPATIBLE
2083  // Serialize the number of arguments
2084  _status = _logBuff.serializeFrom(static_cast<U8>(2));
2085  FW_ASSERT(
2086  _status == Fw::FW_SERIALIZE_OK,
2087  static_cast<FwAssertArgType>(_status)
2088  );
2089 #endif
2090 
2091 #if FW_AMPCS_COMPATIBLE
2092  // Serialize the argument size
2093  _status = _logBuff.serializeFrom(
2094  static_cast<U8>(sizeof(U32))
2095  );
2096  FW_ASSERT(
2097  _status == Fw::FW_SERIALIZE_OK,
2098  static_cast<FwAssertArgType>(_status)
2099  );
2100 #endif
2101  _status = _logBuff.serializeFrom(bytes);
2102  FW_ASSERT(
2103  _status == Fw::FW_SERIALIZE_OK,
2104  static_cast<FwAssertArgType>(_status)
2105  );
2106 
2107  _status = file.serializeTo(
2108  _logBuff,
2109  FW_MIN(static_cast<FwSizeType>(FW_LOG_STRING_MAX_SIZE), 240)
2110  );
2111  FW_ASSERT(
2112  _status == Fw::FW_SERIALIZE_OK,
2113  static_cast<FwAssertArgType>(_status)
2114  );
2115 
2116  this->eventOut_out(
2117  0,
2118  _id,
2119  _logTime,
2121  _logBuff
2122  );
2123  }
2124 
2125  // Emit the event on the text log port
2126 #if FW_ENABLE_TEXT_LOGGING
2127  if (this->isConnected_textEventOut_OutputPort(0)) {
2128 #if FW_OBJECT_NAMES == 1
2129  const char* _formatString =
2130  "(%s) %s: Wrote %" PRIu32 " bytes to file %s";
2131 #else
2132  const char* _formatString =
2133  "%s: Wrote %" PRIu32 " bytes to file %s";
2134 #endif
2135 
2136  Fw::TextLogString _logString;
2137  (void) _logString.format(
2138  _formatString,
2139 #if FW_OBJECT_NAMES == 1
2140  this->m_objName.toChar(),
2141 #endif
2142  "FileWritten ",
2143  bytes,
2144  file.toChar()
2145  );
2146 
2147  this->textEventOut_out(
2148  0,
2149  _id,
2150  _logTime,
2152  _logString
2153  );
2154  }
2155 #endif
2156  }
2157 
2158  // ----------------------------------------------------------------------
2159  // Event throttle reset functions
2160  // ----------------------------------------------------------------------
2161 
2164  {
2165  // Reset throttle counter
2166  this->m_InvalidBufferThrottle = 0;
2167  }
2168 
2171  {
2172  // Reset throttle counter
2173  this->m_BufferTooSmallForPacketThrottle = 0;
2174  }
2175 
2178  {
2179  // Reset throttle counter
2180  this->m_InvalidHeaderHashThrottle = 0;
2181  }
2182 
2185  {
2186  // Reset throttle counter
2187  this->m_InvalidHeaderThrottle = 0;
2188  }
2189 
2192  {
2193  // Reset throttle counter
2194  this->m_BufferTooSmallForDataThrottle = 0;
2195  }
2196 
2199  {
2200  // Reset throttle counter
2201  this->m_FileNameFormatErrorThrottle = 0;
2202  }
2203 
2206  {
2207  // Reset throttle counter
2208  this->m_FileOpenErrorThrottle = 0;
2209  }
2210 
2213  {
2214  // Reset throttle counter
2215  this->m_FileWriteErrorThrottle = 0;
2216  }
2217 
2218  // ----------------------------------------------------------------------
2219  // Telemetry serialized write
2220  // ----------------------------------------------------------------------
2221 
2224  FwChanIdType id,
2225  Fw::TlmBuffer& _tlmBuff,
2226  Fw::Time _tlmTime
2227  ) const
2228  {
2229  if (this->isConnected_tlmOut_OutputPort(0)) {
2230  if (
2232  (_tlmTime == Fw::ZERO_TIME)
2233  ) {
2234  this->timeGetOut_out(0, _tlmTime);
2235  }
2236 
2237  FwChanIdType _id;
2238  _id = this->getIdBase() + id;
2239 
2240  this->tlmOut_out(
2241  0,
2242  _id,
2243  _tlmTime,
2244  _tlmBuff
2245  );
2246  }
2247  }
2248 
2249  // ----------------------------------------------------------------------
2250  // Telemetry write functions
2251  // ----------------------------------------------------------------------
2252 
2255  U32 arg,
2256  Fw::Time _tlmTime
2257  )
2258  {
2259  // Check to see if it is the first time
2260  if (not this->m_first_update_NumBuffersReceived) {
2261  // Check to see if value has changed. If not, don't write it.
2262  if (arg == this->m_last_NumBuffersReceived) {
2263  return;
2264  }
2265  else {
2266  this->m_last_NumBuffersReceived = arg;
2267  }
2268  }
2269  else {
2270  this->m_first_update_NumBuffersReceived = false;
2271  this->m_last_NumBuffersReceived = arg;
2272  }
2273 
2274  if (this->isConnected_tlmOut_OutputPort(0)) {
2275  Fw::TlmBuffer _tlmBuff;
2276  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2277  FW_ASSERT(
2278  _stat == Fw::FW_SERIALIZE_OK,
2279  static_cast<FwAssertArgType>(_stat)
2280  );
2281 
2282  this->tlmWrite(
2284  _tlmBuff,
2285  _tlmTime
2286  );
2287  }
2288  }
2289 
2292  U64 arg,
2293  Fw::Time _tlmTime
2294  )
2295  {
2296  // Check to see if it is the first time
2297  if (not this->m_first_update_NumBytesWritten) {
2298  // Check to see if value has changed. If not, don't write it.
2299  if (arg == this->m_last_NumBytesWritten) {
2300  return;
2301  }
2302  else {
2303  this->m_last_NumBytesWritten = arg;
2304  }
2305  }
2306  else {
2307  this->m_first_update_NumBytesWritten = false;
2308  this->m_last_NumBytesWritten = arg;
2309  }
2310 
2311  if (this->isConnected_tlmOut_OutputPort(0)) {
2312  Fw::TlmBuffer _tlmBuff;
2313  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2314  FW_ASSERT(
2315  _stat == Fw::FW_SERIALIZE_OK,
2316  static_cast<FwAssertArgType>(_stat)
2317  );
2318 
2319  this->tlmWrite(
2321  _tlmBuff,
2322  _tlmTime
2323  );
2324  }
2325  }
2326 
2329  U32 arg,
2330  Fw::Time _tlmTime
2331  )
2332  {
2333  // Check to see if it is the first time
2334  if (not this->m_first_update_NumSuccessfulWrites) {
2335  // Check to see if value has changed. If not, don't write it.
2336  if (arg == this->m_last_NumSuccessfulWrites) {
2337  return;
2338  }
2339  else {
2340  this->m_last_NumSuccessfulWrites = arg;
2341  }
2342  }
2343  else {
2344  this->m_first_update_NumSuccessfulWrites = false;
2345  this->m_last_NumSuccessfulWrites = arg;
2346  }
2347 
2348  if (this->isConnected_tlmOut_OutputPort(0)) {
2349  Fw::TlmBuffer _tlmBuff;
2350  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2351  FW_ASSERT(
2352  _stat == Fw::FW_SERIALIZE_OK,
2353  static_cast<FwAssertArgType>(_stat)
2354  );
2355 
2356  this->tlmWrite(
2358  _tlmBuff,
2359  _tlmTime
2360  );
2361  }
2362  }
2363 
2366  U32 arg,
2367  Fw::Time _tlmTime
2368  )
2369  {
2370  // Check to see if it is the first time
2371  if (not this->m_first_update_NumFailedWrites) {
2372  // Check to see if value has changed. If not, don't write it.
2373  if (arg == this->m_last_NumFailedWrites) {
2374  return;
2375  }
2376  else {
2377  this->m_last_NumFailedWrites = arg;
2378  }
2379  }
2380  else {
2381  this->m_first_update_NumFailedWrites = false;
2382  this->m_last_NumFailedWrites = arg;
2383  }
2384 
2385  if (this->isConnected_tlmOut_OutputPort(0)) {
2386  Fw::TlmBuffer _tlmBuff;
2387  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2388  FW_ASSERT(
2389  _stat == Fw::FW_SERIALIZE_OK,
2390  static_cast<FwAssertArgType>(_stat)
2391  );
2392 
2393  this->tlmWrite(
2395  _tlmBuff,
2396  _tlmTime
2397  );
2398  }
2399  }
2400 
2403  U32 arg,
2404  Fw::Time _tlmTime
2405  )
2406  {
2407  // Check to see if it is the first time
2408  if (not this->m_first_update_NumErrors) {
2409  // Check to see if value has changed. If not, don't write it.
2410  if (arg == this->m_last_NumErrors) {
2411  return;
2412  }
2413  else {
2414  this->m_last_NumErrors = arg;
2415  }
2416  }
2417  else {
2418  this->m_first_update_NumErrors = false;
2419  this->m_last_NumErrors = arg;
2420  }
2421 
2422  if (this->isConnected_tlmOut_OutputPort(0)) {
2423  Fw::TlmBuffer _tlmBuff;
2424  Fw::SerializeStatus _stat = _tlmBuff.serializeFrom(arg);
2425  FW_ASSERT(
2426  _stat == Fw::FW_SERIALIZE_OK,
2427  static_cast<FwAssertArgType>(_stat)
2428  );
2429 
2430  this->tlmWrite(
2432  _tlmBuff,
2433  _tlmTime
2434  );
2435  }
2436  }
2437 
2438  // ----------------------------------------------------------------------
2439  // Time
2440  // ----------------------------------------------------------------------
2441 
2443  getTime() const
2444  {
2445  if (this->isConnected_timeGetOut_OutputPort(0)) {
2446  Fw::Time _time;
2447  this->timeGetOut_out(0, _time);
2448  return _time;
2449  }
2450  else {
2451  return Fw::Time(TimeBase::TB_NONE, 0, 0);
2452  }
2453  }
2454 
2455  // ----------------------------------------------------------------------
2456  // Message dispatch functions
2457  // ----------------------------------------------------------------------
2458 
2459  Fw::QueuedComponentBase::MsgDispatchStatus DpWriterComponentBase ::
2460  doDispatch()
2461  {
2462  ComponentIpcSerializableBuffer _msg;
2463  FwQueuePriorityType _priority = 0;
2464 
2465  Os::Queue::Status _msgStatus = this->m_queue.receive(
2466  _msg,
2468  _priority
2469  );
2470  FW_ASSERT(
2471  _msgStatus == Os::Queue::OP_OK,
2472  static_cast<FwAssertArgType>(_msgStatus)
2473  );
2474 
2475  // Reset to beginning of buffer
2476  _msg.resetDeser();
2477 
2478  FwEnumStoreType _desMsg = 0;
2479  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
2480  FW_ASSERT(
2481  _deserStatus == Fw::FW_SERIALIZE_OK,
2482  static_cast<FwAssertArgType>(_deserStatus)
2483  );
2484 
2485  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
2486 
2487  if (_msgType == DPWRITER_COMPONENT_EXIT) {
2488  return MSG_DISPATCH_EXIT;
2489  }
2490 
2491  FwIndexType portNum = 0;
2492  _deserStatus = _msg.deserializeTo(portNum);
2493  FW_ASSERT(
2494  _deserStatus == Fw::FW_SERIALIZE_OK,
2495  static_cast<FwAssertArgType>(_deserStatus)
2496  );
2497 
2498  switch (_msgType) {
2499  // Handle async input port bufferSendIn
2500  case BUFFERSENDIN_BUFFERSEND: {
2501  // Deserialize argument fwBuffer
2502  Fw::Buffer fwBuffer;
2503  _deserStatus = _msg.deserializeTo(fwBuffer);
2504  FW_ASSERT(
2505  _deserStatus == Fw::FW_SERIALIZE_OK,
2506  static_cast<FwAssertArgType>(_deserStatus)
2507  );
2508  // Call handler function
2509  this->bufferSendIn_handler(
2510  portNum,
2511  fwBuffer
2512  );
2513 
2514  break;
2515  }
2516 
2517  // Handle async input port schedIn
2518  case SCHEDIN_SCHED: {
2519  // Deserialize argument context
2520  U32 context;
2521  _deserStatus = _msg.deserializeTo(context);
2522  FW_ASSERT(
2523  _deserStatus == Fw::FW_SERIALIZE_OK,
2524  static_cast<FwAssertArgType>(_deserStatus)
2525  );
2526  // Call handler function
2527  this->schedIn_handler(
2528  portNum,
2529  context
2530  );
2531 
2532  break;
2533  }
2534 
2535  // Handle command CLEAR_EVENT_THROTTLE
2536  case CMD_CLEAR_EVENT_THROTTLE: {
2537  // Deserialize opcode
2538  FwOpcodeType _opCode = 0;
2539  _deserStatus = _msg.deserializeTo(_opCode);
2540  FW_ASSERT (
2541  _deserStatus == Fw::FW_SERIALIZE_OK,
2542  static_cast<FwAssertArgType>(_deserStatus)
2543  );
2544 
2545  // Deserialize command sequence
2546  U32 _cmdSeq = 0;
2547  _deserStatus = _msg.deserializeTo(_cmdSeq);
2548  FW_ASSERT (
2549  _deserStatus == Fw::FW_SERIALIZE_OK,
2550  static_cast<FwAssertArgType>(_deserStatus)
2551  );
2552 
2553  // Deserialize command argument buffer
2554  Fw::CmdArgBuffer args;
2555  _deserStatus = _msg.deserializeTo(args);
2556  FW_ASSERT (
2557  _deserStatus == Fw::FW_SERIALIZE_OK,
2558  static_cast<FwAssertArgType>(_deserStatus)
2559  );
2560 
2561  // Reset buffer
2562  args.resetDeser();
2563 
2564  // Make sure there was no data left over.
2565  // That means the argument buffer size was incorrect.
2566 #if FW_CMD_CHECK_RESIDUAL
2567  if (args.getDeserializeSizeLeft() != 0) {
2569  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2570  }
2571  // Don't crash the task if bad arguments were passed from the ground
2572  break;
2573  }
2574 #endif
2575 
2576  // Call handler function
2577  this->CLEAR_EVENT_THROTTLE_cmdHandler(_opCode, _cmdSeq);
2578 
2579  break;
2580  }
2581 
2582  default:
2583  return MSG_DISPATCH_ERROR;
2584  }
2585 
2586  return MSG_DISPATCH_OK;
2587  }
2588 
2589  // ----------------------------------------------------------------------
2590  // Calls for messages received on special input ports
2591  // ----------------------------------------------------------------------
2592 
2593  void DpWriterComponentBase ::
2594  m_p_cmdIn_in(
2595  Fw::PassiveComponentBase* callComp,
2596  FwIndexType portNum,
2597  FwOpcodeType opCode,
2598  U32 cmdSeq,
2599  Fw::CmdArgBuffer& args
2600  )
2601  {
2602  FW_ASSERT(callComp != nullptr);
2603  DpWriterComponentBase* compPtr = static_cast<DpWriterComponentBase*>(callComp);
2604  compPtr->cmdIn_handlerBase(
2605  portNum,
2606  opCode,
2607  cmdSeq,
2608  args
2609  );
2610  }
2611 
2612  // ----------------------------------------------------------------------
2613  // Calls for messages received on typed input ports
2614  // ----------------------------------------------------------------------
2615 
2616  void DpWriterComponentBase ::
2617  m_p_bufferSendIn_in(
2618  Fw::PassiveComponentBase* callComp,
2619  FwIndexType portNum,
2620  Fw::Buffer& fwBuffer
2621  )
2622  {
2623  FW_ASSERT(callComp != nullptr);
2624  DpWriterComponentBase* compPtr = static_cast<DpWriterComponentBase*>(callComp);
2625  compPtr->bufferSendIn_handlerBase(
2626  portNum,
2627  fwBuffer
2628  );
2629  }
2630 
2631  void DpWriterComponentBase ::
2632  m_p_schedIn_in(
2633  Fw::PassiveComponentBase* callComp,
2634  FwIndexType portNum,
2635  U32 context
2636  )
2637  {
2638  FW_ASSERT(callComp != nullptr);
2639  DpWriterComponentBase* compPtr = static_cast<DpWriterComponentBase*>(callComp);
2640  compPtr->schedIn_handlerBase(
2641  portNum,
2642  context
2643  );
2644  }
2645 
2646 #if !FW_DIRECT_PORT_CALLS
2647 
2648  // ----------------------------------------------------------------------
2649  // Invocation functions for special output ports
2650  // ----------------------------------------------------------------------
2651 
2652  void DpWriterComponentBase ::
2653  cmdRegIn_out(
2654  FwIndexType portNum,
2655  FwOpcodeType opCode
2656  ) const
2657  {
2658  FW_ASSERT(
2659  (0 <= portNum) && (portNum < this->getNum_cmdRegIn_OutputPorts()),
2660  static_cast<FwAssertArgType>(portNum)
2661  );
2662 
2663  FW_ASSERT(
2664  this->m_cmdRegIn_OutputPort[portNum].isConnected(),
2665  static_cast<FwAssertArgType>(portNum)
2666  );
2667  this->m_cmdRegIn_OutputPort[portNum].invoke(
2668  opCode
2669  );
2670  }
2671 
2672  void DpWriterComponentBase ::
2673  cmdResponseOut_out(
2674  FwIndexType portNum,
2675  FwOpcodeType opCode,
2676  U32 cmdSeq,
2677  const Fw::CmdResponse& response
2678  ) const
2679  {
2680  FW_ASSERT(
2681  (0 <= portNum) && (portNum < this->getNum_cmdResponseOut_OutputPorts()),
2682  static_cast<FwAssertArgType>(portNum)
2683  );
2684 
2685  FW_ASSERT(
2686  this->m_cmdResponseOut_OutputPort[portNum].isConnected(),
2687  static_cast<FwAssertArgType>(portNum)
2688  );
2689  this->m_cmdResponseOut_OutputPort[portNum].invoke(
2690  opCode,
2691  cmdSeq,
2692  response
2693  );
2694  }
2695 
2696  void DpWriterComponentBase ::
2697  eventOut_out(
2698  FwIndexType portNum,
2699  FwEventIdType id,
2700  Fw::Time& timeTag,
2701  const Fw::LogSeverity& severity,
2702  Fw::LogBuffer& args
2703  ) const
2704  {
2705  FW_ASSERT(
2706  (0 <= portNum) && (portNum < this->getNum_eventOut_OutputPorts()),
2707  static_cast<FwAssertArgType>(portNum)
2708  );
2709 
2710  FW_ASSERT(
2711  this->m_eventOut_OutputPort[portNum].isConnected(),
2712  static_cast<FwAssertArgType>(portNum)
2713  );
2714  this->m_eventOut_OutputPort[portNum].invoke(
2715  id,
2716  timeTag,
2717  severity,
2718  args
2719  );
2720  }
2721 
2722 #if FW_ENABLE_TEXT_LOGGING
2723 
2724  void DpWriterComponentBase ::
2725  textEventOut_out(
2726  FwIndexType portNum,
2727  FwEventIdType id,
2728  Fw::Time& timeTag,
2729  const Fw::LogSeverity& severity,
2730  Fw::TextLogString& text
2731  ) const
2732  {
2733  FW_ASSERT(
2734  (0 <= portNum) && (portNum < this->getNum_textEventOut_OutputPorts()),
2735  static_cast<FwAssertArgType>(portNum)
2736  );
2737 
2738  FW_ASSERT(
2739  this->m_textEventOut_OutputPort[portNum].isConnected(),
2740  static_cast<FwAssertArgType>(portNum)
2741  );
2742  this->m_textEventOut_OutputPort[portNum].invoke(
2743  id,
2744  timeTag,
2745  severity,
2746  text
2747  );
2748  }
2749 
2750 #endif
2751 
2752  void DpWriterComponentBase ::
2753  timeGetOut_out(
2754  FwIndexType portNum,
2755  Fw::Time& time
2756  ) const
2757  {
2758  FW_ASSERT(
2759  (0 <= portNum) && (portNum < this->getNum_timeGetOut_OutputPorts()),
2760  static_cast<FwAssertArgType>(portNum)
2761  );
2762 
2763  FW_ASSERT(
2764  this->m_timeGetOut_OutputPort[portNum].isConnected(),
2765  static_cast<FwAssertArgType>(portNum)
2766  );
2767  this->m_timeGetOut_OutputPort[portNum].invoke(
2768  time
2769  );
2770  }
2771 
2772  void DpWriterComponentBase ::
2773  tlmOut_out(
2774  FwIndexType portNum,
2775  FwChanIdType id,
2776  Fw::Time& timeTag,
2777  Fw::TlmBuffer& val
2778  ) const
2779  {
2780  FW_ASSERT(
2781  (0 <= portNum) && (portNum < this->getNum_tlmOut_OutputPorts()),
2782  static_cast<FwAssertArgType>(portNum)
2783  );
2784 
2785  FW_ASSERT(
2786  this->m_tlmOut_OutputPort[portNum].isConnected(),
2787  static_cast<FwAssertArgType>(portNum)
2788  );
2789  this->m_tlmOut_OutputPort[portNum].invoke(
2790  id,
2791  timeTag,
2792  val
2793  );
2794  }
2795 
2796 #endif
2797 
2798 }
An error occurred when writing to a file.
Serialization/Deserialization operation was successful.
static constexpr FwIndexType getNum_bufferSendIn_InputPorts()
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:157
message to exit active component task
virtual ~DpWriterComponentBase()
Destroy DpWriterComponentBase object.
bool isConnected_cmdResponseOut_OutputPort(FwIndexType portNum) const
static constexpr FwSizeType CAPACITY
Definition: CmdPortAc.hpp:36
FwIdType FwOpcodeType
The type of a command opcode.
void log_WARNING_HI_BufferTooSmallForData(FwSizeType bufferSize, U32 minSize)
Operation succeeded.
Definition: Os.hpp:27
void invoke(const Fw::StringBase &fileName, FwDpPriorityType priority, FwSizeType size) const
Invoke a port connection.
void schedIn_handlerBase(FwIndexType portNum, U32 context)
Handler base-class function for input port schedIn.
virtual void CLEAR_EVENT_THROTTLE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
PlatformSizeType FwSizeType
static constexpr FwIndexType getNum_cmdResponseOut_OutputPorts()
bool isConnected_cmdRegIn_OutputPort(FwIndexType portNum) const
U32 FwDpPriorityType
The type of a data product priority.
Status receive(U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
receive a message from the queue through delegate
Definition: Queue.cpp:71
void addCallPort(InputDpWrittenPort *callPort)
Register an input port.
I32 FwEnumStoreType
static constexpr FwIndexType getNum_eventOut_OutputPorts()
Status
status returned from the queue send function
Definition: Queue.hpp:30
An error occurred when formatting a file name.
Received buffer is too small to hold the data specified in the header.
void init()
Initialization function.
Definition: SchedPortAc.cpp:73
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void set_dpWrittenOut_OutputPort(FwIndexType portNum, Svc::InputDpWrittenPort *port)
Connect port to dpWrittenOut[portNum].
void init()
Initialization function.
Definition: CmdPortAc.cpp:89
static constexpr FwSizeType CAPACITY
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
void log_WARNING_HI_FileNameFormatError_ThrottleClear()
Reset throttle value for FileNameFormatError.
virtual const CHAR * toChar() const =0
Convert to a C-style char*.
const Time ZERO_TIME
Definition: Time.cpp:5
bool isConnected_timeGetOut_OutputPort(FwIndexType portNum) const
void init()
Initialization function.
Definition: TlmPortAc.cpp:171
Enum representing a command response.
virtual void bufferSendIn_preMsgHook(FwIndexType portNum, Fw::Buffer &fwBuffer)
Pre-message hook for async input port bufferSendIn.
An error occurred when opening a file.
static constexpr FwIndexType getNum_schedIn_InputPorts()
No time base has been established (Required)
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
void addCallPort(InputCmdRegPort *callPort)
Register an input port.
static constexpr FwIndexType getNum_timeGetOut_OutputPorts()
void cmdIn_handlerBase(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
Handler base-class function for input port cmdIn.
FPP shadow-enum representing Fw::FormatStatus.
static constexpr FwIndexType getNum_deallocBufferSendOut_OutputPorts()
Os::Queue m_queue
queue object for active component
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:177
void tlmWrite_NumErrors(U32 arg, Fw::Time _tlmTime=Fw::Time())
void init()
Object initializer.
Definition: ObjBase.cpp:24
bool isConnected_dpWrittenOut_OutputPort(FwIndexType portNum) const
SerializeStatus
forward declaration for string
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CmdPortAc.cpp:95
Fw::InputBufferSendPort * get_bufferSendIn_InputPort(FwIndexType portNum)
Message will block until space is available.
Definition: Queue.hpp:47
bool isConnected_deallocBufferSendOut_OutputPort(FwIndexType portNum) const
void deallocBufferSendOut_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port deallocBufferSendOut.
void log_WARNING_HI_InvalidBuffer_ThrottleClear()
Reset throttle value for InvalidBuffer.
FwIdType FwEventIdType
The type of an event identifier.
void tlmWrite_NumFailedWrites(U32 arg, Fw::Time _tlmTime=Fw::Time())
void log_WARNING_HI_FileWriteError_ThrottleClear()
Reset throttle value for FileWriteError.
void invoke(FwOpcodeType opCode) const
Invoke a port connection.
void CLEAR_EVENT_THROTTLE_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:40
Error occurred when deserializing the packet header.
void init()
Initialization function.
Definition: TimePortAc.cpp:151
void tlmWrite(FwChanIdType id, Fw::TlmBuffer &_tlmBuff, Fw::Time _tlmTime=Fw::Time()) const
Less important informational events.
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
#define FW_MIN(a, b)
MIN macro (deprecated in C++, use std::min)
Definition: BasicTypes.h:99
void invoke(Fw::Buffer &fwBuffer) const
Invoke a port connection.
void init()
Initialization function.
void addCallPort(InputBufferSendPort *callPort)
Register an input port.
void dpWrittenOut_out(FwIndexType portNum, const Fw::StringBase &fileName, FwDpPriorityType priority, FwSizeType size) const
Invoke output port dpWrittenOut.
void invoke(Fw::Time &time) const
Invoke a port connection.
Definition: TimePortAc.cpp:170
Fw::InputCmdPort * get_cmdIn_InputPort(FwIndexType portNum)
void log_WARNING_HI_InvalidHeaderHash(FwSizeType bufferSize, U32 storedHash, U32 computedHash)
Serializable::SizeType getDeserializeSizeLeft() const override
Get remaining deserialization buffer size.
void set_deallocBufferSendOut_OutputPort(FwIndexType portNum, Fw::InputBufferSendPort *port)
Connect port to deallocBufferSendOut[portNum].
void invoke(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response) const
Invoke a port connection.
FwIdType FwChanIdType
The type of a telemetry channel identifier.
void tlmWrite_NumBuffersReceived(U32 arg, Fw::Time _tlmTime=Fw::Time())
Status send(const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override
send a message into the queue through delegate
Definition: Queue.cpp:54
static constexpr FwIndexType getNum_procBufferSendOut_OutputPorts()
void procBufferSendOut_out(FwIndexType portNum, Fw::Buffer &fwBuffer) const
Invoke output port procBufferSendOut.
void resetDeser() override
Reset deserialization pointer to beginning of buffer.
void log_WARNING_HI_BufferTooSmallForData_ThrottleClear()
Reset throttle value for BufferTooSmallForData.
void log_WARNING_HI_FileOpenError_ThrottleClear()
Reset throttle value for FileOpenError.
static constexpr FwIndexType getNum_tlmOut_OutputPorts()
A serious but recoverable event.
void invoke(FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) const
Invoke a port connection.
Definition: TlmPortAc.cpp:190
DpWriterComponentBase(const char *compName="")
Construct DpWriterComponentBase object.
const char * toChar() const
Convert to a C-style char*.
bool isConnected() const
Definition: PortBase.cpp:38
void log_WARNING_HI_FileOpenError(U32 status, const Fw::StringBase &file)
void log_WARNING_HI_InvalidHeader_ThrottleClear()
Reset throttle value for InvalidHeader.
Enum representing event severity.
void log_WARNING_HI_FileNameFormatError(const Fw::StringFormatStatus &status)
#define PRI_FwIndexType
void log_WARNING_HI_InvalidHeaderHash_ThrottleClear()
Reset throttle value for InvalidHeaderHash.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:58
void init()
Initialization function.
Definition: LogPortAc.cpp:180
bool isConnected_procBufferSendOut_OutputPort(FwIndexType portNum) const
void setPortNum(FwIndexType portNum)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:54
void log_WARNING_HI_BufferTooSmallForPacket(FwSizeType bufferSize, U32 minSize)
BlockingType
message type
Definition: Queue.hpp:46
void regCommands()
Register commands with the Command Dispatcher.
Command failed to deserialize.
PlatformQueuePriorityType FwQueuePriorityType
The type of queue priorities used.
void init()
Initialization function.
void set_tlmOut_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to tlmOut[portNum].
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: SchedPortAc.cpp:79
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args) const
Invoke a port connection.
Definition: LogPortAc.cpp:199
bool isConnected_eventOut_OutputPort(FwIndexType portNum) const
void set_cmdResponseOut_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to cmdResponseOut[portNum].
void log_ACTIVITY_LO_FileWritten(U32 bytes, const Fw::StringBase &file) const
static constexpr FwIndexType getNum_cmdRegIn_OutputPorts()
A message was sent requesting an exit of the loop.
virtual void CLEAR_EVENT_THROTTLE_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command CLEAR_EVENT_THROTTLE.
virtual void schedIn_handler(FwIndexType portNum, U32 context)=0
Handler for input port schedIn.
PlatformIndexType FwIndexType
static constexpr FwIndexType getNum_dpWrittenOut_OutputPorts()
void set_eventOut_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to eventOut[portNum].
bool isConnected_tlmOut_OutputPort(FwIndexType portNum) const
virtual void bufferSendIn_handler(FwIndexType portNum, Fw::Buffer &fwBuffer)=0
Handler for input port bufferSendIn.
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:186
void log_WARNING_HI_FileWriteError(U32 status, U32 bytesWritten, U32 bytesToWrite, const Fw::StringBase &file)
void init()
Initialization function.
void set_timeGetOut_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to timeGetOut[portNum].
RateGroupDivider component implementation.
message sent/received okay
Definition: Queue.hpp:31
U8 BYTE
byte type
Definition: BasicTypes.h:57
void bufferSendIn_handlerBase(FwIndexType portNum, Fw::Buffer &fwBuffer)
Handler base-class function for input port bufferSendIn.
void tlmWrite_NumBytesWritten(U64 arg, Fw::Time _tlmTime=Fw::Time())
The received buffer has an invalid header hash.
virtual void schedIn_preMsgHook(FwIndexType portNum, U32 context)
Pre-message hook for async input port schedIn.
void log_WARNING_HI_InvalidHeader(FwSizeType bufferSize, U32 errorCode)
void tlmWrite_NumSuccessfulWrites(U32 arg, Fw::Time _tlmTime=Fw::Time())
void log_WARNING_HI_BufferTooSmallForPacket_ThrottleClear()
Reset throttle value for BufferTooSmallForPacket.
Message will return with status when space is unavailable.
Definition: Queue.hpp:48
Implementation of malloc based allocator.
void set_procBufferSendOut_OutputPort(FwIndexType portNum, Fw::InputBufferSendPort *port)
Connect port to procBufferSendOut[portNum].
Received buffer is too small to hold a data product packet.
void init()
Initialization function.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
void init()
Initialization function.
Svc::InputSchedPort * get_schedIn_InputPort(FwIndexType portNum)
static constexpr FwSizeType CAPACITY
Definition: SchedPortAc.hpp:34
void set_cmdRegIn_OutputPort(FwIndexType portNum, Fw::InputCmdRegPort *port)
Connect port to cmdRegIn[portNum].
The size of the serial representation.
void addCallPort(InputCmdResponsePort *callPort)
Register an input port.
static constexpr FwIndexType getNum_cmdIn_InputPorts()
SerializeStatus serializeTo(SerialBufferBase &buffer, Endianness mode=Endianness::BIG) const override
Serialize the contents of this object to a buffer.
BYTE cmdPortSize[Fw::CmdPortBuffer::CAPACITY]