summaryrefslogtreecommitdiffstats
path: root/Master/Real-Time Systems/RTS_A8/src/Fahren.cpp
diff options
context:
space:
mode:
authorSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
committerSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
commit33613a85afc4b1481367fbe92a17ee59c240250b (patch)
tree670b842326116b376b505ec2263878912fca97e2 /Master/Real-Time Systems/RTS_A8/src/Fahren.cpp
downloadStudium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.gz
Studium-33613a85afc4b1481367fbe92a17ee59c240250b.tar.bz2
add new repoHEADmaster
Diffstat (limited to 'Master/Real-Time Systems/RTS_A8/src/Fahren.cpp')
-rw-r--r--Master/Real-Time Systems/RTS_A8/src/Fahren.cpp44
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;
+ }
+}