Accueil > > > uaemon/Control.h
LECTEUR DE GUIDES AUDIO GÉOLOCALISÉS
uaemon/Control.h
Informations sur ce code source
C'est un lecteur de guides touristiques audio géolocalisés. Les guides audio peuvent être préparés et téléchargés sur le site http://www.uaemon.com. Une fois sur place, les guides qui correspondent au lieu sont joués automatiquement, comme si il y av
Fichier : uaemon/Control.h
Nombre de lignes : 95 lignes
Afficher ce fichier en plein écran
- /*
- * Control.h
- *
- * Copyright (C) 2009 uaemon <uaemon@uaemon.com>
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
-
- #pragma once
-
- // The goal of Control class is to find a guide to play according to the current GPS position
-
- // After downloading the guides from http://www.uaemon.com, the web server provides a file
- // which contains the list of guides's information (guideCollectionFileName)
- // The guide files are given separately
-
- // On receiving a location information from GPS, the best guide name is retrieved from "guideCollectionFileName",
- // then the guide is played
-
- // According to the listener's reaction (pause, stop etc), the statistics are collected and saved.
- // The already played guides will not be retrieved from web server next time according to these saved information
-
- // #define GUIDE_FILE_NAME_LENGTH 18 // name: 14, plus ".", plus extension: 3
- #define GUIDE_LIST_FIELD_LENGTH 24 // same field length for all elements of a guide entry
- #define DEFAULT_INSTALLATION_DIRECTORY "\\Storage Card\\uaemon\\"
- #define DEFAULT_CONFIGURATION_FILE_NAME "uaemon_setup.txt" // in the same directory as executable
- #define DEFAULT_GUIDE_COLLECTION_FILE_NAME "guide_list.txt"
- #define DEFAULT_PLAYED_GUIDE_FILE_NAME "played_list.txt"
- #define DEFAULT_GUIDE_INSTALL_DIRECTORY "guides\\"
- // #define ACCEPTABLE_DISTANCE 100 // 100 meters
- extern int ACCEPTABLE_DISTANCE;
-
- typedef struct {
- unsigned char majorVersion[2];
- unsigned char minorVersion[2];
- } guideFirstEntry;
-
- typedef struct {
- char archName[GUIDE_LIST_FIELD_LENGTH];
- char guideName[GUIDE_LIST_FIELD_LENGTH];
- char guideOrigineName[GUIDE_LIST_FIELD_LENGTH];
- char lng[GUIDE_LIST_FIELD_LENGTH];
- char lat[GUIDE_LIST_FIELD_LENGTH];
- char duration[8]; // in hh:mm:ss
- char radius[8]; // in meters
- } guideEntry;
-
- typedef union {
- guideFirstEntry firstElt;
- guideEntry elt;
- } guideListEntry;
-
- class Control
- {
- public:
- Control(void);
- Control(char *instDir);
- ~Control(void);
-
- // inputs: lng & lat the position given by GPS; output: the best guide if found, or NULL if no acceptable guide found
- guideEntry *getGuide(double lng, double lat, double *dist);
- void playedGuide(guideEntry *theGuide, int playedTime); // playedTime = -1 means the guide is completely played
-
- private:
- bool isPlayed(guideEntry *theGuide);
- double toRadians(double degree);
- double toDegrees(double radian);
- double distance(double lat1, double lon1, double lat2, double lon2);
-
- guideEntry guide;
- guideListEntry guideConfig;
- char guideCollectionFileName[MAX_PATH]; // file name which contains the list of guides's information
- char guidePlayedFileName[MAX_PATH]; // file name which contains the list of guides's information
- char instalDir[MAX_PATH];
- FILE *guideCollectionFileHandler;
- FILE *guidePlayedFileHandler;
- double Pi;
- };
|