N-sim
Emulation and simulation of
Wireless Sensor Networks



   Home


   Project Page


   Download


   CVS



   Installation


   Configuration


   Plug-ins




 Hosted by
SourceForge.net Logo

/home/brennan/n-sim/Vaike/linux/system-addons/drivers/raw_radiation.c File Reference

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#include </usr/include/math.h>
#include "usb.h"
#include <assert.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <unistd.h>
#include <errno.h>

Go to the source code of this file.

Classes

struct  RING_ELEMENT

Defines

#define PROGVERSION   "1.0.0.1"
#define BOOL   int
#define TRUE   1
#define FALSE   0
#define D0   0x01
#define D1   0x02
#define D2   0x04
#define D3   0x08
#define D4   0x10
#define D5   0x20
#define D6   0x40
#define D7   0x80
#define DFF   0xff
#define LOG_FILEPATH_FLAG   0x00000001
#define SPECTRA_FILEPATH_FLAG   0x00000002
#define SPECTRA_SECONDS_FLAG   0x00000004
#define LOG_DOLOG_FLAG   0x00000008
#define PRE_ALARM_FLAG   0x00000010
#define POST_ALARM_FLAG   0x00000020
#define RING_SIZE_FLAG   0x00000040
#define DEAD_BAND_FLAG   0x00000080
#define BG_PERIOD_FLAG   0x00000100
#define SIGMA_ALARM_FLAG   0x00000200
#define PEAKTRACK_BIN_FLAG   0x00000400
#define PEAKTRACK_ROI_FLAG   0x00000800
#define PEAKTRACK_SMOOTH_FLAG   0x00001000
#define ALARM_FILEPATH_FLAG   0x00002000
#define SPECTRAOUT_SIZE_FLAG   0x00004000
#define BG_MINIMUM_FLAG   0x00008000
#define FORCE_NOALARM_FLAG   0x00010000
#define PEAKTRACK_FORCE_FLAG   0x00020000
#define ALL_FLAGS   0x0003ffff
#define IPPROTO_SCTP   132
#define MY_VID   0x0BD7
#define MY_PID   0xA021
#define REQUESTTYPEIN   0xc8
#define REQUESTTYPEOUT   0x48
#define EP_IN_STATUSA   0x81
#define EP_IN_SPECTRAA   0x82
#define EP_IN_STATUSB   0x83
#define EP_IN_SPECTRAB   0x84
#define EP_IN_CONFIGUR   0x85
#define EP_OUT_CONFIGUR   0x01
#define EP_OUT   0x01
#define CLEARBUFF_A   0x80
#define CLEARBUFF_B   0x81
#define ENABLEMCA   0x82
#define DISABLEMCA   0x83
#define BUF_SIZE   65
#define CONFIG_SIZE   64
#define STATUS_SIZE   64
#define SPECT_SIZE   (8192*3+1)
#define SPECT_FSIZE   (8192)
#define NOSPECTRA_TYPE   0
#define UNASSIGNED_TYPE   1
#define PREALARM_TYPE   2
#define ALARM_TYPE   3
#define POSTALARM_TYPE   4
#define GUARD_TYPE   5
#define BG_TYPE   6
#define FRAGMENTSIZE   1024
#define PKTDELAY   10000
#define min(x, y)   (x<y ? x:y)

Functions

usb_dev_handle * open_dev (void)
void print_to_log (char *)
char getconfig (char *pcBuf, int iOffset, char cMask, char cSigned)
double Transmogrify (double fInPut, double fPeakTrackOffset, BOOL bUseTemp)
double PeakTrack (double *dOutSpectrum, int iSize, int iExpectedBinPeak, int iRegionSize, int iSmoothWindow)
void ReBIN (double *dInSpectrum, int iInSize, double *dOutSpectrum, int iOutSize, double dPeakTrackOffset, BOOL bUseTemp)
void zero_spectra (struct RING_ELEMENT *pring_element)
void add_spectra (struct RING_ELEMENT *pring_elementdest, struct RING_ELEMENT *pring_elementsrc)
void print_spectra (struct RING_ELEMENT *pring_element, char *szPath, double fPeakTrackOffset)
int send_spectra (struct RING_ELEMENT *pring_element, char *szPath, double fPeakTrackOffset)
void setconfig (char *pcBuf, int iOffset, unsigned char cMask, char cValue)
void log_configuration (char *tmp)
void reconfig1 (void)
int reconfig2 (usb_dev_handle *dev)
void End (void)
int main (int argc, char **argv)

Variables

char * server = "128.165.54.61"
int port = 2000
int fd
hostent * he
sockaddr_in their_addr
int tcpconnectopen = 0
struct {
   char *   name
   double   equatorial_radius
   double   inverse_flattening
   char *   szParameter
   char   cIndex
   char   cMask
   char   cSigned
   snd_pcm_format_t   format
   unsigned int   channels
   unsigned int   rate
   char *   szParameter
   sensor_t *   sensors
   app_t *   applications
   double   fix_time
   double   satellites
   double   latitude
   double   longitude
   double   altitude
   double   voltage
   int   num_procs
   app_t *   processes
config []
unsigned char cur_config [BUF_SIZE]
char szConfigChange [18] = {"0000_00_00_000000"}
char szExecutablePath [256]
char szConfigPathFile [256]
char szLogPathFile [256]
char szSpectraPathFile [256]
char szAlarmPathFile [256]
char szAlarmBGPathFile [256]
int iCollectSeconds
int iDoLog
int bg_period = 3600
time_t bg_previous = 0
int pre_alarm = 1
int post_alarm = 1
int ring_size = 32
int ring_size_prev = 0
int dead_band = 2
int bg_minimum = 20
int ring_insertion_point = 0
int ring_count = 0
double sigma_alarm = 5.0
int force_noalarm = 600
int spectraout_size = 2500
int peaktrack_bin = 750
int peaktrack_roi = 50
int peaktrack_smooth = 6
double fpeaktrack_offset = 0.0
double fpeaktrack_force = 1.0
float fA_TParam
float fA_Param
float fB_TParam
float fB_Param
float fC_TParam
float fC_Param
BOOL bInAlarm = FALSE
BOOL bHaveBG = FALSE
RING_ELEMENT ring_element
RING_ELEMENTpring_element
RING_ELEMENT alarm_spectra
RING_ELEMENT bg_spectra
RING_ELEMENT alarmbg_spectra
RING_ELEMENT tmp_spectra
RING_ELEMENT rebin_spectra
RING_ELEMENTring_buffer = NULL


Define Documentation

#define ALARM_FILEPATH_FLAG   0x00002000
 

Definition at line 79 of file raw_radiation.c.

#define ALARM_TYPE   3
 

Definition at line 119 of file raw_radiation.c.

#define ALL_FLAGS   0x0003ffff
 

Definition at line 84 of file raw_radiation.c.

#define BG_MINIMUM_FLAG   0x00008000
 

Definition at line 81 of file raw_radiation.c.

#define BG_PERIOD_FLAG   0x00000100
 

Definition at line 74 of file raw_radiation.c.

#define BG_TYPE   6
 

Definition at line 122 of file raw_radiation.c.

#define BOOL   int
 

Definition at line 52 of file raw_radiation.c.

#define BUF_SIZE   65
 

Definition at line 110 of file raw_radiation.c.

#define CLEARBUFF_A   0x80
 

Definition at line 105 of file raw_radiation.c.

#define CLEARBUFF_B   0x81
 

Definition at line 106 of file raw_radiation.c.

#define CONFIG_SIZE   64
 

Definition at line 111 of file raw_radiation.c.

#define D0   0x01
 

Definition at line 56 of file raw_radiation.c.

#define D1   0x02
 

Definition at line 57 of file raw_radiation.c.

#define D2   0x04
 

Definition at line 58 of file raw_radiation.c.

#define D3   0x08
 

Definition at line 59 of file raw_radiation.c.

#define D4   0x10
 

Definition at line 60 of file raw_radiation.c.

#define D5   0x20
 

Definition at line 61 of file raw_radiation.c.

#define D6   0x40
 

Definition at line 62 of file raw_radiation.c.

#define D7   0x80
 

Definition at line 63 of file raw_radiation.c.

#define DEAD_BAND_FLAG   0x00000080
 

Definition at line 73 of file raw_radiation.c.

#define DFF   0xff
 

Definition at line 64 of file raw_radiation.c.

#define DISABLEMCA   0x83
 

Definition at line 108 of file raw_radiation.c.

#define ENABLEMCA   0x82
 

Definition at line 107 of file raw_radiation.c.

#define EP_IN_CONFIGUR   0x85
 

Definition at line 101 of file raw_radiation.c.

#define EP_IN_SPECTRAA   0x82
 

Definition at line 98 of file raw_radiation.c.

#define EP_IN_SPECTRAB   0x84
 

Definition at line 100 of file raw_radiation.c.

#define EP_IN_STATUSA   0x81
 

Definition at line 97 of file raw_radiation.c.

#define EP_IN_STATUSB   0x83
 

Definition at line 99 of file raw_radiation.c.

#define EP_OUT   0x01
 

Definition at line 103 of file raw_radiation.c.

#define EP_OUT_CONFIGUR   0x01
 

Definition at line 102 of file raw_radiation.c.

#define FALSE   0
 

Definition at line 54 of file raw_radiation.c.

#define FORCE_NOALARM_FLAG   0x00010000
 

Definition at line 82 of file raw_radiation.c.

#define FRAGMENTSIZE   1024
 

Definition at line 130 of file raw_radiation.c.

#define GUARD_TYPE   5
 

Definition at line 121 of file raw_radiation.c.

#define IPPROTO_SCTP   132
 

Definition at line 85 of file raw_radiation.c.

#define LOG_DOLOG_FLAG   0x00000008
 

Definition at line 69 of file raw_radiation.c.

#define LOG_FILEPATH_FLAG   0x00000001
 

Definition at line 66 of file raw_radiation.c.

#define min x,
 )     (x<y ? x:y)
 

Definition at line 135 of file raw_radiation.c.

#define MY_PID   0xA021
 

Definition at line 91 of file raw_radiation.c.

#define MY_VID   0x0BD7
 

Definition at line 90 of file raw_radiation.c.

#define NOSPECTRA_TYPE   0
 

Definition at line 116 of file raw_radiation.c.

#define PEAKTRACK_BIN_FLAG   0x00000400
 

Definition at line 76 of file raw_radiation.c.

#define PEAKTRACK_FORCE_FLAG   0x00020000
 

Definition at line 83 of file raw_radiation.c.

#define PEAKTRACK_ROI_FLAG   0x00000800
 

Definition at line 77 of file raw_radiation.c.

#define PEAKTRACK_SMOOTH_FLAG   0x00001000
 

Definition at line 78 of file raw_radiation.c.

#define PKTDELAY   10000
 

Definition at line 131 of file raw_radiation.c.

#define POST_ALARM_FLAG   0x00000020
 

Definition at line 71 of file raw_radiation.c.

#define POSTALARM_TYPE   4
 

Definition at line 120 of file raw_radiation.c.

#define PRE_ALARM_FLAG   0x00000010
 

Definition at line 70 of file raw_radiation.c.

#define PREALARM_TYPE   2
 

Definition at line 118 of file raw_radiation.c.

#define PROGVERSION   "1.0.0.1"
 

Definition at line 50 of file raw_radiation.c.

#define REQUESTTYPEIN   0xc8
 

Definition at line 93 of file raw_radiation.c.

#define REQUESTTYPEOUT   0x48
 

Definition at line 94 of file raw_radiation.c.

#define RING_SIZE_FLAG   0x00000040
 

Definition at line 72 of file raw_radiation.c.

#define SIGMA_ALARM_FLAG   0x00000200
 

Definition at line 75 of file raw_radiation.c.

#define SPECT_FSIZE   (8192)
 

Definition at line 114 of file raw_radiation.c.

#define SPECT_SIZE   (8192*3+1)
 

Definition at line 113 of file raw_radiation.c.

#define SPECTRA_FILEPATH_FLAG   0x00000002
 

Definition at line 67 of file raw_radiation.c.

#define SPECTRA_SECONDS_FLAG   0x00000004
 

Definition at line 68 of file raw_radiation.c.

#define SPECTRAOUT_SIZE_FLAG   0x00004000
 

Definition at line 80 of file raw_radiation.c.

#define STATUS_SIZE   64
 

Definition at line 112 of file raw_radiation.c.

#define TRUE   1
 

Definition at line 53 of file raw_radiation.c.

#define UNASSIGNED_TYPE   1
 

Definition at line 117 of file raw_radiation.c.


Function Documentation

void add_spectra struct RING_ELEMENT pring_elementdest,
struct RING_ELEMENT pring_elementsrc
 

Definition at line 321 of file raw_radiation.c.

References RING_ELEMENT::fDuration, RING_ELEMENT::fspectra, RING_ELEMENT::iSqSum, RING_ELEMENT::iSum, and SPECT_FSIZE.

void End void   ) 
 

Definition at line 1346 of file raw_radiation.c.

References print_to_log().

char getconfig char *  pcBuf,
int  iOffset,
char  cMask,
char  cSigned
 

void log_configuration char *  tmp  ) 
 

Definition at line 875 of file raw_radiation.c.

References cIndex, config, getconfig(), print_to_log(), s, and szParameter.

int main int  argc,
char **  argv
 

Definition at line 1356 of file raw_radiation.c.

References add_spectra(), alarm_spectra, ALARM_TYPE, assert, bg_spectra, bHaveBG, bInAlarm, BUF_SIZE, End(), EP_IN_CONFIGUR, EP_IN_SPECTRAA, EP_IN_STATUSA, FALSE, RING_ELEMENT::fDuration, iCollectSeconds, iDoLog, RING_ELEMENT::iSize, RING_ELEMENT::iSqSum, RING_ELEMENT::iSum, RING_ELEMENT::iType, memcpy, open_dev(), pre_alarm, PREALARM_TYPE, print_to_log(), PROGVERSION, reconfig1(), reconfig2(), ring_buffer, ring_insertion_point, ring_size, s, sigma_alarm, SPECT_SIZE, RING_ELEMENT::status, status, strcmp, szConfigChange, szConfigPathFile, szExecutablePath, szLogPathFile, RING_ELEMENT::time, TRUE, UNASSIGNED_TYPE, and zero_spectra().

usb_dev_handle* open_dev void   ) 
 

double PeakTrack double *  dOutSpectrum,
int  iSize,
int  iExpectedBinPeak,
int  iRegionSize,
int  iSmoothWindow
 

void print_spectra struct RING_ELEMENT pring_element,
char *  szPath,
double  fPeakTrackOffset
 

Definition at line 331 of file raw_radiation.c.

References pring_element, and RING_ELEMENT::time.

void print_to_log char *   ) 
 

void ReBIN double *  dInSpectrum,
int  iInSize,
double *  dOutSpectrum,
int  iOutSize,
double  dPeakTrackOffset,
BOOL  bUseTemp
 

void reconfig1 void   ) 
 

Definition at line 891 of file raw_radiation.c.

References ALARM_FILEPATH_FLAG, ALL_FLAGS, bg_minimum, BG_MINIMUM_FLAG, bg_period, BG_PERIOD_FLAG, bg_previous, bHaveBG, bInAlarm, dead_band, DEAD_BAND_FLAG, FALSE, force_noalarm, FORCE_NOALARM_FLAG, fpeaktrack_force, iCollectSeconds, iDoLog, LOG_DOLOG_FLAG, LOG_FILEPATH_FLAG, peaktrack_bin, PEAKTRACK_BIN_FLAG, PEAKTRACK_FORCE_FLAG, peaktrack_roi, PEAKTRACK_ROI_FLAG, peaktrack_smooth, PEAKTRACK_SMOOTH_FLAG, post_alarm, POST_ALARM_FLAG, pre_alarm, PRE_ALARM_FLAG, print_to_log(), ring_size, RING_SIZE_FLAG, ring_size_prev, sigma_alarm, SIGMA_ALARM_FLAG, SPECTRA_FILEPATH_FLAG, SPECTRA_SECONDS_FLAG, spectraout_size, SPECTRAOUT_SIZE_FLAG, strchr, szAlarmBGPathFile, szAlarmPathFile, szConfigPathFile, szLogPathFile, and szSpectraPathFile.

int reconfig2 usb_dev_handle *  dev  ) 
 

Definition at line 1163 of file raw_radiation.c.

References cur_config, EP_IN_CONFIGUR, print_to_log(), and s.

int send_spectra struct RING_ELEMENT pring_element,
char *  szPath,
double  fPeakTrackOffset
 

Definition at line 435 of file raw_radiation.c.

References ALARM_TYPE, BG_TYPE, cur_config, error, RING_ELEMENT::fDuration, GUARD_TYPE, RING_ELEMENT::iSum, RING_ELEMENT::iType, NOSPECTRA_TYPE, POSTALARM_TYPE, PREALARM_TYPE, pring_element, print_to_log(), SPECT_SIZE, RING_ELEMENT::time, and UNASSIGNED_TYPE.

void setconfig char *  pcBuf,
int  iOffset,
unsigned char  cMask,
char  cValue
 

Definition at line 860 of file raw_radiation.c.

double Transmogrify double  fInPut,
double  fPeakTrackOffset,
BOOL  bUseTemp
 

void zero_spectra struct RING_ELEMENT pring_element  ) 
 

Definition at line 313 of file raw_radiation.c.

References RING_ELEMENT::fDuration, RING_ELEMENT::fspectra, RING_ELEMENT::iSqSum, RING_ELEMENT::iSum, and pring_element.


Variable Documentation

struct RING_ELEMENT alarm_spectra
 

Definition at line 299 of file raw_radiation.c.

struct RING_ELEMENT alarmbg_spectra
 

Definition at line 301 of file raw_radiation.c.

int bg_minimum = 20
 

Definition at line 264 of file raw_radiation.c.

int bg_period = 3600
 

Definition at line 255 of file raw_radiation.c.

time_t bg_previous = 0
 

Definition at line 256 of file raw_radiation.c.

struct RING_ELEMENT bg_spectra
 

Definition at line 300 of file raw_radiation.c.

BOOL bHaveBG = FALSE
 

Definition at line 286 of file raw_radiation.c.

BOOL bInAlarm = FALSE
 

Definition at line 285 of file raw_radiation.c.

char cIndex
 

Definition at line 141 of file raw_radiation.c.

char cMask
 

Definition at line 142 of file raw_radiation.c.

struct { ... } config[]
 

char cSigned
 

Definition at line 143 of file raw_radiation.c.

unsigned char cur_config[BUF_SIZE]
 

Definition at line 233 of file raw_radiation.c.

int dead_band = 2
 

Definition at line 263 of file raw_radiation.c.

float fA_Param
 

Definition at line 278 of file raw_radiation.c.

float fA_TParam
 

Definition at line 277 of file raw_radiation.c.

float fB_Param
 

Definition at line 280 of file raw_radiation.c.

float fB_TParam
 

Definition at line 279 of file raw_radiation.c.

float fC_Param
 

Definition at line 282 of file raw_radiation.c.

float fC_TParam
 

Definition at line 281 of file raw_radiation.c.

int fd
 

Definition at line 132 of file raw_radiation.c.

int force_noalarm = 600
 

Definition at line 268 of file raw_radiation.c.

double fpeaktrack_force = 1.0
 

Definition at line 276 of file raw_radiation.c.

double fpeaktrack_offset = 0.0
 

Definition at line 275 of file raw_radiation.c.

struct hostent* he
 

Definition at line 133 of file raw_radiation.c.

int iCollectSeconds
 

Definition at line 250 of file raw_radiation.c.

int iDoLog
 

Definition at line 252 of file raw_radiation.c.

int peaktrack_bin = 750
 

Definition at line 272 of file raw_radiation.c.

int peaktrack_roi = 50
 

Definition at line 273 of file raw_radiation.c.

int peaktrack_smooth = 6
 

Definition at line 274 of file raw_radiation.c.

int port = 2000
 

Definition at line 129 of file raw_radiation.c.

int post_alarm = 1
 

Definition at line 260 of file raw_radiation.c.

int pre_alarm = 1
 

Definition at line 259 of file raw_radiation.c.

struct RING_ELEMENT* pring_element
 

struct RING_ELEMENT rebin_spectra
 

Definition at line 303 of file raw_radiation.c.

struct RING_ELEMENT* ring_buffer = NULL
 

Definition at line 304 of file raw_radiation.c.

int ring_count = 0
 

Definition at line 266 of file raw_radiation.c.

struct RING_ELEMENT ring_element
 

int ring_insertion_point = 0
 

Definition at line 265 of file raw_radiation.c.

int ring_size = 32
 

Definition at line 261 of file raw_radiation.c.

int ring_size_prev = 0
 

Definition at line 262 of file raw_radiation.c.

char* server = "128.165.54.61"
 

Definition at line 128 of file raw_radiation.c.

double sigma_alarm = 5.0
 

Definition at line 267 of file raw_radiation.c.

int spectraout_size = 2500
 

Definition at line 271 of file raw_radiation.c.

char szAlarmBGPathFile[256]
 

Definition at line 248 of file raw_radiation.c.

char szAlarmPathFile[256]
 

Definition at line 246 of file raw_radiation.c.

char szConfigChange[18] = {"0000_00_00_000000"}
 

Definition at line 236 of file raw_radiation.c.

char szConfigPathFile[256]
 

Definition at line 240 of file raw_radiation.c.

char szExecutablePath[256]
 

Definition at line 238 of file raw_radiation.c.

char szLogPathFile[256]
 

Definition at line 242 of file raw_radiation.c.

char* szParameter
 

Definition at line 140 of file raw_radiation.c.

char szSpectraPathFile[256]
 

Definition at line 244 of file raw_radiation.c.

int tcpconnectopen = 0
 

Definition at line 136 of file raw_radiation.c.

struct sockaddr_in their_addr
 

Definition at line 134 of file raw_radiation.c.

struct RING_ELEMENT tmp_spectra
 

Definition at line 302 of file raw_radiation.c.


© 2007, Los Alamos National Security, LLC.