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 
7 #include "Fw/Types/Assert.hpp"
9 #if FW_ENABLE_TEXT_LOGGING
10 #include "Fw/Types/String.hpp"
11 #endif
13 
14 namespace Svc {
15 
16  namespace {
17  enum MsgTypeEnum {
19  PINGIN_PING,
20  SETPRM_PRMSET,
21  CMD_PRM_SAVE_FILE,
22  CMD_PRM_LOAD_FILE,
23  CMD_PRM_COMMIT_STAGED,
24  };
25 
26  // Get the max size by constructing a union of the async input, command, and
27  // internal port serialization sizes
28  union BuffUnion {
32  };
33 
34  // Define a message buffer class large enough to handle all the
35  // asynchronous inputs to the component
36  class ComponentIpcSerializableBuffer :
38  {
39 
40  public:
41 
42  enum {
43  // Offset into data in buffer: Size of message ID and port number
44  DATA_OFFSET = sizeof(FwEnumStoreType) + sizeof(FwIndexType),
45  // Max data size
46  MAX_DATA_SIZE = sizeof(BuffUnion),
47  // Max message size: Size of message id + size of port + max data size
48  SERIALIZATION_SIZE = DATA_OFFSET + MAX_DATA_SIZE
49  };
50 
51  Fw::Serializable::SizeType getCapacity() const {
52  return sizeof(m_buff);
53  }
54 
55  U8* getBuffAddr() {
56  return m_buff;
57  }
58 
59  const U8* getBuffAddr() const {
60  return m_buff;
61  }
62 
63  private:
64  // Should be the max of all the input ports serialized sizes...
65  U8 m_buff[SERIALIZATION_SIZE];
66 
67  };
68  }
69 
70  // ----------------------------------------------------------------------
71  // Component initialization
72  // ----------------------------------------------------------------------
73 
76  FwSizeType queueDepth,
77  FwEnumStoreType instance
78  )
79  {
80  // Initialize base class
82 
83  // Connect input port CmdDisp
84  for (
85  FwIndexType port = 0;
86  port < static_cast<FwIndexType>(this->getNum_CmdDisp_InputPorts());
87  port++
88  ) {
89  this->m_CmdDisp_InputPort[port].init();
90  this->m_CmdDisp_InputPort[port].addCallComp(
91  this,
92  m_p_CmdDisp_in
93  );
94  this->m_CmdDisp_InputPort[port].setPortNum(port);
95 
96 #if FW_OBJECT_NAMES == 1
97  Fw::ObjectName portName;
98  portName.format(
99  "%s_CmdDisp_InputPort[%" PRI_FwIndexType "]",
100  this->m_objName.toChar(),
101  port
102  );
103  this->m_CmdDisp_InputPort[port].setObjName(portName.toChar());
104 #endif
105  }
106 
107  // Connect input port getPrm
108  for (
109  FwIndexType port = 0;
110  port < static_cast<FwIndexType>(this->getNum_getPrm_InputPorts());
111  port++
112  ) {
113  this->m_getPrm_InputPort[port].init();
114  this->m_getPrm_InputPort[port].addCallComp(
115  this,
116  m_p_getPrm_in
117  );
118  this->m_getPrm_InputPort[port].setPortNum(port);
119 
120 #if FW_OBJECT_NAMES == 1
121  Fw::ObjectName portName;
122  portName.format(
123  "%s_getPrm_InputPort[%" PRI_FwIndexType "]",
124  this->m_objName.toChar(),
125  port
126  );
127  this->m_getPrm_InputPort[port].setObjName(portName.toChar());
128 #endif
129  }
130 
131  // Connect input port pingIn
132  for (
133  FwIndexType port = 0;
134  port < static_cast<FwIndexType>(this->getNum_pingIn_InputPorts());
135  port++
136  ) {
137  this->m_pingIn_InputPort[port].init();
138  this->m_pingIn_InputPort[port].addCallComp(
139  this,
140  m_p_pingIn_in
141  );
142  this->m_pingIn_InputPort[port].setPortNum(port);
143 
144 #if FW_OBJECT_NAMES == 1
145  Fw::ObjectName portName;
146  portName.format(
147  "%s_pingIn_InputPort[%" PRI_FwIndexType "]",
148  this->m_objName.toChar(),
149  port
150  );
151  this->m_pingIn_InputPort[port].setObjName(portName.toChar());
152 #endif
153  }
154 
155  // Connect input port setPrm
156  for (
157  FwIndexType port = 0;
158  port < static_cast<FwIndexType>(this->getNum_setPrm_InputPorts());
159  port++
160  ) {
161  this->m_setPrm_InputPort[port].init();
162  this->m_setPrm_InputPort[port].addCallComp(
163  this,
164  m_p_setPrm_in
165  );
166  this->m_setPrm_InputPort[port].setPortNum(port);
167 
168 #if FW_OBJECT_NAMES == 1
169  Fw::ObjectName portName;
170  portName.format(
171  "%s_setPrm_InputPort[%" PRI_FwIndexType "]",
172  this->m_objName.toChar(),
173  port
174  );
175  this->m_setPrm_InputPort[port].setObjName(portName.toChar());
176 #endif
177  }
178 
179  // Connect output port CmdReg
180  for (
181  FwIndexType port = 0;
182  port < static_cast<FwIndexType>(this->getNum_CmdReg_OutputPorts());
183  port++
184  ) {
185  this->m_CmdReg_OutputPort[port].init();
186 
187 #if FW_OBJECT_NAMES == 1
188  Fw::ObjectName portName;
189  portName.format(
190  "%s_CmdReg_OutputPort[%" PRI_FwIndexType "]",
191  this->m_objName.toChar(),
192  port
193  );
194  this->m_CmdReg_OutputPort[port].setObjName(portName.toChar());
195 #endif
196  }
197 
198  // Connect output port CmdStatus
199  for (
200  FwIndexType port = 0;
201  port < static_cast<FwIndexType>(this->getNum_CmdStatus_OutputPorts());
202  port++
203  ) {
204  this->m_CmdStatus_OutputPort[port].init();
205 
206 #if FW_OBJECT_NAMES == 1
207  Fw::ObjectName portName;
208  portName.format(
209  "%s_CmdStatus_OutputPort[%" PRI_FwIndexType "]",
210  this->m_objName.toChar(),
211  port
212  );
213  this->m_CmdStatus_OutputPort[port].setObjName(portName.toChar());
214 #endif
215  }
216 
217  // Connect output port Log
218  for (
219  FwIndexType port = 0;
220  port < static_cast<FwIndexType>(this->getNum_Log_OutputPorts());
221  port++
222  ) {
223  this->m_Log_OutputPort[port].init();
224 
225 #if FW_OBJECT_NAMES == 1
226  Fw::ObjectName portName;
227  portName.format(
228  "%s_Log_OutputPort[%" PRI_FwIndexType "]",
229  this->m_objName.toChar(),
230  port
231  );
232  this->m_Log_OutputPort[port].setObjName(portName.toChar());
233 #endif
234  }
235 
236 #if FW_ENABLE_TEXT_LOGGING == 1
237  // Connect output port LogText
238  for (
239  FwIndexType port = 0;
240  port < static_cast<FwIndexType>(this->getNum_LogText_OutputPorts());
241  port++
242  ) {
243  this->m_LogText_OutputPort[port].init();
244 
245 #if FW_OBJECT_NAMES == 1
246  Fw::ObjectName portName;
247  portName.format(
248  "%s_LogText_OutputPort[%" PRI_FwIndexType "]",
249  this->m_objName.toChar(),
250  port
251  );
252  this->m_LogText_OutputPort[port].setObjName(portName.toChar());
253 #endif
254  }
255 #endif
256 
257  // Connect output port Time
258  for (
259  FwIndexType port = 0;
260  port < static_cast<FwIndexType>(this->getNum_Time_OutputPorts());
261  port++
262  ) {
263  this->m_Time_OutputPort[port].init();
264 
265 #if FW_OBJECT_NAMES == 1
266  Fw::ObjectName portName;
267  portName.format(
268  "%s_Time_OutputPort[%" PRI_FwIndexType "]",
269  this->m_objName.toChar(),
270  port
271  );
272  this->m_Time_OutputPort[port].setObjName(portName.toChar());
273 #endif
274  }
275 
276  // Connect output port pingOut
277  for (
278  FwIndexType port = 0;
279  port < static_cast<FwIndexType>(this->getNum_pingOut_OutputPorts());
280  port++
281  ) {
282  this->m_pingOut_OutputPort[port].init();
283 
284 #if FW_OBJECT_NAMES == 1
285  Fw::ObjectName portName;
286  portName.format(
287  "%s_pingOut_OutputPort[%" PRI_FwIndexType "]",
288  this->m_objName.toChar(),
289  port
290  );
291  this->m_pingOut_OutputPort[port].setObjName(portName.toChar());
292 #endif
293  }
294 
295  // Create the queue
296  Os::Queue::Status qStat = this->createQueue(
297  queueDepth,
298  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
299  );
300  FW_ASSERT(
301  Os::Queue::Status::OP_OK == qStat,
302  static_cast<FwAssertArgType>(qStat)
303  );
304  }
305 
306  // ----------------------------------------------------------------------
307  // Getters for special input ports
308  // ----------------------------------------------------------------------
309 
312  {
313  FW_ASSERT(
314  (0 <= portNum) && (portNum < this->getNum_CmdDisp_InputPorts()),
315  static_cast<FwAssertArgType>(portNum)
316  );
317 
318  return &this->m_CmdDisp_InputPort[portNum];
319  }
320 
321  // ----------------------------------------------------------------------
322  // Getters for typed input ports
323  // ----------------------------------------------------------------------
324 
327  {
328  FW_ASSERT(
329  (0 <= portNum) && (portNum < this->getNum_getPrm_InputPorts()),
330  static_cast<FwAssertArgType>(portNum)
331  );
332 
333  return &this->m_getPrm_InputPort[portNum];
334  }
335 
338  {
339  FW_ASSERT(
340  (0 <= portNum) && (portNum < this->getNum_pingIn_InputPorts()),
341  static_cast<FwAssertArgType>(portNum)
342  );
343 
344  return &this->m_pingIn_InputPort[portNum];
345  }
346 
349  {
350  FW_ASSERT(
351  (0 <= portNum) && (portNum < this->getNum_setPrm_InputPorts()),
352  static_cast<FwAssertArgType>(portNum)
353  );
354 
355  return &this->m_setPrm_InputPort[portNum];
356  }
357 
358  // ----------------------------------------------------------------------
359  // Connect input ports to special output ports
360  // ----------------------------------------------------------------------
361 
364  FwIndexType portNum,
365  Fw::InputCmdRegPort* port
366  )
367  {
368  FW_ASSERT(
369  (0 <= portNum) && (portNum < this->getNum_CmdReg_OutputPorts()),
370  static_cast<FwAssertArgType>(portNum)
371  );
372 
373  this->m_CmdReg_OutputPort[portNum].addCallPort(port);
374  }
375 
378  FwIndexType portNum,
380  )
381  {
382  FW_ASSERT(
383  (0 <= portNum) && (portNum < this->getNum_CmdStatus_OutputPorts()),
384  static_cast<FwAssertArgType>(portNum)
385  );
386 
387  this->m_CmdStatus_OutputPort[portNum].addCallPort(port);
388  }
389 
392  FwIndexType portNum,
393  Fw::InputLogPort* port
394  )
395  {
396  FW_ASSERT(
397  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
398  static_cast<FwAssertArgType>(portNum)
399  );
400 
401  this->m_Log_OutputPort[portNum].addCallPort(port);
402  }
403 
404 #if FW_ENABLE_TEXT_LOGGING == 1
405 
406  void PrmDbComponentBase ::
407  set_LogText_OutputPort(
408  FwIndexType portNum,
410  )
411  {
412  FW_ASSERT(
413  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
414  static_cast<FwAssertArgType>(portNum)
415  );
416 
417  this->m_LogText_OutputPort[portNum].addCallPort(port);
418  }
419 
420 #endif
421 
424  FwIndexType portNum,
425  Fw::InputTimePort* port
426  )
427  {
428  FW_ASSERT(
429  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
430  static_cast<FwAssertArgType>(portNum)
431  );
432 
433  this->m_Time_OutputPort[portNum].addCallPort(port);
434  }
435 
436  // ----------------------------------------------------------------------
437  // Connect typed input ports to typed output ports
438  // ----------------------------------------------------------------------
439 
442  FwIndexType portNum,
443  Svc::InputPingPort* port
444  )
445  {
446  FW_ASSERT(
447  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
448  static_cast<FwAssertArgType>(portNum)
449  );
450 
451  this->m_pingOut_OutputPort[portNum].addCallPort(port);
452  }
453 
454 #if FW_PORT_SERIALIZATION
455 
456  // ----------------------------------------------------------------------
457  // Connect serial input ports to special output ports
458  // ----------------------------------------------------------------------
459 
462  FwIndexType portNum,
463  Fw::InputSerializePort* port
464  )
465  {
466  FW_ASSERT(
467  (0 <= portNum) && (portNum < this->getNum_CmdReg_OutputPorts()),
468  static_cast<FwAssertArgType>(portNum)
469  );
470 
471  this->m_CmdReg_OutputPort[portNum].registerSerialPort(port);
472  }
473 
476  FwIndexType portNum,
477  Fw::InputSerializePort* port
478  )
479  {
480  FW_ASSERT(
481  (0 <= portNum) && (portNum < this->getNum_CmdStatus_OutputPorts()),
482  static_cast<FwAssertArgType>(portNum)
483  );
484 
485  this->m_CmdStatus_OutputPort[portNum].registerSerialPort(port);
486  }
487 
490  FwIndexType portNum,
491  Fw::InputSerializePort* port
492  )
493  {
494  FW_ASSERT(
495  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
496  static_cast<FwAssertArgType>(portNum)
497  );
498 
499  this->m_Log_OutputPort[portNum].registerSerialPort(port);
500  }
501 
502 #if FW_ENABLE_TEXT_LOGGING == 1
503 
504  void PrmDbComponentBase ::
505  set_LogText_OutputPort(
506  FwIndexType portNum,
507  Fw::InputSerializePort* port
508  )
509  {
510  FW_ASSERT(
511  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
512  static_cast<FwAssertArgType>(portNum)
513  );
514 
515  this->m_LogText_OutputPort[portNum].registerSerialPort(port);
516  }
517 
518 #endif
519 
522  FwIndexType portNum,
523  Fw::InputSerializePort* port
524  )
525  {
526  FW_ASSERT(
527  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
528  static_cast<FwAssertArgType>(portNum)
529  );
530 
531  this->m_Time_OutputPort[portNum].registerSerialPort(port);
532  }
533 
534 #endif
535 
536 #if FW_PORT_SERIALIZATION
537 
538  // ----------------------------------------------------------------------
539  // Connect serial input ports to typed output ports
540  // ----------------------------------------------------------------------
541 
544  FwIndexType portNum,
545  Fw::InputSerializePort* port
546  )
547  {
548  FW_ASSERT(
549  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
550  static_cast<FwAssertArgType>(portNum)
551  );
552 
553  this->m_pingOut_OutputPort[portNum].registerSerialPort(port);
554  }
555 
556 #endif
557 
558  // ----------------------------------------------------------------------
559  // Command registration
560  // ----------------------------------------------------------------------
561 
564  {
565  FW_ASSERT(this->m_CmdReg_OutputPort[0].isConnected());
566 
567  this->m_CmdReg_OutputPort[0].invoke(
569  );
570 
571  this->m_CmdReg_OutputPort[0].invoke(
573  );
574 
575  this->m_CmdReg_OutputPort[0].invoke(
577  );
578  }
579 
580  // ----------------------------------------------------------------------
581  // Component construction and destruction
582  // ----------------------------------------------------------------------
583 
585  PrmDbComponentBase(const char* compName) :
586  Fw::ActiveComponentBase(compName)
587  {
588  this->m_PrmIdNotFoundThrottle = 0;
589  }
590 
593  {
594 
595  }
596 
597  // ----------------------------------------------------------------------
598  // Connection status queries for special output ports
599  // ----------------------------------------------------------------------
600 
603  {
604  FW_ASSERT(
605  (0 <= portNum) && (portNum < this->getNum_CmdReg_OutputPorts()),
606  static_cast<FwAssertArgType>(portNum)
607  );
608 
609  return this->m_CmdReg_OutputPort[portNum].isConnected();
610  }
611 
614  {
615  FW_ASSERT(
616  (0 <= portNum) && (portNum < this->getNum_CmdStatus_OutputPorts()),
617  static_cast<FwAssertArgType>(portNum)
618  );
619 
620  return this->m_CmdStatus_OutputPort[portNum].isConnected();
621  }
622 
625  {
626  FW_ASSERT(
627  (0 <= portNum) && (portNum < this->getNum_Log_OutputPorts()),
628  static_cast<FwAssertArgType>(portNum)
629  );
630 
631  return this->m_Log_OutputPort[portNum].isConnected();
632  }
633 
634 #if FW_ENABLE_TEXT_LOGGING == 1
635 
636  bool PrmDbComponentBase ::
637  isConnected_LogText_OutputPort(FwIndexType portNum)
638  {
639  FW_ASSERT(
640  (0 <= portNum) && (portNum < this->getNum_LogText_OutputPorts()),
641  static_cast<FwAssertArgType>(portNum)
642  );
643 
644  return this->m_LogText_OutputPort[portNum].isConnected();
645  }
646 
647 #endif
648 
651  {
652  FW_ASSERT(
653  (0 <= portNum) && (portNum < this->getNum_Time_OutputPorts()),
654  static_cast<FwAssertArgType>(portNum)
655  );
656 
657  return this->m_Time_OutputPort[portNum].isConnected();
658  }
659 
660  // ----------------------------------------------------------------------
661  // Connection status queries for typed output ports
662  // ----------------------------------------------------------------------
663 
666  {
667  FW_ASSERT(
668  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
669  static_cast<FwAssertArgType>(portNum)
670  );
671 
672  return this->m_pingOut_OutputPort[portNum].isConnected();
673  }
674 
675  // ----------------------------------------------------------------------
676  // Port handler base-class functions for typed input ports
677  //
678  // Call these functions directly to bypass the corresponding ports
679  // ----------------------------------------------------------------------
680 
683  FwIndexType portNum,
684  FwPrmIdType id,
685  Fw::ParamBuffer& val
686  )
687  {
688  // Make sure port number is valid
689  FW_ASSERT(
690  (0 <= portNum) && (portNum < this->getNum_getPrm_InputPorts()),
691  static_cast<FwAssertArgType>(portNum)
692  );
693 
694  Fw::ParamValid retVal;
695 
696  // Lock guard mutex before calling
697  this->lock();
698 
699  // Call handler function
700  retVal = this->getPrm_handler(
701  portNum,
702  id,
703  val
704  );
705 
706  // Unlock guard mutex
707  this->unLock();
708 
709  return retVal;
710  }
711 
714  FwIndexType portNum,
715  U32 key
716  )
717  {
718  // Make sure port number is valid
719  FW_ASSERT(
720  (0 <= portNum) && (portNum < this->getNum_pingIn_InputPorts()),
721  static_cast<FwAssertArgType>(portNum)
722  );
723 
724  // Call pre-message hook
726  portNum,
727  key
728  );
729  ComponentIpcSerializableBuffer msg;
731 
732  // Serialize message ID
733  _status = msg.serializeFrom(
734  static_cast<FwEnumStoreType>(PINGIN_PING)
735  );
736  FW_ASSERT(
737  _status == Fw::FW_SERIALIZE_OK,
738  static_cast<FwAssertArgType>(_status)
739  );
740 
741  // Serialize port number
742  _status = msg.serializeFrom(portNum);
743  FW_ASSERT(
744  _status == Fw::FW_SERIALIZE_OK,
745  static_cast<FwAssertArgType>(_status)
746  );
747 
748  // Serialize argument key
749  _status = msg.serializeFrom(key);
750  FW_ASSERT(
751  _status == Fw::FW_SERIALIZE_OK,
752  static_cast<FwAssertArgType>(_status)
753  );
754 
755  // Send message
757  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
758 
759  FW_ASSERT(
760  qStatus == Os::Queue::OP_OK,
761  static_cast<FwAssertArgType>(qStatus)
762  );
763  }
764 
767  FwIndexType portNum,
768  FwPrmIdType id,
769  Fw::ParamBuffer& val
770  )
771  {
772  // Make sure port number is valid
773  FW_ASSERT(
774  (0 <= portNum) && (portNum < this->getNum_setPrm_InputPorts()),
775  static_cast<FwAssertArgType>(portNum)
776  );
777 
778  // Call pre-message hook
780  portNum,
781  id,
782  val
783  );
784  ComponentIpcSerializableBuffer msg;
786 
787  // Serialize message ID
788  _status = msg.serializeFrom(
789  static_cast<FwEnumStoreType>(SETPRM_PRMSET)
790  );
791  FW_ASSERT(
792  _status == Fw::FW_SERIALIZE_OK,
793  static_cast<FwAssertArgType>(_status)
794  );
795 
796  // Serialize port number
797  _status = msg.serializeFrom(portNum);
798  FW_ASSERT(
799  _status == Fw::FW_SERIALIZE_OK,
800  static_cast<FwAssertArgType>(_status)
801  );
802 
803  // Serialize argument id
804  _status = msg.serializeFrom(id);
805  FW_ASSERT(
806  _status == Fw::FW_SERIALIZE_OK,
807  static_cast<FwAssertArgType>(_status)
808  );
809 
810  // Serialize argument val
811  _status = msg.serializeFrom(val);
812  FW_ASSERT(
813  _status == Fw::FW_SERIALIZE_OK,
814  static_cast<FwAssertArgType>(_status)
815  );
816 
817  // Send message
819  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
820 
821  FW_ASSERT(
822  qStatus == Os::Queue::OP_OK,
823  static_cast<FwAssertArgType>(qStatus)
824  );
825  }
826 
827  // ----------------------------------------------------------------------
828  // Pre-message hooks for typed async input ports
829  //
830  // Each of these functions is invoked just before processing a message
831  // on the corresponding port. By default, they do nothing. You can
832  // override them to provide specific pre-message behavior.
833  // ----------------------------------------------------------------------
834 
837  FwIndexType portNum,
838  U32 key
839  )
840  {
841  // Default: no-op
842  }
843 
846  FwIndexType portNum,
847  FwPrmIdType id,
848  Fw::ParamBuffer& val
849  )
850  {
851  // Default: no-op
852  }
853 
854  // ----------------------------------------------------------------------
855  // Invocation functions for typed output ports
856  // ----------------------------------------------------------------------
857 
860  FwIndexType portNum,
861  U32 key
862  )
863  {
864  FW_ASSERT(
865  (0 <= portNum) && (portNum < this->getNum_pingOut_OutputPorts()),
866  static_cast<FwAssertArgType>(portNum)
867  );
868 
869  FW_ASSERT(
870  this->m_pingOut_OutputPort[portNum].isConnected(),
871  static_cast<FwAssertArgType>(portNum)
872  );
873  this->m_pingOut_OutputPort[portNum].invoke(
874  key
875  );
876  }
877 
878  // ----------------------------------------------------------------------
879  // Command response
880  // ----------------------------------------------------------------------
881 
884  FwOpcodeType opCode,
885  U32 cmdSeq,
886  Fw::CmdResponse response
887  )
888  {
889  FW_ASSERT(this->m_CmdStatus_OutputPort[0].isConnected());
890  this->m_CmdStatus_OutputPort[0].invoke(opCode, cmdSeq, response);
891  }
892 
893  // ----------------------------------------------------------------------
894  // Command handler base-class functions
895  //
896  // Call these functions directly to bypass the command input port
897  // ----------------------------------------------------------------------
898 
901  FwOpcodeType opCode,
902  U32 cmdSeq,
903  Fw::CmdArgBuffer& args
904  )
905  {
906  // Call pre-message hook
907  this->PRM_SAVE_FILE_preMsgHook(opCode,cmdSeq);
908 
909  // Defer deserializing arguments to the message dispatcher
910  // to avoid deserializing and reserializing just for IPC
911  ComponentIpcSerializableBuffer msg;
913 
914  // Serialize for IPC
915  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(CMD_PRM_SAVE_FILE));
916  FW_ASSERT (
917  _status == Fw::FW_SERIALIZE_OK,
918  static_cast<FwAssertArgType>(_status)
919  );
920 
921  // Fake port number to make message dequeue work
922  FwIndexType port = 0;
923 
924  _status = msg.serializeFrom(port);
925  FW_ASSERT (
926  _status == Fw::FW_SERIALIZE_OK,
927  static_cast<FwAssertArgType>(_status)
928  );
929 
930  _status = msg.serializeFrom(opCode);
931  FW_ASSERT (
932  _status == Fw::FW_SERIALIZE_OK,
933  static_cast<FwAssertArgType>(_status)
934  );
935 
936  _status = msg.serializeFrom(cmdSeq);
937  FW_ASSERT (
938  _status == Fw::FW_SERIALIZE_OK,
939  static_cast<FwAssertArgType>(_status)
940  );
941 
942  _status = msg.serializeFrom(args);
943  FW_ASSERT (
944  _status == Fw::FW_SERIALIZE_OK,
945  static_cast<FwAssertArgType>(_status)
946  );
947 
948  // Send message
950  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
951 
952  FW_ASSERT(
953  qStatus == Os::Queue::OP_OK,
954  static_cast<FwAssertArgType>(qStatus)
955  );
956  }
957 
960  FwOpcodeType opCode,
961  U32 cmdSeq,
962  Fw::CmdArgBuffer& args
963  )
964  {
965  // Call pre-message hook
966  this->PRM_LOAD_FILE_preMsgHook(opCode,cmdSeq);
967 
968  // Defer deserializing arguments to the message dispatcher
969  // to avoid deserializing and reserializing just for IPC
970  ComponentIpcSerializableBuffer msg;
972 
973  // Serialize for IPC
974  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(CMD_PRM_LOAD_FILE));
975  FW_ASSERT (
976  _status == Fw::FW_SERIALIZE_OK,
977  static_cast<FwAssertArgType>(_status)
978  );
979 
980  // Fake port number to make message dequeue work
981  FwIndexType port = 0;
982 
983  _status = msg.serializeFrom(port);
984  FW_ASSERT (
985  _status == Fw::FW_SERIALIZE_OK,
986  static_cast<FwAssertArgType>(_status)
987  );
988 
989  _status = msg.serializeFrom(opCode);
990  FW_ASSERT (
991  _status == Fw::FW_SERIALIZE_OK,
992  static_cast<FwAssertArgType>(_status)
993  );
994 
995  _status = msg.serializeFrom(cmdSeq);
996  FW_ASSERT (
997  _status == Fw::FW_SERIALIZE_OK,
998  static_cast<FwAssertArgType>(_status)
999  );
1000 
1001  _status = msg.serializeFrom(args);
1002  FW_ASSERT (
1003  _status == Fw::FW_SERIALIZE_OK,
1004  static_cast<FwAssertArgType>(_status)
1005  );
1006 
1007  // Send message
1009  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1010 
1011  FW_ASSERT(
1012  qStatus == Os::Queue::OP_OK,
1013  static_cast<FwAssertArgType>(qStatus)
1014  );
1015  }
1016 
1019  FwOpcodeType opCode,
1020  U32 cmdSeq,
1021  Fw::CmdArgBuffer& args
1022  )
1023  {
1024  // Call pre-message hook
1025  this->PRM_COMMIT_STAGED_preMsgHook(opCode,cmdSeq);
1026 
1027  // Defer deserializing arguments to the message dispatcher
1028  // to avoid deserializing and reserializing just for IPC
1029  ComponentIpcSerializableBuffer msg;
1031 
1032  // Serialize for IPC
1033  _status = msg.serializeFrom(static_cast<FwEnumStoreType>(CMD_PRM_COMMIT_STAGED));
1034  FW_ASSERT (
1035  _status == Fw::FW_SERIALIZE_OK,
1036  static_cast<FwAssertArgType>(_status)
1037  );
1038 
1039  // Fake port number to make message dequeue work
1040  FwIndexType port = 0;
1041 
1042  _status = msg.serializeFrom(port);
1043  FW_ASSERT (
1044  _status == Fw::FW_SERIALIZE_OK,
1045  static_cast<FwAssertArgType>(_status)
1046  );
1047 
1048  _status = msg.serializeFrom(opCode);
1049  FW_ASSERT (
1050  _status == Fw::FW_SERIALIZE_OK,
1051  static_cast<FwAssertArgType>(_status)
1052  );
1053 
1054  _status = msg.serializeFrom(cmdSeq);
1055  FW_ASSERT (
1056  _status == Fw::FW_SERIALIZE_OK,
1057  static_cast<FwAssertArgType>(_status)
1058  );
1059 
1060  _status = msg.serializeFrom(args);
1061  FW_ASSERT (
1062  _status == Fw::FW_SERIALIZE_OK,
1063  static_cast<FwAssertArgType>(_status)
1064  );
1065 
1066  // Send message
1068  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
1069 
1070  FW_ASSERT(
1071  qStatus == Os::Queue::OP_OK,
1072  static_cast<FwAssertArgType>(qStatus)
1073  );
1074  }
1075 
1076  // ----------------------------------------------------------------------
1077  // Pre-message hooks for async commands
1078  //
1079  // Each of these functions is invoked just before processing the
1080  // corresponding command. By default they do nothing. You can
1081  // override them to provide specific pre-command behavior.
1082  // ----------------------------------------------------------------------
1083 
1086  FwOpcodeType opCode,
1087  U32 cmdSeq
1088  )
1089  {
1090  // Defaults to no-op; can be overridden
1091  (void) opCode;
1092  (void) cmdSeq;
1093  }
1094 
1097  FwOpcodeType opCode,
1098  U32 cmdSeq
1099  )
1100  {
1101  // Defaults to no-op; can be overridden
1102  (void) opCode;
1103  (void) cmdSeq;
1104  }
1105 
1108  FwOpcodeType opCode,
1109  U32 cmdSeq
1110  )
1111  {
1112  // Defaults to no-op; can be overridden
1113  (void) opCode;
1114  (void) cmdSeq;
1115  }
1116 
1117  // ----------------------------------------------------------------------
1118  // Event logging functions
1119  // ----------------------------------------------------------------------
1120 
1123  {
1124  // Check throttle value
1125  if (this->m_PrmIdNotFoundThrottle >= EVENTID_PRMIDNOTFOUND_THROTTLE) {
1126  return;
1127  }
1128  else {
1129  this->m_PrmIdNotFoundThrottle++;
1130  }
1131 
1132  // Get the time
1133  Fw::Time _logTime;
1134  if (this->m_Time_OutputPort[0].isConnected()) {
1135  this->m_Time_OutputPort[0].invoke(_logTime);
1136  }
1137 
1138  FwEventIdType _id = static_cast<FwEventIdType>(0);
1139 
1140  _id = this->getIdBase() + EVENTID_PRMIDNOTFOUND;
1141 
1142  // Emit the event on the log port
1143  if (this->m_Log_OutputPort[0].isConnected()) {
1144  Fw::LogBuffer _logBuff;
1146 
1147 #if FW_AMPCS_COMPATIBLE
1148  // Serialize the number of arguments
1149  _status = _logBuff.serializeFrom(static_cast<U8>(1));
1150  FW_ASSERT(
1151  _status == Fw::FW_SERIALIZE_OK,
1152  static_cast<FwAssertArgType>(_status)
1153  );
1154 #endif
1155 
1156 #if FW_AMPCS_COMPATIBLE
1157  // Serialize the argument size
1158  _status = _logBuff.serializeFrom(
1159  static_cast<U8>(sizeof(FwPrmIdType))
1160  );
1161  FW_ASSERT(
1162  _status == Fw::FW_SERIALIZE_OK,
1163  static_cast<FwAssertArgType>(_status)
1164  );
1165 #endif
1166  _status = _logBuff.serializeFrom(Id);
1167  FW_ASSERT(
1168  _status == Fw::FW_SERIALIZE_OK,
1169  static_cast<FwAssertArgType>(_status)
1170  );
1171 
1172  this->m_Log_OutputPort[0].invoke(
1173  _id,
1174  _logTime,
1176  _logBuff
1177  );
1178  }
1179 
1180  // Emit the event on the text log port
1181 #if FW_ENABLE_TEXT_LOGGING
1182  if (this->m_LogText_OutputPort[0].isConnected()) {
1183 #if FW_OBJECT_NAMES == 1
1184  const char* _formatString =
1185  "(%s) %s: Parameter ID 0x%" PRIx32 " not found";
1186 #else
1187  const char* _formatString =
1188  "%s: Parameter ID 0x%" PRIx32 " not found";
1189 #endif
1190 
1191  Fw::TextLogString _logString;
1192  _logString.format(
1193  _formatString,
1194 #if FW_OBJECT_NAMES == 1
1195  this->m_objName.toChar(),
1196 #endif
1197  "PrmIdNotFound ",
1198  Id
1199  );
1200 
1201  this->m_LogText_OutputPort[0].invoke(
1202  _id,
1203  _logTime,
1205  _logString
1206  );
1207  }
1208 #endif
1209  }
1210 
1213  {
1214  // Get the time
1215  Fw::Time _logTime;
1216  if (this->m_Time_OutputPort[0].isConnected()) {
1217  this->m_Time_OutputPort[0].invoke(_logTime);
1218  }
1219 
1220  FwEventIdType _id = static_cast<FwEventIdType>(0);
1221 
1222  _id = this->getIdBase() + EVENTID_PRMIDUPDATED;
1223 
1224  // Emit the event on the log port
1225  if (this->m_Log_OutputPort[0].isConnected()) {
1226  Fw::LogBuffer _logBuff;
1228 
1229 #if FW_AMPCS_COMPATIBLE
1230  // Serialize the number of arguments
1231  _status = _logBuff.serializeFrom(static_cast<U8>(1));
1232  FW_ASSERT(
1233  _status == Fw::FW_SERIALIZE_OK,
1234  static_cast<FwAssertArgType>(_status)
1235  );
1236 #endif
1237 
1238 #if FW_AMPCS_COMPATIBLE
1239  // Serialize the argument size
1240  _status = _logBuff.serializeFrom(
1241  static_cast<U8>(sizeof(FwPrmIdType))
1242  );
1243  FW_ASSERT(
1244  _status == Fw::FW_SERIALIZE_OK,
1245  static_cast<FwAssertArgType>(_status)
1246  );
1247 #endif
1248  _status = _logBuff.serializeFrom(Id);
1249  FW_ASSERT(
1250  _status == Fw::FW_SERIALIZE_OK,
1251  static_cast<FwAssertArgType>(_status)
1252  );
1253 
1254  this->m_Log_OutputPort[0].invoke(
1255  _id,
1256  _logTime,
1258  _logBuff
1259  );
1260  }
1261 
1262  // Emit the event on the text log port
1263 #if FW_ENABLE_TEXT_LOGGING
1264  if (this->m_LogText_OutputPort[0].isConnected()) {
1265 #if FW_OBJECT_NAMES == 1
1266  const char* _formatString =
1267  "(%s) %s: Parameter ID 0x%" PRIx32 " updated";
1268 #else
1269  const char* _formatString =
1270  "%s: Parameter ID 0x%" PRIx32 " updated";
1271 #endif
1272 
1273  Fw::TextLogString _logString;
1274  _logString.format(
1275  _formatString,
1276 #if FW_OBJECT_NAMES == 1
1277  this->m_objName.toChar(),
1278 #endif
1279  "PrmIdUpdated ",
1280  Id
1281  );
1282 
1283  this->m_LogText_OutputPort[0].invoke(
1284  _id,
1285  _logTime,
1287  _logString
1288  );
1289  }
1290 #endif
1291  }
1292 
1295  {
1296  // Get the time
1297  Fw::Time _logTime;
1298  if (this->m_Time_OutputPort[0].isConnected()) {
1299  this->m_Time_OutputPort[0].invoke(_logTime);
1300  }
1301 
1302  FwEventIdType _id = static_cast<FwEventIdType>(0);
1303 
1304  _id = this->getIdBase() + EVENTID_PRMDBFULL;
1305 
1306  // Emit the event on the log port
1307  if (this->m_Log_OutputPort[0].isConnected()) {
1308  Fw::LogBuffer _logBuff;
1310 
1311 #if FW_AMPCS_COMPATIBLE
1312  // Serialize the number of arguments
1313  _status = _logBuff.serializeFrom(static_cast<U8>(1));
1314  FW_ASSERT(
1315  _status == Fw::FW_SERIALIZE_OK,
1316  static_cast<FwAssertArgType>(_status)
1317  );
1318 #endif
1319 
1320 #if FW_AMPCS_COMPATIBLE
1321  // Serialize the argument size
1322  _status = _logBuff.serializeFrom(
1323  static_cast<U8>(sizeof(FwPrmIdType))
1324  );
1325  FW_ASSERT(
1326  _status == Fw::FW_SERIALIZE_OK,
1327  static_cast<FwAssertArgType>(_status)
1328  );
1329 #endif
1330  _status = _logBuff.serializeFrom(Id);
1331  FW_ASSERT(
1332  _status == Fw::FW_SERIALIZE_OK,
1333  static_cast<FwAssertArgType>(_status)
1334  );
1335 
1336  this->m_Log_OutputPort[0].invoke(
1337  _id,
1338  _logTime,
1340  _logBuff
1341  );
1342  }
1343 
1344  // Emit the event on the text log port
1345 #if FW_ENABLE_TEXT_LOGGING
1346  if (this->m_LogText_OutputPort[0].isConnected()) {
1347 #if FW_OBJECT_NAMES == 1
1348  const char* _formatString =
1349  "(%s) %s: Parameter DB full when adding ID 0x%" PRIx32 " ";
1350 #else
1351  const char* _formatString =
1352  "%s: Parameter DB full when adding ID 0x%" PRIx32 " ";
1353 #endif
1354 
1355  Fw::TextLogString _logString;
1356  _logString.format(
1357  _formatString,
1358 #if FW_OBJECT_NAMES == 1
1359  this->m_objName.toChar(),
1360 #endif
1361  "PrmDbFull ",
1362  Id
1363  );
1364 
1365  this->m_LogText_OutputPort[0].invoke(
1366  _id,
1367  _logTime,
1369  _logString
1370  );
1371  }
1372 #endif
1373  }
1374 
1377  {
1378  // Get the time
1379  Fw::Time _logTime;
1380  if (this->m_Time_OutputPort[0].isConnected()) {
1381  this->m_Time_OutputPort[0].invoke(_logTime);
1382  }
1383 
1384  FwEventIdType _id = static_cast<FwEventIdType>(0);
1385 
1386  _id = this->getIdBase() + EVENTID_PRMIDADDED;
1387 
1388  // Emit the event on the log port
1389  if (this->m_Log_OutputPort[0].isConnected()) {
1390  Fw::LogBuffer _logBuff;
1392 
1393 #if FW_AMPCS_COMPATIBLE
1394  // Serialize the number of arguments
1395  _status = _logBuff.serializeFrom(static_cast<U8>(1));
1396  FW_ASSERT(
1397  _status == Fw::FW_SERIALIZE_OK,
1398  static_cast<FwAssertArgType>(_status)
1399  );
1400 #endif
1401 
1402 #if FW_AMPCS_COMPATIBLE
1403  // Serialize the argument size
1404  _status = _logBuff.serializeFrom(
1405  static_cast<U8>(sizeof(FwPrmIdType))
1406  );
1407  FW_ASSERT(
1408  _status == Fw::FW_SERIALIZE_OK,
1409  static_cast<FwAssertArgType>(_status)
1410  );
1411 #endif
1412  _status = _logBuff.serializeFrom(Id);
1413  FW_ASSERT(
1414  _status == Fw::FW_SERIALIZE_OK,
1415  static_cast<FwAssertArgType>(_status)
1416  );
1417 
1418  this->m_Log_OutputPort[0].invoke(
1419  _id,
1420  _logTime,
1422  _logBuff
1423  );
1424  }
1425 
1426  // Emit the event on the text log port
1427 #if FW_ENABLE_TEXT_LOGGING
1428  if (this->m_LogText_OutputPort[0].isConnected()) {
1429 #if FW_OBJECT_NAMES == 1
1430  const char* _formatString =
1431  "(%s) %s: Parameter ID 0x%" PRIx32 " added";
1432 #else
1433  const char* _formatString =
1434  "%s: Parameter ID 0x%" PRIx32 " added";
1435 #endif
1436 
1437  Fw::TextLogString _logString;
1438  _logString.format(
1439  _formatString,
1440 #if FW_OBJECT_NAMES == 1
1441  this->m_objName.toChar(),
1442 #endif
1443  "PrmIdAdded ",
1444  Id
1445  );
1446 
1447  this->m_LogText_OutputPort[0].invoke(
1448  _id,
1449  _logTime,
1451  _logString
1452  );
1453  }
1454 #endif
1455  }
1456 
1460  I32 record,
1461  I32 error
1462  ) const
1463  {
1464  // Get the time
1465  Fw::Time _logTime;
1466  if (this->m_Time_OutputPort[0].isConnected()) {
1467  this->m_Time_OutputPort[0].invoke(_logTime);
1468  }
1469 
1470  FwEventIdType _id = static_cast<FwEventIdType>(0);
1471 
1472  _id = this->getIdBase() + EVENTID_PRMFILEWRITEERROR;
1473 
1474  // Emit the event on the log port
1475  if (this->m_Log_OutputPort[0].isConnected()) {
1476  Fw::LogBuffer _logBuff;
1478 
1479 #if FW_AMPCS_COMPATIBLE
1480  // Serialize the number of arguments
1481  _status = _logBuff.serializeFrom(static_cast<U8>(3));
1482  FW_ASSERT(
1483  _status == Fw::FW_SERIALIZE_OK,
1484  static_cast<FwAssertArgType>(_status)
1485  );
1486 #endif
1487 
1488 #if FW_AMPCS_COMPATIBLE
1489  // Serialize the argument size
1490  _status = _logBuff.serializeFrom(
1492  );
1493  FW_ASSERT(
1494  _status == Fw::FW_SERIALIZE_OK,
1495  static_cast<FwAssertArgType>(_status)
1496  );
1497 #endif
1498  _status = _logBuff.serializeFrom(stage);
1499  FW_ASSERT(
1500  _status == Fw::FW_SERIALIZE_OK,
1501  static_cast<FwAssertArgType>(_status)
1502  );
1503 
1504 #if FW_AMPCS_COMPATIBLE
1505  // Serialize the argument size
1506  _status = _logBuff.serializeFrom(
1507  static_cast<U8>(sizeof(I32))
1508  );
1509  FW_ASSERT(
1510  _status == Fw::FW_SERIALIZE_OK,
1511  static_cast<FwAssertArgType>(_status)
1512  );
1513 #endif
1514  _status = _logBuff.serializeFrom(record);
1515  FW_ASSERT(
1516  _status == Fw::FW_SERIALIZE_OK,
1517  static_cast<FwAssertArgType>(_status)
1518  );
1519 
1520 #if FW_AMPCS_COMPATIBLE
1521  // Serialize the argument size
1522  _status = _logBuff.serializeFrom(
1523  static_cast<U8>(sizeof(I32))
1524  );
1525  FW_ASSERT(
1526  _status == Fw::FW_SERIALIZE_OK,
1527  static_cast<FwAssertArgType>(_status)
1528  );
1529 #endif
1530  _status = _logBuff.serializeFrom(error);
1531  FW_ASSERT(
1532  _status == Fw::FW_SERIALIZE_OK,
1533  static_cast<FwAssertArgType>(_status)
1534  );
1535 
1536  this->m_Log_OutputPort[0].invoke(
1537  _id,
1538  _logTime,
1540  _logBuff
1541  );
1542  }
1543 
1544  // Emit the event on the text log port
1545 #if FW_ENABLE_TEXT_LOGGING
1546  if (this->m_LogText_OutputPort[0].isConnected()) {
1547 #if FW_OBJECT_NAMES == 1
1548  const char* _formatString =
1549  "(%s) %s: Parameter write failed in stage %s with record %" PRIi32 " and error %" PRIi32 "";
1550 #else
1551  const char* _formatString =
1552  "%s: Parameter write failed in stage %s with record %" PRIi32 " and error %" PRIi32 "";
1553 #endif
1554 
1555  Fw::String stageStr;
1556  stage.toString(stageStr);
1557 
1558  Fw::TextLogString _logString;
1559  _logString.format(
1560  _formatString,
1561 #if FW_OBJECT_NAMES == 1
1562  this->m_objName.toChar(),
1563 #endif
1564  "PrmFileWriteError ",
1565  stageStr.toChar(),
1566  record,
1567  error
1568  );
1569 
1570  this->m_LogText_OutputPort[0].invoke(
1571  _id,
1572  _logTime,
1574  _logString
1575  );
1576  }
1577 #endif
1578  }
1579 
1582  {
1583  // Get the time
1584  Fw::Time _logTime;
1585  if (this->m_Time_OutputPort[0].isConnected()) {
1586  this->m_Time_OutputPort[0].invoke(_logTime);
1587  }
1588 
1589  FwEventIdType _id = static_cast<FwEventIdType>(0);
1590 
1591  _id = this->getIdBase() + EVENTID_PRMFILESAVECOMPLETE;
1592 
1593  // Emit the event on the log port
1594  if (this->m_Log_OutputPort[0].isConnected()) {
1595  Fw::LogBuffer _logBuff;
1597 
1598 #if FW_AMPCS_COMPATIBLE
1599  // Serialize the number of arguments
1600  _status = _logBuff.serializeFrom(static_cast<U8>(1));
1601  FW_ASSERT(
1602  _status == Fw::FW_SERIALIZE_OK,
1603  static_cast<FwAssertArgType>(_status)
1604  );
1605 #endif
1606 
1607 #if FW_AMPCS_COMPATIBLE
1608  // Serialize the argument size
1609  _status = _logBuff.serializeFrom(
1610  static_cast<U8>(sizeof(U32))
1611  );
1612  FW_ASSERT(
1613  _status == Fw::FW_SERIALIZE_OK,
1614  static_cast<FwAssertArgType>(_status)
1615  );
1616 #endif
1617  _status = _logBuff.serializeFrom(records);
1618  FW_ASSERT(
1619  _status == Fw::FW_SERIALIZE_OK,
1620  static_cast<FwAssertArgType>(_status)
1621  );
1622 
1623  this->m_Log_OutputPort[0].invoke(
1624  _id,
1625  _logTime,
1627  _logBuff
1628  );
1629  }
1630 
1631  // Emit the event on the text log port
1632 #if FW_ENABLE_TEXT_LOGGING
1633  if (this->m_LogText_OutputPort[0].isConnected()) {
1634 #if FW_OBJECT_NAMES == 1
1635  const char* _formatString =
1636  "(%s) %s: Parameter file save completed. Wrote %" PRIu32 " records.";
1637 #else
1638  const char* _formatString =
1639  "%s: Parameter file save completed. Wrote %" PRIu32 " records.";
1640 #endif
1641 
1642  Fw::TextLogString _logString;
1643  _logString.format(
1644  _formatString,
1645 #if FW_OBJECT_NAMES == 1
1646  this->m_objName.toChar(),
1647 #endif
1648  "PrmFileSaveComplete ",
1649  records
1650  );
1651 
1652  this->m_LogText_OutputPort[0].invoke(
1653  _id,
1654  _logTime,
1656  _logString
1657  );
1658  }
1659 #endif
1660  }
1661 
1665  I32 record,
1666  I32 error
1667  ) const
1668  {
1669  // Get the time
1670  Fw::Time _logTime;
1671  if (this->m_Time_OutputPort[0].isConnected()) {
1672  this->m_Time_OutputPort[0].invoke(_logTime);
1673  }
1674 
1675  FwEventIdType _id = static_cast<FwEventIdType>(0);
1676 
1677  _id = this->getIdBase() + EVENTID_PRMFILEREADERROR;
1678 
1679  // Emit the event on the log port
1680  if (this->m_Log_OutputPort[0].isConnected()) {
1681  Fw::LogBuffer _logBuff;
1683 
1684 #if FW_AMPCS_COMPATIBLE
1685  // Serialize the number of arguments
1686  _status = _logBuff.serializeFrom(static_cast<U8>(3));
1687  FW_ASSERT(
1688  _status == Fw::FW_SERIALIZE_OK,
1689  static_cast<FwAssertArgType>(_status)
1690  );
1691 #endif
1692 
1693 #if FW_AMPCS_COMPATIBLE
1694  // Serialize the argument size
1695  _status = _logBuff.serializeFrom(
1697  );
1698  FW_ASSERT(
1699  _status == Fw::FW_SERIALIZE_OK,
1700  static_cast<FwAssertArgType>(_status)
1701  );
1702 #endif
1703  _status = _logBuff.serializeFrom(stage);
1704  FW_ASSERT(
1705  _status == Fw::FW_SERIALIZE_OK,
1706  static_cast<FwAssertArgType>(_status)
1707  );
1708 
1709 #if FW_AMPCS_COMPATIBLE
1710  // Serialize the argument size
1711  _status = _logBuff.serializeFrom(
1712  static_cast<U8>(sizeof(I32))
1713  );
1714  FW_ASSERT(
1715  _status == Fw::FW_SERIALIZE_OK,
1716  static_cast<FwAssertArgType>(_status)
1717  );
1718 #endif
1719  _status = _logBuff.serializeFrom(record);
1720  FW_ASSERT(
1721  _status == Fw::FW_SERIALIZE_OK,
1722  static_cast<FwAssertArgType>(_status)
1723  );
1724 
1725 #if FW_AMPCS_COMPATIBLE
1726  // Serialize the argument size
1727  _status = _logBuff.serializeFrom(
1728  static_cast<U8>(sizeof(I32))
1729  );
1730  FW_ASSERT(
1731  _status == Fw::FW_SERIALIZE_OK,
1732  static_cast<FwAssertArgType>(_status)
1733  );
1734 #endif
1735  _status = _logBuff.serializeFrom(error);
1736  FW_ASSERT(
1737  _status == Fw::FW_SERIALIZE_OK,
1738  static_cast<FwAssertArgType>(_status)
1739  );
1740 
1741  this->m_Log_OutputPort[0].invoke(
1742  _id,
1743  _logTime,
1745  _logBuff
1746  );
1747  }
1748 
1749  // Emit the event on the text log port
1750 #if FW_ENABLE_TEXT_LOGGING
1751  if (this->m_LogText_OutputPort[0].isConnected()) {
1752 #if FW_OBJECT_NAMES == 1
1753  const char* _formatString =
1754  "(%s) %s: Parameter file read failed in stage %s with record %" PRIi32 " and error %" PRIi32 "";
1755 #else
1756  const char* _formatString =
1757  "%s: Parameter file read failed in stage %s with record %" PRIi32 " and error %" PRIi32 "";
1758 #endif
1759 
1760  Fw::String stageStr;
1761  stage.toString(stageStr);
1762 
1763  Fw::TextLogString _logString;
1764  _logString.format(
1765  _formatString,
1766 #if FW_OBJECT_NAMES == 1
1767  this->m_objName.toChar(),
1768 #endif
1769  "PrmFileReadError ",
1770  stageStr.toChar(),
1771  record,
1772  error
1773  );
1774 
1775  this->m_LogText_OutputPort[0].invoke(
1776  _id,
1777  _logTime,
1779  _logString
1780  );
1781  }
1782 #endif
1783  }
1784 
1787  const Fw::StringBase& databaseString,
1788  U32 recordsTotal,
1789  U32 recordsAdded,
1790  U32 recordsUpdated
1791  ) const
1792  {
1793  // Get the time
1794  Fw::Time _logTime;
1795  if (this->m_Time_OutputPort[0].isConnected()) {
1796  this->m_Time_OutputPort[0].invoke(_logTime);
1797  }
1798 
1799  FwEventIdType _id = static_cast<FwEventIdType>(0);
1800 
1801  _id = this->getIdBase() + EVENTID_PRMFILELOADCOMPLETE;
1802 
1803  // Emit the event on the log port
1804  if (this->m_Log_OutputPort[0].isConnected()) {
1805  Fw::LogBuffer _logBuff;
1807 
1808 #if FW_AMPCS_COMPATIBLE
1809  // Serialize the number of arguments
1810  _status = _logBuff.serializeFrom(static_cast<U8>(4));
1811  FW_ASSERT(
1812  _status == Fw::FW_SERIALIZE_OK,
1813  static_cast<FwAssertArgType>(_status)
1814  );
1815 #endif
1816 
1817  _status = databaseString.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
1818  FW_ASSERT(
1819  _status == Fw::FW_SERIALIZE_OK,
1820  static_cast<FwAssertArgType>(_status)
1821  );
1822 
1823 #if FW_AMPCS_COMPATIBLE
1824  // Serialize the argument size
1825  _status = _logBuff.serializeFrom(
1826  static_cast<U8>(sizeof(U32))
1827  );
1828  FW_ASSERT(
1829  _status == Fw::FW_SERIALIZE_OK,
1830  static_cast<FwAssertArgType>(_status)
1831  );
1832 #endif
1833  _status = _logBuff.serializeFrom(recordsTotal);
1834  FW_ASSERT(
1835  _status == Fw::FW_SERIALIZE_OK,
1836  static_cast<FwAssertArgType>(_status)
1837  );
1838 
1839 #if FW_AMPCS_COMPATIBLE
1840  // Serialize the argument size
1841  _status = _logBuff.serializeFrom(
1842  static_cast<U8>(sizeof(U32))
1843  );
1844  FW_ASSERT(
1845  _status == Fw::FW_SERIALIZE_OK,
1846  static_cast<FwAssertArgType>(_status)
1847  );
1848 #endif
1849  _status = _logBuff.serializeFrom(recordsAdded);
1850  FW_ASSERT(
1851  _status == Fw::FW_SERIALIZE_OK,
1852  static_cast<FwAssertArgType>(_status)
1853  );
1854 
1855 #if FW_AMPCS_COMPATIBLE
1856  // Serialize the argument size
1857  _status = _logBuff.serializeFrom(
1858  static_cast<U8>(sizeof(U32))
1859  );
1860  FW_ASSERT(
1861  _status == Fw::FW_SERIALIZE_OK,
1862  static_cast<FwAssertArgType>(_status)
1863  );
1864 #endif
1865  _status = _logBuff.serializeFrom(recordsUpdated);
1866  FW_ASSERT(
1867  _status == Fw::FW_SERIALIZE_OK,
1868  static_cast<FwAssertArgType>(_status)
1869  );
1870 
1871  this->m_Log_OutputPort[0].invoke(
1872  _id,
1873  _logTime,
1875  _logBuff
1876  );
1877  }
1878 
1879  // Emit the event on the text log port
1880 #if FW_ENABLE_TEXT_LOGGING
1881  if (this->m_LogText_OutputPort[0].isConnected()) {
1882 #if FW_OBJECT_NAMES == 1
1883  const char* _formatString =
1884  "(%s) %s: Parameter file load completed. Database: %s, Records: %" PRIu32 " (%" PRIu32 " added and %" PRIu32 " updated).";
1885 #else
1886  const char* _formatString =
1887  "%s: Parameter file load completed. Database: %s, Records: %" PRIu32 " (%" PRIu32 " added and %" PRIu32 " updated).";
1888 #endif
1889 
1890  Fw::TextLogString _logString;
1891  _logString.format(
1892  _formatString,
1893 #if FW_OBJECT_NAMES == 1
1894  this->m_objName.toChar(),
1895 #endif
1896  "PrmFileLoadComplete ",
1897  databaseString.toChar(),
1898  recordsTotal,
1899  recordsAdded,
1900  recordsUpdated
1901  );
1902 
1903  this->m_LogText_OutputPort[0].invoke(
1904  _id,
1905  _logTime,
1907  _logString
1908  );
1909  }
1910 #endif
1911  }
1912 
1915  {
1916  // Get the time
1917  Fw::Time _logTime;
1918  if (this->m_Time_OutputPort[0].isConnected()) {
1919  this->m_Time_OutputPort[0].invoke(_logTime);
1920  }
1921 
1922  FwEventIdType _id = static_cast<FwEventIdType>(0);
1923 
1924  _id = this->getIdBase() + EVENTID_PRMDBCOMMITCOMPLETE;
1925 
1926  // Emit the event on the log port
1927  if (this->m_Log_OutputPort[0].isConnected()) {
1928  Fw::LogBuffer _logBuff;
1929 
1930 #if FW_AMPCS_COMPATIBLE
1932  // Serialize the number of arguments
1933  _status = _logBuff.serializeFrom(static_cast<U8>(0));
1934  FW_ASSERT(
1935  _status == Fw::FW_SERIALIZE_OK,
1936  static_cast<FwAssertArgType>(_status)
1937  );
1938 #endif
1939 
1940  this->m_Log_OutputPort[0].invoke(
1941  _id,
1942  _logTime,
1944  _logBuff
1945  );
1946  }
1947 
1948  // Emit the event on the text log port
1949 #if FW_ENABLE_TEXT_LOGGING
1950  if (this->m_LogText_OutputPort[0].isConnected()) {
1951 #if FW_OBJECT_NAMES == 1
1952  const char* _formatString =
1953  "(%s) %s: Parameter DB commit complete, staged updates are now active.";
1954 #else
1955  const char* _formatString =
1956  "%s: Parameter DB commit complete, staged updates are now active.";
1957 #endif
1958 
1959  Fw::TextLogString _logString;
1960  _logString.format(
1961  _formatString,
1962 #if FW_OBJECT_NAMES == 1
1963  this->m_objName.toChar(),
1964 #endif
1965  "PrmDbCommitComplete "
1966  );
1967 
1968  this->m_LogText_OutputPort[0].invoke(
1969  _id,
1970  _logTime,
1972  _logString
1973  );
1974  }
1975 #endif
1976  }
1977 
1980  const Fw::StringBase& databaseStringSrc,
1981  const Fw::StringBase& databaseStringDest
1982  ) const
1983  {
1984  // Get the time
1985  Fw::Time _logTime;
1986  if (this->m_Time_OutputPort[0].isConnected()) {
1987  this->m_Time_OutputPort[0].invoke(_logTime);
1988  }
1989 
1990  FwEventIdType _id = static_cast<FwEventIdType>(0);
1991 
1992  _id = this->getIdBase() + EVENTID_PRMDBCOPYALLCOMPLETE;
1993 
1994  // Emit the event on the log port
1995  if (this->m_Log_OutputPort[0].isConnected()) {
1996  Fw::LogBuffer _logBuff;
1998 
1999 #if FW_AMPCS_COMPATIBLE
2000  // Serialize the number of arguments
2001  _status = _logBuff.serializeFrom(static_cast<U8>(2));
2002  FW_ASSERT(
2003  _status == Fw::FW_SERIALIZE_OK,
2004  static_cast<FwAssertArgType>(_status)
2005  );
2006 #endif
2007 
2008  _status = databaseStringSrc.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
2009  FW_ASSERT(
2010  _status == Fw::FW_SERIALIZE_OK,
2011  static_cast<FwAssertArgType>(_status)
2012  );
2013 
2014  _status = databaseStringDest.serializeTo(_logBuff, FW_MIN(FW_LOG_STRING_MAX_SIZE, 80));
2015  FW_ASSERT(
2016  _status == Fw::FW_SERIALIZE_OK,
2017  static_cast<FwAssertArgType>(_status)
2018  );
2019 
2020  this->m_Log_OutputPort[0].invoke(
2021  _id,
2022  _logTime,
2024  _logBuff
2025  );
2026  }
2027 
2028  // Emit the event on the text log port
2029 #if FW_ENABLE_TEXT_LOGGING
2030  if (this->m_LogText_OutputPort[0].isConnected()) {
2031 #if FW_OBJECT_NAMES == 1
2032  const char* _formatString =
2033  "(%s) %s: All parameters copied. Source database: %s, Destination database: %s.";
2034 #else
2035  const char* _formatString =
2036  "%s: All parameters copied. Source database: %s, Destination database: %s.";
2037 #endif
2038 
2039  Fw::TextLogString _logString;
2040  _logString.format(
2041  _formatString,
2042 #if FW_OBJECT_NAMES == 1
2043  this->m_objName.toChar(),
2044 #endif
2045  "PrmDbCopyAllComplete ",
2046  databaseStringSrc.toChar(),
2047  databaseStringDest.toChar()
2048  );
2049 
2050  this->m_LogText_OutputPort[0].invoke(
2051  _id,
2052  _logTime,
2054  _logString
2055  );
2056  }
2057 #endif
2058  }
2059 
2062  {
2063  // Get the time
2064  Fw::Time _logTime;
2065  if (this->m_Time_OutputPort[0].isConnected()) {
2066  this->m_Time_OutputPort[0].invoke(_logTime);
2067  }
2068 
2069  FwEventIdType _id = static_cast<FwEventIdType>(0);
2070 
2071  _id = this->getIdBase() + EVENTID_PRMDBFILELOADFAILED;
2072 
2073  // Emit the event on the log port
2074  if (this->m_Log_OutputPort[0].isConnected()) {
2075  Fw::LogBuffer _logBuff;
2076 
2077 #if FW_AMPCS_COMPATIBLE
2079  // Serialize the number of arguments
2080  _status = _logBuff.serializeFrom(static_cast<U8>(0));
2081  FW_ASSERT(
2082  _status == Fw::FW_SERIALIZE_OK,
2083  static_cast<FwAssertArgType>(_status)
2084  );
2085 #endif
2086 
2087  this->m_Log_OutputPort[0].invoke(
2088  _id,
2089  _logTime,
2091  _logBuff
2092  );
2093  }
2094 
2095  // Emit the event on the text log port
2096 #if FW_ENABLE_TEXT_LOGGING
2097  if (this->m_LogText_OutputPort[0].isConnected()) {
2098 #if FW_OBJECT_NAMES == 1
2099  const char* _formatString =
2100  "(%s) %s: Parameter file load failed. Clearing staging database and abandoning parameter file load.";
2101 #else
2102  const char* _formatString =
2103  "%s: Parameter file load failed. Clearing staging database and abandoning parameter file load.";
2104 #endif
2105 
2106  Fw::TextLogString _logString;
2107  _logString.format(
2108  _formatString,
2109 #if FW_OBJECT_NAMES == 1
2110  this->m_objName.toChar(),
2111 #endif
2112  "PrmDbFileLoadFailed "
2113  );
2114 
2115  this->m_LogText_OutputPort[0].invoke(
2116  _id,
2117  _logTime,
2119  _logString
2120  );
2121  }
2122 #endif
2123  }
2124 
2127  Svc::PrmDb_PrmDbFileLoadState currentState,
2128  Svc::PrmDb_PrmLoadAction attemptedAction
2129  ) const
2130  {
2131  // Get the time
2132  Fw::Time _logTime;
2133  if (this->m_Time_OutputPort[0].isConnected()) {
2134  this->m_Time_OutputPort[0].invoke(_logTime);
2135  }
2136 
2137  FwEventIdType _id = static_cast<FwEventIdType>(0);
2138 
2140 
2141  // Emit the event on the log port
2142  if (this->m_Log_OutputPort[0].isConnected()) {
2143  Fw::LogBuffer _logBuff;
2145 
2146 #if FW_AMPCS_COMPATIBLE
2147  // Serialize the number of arguments
2148  _status = _logBuff.serializeFrom(static_cast<U8>(2));
2149  FW_ASSERT(
2150  _status == Fw::FW_SERIALIZE_OK,
2151  static_cast<FwAssertArgType>(_status)
2152  );
2153 #endif
2154 
2155 #if FW_AMPCS_COMPATIBLE
2156  // Serialize the argument size
2157  _status = _logBuff.serializeFrom(
2159  );
2160  FW_ASSERT(
2161  _status == Fw::FW_SERIALIZE_OK,
2162  static_cast<FwAssertArgType>(_status)
2163  );
2164 #endif
2165  _status = _logBuff.serializeFrom(currentState);
2166  FW_ASSERT(
2167  _status == Fw::FW_SERIALIZE_OK,
2168  static_cast<FwAssertArgType>(_status)
2169  );
2170 
2171 #if FW_AMPCS_COMPATIBLE
2172  // Serialize the argument size
2173  _status = _logBuff.serializeFrom(
2175  );
2176  FW_ASSERT(
2177  _status == Fw::FW_SERIALIZE_OK,
2178  static_cast<FwAssertArgType>(_status)
2179  );
2180 #endif
2181  _status = _logBuff.serializeFrom(attemptedAction);
2182  FW_ASSERT(
2183  _status == Fw::FW_SERIALIZE_OK,
2184  static_cast<FwAssertArgType>(_status)
2185  );
2186 
2187  this->m_Log_OutputPort[0].invoke(
2188  _id,
2189  _logTime,
2191  _logBuff
2192  );
2193  }
2194 
2195  // Emit the event on the text log port
2196 #if FW_ENABLE_TEXT_LOGGING
2197  if (this->m_LogText_OutputPort[0].isConnected()) {
2198 #if FW_OBJECT_NAMES == 1
2199  const char* _formatString =
2200  "(%s) %s: Invalid action during parameter file load. Current state: %s, Action (Invalid for current state): %s.";
2201 #else
2202  const char* _formatString =
2203  "%s: Invalid action during parameter file load. Current state: %s, Action (Invalid for current state): %s.";
2204 #endif
2205 
2206  Fw::String currentStateStr;
2207  currentState.toString(currentStateStr);
2208  Fw::String attemptedActionStr;
2209  attemptedAction.toString(attemptedActionStr);
2210 
2211  Fw::TextLogString _logString;
2212  _logString.format(
2213  _formatString,
2214 #if FW_OBJECT_NAMES == 1
2215  this->m_objName.toChar(),
2216 #endif
2217  "PrmDbFileLoadInvalidAction ",
2218  currentStateStr.toChar(),
2219  attemptedActionStr.toChar()
2220  );
2221 
2222  this->m_LogText_OutputPort[0].invoke(
2223  _id,
2224  _logTime,
2226  _logString
2227  );
2228  }
2229 #endif
2230  }
2231 
2232  // ----------------------------------------------------------------------
2233  // Event throttle reset functions
2234  // ----------------------------------------------------------------------
2235 
2238  {
2239  // Reset throttle counter
2240  this->m_PrmIdNotFoundThrottle = 0;
2241  }
2242 
2243  // ----------------------------------------------------------------------
2244  // Time
2245  // ----------------------------------------------------------------------
2246 
2248  getTime() const
2249  {
2250  if (this->m_Time_OutputPort[0].isConnected()) {
2251  Fw::Time _time;
2252  this->m_Time_OutputPort[0].invoke(_time);
2253  return _time;
2254  }
2255  else {
2256  return Fw::Time(TimeBase::TB_NONE, 0, 0);
2257  }
2258  }
2259 
2260  // ----------------------------------------------------------------------
2261  // Mutex operations for guarded ports
2262  //
2263  // You can override these operations to provide more sophisticated
2264  // synchronization
2265  // ----------------------------------------------------------------------
2266 
2269  {
2270  this->m_guardedPortMutex.lock();
2271  }
2272 
2275  {
2276  this->m_guardedPortMutex.unLock();
2277  }
2278 
2279  // ----------------------------------------------------------------------
2280  // Message dispatch functions
2281  // ----------------------------------------------------------------------
2282 
2283  Fw::QueuedComponentBase::MsgDispatchStatus PrmDbComponentBase ::
2284  doDispatch()
2285  {
2286  ComponentIpcSerializableBuffer _msg;
2287  FwQueuePriorityType _priority = 0;
2288 
2289  Os::Queue::Status _msgStatus = this->m_queue.receive(
2290  _msg,
2292  _priority
2293  );
2294  FW_ASSERT(
2295  _msgStatus == Os::Queue::OP_OK,
2296  static_cast<FwAssertArgType>(_msgStatus)
2297  );
2298 
2299  // Reset to beginning of buffer
2300  _msg.resetDeser();
2301 
2302  FwEnumStoreType _desMsg = 0;
2303  Fw::SerializeStatus _deserStatus = _msg.deserializeTo(_desMsg);
2304  FW_ASSERT(
2305  _deserStatus == Fw::FW_SERIALIZE_OK,
2306  static_cast<FwAssertArgType>(_deserStatus)
2307  );
2308 
2309  MsgTypeEnum _msgType = static_cast<MsgTypeEnum>(_desMsg);
2310 
2311  if (_msgType == PRMDB_COMPONENT_EXIT) {
2312  return MSG_DISPATCH_EXIT;
2313  }
2314 
2315  FwIndexType portNum = 0;
2316  _deserStatus = _msg.deserializeTo(portNum);
2317  FW_ASSERT(
2318  _deserStatus == Fw::FW_SERIALIZE_OK,
2319  static_cast<FwAssertArgType>(_deserStatus)
2320  );
2321 
2322  switch (_msgType) {
2323  // Handle async input port pingIn
2324  case PINGIN_PING: {
2325  // Deserialize argument key
2326  U32 key;
2327  _deserStatus = _msg.deserializeTo(key);
2328  FW_ASSERT(
2329  _deserStatus == Fw::FW_SERIALIZE_OK,
2330  static_cast<FwAssertArgType>(_deserStatus)
2331  );
2332  // Call handler function
2333  this->pingIn_handler(
2334  portNum,
2335  key
2336  );
2337 
2338  break;
2339  }
2340 
2341  // Handle async input port setPrm
2342  case SETPRM_PRMSET: {
2343  // Deserialize argument id
2344  FwPrmIdType id;
2345  _deserStatus = _msg.deserializeTo(id);
2346  FW_ASSERT(
2347  _deserStatus == Fw::FW_SERIALIZE_OK,
2348  static_cast<FwAssertArgType>(_deserStatus)
2349  );
2350 
2351  // Deserialize argument val
2352  Fw::ParamBuffer val;
2353  _deserStatus = _msg.deserializeTo(val);
2354  FW_ASSERT(
2355  _deserStatus == Fw::FW_SERIALIZE_OK,
2356  static_cast<FwAssertArgType>(_deserStatus)
2357  );
2358  // Call handler function
2359  this->setPrm_handler(
2360  portNum,
2361  id,
2362  val
2363  );
2364 
2365  break;
2366  }
2367 
2368  // Handle command PRM_SAVE_FILE
2369  case CMD_PRM_SAVE_FILE: {
2370  // Deserialize opcode
2371  FwOpcodeType _opCode = 0;
2372  _deserStatus = _msg.deserializeTo(_opCode);
2373  FW_ASSERT (
2374  _deserStatus == Fw::FW_SERIALIZE_OK,
2375  static_cast<FwAssertArgType>(_deserStatus)
2376  );
2377 
2378  // Deserialize command sequence
2379  U32 _cmdSeq = 0;
2380  _deserStatus = _msg.deserializeTo(_cmdSeq);
2381  FW_ASSERT (
2382  _deserStatus == Fw::FW_SERIALIZE_OK,
2383  static_cast<FwAssertArgType>(_deserStatus)
2384  );
2385 
2386  // Deserialize command argument buffer
2387  Fw::CmdArgBuffer args;
2388  _deserStatus = _msg.deserializeTo(args);
2389  FW_ASSERT (
2390  _deserStatus == Fw::FW_SERIALIZE_OK,
2391  static_cast<FwAssertArgType>(_deserStatus)
2392  );
2393 
2394  // Reset buffer
2395  args.resetDeser();
2396 
2397  // Make sure there was no data left over.
2398  // That means the argument buffer size was incorrect.
2399 #if FW_CMD_CHECK_RESIDUAL
2400  if (args.getDeserializeSizeLeft() != 0) {
2401  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2402  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2403  }
2404  // Don't crash the task if bad arguments were passed from the ground
2405  break;
2406  }
2407 #endif
2408 
2409  // Call handler function
2410  this->PRM_SAVE_FILE_cmdHandler(_opCode, _cmdSeq);
2411 
2412  break;
2413  }
2414 
2415  // Handle command PRM_LOAD_FILE
2416  case CMD_PRM_LOAD_FILE: {
2417  // Deserialize opcode
2418  FwOpcodeType _opCode = 0;
2419  _deserStatus = _msg.deserializeTo(_opCode);
2420  FW_ASSERT (
2421  _deserStatus == Fw::FW_SERIALIZE_OK,
2422  static_cast<FwAssertArgType>(_deserStatus)
2423  );
2424 
2425  // Deserialize command sequence
2426  U32 _cmdSeq = 0;
2427  _deserStatus = _msg.deserializeTo(_cmdSeq);
2428  FW_ASSERT (
2429  _deserStatus == Fw::FW_SERIALIZE_OK,
2430  static_cast<FwAssertArgType>(_deserStatus)
2431  );
2432 
2433  // Deserialize command argument buffer
2434  Fw::CmdArgBuffer args;
2435  _deserStatus = _msg.deserializeTo(args);
2436  FW_ASSERT (
2437  _deserStatus == Fw::FW_SERIALIZE_OK,
2438  static_cast<FwAssertArgType>(_deserStatus)
2439  );
2440 
2441  // Reset buffer
2442  args.resetDeser();
2443 
2444  // Deserialize argument fileName
2445  Fw::CmdStringArg fileName;
2446  _deserStatus = args.deserializeTo(fileName);
2447  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2448  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2449  this->cmdResponse_out(
2450  _opCode,
2451  _cmdSeq,
2453  );
2454  }
2455  // Don't crash the task if bad arguments were passed from the ground
2456  break;
2457  }
2458 
2459  // Deserialize argument merge
2460  Svc::PrmDb_Merge merge;
2461  _deserStatus = args.deserializeTo(merge);
2462  if (_deserStatus != Fw::FW_SERIALIZE_OK) {
2463  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2464  this->cmdResponse_out(
2465  _opCode,
2466  _cmdSeq,
2468  );
2469  }
2470  // Don't crash the task if bad arguments were passed from the ground
2471  break;
2472  }
2473 
2474  // Make sure there was no data left over.
2475  // That means the argument buffer size was incorrect.
2476 #if FW_CMD_CHECK_RESIDUAL
2477  if (args.getDeserializeSizeLeft() != 0) {
2478  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2479  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2480  }
2481  // Don't crash the task if bad arguments were passed from the ground
2482  break;
2483  }
2484 #endif
2485 
2486  // Call handler function
2488  _opCode, _cmdSeq,
2489  fileName,
2490  merge
2491  );
2492 
2493  break;
2494  }
2495 
2496  // Handle command PRM_COMMIT_STAGED
2497  case CMD_PRM_COMMIT_STAGED: {
2498  // Deserialize opcode
2499  FwOpcodeType _opCode = 0;
2500  _deserStatus = _msg.deserializeTo(_opCode);
2501  FW_ASSERT (
2502  _deserStatus == Fw::FW_SERIALIZE_OK,
2503  static_cast<FwAssertArgType>(_deserStatus)
2504  );
2505 
2506  // Deserialize command sequence
2507  U32 _cmdSeq = 0;
2508  _deserStatus = _msg.deserializeTo(_cmdSeq);
2509  FW_ASSERT (
2510  _deserStatus == Fw::FW_SERIALIZE_OK,
2511  static_cast<FwAssertArgType>(_deserStatus)
2512  );
2513 
2514  // Deserialize command argument buffer
2515  Fw::CmdArgBuffer args;
2516  _deserStatus = _msg.deserializeTo(args);
2517  FW_ASSERT (
2518  _deserStatus == Fw::FW_SERIALIZE_OK,
2519  static_cast<FwAssertArgType>(_deserStatus)
2520  );
2521 
2522  // Reset buffer
2523  args.resetDeser();
2524 
2525  // Make sure there was no data left over.
2526  // That means the argument buffer size was incorrect.
2527 #if FW_CMD_CHECK_RESIDUAL
2528  if (args.getDeserializeSizeLeft() != 0) {
2529  if (this->m_CmdStatus_OutputPort[0].isConnected()) {
2530  this->cmdResponse_out(_opCode, _cmdSeq, Fw::CmdResponse::FORMAT_ERROR);
2531  }
2532  // Don't crash the task if bad arguments were passed from the ground
2533  break;
2534  }
2535 #endif
2536 
2537  // Call handler function
2538  this->PRM_COMMIT_STAGED_cmdHandler(_opCode, _cmdSeq);
2539 
2540  break;
2541  }
2542 
2543  default:
2544  return MSG_DISPATCH_ERROR;
2545  }
2546 
2547  return MSG_DISPATCH_OK;
2548  }
2549 
2550  // ----------------------------------------------------------------------
2551  // Calls for messages received on special input ports
2552  // ----------------------------------------------------------------------
2553 
2554  void PrmDbComponentBase ::
2555  m_p_CmdDisp_in(
2556  Fw::PassiveComponentBase* callComp,
2557  FwIndexType portNum,
2558  FwOpcodeType opCode,
2559  U32 cmdSeq,
2560  Fw::CmdArgBuffer& args
2561  )
2562  {
2563  FW_ASSERT(callComp);
2564  PrmDbComponentBase* compPtr = static_cast<PrmDbComponentBase*>(callComp);
2565 
2566  const U32 idBase = callComp->getIdBase();
2567  FW_ASSERT(opCode >= idBase, static_cast<FwAssertArgType>(opCode), static_cast<FwAssertArgType>(idBase));
2568 
2569  // Select base class function based on opcode
2570  switch (opCode - idBase) {
2571  case OPCODE_PRM_SAVE_FILE: {
2572  compPtr->PRM_SAVE_FILE_cmdHandlerBase(
2573  opCode,
2574  cmdSeq,
2575  args
2576  );
2577  break;
2578  }
2579 
2580  case OPCODE_PRM_LOAD_FILE: {
2581  compPtr->PRM_LOAD_FILE_cmdHandlerBase(
2582  opCode,
2583  cmdSeq,
2584  args
2585  );
2586  break;
2587  }
2588 
2589  case OPCODE_PRM_COMMIT_STAGED: {
2590  compPtr->PRM_COMMIT_STAGED_cmdHandlerBase(
2591  opCode,
2592  cmdSeq,
2593  args
2594  );
2595  break;
2596  }
2597  }
2598  }
2599 
2600  // ----------------------------------------------------------------------
2601  // Calls for messages received on typed input ports
2602  // ----------------------------------------------------------------------
2603 
2604  Fw::ParamValid PrmDbComponentBase ::
2605  m_p_getPrm_in(
2606  Fw::PassiveComponentBase* callComp,
2607  FwIndexType portNum,
2608  FwPrmIdType id,
2609  Fw::ParamBuffer& val
2610  )
2611  {
2612  FW_ASSERT(callComp);
2613  PrmDbComponentBase* compPtr = static_cast<PrmDbComponentBase*>(callComp);
2614  return compPtr->getPrm_handlerBase(
2615  portNum,
2616  id,
2617  val
2618  );
2619  }
2620 
2621  void PrmDbComponentBase ::
2622  m_p_pingIn_in(
2623  Fw::PassiveComponentBase* callComp,
2624  FwIndexType portNum,
2625  U32 key
2626  )
2627  {
2628  FW_ASSERT(callComp);
2629  PrmDbComponentBase* compPtr = static_cast<PrmDbComponentBase*>(callComp);
2630  compPtr->pingIn_handlerBase(
2631  portNum,
2632  key
2633  );
2634  }
2635 
2636  void PrmDbComponentBase ::
2637  m_p_setPrm_in(
2638  Fw::PassiveComponentBase* callComp,
2639  FwIndexType portNum,
2640  FwPrmIdType id,
2641  Fw::ParamBuffer& val
2642  )
2643  {
2644  FW_ASSERT(callComp);
2645  PrmDbComponentBase* compPtr = static_cast<PrmDbComponentBase*>(callComp);
2646  compPtr->setPrm_handlerBase(
2647  portNum,
2648  id,
2649  val
2650  );
2651  }
2652 
2653 }
void set_CmdReg_OutputPort(FwIndexType portNum, Fw::InputCmdRegPort *port)
Connect port to CmdReg[portNum].
Command to save parameter image to file. Uses file name passed to constructor.
Serialization/Deserialization operation was successful.
void regCommands()
Register commands with the Command Dispatcher.
State of parameter DB file load operations.
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
bool isConnected_CmdReg_OutputPort(FwIndexType portNum)
FwIdType FwOpcodeType
The type of a command opcode.
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
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
void log_WARNING_LO_PrmIdNotFound_ThrottleClear()
Reset throttle value for PrmIdNotFound.
PlatformSizeType FwSizeType
Status receive(U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
receive a message from the queue through delegate
Definition: Queue.cpp:71
I32 FwEnumStoreType
Status
status returned from the queue send function
Definition: Queue.hpp:30
void log_ACTIVITY_HI_PrmIdUpdated(FwPrmIdType Id) const
const char * toChar() const
Convert to a C-style char*.
Definition: String.hpp:50
The size of the serial representations of the port arguments.
Definition: CmdPortAc.hpp:38
static constexpr FwIndexType getNum_pingOut_OutputPorts()
PrmDbComponentBase(const char *compName="")
Construct PrmDbComponentBase object.
void init()
Initialization function.
Definition: CmdPortAc.cpp:56
FwIdType FwPrmIdType
The type of a parameter identifier.
void unLock()
unlock the mutex and assert success
Definition: Mutex.cpp:41
void log_ACTIVITY_HI_PrmFileSaveComplete(U32 records) const
The size of the serial representation.
void invoke(U32 key) const
Invoke a port interface.
Definition: PingPortAc.cpp:147
static constexpr FwIndexType getNum_Log_OutputPorts()
virtual const CHAR * toChar() const =0
Convert to a C-style char*.
Fw::InputPrmSetPort * get_setPrm_InputPort(FwIndexType portNum)
virtual void PRM_COMMIT_STAGED_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command PRM_COMMIT_STAGED.
Enum representing a command response.
No time base has been established (Required)
void addCallPort(InputCmdRegPort *callPort)
Register an input port.
virtual void PRM_COMMIT_STAGED_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
static constexpr FwIndexType getNum_Time_OutputPorts()
void init()
Initialization function.
Os::Queue m_queue
queue object for active component
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 log_ACTIVITY_HI_PrmFileLoadComplete(const Fw::StringBase &databaseString, U32 recordsTotal, U32 recordsAdded, U32 recordsUpdated) const
void init()
Object initializer.
Definition: ObjBase.cpp:24
virtual ~PrmDbComponentBase()
Destroy PrmDbComponentBase object.
SerializeStatus
forward declaration for string
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: CmdPortAc.cpp:62
virtual void lock()
Lock the guarded mutex.
Message will block until space is available.
Definition: Queue.hpp:47
void log_WARNING_HI_PrmFileReadError(Svc::PrmDb_PrmReadError stage, I32 record, I32 error) const
Parameter ID updated in database.
FwIdType FwEventIdType
The type of an event identifier.
void invoke(FwOpcodeType opCode) const
Invoke a port interface.
static constexpr FwIndexType getNum_getPrm_InputPorts()
#define FW_OBJECT_NAMES
Indicates whether or not object names are stored (more memory, can be used for tracking objects) ...
Definition: FpConfig.h:26
void init()
Initialization function.
Definition: TimePortAc.cpp:128
void log_ACTIVITY_HI_PrmDbCommitComplete() const
Fw::InputCmdPort * get_CmdDisp_InputPort(FwIndexType portNum)
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
void log_WARNING_LO_PrmDbFileLoadInvalidAction(Svc::PrmDb_PrmDbFileLoadState currentState, Svc::PrmDb_PrmLoadAction attemptedAction) const
Loads a file from storage into the staging database. The file could have selective IDs and not the wh...
#define FW_MIN(a, b)
MIN macro.
Definition: BasicTypes.h:92
A less serious but recoverable event.
void init()
Initialization function.
Definition: PingPortAc.cpp:128
Parameter ID not found in database.
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
void PRM_COMMIT_STAGED_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
bool isConnected_CmdStatus_OutputPort(FwIndexType portNum)
bool isConnected_Log_OutputPort(FwIndexType portNum)
virtual void PRM_LOAD_FILE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdStringArg &fileName, Svc::PrmDb_Merge merge)=0
Serializable::SizeType getDeserializeSizeLeft() const override
Get remaining deserialization buffer size.
message to exit active component task
const char * toChar() const
Convert to a C-style char*.
Definition: ObjectName.hpp:50
void invoke(FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response) const
Invoke a port interface.
FwSizeType SizeType
void addCallPort(InputPingPort *callPort)
Register an input port.
Definition: PingPortAc.cpp:134
Status send(const U8 *buffer, FwSizeType size, FwQueuePriorityType priority, BlockingType blockType) override
send a message into the queue through delegate
Definition: Queue.cpp:54
void setPrm_handlerBase(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val)
Handler base-class function for input port setPrm.
virtual void unLock()
Unlock the guarded mutex.
void resetDeser() override
Reset deserialization pointer to beginning of buffer.
void log_ACTIVITY_HI_PrmIdAdded(FwPrmIdType Id) const
Svc::InputPingPort * get_pingIn_InputPort(FwIndexType portNum)
A serious but recoverable event.
void log_ACTIVITY_HI_PrmDbCopyAllComplete(const Fw::StringBase &databaseStringSrc, const Fw::StringBase &databaseStringDest) const
bool isConnected() const
Definition: PortBase.cpp:38
#define PRI_FwIndexType
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:39
void init()
Initialization function.
Definition: LogPortAc.cpp:151
void setPortNum(FwIndexType portNum)
void PRM_LOAD_FILE_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:53
virtual void PRM_SAVE_FILE_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command PRM_SAVE_FILE.
void log_WARNING_HI_PrmDbFull(FwPrmIdType Id) const
BlockingType
message type
Definition: Queue.hpp:46
void pingOut_out(FwIndexType portNum, U32 key)
Invoke output port pingOut.
virtual void PRM_LOAD_FILE_preMsgHook(FwOpcodeType opCode, U32 cmdSeq)
Pre-message hook for command PRM_LOAD_FILE.
void pingIn_handlerBase(FwIndexType portNum, U32 key)
Handler base-class function for input port pingIn.
Command failed to deserialize.
void PRM_SAVE_FILE_cmdHandlerBase(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdArgBuffer &args)
PlatformQueuePriorityType FwQueuePriorityType
The type of queue priorities used.
Important informational events.
void invoke(FwEventIdType id, Fw::Time &timeTag, const Fw::LogSeverity &severity, Fw::LogBuffer &args) const
Invoke a port interface.
Definition: LogPortAc.cpp:170
The size of the serial representations of the port arguments.
Definition: PingPortAc.hpp:36
void log_WARNING_LO_PrmIdNotFound(FwPrmIdType Id)
Parameter file load failed, not staging any update.
All parameters Copied from one DB to another.
A message was sent requesting an exit of the loop.
PlatformIndexType FwIndexType
static constexpr FwIndexType getNum_CmdStatus_OutputPorts()
void set_CmdStatus_OutputPort(FwIndexType portNum, Fw::InputCmdResponsePort *port)
Connect port to CmdStatus[portNum].
virtual void setPrm_handler(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val)=0
Handler for input port setPrm.
void addCallPort(InputLogPort *callPort)
Register an input port.
Definition: LogPortAc.cpp:157
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.
static constexpr FwIndexType getNum_pingIn_InputPorts()
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
void init()
Initialization function.
Definition: PingPortAc.cpp:56
RateGroupDivider component implementation.
The size of the serial representation.
message sent/received okay
Definition: Queue.hpp:31
SerializeStatus deserializeTo(U8 &val, Endianness mode=Endianness::BIG) override
Deserialize an 8-bit unsigned integer value.
Enum representing parameter validity.
U8 BYTE
byte type
Definition: BasicTypes.h:56
static constexpr FwIndexType getNum_CmdDisp_InputPorts()
bool isConnected_Time_OutputPort(FwIndexType portNum)
Fw::InputPrmGetPort * get_getPrm_InputPort(FwIndexType portNum)
static constexpr FwIndexType getNum_CmdReg_OutputPorts()
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
bool isConnected_pingOut_OutputPort(FwIndexType portNum)
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:48
Implementation of malloc based allocator.
void init()
Initialization function.
virtual void PRM_SAVE_FILE_cmdHandler(FwOpcodeType opCode, U32 cmdSeq)=0
The size of the serial representation.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
Commits the backup database to become the prime (active) database.
static constexpr FwIndexType getNum_setPrm_InputPorts()
virtual void setPrm_preMsgHook(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val)
Pre-message hook for async input port setPrm.
void init()
Initialization function.
void log_WARNING_HI_PrmDbFileLoadFailed() const
void addCallPort(InputCmdResponsePort *callPort)
Register an input port.
void lock()
lock the mutex and assert success
Definition: Mutex.cpp:34
The size of the serial representations of the port arguments.
SerializeStatus serializeTo(SerialBufferBase &buffer, Endianness mode=Endianness::BIG) const override
Serialize the contents of this object to a buffer.