Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. switch (msgID){
  2. case END_CHARGE_REPORT_1_MSG:
  3. return processEndChargeReportMsg(msgID);
  4. case END_CHARGE_REPORT_2_MSG:
  5. return processEndChargeReportMsg(msgID);
  6. case END_CHARGE_REPORT_3_MSG:
  7. return processEndChargeReportMsg(msgID);
  8. case END_CHARGE_REQUEST_MSG:
  9. return processEndChargeRequestMsg(msgID);
  10.  
  11. case START_CHARGE_REPORT_1_MSG:
  12. return processStartChargeReportMsg(msgID);
  13. case START_CHARGE_REPORT_2_MSG:
  14. return processStartChargeReportMsg(msgID);
  15. case START_CHARGE_REPORT_3_MSG:
  16. return processStartChargeReportMsg(msgID);
  17.  
  18. class myCANMessages{
  19. virtual process()
  20. }
  21.  
  22. //Derived classes for each type of message group
  23. class startChargeMessageGroup : public myCANMessages{
  24. CANMessage fullMsgGroup[3];
  25. process(){
  26. load CANMessage into fullMsgGroup
  27. if(allMessagesReceived)
  28. parse(CANMessage)
  29. take_action(decoded data from CANMessage)
  30. }
  31. }
  32.  
  33. class endChargeMessageGroup : public myCANMessages{ ///etc...etc...
  34.  
  35. myCANMessages *polymorphPointer
  36.  
  37. while(1){
  38. CANMessage = readCANMessage();
  39.  
  40. --> somehow assign this automagically to correct derivedObject type
  41.  
  42.  
  43. polymorphPointer = &derivedObject;
  44. polymorphPointer->process
  45.  
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement