F´ Flight Software - C/C++ Documentation
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  // Offset into data in buffer: Size of message ID and port number
47  DATA_OFFSET = sizeof(FwEnumStoreType) + sizeof(FwIndexType),
48  // Max data size
49  MAX_DATA_SIZE = sizeof(BuffUnion),
50  // Max message size: Size of message id + size of port + max data size
51  SERIALIZATION_SIZE = DATA_OFFSET + MAX_DATA_SIZE
52  };
53 
54  Fw::Serializable::SizeType getBuffCapacity() const {
55  return sizeof(m_buff);
56  }
57 
58  U8* getBuffAddr() {
59  return m_buff;
60  }
61 
62  const U8* getBuffAddr() const {
63  return m_buff;
64  }
65 
66  private:
67  // Should be the max of all the input ports serialized sizes...
68  U8 m_buff[SERIALIZATION_SIZE];
69 
70  };
71  }
72 
73  // ----------------------------------------------------------------------
74  // Component initialization
75  // ----------------------------------------------------------------------
76 
79  FwSizeType queueDepth,
80  FwEnumStoreType instance
81  )
82  {
83  // Initialize base class
85 
86  // Connect input port BufferIn
87  for (
88  FwIndexType port = 0;
89  port < static_cast<FwIndexType>(this->getNum_BufferIn_InputPorts());
90  port++
91  ) {
92  this->m_BufferIn_InputPort[port].init();
93  this->m_BufferIn_InputPort[port].addCallComp(
94  this,
95  m_p_BufferIn_in
96  );
97  this->m_BufferIn_InputPort[port].setPortNum(port);
98 
99 #if FW_OBJECT_NAMES == 1
100  Fw::ObjectName portName;
101  portName.format(
102  "%s_BufferIn_InputPort[%" PRI_PlatformIntType "]",
103  this->m_objName.toChar(),
104  port
105  );
106  this->m_BufferIn_InputPort[port].setObjName(portName.toChar());
107 #endif
108  }
109 
110  // Connect input port PingIn
111  for (
112  FwIndexType port = 0;
113  port < static_cast<FwIndexType>(this->getNum_PingIn_InputPorts());
114  port++
115  ) {
116  this->m_PingIn_InputPort[port].init();
117  this->m_PingIn_InputPort[port].addCallComp(
118  this,
119  m_p_PingIn_in
120  );
121  this->m_PingIn_InputPort[port].setPortNum(port);
122 
123 #if FW_OBJECT_NAMES == 1
124  Fw::ObjectName portName;
125  portName.format(
126  "%s_PingIn_InputPort[%" PRI_PlatformIntType "]",
127  this->m_objName.toChar(),
128  port
129  );
130  this->m_PingIn_InputPort[port].setObjName(portName.toChar());
131 #endif
132  }
133 
134  // Connect input port Sched
135  for (
136  FwIndexType port = 0;
137  port < static_cast<FwIndexType>(this->getNum_Sched_InputPorts());
138  port++
139  ) {
140  this->m_Sched_InputPort[port].init();
141  this->m_Sched_InputPort[port].addCallComp(
142  this,
143  m_p_Sched_in
144  );
145  this->m_Sched_InputPort[port].setPortNum(port);
146 
147 #if FW_OBJECT_NAMES == 1
148  Fw::ObjectName portName;
149  portName.format(
150  "%s_Sched_InputPort[%" PRI_PlatformIntType "]",
151  this->m_objName.toChar(),
152  port
153  );
154  this->m_Sched_InputPort[port].setObjName(portName.toChar());
155 #endif
156  }
157 
158  // Connect output port Time
159  for (
160  FwIndexType port = 0;
161  port < static_cast<FwIndexType>(this->getNum_Time_OutputPorts());
162  port++
163  ) {
164  this->m_Time_OutputPort[port].init();
165 
166 #if FW_OBJECT_NAMES == 1
167  Fw::ObjectName portName;
168  portName.format(
169  "%s_Time_OutputPort[%" PRI_PlatformIntType "]",
170  this->m_objName.toChar(),
171  port
172  );
173  this->m_Time_OutputPort[port].setObjName(portName.toChar());
174 #endif
175  }
176 
177  // Connect output port Tlm
178  for (
179  FwIndexType port = 0;
180  port < static_cast<FwIndexType>(this->getNum_Tlm_OutputPorts());
181  port++
182  ) {
183  this->m_Tlm_OutputPort[port].init();
184 
185 #if FW_OBJECT_NAMES == 1
186  Fw::ObjectName portName;
187  portName.format(
188  "%s_Tlm_OutputPort[%" PRI_PlatformIntType "]",
189  this->m_objName.toChar(),
190  port
191  );
192  this->m_Tlm_OutputPort[port].setObjName(portName.toChar());
193 #endif
194  }
195 
196  // Connect output port BufferOut
197  for (
198  FwIndexType port = 0;
199  port < static_cast<FwIndexType>(this->getNum_BufferOut_OutputPorts());
200  port++
201  ) {
202  this->m_BufferOut_OutputPort[port].init();
203 
204 #if FW_OBJECT_NAMES == 1
205  Fw::ObjectName portName;
206  portName.format(
207  "%s_BufferOut_OutputPort[%" PRI_PlatformIntType "]",
208  this->m_objName.toChar(),
209  port
210  );
211  this->m_BufferOut_OutputPort[port].setObjName(portName.toChar());
212 #endif
213  }
214 
215  // Connect output port CycleOut
216  for (
217  FwIndexType port = 0;
218  port < static_cast<FwIndexType>(this->getNum_CycleOut_OutputPorts());
219  port++
220  ) {
221  this->m_CycleOut_OutputPort[port].init();
222 
223 #if FW_OBJECT_NAMES == 1
224  Fw::ObjectName portName;
225  portName.format(
226  "%s_CycleOut_OutputPort[%" PRI_PlatformIntType "]",
227  this->m_objName.toChar(),
228  port
229  );
230  this->m_CycleOut_OutputPort[port].setObjName(portName.toChar());
231 #endif
232  }
233 
234  // Connect output port PingOut
235  for (
236  FwIndexType port = 0;
237  port < static_cast<FwIndexType>(this->getNum_PingOut_OutputPorts());
238  port++
239  ) {
240  this->m_PingOut_OutputPort[port].init();
241 
242 #if FW_OBJECT_NAMES == 1
243  Fw::ObjectName portName;
244  portName.format(
245  "%s_PingOut_OutputPort[%" PRI_PlatformIntType "]",
246  this->m_objName.toChar(),
247  port
248  );
249  this->m_PingOut_OutputPort[port].setObjName(portName.toChar());
250 #endif
251  }
252 
253  // Create the queue
254  Os::Queue::Status qStat = this->createQueue(
255  queueDepth,
256  static_cast<FwSizeType>(ComponentIpcSerializableBuffer::SERIALIZATION_SIZE)
257  );
258  FW_ASSERT(
259  Os::Queue::Status::OP_OK == qStat,
260  static_cast<FwAssertArgType>(qStat)
261  );
262  }
263 
264  // ----------------------------------------------------------------------
265  // Getters for typed input ports
266  // ----------------------------------------------------------------------
267 
270  {
271  FW_ASSERT(
272  portNum < this->getNum_BufferIn_InputPorts(),
273  static_cast<FwAssertArgType>(portNum)
274  );
275 
276  return &this->m_BufferIn_InputPort[portNum];
277  }
278 
281  {
282  FW_ASSERT(
283  portNum < this->getNum_PingIn_InputPorts(),
284  static_cast<FwAssertArgType>(portNum)
285  );
286 
287  return &this->m_PingIn_InputPort[portNum];
288  }
289 
292  {
293  FW_ASSERT(
294  portNum < this->getNum_Sched_InputPorts(),
295  static_cast<FwAssertArgType>(portNum)
296  );
297 
298  return &this->m_Sched_InputPort[portNum];
299  }
300 
301  // ----------------------------------------------------------------------
302  // Connect input ports to special output ports
303  // ----------------------------------------------------------------------
304 
307  FwIndexType portNum,
308  Fw::InputTimePort* port
309  )
310  {
311  FW_ASSERT(
312  portNum < this->getNum_Time_OutputPorts(),
313  static_cast<FwAssertArgType>(portNum)
314  );
315 
316  this->m_Time_OutputPort[portNum].addCallPort(port);
317  }
318 
321  FwIndexType portNum,
322  Fw::InputTlmPort* port
323  )
324  {
325  FW_ASSERT(
326  portNum < this->getNum_Tlm_OutputPorts(),
327  static_cast<FwAssertArgType>(portNum)
328  );
329 
330  this->m_Tlm_OutputPort[portNum].addCallPort(port);
331  }
332 
333  // ----------------------------------------------------------------------
334  // Connect typed input ports to typed output ports
335  // ----------------------------------------------------------------------
336 
339  FwIndexType portNum,
341  )
342  {
343  FW_ASSERT(
344  portNum < this->getNum_BufferOut_OutputPorts(),
345  static_cast<FwAssertArgType>(portNum)
346  );
347 
348  this->m_BufferOut_OutputPort[portNum].addCallPort(port);
349  }
350 
353  FwIndexType portNum,
354  Svc::InputCyclePort* port
355  )
356  {
357  FW_ASSERT(
358  portNum < this->getNum_CycleOut_OutputPorts(),
359  static_cast<FwAssertArgType>(portNum)
360  );
361 
362  this->m_CycleOut_OutputPort[portNum].addCallPort(port);
363  }
364 
367  FwIndexType portNum,
368  Svc::InputPingPort* port
369  )
370  {
371  FW_ASSERT(
372  portNum < this->getNum_PingOut_OutputPorts(),
373  static_cast<FwAssertArgType>(portNum)
374  );
375 
376  this->m_PingOut_OutputPort[portNum].addCallPort(port);
377  }
378 
379 #if FW_PORT_SERIALIZATION
380 
381  // ----------------------------------------------------------------------
382  // Connect serial input ports to special output ports
383  // ----------------------------------------------------------------------
384 
387  FwIndexType portNum,
388  Fw::InputSerializePort* port
389  )
390  {
391  FW_ASSERT(
392  portNum < this->getNum_Time_OutputPorts(),
393  static_cast<FwAssertArgType>(portNum)
394  );
395 
396  this->m_Time_OutputPort[portNum].registerSerialPort(port);
397  }
398 
401  FwIndexType portNum,
402  Fw::InputSerializePort* port
403  )
404  {
405  FW_ASSERT(
406  portNum < this->getNum_Tlm_OutputPorts(),
407  static_cast<FwAssertArgType>(portNum)
408  );
409 
410  this->m_Tlm_OutputPort[portNum].registerSerialPort(port);
411  }
412 
413 #endif
414 
415 #if FW_PORT_SERIALIZATION
416 
417  // ----------------------------------------------------------------------
418  // Connect serial input ports to typed output ports
419  // ----------------------------------------------------------------------
420 
423  FwIndexType portNum,
424  Fw::InputSerializePort* port
425  )
426  {
427  FW_ASSERT(
428  portNum < this->getNum_BufferOut_OutputPorts(),
429  static_cast<FwAssertArgType>(portNum)
430  );
431 
432  this->m_BufferOut_OutputPort[portNum].registerSerialPort(port);
433  }
434 
437  FwIndexType portNum,
438  Fw::InputSerializePort* port
439  )
440  {
441  FW_ASSERT(
442  portNum < this->getNum_CycleOut_OutputPorts(),
443  static_cast<FwAssertArgType>(portNum)
444  );
445 
446  this->m_CycleOut_OutputPort[portNum].registerSerialPort(port);
447  }
448 
451  FwIndexType portNum,
452  Fw::InputSerializePort* port
453  )
454  {
455  FW_ASSERT(
456  portNum < this->getNum_PingOut_OutputPorts(),
457  static_cast<FwAssertArgType>(portNum)
458  );
459 
460  this->m_PingOut_OutputPort[portNum].registerSerialPort(port);
461  }
462 
463 #endif
464 
465  // ----------------------------------------------------------------------
466  // Component construction and destruction
467  // ----------------------------------------------------------------------
468 
470  BlockDriverComponentBase(const char* compName) :
471  Fw::ActiveComponentBase(compName)
472  {
473 
474  }
475 
478  {
479 
480  }
481 
482  // ----------------------------------------------------------------------
483  // Getters for numbers of typed input ports
484  // ----------------------------------------------------------------------
485 
488  {
489  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_BufferIn_InputPort));
490  }
491 
494  {
495  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_PingIn_InputPort));
496  }
497 
500  {
501  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Sched_InputPort));
502  }
503 
504  // ----------------------------------------------------------------------
505  // Getters for numbers of special output ports
506  // ----------------------------------------------------------------------
507 
510  {
511  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Time_OutputPort));
512  }
513 
516  {
517  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_Tlm_OutputPort));
518  }
519 
520  // ----------------------------------------------------------------------
521  // Getters for numbers of typed output ports
522  // ----------------------------------------------------------------------
523 
526  {
527  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_BufferOut_OutputPort));
528  }
529 
532  {
533  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_CycleOut_OutputPort));
534  }
535 
538  {
539  return static_cast<FwIndexType>(FW_NUM_ARRAY_ELEMENTS(this->m_PingOut_OutputPort));
540  }
541 
542  // ----------------------------------------------------------------------
543  // Connection status queries for special output ports
544  // ----------------------------------------------------------------------
545 
548  {
549  FW_ASSERT(
550  portNum < this->getNum_Time_OutputPorts(),
551  static_cast<FwAssertArgType>(portNum)
552  );
553 
554  return this->m_Time_OutputPort[portNum].isConnected();
555  }
556 
559  {
560  FW_ASSERT(
561  portNum < this->getNum_Tlm_OutputPorts(),
562  static_cast<FwAssertArgType>(portNum)
563  );
564 
565  return this->m_Tlm_OutputPort[portNum].isConnected();
566  }
567 
568  // ----------------------------------------------------------------------
569  // Connection status queries for typed output ports
570  // ----------------------------------------------------------------------
571 
574  {
575  FW_ASSERT(
576  portNum < this->getNum_BufferOut_OutputPorts(),
577  static_cast<FwAssertArgType>(portNum)
578  );
579 
580  return this->m_BufferOut_OutputPort[portNum].isConnected();
581  }
582 
585  {
586  FW_ASSERT(
587  portNum < this->getNum_CycleOut_OutputPorts(),
588  static_cast<FwAssertArgType>(portNum)
589  );
590 
591  return this->m_CycleOut_OutputPort[portNum].isConnected();
592  }
593 
596  {
597  FW_ASSERT(
598  portNum < this->getNum_PingOut_OutputPorts(),
599  static_cast<FwAssertArgType>(portNum)
600  );
601 
602  return this->m_PingOut_OutputPort[portNum].isConnected();
603  }
604 
605  // ----------------------------------------------------------------------
606  // Port handler base-class functions for typed input ports
607  //
608  // Call these functions directly to bypass the corresponding ports
609  // ----------------------------------------------------------------------
610 
613  FwIndexType portNum,
614  Drv::DataBuffer& buff
615  )
616  {
617  // Make sure port number is valid
618  FW_ASSERT(
619  portNum < this->getNum_BufferIn_InputPorts(),
620  static_cast<FwAssertArgType>(portNum)
621  );
622 
623  // Call pre-message hook
625  portNum,
626  buff
627  );
628  ComponentIpcSerializableBuffer msg;
630 
631  // Serialize message ID
632  _status = msg.serialize(
633  static_cast<FwEnumStoreType>(BUFFERIN_DATABUFFER)
634  );
635  FW_ASSERT(
636  _status == Fw::FW_SERIALIZE_OK,
637  static_cast<FwAssertArgType>(_status)
638  );
639 
640  // Serialize port number
641  _status = msg.serialize(portNum);
642  FW_ASSERT(
643  _status == Fw::FW_SERIALIZE_OK,
644  static_cast<FwAssertArgType>(_status)
645  );
646 
647  // Serialize argument buff
648  _status = msg.serialize(buff);
649  FW_ASSERT(
650  _status == Fw::FW_SERIALIZE_OK,
651  static_cast<FwAssertArgType>(_status)
652  );
653 
654  // Send message
656  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
657 
658  FW_ASSERT(
659  qStatus == Os::Queue::OP_OK,
660  static_cast<FwAssertArgType>(qStatus)
661  );
662  }
663 
666  FwIndexType portNum,
667  U32 key
668  )
669  {
670  // Make sure port number is valid
671  FW_ASSERT(
672  portNum < this->getNum_PingIn_InputPorts(),
673  static_cast<FwAssertArgType>(portNum)
674  );
675 
676  // Call pre-message hook
678  portNum,
679  key
680  );
681  ComponentIpcSerializableBuffer msg;
683 
684  // Serialize message ID
685  _status = msg.serialize(
686  static_cast<FwEnumStoreType>(PINGIN_PING)
687  );
688  FW_ASSERT(
689  _status == Fw::FW_SERIALIZE_OK,
690  static_cast<FwAssertArgType>(_status)
691  );
692 
693  // Serialize port number
694  _status = msg.serialize(portNum);
695  FW_ASSERT(
696  _status == Fw::FW_SERIALIZE_OK,
697  static_cast<FwAssertArgType>(_status)
698  );
699 
700  // Serialize argument key
701  _status = msg.serialize(key);
702  FW_ASSERT(
703  _status == Fw::FW_SERIALIZE_OK,
704  static_cast<FwAssertArgType>(_status)
705  );
706 
707  // Send message
709  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
710 
711  FW_ASSERT(
712  qStatus == Os::Queue::OP_OK,
713  static_cast<FwAssertArgType>(qStatus)
714  );
715  }
716 
719  FwIndexType portNum,
720  U32 context
721  )
722  {
723  // Make sure port number is valid
724  FW_ASSERT(
725  portNum < this->getNum_Sched_InputPorts(),
726  static_cast<FwAssertArgType>(portNum)
727  );
728 
729  // Call pre-message hook
731  portNum,
732  context
733  );
734  ComponentIpcSerializableBuffer msg;
736 
737  // Serialize message ID
738  _status = msg.serialize(
739  static_cast<FwEnumStoreType>(SCHED_SCHED)
740  );
741  FW_ASSERT(
742  _status == Fw::FW_SERIALIZE_OK,
743  static_cast<FwAssertArgType>(_status)
744  );
745 
746  // Serialize port number
747  _status = msg.serialize(portNum);
748  FW_ASSERT(
749  _status == Fw::FW_SERIALIZE_OK,
750  static_cast<FwAssertArgType>(_status)
751  );
752 
753  // Serialize argument context
754  _status = msg.serialize(context);
755  FW_ASSERT(
756  _status == Fw::FW_SERIALIZE_OK,
757  static_cast<FwAssertArgType>(_status)
758  );
759 
760  // Send message
762  Os::Queue::Status qStatus = this->m_queue.send(msg, 0, _block);
763 
764  FW_ASSERT(
765  qStatus == Os::Queue::OP_OK,
766  static_cast<FwAssertArgType>(qStatus)
767  );
768  }
769 
770  // ----------------------------------------------------------------------
771  // Pre-message hooks for typed async input ports
772  //
773  // Each of these functions is invoked just before processing a message
774  // on the corresponding port. By default, they do nothing. You can
775  // override them to provide specific pre-message behavior.
776  // ----------------------------------------------------------------------
777 
780  FwIndexType portNum,
781  Drv::DataBuffer& buff
782  )
783  {
784  // Default: no-op
785  }
786 
789  FwIndexType portNum,
790  U32 key
791  )
792  {
793  // Default: no-op
794  }
795 
798  FwIndexType portNum,
799  U32 context
800  )
801  {
802  // Default: no-op
803  }
804 
805  // ----------------------------------------------------------------------
806  // Invocation functions for typed output ports
807  // ----------------------------------------------------------------------
808 
811  FwIndexType portNum,
812  Drv::DataBuffer& buff
813  )
814  {
815  FW_ASSERT(
816  portNum < this->getNum_BufferOut_OutputPorts(),
817  static_cast<FwAssertArgType>(portNum)
818  );
819  this->m_BufferOut_OutputPort[portNum].invoke(
820  buff
821  );
822  }
823 
826  FwIndexType portNum,
827  Os::RawTime& cycleStart
828  )
829  {
830  FW_ASSERT(
831  portNum < this->getNum_CycleOut_OutputPorts(),
832  static_cast<FwAssertArgType>(portNum)
833  );
834  this->m_CycleOut_OutputPort[portNum].invoke(
835  cycleStart
836  );
837  }
838 
841  FwIndexType portNum,
842  U32 key
843  )
844  {
845  FW_ASSERT(
846  portNum < this->getNum_PingOut_OutputPorts(),
847  static_cast<FwAssertArgType>(portNum)
848  );
849  this->m_PingOut_OutputPort[portNum].invoke(
850  key
851  );
852  }
853 
854  // ----------------------------------------------------------------------
855  // Internal interface base-class functions
856  // ----------------------------------------------------------------------
857 
860  {
861  ComponentIpcSerializableBuffer msg;
863 
864  // Serialize the message ID
865  _status = msg.serialize(static_cast<FwEnumStoreType>(INT_IF_INTERRUPTREPORT));
866  FW_ASSERT (
867  _status == Fw::FW_SERIALIZE_OK,
868  static_cast<FwAssertArgType>(_status)
869  );
870 
871  // Fake port number to make message dequeue work
872  _status = msg.serialize(static_cast<FwIndexType>(0));
873  FW_ASSERT (
874  _status == Fw::FW_SERIALIZE_OK,
875  static_cast<FwAssertArgType>(_status)
876  );
877 
878  _status = msg.serialize(interrupt);
879  FW_ASSERT(
880  _status == Fw::FW_SERIALIZE_OK,
881  static_cast<FwAssertArgType>(_status)
882  );
883 
884  // Send message
886  Os::Queue::Status qStatus = this->m_queue.send(msg, 1, _block);
887 
888  FW_ASSERT(
889  qStatus == Os::Queue::OP_OK,
890  static_cast<FwAssertArgType>(qStatus)
891  );
892  }
893 
894  // ----------------------------------------------------------------------
895  // Telemetry write functions
896  // ----------------------------------------------------------------------
897 
900  U32 arg,
901  Fw::Time _tlmTime
902  ) const
903  {
904  if (this->m_Tlm_OutputPort[0].isConnected()) {
905  if (
906  this->m_Time_OutputPort[0].isConnected() &&
907  (_tlmTime == Fw::ZERO_TIME)
908  ) {
909  this->m_Time_OutputPort[0].invoke(_tlmTime);
910  }
911 
912  Fw::TlmBuffer _tlmBuff;
913  Fw::SerializeStatus _stat = _tlmBuff.serialize(arg);
914  FW_ASSERT(
915  _stat == Fw::FW_SERIALIZE_OK,
916  static_cast<FwAssertArgType>(_stat)
917  );
918 
919  FwChanIdType _id;
920 
921  _id = this->getIdBase() + CHANNELID_BD_CYCLES;
922 
923  this->m_Tlm_OutputPort[0].invoke(
924  _id,
925  _tlmTime,
926  _tlmBuff
927  );
928  }
929  }
930 
931  // ----------------------------------------------------------------------
932  // Time
933  // ----------------------------------------------------------------------
934 
937  {
938  if (this->m_Time_OutputPort[0].isConnected()) {
939  Fw::Time _time;
940  this->m_Time_OutputPort[0].invoke(_time);
941  return _time;
942  }
943  else {
944  return Fw::Time(TB_NONE, 0, 0);
945  }
946  }
947 
948  // ----------------------------------------------------------------------
949  // Message dispatch functions
950  // ----------------------------------------------------------------------
951 
952  Fw::QueuedComponentBase::MsgDispatchStatus BlockDriverComponentBase ::
953  doDispatch()
954  {
955  ComponentIpcSerializableBuffer msg;
956  FwQueuePriorityType priority = 0;
957 
958  Os::Queue::Status msgStatus = this->m_queue.receive(
959  msg,
961  priority
962  );
963  FW_ASSERT(
964  msgStatus == Os::Queue::OP_OK,
965  static_cast<FwAssertArgType>(msgStatus)
966  );
967 
968  // Reset to beginning of buffer
969  msg.resetDeser();
970 
971  FwEnumStoreType desMsg = 0;
972  Fw::SerializeStatus deserStatus = msg.deserialize(desMsg);
973  FW_ASSERT(
974  deserStatus == Fw::FW_SERIALIZE_OK,
975  static_cast<FwAssertArgType>(deserStatus)
976  );
977 
978  MsgTypeEnum msgType = static_cast<MsgTypeEnum>(desMsg);
979 
980  if (msgType == BLOCKDRIVER_COMPONENT_EXIT) {
981  return MSG_DISPATCH_EXIT;
982  }
983 
984  FwIndexType portNum = 0;
985  deserStatus = msg.deserialize(portNum);
986  FW_ASSERT(
987  deserStatus == Fw::FW_SERIALIZE_OK,
988  static_cast<FwAssertArgType>(deserStatus)
989  );
990 
991  switch (msgType) {
992  // Handle async input port BufferIn
993  case BUFFERIN_DATABUFFER: {
994  // Deserialize argument buff
995  Drv::DataBuffer buff;
996  deserStatus = msg.deserialize(buff);
997  FW_ASSERT(
998  deserStatus == Fw::FW_SERIALIZE_OK,
999  static_cast<FwAssertArgType>(deserStatus)
1000  );
1001  // Call handler function
1002  this->BufferIn_handler(
1003  portNum,
1004  buff
1005  );
1006 
1007  break;
1008  }
1009 
1010  // Handle async input port PingIn
1011  case PINGIN_PING: {
1012  // Deserialize argument key
1013  U32 key;
1014  deserStatus = msg.deserialize(key);
1015  FW_ASSERT(
1016  deserStatus == Fw::FW_SERIALIZE_OK,
1017  static_cast<FwAssertArgType>(deserStatus)
1018  );
1019  // Call handler function
1020  this->PingIn_handler(
1021  portNum,
1022  key
1023  );
1024 
1025  break;
1026  }
1027 
1028  // Handle async input port Sched
1029  case SCHED_SCHED: {
1030  // Deserialize argument context
1031  U32 context;
1032  deserStatus = msg.deserialize(context);
1033  FW_ASSERT(
1034  deserStatus == Fw::FW_SERIALIZE_OK,
1035  static_cast<FwAssertArgType>(deserStatus)
1036  );
1037  // Call handler function
1038  this->Sched_handler(
1039  portNum,
1040  context
1041  );
1042 
1043  break;
1044  }
1045 
1046  // Handle internal interface InterruptReport
1047  case INT_IF_INTERRUPTREPORT: {
1048  U32 interrupt;
1049  deserStatus = msg.deserialize(interrupt);
1050 
1051  // Internal interface should always deserialize
1052  FW_ASSERT(
1053  Fw::FW_SERIALIZE_OK == deserStatus,
1054  static_cast<FwAssertArgType>(deserStatus)
1055  );
1056 
1057  // Make sure there was no data left over.
1058  // That means the buffer size was incorrect.
1059  FW_ASSERT(
1060  msg.getBuffLeft() == 0,
1061  static_cast<FwAssertArgType>(msg.getBuffLeft())
1062  );
1063 
1064  // Call handler function
1066  interrupt
1067  );
1068 
1069  break;
1070  }
1071 
1072  default:
1073  return MSG_DISPATCH_ERROR;
1074  }
1075 
1076  return MSG_DISPATCH_OK;
1077  }
1078 
1079  // ----------------------------------------------------------------------
1080  // Calls for messages received on typed input ports
1081  // ----------------------------------------------------------------------
1082 
1083  void BlockDriverComponentBase ::
1084  m_p_BufferIn_in(
1085  Fw::PassiveComponentBase* callComp,
1086  FwIndexType portNum,
1087  Drv::DataBuffer& buff
1088  )
1089  {
1090  FW_ASSERT(callComp);
1091  BlockDriverComponentBase* compPtr = static_cast<BlockDriverComponentBase*>(callComp);
1092  compPtr->BufferIn_handlerBase(
1093  portNum,
1094  buff
1095  );
1096  }
1097 
1098  void BlockDriverComponentBase ::
1099  m_p_PingIn_in(
1100  Fw::PassiveComponentBase* callComp,
1101  FwIndexType portNum,
1102  U32 key
1103  )
1104  {
1105  FW_ASSERT(callComp);
1106  BlockDriverComponentBase* compPtr = static_cast<BlockDriverComponentBase*>(callComp);
1107  compPtr->PingIn_handlerBase(
1108  portNum,
1109  key
1110  );
1111  }
1112 
1113  void BlockDriverComponentBase ::
1114  m_p_Sched_in(
1115  Fw::PassiveComponentBase* callComp,
1116  FwIndexType portNum,
1117  U32 context
1118  )
1119  {
1120  FW_ASSERT(callComp);
1121  BlockDriverComponentBase* compPtr = static_cast<BlockDriverComponentBase*>(callComp);
1122  compPtr->Sched_handlerBase(
1123  portNum,
1124  context
1125  );
1126  }
1127 
1128 }
void Sched_handlerBase(FwIndexType portNum, U32 context)
Handler base-class function for input port Sched.
Serialization/Deserialization operation was successful.
bool isConnected_BufferOut_OutputPort(FwIndexType portNum)
void addCallPort(InputTimePort *callPort)
Register an input port.
Definition: TimePortAc.cpp:134
PlatformAssertArgType FwAssertArgType
Definition: FpConfig.h:39
Definition: Time.hpp:9
Svc::InputSchedPort * get_Sched_InputPort(FwIndexType portNum)
void init()
Initialization function.
bool isConnected_Time_OutputPort(FwIndexType portNum)
bool isConnected_CycleOut_OutputPort(FwIndexType portNum)
BYTE BufferInPortSize[Drv::InputDataBufferPort::SERIALIZED_SIZE]
Operation succeeded.
Definition: Os.hpp:26
NATIVE_UINT_TYPE SizeType
Status
status returned from the queue send function
Definition: Queue.hpp:30
SerializeStatus serialize(U8 val)
serialize 8-bit unsigned int
void init()
Initialization function.
void init()
Initialization function.
Definition: SchedPortAc.cpp:56
virtual ~BlockDriverComponentBase()
Destroy BlockDriverComponentBase object.
BYTE SchedPortSize[Svc::InputSchedPort::SERIALIZED_SIZE]
void tlmWrite_BD_Cycles(U32 arg, Fw::Time _tlmTime=Fw::Time()) const
PlatformSizeType FwSizeType
Definition: FpConfig.h:35
bool isConnected_Tlm_OutputPort(FwIndexType portNum)
void invoke(U32 key) const
Invoke a port interface.
Definition: PingPortAc.cpp:147
const Time ZERO_TIME
Definition: Time.cpp:5
void set_Tlm_OutputPort(FwIndexType portNum, Fw::InputTlmPort *port)
Connect port to Tlm[portNum].
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
I32 FwEnumStoreType
Definition: FpConfig.h:64
void init()
Initialization function.
Definition: TlmPortAc.cpp:144
PlatformIndexType FwIndexType
Definition: FpConfig.h:25
BYTE PingInPortSize[Svc::InputPingPort::SERIALIZED_SIZE]
Os::Queue m_queue
queue object for active component
void PingOut_out(FwIndexType portNum, U32 key)
Invoke output port PingOut.
void addCallPort(InputTlmPort *callPort)
Register an input port.
Definition: TlmPortAc.cpp:150
void init()
Object initializer.
Definition: ObjBase.cpp:26
virtual void Sched_preMsgHook(FwIndexType portNum, U32 context)
Pre-message hook for async input port Sched.
SerializeStatus
forward declaration for string
Message will block until space is available.
Definition: Queue.hpp:46
void addCallPort(InputCyclePort *callPort)
Register an input port.
void set_CycleOut_OutputPort(FwIndexType portNum, Svc::InputCyclePort *port)
Connect port to CycleOut[portNum].
void init()
Initialization function.
Definition: TimePortAc.cpp:128
void setPortNum(NATIVE_INT_TYPE portNum)
Os::Queue::Status createQueue(FwSizeType depth, FwSizeType msgSize)
virtual void PingIn_handler(FwIndexType portNum, U32 key)=0
Handler for input port PingIn.
void init()
Initialization function.
Definition: PingPortAc.cpp:128
The size of the serial representations of the port arguments.
Definition: PingPortAc.hpp:36
void invoke(Fw::Time &time) const
Invoke a port interface.
Definition: TimePortAc.cpp:147
const char * toChar() const
Definition: ObjectName.hpp:50
No time base has been established.
Definition: FpConfig.h:70
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
void set_PingOut_OutputPort(FwIndexType portNum, Svc::InputPingPort *port)
Connect port to PingOut[portNum].
Drv::InputDataBufferPort * get_BufferIn_InputPort(FwIndexType portNum)
void PingIn_handlerBase(FwIndexType portNum, U32 key)
Handler base-class function for input port PingIn.
void set_Time_OutputPort(FwIndexType portNum, Fw::InputTimePort *port)
Connect port to Time[portNum].
void invoke(FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) const
Invoke a port interface.
Definition: TlmPortAc.cpp:163
bool isConnected() const
Definition: PortBase.cpp:42
FormatStatus format(const CHAR *formatString,...)
write formatted string to buffer
Definition: StringBase.cpp:55
FwIndexType getNum_BufferOut_OutputPorts() const
uint8_t U8
8-bit unsigned integer
Definition: BasicTypes.h:30
void init()
Initialization function.
BlockingType
message type
Definition: Queue.hpp:45
#define PRI_PlatformIntType
void set_BufferOut_OutputPort(FwIndexType portNum, Drv::InputDataBufferPort *port)
Connect port to BufferOut[portNum].
virtual void PingIn_preMsgHook(FwIndexType portNum, U32 key)
Pre-message hook for async input port PingIn.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: SchedPortAc.cpp:62
void CycleOut_out(FwIndexType portNum, Os::RawTime &cycleStart)
Invoke output port CycleOut.
PlatformQueuePriorityType FwQueuePriorityType
Definition: FpConfig.h:55
message to exit active component task
A message was sent requesting an exit of the loop.
void addCallPort(InputDataBufferPort *callPort)
Register an input port.
FwIndexType getNum_BufferIn_InputPorts() const
The size of the serial representations of the port arguments.
void invoke(Drv::DataBuffer &buff) const
Invoke a port interface.
void BufferIn_handlerBase(FwIndexType portNum, Drv::DataBuffer &buff)
Handler base-class function for input port BufferIn.
void BufferOut_out(FwIndexType portNum, Drv::DataBuffer &buff)
Invoke output port BufferOut.
#define FW_NUM_ARRAY_ELEMENTS(a)
number of elements in an array
Definition: BasicTypes.h:70
void init()
Initialization function.
Definition: PingPortAc.cpp:56
bool isConnected_PingOut_OutputPort(FwIndexType portNum)
void InterruptReport_internalInterfaceInvoke(U32 interrupt)
Internal interface base-class function for InterruptReport.
BlockDriverComponentBase(const char *compName="")
Construct BlockDriverComponentBase object.
message sent/received okay
Definition: Queue.hpp:31
U8 BYTE
byte type
Definition: BasicTypes.h:31
virtual void Sched_handler(FwIndexType portNum, U32 context)=0
Handler for input port Sched.
virtual void InterruptReport_internalInterfaceHandler(U32 interrupt)=0
Internal interface handler for InterruptReport.
void addCallComp(Fw::PassiveComponentBase *callComp, CompFuncPtr funcPtr)
Register a component.
Definition: PingPortAc.cpp:62
BYTE InterruptReportIntIfSize[sizeof(U32)]
void invoke(Os::RawTime &cycleStart) const
Invoke a port interface.
Message will return with status when space is unavailable.
Definition: Queue.hpp:47
FwIndexType getNum_CycleOut_OutputPorts() const
FwIndexType getNum_PingOut_OutputPorts() const
The size of the serial representations of the port arguments.
Definition: SchedPortAc.hpp:36
Status receive(U8 *destination, FwSizeType capacity, BlockingType blockType, FwSizeType &actualSize, FwQueuePriorityType &priority) override
receive a message from the queue through delegate
Svc::InputPingPort * get_PingIn_InputPort(FwIndexType portNum)
virtual void BufferIn_preMsgHook(FwIndexType portNum, Drv::DataBuffer &buff)
Pre-message hook for async input port BufferIn.
#define FW_ASSERT(...)
Definition: Assert.hpp:14
virtual void BufferIn_handler(FwIndexType portNum, Drv::DataBuffer &buff)=0
Handler for input port BufferIn.
U32 FwChanIdType
Definition: FpConfig.h:95