/*************************************************************************\ * Copyright (c) 2002 The University of Chicago, as Operator of Argonne * National Laboratory. * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. * This file is distributed subject to a Software License Agreement found * in the file LICENSE that is included with this distribution. \*************************************************************************/ /* program: mcs2sdds * purpose: convert EG&G Turbo MCS data files to SDDS * * M. Borland, 1994 * Based partly on readmcs.c, a sample program provided by EG&G. $Log: mcs2sdds.c,v $ Revision 1.6 2002/08/14 17:12:37 soliday Added Open License Revision 1.5 2001/01/23 19:47:26 soliday Fixed Solaris compiler warnings. Revision 1.4 1999/05/25 19:03:49 soliday Removed compiler warning on linux. Revision 1.3 1995/09/06 14:55:53 saunders First test release of SDDS1.5 */ #include "mdb.h" #include "SDDS.h" #include "scan.h" #define SET_ASCII 0 #define N_OPTIONS 1 char *option[N_OPTIONS] = { "ascii" }; char *USAGE = "mcs2sdds [-ascii]" ; #define MCS -4 void swapshort(short *data); void swaplong(long *data); void swapulong(unsigned long *data); void swapushort(unsigned short *data); void swapfloat(float *data); int main(int argc,char **argv) { char reserved[100]; /* buffer to skip reserved bytes */ short f_type; /* MCS file type */ char trigger; /* Trigger Flag */ char dwell_flag; /* External Dwell Flag */ char dwell_units; /* 0=us, 1=ms, 2=sec, 3=ns */ char acq_mode; /* Acquisition mode flag 0=replace, 1=sum */ unsigned long dwell_913; /* Dwell time in old 913 format */ unsigned short pass_length; /* pass length in channels */ unsigned long pass_count; unsigned long pass_count_preset; char acq_time[9]; /* buffer for acquisition time */ char acq_date[9]; /* buffer for acquisition date */ unsigned short mark_chan; /* first marker channel */ char mcs_num; /* 1-8 are valid */ char cal_flag; /* 0=no calibration */ char cal_units[4]; /* calibration units */ float cal_zero; /* calibration zero intercept */ float cal_slope; /* calibration slope */ char id_byte; /* always 0xaa */ char detector_len; /* Detector description length */ char detector[65]; /* detector description */ char sample_len; /* Sample description length */ char sample[65]; /* Sample description */ char disc_sel; /* 0=SCA otherwise Disc */ char disc_edge; /* 0=falling else rising */ float disc; /* disc setting in volts */ float sca_uld; /* sca upper-level in volts */ float sca_lld; /* sca lower-level in volts */ float dwell; /* dwell time in dwell_units */ char consistent; /* settings consistent flag */ char mcs_id[9]; /* MCS ID string "0914-001" */ FILE *fpi; char *input, *output; SDDS_DATASET SDDS_dataset; SCANNED_ARG *scanned; long i, i_arg; char ts1[256], ts2[256], ts3[256], ts4[256]; unsigned long *ucount; long *count, *channel; long ascii; SDDS_RegisterProgramName(argv[0]); argc = scanargs(&scanned, argc, argv); if (argc<3) bomb(NULL, USAGE); input = output = NULL; ascii = 0; for (i_arg=1; i_arg