Weather casting with Machine Learning (SVM and SRNN).
Dependencies: EthernetInterface GraphicHandler NTPClient SRNN SVM SensorModule mbed-rtos mbed
Diff: setup.cpp
- Revision:
- 4:00da8e8c7e2a
- Parent:
- 3:5add3759e08a
- Child:
- 5:b61f3f5b0fc8
diff -r 5add3759e08a -r 00da8e8c7e2a setup.cpp --- a/setup.cpp Thu Feb 19 08:20:46 2015 +0000 +++ b/setup.cpp Thu Feb 19 13:53:12 2015 +0000 @@ -94,6 +94,7 @@ int line = 0; while( ( ret = fscanf( srnn_setup_fp, " %[^\n,],%f,%f,%f", buf_str, &(buf_data[0]), &(buf_data[1]), &(buf_data[2])) ) != EOF ) { + if ( line == LEN_DATA_SEQUENCE ) break; memcpy(&(sample[line * DIM_SIGNAL]), buf_data, sizeof(float) * DIM_SIGNAL); // printf("sample %d : %f %f %f \r\n", line, MATRIX_AT(sample,DIM_SIGNAL,line,0), MATRIX_AT(sample,DIM_SIGNAL,line,1), MATRIX_AT(sample,DIM_SIGNAL,line,2)); line++; @@ -156,7 +157,7 @@ // グラフィックハンドラの初期化 static void graphic_handler_setup(void) { - graphic_handler = new GraphicHandler(DIM_SIGNAL, PREDICT_INTERVAL_TIME, PREDICT_LENGTH, get_JST()); + graphic_handler = new GraphicHandler(DIM_SIGNAL, PREDICT_INTERVAL_TIME, PREDICT_LENGTH, time(NULL)); } // データの初期化(アロケート) @@ -168,6 +169,25 @@ new_predict_probability = new float[PREDICT_LENGTH]; // 現在の予測天気の確率 } +// 時刻の設定 +static void jst_setup(int year, int month, int day, int hour, int min) +{ + // setup time structure + if ( time(NULL) == 0 ) { + struct tm t; + t.tm_sec = 0; // 0-59 + t.tm_min = min; // 0-59 + t.tm_hour = hour; // 0-23 + t.tm_mday = day; // 1-31 + t.tm_mon = (month-1); // 0-11 + t.tm_year = (year-1900); // year since 1900 + + // convert to timestamp and set + time_t seconds = mktime(&t); + set_time(seconds); + } +} + // セットアップ. void setup(void) { @@ -179,9 +199,9 @@ printf("SRNN ...OK \r\n"); sensor_setup(); printf("SENSOR ...OK \r\n"); - //network_setup(); - set_time(time(NULL)); - printf("NETWORK ...NO(offline) \r\n"); + // network_setup(); + jst_setup(2015, 2, 19, 21, 30); + // printf("NETWORK ...NO(offline) \r\n"); graphic_handler_setup(); printf("GRAPHIC ...OK \r\n"); data_setup();