Skip to content

Instantly share code, notes, and snippets.

@sivabudh
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sivabudh/56228e0f4b86a1a115d6 to your computer and use it in GitHub Desktop.
Save sivabudh/56228e0f4b86a1a115d6 to your computer and use it in GitHub Desktop.
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