Easy Training / Training

Dependents:   Easyfit

training.cpp

Committer:
MarcelPortmann
Date:
2020-04-28
Revision:
1:aa8497b98ef4
Parent:
0:0c6d1b9144af
Child:
2:0df0d0be0664

File content as of revision 1:aa8497b98ef4:

/*
Hear cold stand a discription


*/


#include "training.h"
//#include "math.h"

training::training()
{
    fail_pos = 0;
    time_short = 0;
    time_long = 0;

}


void training::load_training(string name)
{
    int i = 0;
    tr_name = name;
    int sice = 50;
    //sice = loading.size(tr_name)

    for(i = 0; i<sice; i++) {                                                  // loads the whole trainings data into data vector
        loading.AuslesenPositionsdaten(tr_name,i);

        temp.time =   loading.zahl[0];
        temp.pos[0] = loading.zahl[1];
        temp.pos[1] = loading.zahl[2];
        temp.pos[2] = loading.zahl[3];
        temp.start =  loading.zahl[4];                                         // fragen wegen status eintrag
        temp.end =    loading.zahl[5];  
        

        data_vec.push_back(temp);

    }
}

void training::start_training(void)
{
    fail_pos = 0;
    time_short = 0;
    time_long = 0;
    point_count = 0;
    repet = 0;

}

void training::compire_point(float posx,float posy,float posz, int time)
{
    float temp_pos[3] = {};
    float dist = 0, timediv = 0;

    if(data_vec[point_count].start) {                                           // counts the repetitions
        repet++;

    }

    temp_pos[0] = posx - data_vec[point_count].pos[0];                          // calculates distance curent to needed
    temp_pos[1] = posx - data_vec[point_count].pos[1];
    temp_pos[2] = posx - data_vec[point_count].pos[2];

    dist = sqrt(pow(temp_pos[0],2)+pow(temp_pos[1],2)+pow(temp_pos[2],2));

    if(dist>= POSTOL) {                                                         // counts position fail
        fail_pos++;
    }

    if(data_vec[point_count].end) {                                             // counts time too short and time too long
        timediv = time - (data_vec[point_count].time);
        if(timediv>=TIMETOL) {
            time_long++;
        }
        if(timediv<=(-TIMETOL)) {
            time_short++;
        }
    }

    point_count++;

    if(point_count>= data_vec.size()) {                                         // resets the piontecount after a complet cycle
        point_count = 0;
    }

}

void training::end_training(void)
{
    // writhe status to memory / update memory
}