ProtocolTrial.cpp 1.41 KB
Newer Older
Hurstel's avatar
Hurstel committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
#include "stdafx.h"

#include "ProtocolTrial.h"

#include "Globals.h"

void BaseTrialData::OutputSampling(std::ostream& str)
{
    str << "#Time[s]; PosX[mm]; PosY[mm]; PosZ[mm]; ForceY[N]" << std::endl;

    for(unsigned int j = 0 ; j < dataNum ; j++)
    {
        str	<< data[j].time << ";"
            << data[j].pos.x << ";"
            << data[j].pos.y << ";"
            << data[j].pos.z << ";"
            << data[j].yForce << std::endl;
    }
}


ProtocolTrialHandler::ProtocolTrialHandler(){}

ProtocolTrialHandler::~ProtocolTrialHandler(){}

void ProtocolTrialHandler::Init(float planeLevel,
            float activationLevel,
            float fmStiffness,
            float fmForceLimit,
            Gap signalGap,
            float trailRecordDuration)
{
    refLevelHeight = planeLevel;
    activationHeight = activationLevel;

    stiffness = fmStiffness;
    forceLimit = fmForceLimit;

    trailRecord = trailRecordDuration;

    state = TS_WAITFORACTIVATION;			// Initial state
    gap= signalGap;


    data.Clear();
    auxRes= TrialAuxResults();

    activationReport= false;
}


double ProtocolTrialHandler::ForceValue(double pos, double time)
{
    double retForce = 0.0;

    if(time - auxRes.belowPlaneStart && pos <= auxRes.dynamicPlaneLevel)
    {
        retForce = (auxRes.dynamicPlaneLevel - pos) * stiffness;

        if(retForce > forceLimit)
            retForce = forceLimit;
    }

    return retForce;
}