#include <sys/types.h>
Go to the source code of this file.
Classes |
struct | PluginPacketHeader |
struct | ptime |
Defines |
#define | PLUGIN_CIDLEN 10 /* length of channel ID */ |
#define | PLUGIN_FD 63 |
#define | PLUGIN_INTERFACE_VERSION 3 |
#define | PLUGIN_MAX_DATA_BYTES 4000 |
#define | PLUGIN_MAX_MSG_SIZE 132 /* Quanterra/Comserv limit */ |
#define | PLUGIN_MSEED_SIZE 512 /* hardcoded Comserv limit */ |
#define | PLUGIN_SIDLEN 10 /* length of station ID */ |
Enumerations |
enum | PluginPacketType {
PluginRawDataTimePacket = 8,
PluginRawDataPacket,
PluginRawDataGapPacket,
PluginRawDataFlushPacket,
PluginLogPacket,
PluginMSEEDPacket,
PluginRawDataTimePacket = 8,
PluginRawDataPacket,
PluginRawDataGapPacket,
PluginRawDataFlushPacket,
PluginLogPacket,
PluginMSEEDPacket
} |
Functions |
int | send_flush3 (const char *station, const char *channel) |
int | send_log3 (const char *station, const struct ptime *pt, const char *fmt,...) |
int | send_mseed (const char *station, const void *dataptr, int packet_size) |
int | send_raw3 (const char *station, const char *channel, const struct ptime *pt, int usec_correction, int timing_quality, const int32_t *dataptr, int number_of_samples) |
int | send_raw_depoch (const char *station, const char *channel, double depoch, int usec_correction, int timing_quality, const int32_t *dataptr, int number_of_samples) |
Define Documentation
Enumeration Type Documentation
- Enumerator:
PluginRawDataTimePacket |
|
PluginRawDataPacket |
|
PluginRawDataGapPacket |
|
PluginRawDataFlushPacket |
|
PluginLogPacket |
|
PluginMSEEDPacket |
|
PluginRawDataTimePacket |
|
PluginRawDataPacket |
|
PluginRawDataGapPacket |
|
PluginRawDataFlushPacket |
|
PluginLogPacket |
|
PluginMSEEDPacket |
|
Function Documentation
int send_flush3 |
( |
const char * |
station, |
|
|
const char * |
channel |
|
) |
| |
{
struct PluginPacketHeader head;
memset(&head, 0, sizeof(struct PluginPacketHeader));
strncpy(head.station, station, PLUGIN_SIDLEN);
strncpy(head.channel, channel, PLUGIN_CIDLEN);
head.packtype=PluginRawDataFlushPacket;
head.data_size=0;
head.usec_correction=0;
head.timing_quality=0;
memset(&head.pt, 0, sizeof(struct ptime));
return send_packet(&head, NULL, 0);
}
int send_log3 |
( |
const char * |
station, |
|
|
const struct ptime * |
pt, |
|
|
const char * |
fmt, |
|
|
|
... |
|
) |
| |
{
int retval;
va_list argptr;
if(pt==NULL) return 0;
va_start(argptr, fmt);
retval=send_log_helper(station, pt, fmt, argptr);
va_end(argptr);
return retval;
}
int send_mseed |
( |
const char * |
station, |
|
|
const void * |
dataptr, |
|
|
int |
packet_size |
|
) |
| |
int send_raw3 |
( |
const char * |
station, |
|
|
const char * |
channel, |
|
|
const struct ptime * |
pt, |
|
|
int |
usec_correction, |
|
|
int |
timing_quality, |
|
|
const int32_t * |
dataptr, |
|
|
int |
number_of_samples |
|
) |
| |
{
int r, sample_count, samples_sent=0;
struct PluginPacketHeader head;
memset(&head, 0, sizeof(struct PluginPacketHeader));
strncpy(head.station, station, PLUGIN_SIDLEN);
strncpy(head.channel, channel, PLUGIN_CIDLEN);
if(number_of_samples==0 && pt!=NULL)
{
head.packtype=PluginRawDataTimePacket;
head.pt=*pt;
head.usec_correction=usec_correction;
head.timing_quality=timing_quality;
return send_packet(&head, NULL, 0);
}
if(dataptr==NULL)
{
head.packtype=PluginRawDataGapPacket;
head.data_size=number_of_samples;
memset(&head.pt, 0, sizeof(struct ptime));
head.usec_correction=usec_correction;
head.timing_quality=timing_quality;
return send_packet(&head, NULL, 0);
}
if(number_of_samples < 0)
return -1;
while(samples_sent < number_of_samples)
{
sample_count=number_of_samples - samples_sent;
if(sample_count > (PLUGIN_MAX_DATA_BYTES >> 2))
sample_count=(PLUGIN_MAX_DATA_BYTES >> 2);
head.data_size=sample_count;
if(samples_sent==0 && pt!=NULL)
{
head.packtype=PluginRawDataTimePacket;
head.pt=*pt;
head.usec_correction=usec_correction;
head.timing_quality=timing_quality;
}
else
{
head.packtype=PluginRawDataPacket;
memset(&head.pt, 0, sizeof(struct ptime));
head.usec_correction=0;
head.timing_quality=0;
}
if((r=send_packet(&head, dataptr + samples_sent,
sample_count << 2)) <= 0)
return r;
samples_sent += sample_count;
}
return (number_of_samples << 2);
}
int send_raw_depoch |
( |
const char * |
station, |
|
|
const char * |
channel, |
|
|
double |
depoch, |
|
|
int |
usec_correction, |
|
|
int |
timing_quality, |
|
|
const int32_t * |
dataptr, |
|
|
int |
number_of_samples |
|
) |
| |
{
time_t t;
struct ptime pt;
struct tm *t_parts;
t=(time_t)depoch;
t_parts=gmtime(&t);
pt.year=t_parts->tm_year + 1900;
pt.yday=t_parts->tm_yday + 1;
pt.hour=t_parts->tm_hour;
pt.minute=t_parts->tm_min;
pt.second=t_parts->tm_sec;
pt.usec =(int)((depoch - (double)t) * 1000000.0);
return send_raw3(station, channel, &pt, usec_correction, timing_quality,
dataptr, number_of_samples);
}