//
// VAIBODef.h
//
// Copyright 2004 Sony Corporation
//

#ifndef _VAIBODEF_
#define _VAIBODEF_


#define     AIBO_VOLUME_MIN     ( 0 )   
#define     AIBO_VOLUME_MAX     ( 3 )   


// Error code
#define VAIBO_NOERROR           0               // No error
#define VAIBO_READY             1               // Ready to send command/data
#define VAIBO_NOTSTART          -10             // Not started
#define VAIBO_WORKING           -11             // Already working
#define VAIBO_MEMERR            -12             // Memory allocation failed
#define VAIBO_SERVERSTOP        -13             // server stopped
#define VAIBO_PORT_NOTOPEN      -20             // Cannot open communication port
#define VAIBO_PORT_OPENERR      -21             // Error opening communication port
#define VAIBO_NSM_ERROR         -22             // NSM starting error
#define VAIBO_CONNECTION_BUSY	-23             // It is dealing with a connection
#define VAIBO_COMM_NOREPLY      -30             // No reply of a command
#define VAIBO_COMM_COMMERR      -31             // command error
#define VAIBO_COMM_PAUSE        -32             // command paused
#define VAIBO_COMM_WAIT         -33             // command waiting
#define VAIBO_COMM_IGNORE       -34             // command ignored
#define VAIBO_COMM_TIMEOUT      -35             // command timeout
#define VAIBO_COMM_LOCK         -36             // server locked
#define VAIBO_COMM_RESTRICTION  -37				// command restriction
#define VAIBO_COMM_BUSY			-38				// command busy
#define VAIBO_FILE_SEADERR      -42             // file send error
#define VAIBO_FILE_OPENERR      -43             // file open error
#define VAIBO_FILE_MAKEERR      -44             // file creation error
#define VAIBO_FILE_READERR      -45             // file read error
#define VAIBO_FILE_WRITEERR     -46             // file write error
#define VAIBO_LIMIT_MWCID       -50             // cannot use MWCID
#define VAIBO_VPRFILE_NOEXIST   -60             // VPR file is not registered

#define IMAGETP_NOERROR         0               // No error
#define IMAGETP_INITERR         -101            // initialization error
#define IMAGETP_OPENERR         -102            // cannot open
#define IMAGETP_NOTOPEN         -103            // it is not opened 
#define IMAGETP_MEMERR          -104            // Memory allocation failed
#define IMAGETP_CREATEERR       -105            // creation error
#define IMAGETP_DATAERR         -106            // data error
#define IMAGETP_SAVEERR         -107            // save error

#define IMAGETP_STATE_ERR       -110            // unexpected error
#define IMAGETP_WORKING         -120            // Already working

#define IMAGETP_STATE_CLOSE     -150            // CLOSE
#define IMAGETP_STATE_INIT      -151            // finished INIT
#define IMAGETP_STATE_OPEN      -152            // finished OPEN
#define IMAGETP_STATE_SERVICE   -153            // start SERVICE
#define IMAGETP_STATE_PAUSE     -154            // pause
#define IMAGETP_STATE_PLAY      -155            // data translation


#define AUDIOTP_NOERROR         0               // No error
#define AUDIOTP_INITERR         -201            // initialize error
#define AUDIOTP_OPENERR         -202            // cannot open
#define AUDIOTP_NOTOPEN         -203            // it is not opened
#define AUDIOTP_MEMERR          -204            // Memory allocation failed
#define AUDIOTP_CREATEERR       -205            // creation error
#define AUDIOTP_DEVICEERR       -206            // device open error
#define AUDIOTP_SENDERR         -207            // sending data error

#define AUDIOTP_STATE_ERR       -210            // unexpected error
#define AUDIOTP_WORKING         -220            // Already working

#define AUDIOTP_STATE_CLOSE     -250            // CLOSE
#define AUDIOTP_STATE_INIT      -251            // finished INIT
#define AUDIOTP_STATE_OPEN      -252            // finished OPEN
#define AUDIOTP_STATE_SERVICE   -253            // start SERVICE
#define AUDIOTP_STATE_PAUSE     -254            // pause
#define AUDIOTP_STATE_PLAY      -255            // data translation

#define SENSORTP_NOERROR        0               // No error

#define SENSORTP_STATE_ERR      -310            // unexpected error
#define SENSORTP_WORKING        -320            // Already working
#define SENSORTP_NOTSTART       -330            // Not started

#define SENSORTP_STATE_CLOSE    -350            // CLOSE
#define SENSORTP_STATE_SERVICE  -351            // start SERVICE
#define SENSORTP_STATE_PAUSE    -352            // pause
#define SENSORTP_STATE_PLAY     -353            // data translation

#define FTP_STATE_ERR           -410            // unexpected error
#define FTP_WORKING             -420            // Already working

// type of SEM_RESULT message
#define RESULT_COMPLETE         1               // command complete
#define RESULT_INCOMPLETE       2               // command incomplete
#define RESULT_UNKNOWN          3               // command unknown
#define RESULT_FOLLOWFAIL       4               // follow fail
#define RESULT_FOLLOWSTART      5               // follow start
#define RESULT_FOLLOWEND        6               // follow finished

// type of SEM_FINISHED message
#define FINISHED_COMPLETE       1               // command complete
#define FINISHED_INCOMPLETE     2               // command incomplete
#define FINISHED_UNKNOWN        3               // command unknown

// type of SEM_ERROR
#define ERROR_LOOKUP_IMAGETP    0x0001          // ImgageTP service look up error
#define ERROR_REQ_IMAGETP       0x0002          // ImgageTP service connection request error
#define ERROR_LOOKUP_AUDIOIN    0x0011          // AudioTP(In) service look up error
#define ERROR_REQ_AUDIOIN       0x0012          // AudioTP(In) service connection request error
#define ERROR_LOOKUP_NETAUDIO   0x0015          // NetAudio(Out) service look up error
#define ERROR_REQ_NETAUDIO      0x0016          // NetAudio(Out) service connection request error
#define ERROR_LOOKUP_FTP        0x0021          // FTP service look up error
#define ERROR_REQ_FTP           0x0022          // FTP service connection request error
#define ERROR_LOOKUP_SENSOR     0x0023          // SensorTP service look up error
#define ERROR_REQ_SENSOR        0x0024          // SensorTP service connection request error

// Windows Message ：WPARAM
#define SEM_STATUS              0x0001
#define SEM_START               0x0002
#define SEM_DONE                0x0003
#define SEM_ERROR               0x0004
#define SEM_RESULT              0x0005
#define SEM_FINISHED            0x0006
#define SEM_VERSION             0x0007

// SEM_STATUS Message ：lParam upper word (posture information)
#define ST_POS_UNKNOWN          0xFF00          // Unknown
#define ST_POS_TEMP             0x00FF          // Tempolary
#define ST_POS_UNDEFINE         0xFFFF          // Undefined
#define ST_POS_STAND            0x0001          // STAND
#define ST_POS_SIT              0x0002          // SIT
#define ST_POS_LIE              0x0003          // LIE
#define ST_POS_WALK             0x0004          // WALK
#define ST_POS_STATION          0x0005          // STATION
#define ST_POS_PSTATION         0x0006          // STATION
#define ST_POS_LIFT             0x0007          // Lift
#define ST_POS_NEUTRAL          0x0100          // Neutral
#define ST_POS_SHUTDOWN         0x0064          // 
#define ST_POS_FALLDOWN         0x1000          // 
#define ST_POS_MECHALOAD_H      0x2000          // Mecha load high
#define ST_POS_JAM              0x3000          // 

// SEM_STATUS Message ：lParam lower word (status)
#define ST_STAT_UNKNOWN         0xFFFF          // Unknown
#define ST_STAT_DEFAULT         0x0001          // Stable
#define ST_STAT_PLAY_WAV        0x0002          // Playing WAVE
#define ST_STAT_PLAY_STREAM     0x0003          // Playing stream audio
#define ST_STAT_PLAY_MOTION     0x0004          // Playing motion
#define ST_STAT_POS_CHANGE      0x0005          // changing posture
#define ST_STAT_WALK_SLOW       0x0030          // Walking(Slow)
#define ST_STAT_WALK_NORMAL     0x0031          // Walking(Normal)
#define ST_STAT_WALK_FAST       0x0032          // Walking(Fast)
#define ST_STAT_WALK_BACK       0x0033          // Walking(Back)
#define ST_STAT_TURN_L_SLOW     0x0034          // Walking(Left Turn,Slow)
#define ST_STAT_TURN_L_NORMAL   0x0035          // Walking(Left Turn,Normal)
#define ST_STAT_TURN_L_FAST     0x0036          // Walking(Left Turn,Fast)
#define ST_STAT_TURN_R_SLOW     0x0037          // Walking(Right Turn,Slow)
#define ST_STAT_TURN_R_NORMAL   0x0038          // Walking(Right Turn,Normal)
#define ST_STAT_TURN_R_FAST     0x0039          // Walking(Right Turn,Fast)

// SEM_START Message  ：lParam lower word
#define START_COMM_SESSION      0x0010          // Starting session
#define START_NSM_CONNECTION    0x0011          // Starting NSM connection
#define START_SHUTDOWN          0x0064          // Notice shutdown
#define START_IMAGETP           0x0100          // Starting ImageTP service
#define START_AUDIOINTP         0x0200          // Starting AudioTP(In) service
#define START_FTP               0x0400          // Starting FTP service
#define START_SENSORTP          0x0500          // Starting SensorTP service
#define START_NETAUDIO          0x0600          // Starting NetAudio(Out) service

// SEM_DONE Message ：lParam lower word
#define DONE_SEND_CMD           0x0000          // Complete SendCmd
#define DONE_CHANGE_HEAD        0x0001          // Complete ChangeHeadAngle
#define DONE_KICK               0x0002          // Complete DoKick
#define DONE_HEADER             0x0003          // Complete DoHeader
#define DONE_WALKING            0x0004          // Complete DoWalking
#define DONE_SET_POSTURE        0x0005          // Complete SetPosture
#define DONE_SEND_WAV           0x0006          // Complete Send WAV
#define DONE_PLAY_WAV           0x0007          // Complete Play WAV
#define DONE_PLAY_MOTION        0x0008          // Complete PlayMotion
#define DONE_TURN_BODY          0x0009          // Complete TurnBody
#define DONE_SET_CLOCK          0x000B          // Complete SetClock
#define DONE_NETAUDIO           0x000C          // Complete NetAudio

// APP command 
// CVAIBO::SendCmd(int cmd, BOOL waitF, int nParam1, int nParam2, int nParam3, int nParam4)
#define APPCMD_RELOAD               0x0001      // WAV data reload ; Reload should be called before playing WAV
#define APPCMD_PLAY_WAV             0x0002      // Play WAV ; The WAV data should be translated by FTPMMSendWAVFile()
#define APPCMD_PLAY_STOP            0x0003      // stop playing WAV
#define APPCMD_REPEAT               0x0004      // repeat playing WAV
#define APPCMD_WAV_CLEAR            0x0005      // clear WAV
#define APPCMD_TAKE_PICTURE         0x0006      // Play take picture motion
#define APPCMD_SHUTDOWN             0x0007      // shutdown
#define APPCMD_REBOOT               0x0008      // reboot

// APP command for ImageTP
#define APPCMD_IMAGE_PLAY           0x0021      // Play
#define APPCMD_IMAGE_STOP           0x0022      // Stop
#define APPCMD_IMAGE_SETPARAM       0x0023      // Control

// APPCMD_IMAGE_SETPARAM : nParam1
#define CMDSID_PROFILE          0x00000001      // profile
#define CMDSID_LEVEL            0x00000002      // 
#define CMDSID_QUALITY          0x00000003      // 
#define CMDSID_SKIPFRAME        0x00000004      // skip frame
#define CMDSID_LOOKUPLIMITTER   0x00000005      //
// APPCMD_IMAGE_SETPARAM : nParam2
#define IMAGE_PROFILE_LOW           (   1 )     // Image size 102x79
#define IMAGE_PROFILE_MID           (   2 )     // Image size 204x159
#define IMAGE_PROFILE_HIGH          (   3 )     // Image size 412x318
#define IMAGE_QUALITY_LOW           ( 100 )     // Low quality (data size small)
#define IMAGE_QUALITYT_MID          (  60 )     // Middle quality
#define IMAGE_QUALITY_HIGH          (  30 )     // High quality (data size large)

// APP(AudioTP) command
#define APPCMD_AUDIO_RECV_START     0x0040      // Receive data; AudioTP(AIBO->PC) start
#define APPCMD_AUDIO_RECV_STOP      0x0041      // Receive data; AudioTP(AIBO->PC) stop
#define APPCMD_AUDIO_RECV_MODE      0x0042      // Receive data; AudioTP(AIBO->PC) change data mode
#define APPCMD_AUDIO_SPPLAY_START   0x0046      // Send data; NetAudio(PC->AIBO) start
#define APPCMD_AUDIO_SPPLAY_STOP    0x0047      // Send data; NetAudio(PC->AIBO) stop
#define APPCMD_AUDIO_SPPLAY_CHMOD   0x0048      // Send data; NetAudio(PC->AIBO) change data mode

// APPCMD_AUDIO_RECV_MODE    : nParam1
// APPCMD_AUDIO_SPPLAY_CHMOD : nParam1
#define ATP16K_16BIT_STEREO         0           // 16kHz,16Bit,Stereo
#define ATP16K_16BIT_MONO_L         1           // 16kHz,16Bit,Mono Left
#define ATP16K_16BIT_MONO_R         2           // 16kHz,16Bit,Mono Right
#define ATP16K_16BIT_MONO_MIX       3           // 16kHz,16Bit,Mono Mix
#define ATP8K_16BIT_STEREO          4           // 8kHz,16Bit,Stereo
#define ATP8K_16BIT_MONO_L          5           // 8kHz,16Bit,Mono Left
#define ATP8K_16BIT_MONO_R          6           // 8kHz,16Bit,Mono Right
#define ATP8K_16BIT_MONO_MIX        7           // 8kHz,16Bit,Mono Mix
#define ATP16K_8BIT_STEREO          8           // 16kHz,8Bit,Stereo
#define ATP16K_8BIT_MONO_L          9           // 16kHz,8Bit,Mono Left
#define ATP16K_8BIT_MONO_R          10          // 16kHz,8Bit,Mono Right
#define ATP16K_8BIT_MONO_MIX        11          // 16kHz,8Bit,Mono Mix
#define ATP8K_8BIT_STEREO           12          // 8kHz,8Bit,Stereo
#define ATP8K_8BIT_MONO_L           13          // 8kHz,8Bit,Mono Left
#define ATP8K_8BIT_MONO_R           14          // 8kHz,8Bit,Mono Right
#define ATP8K_8BIT_MONO_MIX         15          // 8kHz,8Bit,Mono Mix

// DisconnectMode
// CVAIBO::ChangeDisconnectMode( int nMode );
// nMode
#define DISCONNECT_MODE_AUTONOMY            ( 1 )       // Autonomy when network disconnected
#define DISCONNECT_MODE_SAFTY               ( 3 )       // Keep safty posture(sleep) when network disconnected
#define DISCONNECT_MODE_SAFTYSHUTDOWN       ( 4 )       // AIBO Shutdown when network disconnected

// Camera control
// CVAIBO::CameraSetModeManual( int nShutterSpeed, int nExposure );
// CVAIBO::CameraSetParamExposure( int nExposure );
// CVAIBO::CameraSetParamShutterSpeed( int nShutterSpeed );
// nShutterSpeed
#define CAMERA_SHUTTERSPEED_MIN             ( 0 )                           // Shutter speed min.  
#define CAMERA_SHUTTERSPEED_MAX             ( 524 )                         // Shutter speed max. 
#define CAMERA_SHUTTERSPEED_PER_10MS        ( 158 )                         // Shutter speed 1/100[sec] = 10[ms] 
#define CAMERA_SHUTTERSPEED_PER_20MS        ( 316 )                         // Shutter speed 1/ 50[sec] = 20[ms] 
#define CAMERA_SHUTTERSPEED_DEFAULT         CAMERA_SHUTTERSPEED_PER_20MS    // Shutter speed default
// nExposure
#define CAMERA_EXPOSURE_MIN                 ( 0 )                           // Exposure min. 
#define CAMERA_EXPOSURE_MAX                 ( 24 )                          // Exposure max. 
#define CAMERA_EXPOSURE_DEFAULT             ( 6 )                           // Exposure default


// RequestNetService parameter
enum {
    FTP_ID = 0,
    SENSOR_ID, IMAGE_ID, AUDIO_IN_ID, NETAUDIO_ID
};


// Windows Message for network connected
// Client <--> Server
// WPARAM  HiWord=AiboID LowWord=0   LPARAM application ID
static const UINT WM_VAIBO_CONNECT = RegisterWindowMessage(_T("SonyERCVAIBOConnect"));

// Windows Message for network disconnected
// Client <--> Server
// WPARAM  HiWord=AiboID LowWord=0   LPARAM application ID
static const UINT WM_VAIBO_DISCONNECT = RegisterWindowMessage(_T("SonyERCVAIBODisconnect"));

// Windows Message for sending semantics
// Client <-- Server
// WPARAM  HiWord=AiboID LowWord=type  LPARAM contents
static const UINT WM_VAIBO_SEMANTICS = RegisterWindowMessage(_T("SonyERCVAIBOSemantics"));

// Windows Message for sending InputSemantics
// Client <-- Server
// WPARAM  HiWord=AiboID LowWord=0     LPARAM 0
static const UINT WM_VAIBO_INPUT_SEMANTICS = RegisterWindowMessage(_T("SonyERCVAIBOInputSemantics"));

// Windows Message for sending sensor data
// Client <-- Server
// WPARAM  HiWord=AiboID LowWord=nNumOfData  LPARAM *SensorRec data
static const UINT WM_VAIBO_SENSOR_DATA = RegisterWindowMessage(_T("SonyERCVAIBOSensorData"));

// Windows Message for sending result (Enable)
// Client <-- Server
// WPARAM  HiWord=AiboID LowWord=type  LPARAM contents
static const UINT WM_VAIBO_SENSOR_ENABLE = RegisterWindowMessage(_T("SonyERCVAIBOSensorEnable"));

//  Windows Message for sending result (Disable)
// Client <-- Server
// WPARAM  HiWord=AiboID LowWord=type  LPARAM contents
static const UINT WM_VAIBO_SENSOR_DISABLE = RegisterWindowMessage(_T("SonyERCVAIBOSensorDisable"));

// Windows Message for sending lock/unlock server status
// Client <-- Server
// WPARAM  HiWord=AiboID LowWord=0   LPARAM  0(unlocked) or 1(locked)
static const UINT WM_VAIBO_LOCK = RegisterWindowMessage(_T("SonyERCVAIBOServerLock"));

// Windows Message for sharing server
// Client <-- Server
// WPARAM  HiWord=AiboID LowWord=1(Increase) or 0(Decrease)  LPARAM Client window handle
static const UINT WM_VAIBO_CLIENT_UPDATE = RegisterWindowMessage(_T("SonyERCVAIBOClientUpdate"));

// Windows Message for FTP service (send data size of ftp)
// Client <-- Server
// WPARAM  HiWord=AiboID LowWord=0   LPARAM Data size 
static const UINT WM_MMFTP_SENDING = RegisterWindowMessage(_T("SonyERCMMFTPSending"));

// Windows Message for JPEG decode completed
// Server --> Client
// WPARAM  HiWord=AiboID LowWord=0   LPARAM Data size 
static const UINT WM_IMAGETP_UPDATE = RegisterWindowMessage(_T("SonyERCImageTPUpdate"));

// Windows Message for JPEG decode completed
// Server --> Client
// WPARAM  HiWord=AiboID LowWord=0   LPARAM Data size 
static const UINT WM_IMAGETP_UPDATE2 = RegisterWindowMessage(_T("SonyERCImageTPUpdate2"));

// Windows Message for changing ImageTP mode
// Server --> Client
// WPARAM  kind  LPARAM value
static const UINT WM_IMAGETP_CHANGE = RegisterWindowMessage(_T("SonyERCImageTPChange"));

// Windows Message for getting WAVE packet
// Server --> Client
// WPARAM  HiWord=AiboID LowWord=0   LPARAM Data size 
static const UINT WM_AUDIOTP_UPDATE = RegisterWindowMessage(_T("SonyERCAudioTPUpdate"));

// Windows Message for getting ProductID
// Server --> Client
// WPARAM  HiWord=AiboID LowWord=0   LPARAM 0
//
static const UINT WM_VAIBO_PRODUCTID = RegisterWindowMessage(_T("SonyERCVAIBOProductID"));

// Windows Message for changing battery level
// Server --> Client
// WPARAM  HiWord=AiboID LowWord=0   LPARAM Battery level
static const UINT WM_VAIBO_BATTERY_LVL = RegisterWindowMessage(_T("SonyERCVAIBOBatteryLevel"));

// Windows Message for changing control status
// Client <-- Server
// WPARAM  HiWord=AiboID LowWord=0   LPARAM 0:InternalControl  1: ExternalControl
static const UINT WM_VAIBO_REMOTE_NOTIFY = RegisterWindowMessage(_T("SonyERCVAIBORemoteNotify"));


#define     CLIENTMAX           10
#define     AIBOMAX             16

// Autonomy services
enum E_ROBOTOBJECT {
    eRobotObjectRognizeAudio,           // Voice recognition
    eRobotObjectRecognizeMObject,       // Moving objects recognition
    eRobotObjectDetectiveFace,          // Face detection
    eRobotObjectRecognizeFace,          // Face recognition
    eRobotObjectRecognizeVisualPattern, // Visual patter recognition
    eRobotObjectRecognizeObjectPink,    // Target(PINK) recognition
    eRobotObjectRecognizeCliff,         // Cliff detect
    eRobotObjectRecognizeSpeaker,       // Speaker recognition
    eRobotObjectMax
};

// Status of  Autonomy service
enum E_ROBOTOBJECTMODE {
    eRobotObjectModeStart,
    eRobotObjectModeStop
};


// Sensor Data 
typedef struct SensorRec {
    int             sensorID;
    unsigned long   value;
    long            percentage_x;
    long            percentage_y;
} SensorRec, *SensorRecP;


// Product Info 
typedef struct ProductInfo {
    WORD            formatMajorVer;
    WORD            formatMinorVer;
    WORD            vendorID;
    WORD            majorVer;
    WORD            minorVer;
    WORD            langCode;
    WORD            languageCode;
    WORD            reserved;
} ProductInfo;


// MAC Address 
struct MACAddressInfo {
    char    strAddress[ 18 ];   // include terminate character
};


#endif  // define _VAIBODEF_
