diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Master/Real-Time Systems/RTS_A8/src/Fahren.cpp | |
| download | Studium-master.tar.gz Studium-master.tar.bz2 | |
Diffstat (limited to 'Master/Real-Time Systems/RTS_A8/src/Fahren.cpp')
| -rw-r--r-- | Master/Real-Time Systems/RTS_A8/src/Fahren.cpp | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/Master/Real-Time Systems/RTS_A8/src/Fahren.cpp b/Master/Real-Time Systems/RTS_A8/src/Fahren.cpp new file mode 100644 index 0000000..12c77a0 --- /dev/null +++ b/Master/Real-Time Systems/RTS_A8/src/Fahren.cpp @@ -0,0 +1,44 @@ +/* + * Fahren.cpp + * + * Created on: 30.11.2010 + * Author: istsveise + */ + +#include "Fahren.h" +#ifndef POS_H_ + #include "POS.h" +#endif +#include <iostream> +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; + } +} |
