git.ucc.asn.au
/
matches
/
MCTX3420.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use experiment folders instead of chdir
[matches/MCTX3420.git]
/
server
/
sensor.c
diff --git
a/server/sensor.c
b/server/sensor.c
index
9c3d2b4
..
c41d39e
100644
(file)
--- a/
server/sensor.c
+++ b/
server/sensor.c
@@
-45,8
+45,6
@@
int Sensor_Add(const char * name, int user_id, ReadFn read, InitFn init, CleanFn
s->name = name;
s->read = read; // Set read function
s->init = init; // Set init function
s->name = name;
s->read = read; // Set read function
s->init = init; // Set init function
- if (init != NULL)
- init(name, user_id); // Call it
// Start by averaging values taken over a second
s->sample_us = 1e6;
// Start by averaging values taken over a second
s->sample_us = 1e6;
@@
-54,6
+52,14
@@
int Sensor_Add(const char * name, int user_id, ReadFn read, InitFn init, CleanFn
// Set sanity function
s->sanity = sanity;
// Set sanity function
s->sanity = sanity;
+
+ if (init != NULL)
+ {
+ if (!init(name, user_id))
+ Fatal("Couldn't init sensor %s", name);
+ }
+
+
return g_num_sensors;
}
return g_num_sensors;
}
@@
-114,11
+120,15
@@
void Sensor_SetMode(Sensor * s, ControlModes mode, void * arg)
{
// Set filename
char filename[BUFSIZ];
{
// Set filename
char filename[BUFSIZ];
- const char *experiment_name = (const char*) arg;
+ const char *experiment_path = (const char*) arg;
+ int ret;
- if (snprintf(filename, BUFSIZ, "%s_%d", experiment_name, s->id) >= BUFSIZ)
+ ret = snprintf(filename, BUFSIZ, "%s/sensor_%d", experiment_path, s->id);
+
+ if (ret >= BUFSIZ)
{
{
- Fatal("Experiment name \"%s\" too long (>%d)", experiment_name, BUFSIZ);
+ Fatal("Experiment path \"%s\" too long (%d, limit %d)",
+ experiment_path, ret, BUFSIZ);
}
Log(LOGDEBUG, "Sensor %d with DataFile \"%s\"", s->id, filename);
}
Log(LOGDEBUG, "Sensor %d with DataFile \"%s\"", s->id, filename);
@@
-285,7
+295,6
@@
void Sensor_Handler(FCGIContext *context, char * params)
struct timeval now;
gettimeofday(&now, NULL);
double current_time = TIMEVAL_DIFF(now, *Control_GetStartTime());
struct timeval now;
gettimeofday(&now, NULL);
double current_time = TIMEVAL_DIFF(now, *Control_GetStartTime());
-
int id = 0;
const char * name = "";
double start_time = 0;
int id = 0;
const char * name = "";
double start_time = 0;
UCC
git Repository :: git.ucc.asn.au