*/
#include "actuator.h"
+#include "control.h"
#include "options.h"
/** Array of Actuators (global to this file) initialised by Actuator_Init **/
pthread_create(&(a->thread), NULL, Actuator_Loop, (void*)(a));
}
+void Actuator_Pause(Actuator *a)
+{
+ if (a->activated)
+ {
+ a->activated = false;
+ Actuator_SetControl(a, NULL);
+ pthread_join(a->thread, NULL); // Wait for thread to exit
+ }
+}
+
+void Actuator_Resume(Actuator *a)
+{
+ if (!a->activated)
+ {
+ a->activated = true;
+ pthread_create(&(a->thread), NULL, Actuator_Loop, (void*)(a));
+ }
+}
+
/**
* Stop an Actuator
* @param s - The Actuator to stop
void Actuator_Stop(Actuator * a)
{
// Stop
- a->activated = false;
- Actuator_SetControl(a, NULL);
- pthread_join(a->thread, NULL); // Wait for thread to exit
+ Actuator_Pause(a);
Data_Close(&(a->data_file)); // Close DataFile
}
+void Actuator_PauseAll()
+{
+ for (int i = 0; i < NUMACTUATORS; ++i)
+ Actuator_Pause(g_actuators+i);
+}
+
+void Actuator_ResumeAll()
+{
+ for (int i = 0; i < NUMACTUATORS; ++i)
+ Actuator_Resume(g_actuators+i);
+}
+
/**
* Stop all Actuators
*/
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)
{
{
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;
// key/value pairs
FCGIValue values[] = {
- {"id", &id, FCGI_REQUIRED(FCGI_LONG_T)},
+ {"id", &id, FCGI_REQUIRED(FCGI_INT_T)},
{"set", &set, FCGI_DOUBLE_T},
{"start_time", &start_time, FCGI_DOUBLE_T},
{"end_time", &end_time, FCGI_DOUBLE_T},