Change times to be relative to this experiment
authorJeremy Tan <[email protected]>
Sat, 14 Sep 2013 06:15:10 +0000 (14:15 +0800)
committerJeremy Tan <[email protected]>
Sat, 14 Sep 2013 06:15:10 +0000 (14:15 +0800)
server/actuator.c
server/control.c
server/control.h
server/sensor.c

index 3c09d05..425449c 100644 (file)
@@ -144,7 +144,7 @@ void Actuator_SetValue(Actuator * a, double value)
        struct timeval t;
        gettimeofday(&t, NULL);
 
-       DataPoint d = {TIMEVAL_DIFF(t, g_options.start_time), value};
+       DataPoint d = {TIMEVAL_DIFF(t, *Control_GetStartTime()), value};
        //TODO: Set actuator
        switch (a->id)
        {
@@ -212,7 +212,7 @@ void Actuator_Handler(FCGIContext * context, char * params)
 {
        struct timeval now;
        gettimeofday(&now, NULL);
-       double current_time = TIMEVAL_DIFF(now, g_options.start_time);
+       double current_time = TIMEVAL_DIFF(now, *Control_GetStartTime());
        int id = 0;
        double set = 0;
        double start_time = 0;
index b12530f..4c64f02 100644 (file)
@@ -112,4 +112,8 @@ bool Control_Lock() {
 
 void Control_Unlock() {
        pthread_mutex_unlock(&(g_controls.mutex));
+}
+
+const struct timeval* Control_GetStartTime() {
+       return &g_controls.start_time;
 }
\ No newline at end of file
index 347465e..f1b95ea 100644 (file)
@@ -12,5 +12,6 @@ extern void Control_Pause();
 extern bool Control_Stop();
 extern bool Control_Lock();
 extern void Control_Unlock();
+extern const struct timeval* Control_GetStartTime();
 
 #endif
index f3860c9..a151312 100644 (file)
@@ -135,7 +135,7 @@ bool Sensor_Read(Sensor * s, DataPoint * d)
        // Set time stamp
        struct timeval t;
        gettimeofday(&t, NULL);
-       d->time_stamp = TIMEVAL_DIFF(t, g_options.start_time);
+       d->time_stamp = TIMEVAL_DIFF(t, *Control_GetStartTime());
 
        // Read value based on Sensor Id
        switch (s->id)
@@ -285,7 +285,7 @@ void Sensor_Handler(FCGIContext *context, char * params)
 {
        struct timeval now;
        gettimeofday(&now, NULL);
-       double current_time = TIMEVAL_DIFF(now, g_options.start_time);
+       double current_time = TIMEVAL_DIFF(now, *Control_GetStartTime());
 
        int id = 0;
        double start_time = 0;

UCC git Repository :: git.ucc.asn.au