F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
PrmDbComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title PrmDbComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for PrmDb component base class
5 // ======================================================================
6 
8 #include "Fw/Types/Assert.hpp"
10 #if FW_ENABLE_TEXT_LOGGING
11 #include "Fw/Types/String.hpp"
12 #endif
13 
14 namespace Svc {
15 
16  namespace {
17  enum MsgTypeEnum {
19  PINGIN_PING,
20  SETPRM_PRMSET,
21  CMD_PRM_SAVE_FILE,
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 {
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  Fw::Serializable::SizeType getBuffCapacity() const {
50  return sizeof(m_buff);
51  }
52 
53  U8* getBuffAddr() {
54  return m_buff;
55  }
56 
57  const U8* getBuffAddr() const {
58  return m_buff;
59  }
60 
61  private:
62  // Should be the max of all the input ports serialized sizes...
63  U8 m_buff[SERIALIZATION_SIZE];
64 
65  };
66  }
67 
68  // ----------------------------------------------------------------------
69  // Component initialization
70  // ----------------------------------------------------------------------
71 
74  FwSizeType queueDepth,
75  FwEnumStoreType instance
76  )
77  {
78  // Initialize base class
80 
81  // Connect input port CmdDisp
82  for (
83  FwIndexType port = 0;
84  port < static_cast<FwIndexType>(this->getNum_CmdDisp_InputPorts());
85  port++
86  ) {
87  this->m_CmdDisp_InputPort[port].init();
88  this->m_CmdDisp_InputPort[port].addCallComp(
89  this,
90  m_p_CmdDisp_in
91  );
92  this->m_CmdDisp_InputPort[port].setPortNum(port);
93 
94 #if FW_OBJECT_NAMES == 1
95  Fw::ObjectName portName;
96  portName.format(
97  "%s_CmdDisp_InputPort[%" PRI_PlatformIntType "]",
98  this->m_objName.toChar(),
99  port
100  );
101  this->m_CmdDisp_InputPort[port].setObjName(portName.toChar());
102 #endif
103  }
104 
105  // Connect input port getPrm
106  for (
107  FwIndexType port = 0;
108  port < static_cast<FwIndexType>(this->getNum_getPrm_InputPorts());
109  port++
110  ) {
111  this->m_getPrm_InputPort[port].init();
112  this->m_getPrm_InputPort[port].addCallComp(
113  this,
114  m_p_getPrm_in
115  );
116  this->m_getPrm_InputPort[port].setPortNum(port);
117 
118 #if FW_OBJECT_NAMES == 1
119  Fw::ObjectName portName;
120  portName.format(
121  "%s_getPrm_InputPort[%" PRI_PlatformIntType "]",
122  this->m_objName.toChar(),
123  port
124  );
125  this->m_getPrm_InputPort[port].setObjName(portName.toChar());
126 #endif
127  }
128 
129  // Connect input port pingIn
130  for (
131  FwIndexType port = 0;
132  port < static_cast<FwIndexType>(this->getNum_pingIn_InputPorts());
133  port++
134  ) {
135  this->m_pingIn_InputPort[port].init();
136  this->m_pingIn_InputPort[port].addCallComp(
137  this,
138  m_p_pingIn_in
139  );
140  this->m_pingIn_InputPort[port].setPortNum(port);
141 
142 #if FW_OBJECT_NAMES == 1
143  Fw::ObjectName portName;
144  portName.format(
145  "%s_pingIn_InputPort[%" PRI_PlatformIntType "]",
146  this->m_objName.toChar(),
147  port
148  );
149  this->m_pingIn_InputPort[port].setObjName(portName.toChar());
150 #endif
151  }
152 
153  // Connect input port setPrm
154  for (
155  FwIndexType port = 0;
156  port < static_cast<FwIndexType>(this->getNum_setPrm_InputPorts());
157  port++
158  ) {
159  this->m_setPrm_InputPort[port].init();
160  this->m_setPrm_InputPort[port].addCallComp(
161  this,
162  m_p_setPrm_in
163  );
164  this->m_setPrm_InputPort[port].setPortNum(port);
165 
166 #if FW_OBJECT_NAMES == 1
167  Fw::ObjectName portName;
168  portName.format(
169  "%s_setPrm_InputPort[%" PRI_PlatformIntType "]",
170  this->m_objName.toChar(),
171  port
172  );
173  this->m_setPrm_InputPort[port].setObjName(portName.toChar());
174 #endif
175  }
176 
177  // Connect output port CmdReg
178  for (
179  FwIndexType port = 0;
180  port < static_cast<FwIndexType>(this->getNum_CmdReg_OutputPorts());
181  port++
182  ) {
183  this->m_CmdReg_OutputPort[port].init();
184 
185 #if FW_OBJECT_NAMES == 1
186  Fw::ObjectName portName;
187  portName.format(
188  "%s_CmdReg_OutputPort[%" PRI_PlatformIntType "]",
189  this->m_objName.toChar(),
190  port
191  );
192  this->m_CmdReg_OutputPort[port].setObjName(portName.toChar());
193 #endif
194  }
195 
196  // Connect output port CmdStatus
197  for (
198  FwIndexType port = 0;
199  port < static_cast<FwIndexType>(this->getNum_CmdStatus_OutputPorts());
200  port++
201  ) {
202  this->m_CmdStatus_OutputPort[port].init();
203 
204 #if FW_OBJECT_NAMES == 1
205  Fw::ObjectName portName;
206  portName.format(
207  "%s_CmdStatus_OutputPort[%" PRI_PlatformIntType "]",
208  this->m_objName.toChar(),
209  port
210  );
211  this->m_CmdStatus_OutputPort[port].setObjName(portName.toChar());
212 #endif
213  }
214 
215  // Connect output port Log
216  for (
217  FwIndexType port = 0;
218  port < static_cast<FwIndexType>(this->getNum_Log_OutputPorts());
219  port++
220  ) {
221  this->m_Log_OutputPort[port].init();
222 
223 #if FW_OBJECT_NAMES == 1
224  Fw::ObjectName portName;
225  portName.format(
226  "%s_Log_OutputPort[%" PRI_PlatformIntType "]",
227  this->m_objName.toChar(),
228  port
229  );
230  this->m_Log_OutputPort[port].setObjName(portName.toChar());
231 #endif
232  }
233 
234 #if FW_ENABLE_TEXT_LOGGING == 1
235  // Connect output port LogText
236  for (
237  FwIndexType port = 0;
238  port < static_cast<FwIndexType>(this->getNum_LogText_OutputPorts());
239  port++
240  ) {
241  this->m_LogText_OutputPort[port].init();
242 
243 #if FW_OBJECT_NAMES == 1
244  Fw::ObjectName portName;
245  portName.format(
246  "%s_LogText_OutputPort[%" PRI_PlatformIntType "]",
247  this->m_objName.toChar(),
248  port
249  );
250  this->m_LogText_OutputPort[port].setObjName(portName.toChar());
251 #endif
252  }
253 #endif
254 
255  // Connect output port Time
256  for (
257  FwIndexType port = 0;
258  port < static_cast<FwIndexType>(this->getNum_Time_OutputPorts());
259  port++
260  ) {
261  this->m_Time_OutputPort[port].init();
262 
263 #if FW_OBJECT_NAMES == 1
264  Fw::ObjectName portName;
265  portName.format(
266  "%s_Time_OutputPort[%" PRI_PlatformIntType "]",
267  this->m_objName.toChar(),
268  port
269  );
270  this->m_Time_OutputPort[port].setObjName(portName.toChar());
271 #endif
272  }
273 
274  // Connect output port pingOut
275  for (
276  FwIndexType port = 0;
277  port < static_cast<FwIndexType>(this->getNum_pingOut_OutputPorts());
278  port++
279  ) {
280  this->m_pingOut_OutputPort[port].init();
281 
282 #if FW_OBJECT_NAMES == 1
283  Fw::ObjectName portName;
284  portName.format(
285  "%s_pingOut_OutputPort[%" PRI_PlatformIntType "]",
286  this->m_objName.toChar(),
287  port
288  );
289  this->m_pingOut_OutputPort[port].setObjName(portName.toChar());
290 #endif
291  }
292 
293  // Create the queue
294  Os::Queue::Status qStat = this->createQueue(
295  queueDepth,
296  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
297  );
298  FW_ASSERT(
299  Os::Queue::Status::OP_OK == qStat,
300  static_cast<FwAssertArgType>(qStat)
301  );
302  }
303 
304  // ----------------------------------------------------------------------
305  // Getters for special input ports
306  // ----------------------------------------------------------------------
307 
310  {
311  FW_ASSERT(
312  portNum < this->getNum_CmdDisp_InputPorts(),
313  static_cast<FwAssertArgType>(portNum)
314  );
315 
316  return &this->m_CmdDisp_InputPort[portNum];
317  }
318 
319  // ----------------------------------------------------------------------
320  // Getters for typed input ports
321  // ----------------------------------------------------------------------
322 
325  {
326  FW_ASSERT(
327  portNum < this->getNum_getPrm_InputPorts(),
328  static_cast<FwAssertArgType>(portNum)
329  );
330 
331  return &this->m_getPrm_InputPort[portNum];
332  }
333 
336  {
337  FW_ASSERT(
338  portNum < this->getNum_pingIn_InputPorts(),
339  static_cast<FwAssertArgType>(portNum)
340  );
341 
342  return &this->m_pingIn_InputPort[portNum];
343  }
344 
347  {
348  FW_ASSERT(
349  portNum < this->getNum_setPrm_InputPorts(),
350  static_cast<FwAssertArgType>(portNum)
351  );
352 
353  return &this->m_setPrm_InputPort[portNum];
354  }
355 
356  // ----------------------------------------------------------------------
357  // Connect input ports to special output ports
358  // ----------------------------------------------------------------------
359 
362  FwIndexType portNum,
363  Fw::InputCmdRegPort* port
364  )
365  {
366  FW_ASSERT(
367  portNum < this->getNum_CmdReg_OutputPorts(),
368  static_cast<FwAssertArgType>(portNum)
369  );
370 
371  this->m_CmdReg_OutputPort[portNum].addCallPort(port);
372  }
373 
376  FwIndexType portNum,
378  )
379  {
380  FW_ASSERT(
381  portNum < this->getNum_CmdStatus_OutputPorts(),
382  static_cast<FwAssertArgType>(portNum)
383  );
384 
385  this->m_CmdStatus_OutputPort[portNum].addCallPort(port);
386  }
387 
390  FwIndexType portNum,
391  Fw::InputLogPort* port
392  )
393  {
394  FW_ASSERT(
395  portNum < this->getNum_Log_OutputPorts(),
396  static_cast<FwAssertArgType>(portNum)
397  );
398 
399  this->m_Log_OutputPort[portNum].addCallPort(port);
400  }
401 
402 #if FW_ENABLE_TEXT_LOGGING == 1
403 
404  void PrmDbComponentBase ::
405  set_LogText_OutputPort(
406  FwIndexType portNum,
408  )
409  {
410  FW_ASSERT(
411  portNum < this->getNum_LogText_OutputPorts(),
412  static_cast<FwAssertArgType>(portNum)
413  );
414 
415  this->m_LogText_OutputPort[portNum].addCallPort(port);
416  }
417 
418 #endif
419 
422  FwIndexType portNum,
423  Fw::InputTimePort* port
424  )
425  {
426  FW_ASSERT(
427  portNum < this->getNum_Time_OutputPorts(),
428  static_cast<FwAssertArgType>(portNum)
429  );
430 
431  this->m_Time_OutputPort[portNum].addCallPort(port);
432  }
433 
434  // ----------------------------------------------------------------------
435  // Connect typed input ports to typed output ports
436  // ----------------------------------------------------------------------
437 
440  FwIndexType portNum,
441  Svc::InputPingPort* port
442  )
443  {
444  FW_ASSERT(
445  portNum < this->getNum_pingOut_OutputPorts(),
446  static_cast<FwAssertArgType>(portNum)
447  );
448 
449  this->m_pingOut_OutputPort[portNum].addCallPort(port);
450  }
451 
452 #if FW_PORT_SERIALIZATION
453 
454  // ----------------------------------------------------------------------
455  // Connect serial input ports to special output ports
456  // ----------------------------------------------------------------------
457 
460  FwIndexType portNum,
461  Fw::InputSerializePort* port
462  )
463  {
464  FW_ASSERT(
465  portNum < this->getNum_CmdReg_OutputPorts(),
466  static_cast<FwAssertArgType>(portNum)
467  );
468 
469  this->m_CmdReg_OutputPort[portNum].registerSerialPort(port);
470  }
471 
474  FwIndexType portNum,
475  Fw::InputSerializePort* port
476  )
477  {
478  FW_ASSERT(
479  portNum < this->getNum_CmdStatus_OutputPorts(),
480  static_cast<FwAssertArgType>(portNum)
481  );
482 
483  this->m_CmdStatus_OutputPort[portNum].registerSerialPort(port);
484  }
485 
488  FwIndexType portNum,
489  Fw::InputSerializePort* port
490  )
491  {
492  FW_ASSERT(
493  portNum < this->getNum_Log_OutputPorts(),
494  static_cast<FwAssertArgType>(portNum)
495  );
496 
497  this->m_Log_OutputPort[portNum].registerSerialPort(port);
498  }
499 
500 #if FW_ENABLE_TEXT_LOGGING == 1
501 
502  void PrmDbComponentBase ::
503  set_LogText_OutputPort(
504  FwIndexType portNum,
505  Fw::InputSerializePort* port
506  )
507  {
508  FW_ASSERT(
509  portNum < this->getNum_LogText_OutputPorts(),
510  static_cast<FwAssertArgType>(portNum)
511  );
512 
513  this->m_LogText_OutputPort[portNum].registerSerialPort(port);
514  }
515 
516 #endif
517 
520  FwIndexType portNum,
521  Fw::InputSerializePort* port
522  )
523  {
524  FW_ASSERT(
525  portNum < this->getNum_Time_OutputPorts(),
526  static_cast<FwAssertArgType>(portNum)
527  );
528 
529  this->m_Time_OutputPort[portNum].registerSerialPort(port);
530  }
531 
532 #endif
533 
534 #if FW_PORT_SERIALIZATION
535 
536  // ----------------------------------------------------------------------
537  // Connect serial input ports to typed output ports
538  // ----------------------------------------------------------------------
539 
542  FwIndexType portNum,
543  Fw::InputSerializePort* port
544  )
545  {
546  FW_ASSERT(
547  portNum < this->getNum_pingOut_OutputPorts(),
548  static_cast<FwAssertArgType>(portNum)
549  );
550 
551  this->m_pingOut_OutputPort[portNum].registerSerialPort(port);
552  }
553 
554 #endif
555 
556  // ----------------------------------------------------------------------
557  // Command registration
558  // ----------------------------------------------------------------------
559 
562  {
563  FW_ASSERT(this->m_CmdReg_OutputPort[0].isConnected());
564 
565  this->m_CmdReg_OutputPort[0].invoke(
567  );
568  }
569 
570  // ----------------------------------------------------------------------
571  // Component construction and destruction
572  // ----------------------------------------------------------------------
573 
575  PrmDbComponentBase(const char* compName) :
576  Fw::ActiveComponentBase(compName)
577  {
578  this->m_PrmIdNotFoundThrottle = 0;
579  }
580 
583  {
584 
585  }
586 
587  // ----------------------------------------------------------------------
588  // Getters for numbers of special input ports
589  // ----------------------------------------------------------------------
590 
593  {
594  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_CmdDisp_InputPort));
595  }
596 
597  // ----------------------------------------------------------------------
598  // Getters for numbers of typed input ports
599  // ----------------------------------------------------------------------
600 
603  {
604  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_getPrm_InputPort));
605  }
606 
609  {
610  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_pingIn_InputPort));
611  }
612 
615  {
616  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_setPrm_InputPort));
617  }
618 
619  // ----------------------------------------------------------------------
620  // Getters for numbers of special output ports
621  // ----------------------------------------------------------------------
622 
625  {
626  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_CmdReg_OutputPort));
627  }
628 
631  {
632  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_CmdStatus_OutputPort));
633  }
634 
637  {
638  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Log_OutputPort));
639  }
640 
641 #if FW_ENABLE_TEXT_LOGGING == 1
642 
643  FwIndexType PrmDbComponentBase ::
644  getNum_LogText_OutputPorts() const
645  {
646  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_LogText_OutputPort));
647  }
648 
649 #endif
650 
653  {
654  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Time_OutputPort));
655  }
656 
657  // ----------------------------------------------------------------------
658  // Getters for numbers of typed output ports
659  // ----------------------------------------------------------------------
660 
663  {
664  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_pingOut_OutputPort));
665  }
666 
667  // ----------------------------------------------------------------------
668  // Connection status queries for special output ports
669  // ----------------------------------------------------------------------
670 
673  {
674  FW_ASSERT(
675  portNum < this->getNum_CmdReg_OutputPorts(),
676  static_cast<FwAssertArgType>(portNum)
677  );
678 
679  return this->m_CmdReg_OutputPort[portNum].isConnected();
680  }
681 
684  {
685  FW_ASSERT(
686  portNum < this->getNum_CmdStatus_OutputPorts(),
687  static_cast<FwAssertArgType>(portNum)
688  );
689 
690  return this->m_CmdStatus_OutputPort[portNum].isConnected();
691  }
692 
695  {
696  FW_ASSERT(
697  portNum < this->getNum_Log_OutputPorts(),
698  static_cast<FwAssertArgType>(portNum)
699  );
700 
701  return this->m_Log_OutputPort[portNum].isConnected();
702  }
703 
704 #if FW_ENABLE_TEXT_LOGGING == 1
705 
706  bool PrmDbComponentBase ::
707  isConnected_LogText_OutputPort(FwIndexType portNum)
708  {
709  FW_ASSERT(
710  portNum < this->getNum_LogText_OutputPorts(),
711  static_cast<FwAssertArgType>(portNum)
712  );
713 
714  return this->m_LogText_OutputPort[portNum].isConnected();
715  }
716 
717 #endif
718 
721  {
722  FW_ASSERT(
723  portNum < this->getNum_Time_OutputPorts(),
724  static_cast<FwAssertArgType>(portNum)
725  );
726 
727  return this->m_Time_OutputPort[portNum].isConnected();
728  }
729 
730  // ----------------------------------------------------------------------
731  // Connection status queries for typed output ports
732  // ----------------------------------------------------------------------
733 
736  {
737  FW_ASSERT(
738  portNum < this->getNum_pingOut_OutputPorts(),
739  static_cast<FwAssertArgType>(portNum)
740  );
741 
742  return this->m_pingOut_OutputPort[portNum].isConnected();
743  }
744 
745  // ----------------------------------------------------------------------
746  // Port handler base-class functions for typed input ports
747  //
748  // Call these functions directly to bypass the corresponding ports
749  // ----------------------------------------------------------------------
750 
753  FwIndexType portNum,
754  FwPrmIdType id,
755  Fw::ParamBuffer& val
756  )
757  {
758  // Make sure port number is valid
759  FW_ASSERT(
760  portNum < this->getNum_getPrm_InputPorts(),
761  static_cast<FwAssertArgType>(portNum)
762  );
763 
764  Fw::ParamValid retVal;
765 
766  // Lock guard mutex before calling
767  this->lock();
768 
769  // Call handler function
770  retVal = this->getPrm_handler(
771  portNum,
772  id,
773  val
774  );
775 
776  // Unlock guard mutex
777  this->unLock();
778 
779  return retVal;
780  }
781 
784  FwIndexType portNum,
785  U32 key
786  )
787  {
788  // Make sure port number is valid
789  FW_ASSERT(
790  portNum < this->getNum_pingIn_InputPorts(),
791  static_cast<FwAssertArgType>(portNum)
792  );
793 
794  // Call pre-message hook
796  portNum,
797  key
798  );
799  ComponentIpcSerializableBuffer msg;
801 
802  // Serialize message ID
803  _status = msg.serialize(
804  static_cast<FwEnumStoreType>(PINGIN_PING)
805  );
806  FW_ASSERT(
807  _status == Fw::FW_SERIALIZE_OK,
808  static_cast<FwAssertArgType>(_status)
809  );
810 
811  // Serialize port number
812  _status = msg.serialize(portNum);
813  FW_ASSERT(
814  _status == Fw::FW_SERIALIZE_OK,
815  static_cast<FwAssertArgType>(_status)
816  );
817 
818  // Serialize argument key
819  _status = msg.serialize(key);
820  FW_ASSERT(
821  _status == Fw::FW_SERIALIZE_OK,
822  static_cast<FwAssertArgType>(_status)
823  );
824 
825  // Send message
827  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
828 
829  FW_ASSERT(
830  qStatus == Os::Queue::OP_OK,
831  static_cast<FwAssertArgType>(qStatus)
832  );
833  }
834 
837  FwIndexType portNum,
838  FwPrmIdType id,
839  Fw::ParamBuffer& val
840  )
841  {
842  // Make sure port number is valid
843  FW_ASSERT(
844  portNum < this->getNum_setPrm_InputPorts(),
845  static_cast<FwAssertArgType>(portNum)
846  );
847 
848  // Call pre-message hook
850  portNum,
851  id,
852  val
853  );
854  ComponentIpcSerializableBuffer msg;
856 
857  // Serialize message ID
858  _status = msg.serialize(
859  static_cast<FwEnumStoreType>(SETPRM_PRMSET)
860  );
861  FW_ASSERT(
862  _status == Fw::FW_SERIALIZE_OK,
863  static_cast<FwAssertArgType>(_status)
864  );
865 
866  // Serialize port number
867  _status = msg.serialize(portNum);
868  FW_ASSERT(
869  _status == Fw::FW_SERIALIZE_OK,
870  static_cast<FwAssertArgType>(_status)
871  );
872 
873  // Serialize argument id
874  _status = msg.serialize(id);
875  FW_ASSERT(
876  _status == Fw::FW_SERIALIZE_OK,
877  static_cast<FwAssertArgType>(_status)
878  );
879 
880  // Serialize argument val
881  _status = msg.serialize(val);
882  FW_ASSERT(
883  _status == Fw::FW_SERIALIZE_OK,
884  static_cast<FwAssertArgType>(_status)
885  );
886 
887  // Send message
889  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
890 
891  FW_ASSERT(
892  qStatus == Os::Queue::OP_OK,
893  static_cast<FwAssertArgType>(qStatus)
894  );
895  }
896 
897  // ----------------------------------------------------------------------
898  // Pre-message hooks for typed async input ports
899  //
900  // Each of these functions is invoked just before processing a message
901  // on the corresponding port. By default, they do nothing. You can
902  // override them to provide specific pre-message behavior.
903  // ----------------------------------------------------------------------
904 
907  FwIndexType portNum,
908  U32 key
909  )
910  {
911  // Default: no-op
912  }
913 
916  FwIndexType portNum,
917  FwPrmIdType id,
918  Fw::ParamBuffer& val
919  )
920  {
921  // Default: no-op
922  }
923 
924  // ----------------------------------------------------------------------
925  // Invocation functions for typed output ports
926  // ----------------------------------------------------------------------
927 
930  FwIndexType portNum,
931  U32 key
932  )
933  {
934  FW_ASSERT(
935  portNum < this->getNum_pingOut_OutputPorts(),
936  static_cast<FwAssertArgType>(portNum)
937  );
938 
939  FW_ASSERT(
940  this->m_pingOut_OutputPort[portNum].isConnected(),
941  static_cast<FwAssertArgType>(portNum)
942  );
943  this->m_pingOut_OutputPort[portNum].invoke(
944  key
945  );
946  }
947 
948  // ----------------------------------------------------------------------
949  // Command response
950  // ----------------------------------------------------------------------
951 
954  FwOpcodeType opCode,
955  U32 cmdSeq,
956  Fw::CmdResponse response
957  )
958  {
959  FW_ASSERT(this->m_CmdStatus_OutputPort[0].isConnected());
960  this->m_CmdStatus_OutputPort[0].invoke(opCode, cmdSeq, response);
961  }
962 
963  // ----------------------------------------------------------------------
964  // Command handler base-class functions
965  //
966  // Call these functions directly to bypass the command input port
967  // ----------------------------------------------------------------------
968 
971  FwOpcodeType opCode,
972  U32 cmdSeq,
973  Fw::CmdArgBuffer& args
974  )
975  {
976  // Call pre-message hook
977  this->PRM_SAVE_FILE_preMsgHook(opCode,cmdSeq);
978 
979  // Defer deserializing arguments to the message dispatcher
980  // to avoid deserializing and reserializing just for IPC
981  ComponentIpcSerializableBuffer msg;
983 
984  // Serialize for IPC
985  _status = msg.serialize(static_cast<FwEnumStoreType>(CMD_PRM_SAVE_FILE));
986  FW_ASSERT (
987  _status == Fw::FW_SERIALIZE_OK,
988  static_cast<FwAssertArgType>(_status)
989  );
990 
991  // Fake port number to make message dequeue work
992  FwIndexType port = 0;
993 
994  _status = msg.serialize(port);
995  FW_ASSERT (
996  _status == Fw::FW_SERIALIZE_OK,
997  static_cast<FwAssertArgType>(_status)
998  );
999 
1000  _status = msg.serialize(opCode);
1001  FW_ASSERT (
1002  _status == Fw::FW_SERIALIZE_OK,
1003  static_cast<FwAssertArgType>(_status)
1004  );
1005 
1006  _status = msg.serialize(cmdSeq);
1007  FW_ASSERT (
1008  _status == Fw::FW_SERIALIZE_OK,
1009  static_cast<FwAssertArgType>(_status)
1010  );
1011 
1012  _status = msg.serialize(args);
1013  FW_ASSERT (
1014  _status == Fw::FW_SERIALIZE_OK,
1015  static_cast<FwAssertArgType>(_status)
1016  );
1017 
1018  // Send message
1020  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1021 
1022  FW_ASSERT(
1023  qStatus == Os::Queue::OP_OK,
1024  static_cast<FwAssertArgType>(qStatus)
1025  );
1026  }
1027 
1028  // ----------------------------------------------------------------------
1029  // Pre-message hooks for async commands
1030  //
1031  // Each of these functions is invoked just before processing the
1032  // corresponding command. By default they do nothing. You can
1033  // override them to provide specific pre-command behavior.
1034  // ----------------------------------------------------------------------
1035 
1038  FwOpcodeType opCode,
1039  U32 cmdSeq
1040  )
1041  {
1042  // Defaults to no-op; can be overridden
1043  (void) opCode;
1044  (void) cmdSeq;
1045  }
1046 
1047  // ----------------------------------------------------------------------
1048  // Event logging functions
1049  // ----------------------------------------------------------------------
1050 
1053  {
1054  // Check throttle value
1055  if (this->m_PrmIdNotFoundThrottle >= EVENTID_PRMIDNOTFOUND_THROTTLE) {
1056  return;
1057  }
1058  else {
1059  this->m_PrmIdNotFoundThrottle++;
1060  }
1061 
1062  // Get the time
1063  Fw::Time _logTime;
1064  if (this->m_Time_OutputPort[0].isConnected()) {
1065  this->m_Time_OutputPort[0].invoke(_logTime);
1066  }
1067 
1068  FwEventIdType _id = static_cast<FwEventIdType>(0);
1069 
1070  _id = this->getIdBase() + EVENTID_PRMIDNOTFOUND;
1071 
1072  // Emit the event on the log port
1073  if (this->m_Log_OutputPort[0].isConnected()) {
1074  Fw::LogBuffer _logBuff;
1076 
1077 #if FW_AMPCS_COMPATIBLE
1078  // Serialize the number of arguments
1079  _status = _logBuff.serialize(static_cast<U8>(1));
1080  FW_ASSERT(
1081  _status == Fw::FW_SERIALIZE_OK,
1082  static_cast<FwAssertArgType>(_status)
1083  );
1084 #endif
1085 
1086 #if FW_AMPCS_COMPATIBLE
1087  // Serialize the argument size
1088  _status = _logBuff.serialize(
1089  static_cast<U8>(sizeof(U32))
1090  );
1091  FW_ASSERT(
1092  _status == Fw::FW_SERIALIZE_OK,
1093  static_cast<FwAssertArgType>(_status)
1094  );
1095 #endif
1096  _status = _logBuff.serialize(Id);
1097  FW_ASSERT(
1098  _status == Fw::FW_SERIALIZE_OK,
1099  static_cast<FwAssertArgType>(_status)
1100  );
1101 
1102  this->m_Log_OutputPort[0].invoke(
1103  _id,
1104  _logTime,
1106  _logBuff
1107  );
1108  }
1109 
1110  // Emit the event on the text log port
1111 #if FW_ENABLE_TEXT_LOGGING
1112  if (this->m_LogText_OutputPort[0].isConnected()) {
1113 #if FW_OBJECT_NAMES == 1
1114  const char* _formatString =
1115  "(%s) %s: Parameter ID 0x%" PRIx32 " not found";
1116 #else
1117  const char* _formatString =
1118  "%s: Parameter ID 0x%" PRIx32 " not found";
1119 #endif
1120 
1121  Fw::TextLogString _logString;
1122  _logString.format(
1123  _formatString,
1124 #if FW_OBJECT_NAMES == 1
1125  this->m_objName.toChar(),
1126 #endif
1127  "PrmIdNotFound ",
1128  Id
1129  );
1130 
1131  this->m_LogText_OutputPort[0].invoke(
1132  _id,
1133  _logTime,
1135  _logString
1136  );
1137  }
1138 #endif
1139  }
1140 
1143  {
1144  // Get the time
1145  Fw::Time _logTime;
1146  if (this->m_Time_OutputPort[0].isConnected()) {
1147  this->m_Time_OutputPort[0].invoke(_logTime);
1148  }
1149 
1150  FwEventIdType _id = static_cast<FwEventIdType>(0);
1151 
1152  _id = this->getIdBase() + EVENTID_PRMIDUPDATED;
1153 
1154  // Emit the event on the log port
1155  if (this->m_Log_OutputPort[0].isConnected()) {
1156  Fw::LogBuffer _logBuff;
1158 
1159 #if FW_AMPCS_COMPATIBLE
1160  // Serialize the number of arguments
1161  _status = _logBuff.serialize(static_cast<U8>(1));
1162  FW_ASSERT(
1163  _status == Fw::FW_SERIALIZE_OK,
1164  static_cast<FwAssertArgType>(_status)
1165  );
1166 #endif
1167 
1168 #if FW_AMPCS_COMPATIBLE
1169  // Serialize the argument size
1170  _status = _logBuff.serialize(
1171  static_cast<U8>(sizeof(U32))
1172  );
1173  FW_ASSERT(
1174  _status == Fw::FW_SERIALIZE_OK,
1175  static_cast<FwAssertArgType>(_status)
1176  );
1177 #endif
1178  _status = _logBuff.serialize(Id);
1179  FW_ASSERT(
1180  _status == Fw::FW_SERIALIZE_OK,
1181  static_cast<FwAssertArgType>(_status)
1182  );
1183 
1184  this->m_Log_OutputPort[0].invoke(
1185  _id,
1186  _logTime,
1188  _logBuff
1189  );
1190  }
1191 
1192  // Emit the event on the text log port
1193 #if FW_ENABLE_TEXT_LOGGING
1194  if (this->m_LogText_OutputPort[0].isConnected()) {
1195 #if FW_OBJECT_NAMES == 1
1196  const char* _formatString =
1197  "(%s) %s: Parameter ID 0x%" PRIx32 " updated";
1198 #else
1199  const char* _formatString =
1200  "%s: Parameter ID 0x%" PRIx32 " updated";
1201 #endif
1202 
1203  Fw::TextLogString _logString;
1204  _logString.format(
1205  _formatString,
1206 #if FW_OBJECT_NAMES == 1
1207  this->m_objName.toChar(),
1208 #endif
1209  "PrmIdUpdated ",
1210  Id
1211  );
1212 
1213  this->m_LogText_OutputPort[0].invoke(
1214  _id,
1215  _logTime,
1217  _logString
1218  );
1219  }
1220 #endif
1221  }
1222 
1225  {
1226  // Get the time
1227  Fw::Time _logTime;
1228  if (this->m_Time_OutputPort[0].isConnected()) {
1229  this->m_Time_OutputPort[0].invoke(_logTime);
1230  }
1231 
1232  FwEventIdType _id = static_cast<FwEventIdType>(0);
1233 
1234  _id = this->getIdBase() + EVENTID_PRMDBFULL;
1235 
1236  // Emit the event on the log port
1237  if (this->m_Log_OutputPort[0].isConnected()) {
1238  Fw::LogBuffer _logBuff;
1240 
1241 #if FW_AMPCS_COMPATIBLE
1242  // Serialize the number of arguments
1243  _status = _logBuff.serialize(static_cast<U8>(1 + 1));
1244  FW_ASSERT(
1245  _status == Fw::FW_SERIALIZE_OK,
1246  static_cast<FwAssertArgType>(_status)
1247  );
1248 
1249  // For FATAL, add stack size of 4 and a dummy entry. No support for stacks yet.
1250  _status = _logBuff.serialize(static_cast<U8>(4));
1251  FW_ASSERT(
1252  _status == Fw::FW_SERIALIZE_OK,
1253  static_cast<FwAssertArgType>(_status)
1254  );
1255 
1256  _status = _logBuff.serialize(static_cast<U32>(0));
1257  FW_ASSERT(
1258  _status == Fw::FW_SERIALIZE_OK,
1259  static_cast<FwAssertArgType>(_status)
1260  );
1261 #endif
1262 
1263 #if FW_AMPCS_COMPATIBLE
1264  // Serialize the argument size
1265  _status = _logBuff.serialize(
1266  static_cast<U8>(sizeof(U32))
1267  );
1268  FW_ASSERT(
1269  _status == Fw::FW_SERIALIZE_OK,
1270  static_cast<FwAssertArgType>(_status)
1271  );
1272 #endif
1273  _status = _logBuff.serialize(Id);
1274  FW_ASSERT(
1275  _status == Fw::FW_SERIALIZE_OK,
1276  static_cast<FwAssertArgType>(_status)
1277  );
1278 
1279  this->m_Log_OutputPort[0].invoke(
1280  _id,
1281  _logTime,
1283  _logBuff
1284  );
1285  }
1286 
1287  // Emit the event on the text log port
1288 #if FW_ENABLE_TEXT_LOGGING
1289  if (this->m_LogText_OutputPort[0].isConnected()) {
1290 #if FW_OBJECT_NAMES == 1
1291  const char* _formatString =
1292  "(%s) %s: Parameter DB full when adding ID 0x%" PRIx32 " ";
1293 #else
1294  const char* _formatString =
1295  "%s: Parameter DB full when adding ID 0x%" PRIx32 " ";
1296 #endif
1297 
1298  Fw::TextLogString _logString;
1299  _logString.format(
1300  _formatString,
1301 #if FW_OBJECT_NAMES == 1
1302  this->m_objName.toChar(),
1303 #endif
1304  "PrmDbFull ",
1305  Id
1306  );
1307 
1308  this->m_LogText_OutputPort[0].invoke(
1309  _id,
1310  _logTime,
1312  _logString
1313  );
1314  }
1315 #endif
1316  }
1317 
1320  {
1321  // Get the time
1322  Fw::Time _logTime;
1323  if (this->m_Time_OutputPort[0].isConnected()) {
1324  this->m_Time_OutputPort[0].invoke(_logTime);
1325  }
1326 
1327  FwEventIdType _id = static_cast<FwEventIdType>(0);
1328 
1329  _id = this->getIdBase() + EVENTID_PRMIDADDED;
1330 
1331  // Emit the event on the log port
1332  if (this->m_Log_OutputPort[0].isConnected()) {
1333  Fw::LogBuffer _logBuff;
1335 
1336 #if FW_AMPCS_COMPATIBLE
1337  // Serialize the number of arguments
1338  _status = _logBuff.serialize(static_cast<U8>(1));
1339  FW_ASSERT(
1340  _status == Fw::FW_SERIALIZE_OK,
1341  static_cast<FwAssertArgType>(_status)
1342  );
1343 #endif
1344 
1345 #if FW_AMPCS_COMPATIBLE
1346  // Serialize the argument size
1347  _status = _logBuff.serialize(
1348  static_cast<U8>(sizeof(U32))
1349  );
1350  FW_ASSERT(
1351  _status == Fw::FW_SERIALIZE_OK,
1352  static_cast<FwAssertArgType>(_status)
1353  );
1354 #endif
1355  _status = _logBuff.serialize(Id);
1356  FW_ASSERT(
1357  _status == Fw::FW_SERIALIZE_OK,
1358  static_cast<FwAssertArgType>(_status)
1359  );
1360 
1361  this->m_Log_OutputPort[0].invoke(
1362  _id,
1363  _logTime,
1365  _logBuff
1366  );
1367  }
1368 
1369  // Emit the event on the text log port
1370 #if FW_ENABLE_TEXT_LOGGING
1371  if (this->m_LogText_OutputPort[0].isConnected()) {
1372 #if FW_OBJECT_NAMES == 1
1373  const char* _formatString =
1374  "(%s) %s: Parameter ID 0x%" PRIx32 " added";
1375 #else
1376  const char* _formatString =
1377  "%s: Parameter ID 0x%" PRIx32 " added";
1378 #endif
1379 
1380  Fw::TextLogString _logString;
1381  _logString.format(
1382  _formatString,
1383 #if FW_OBJECT_NAMES == 1
1384  this->m_objName.toChar(),
1385 #endif
1386  "PrmIdAdded ",
1387  Id
1388  );
1389 
1390  this->m_LogText_OutputPort[0].invoke(
1391  _id,
1392  _logTime,
1394  _logString
1395  );
1396  }
1397 #endif
1398  }
1399 
1403  I32 record,
1404  I32 error
1405  ) const
1406  {
1407  // Get the time
1408  Fw::Time _logTime;
1409  if (this->m_Time_OutputPort[0].isConnected()) {
1410  this->m_Time_OutputPort[0].invoke(_logTime);
1411  }
1412 
1413  FwEventIdType _id = static_cast<FwEventIdType>(0);
1414 
1415  _id = this->getIdBase() + EVENTID_PRMFILEWRITEERROR;
1416 
1417  // Emit the event on the log port
1418  if (this->m_Log_OutputPort[0].isConnected()) {
1419  Fw::LogBuffer _logBuff;
1421 
1422 #if FW_AMPCS_COMPATIBLE
1423  // Serialize the number of arguments
1424  _status = _logBuff.serialize(static_cast<U8>(3));
1425  FW_ASSERT(
1426  _status == Fw::FW_SERIALIZE_OK,
1427  static_cast<FwAssertArgType>(_status)
1428  );
1429 #endif
1430 
1431 #if FW_AMPCS_COMPATIBLE
1432  // Serialize the argument size
1433  _status = _logBuff.serialize(
1435  );
1436  FW_ASSERT(
1437  _status == Fw::FW_SERIALIZE_OK,
1438  static_cast<FwAssertArgType>(_status)
1439  );
1440 #endif
1441  _status = _logBuff.serialize(stage);
1442  FW_ASSERT(
1443  _status == Fw::FW_SERIALIZE_OK,
1444  static_cast<FwAssertArgType>(_status)
1445  );
1446 
1447 #if FW_AMPCS_COMPATIBLE
1448  // Serialize the argument size
1449  _status = _logBuff.serialize(
1450  static_cast<U8>(sizeof(I32))
1451  );
1452  FW_ASSERT(
1453  _status == Fw::FW_SERIALIZE_OK,
1454  static_cast<FwAssertArgType>(_status)
1455  );
1456 #endif
1457  _status = _logBuff.serialize(record);
1458  FW_ASSERT(
1459  _status == Fw::FW_SERIALIZE_OK,
1460  static_cast<FwAssertArgType>(_status)
1461  );
1462 
1463 #if FW_AMPCS_COMPATIBLE
1464  // Serialize the argument size
1465  _status = _logBuff.serialize(
1466  static_cast<U8>(sizeof(I32))
1467  );
1468  FW_ASSERT(
1469  _status == Fw::FW_SERIALIZE_OK,
1470  static_cast<FwAssertArgType>(_status)
1471  );
1472 #endif
1473  _status = _logBuff.serialize(error);
1474  FW_ASSERT(
1475  _status == Fw::FW_SERIALIZE_OK,
1476  static_cast<FwAssertArgType>(_status)
1477  );
1478 
1479  this->m_Log_OutputPort[0].invoke(
1480  _id,
1481  _logTime,
1483  _logBuff
1484  );
1485  }
1486 
1487  // Emit the event on the text log port
1488 #if FW_ENABLE_TEXT_LOGGING
1489  if (this->m_LogText_OutputPort[0].isConnected()) {
1490 #if FW_OBJECT_NAMES == 1
1491  const char* _formatString =
1492  "(%s) %s: Parameter write failed in stage %s with record %" PRIi32 " and error %" PRIi32 "";
1493 #else
1494  const char* _formatString =
1495  "%s: Parameter write failed in stage %s with record %" PRIi32 " and error %" PRIi32 "";
1496 #endif
1497 
1498  Fw::String stageStr;
1499  stage.toString(stageStr);
1500 
1501  Fw::TextLogString _logString;
1502  _logString.format(
1503  _formatString,
1504 #if FW_OBJECT_NAMES == 1
1505  this->m_objName.toChar(),
1506 #endif
1507  "PrmFileWriteError ",
1508  stageStr.toChar(),
1509  record,
1510  error
1511  );
1512 
1513  this->m_LogText_OutputPort[0].invoke(
1514  _id,
1515  _logTime,
1517  _logString
1518  );
1519  }
1520 #endif
1521  }
1522 
1525  {
1526  // Get the time
1527  Fw::Time _logTime;
1528  if (this->m_Time_OutputPort[0].isConnected()) {
1529  this->m_Time_OutputPort[0].invoke(_logTime);
1530  }
1531 
1532  FwEventIdType _id = static_cast<FwEventIdType>(0);
1533 
1534  _id = this->getIdBase() + EVENTID_PRMFILESAVECOMPLETE;
1535 
1536  // Emit the event on the log port
1537  if (this->m_Log_OutputPort[0].isConnected()) {
1538  Fw::LogBuffer _logBuff;
1540 
1541 #if FW_AMPCS_COMPATIBLE
1542  // Serialize the number of arguments
1543  _status = _logBuff.serialize(static_cast<U8>(1));
1544  FW_ASSERT(
1545  _status == Fw::FW_SERIALIZE_OK,
1546  static_cast<FwAssertArgType>(_status)
1547  );
1548 #endif
1549 
1550 #if FW_AMPCS_COMPATIBLE
1551  // Serialize the argument size
1552  _status = _logBuff.serialize(
1553  static_cast<U8>(sizeof(U32))
1554  );
1555  FW_ASSERT(
1556  _status == Fw::FW_SERIALIZE_OK,
1557  static_cast<FwAssertArgType>(_status)
1558  );
1559 #endif
1560  _status = _logBuff.serialize(records);
1561  FW_ASSERT(
1562  _status == Fw::FW_SERIALIZE_OK,
1563  static_cast<FwAssertArgType>(_status)
1564  );
1565 
1566  this->m_Log_OutputPort[0].invoke(
1567  _id,
1568  _logTime,
1570  _logBuff
1571  );
1572  }
1573 
1574  // Emit the event on the text log port
1575 #if FW_ENABLE_TEXT_LOGGING
1576  if (this->m_LogText_OutputPort[0].isConnected()) {
1577 #if FW_OBJECT_NAMES == 1
1578  const char* _formatString =
1579  "(%s) %s: Parameter file save completed. Wrote %" PRIu32 " records.";
1580 #else
1581  const char* _formatString =
1582  "%s: Parameter file save completed. Wrote %" PRIu32 " records.";
1583 #endif
1584 
1585  Fw::TextLogString _logString;
1586  _logString.format(
1587  _formatString,
1588 #if FW_OBJECT_NAMES == 1
1589  this->m_objName.toChar(),
1590 #endif
1591  "PrmFileSaveComplete ",
1592  records
1593  );
1594 
1595  this->m_LogText_OutputPort[0].invoke(
1596  _id,
1597  _logTime,
1599  _logString
1600  );
1601  }
1602 #endif
1603  }
1604 
1608  I32 record,
1609  I32 error
1610  ) const
1611  {
1612  // Get the time
1613  Fw::Time _logTime;
1614  if (this->m_Time_OutputPort[0].isConnected()) {
1615  this->m_Time_OutputPort[0].invoke(_logTime);
1616  }
1617 
1618  FwEventIdType _id = static_cast<FwEventIdType>(0);
1619 
1620  _id = this->getIdBase() + EVENTID_PRMFILEREADERROR;
1621 
1622  // Emit the event on the log port
1623  if (this->m_Log_OutputPort[0].isConnected()) {
1624  Fw::LogBuffer _logBuff;
1626 
1627 #if FW_AMPCS_COMPATIBLE
1628  // Serialize the number of arguments
1629  _status = _logBuff.serialize(static_cast<U8>(3));
1630  FW_ASSERT(
1631  _status == Fw::FW_SERIALIZE_OK,
1632  static_cast<FwAssertArgType>(_status)
1633  );
1634 #endif
1635 
1636 #if FW_AMPCS_COMPATIBLE
1637  // Serialize the argument size
1638  _status = _logBuff.serialize(
1640  );
1641  FW_ASSERT(
1642  _status == Fw::FW_SERIALIZE_OK,
1643  static_cast<FwAssertArgType>(_status)
1644  );
1645 #endif
1646  _status = _logBuff.serialize(stage);
1647  FW_ASSERT(
1648  _status == Fw::FW_SERIALIZE_OK,
1649  static_cast<FwAssertArgType>(_status)
1650  );
1651 
1652 #if FW_AMPCS_COMPATIBLE
1653  // Serialize the argument size
1654  _status = _logBuff.serialize(
1655  static_cast<U8>(sizeof(I32))
1656  );
1657  FW_ASSERT(
1658  _status == Fw::FW_SERIALIZE_OK,
1659  static_cast<FwAssertArgType>(_status)
1660  );
1661 #endif
1662  _status = _logBuff.serialize(record);
1663  FW_ASSERT(
1664  _status == Fw::FW_SERIALIZE_OK,
1665  static_cast<FwAssertArgType>(_status)
1666  );
1667 
1668 #if FW_AMPCS_COMPATIBLE
1669  // Serialize the argument size
1670  _status = _logBuff.serialize(
1671  static_cast<U8>(sizeof(I32))
1672  );
1673  FW_ASSERT(
1674  _status == Fw::FW_SERIALIZE_OK,
1675  static_cast<FwAssertArgType>(_status)
1676  );
1677 #endif
1678  _status = _logBuff.serialize(error);
1679  FW_ASSERT(
1680  _status == Fw::FW_SERIALIZE_OK,
1681  static_cast<FwAssertArgType>(_status)
1682  );
1683 
1684  this->m_Log_OutputPort[0].invoke(
1685  _id,
1686  _logTime,
1688  _logBuff
1689  );
1690  }
1691 
1692  // Emit the event on the text log port
1693 #if FW_ENABLE_TEXT_LOGGING
1694  if (this->m_LogText_OutputPort[0].isConnected()) {
1695 #if FW_OBJECT_NAMES == 1
1696  const char* _formatString =
1697  "(%s) %s: Parameter file read failed in stage %s with record %" PRIi32 " and error %" PRIi32 "";
1698 #else
1699  const char* _formatString =
1700  "%s: Parameter file read failed in stage %s with record %" PRIi32 " and error %" PRIi32 "";
1701 #endif
1702 
1703  Fw::String stageStr;
1704  stage.toString(stageStr);
1705 
1706  Fw::TextLogString _logString;
1707  _logString.format(
1708  _formatString,
1709 #if FW_OBJECT_NAMES == 1
1710  this->m_objName.toChar(),
1711 #endif
1712  "PrmFileReadError ",
1713  stageStr.toChar(),
1714  record,
1715  error
1716  );
1717 
1718  this->m_LogText_OutputPort[0].invoke(
1719  _id,
1720  _logTime,
1722  _logString
1723  );
1724  }
1725 #endif
1726  }
1727 
1730  {
1731  // Get the time
1732  Fw::Time _logTime;
1733  if (this->m_Time_OutputPort[0].isConnected()) {
1734  this->m_Time_OutputPort[0].invoke(_logTime);
1735  }
1736 
1737  FwEventIdType _id = static_cast<FwEventIdType>(0);
1738 
1739  _id = this->getIdBase() + EVENTID_PRMFILELOADCOMPLETE;
1740 
1741  // Emit the event on the log port
1742  if (this->m_Log_OutputPort[0].isConnected()) {
1743  Fw::LogBuffer _logBuff;
1745 
1746 #if FW_AMPCS_COMPATIBLE
1747  // Serialize the number of arguments
1748  _status = _logBuff.serialize(static_cast<U8>(1));
1749  FW_ASSERT(
1750  _status == Fw::FW_SERIALIZE_OK,
1751  static_cast<FwAssertArgType>(_status)
1752  );
1753 #endif
1754 
1755 #if FW_AMPCS_COMPATIBLE
1756  // Serialize the argument size
1757  _status = _logBuff.serialize(
1758  static_cast<U8>(sizeof(U32))
1759  );
1760  FW_ASSERT(
1761  _status == Fw::FW_SERIALIZE_OK,
1762  static_cast<FwAssertArgType>(_status)
1763  );
1764 #endif
1765  _status = _logBuff.serialize(records);
1766  FW_ASSERT(
1767  _status == Fw::FW_SERIALIZE_OK,
1768  static_cast<FwAssertArgType>(_status)
1769  );
1770 
1771  this->m_Log_OutputPort[0].invoke(
1772  _id,
1773  _logTime,
1775  _logBuff
1776  );
1777  }
1778 
1779  // Emit the event on the text log port
1780 #if FW_ENABLE_TEXT_LOGGING
1781  if (this->m_LogText_OutputPort[0].isConnected()) {
1782 #if FW_OBJECT_NAMES == 1
1783  const char* _formatString =
1784  "(%s) %s: Parameter file load completed. Read %" PRIu32 " records.";
1785 #else
1786  const char* _formatString =
1787  "%s: Parameter file load completed. Read %" PRIu32 " records.";
1788 #endif
1789 
1790  Fw::TextLogString _logString;
1791  _logString.format(
1792  _formatString,
1793 #if FW_OBJECT_NAMES == 1
1794  this->m_objName.toChar(),
1795 #endif
1796  "PrmFileLoadComplete ",
1797  records
1798  );
1799 
1800  this->m_LogText_OutputPort[0].invoke(
1801  _id,
1802  _logTime,
1804  _logString
1805  );
1806  }
1807 #endif
1808  }
1809 
1810  // ----------------------------------------------------------------------
1811  // Event throttle reset functions
1812  // ----------------------------------------------------------------------
1813 
1816  {
1817  // Reset throttle counter
1818  this->m_PrmIdNotFoundThrottle = 0;
1819  }
1820 
1821  // ----------------------------------------------------------------------
1822  // Time
1823  // ----------------------------------------------------------------------
1824 
1827  {
1828  if (this->m_Time_OutputPort[0].isConnected()) {
1829  Fw::Time _time;
1830  this->m_Time_OutputPort[0].invoke(_time);
1831  return _time;
1832  }
1833  else {
1834  return Fw::Time(TB_NONE, 0, 0);
1835  }
1836  }
1837 
1838  // ----------------------------------------------------------------------
1839  // Mutex operations for guarded ports
1840  //
1841  // You can override these operations to provide more sophisticated
1842  // synchronization
1843  // ----------------------------------------------------------------------
1844 
1847  {
1848  this->m_guardedPortMutex.lock();
1849  }
1850 
1853  {
1854  this->m_guardedPortMutex.unLock();
1855  }
1856 
1857  // ----------------------------------------------------------------------
1858  // Message dispatch functions
1859  // ----------------------------------------------------------------------
1860 
1861  Fw::QueuedComponentBase::MsgDispatchStatus PrmDbComponentBase ::
1862  doDispatch()
1863  {
1864  ComponentIpcSerializableBuffer _msg;
1865  FwQueuePriorityType _priority = 0;
1866 
1867  Os::Queue::Status _msgStatus = this->m_queue.receive(
1868  _msg,
1870  _priority
1871  );
1872  FW_ASSERT(
1873  _msgStatus == Os::Queue::OP_OK,
1874  static_cast<FwAssertArgType>(_msgStatus)
1875  );
1876 
1877  // Reset to beginning of buffer
1878  _msg.resetDeser();
1879 
1880  FwEnumStoreType _desMsg = 0;
1881  Fw::SerializeStatus _deserStatus = _msg.deserialize(_desMsg);
1882  FW_ASSERT(
1883  _deserStatus == Fw::FW_SERIALIZE_OK,
1884  static_cast<FwAssertArgType>(_deserStatus)
1885  );
1886 
1887  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
1888 
1889  if (_msgType == PRMDB_COMPONENT_EXIT) {
1890  return MSG_DISPATCH_EXIT;
1891  }
1892 
1893  FwIndexType portNum = 0;
1894  _deserStatus = _msg.deserialize(portNum);
1895  FW_ASSERT(
1896  _deserStatus == Fw::FW_SERIALIZE_OK,
1897  static_cast<FwAssertArgType>(_deserStatus)
1898  );
1899 
1900  switch (_msgType) {
1901  // Handle async input port pingIn
1902  case PINGIN_PING: {
1903  // Deserialize argument key
1904  U32 key;
1905  _deserStatus = _msg.deserialize(key);
1906  FW_ASSERT(
1907  _deserStatus == Fw::FW_SERIALIZE_OK,
1908  static_cast<FwAssertArgType>(_deserStatus)
1909  );
1910  // Call handler function
1911  this->pingIn_handler(
1912  portNum,
1913  key
1914  );
1915 
1916  break;
1917  }
1918 
1919  // Handle async input port setPrm
1920  case SETPRM_PRMSET: {
1921  // Deserialize argument id
1922  FwPrmIdType id;
1923  _deserStatus = _msg.deserialize(id);
1924  FW_ASSERT(
1925  _deserStatus == Fw::FW_SERIALIZE_OK,
1926  static_cast<FwAssertArgType>(_deserStatus)
1927  );
1928 
1929  // Deserialize argument val
1930  Fw::ParamBuffer val;
1931  _deserStatus = _msg.deserialize(val);
1932  FW_ASSERT(
1933  _deserStatus == Fw::FW_SERIALIZE_OK,
1934  static_cast<FwAssertArgType>(_deserStatus)
1935  );
1936  // Call handler function
1937  this->setPrm_handler(
1938  portNum,
1939  id,
1940  val
1941  );
1942 
1943  break;
1944  }
1945 
1946  // Handle command PRM_SAVE_FILE
1947  case CMD_PRM_SAVE_FILE: {
1948  // Deserialize opcode
1949  FwOpcodeType _opCode = 0;
1950  _deserStatus = _msg.deserialize(_opCode);
1951  FW_ASSERT (
1952  _deserStatus == Fw::FW_SERIALIZE_OK,
1953  static_cast<FwAssertArgType>(_deserStatus)
1954  );
1955 
1956  // Deserialize command sequence
1957  U32 _cmdSeq = 0;
1958  _deserStatus = _msg.deserialize(_cmdSeq);
1959  FW_ASSERT (
1960  _deserStatus == Fw::FW_SERIALIZE_OK,
1961  static_cast<FwAssertArgType>(_deserStatus)
1962  );
1963 
1964  // Deserialize command argument buffer
1965  Fw::CmdArgBuffer args;
1966  _deserStatus = _msg.deserialize(args);
1967  FW_ASSERT (
1968  _deserStatus == Fw::FW_SERIALIZE_OK,
1969  static_cast<FwAssertArgType>(_deserStatus)
1970  );
1971 
1972  // Reset buffer
1973  args.resetDeser();
1974 
1975  // Make sure there was no data left over.
1976  // That means the argument buffer size was incorrect.
1977 #if FW_CMD_CHECK_RESIDUAL
1978  if (args.getBuffLeft() != 0) {
1979  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
1980  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
1981  }
1982  // Don't crash the task if bad arguments were passed from the ground
1983  break;
1984  }
1985 #endif
1986 
1987  // Call handler function
1988  this->PRM_SAVE_FILE_cmdHandler(_opCode, _cmdSeq);
1989 
1990  break;
1991  }
1992 
1993  default:
1994  return MSG_DISPATCH_ERROR;
1995  }
1996 
1997  return MSG_DISPATCH_OK;
1998  }
1999 
2000  // ----------------------------------------------------------------------
2001  // Calls for messages received on special input ports
2002  // ----------------------------------------------------------------------
2003 
2004  void PrmDbComponentBase ::
2005  m_p_CmdDisp_in(
2006  Fw::PassiveComponentBase* callComp,
2007  FwIndexType portNum,
2008  FwOpcodeType opCode,
2009  U32 cmdSeq,
2010  Fw::CmdArgBuffer& args
2011  )
2012  {
2013  FW_ASSERT(callComp);
2014  PrmDbComponentBase* compPtr = static_cast<PrmDbComponentBase*>(callComp);
2015 
2016  const U32 idBase = callComp->getIdBase();
2017  FW_ASSERT(opCode >= idBase, static_cast<FwAssertArgType>(opCode), static_cast<FwAssertArgType>(idBase));
2018 
2019  // Select base class function based on opcode
2020  switch (opCode - idBase) {
2021  case OPCODE_PRM_SAVE_FILE: {
2022  compPtr->PRM_SAVE_FILE_cmdHandlerBase(
2023  opCode,
2024  cmdSeq,
2025  args
2026  );
2027  break;
2028  }
2029  }
2030  }
2031 
2032  // ----------------------------------------------------------------------
2033  // Calls for messages received on typed input ports
2034  // ----------------------------------------------------------------------
2035 
2036  Fw::ParamValid PrmDbComponentBase ::
2037  m_p_getPrm_in(
2038  Fw::PassiveComponentBase* callComp,
2039  FwIndexType portNum,
2040  FwPrmIdType id,
2041  Fw::ParamBuffer& val
2042  )
2043  {
2044  FW_ASSERT(callComp);
2045  PrmDbComponentBase* compPtr = static_cast<PrmDbComponentBase*>(callComp);
2046  return compPtr->getPrm_handlerBase(
2047  portNum,
2048  id,
2049  val
2050  );
2051  }
2052 
2053  void PrmDbComponentBase ::
2054  m_p_pingIn_in(
2055  Fw::PassiveComponentBase* callComp,
2056  FwIndexType portNum,
2057  U32 key
2058  )
2059  {
2060  FW_ASSERT(callComp);
2061  PrmDbComponentBase* compPtr = static_cast<PrmDbComponentBase*>(callComp);
2062  compPtr->pingIn_handlerBase(
2063  portNum,
2064  key
2065  );
2066  }
2067 
2068  void PrmDbComponentBase ::
2069  m_p_setPrm_in(
2070  Fw::PassiveComponentBase* callComp,
2071  FwIndexType portNum,
2072  FwPrmIdType id,
2073  Fw::ParamBuffer& val
2074  )
2075  {
2076  FW_ASSERT(callComp);
2077  PrmDbComponentBase* compPtr = static_cast<PrmDbComponentBase*>(callComp);
2078  compPtr->setPrm_handlerBase(
2079  portNum,
2080  id,
2081  val
2082  );
2083  }
2084 
2085 }
void set_CmdReg_OutputPort(FwIndexType portNum, Fw::InputCmdRegPort *port)
Connect port to CmdReg[portNum].
Serialization/Deserialization operation was successful.
void regCommands()
Register commands with the Command Dispatcher.
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
Definition: Time.hpp:9
bool isConnected_CmdReg_OutputPort(FwIndexType portNum)
Fw::ParamValid getPrm_handlerBase(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val)
Handler base-class function for input port getPrm.
Operation succeeded.
Definition: Os.hpp:26
void log_WARNING_LO_PrmIdNotFound_ThrottleClear()
Reset throttle value for PrmIdNotFound.
Throttle reset count for PrmIdNotFound.
The size of the serial representation.
The size of the serial representations of the port arguments.
Status
status returned from the queue send function
Definition: Queue.hpp:30
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
const char * toChar() const
Definition: String.hpp:50
void log_WARNING_LO_PrmIdNotFound(U32 Id)
PrmDbComponentBase(const char *compName="")
Construct PrmDbComponentBase object.
void init()
Initialization function.
Definition: CmdPortAc.cpp:56
void unLock()
unlock the mutex and assert success
Definition: Mutex.cpp:40
void log_ACTIVITY_HI_PrmFileSaveComplete(U32 records) const
PlatformSizeType FwSizeType
Definition: FpConfig.h:35
void invoke(U32 key) const
Invoke a port interface.
Definition: PingPortAc.cpp:147
Fw::InputPrmSetPort * get_setPrm_InputPort(FwIndexType portNum)
I32 FwEnumStoreType
Definition: FpConfig.h:64
Enum representing a command response.
void addCallPort(InputCmdRegPort *callPort)
Register an input port.
PlatformIndexType FwIndexType
Definition: FpConfig.h:25
Command to save parameter image to file. Uses file name passed to constructor.
The size of the serial representations of the port arguments.
Definition: CmdPortAc.hpp:37
void init()
Initialization function.
Os::Queue m_queue
queue object for active component
U32 FwPrmIdType
Definition: FpConfig.h:107
void log_WARNING_HI_PrmFileWriteError(Svc::PrmDb_PrmWriteError stage, I32 record, I32 error) const
void set_Log_OutputPort(FwIndexType portNum, Fw::InputLogPort *port)
Connect port to Log[portNum].
virtual void pingIn_handler(FwIndexType portNum, U32 key)=0
Handler for input port pingIn.
void init()
Object initializer.
Definition: ObjBase.cpp:26
virtual ~PrmDbComponentBase()
Destroy PrmDbComponentBase object.
SerializeStatus
forward declaration for string
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CmdPortAc.cpp:62
void log_ACTIVITY_HI_PrmFileLoadComplete(U32 records) const
virtual void lock()
Lock the guarded mutex.
Message will block until space is available.
Definition: Queue.hpp:46
FwIndexType getNum_setPrm_InputPorts() const
void log_WARNING_HI_PrmFileReadError(Svc::PrmDb_PrmReadError stage, I32 record, I32 error) const
FwIndexType getNum_getPrm_InputPorts() const
void invoke(FwOpcodeType opCode) const
Invoke a port interface.
Parameter ID updated in database.
Serializable::SizeType getBuffLeft() const
returns how much deserialization buffer is left
void init()
Initialization function.
Definition: TimePortAc.cpp:128
Fw::InputCmdPort * get_CmdDisp_InputPort(FwIndexType portNum)
message to exit active component task
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
A less serious but recoverable event.
void init()
Initialization function.
Definition: PingPortAc.cpp:128
virtual void pingIn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port pingIn.
void invoke(Fw::Time &time) const
Invoke a port interface.
Definition: TimePortAc.cpp:147
bool isConnected_CmdStatus_OutputPort(FwIndexType portNum)
U32 FwOpcodeType
Definition: FpConfig.h:91
bool isConnected_Log_OutputPort(FwIndexType portNum)
const char * toChar() const
Definition: ObjectName.hpp:50
void invoke(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response) const
Invoke a port interface.
The size of the serial representation.
No time base has been established.
Definition: FpConfig.h:70
FwSizeType SizeType
void addCallPort(InputPingPort *callPort)
Register an input port.
Definition: PingPortAc.cpp:134
void log_ACTIVITY_HI_PrmIdAdded(U32 Id) const
void setPrm_handlerBase(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val)
Handler base-class function for input port setPrm.
Status send(const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override
send a message into the queue through delegate
FwIndexType getNum_Log_OutputPorts() const
virtual void unLock()
Unlock the guarded mutex.
Svc::InputPingPort * get_pingIn_InputPort(FwIndexType portNum)
void resetDeser()
reset deserialization to beginning
A serious but recoverable event.
bool isConnected() const
Definition: PortBase.cpp:42
U32 FwEventIdType
Definition: FpConfig.h:103
virtual Fw::ParamValid getPrm_handler(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val)=0
Handler for input port getPrm.
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
void init()
Initialization function.
Definition: LogPortAc.cpp:151
void setPortNum(FwIndexType portNum)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:32
virtual void PRM_SAVE_FILE_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command PRM_SAVE_FILE.
BlockingType
message type
Definition: Queue.hpp:45
void log_ACTIVITY_HI_PrmIdUpdated(U32 Id) const
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
void pingIn_handlerBase(FwIndexType portNum, U32 key)
Handler base-class function for input port pingIn.
Command failed to deserialize.
FwIndexType getNum_pingOut_OutputPorts() const
void PRM_SAVE_FILE_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
Important informational events.
FwIndexType getNum_CmdDisp_InputPorts() const
FwIndexType getNum_Time_OutputPorts() const
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args) const
Invoke a port interface.
Definition: LogPortAc.cpp:170
PlatformQueuePriorityType FwQueuePriorityType
Definition: FpConfig.h:55
A message was sent requesting an exit of the loop.
FwIndexType getNum_CmdStatus_OutputPorts() const
void set_CmdStatus_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to CmdStatus[portNum].
A fatal non-recoverable event.
virtual void setPrm_handler(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val)=0
Handler for input port setPrm.
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:85
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:157
Parameter ID not found in database.
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
void init()
Initialization function.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
void init()
Initialization function.
Definition: PingPortAc.cpp:56
Parameter ID added to database.
The size of the serial representations of the port arguments.
Definition: PingPortAc.hpp:36
message sent/received okay
Definition: Queue.hpp:31
Enum representing parameter validity.
U8 BYTE
byte type
Definition: BasicTypes.h:35
bool isConnected_Time_OutputPort(FwIndexType portNum)
Fw::InputPrmGetPort * get_getPrm_InputPort(FwIndexType portNum)
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
bool isConnected_pingOut_OutputPort(FwIndexType portNum)
FwIndexType getNum_pingIn_InputPorts() const
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: PingPortAc.cpp:62
void set_pingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to pingOut[portNum].
Message will return with status when space is unavailable.
Definition: Queue.hpp:47
Status receive(U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
receive a message from the queue through delegate
void init()
Initialization function.
virtual void PRM_SAVE_FILE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
FwIndexType getNum_CmdReg_OutputPorts() const
void log_FATAL_PrmDbFull(U32 Id) const
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:148
#define FW_ASSERT(...)
Definition: Assert.hpp:14
virtual void setPrm_preMsgHook(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val)
Pre-message hook for async input port setPrm.
void init()
Initialization function.
void addCallPort(InputCmdResponsePort *callPort)
Register an input port.
void lock()
lock the mutex and assert success
Definition: Mutex.cpp:34