+static Actuator g_actuators[ACTUATORS_MAX];
+/**
+ * Add and initialise an Actuator
+ * @param name - Human readable name of the actuator
+ * @param read - Function to call whenever the actuator should be read
+ * @param init - Function to call to initialise the actuator (may be NULL)
+ * @returns Number of actuators added so far
+ */
+int Actuator_Add(const char * name, int user_id, SetFn set, InitFn init, CleanFn cleanup, SanityFn sanity)
+{
+ if (++g_num_actuators > ACTUATORS_MAX)
+ {
+ Fatal("Too many sensors; Increase ACTUATORS_MAX from %d in actuator.h and recompile", ACTUATORS_MAX);
+ }
+ Actuator * a = &(g_actuators[g_num_actuators-1]);
+ a->id = g_num_actuators-1;
+ a->user_id = user_id;
+ Data_Init(&(a->data_file));
+ a->name = name;
+ a->set = set; // Set read function
+ a->init = init; // Set init function
+ if (init != NULL)
+ init(name, user_id); // Call it
+ a->sanity = sanity;
+
+ pthread_mutex_init(&(a->mutex), NULL);
+
+ return g_num_actuators;
+}