mirror of
https://gitlab.com/Luci_/arduino-photometrics.git
synced 2026-04-03 03:25:36 +02:00
fixe get_measure for theses test
This commit is contained in:
parent
7cda108dea
commit
3975f3d95c
|
|
@ -353,10 +353,13 @@ void Storage_interface::get_measure(uint8_t* array_photo_val, uint8_t* array_tem
|
|||
get_nb_photo_sensor(p_last_header, nb_photo);
|
||||
get_nb_temp_sensor(p_last_header, nb_temp);
|
||||
|
||||
// idx calculator
|
||||
idx += ((uint16_t)(*nb_photo) + (uint16_t)(*nb_temp)) * idx_measure * (uint16_t)sizeof(uint8_t);
|
||||
idx += (uint16_t)sizeof(uint32_t) * idx_measure;
|
||||
flags = EEPROM.read(p_last_header);
|
||||
if((flags & 0b01000000) != 0){
|
||||
EEPROM.get(p_last_header + OFFSET_START_DATA_MEASURES, timestamp);
|
||||
idx += sizeof(uint32_t) * idx_measure;
|
||||
EEPROM.get(idx, *timestamp);
|
||||
idx += (uint16_t)sizeof(uint32_t);
|
||||
}else if ((flags & 0b00100000) != 0){
|
||||
uint8_t schedule;
|
||||
get_measure_sch(p_last_header, &schedule);
|
||||
|
|
@ -366,8 +369,6 @@ void Storage_interface::get_measure(uint8_t* array_photo_val, uint8_t* array_tem
|
|||
idx += sizeof(uint32_t);
|
||||
idx += sizeof(uint32_t) * (idx_measure / schedule);
|
||||
}
|
||||
|
||||
idx += ((*nb_photo) + (*nb_temp)) * idx_measure * sizeof(uint8_t);
|
||||
|
||||
for(int i = 0; i < *nb_photo; i++, idx += sizeof(uint8_t)){
|
||||
array_photo_val[i] = EEPROM.read(idx);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ private:
|
|||
uint16_t get_idx_package(uint16_t package_number);
|
||||
|
||||
void write_csv_header(bool* timestamp, bool* photo_sensor, bool* temp_sensor, uint8_t* nb_photo_sensor, uint8_t* nb_temp_sensor);
|
||||
void get_measure(uint8_t* array_photo_val, uint8_t* array_temp_val, uint32_t* timestamp, uint8_t* nb_photo, uint8_t* nb_temp, uint16_t measure_number);
|
||||
|
||||
|
||||
public:
|
||||
|
|
@ -57,6 +56,11 @@ public:
|
|||
|
||||
void upload_csv();
|
||||
|
||||
|
||||
|
||||
// for test here but its need to be in private
|
||||
void get_measure(uint8_t* array_photo_val, uint8_t* array_temp_val, uint32_t* timestamp, uint8_t* nb_photo, uint8_t* nb_temp, uint16_t measure_number);
|
||||
|
||||
// The function dont check if the stored measure structure match with the header
|
||||
// template< typename T, typename TT>
|
||||
// void put_measure(T* photo_values, TT* temp_values, uint32_t timestamp, uint8_t nb_photo, uint8_t nb_temp){
|
||||
|
|
|
|||
|
|
@ -238,28 +238,28 @@ void test_get_measure(){
|
|||
|
||||
uint32_t v_epoch;
|
||||
uint8_t v_photo_val_array[nb_photo_sensor], v_temp_val_array[nb_temp_sensor];
|
||||
test.get_measure_at(v_photo_val_array, v_temp_val_array, &epoch, &nb_photo_sensor, &nb_temp_sensor, 0, 0);
|
||||
test.get_measure(v_photo_val_array, v_temp_val_array, &v_epoch, &nb_photo_sensor, &nb_temp_sensor, 0);
|
||||
|
||||
TEST_ASSERT(v_epoch == epoch);
|
||||
|
||||
for (int i = 0, reading_head = offset + OFFSET_START_DATA_MEASURES + sizeof(uint32_t); i < nb_photo_sensor; i++, reading_head += sizeofuint8){
|
||||
for (int i = 0; i < nb_photo_sensor; i++){
|
||||
TEST_ASSERT(v_photo_val_array[i] == photo_val_array[i]);
|
||||
}
|
||||
for (int i = 0, reading_head = offset + OFFSET_START_DATA_MEASURES + sizeof(uint32_t) + sizeofuint8 * nb_photo_sensor; i < nb_temp_sensor; i++, reading_head += sizeofuint8){
|
||||
for (int i = 0; i < nb_temp_sensor; i++){
|
||||
TEST_ASSERT(v_temp_val_array[i] == temp_val_array[i]);
|
||||
}
|
||||
|
||||
// test on the second measure of the first package
|
||||
test.add_measure(photo_val_array, temp_val_array, epoch, nb_photo_sensor, nb_temp_sensor);
|
||||
|
||||
test.get_measure_at(v_photo_val_array, v_temp_val_array, &epoch, &nb_photo_sensor, &nb_temp_sensor, 1, 2);
|
||||
test.get_measure(v_photo_val_array, v_temp_val_array, &v_epoch, &nb_photo_sensor, &nb_temp_sensor, 1);
|
||||
|
||||
TEST_ASSERT(v_epoch == epoch);
|
||||
|
||||
for (int i = 0, reading_head = offset + OFFSET_START_DATA_MEASURES + sizeof(uint32_t); i < nb_photo_sensor; i++, reading_head += sizeofuint8){
|
||||
for (int i = 0; i < nb_photo_sensor; i++){
|
||||
TEST_ASSERT(v_photo_val_array[i] == photo_val_array[i]);
|
||||
}
|
||||
for (int i = 0, reading_head = offset + OFFSET_START_DATA_MEASURES + sizeof(uint32_t) + sizeofuint8 * nb_photo_sensor; i < nb_temp_sensor; i++, reading_head += sizeofuint8){
|
||||
for (int i = 0; i < nb_temp_sensor; i++){
|
||||
TEST_ASSERT(v_temp_val_array[i] == temp_val_array[i]);
|
||||
}
|
||||
|
||||
|
|
@ -267,14 +267,14 @@ void test_get_measure(){
|
|||
test.add_last_package(timestamp, is_final, photo_sensor, temp_sensor, schedule, nb_photo_sensor, nb_temp_sensor, sizeofuint8, sizeofuint8);
|
||||
test.add_measure(photo_val_array, temp_val_array, epoch, nb_photo_sensor, nb_temp_sensor);
|
||||
|
||||
test.get_measure_at(v_photo_val_array, v_temp_val_array, &epoch, &nb_photo_sensor, &nb_temp_sensor, 2, 1);
|
||||
test.get_measure(v_photo_val_array, v_temp_val_array, &v_epoch, &nb_photo_sensor, &nb_temp_sensor, 0);
|
||||
|
||||
TEST_ASSERT(v_epoch == epoch);
|
||||
|
||||
for (int i = 0, reading_head = offset + OFFSET_START_DATA_MEASURES + sizeof(uint32_t); i < nb_photo_sensor; i++, reading_head += sizeofuint8){
|
||||
for (int i = 0; i < nb_photo_sensor; i++){
|
||||
TEST_ASSERT(v_photo_val_array[i] == photo_val_array[i]);
|
||||
}
|
||||
for (int i = 0, reading_head = offset + OFFSET_START_DATA_MEASURES + sizeof(uint32_t) + sizeofuint8 * nb_photo_sensor; i < nb_temp_sensor; i++, reading_head += sizeofuint8){
|
||||
for (int i = 0; i < nb_temp_sensor; i++){
|
||||
TEST_ASSERT(v_temp_val_array[i] == temp_val_array[i]);
|
||||
}
|
||||
}
|
||||
|
|
@ -304,7 +304,7 @@ void test_get_measure_at(){
|
|||
|
||||
uint32_t v_epoch;
|
||||
uint8_t v_photo_val_array[nb_photo_sensor], v_temp_val_array[nb_temp_sensor];
|
||||
test.get_measure_at(v_photo_val_array, v_temp_val_array, &epoch, &nb_photo_sensor, &nb_temp_sensor, 0, 0);
|
||||
test.get_measure_at(v_photo_val_array, v_temp_val_array, &v_epoch, &nb_photo_sensor, &nb_temp_sensor, 0, 0);
|
||||
|
||||
TEST_ASSERT(v_epoch == epoch);
|
||||
|
||||
|
|
@ -318,7 +318,7 @@ void test_get_measure_at(){
|
|||
// test on the second measure of the first package
|
||||
test.add_measure(photo_val_array, temp_val_array, epoch, nb_photo_sensor, nb_temp_sensor);
|
||||
|
||||
test.get_measure_at(v_photo_val_array, v_temp_val_array, &epoch, &nb_photo_sensor, &nb_temp_sensor, 1, 2);
|
||||
test.get_measure_at(v_photo_val_array, v_temp_val_array, &v_epoch, &nb_photo_sensor, &nb_temp_sensor, 1, 2);
|
||||
|
||||
TEST_ASSERT(v_epoch == epoch);
|
||||
|
||||
|
|
@ -333,7 +333,7 @@ void test_get_measure_at(){
|
|||
test.add_last_package(timestamp, is_final, photo_sensor, temp_sensor, schedule, nb_photo_sensor, nb_temp_sensor, sizeofuint8, sizeofuint8);
|
||||
test.add_measure(photo_val_array, temp_val_array, epoch, nb_photo_sensor, nb_temp_sensor);
|
||||
|
||||
test.get_measure_at(v_photo_val_array, v_temp_val_array, &epoch, &nb_photo_sensor, &nb_temp_sensor, 2, 1);
|
||||
test.get_measure_at(v_photo_val_array, v_temp_val_array, &v_epoch, &nb_photo_sensor, &nb_temp_sensor, 2, 1);
|
||||
|
||||
TEST_ASSERT(v_epoch == epoch);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue