Dependents:   ShootingSystem

AmmoPusher.h

Committer:
inst
Date:
2015-10-14
Revision:
2:5ec2a3097d4c
Parent:
1:42d2772575c5

File content as of revision 2:5ec2a3097d4c:

#ifndef INCLUDED_AMMO_PUSHER_H
#define INCLUDED_AMMO_PUSHER_H

#include "mbed.h"
#include "I2CDevice.h"

class AmmoPusher : public I2CDevice{
public:
    enum ActionType{
        NO_OPERATION,
        DRAWING,
        PUSHING
    };
    enum State{
        BETWEEN,
        HAS_FINISHED_DRAWING,
        HAS_FINISHED_PUSHING
    };

    AmmoPusher( char address );
    
    void push(){
        setActionType( PUSHING );
    }
    void draw(){
        setActionType( DRAWING );
    }
    void setActionType( ActionType action ){
        mActionType = action;
    }
    State getState(){
        return mState;
    }
    bool isWorking(){
        return ( ( mState == BETWEEN ) && ( mActionType != NO_OPERATION ) );
    }
    bool hasPushed(){
        return ( mState ==  HAS_FINISHED_PUSHING );
    }
    bool hasDrawn(){
        return ( mState ==  HAS_FINISHED_DRAWING );
    }
    
    virtual int write();
    virtual int read();
    
private:
    ActionType mActionType;
    State mState;
};

#endif