F´ Flight Software - C/C++ Documentation  devel
A framework for building embedded system applications to NASA flight quality standards.
BlockDriverComponentAc.cpp
Go to the documentation of this file.
1 // ======================================================================
2 // \title BlockDriverComponentAc.cpp
3 // \author Generated by fpp-to-cpp
4 // \brief cpp file for BlockDriver 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 Drv {
15 
16  namespace {
17  enum MsgTypeEnum {
18  BLOCKDRIVER_COMPONENT_EXIT = Fw::ActiveComponentBase::ACTIVE_COMPONENT_EXIT,
19  BUFFERIN_DATABUFFER,
20  PINGIN_PING,
21  SCHED_SCHED,
22  INT_IF_INTERRUPTREPORT,
23  };
24 
25  // Get the max size by constructing a union of the async input, command, and
26  // internal port serialization sizes
27  union BuffUnion {
31  // Size of InterruptReport argument list
33  sizeof(U32)
34  ];
35  };
36 
37  // Define a message buffer class large enough to handle all the
38  // asynchronous inputs to the component
39  class ComponentIpcSerializableBuffer :
41  {
42 
43  public:
44 
45  enum {
46  // Max. message size = size of data + message id + port
47  SERIALIZATION_SIZE =
48  sizeof(BuffUnion) +
49  sizeof(FwEnumStoreType) +
50  sizeof(FwIndexType)
51  };
52 
53  Fw::Serializable::SizeType getBuffCapacity() const {
54  return sizeof(m_buff);
55  }
56 
57  U8* getBuffAddr() {
58  return m_buff;
59  }
60 
61  const U8* getBuffAddr() const {
62  return m_buff;
63  }
64 
65  private:
66  // Should be the max of all the input ports serialized sizes...
67  U8 m_buff[SERIALIZATION_SIZE];
68 
69  };
70  }
71 
72  // ----------------------------------------------------------------------
73  // Component initialization
74  // ----------------------------------------------------------------------
75 
77  init(
78  FwQueueSizeType queueDepth,
79  FwEnumStoreType instance
80  )
81  {
82  // Initialize base class
84 
85  // Connect input port BufferIn
86  for (
87  FwIndexType port = 0;
88  port < static_cast<FwIndexType>(this->getNum_BufferIn_InputPorts());
89  port++
90  ) {
91  this->m_BufferIn_InputPort[port].init();
92  this->m_BufferIn_InputPort[port].addCallComp(
93  this,
94  m_p_BufferIn_in
95  );
96  this->m_BufferIn_InputPort[port].setPortNum(port);
97 
98 #if FW_OBJECT_NAMES == 1
99  Fw::ObjectName portName;
100  portName.format(
101  "%s_BufferIn_InputPort[%" PRI_PlatformIntType "]",
102  this->m_objName.toChar(),
103  port
104  );
105  this->m_BufferIn_InputPort[port].setObjName(portName.toChar());
106 #endif
107  }
108 
109  // Connect input port PingIn
110  for (
111  FwIndexType port = 0;
112  port < static_cast<FwIndexType>(this->getNum_PingIn_InputPorts());
113  port++
114  ) {
115  this->m_PingIn_InputPort[port].init();
116  this->m_PingIn_InputPort[port].addCallComp(
117  this,
118  m_p_PingIn_in
119  );
120  this->m_PingIn_InputPort[port].setPortNum(port);
121 
122 #if FW_OBJECT_NAMES == 1
123  Fw::ObjectName portName;
124  portName.format(
125  "%s_PingIn_InputPort[%" PRI_PlatformIntType "]",
126  this->m_objName.toChar(),
127  port
128  );
129  this->m_PingIn_InputPort[port].setObjName(portName.toChar());
130 #endif
131  }
132 
133  // Connect input port Sched
134  for (
135  FwIndexType port = 0;
136  port < static_cast<FwIndexType>(this->getNum_Sched_InputPorts());
137  port++
138  ) {
139  this->m_Sched_InputPort[port].init();
140  this->m_Sched_InputPort[port].addCallComp(
141  this,
142  m_p_Sched_in
143  );
144  this->m_Sched_InputPort[port].setPortNum(port);
145 
146 #if FW_OBJECT_NAMES == 1
147  Fw::ObjectName portName;
148  portName.format(
149  "%s_Sched_InputPort[%" PRI_PlatformIntType "]",
150  this->m_objName.toChar(),
151  port
152  );
153  this->m_Sched_InputPort[port].setObjName(portName.toChar());
154 #endif
155  }
156 
157  // Connect output port Time
158  for (
159  FwIndexType port = 0;
160  port < static_cast<FwIndexType>(this->getNum_Time_OutputPorts());
161  port++
162  ) {
163  this->m_Time_OutputPort[port].init();
164 
165 #if FW_OBJECT_NAMES == 1
166  Fw::ObjectName portName;
167  portName.format(
168  "%s_Time_OutputPort[%" PRI_PlatformIntType "]",
169  this->m_objName.toChar(),
170  port
171  );
172  this->m_Time_OutputPort[port].setObjName(portName.toChar());
173 #endif
174  }
175 
176  // Connect output port Tlm
177  for (
178  FwIndexType port = 0;
179  port < static_cast<FwIndexType>(this->getNum_Tlm_OutputPorts());
180  port++
181  ) {
182  this->m_Tlm_OutputPort[port].init();
183 
184 #if FW_OBJECT_NAMES == 1
185  Fw::ObjectName portName;
186  portName.format(
187  "%s_Tlm_OutputPort[%" PRI_PlatformIntType "]",
188  this->m_objName.toChar(),
189  port
190  );
191  this->m_Tlm_OutputPort[port].setObjName(portName.toChar());
192 #endif
193  }
194 
195  // Connect output port BufferOut
196  for (
197  FwIndexType port = 0;
198  port < static_cast<FwIndexType>(this->getNum_BufferOut_OutputPorts());
199  port++
200  ) {
201  this->m_BufferOut_OutputPort[port].init();
202 
203 #if FW_OBJECT_NAMES == 1
204  Fw::ObjectName portName;
205  portName.format(
206  "%s_BufferOut_OutputPort[%" PRI_PlatformIntType "]",
207  this->m_objName.toChar(),
208  port
209  );
210  this->m_BufferOut_OutputPort[port].setObjName(portName.toChar());
211 #endif
212  }
213 
214  // Connect output port CycleOut
215  for (
216  FwIndexType port = 0;
217  port < static_cast<FwIndexType>(this->getNum_CycleOut_OutputPorts());
218  port++
219  ) {
220  this->m_CycleOut_OutputPort[port].init();
221 
222 #if FW_OBJECT_NAMES == 1
223  Fw::ObjectName portName;
224  portName.format(
225  "%s_CycleOut_OutputPort[%" PRI_PlatformIntType "]",
226  this->m_objName.toChar(),
227  port
228  );
229  this->m_CycleOut_OutputPort[port].setObjName(portName.toChar());
230 #endif
231  }
232 
233  // Connect output port PingOut
234  for (
235  FwIndexType port = 0;
236  port < static_cast<FwIndexType>(this->getNum_PingOut_OutputPorts());
237  port++
238  ) {
239  this->m_PingOut_OutputPort[port].init();
240 
241 #if FW_OBJECT_NAMES == 1
242  Fw::ObjectName portName;
243  portName.format(
244  "%s_PingOut_OutputPort[%" PRI_PlatformIntType "]",
245  this->m_objName.toChar(),
246  port
247  );
248  this->m_PingOut_OutputPort[port].setObjName(portName.toChar());
249 #endif
250  }
251 
252  Os::Queue::QueueStatus qStat = this->createQueue(
253  queueDepth,
254  ComponentIpcSerializableBuffer::SERIALIZATION_SIZE
255  );
256  FW_ASSERT(
257  Os::Queue::QUEUE_OK == qStat,
258  static_cast<FwAssertArgType>(qStat)
259  );
260  }
261 
262  // ----------------------------------------------------------------------
263  // Getters for typed input ports
264  // ----------------------------------------------------------------------
265 
268  {
269  FW_ASSERT(
270  portNum < this->getNum_BufferIn_InputPorts(),
271  static_cast<FwAssertArgType>(portNum)
272  );
273 
274  return &this->m_BufferIn_InputPort[portNum];
275  }
276 
279  {
280  FW_ASSERT(
281  portNum < this->getNum_PingIn_InputPorts(),
282  static_cast<FwAssertArgType>(portNum)
283  );
284 
285  return &this->m_PingIn_InputPort[portNum];
286  }
287 
290  {
291  FW_ASSERT(
292  portNum < this->getNum_Sched_InputPorts(),
293  static_cast<FwAssertArgType>(portNum)
294  );
295 
296  return &this->m_Sched_InputPort[portNum];
297  }
298 
299  // ----------------------------------------------------------------------
300  // Connect input ports to special output ports
301  // ----------------------------------------------------------------------
302 
305  FwIndexType portNum,
306  Fw::InputTimePort* port
307  )
308  {
309  FW_ASSERT(
310  portNum < this->getNum_Time_OutputPorts(),
311  static_cast<FwAssertArgType>(portNum)
312  );
313 
314  this->m_Time_OutputPort[portNum].addCallPort(port);
315  }
316 
319  FwIndexType portNum,
320  Fw::InputTlmPort* port
321  )
322  {
323  FW_ASSERT(
324  portNum < this->getNum_Tlm_OutputPorts(),
325  static_cast<FwAssertArgType>(portNum)
326  );
327 
328  this->m_Tlm_OutputPort[portNum].addCallPort(port);
329  }
330 
331  // ----------------------------------------------------------------------
332  // Connect typed input ports to typed output ports
333  // ----------------------------------------------------------------------
334 
337  FwIndexType portNum,
339  )
340  {
341  FW_ASSERT(
342  portNum < this->getNum_BufferOut_OutputPorts(),
343  static_cast<FwAssertArgType>(portNum)
344  );
345 
346  this->m_BufferOut_OutputPort[portNum].addCallPort(port);
347  }
348 
351  FwIndexType portNum,
352  Svc::InputCyclePort* port
353  )
354  {
355  FW_ASSERT(
356  portNum < this->getNum_CycleOut_OutputPorts(),
357  static_cast<FwAssertArgType>(portNum)
358  );
359 
360  this->m_CycleOut_OutputPort[portNum].addCallPort(port);
361  }
362 
365  FwIndexType portNum,
366  Svc::InputPingPort* port
367  )
368  {
369  FW_ASSERT(
370  portNum < this->getNum_PingOut_OutputPorts(),
371  static_cast<FwAssertArgType>(portNum)
372  );
373 
374  this->m_PingOut_OutputPort[portNum].addCallPort(port);
375  }
376 
377 #if FW_PORT_SERIALIZATION
378 
379  // ----------------------------------------------------------------------
380  // Connect serial input ports to special output ports
381  // ----------------------------------------------------------------------
382 
385  FwIndexType portNum,
386  Fw::InputSerializePort* port
387  )
388  {
389  FW_ASSERT(
390  portNum < this->getNum_Time_OutputPorts(),
391  static_cast<FwAssertArgType>(portNum)
392  );
393 
394  this->m_Time_OutputPort[portNum].registerSerialPort(port);
395  }
396 
399  FwIndexType portNum,
400  Fw::InputSerializePort* port
401  )
402  {
403  FW_ASSERT(
404  portNum < this->getNum_Tlm_OutputPorts(),
405  static_cast<FwAssertArgType>(portNum)
406  );
407 
408  this->m_Tlm_OutputPort[portNum].registerSerialPort(port);
409  }
410 
411 #endif
412 
413 #if FW_PORT_SERIALIZATION
414 
415  // ----------------------------------------------------------------------
416  // Connect serial input ports to typed output ports
417  // ----------------------------------------------------------------------
418 
421  FwIndexType portNum,
422  Fw::InputSerializePort* port
423  )
424  {
425  FW_ASSERT(
426  portNum < this->getNum_BufferOut_OutputPorts(),
427  static_cast<FwAssertArgType>(portNum)
428  );
429 
430  this->m_BufferOut_OutputPort[portNum].registerSerialPort(port);
431  }
432 
435  FwIndexType portNum,
436  Fw::InputSerializePort* port
437  )
438  {
439  FW_ASSERT(
440  portNum < this->getNum_CycleOut_OutputPorts(),
441  static_cast<FwAssertArgType>(portNum)
442  );
443 
444  this->m_CycleOut_OutputPort[portNum].registerSerialPort(port);
445  }
446 
449  FwIndexType portNum,
450  Fw::InputSerializePort* port
451  )
452  {
453  FW_ASSERT(
454  portNum < this->getNum_PingOut_OutputPorts(),
455  static_cast<FwAssertArgType>(portNum)
456  );
457 
458  this->m_PingOut_OutputPort[portNum].registerSerialPort(port);
459  }
460 
461 #endif
462 
463  // ----------------------------------------------------------------------
464  // Component construction and destruction
465  // ----------------------------------------------------------------------
466 
468  BlockDriverComponentBase(const char* compName) :
469  Fw::ActiveComponentBase(compName)
470  {
471 
472  }
473 
476  {
477 
478  }
479 
480  // ----------------------------------------------------------------------
481  // Getters for numbers of typed input ports
482  // ----------------------------------------------------------------------
483 
486  {
487  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_BufferIn_InputPort));
488  }
489 
492  {
493  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_PingIn_InputPort));
494  }
495 
498  {
499  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Sched_InputPort));
500  }
501 
502  // ----------------------------------------------------------------------
503  // Getters for numbers of special output ports
504  // ----------------------------------------------------------------------
505 
508  {
509  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Time_OutputPort));
510  }
511 
514  {
515  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Tlm_OutputPort));
516  }
517 
518  // ----------------------------------------------------------------------
519  // Getters for numbers of typed output ports
520  // ----------------------------------------------------------------------
521 
524  {
525  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_BufferOut_OutputPort));
526  }
527 
530  {
531  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_CycleOut_OutputPort));
532  }
533 
536  {
537  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_PingOut_OutputPort));
538  }
539 
540  // ----------------------------------------------------------------------
541  // Connection status queries for special output ports
542  // ----------------------------------------------------------------------
543 
546  {
547  FW_ASSERT(
548  portNum < this->getNum_Time_OutputPorts(),
549  static_cast<FwAssertArgType>(portNum)
550  );
551 
552  return this->m_Time_OutputPort[portNum].isConnected();
553  }
554 
557  {
558  FW_ASSERT(
559  portNum < this->getNum_Tlm_OutputPorts(),
560  static_cast<FwAssertArgType>(portNum)
561  );
562 
563  return this->m_Tlm_OutputPort[portNum].isConnected();
564  }
565 
566  // ----------------------------------------------------------------------
567  // Connection status queries for typed output ports
568  // ----------------------------------------------------------------------
569 
572  {
573  FW_ASSERT(
574  portNum < this->getNum_BufferOut_OutputPorts(),
575  static_cast<FwAssertArgType>(portNum)
576  );
577 
578  return this->m_BufferOut_OutputPort[portNum].isConnected();
579  }
580 
583  {
584  FW_ASSERT(
585  portNum < this->getNum_CycleOut_OutputPorts(),
586  static_cast<FwAssertArgType>(portNum)
587  );
588 
589  return this->m_CycleOut_OutputPort[portNum].isConnected();
590  }
591 
594  {
595  FW_ASSERT(
596  portNum < this->getNum_PingOut_OutputPorts(),
597  static_cast<FwAssertArgType>(portNum)
598  );
599 
600  return this->m_PingOut_OutputPort[portNum].isConnected();
601  }
602 
603  // ----------------------------------------------------------------------
604  // Port handler base-class functions for typed input ports
605  //
606  // Call these functions directly to bypass the corresponding ports
607  // ----------------------------------------------------------------------
608 
611  FwIndexType portNum,
612  Drv::DataBuffer& buff
613  )
614  {
615  // Make sure port number is valid
616  FW_ASSERT(
617  portNum < this->getNum_BufferIn_InputPorts(),
618  static_cast<FwAssertArgType>(portNum)
619  );
620 
621  // Call pre-message hook
623  portNum,
624  buff
625  );
626  ComponentIpcSerializableBuffer msg;
628 
629  // Serialize message ID
630  _status = msg.serialize(
631  static_cast<FwEnumStoreType>(BUFFERIN_DATABUFFER)
632  );
633  FW_ASSERT(
634  _status == Fw::FW_SERIALIZE_OK,
635  static_cast<FwAssertArgType>(_status)
636  );
637 
638  // Serialize port number
639  _status = msg.serialize(portNum);
640  FW_ASSERT(
641  _status == Fw::FW_SERIALIZE_OK,
642  static_cast<FwAssertArgType>(_status)
643  );
644 
645  // Serialize argument buff
646  _status = msg.serialize(buff);
647  FW_ASSERT(
648  _status == Fw::FW_SERIALIZE_OK,
649  static_cast<FwAssertArgType>(_status)
650  );
651 
652  // Send message
654  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
655 
656  FW_ASSERT(
657  qStatus == Os::Queue::QUEUE_OK,
658  static_cast<FwAssertArgType>(qStatus)
659  );
660  }
661 
664  FwIndexType portNum,
665  U32 key
666  )
667  {
668  // Make sure port number is valid
669  FW_ASSERT(
670  portNum < this->getNum_PingIn_InputPorts(),
671  static_cast<FwAssertArgType>(portNum)
672  );
673 
674  // Call pre-message hook
676  portNum,
677  key
678  );
679  ComponentIpcSerializableBuffer msg;
681 
682  // Serialize message ID
683  _status = msg.serialize(
684  static_cast<FwEnumStoreType>(PINGIN_PING)
685  );
686  FW_ASSERT(
687  _status == Fw::FW_SERIALIZE_OK,
688  static_cast<FwAssertArgType>(_status)
689  );
690 
691  // Serialize port number
692  _status = msg.serialize(portNum);
693  FW_ASSERT(
694  _status == Fw::FW_SERIALIZE_OK,
695  static_cast<FwAssertArgType>(_status)
696  );
697 
698  // Serialize argument key
699  _status = msg.serialize(key);
700  FW_ASSERT(
701  _status == Fw::FW_SERIALIZE_OK,
702  static_cast<FwAssertArgType>(_status)
703  );
704 
705  // Send message
707  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
708 
709  FW_ASSERT(
710  qStatus == Os::Queue::QUEUE_OK,
711  static_cast<FwAssertArgType>(qStatus)
712  );
713  }
714 
717  FwIndexType portNum,
718  U32 context
719  )
720  {
721  // Make sure port number is valid
722  FW_ASSERT(
723  portNum < this->getNum_Sched_InputPorts(),
724  static_cast<FwAssertArgType>(portNum)
725  );
726 
727  // Call pre-message hook
729  portNum,
730  context
731  );
732  ComponentIpcSerializableBuffer msg;
734 
735  // Serialize message ID
736  _status = msg.serialize(
737  static_cast<FwEnumStoreType>(SCHED_SCHED)
738  );
739  FW_ASSERT(
740  _status == Fw::FW_SERIALIZE_OK,
741  static_cast<FwAssertArgType>(_status)
742  );
743 
744  // Serialize port number
745  _status = msg.serialize(portNum);
746  FW_ASSERT(
747  _status == Fw::FW_SERIALIZE_OK,
748  static_cast<FwAssertArgType>(_status)
749  );
750 
751  // Serialize argument context
752  _status = msg.serialize(context);
753  FW_ASSERT(
754  _status == Fw::FW_SERIALIZE_OK,
755  static_cast<FwAssertArgType>(_status)
756  );
757 
758  // Send message
760  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 0, _block);
761 
762  FW_ASSERT(
763  qStatus == Os::Queue::QUEUE_OK,
764  static_cast<FwAssertArgType>(qStatus)
765  );
766  }
767 
768  // ----------------------------------------------------------------------
769  // Pre-message hooks for typed async input ports
770  //
771  // Each of these functions is invoked just before processing a message
772  // on the corresponding port. By default, they do nothing. You can
773  // override them to provide specific pre-message behavior.
774  // ----------------------------------------------------------------------
775 
778  FwIndexType portNum,
779  Drv::DataBuffer& buff
780  )
781  {
782  // Default: no-op
783  }
784 
787  FwIndexType portNum,
788  U32 key
789  )
790  {
791  // Default: no-op
792  }
793 
796  FwIndexType portNum,
797  U32 context
798  )
799  {
800  // Default: no-op
801  }
802 
803  // ----------------------------------------------------------------------
804  // Invocation functions for typed output ports
805  // ----------------------------------------------------------------------
806 
809  FwIndexType portNum,
810  Drv::DataBuffer& buff
811  )
812  {
813  FW_ASSERT(
814  portNum < this->getNum_BufferOut_OutputPorts(),
815  static_cast<FwAssertArgType>(portNum)
816  );
817  this->m_BufferOut_OutputPort[portNum].invoke(
818  buff
819  );
820  }
821 
824  FwIndexType portNum,
825  Svc::TimerVal& cycleStart
826  )
827  {
828  FW_ASSERT(
829  portNum < this->getNum_CycleOut_OutputPorts(),
830  static_cast<FwAssertArgType>(portNum)
831  );
832  this->m_CycleOut_OutputPort[portNum].invoke(
833  cycleStart
834  );
835  }
836 
839  FwIndexType portNum,
840  U32 key
841  )
842  {
843  FW_ASSERT(
844  portNum < this->getNum_PingOut_OutputPorts(),
845  static_cast<FwAssertArgType>(portNum)
846  );
847  this->m_PingOut_OutputPort[portNum].invoke(
848  key
849  );
850  }
851 
852  // ----------------------------------------------------------------------
853  // Internal interface base-class functions
854  // ----------------------------------------------------------------------
855 
858  {
859  ComponentIpcSerializableBuffer msg;
861 
862  // Serialize the message ID
863  _status = msg.serialize(static_cast<FwEnumStoreType>(INT_IF_INTERRUPTREPORT));
864  FW_ASSERT (
865  _status == Fw::FW_SERIALIZE_OK,
866  static_cast<FwAssertArgType>(_status)
867  );
868 
869  // Fake port number to make message dequeue work
870  _status = msg.serialize(static_cast<FwIndexType>(0));
871  FW_ASSERT (
872  _status == Fw::FW_SERIALIZE_OK,
873  static_cast<FwAssertArgType>(_status)
874  );
875 
876  _status = msg.serialize(interrupt);
877  FW_ASSERT(
878  _status == Fw::FW_SERIALIZE_OK,
879  static_cast<FwAssertArgType>(_status)
880  );
881 
882  // Send message
884  Os::Queue::QueueStatus qStatus = this->m_queue.send(msg, 1, _block);
885 
886  FW_ASSERT(
887  qStatus == Os::Queue::QUEUE_OK,
888  static_cast<FwAssertArgType>(qStatus)
889  );
890  }
891 
892  // ----------------------------------------------------------------------
893  // Telemetry write functions
894  // ----------------------------------------------------------------------
895 
898  U32 arg,
899  Fw::Time _tlmTime
900  )
901  {
902  if (this->m_Tlm_OutputPort[0].isConnected()) {
903  if (
904  this->m_Time_OutputPort[0].isConnected() &&
905  (_tlmTime == Fw::ZERO_TIME)
906  ) {
907  this->m_Time_OutputPort[0].invoke(_tlmTime);
908  }
909 
910  Fw::TlmBuffer _tlmBuff;
911  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
912  FW_ASSERT(
913  _stat == Fw::FW_SERIALIZE_OK,
914  static_cast<FwAssertArgType>(_stat)
915  );
916 
917  FwChanIdType _id;
918 
919  _id = this->getIdBase() + CHANNELID_BD_CYCLES;
920 
921  this->m_Tlm_OutputPort[0].invoke(
922  _id,
923  _tlmTime,
924  _tlmBuff
925  );
926  }
927  }
928 
929  // ----------------------------------------------------------------------
930  // Time
931  // ----------------------------------------------------------------------
932 
934  getTime()
935  {
936  if (this->m_Time_OutputPort[0].isConnected()) {
937  Fw::Time _time;
938  this->m_Time_OutputPort[0].invoke(_time);
939  return _time;
940  }
941  else {
942  return Fw::Time(TB_NONE, 0, 0);
943  }
944  }
945 
946  // ----------------------------------------------------------------------
947  // Message dispatch functions
948  // ----------------------------------------------------------------------
949 
950  Fw::QueuedComponentBase::MsgDispatchStatus BlockDriverComponentBase ::
951  doDispatch()
952  {
953  ComponentIpcSerializableBuffer msg;
954  FwQueuePriorityType priority = 0;
955 
956  Os::Queue::QueueStatus msgStatus = this->m_queue.receive(
957  msg,
958  priority,
960  );
961  FW_ASSERT(
962  msgStatus == Os::Queue::QUEUE_OK,
963  static_cast<FwAssertArgType>(msgStatus)
964  );
965 
966  // Reset to beginning of buffer
967  msg.resetDeser();
968 
969  FwEnumStoreType desMsg = 0;
970  Fw::SerializeStatus deserStatus = msg.deserialize(desMsg);
971  FW_ASSERT(
972  deserStatus == Fw::FW_SERIALIZE_OK,
973  static_cast<FwAssertArgType>(deserStatus)
974  );
975 
976  MsgTypeEnum msgType = static_cast<MsgTypeEnum>(desMsg);
977 
978  if (msgType == BLOCKDRIVER_COMPONENT_EXIT) {
979  return MSG_DISPATCH_EXIT;
980  }
981 
982  FwIndexType portNum = 0;
983  deserStatus = msg.deserialize(portNum);
984  FW_ASSERT(
985  deserStatus == Fw::FW_SERIALIZE_OK,
986  static_cast<FwAssertArgType>(deserStatus)
987  );
988 
989  switch (msgType) {
990  // Handle async input port BufferIn
991  case BUFFERIN_DATABUFFER: {
992  // Deserialize argument buff
993  Drv::DataBuffer buff;
994  deserStatus = msg.deserialize(buff);
995  FW_ASSERT(
996  deserStatus == Fw::FW_SERIALIZE_OK,
997  static_cast<FwAssertArgType>(deserStatus)
998  );
999  // Call handler function
1000  this->BufferIn_handler(
1001  portNum,
1002  buff
1003  );
1004 
1005  break;
1006  }
1007 
1008  // Handle async input port PingIn
1009  case PINGIN_PING: {
1010  // Deserialize argument key
1011  U32 key;
1012  deserStatus = msg.deserialize(key);
1013  FW_ASSERT(
1014  deserStatus == Fw::FW_SERIALIZE_OK,
1015  static_cast<FwAssertArgType>(deserStatus)
1016  );
1017  // Call handler function
1018  this->PingIn_handler(
1019  portNum,
1020  key
1021  );
1022 
1023  break;
1024  }
1025 
1026  // Handle async input port Sched
1027  case SCHED_SCHED: {
1028  // Deserialize argument context
1029  U32 context;
1030  deserStatus = msg.deserialize(context);
1031  FW_ASSERT(
1032  deserStatus == Fw::FW_SERIALIZE_OK,
1033  static_cast<FwAssertArgType>(deserStatus)
1034  );
1035  // Call handler function
1036  this->Sched_handler(
1037  portNum,
1038  context
1039  );
1040 
1041  break;
1042  }
1043 
1044  // Handle internal interface InterruptReport
1045  case INT_IF_INTERRUPTREPORT: {
1046  U32 interrupt;
1047  deserStatus = msg.deserialize(interrupt);
1048 
1049  // Internal interface should always deserialize
1050  FW_ASSERT(
1051  Fw::FW_SERIALIZE_OK == deserStatus,
1052  static_cast<FwAssertArgType>(deserStatus)
1053  );
1054 
1055  // Make sure there was no data left over.
1056  // That means the buffer size was incorrect.
1057  FW_ASSERT(
1058  msg.getBuffLeft() == 0,
1059  static_cast<FwAssertArgType>(msg.getBuffLeft())
1060  );
1061 
1062  // Call handler function
1064  interrupt
1065  );
1066 
1067  break;
1068  }
1069 
1070  default:
1071  return MSG_DISPATCH_ERROR;
1072  }
1073 
1074  return MSG_DISPATCH_OK;
1075  }
1076 
1077  // ----------------------------------------------------------------------
1078  // Calls for messages received on typed input ports
1079  // ----------------------------------------------------------------------
1080 
1081  void BlockDriverComponentBase ::
1082  m_p_BufferIn_in(
1083  Fw::PassiveComponentBase* callComp,
1084  FwIndexType portNum,
1085  Drv::DataBuffer& buff
1086  )
1087  {
1088  FW_ASSERT(callComp);
1089  BlockDriverComponentBase* compPtr = static_cast<BlockDriverComponentBase*>(callComp);
1090  compPtr->BufferIn_handlerBase(
1091  portNum,
1092  buff
1093  );
1094  }
1095 
1096  void BlockDriverComponentBase ::
1097  m_p_PingIn_in(
1098  Fw::PassiveComponentBase* callComp,
1099  FwIndexType portNum,
1100  U32 key
1101  )
1102  {
1103  FW_ASSERT(callComp);
1104  BlockDriverComponentBase* compPtr = static_cast<BlockDriverComponentBase*>(callComp);
1105  compPtr->PingIn_handlerBase(
1106  portNum,
1107  key
1108  );
1109  }
1110 
1111  void BlockDriverComponentBase ::
1112  m_p_Sched_in(
1113  Fw::PassiveComponentBase* callComp,
1114  FwIndexType portNum,
1115  U32 context
1116  )
1117  {
1118  FW_ASSERT(callComp);
1119  BlockDriverComponentBase* compPtr = static_cast<BlockDriverComponentBase*>(callComp);
1120  compPtr->Sched_handlerBase(
1121  portNum,
1122  context
1123  );
1124  }
1125 
1126 }
#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
BYTE PingInPortSize[Svc::InputPingPort::SERIALIZED_SIZE]
BYTE InterruptReportIntIfSize[sizeof(U32)]
BYTE BufferInPortSize[Drv::InputDataBufferPort::SERIALIZED_SIZE]
BYTE SchedPortSize[Svc::InputSchedPort::SERIALIZED_SIZE]
#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 FwChanIdType
Definition: FpConfig.h:82
FwIndexType FwQueueSizeType
Definition: FpConfig.h:117
I32 FwQueuePriorityType
Definition: FpConfig.h:98
PlatformIndexType FwIndexType
Definition: FpConfig.h:20
virtual void BufferIn_handler(FwIndexType portNum, Drv::DataBuffer &buff)=0
Handler for input port BufferIn.
bool isConnected_Tlm_OutputPort(FwIndexType portNum)
virtual void Sched_handler(FwIndexType portNum, U32 context)=0
Handler for input port Sched.
void set_PingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to PingOut[portNum].
FwIndexType getNum_CycleOut_OutputPorts() const
void CycleOut_out(FwIndexType portNum, Svc::TimerVal &cycleStart)
Invoke output port CycleOut.
void BufferIn_handlerBase(FwIndexType portNum, Drv::DataBuffer &buff)
Handler base-class function for input port BufferIn.
virtual void PingIn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port PingIn.
void BufferOut_out(FwIndexType portNum, Drv::DataBuffer &buff)
Invoke output port BufferOut.
void tlmWrite_BD_Cycles(U32 arg, Fw::Time _tlmTime=Fw::Time())
void PingIn_handlerBase(FwIndexType portNum, U32 key)
Handler base-class function for input port PingIn.
Drv::InputDataBufferPort * get_BufferIn_InputPort(FwIndexType portNum)
void InterruptReport_internalInterfaceInvoke(U32 interrupt)
Internal interface base-class function for InterruptReport.
Svc::InputPingPort * get_PingIn_InputPort(FwIndexType portNum)
BlockDriverComponentBase(const char *compName="")
Construct BlockDriverComponentBase object.
bool isConnected_BufferOut_OutputPort(FwIndexType portNum)
void set_BufferOut_OutputPort(FwIndexType portNum, Drv::InputDataBufferPort *port)
Connect port to BufferOut[portNum].
@ CHANNELID_BD_CYCLES
Channel ID for BD_Cycles.
virtual void InterruptReport_internalInterfaceHandler(U32 interrupt)=0
Internal interface handler for InterruptReport.
FwIndexType getNum_BufferIn_InputPorts() const
void set_Tlm_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to Tlm[portNum].
virtual ~BlockDriverComponentBase()
Destroy BlockDriverComponentBase object.
FwIndexType getNum_PingOut_OutputPorts() const
bool isConnected_Time_OutputPort(FwIndexType portNum)
void PingOut_out(FwIndexType portNum, U32 key)
Invoke output port PingOut.
bool isConnected_CycleOut_OutputPort(FwIndexType portNum)
Svc::InputSchedPort * get_Sched_InputPort(FwIndexType portNum)
FwIndexType getNum_BufferOut_OutputPorts() const
void set_CycleOut_OutputPort(FwIndexType portNum, Svc::InputCyclePort *port)
Connect port to CycleOut[portNum].
virtual void PingIn_handler(FwIndexType portNum, U32 key)=0
Handler for input port PingIn.
virtual void BufferIn_preMsgHook(FwIndexType portNum, Drv::DataBuffer &buff)
Pre-message hook for async input port BufferIn.
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
void Sched_handlerBase(FwIndexType portNum, U32 context)
Handler base-class function for input port Sched.
bool isConnected_PingOut_OutputPort(FwIndexType portNum)
virtual void Sched_preMsgHook(FwIndexType portNum, U32 context)
Pre-message hook for async input port Sched.
void init()
Initialization function.
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
void addCallPort(InputDataBufferPort *callPort)
Register an input port.
void invoke(Drv::DataBuffer &buff)
Invoke a port interface.
void init()
Initialization function.
@ ACTIVE_COMPONENT_EXIT
message to exit active component task
void setPortNum(NATIVE_INT_TYPE portNum)
void init()
Object initializer.
Definition: ObjBase.cpp:27
const char * toChar() const
Definition: ObjectName.hpp:50
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
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:150
void init()
Initialization function.
Definition: TlmPortAc.cpp:144
void invoke(FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val)
Invoke a port interface.
Definition: TlmPortAc.cpp:163
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
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
Definition: Time.hpp:9
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
@ SERIALIZED_SIZE
The size of the serial representations of the port arguments.
Definition: SchedPortAc.hpp:36
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: SchedPortAc.cpp:62
void init()
Initialization function.
Definition: SchedPortAc.cpp:56
void init()
Initialization function.
void addCallPort(InputCyclePort *callPort)
Register an input port.
void invoke(Svc::TimerVal &cycleStart)
Invoke a port interface.
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
Serializable class for carrying timer values.
Definition: TimerVal.hpp:22
SerializeStatus
forward declaration for string
@ FW_SERIALIZE_OK
Serialization/Deserialization operation was successful.
const Time ZERO_TIME
Definition: Time.cpp:5