%{ /* pipe.tmc controls ascii output bound for a pipe or a file $Log: pipe.tmc,v $ Revision 1.1 2000/11/03 17:06:12 nort Initial revision # 10 Oct 96 nmd # Added new uv power channels from 6 pack, added fXS, added general 12 bit # # 23Jul96 nmd # Soft data and integer time # # Revision 1.4 1995/09/04 13:37:00 nmd # Header information in data stream # # Revision 1.3 1993/08/26 18:58:55 nmd # autorunning # # Revision 1.2 1993/08/09 18:24:58 nmd # last version before new pressure # # Revision 1.1 1993/07/24 21:43:46 nmd # Initial revision # */ #include #include "tmctime.h" #pragma off (unreferenced) static char pipercsid[] = "$Id: pipe.tmc,v 1.1 2000/11/03 17:06:12 nort Exp $"; #pragma on (unreferenced) /* Storage for file based message passing to dataReciever */ short oldMsg; char msgLine[256]; typedef struct manlist_struct { unsigned short manNum; unsigned short bulbNum; float volume; char name[32]; float mixingRatio; } manlist; manlist manifold[10]; unsigned short totalBulbs = 0; void readCompoundList(){ FILE *IF; char line[128]; manlist in; if ( ( IF = fopen("compound.list","r") ) == NULL ) return; totalBulbs=0; fgets(line,255,IF); while ( fgets(line,255,IF) ) if ( sscanf(line,"%d %d %f %s %f", &(in.manNum),&(in.bulbNum),&(in.volume), &(in.name),&(in.mixingRatio) ) == 5 ){ manifold[totalBulbs].manNum = in.manNum; manifold[totalBulbs].bulbNum = in.bulbNum; manifold[totalBulbs].volume = in.volume; manifold[totalBulbs].mixingRatio = in.mixingRatio; strcpy(manifold[totalBulbs].name,in.name); totalBulbs++; } fclose(IF); } /* readCompoundList */ typedef struct fclist_struct { short fcNum; char title[16]; float fullScale; char SN[32]; char mainGas[32]; char minorGas[32]; float mixingRatio; } fclist; fclist flowControllers[20]; short totalFCs = 0; void readFlowList(){ FILE *IF; char line[128]; fclist in; totalFCs=-1; if ( ( IF = fopen("flow.list","r") ) == NULL ) return; totalFCs=0; fgets(line,255,IF); while ( fgets(line,255,IF) ) if ( sscanf(line,"%d %s %f %s %s %s %f", &(in.fcNum),&(in.title),&(in.fullScale),&(in.SN), &(in.mainGas),&(in.minorGas),&(in.mixingRatio) ) == 7 ){ flowControllers[totalFCs].fcNum = in.fcNum; flowControllers[totalFCs].fullScale = in.fullScale; flowControllers[totalFCs].mixingRatio = in.mixingRatio; strcpy(flowControllers[totalFCs].title,in.title); strcpy(flowControllers[totalFCs].SN,in.SN); strcpy(flowControllers[totalFCs].mainGas,in.mainGas); strcpy(flowControllers[totalFCs].minorGas,in.minorGas); totalFCs++; } fclose(IF); } /* readFlowList */ void sendStartRun(){ FILE *IF; unsigned short manNum, bulbNum, injSize, ncvt=0, bulb=0; char line[256],radical[16],runModel[32],*commentStr; printf("!Begin Run\n"); readCompoundList(); IF = fopen("run.schedule","r"); fgets(line,255,IF); fgets(line,255,IF); fclose(IF); sscanf(line,"%d %d %d %s%n", &manNum,&bulbNum,&injSize,radical,&ncvt); commentStr = line + ncvt; sscanf(commentStr,"%s%n",runModel,&ncvt); commentStr += ncvt; while ( bulb < totalBulbs ){ if ( manifold[bulb].manNum == manNum && manifold[bulb].bulbNum == bulbNum ){ printf("!Radical %s\n",radical); printf("!RunModel %s\n",runModel); printf("!Comment %s",commentStr); printf("!Contains %d %f %s %f\n", manifold[bulb].manNum, manifold[bulb].volume, manifold[bulb].name, manifold[bulb].mixingRatio); return; } bulb++; } printf("!Contains nothing\n"); } /* sendStartRun */ void sendStartPlume(){ FILE *IF; char line[256],runType[64]; IF = fopen("run.type","r"); fgets(line,255,IF); sscanf(line,"%s",runType); printf("!Begin %s\n",runType); printf("!Contains 0 0 %s 0\n",runType); } /* sendStartPlume */ void sendStartZero(){ printf("!Begin Zero\n"); printf("!Contains 0 0 Zero 0\n"); } /* sendStartZero */ void sendStartLaserCheck(){ printf("!Begin LaserCheck\n"); printf("!Contains 0 0 LaserCheck 0\n"); } /* sendStartLaserCheck */ void writeDataHeader(){ int n; char line[128]; FILE *IF; printf("%%Raw Data file for run:\n"); printf("%%Revision Date: 8 Jul 1999 (nmd)\n"); printf(" !define timeStampRun %ld\n", itime()); printf("%%Official column names:\n"); printf(" !define_list {time:1, signalFlag:2, backgroundFlag:3, " "injectionFlag:4, det1:5, det2:6, det3:7, det4:8, det5:9, OHcell:10, " "frequency:11, uvAbs:12, p1000A:13, p1000Ax10:14, p1000B:15, " "p1000C:16, p1000D:17, p1A:18, f2literA:19, p1Bx10:20, f5literA:21, " "f50literA:22, p1000E:23, f200literA:24, f50ccA:25, f20ccA:26, " "f200ccA:27,systemTemp:28, labTemp:29, heater1:30, heater2:31, " "heater3:32, heater4:33, heater5:34, heater6:35, XSTemp:36, " "uvTemp1:37, uvTemp2:38,laserFlux:39, positionA:40, " "realTime:41, etalonPosition:42, OHLinePosition:43, FC1Setpoint:44, " "FC2Setpoint:45, FC3Setpoint:46, FC4Setpoint:47, FC5Setpoint:48, " "FC6Setpoint:49, FC7Setpoint:50, FC8Setpoint:51, FCStatus: 52, " "ValveStatus1:53, ValveStatus2:54, scanningCycle:55, " "axis1LaserPower:56, axis2LaserPower:57, axis3LaserPower:58, " "axis4LaserPower:59, axis5LaserPower:60, axis6LaserPower:61, " "general12Bit1:62, general12Bit2:63, general12Bit3:64, " "FC5:65, pressureSetpoint:66" "maxDefinedColumn:66}\n" ); printf(" %% Flow Controller Columns:\n"); printf(" !define_list {FC1:19,FC2:22,FC3:21,FC4:24,FC5:65,FC6:27,FC7:25,FC8:26}\n"); printf("%%Historical column names:\n"); printf(" !define_list {pSystem: #p1000A, pSystemx10: #p1000Ax10, " "pXS: #p1000B, pNO2a: #p1000C, pNO2b: #p1000D, pMan: #p1000E, " "pPitot: #p1A, pDifx10: #p1Bx10, fHe: #f5literA, fWhite: #f2literA, " "fCGLow: #f50literA, fCGHigh: #f200literA, fNO2: #f50ccA, " "fH2: #f20ccA, fXSN2: #f200ccA, axis3Position: #positionA, " "pitotTubePosition: #positionA, fXS: #FC5}\n" ); printf("%%Current column names as of 424 July 1996:\n"); printf(" !define_list {pMan1: #pNO2a, pMan2: #pXS, pSource: #pNO2b}\n"); printf(" !define tempsAreVoltsJD 1996.25\n"); printf("%%Column formats:\n"); printf(" !define formatStr #timeFormatData #flagFormatData " "#flagFormatData #flagFormatData #counterFormatData " "#counterFormatData #counterFormatData #counterFormatData " "#counterFormatData #counterFormatData #counterFormatData " "#counterFormatData #absPressureFormatData #absPressureFormatData " "#absPressureFormatData #absPressureFormatData #absPressureFormatData " "#diffPressureFormatData #flowFormatData " "#diffPressureFormatData #flowFormatData #flowFormatData " "#absPressureFormatData #flowFormatData #flowFormatData " "#flowFormatData #flowFormatData #tempFormatData #tempFormatData " "#tempFormatData #tempFormatData #tempFormatData #tempFormatData " "#tempFormatData #tempFormatData #tempFormatData #tempFormatData " "#tempFormatData #voltageFormatData #voltageFormatData #timeFormatData " "#positionFormatData #voltageFormatData #voltageFormatData " "#voltageFormatData #voltageFormatData #voltageFormatData #voltageFormatData " "#voltageFormatData #voltageFormatData #flagFormatData #flagFormatData " "#voltageFormatData #voltageFormatData #voltageFormatData " "#voltageFormatData #voltageFormatData #voltageFormatData " "#voltageFormatData #voltageFormatData #voltageFormatData " "#flowFormatData #flowFormatData\n" ); printf("%% Flow Controller Definitions (from flow.list)\n"); printf(" ! define flowControllerNumber %d\n", totalFCs); for (n = 0; n < totalFCs; n++){ printf(" ! define flowController%dSerialNumber %s\n", flowControllers[n].fcNum, flowControllers[n].SN); printf(" ! define flowController%dMaxFlow %f\n", flowControllers[n].fcNum, flowControllers[n].fullScale); printf(" ! define flowController%dName %s\n", flowControllers[n].fcNum, flowControllers[n].title); printf(" ! define flowController%dMainGas %s\n", flowControllers[n].fcNum, flowControllers[n].mainGas); printf(" ! define flowController%dMinorGas %s\n", flowControllers[n].fcNum, flowControllers[n].minorGas); printf(" ! define flowController%dTraceMixingRatio %f\n", flowControllers[n].fcNum, flowControllers[n].mixingRatio); } printf("%% Configuration information from configuration.def\n"); if ( ( IF = fopen("configuration.def","r") ) != NULL ){ while ( fgets(line,255,IF) ) printf(" ! %s",line); fclose(IF); } printf("%% End of header\n"); } /* writeDataHeader */ %} state (startupPipe); validate startupPipe; depending on (startupPipe once){ readCompoundList(); readFlowList(); oldMsg=0; } { if ( runHasBegun(HPFStat) ){ if ( maskVal(HPFSTat,ZERO_BIT) ) sendStartZero(); else if ( maskVal(HPFStat,PLUME_BIT) ) sendStartPlume(); else if ( maskVal(HPFStat,LASER_BIT) ) sendStartLaserCheck(); else sendStartRun(); writeDataHeader(); } if ( runHasEnded(HPFStat) ){ if ( runWasAborted(HPFStat) ) printf("!Abort Run\n"); else printf("!End Run\n"); } if ( SWDataRecieverMessage && ! oldMsg ){ FILE* MF; oldMsg = 1; MF = fopen("dr.msg","r"); printf("!%s",fgets(msgLine,255,MF)); fclose(MF); } if ( ! SWDataRecieverMessage && oldMsg ) { oldMsg = 0; } printf("%s ",text(MFCtr)); printf("%u ",maskVal(HPFStat,SIGNAL_BIT)); /* signal flag */ printf("%u ",maskVal(HPFStat,BACKGROUND_BIT)); /* backgnd flag */ printf("%u ",maskVal(HPFStat,INJECTION_BIT)); /* injection flag */ printf("%s ",text(Det1)); printf("%s ",text(Det2)); printf("%s ",text(Det3)); printf("%s ",text(Det4)); printf("%s ",text(Det5)); printf("%s ",text(OHCell)); printf("%s ",text(Freq)); printf("%s ",text(UVSig)); printf("%s ",text(P_TOT)); printf("%s ",text(P_TOT10)); printf("%s ",text(P__XS)); printf("%s ",text(P_NO2)); printf("%s ",text(P__H2)); printf("%s ",text(P_PITOT)); printf("%s ",text(F_WHITE)); printf("%s ",text(P_DIF10)); printf("%s ",text(F___5)); printf("%s ",text(F__50)); printf("%s ",text(P_MAN)); printf("%s ",text(F_200)); printf("%s ",text(F_NO2)); printf("%s ",text(F_H2)); printf("%s ",text(F_XSN2)); printf("%s ",text(T_SYS)); printf("%s ",text(T_LAB)); printf("%s ",text(HEAT1)); printf("%s ",text(HEAT2)); printf("%s ",text(HEAT3)); printf("%s ",text(HEAT4)); printf("%s ",text(HEAT5)); printf("%s ",text(HEAT6)); printf("%s ",text(T_XS)); printf("%s ",text(TUV1)); printf("%s ",text(TUV2)); printf("%s ",text(LFLUX)); printf("%s ",text(POS_3)); printf("%ld ",itime()); printf("%s ",text(SWEtalonPos)); printf("%s ",text(SWEtalonLine)); printf("%s ",text(FC1Set)); printf("%s ",text(FC2Set)); printf("%s ",text(FC3Set)); printf("%s ",text(FC4Set)); printf("%s ",text(FC5Set)); printf("%s ",text(FC6Set)); printf("%s ",text(FC7Set)); printf("%s ",text(FC8Set)); printf("%s ",text(FlowStat)); printf("%s ",text(ValveStat1)); printf("%s ",text(ValveStat2)); printf("%s ",text(SWScanningCycle)); printf("%s ",text(LFLUX1)); printf("%s ",text(LFLUX2)); printf("%s ",text(LFLUX3)); printf("%s ",text(LFLUX4)); printf("%s ",text(LFLUX5)); printf("%s ",text(LFLUX6)); printf("%s ",text(SPECIAL1)); printf("%s ",text(SPECIAL2)); printf("%s ",text(SPECIAL3)); printf("%s ",text(F_XS)); printf("%s ",text(SWPSysSet)); printf("\n"); fflush(NULL); }