20 (*global_error_report)(msg, file, line);
32 return ((
double)tsp->tv_sec) + ((double)tsp->tv_nsec)/1e9;
37 return ((
double)tvp->tv_sec) + ((double)tvp->tv_usec)/1e6;
43 clock_gettime(CLOCK_REALTIME, &tsp);
45 return ((
double)tsp.tv_sec) + ((double)tsp.tv_nsec)/1e9;
52 static int reported = 0;
54 if((*shmemid = shmget(mkey, sz, IPC_CREAT | 0666))<0)
57 *shmemid = shmget(mkey, 1, 0666);
58 if(shmctl(*shmemid, IPC_RMID, 0) < 0)
62 snprintf(oss, 256,
"Could not remove shared memory with key %i.", mkey);
68 snprintf(oss, 256,
"Removed shared memory with key %i.", mkey);
72 if((*shmemid = shmget(mkey, sz, IPC_CREAT | 0666))<0)
76 snprintf(oss, 256,
"Could not create shared memory with key %i.", mkey);
84 snprintf(oss, 256,
"Shared memory created with key %i.", mkey);
94 static int reported = 0;
96 struct shmid_ds shmstats;
100 if((shmemid = shmget(mkey, 0, 0666))<0)
104 snprintf(oss, 256,
"Could not get shared memory with key %i.", mkey);
112 if ((shmemptr = shmat(shmemid, 0, 0)) == (
char *) -1)
116 snprintf(oss, 256,
"Could not attach shared memory with key %i.", mkey);
123 if (shmctl(shmemid, IPC_STAT, &shmstats) < 0)
127 snprintf(oss, 256,
"Could not get shared memory stats with key %i.", mkey);
134 *sz = shmstats.shm_segsz;
136 snprintf(oss, 256,
"Attached to shared memory with key %i of size %zu.", mkey , *sz);
144 return(1.0e6/ (delay_base + delay_inc * rep));
147 int ComputeRepsFrameRate(
double delay_base,
double delay_inc,
double fr)
151 rep = ((1.0e6/fr) - delay_base)/delay_inc;
156 int ComputeRepsExpTime(
double delay_base,
double delay_inc,
double et)
158 return ComputeRepsFrameRate(delay_base, delay_inc, 1./et);
166 if(dienow == 0) dienow = &dienow_tmp;
172 trem = 0.75*(secs-dt);
173 if(trem >= 1.) sleep((
int)trem);
174 else usleep((
int)(trem*1e6));
double get_curr_time()
Gets the current CLOCK_REALTIME time, returns it in seconds to double precision.
void * attach_shm(size_t *sz, key_t mkey, int shmemid)
Attach to a shared memory buffer and get its size.
double tv_to_curr_time(struct timeval *tvp)
Convert a timeval structure to double seconds.
int get_dio_fnames(char *fout, char *fin, char *fbase, int ch)
Fills in the properly formatted dioserver channel fifo names.
VisAO software utilitites, declarations.
int sigproof_sleep(double secs, int *dienow)
Signal proof sleep function.
double ts_to_curr_time(struct timespec *tsp)
Convert a timespec structure to double seconds.
void(* global_error_report)(const char *, const char *, int)
A global error reporting function, arguments are the report, file, and line.
int create_shmem(int *shmemid, key_t mkey, size_t sz)
Create a shared memory buffer.
void(* global_log_info)(const char *)
A global info logging function.
#define MAX_FNAME_SZ
The maximum allowed filename length.
void fifo_error_message(const char *msg, const char *file, int line)
The fifoutils error reporting function.
double ComputeFramerate(double delay_base, double delay_inc, int rep)
Calculate frame rate given Little Joe program parameters.