Last active
August 29, 2015 14:23
-
-
Save sivabudh/56228e0f4b86a1a115d6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class FixedPrecisionDecimal | |
{ | |
const int number; // 1234.5678 | |
FixedPrecisionDecimal(float) | |
{ | |
} | |
FixedPrecisionDecimal(double) | |
{ | |
} | |
float getFloat() | |
{ | |
return processAsFloat(number); | |
} | |
double getDouble() | |
{ | |
return processAsDouble(number); | |
} | |
}; | |
// Unified message | |
class Message { | |
enum MessageType { | |
Authorize, | |
FillGas, | |
}; | |
private MessageType msgType; | |
auto getType() const { | |
return msgType; | |
} | |
}; | |
// Unified message | |
class AuthorizeMsg : Message | |
{ | |
auto getPumpId() | |
{ | |
return 1; | |
} | |
auto getStationId() | |
{ | |
return 1023; | |
} | |
}; | |
class TatsunoHandler : QThread | |
{ | |
public slots: | |
// This slots gets called whenever there's a new message from POS | |
void newMessage(Message * msg) | |
{ | |
// | |
switch(msg->getType()){ | |
case Authorize: | |
auto authorizeMsg = dynamic_cast< AuthorizeMsg * >msg; | |
// do Tatsuno "authorize" processing here | |
break; | |
} | |
} | |
// "tatsuno, authorize, 5.00" | |
// "tatsun, authorize, 5.00" | |
void newMessage(QString const msg) | |
{ | |
} | |
def newMessage(msg): | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment