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