#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include "plugin.h"
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) |
int send_flush3 | ( | const char * | station, |
const char * | channel | ||
) |
References PluginPacketHeader::channel, PluginPacketHeader::data_size, PluginPacketHeader::packtype, PLUGIN_CIDLEN, PLUGIN_SIDLEN, PluginRawDataFlushPacket, PluginPacketHeader::pt, PluginPacketHeader::station, PluginPacketHeader::timing_quality, and PluginPacketHeader::usec_correction.
{ 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 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 | ||
) |
References PluginPacketHeader::data_size, PluginPacketHeader::packtype, PLUGIN_MSEED_SIZE, PLUGIN_SIDLEN, PluginMSEEDPacket, and PluginPacketHeader::station.
{ struct PluginPacketHeader head; if(packet_size!=PLUGIN_MSEED_SIZE) return 0; memset(&head, 0, sizeof(struct PluginPacketHeader)); strncpy(head.station, station, PLUGIN_SIDLEN); head.packtype=PluginMSEEDPacket; head.data_size=packet_size; return send_packet(&head, dataptr, 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 | ||
) |
References PluginPacketHeader::channel, PluginPacketHeader::data_size, PluginPacketHeader::packtype, PLUGIN_CIDLEN, PLUGIN_MAX_DATA_BYTES, PLUGIN_SIDLEN, PluginRawDataGapPacket, PluginRawDataPacket, PluginRawDataTimePacket, PluginPacketHeader::pt, PluginPacketHeader::station, PluginPacketHeader::timing_quality, and PluginPacketHeader::usec_correction.
{ 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 | ||
) |
References ptime::hour, ptime::minute, ptime::second, send_raw3(), ptime::usec, ptime::yday, and ptime::year.
{ 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); }