Surasak Nasuriwong / FileManager

Dependencies:   SDFileSystem

Dependents:   RwSDCard_Xml_GPS

Committer:
Lucyjungz
Date:
Wed May 18 10:46:16 2016 +0000
Revision:
10:a8003d357cf2
Parent:
7:ab015947e368
Child:
11:e21d4c5bfd1b
Support Var Type

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Lucyjungz 3:6e08d0bba1bb 1 /* ############### Constant Defination ################## */
Lucyjungz 3:6e08d0bba1bb 2
Lucyjungz 1:1f1f2b99756b 3 #define DEVICE_NAME "sd"
Lucyjungz 1:1f1f2b99756b 4
Lucyjungz 1:1f1f2b99756b 5 // DEVICE_NAME must be put in between "/" for file name
nsrwsurasak 0:a27e0d3581d1 6 #define SETUP_FILE_NAME "/sd/RMS_Tester.xml"
Lucyjungz 2:18e004a47f52 7 #define GPS_LOG_FILE_NAME "/sd/YYYY-MM-DD.gps.csv "
Lucyjungz 1:1f1f2b99756b 8 #define RTL_LOG_FILE_NAME "/sd/YYYY-MM-DD.rtl.csv"
nsrwsurasak 0:a27e0d3581d1 9 #define VARIABLE_FILE_NAME "/sd/20160216185627_upload.xml"
nsrwsurasak 0:a27e0d3581d1 10 #define MINIRMS_LOG_FILE_NAME "/sd/miniRMS.log"
nsrwsurasak 0:a27e0d3581d1 11
Lucyjungz 10:a8003d357cf2 12 #define GPS_TAG "<Gps>"
nsrwsurasak 0:a27e0d3581d1 13 #define DATA_TAG "<Data>"
nsrwsurasak 0:a27e0d3581d1 14 #define UPDATE_INTERVAL_TAG "<Update_Interval>"
nsrwsurasak 0:a27e0d3581d1 15 #define VAR_NAME_TAG "<varName>"
nsrwsurasak 0:a27e0d3581d1 16 #define VAR_ADDR_TAG "<varAddress>"
Lucyjungz 10:a8003d357cf2 17 #define VAR_TYPE_TAG "<varType>"
Lucyjungz 6:5bd75c0f607c 18 #define VAR_LSB1_TAG "<LSB1>"
Lucyjungz 6:5bd75c0f607c 19 #define VAR_LSB2_TAG "<LSB2>"
Lucyjungz 6:5bd75c0f607c 20 #define VAR_BITMASK_TAG "<BitMask>"
Lucyjungz 5:7c513eee7b2b 21 #define VAR_UNIT_TAG "<Unit>"
nsrwsurasak 0:a27e0d3581d1 22 #define XMLTEXT_SIZE 20
nsrwsurasak 0:a27e0d3581d1 23
nsrwsurasak 0:a27e0d3581d1 24 #define VAR_NAME_MAX_SIZE 20
nsrwsurasak 0:a27e0d3581d1 25 #define VAR_ADDR_MAX_SIZE 10
Lucyjungz 10:a8003d357cf2 26 #define VAR_TYPE_MAX_SIZE 3
Lucyjungz 6:5bd75c0f607c 27 #define VAR_LSB1_MAX_SIZE 3
Lucyjungz 6:5bd75c0f607c 28 #define VAR_LSB2_MAX_SIZE 10
Lucyjungz 6:5bd75c0f607c 29 #define VAR_BITMASK_MAX_SIZE 5
Lucyjungz 5:7c513eee7b2b 30 #define VAR_UNIT_MAX_SIZE 20
Lucyjungz 5:7c513eee7b2b 31
nsrwsurasak 0:a27e0d3581d1 32 #define MAX_VAR 50
nsrwsurasak 0:a27e0d3581d1 33
Lucyjungz 1:1f1f2b99756b 34 #define RMS_HEADER_TIME "Time"
Lucyjungz 7:ab015947e368 35 #define RMS_MSECOND "MSecond"
Lucyjungz 1:1f1f2b99756b 36
Lucyjungz 3:6e08d0bba1bb 37
Lucyjungz 3:6e08d0bba1bb 38 /* ############### Enum ################## */
nsrwsurasak 0:a27e0d3581d1 39 typedef enum {
nsrwsurasak 0:a27e0d3581d1 40 STATE_FINDING, /** Finding */
nsrwsurasak 0:a27e0d3581d1 41 STATE_FOUND_DATA, /** Found Data tag */
nsrwsurasak 0:a27e0d3581d1 42 STATE_FOUND_DATA_INTERVAL, /**< Found update internal of tag*/
nsrwsurasak 0:a27e0d3581d1 43 STATE_FOUND_GPS, /** Found GPS tag */
nsrwsurasak 0:a27e0d3581d1 44 STATE_FOUND_GPS_INTERVAL, /** Found update internal of GPS*/
nsrwsurasak 0:a27e0d3581d1 45 } ReadingFileState;
nsrwsurasak 0:a27e0d3581d1 46
nsrwsurasak 0:a27e0d3581d1 47
Lucyjungz 3:6e08d0bba1bb 48 /* ############### Structure ################## */
Lucyjungz 3:6e08d0bba1bb 49
nsrwsurasak 0:a27e0d3581d1 50 typedef struct {
nsrwsurasak 0:a27e0d3581d1 51 char varName[VAR_NAME_MAX_SIZE];
nsrwsurasak 0:a27e0d3581d1 52 char varAddress[VAR_ADDR_MAX_SIZE+1];
Lucyjungz 10:a8003d357cf2 53 char varType[VAR_TYPE_MAX_SIZE];
Lucyjungz 6:5bd75c0f607c 54 char varLSB1[VAR_LSB1_MAX_SIZE];
Lucyjungz 6:5bd75c0f607c 55 char varLSB2[VAR_LSB2_MAX_SIZE];
Lucyjungz 6:5bd75c0f607c 56 char varBitMask[VAR_BITMASK_MAX_SIZE];
Lucyjungz 5:7c513eee7b2b 57 char varUnit[VAR_UNIT_MAX_SIZE];
nsrwsurasak 0:a27e0d3581d1 58 } Variable_Data_TypeDef;
nsrwsurasak 0:a27e0d3581d1 59
Lucyjungz 3:6e08d0bba1bb 60
Lucyjungz 3:6e08d0bba1bb 61 /* ############### Function Prototype ################## */
Lucyjungz 4:ec62bf823914 62 void FileManager_ReadSetupFile();
Lucyjungz 4:ec62bf823914 63 void FileManager_DeleteFile(char filename[]);
Lucyjungz 4:ec62bf823914 64 int FileManager_GPSInterval();
Lucyjungz 4:ec62bf823914 65 int FileManager_DataInterval();
Lucyjungz 4:ec62bf823914 66 void FileManager_LogGPSData(time_t timestamp ,char lat[], char longti[]);
Lucyjungz 4:ec62bf823914 67 void FileManager_LogSystemData(float gps_interval);
Lucyjungz 4:ec62bf823914 68 Variable_Data_TypeDef * FileManager_ReadVarFile();
Lucyjungz 4:ec62bf823914 69 int FileManager_GetAmountVarList();
Lucyjungz 4:ec62bf823914 70 Variable_Data_TypeDef * FileManager_GetVarList();
Lucyjungz 4:ec62bf823914 71 void FileManager_LogRMSData(time_t timestamp ,float * var, int size);
Lucyjungz 4:ec62bf823914 72 void FileManager_LogRMSHeader(time_t timestamp);
Lucyjungz 4:ec62bf823914 73 bool FileManager_IsFileExist(char filename[]);