/* * Fahren.cpp * * Created on: 30.11.2010 * Author: istsveise */ #include "Fahren.h" #ifndef POS_H_ #include "POS.h" #endif #include using namespace std; extern POS vehiclePosition; extern double lineDir; Fahren::Fahren(int t, int v, int d) :Task(t),V(v),D(d) { } Fahren::~Fahren() { } void Fahren::execute() { cout << "...Fahren::execute T="<< T << endl; while(true) { pthread_mutex_lock(&vehicleMutex); double realV = (T*V) / 1000; vehiclePosition.move(realV,D); double entf = Abstand(vehiclePosition,lineDir); pthread_mutex_unlock(&vehicleMutex); // cout << "entf: " << entf << endl; const int deltha = 1; if(entf < 0) D += deltha; else if (entf > 0) D -= deltha; waitForNextCycle(); // cout << "Fahren::execute next cycle" << endl; } }