Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- switch (msgID){
- case END_CHARGE_REPORT_1_MSG:
- return processEndChargeReportMsg(msgID);
- case END_CHARGE_REPORT_2_MSG:
- return processEndChargeReportMsg(msgID);
- case END_CHARGE_REPORT_3_MSG:
- return processEndChargeReportMsg(msgID);
- case END_CHARGE_REQUEST_MSG:
- return processEndChargeRequestMsg(msgID);
- case START_CHARGE_REPORT_1_MSG:
- return processStartChargeReportMsg(msgID);
- case START_CHARGE_REPORT_2_MSG:
- return processStartChargeReportMsg(msgID);
- case START_CHARGE_REPORT_3_MSG:
- return processStartChargeReportMsg(msgID);
- class myCANMessages{
- virtual process()
- }
- //Derived classes for each type of message group
- class startChargeMessageGroup : public myCANMessages{
- CANMessage fullMsgGroup[3];
- process(){
- load CANMessage into fullMsgGroup
- if(allMessagesReceived)
- parse(CANMessage)
- take_action(decoded data from CANMessage)
- }
- }
- class endChargeMessageGroup : public myCANMessages{ ///etc...etc...
- myCANMessages *polymorphPointer
- while(1){
- CANMessage = readCANMessage();
- --> somehow assign this automagically to correct derivedObject type
- polymorphPointer = &derivedObject;
- polymorphPointer->process
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement