From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- Master/Real-Time Systems/RTS_A8/src/Fahren.cpp | 44 ++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Master/Real-Time Systems/RTS_A8/src/Fahren.cpp (limited to 'Master/Real-Time Systems/RTS_A8/src/Fahren.cpp') 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 +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; + } +} -- cgit v1.2.3