How to determine states for the State pattern
===

I'm developing a DLL that is used to control a POS (Point of sale) terminal via LAN.

The DLL provides commands to perform operations such as:

- Logon
- Logoff
- Authorisation
- Read card data
- Cancellation
- Refund
- Network diagnosis

Also the DLL provides Connect() and Disconnect() functions.

As the POS terminal can be in various states, I'm thinking the State pattern might be used in the DLL.

Pseudo code:

    // My DLL
    class Pos
    {
    public:
        Pos();
        ~Pos();
        
        bool Connect();
        bool Disconnect();
        
        bool DoLogon() { m_pCurrentPosState->DoLogon(this); }
        bool DoLogoff() { m_pCurrentPosState->DoLogoff(this); }
        bool DoAuthorisation() { m_pCurrentPosState->DoAuthorisation(this); }
        bool DoReadCardData() { m_pCurrentPosState->DoReadCardData(this); }
        bool DoCancellation() { m_pCurrentPosState->DoCancellation(this); }
        bool DoRefund() { m_pCurrentPosState->DoRefund(this); }
        bool DoNetworkDiagnosis() { m_pCurrentPosState->DoNetworkDiagnosis(this); }
        ...

    private:
        void ChangeState(PosState *pPosState) { m_pCurrentPosState = pPosState; }

    private:
        friend class PosState;
        PosState *m_pCurrentPosState;
        ...
    };

    class PosState
    {
    public:
        // Implement default behavior for all command requests.
        virtual bool DoLogon(Pos *pPos) {}
        virtual bool DoLogoff(Pos *pPos) {}
        virtual bool DoAuthorisation(Pos *pPos) {}
        virtual bool DoReadCardData(Pos *pPos) {}
        virtual bool DoCancellation(Pos *pPos) {}
        virtual bool DoRefund(Pos *pPos) {}
        virtual bool DoNetworkDiagnosis(Pos *pPos) {}

    protected:
        void ChangeState(Pos *pPos, PosState *pPosState);
    };

    class PosLoggedon : public PosState
    {
    public:
        static PosState* Instance();

        // Implement state-specific behavior.
        bool DoLogoff(Pos *pPos);
        bool DoAuthorisation(Pos *pPos);
        bool DoReadCardData(Pos *pPos);
        bool DoCancellation(Pos *pPos);
        bool DoRefund(Pos *pPos);
        bool DoNetworkDiagnosis(Pos *pPos);
    };

    class PosLoggedoff : public PosState
    {
    public:
        static PosState* Instance();

        // Implement state-specific behavior.
        bool DoLogon(Pos *pPos);
        bool DoAuthorisation(Pos *pPos);
        bool DoReadCardData(Pos *pPos);
        bool DoCancellation(Pos *pPos);
        bool DoRefund(Pos *pPos);
        bool DoNetworkDiagnosis(Pos *pPos);
    };

Both **PosLoggedon** and **PosLoggedoff** are two states I could think of as valid but I'm not sure how to determine others.
	
Does it make sense to create states like **PosAuthorisation**, **PosReadCardData** etc so that they correspond to the POS functions?  Probably it doesn't make sense...

I'm confused as to how to use the State pattern correctly because I'm mixing "current command in progress" and "current POS state".

Perhaps I need a state like **PosCommandInProgress**?

Any advice would be appreciated.

Many thanks.