USHORT parse_days_times(TCHAR FAR * psz, UCHAR FAR * bmap) { WEEKLIST days; DAY times; TCHAR FAR * tok; TCHAR FAR * timetok; USHORT err; USHORT max_len; #if DBG int i,j; UCHAR FAR * weekptr; #endif /* zap it all */ memsetf( (VOID FAR *) bmap, 0, sizeof(WEEK)); /* get our tables of messages */ GetMessageList(7, LocalizedDays, &max_len); GetMessageList(7, LocalizedDaysAbbrev, &max_len); #if DBG WriteToCon(TEXT("parse_days_times: parsing: %Fs\r\n"),(TCHAR FAR *) psz); #endif /* for each day-time section... */ while ( (tok = get_token(&psz, TEXT(";"))) != NULL) { /* parse up the days */ if (err = parse_days(tok, days, &timetok)) return err; /* and the times */ if (err = parse_times(timetok, × )) return err; /* then "or" them into our week bitmap */ map_days_times( days, ×, bmap ); } #if DBG weekptr = bmap; for (i = 0; i < 7; ++i) { WriteToCon(TEXT("%-2.2s "),LocalizedDaysAbbrev[i].msg_text); for (j = 2; j >= 0; --j) WriteToCon(TEXT("%hx "),(USHORT)*(weekptr++)); WriteToCon(TEXT("\r\n")); } #endif return 0; }
/*** * User I/O in localtime, * Storage in zulu! */ int main( int argc, char* argv[] ) { time_t t = get_onesec_resolution(); struct tm local, zulu; set_broken_time( t, &local, &zulu ); format_broken_time( local ); /** see also getdate_r **/ parse_times( ); return 0; }
int main(int argc, char *argv[]){ int sampletime = 1; // in s int numSamples; int32 error = 0; TaskHandle taskHandle = 0; int32 read; float64 *data; char filename[2048] = {'\0'}; char errBuff[2048] = {'\0'}; int recording = 1; float64 state = -10; // used to detect edge FILE *pFile; // file id for output twophoton times file if(argc<2){ customerror("Not enough arguments given."); } sampletime = atoi( argv[1]); if(sampletime<1){ customerror("Sampletime given is incorrect."); } strncpy(filename,argv[2],2048); // calculate number of samples needed numSamples = sampletime *(int) (SAMPLE_FREQUENCY+1); // allocating buffer data = (float64*)malloc( numSamples *sizeof( float64 )); // open file pFile = fopen(filename,"w"); if (pFile==NULL){ customerror("Failed to open %s", filename); } /* char curdir[FILENAME_MAX]; memset(curdir, 0, sizeof(curdir)); if (!GetCurrentDir(curdir, sizeof(curdir))) { customerror("Couldn't get current directory!"); } printf("Current directory: %s\n", curdir); */ printf("Filename: %s\n", filename); // DAQmx Configure Code printf("DAQmx Configure Code\n"); DAQmxErrChk (DAQmxCreateTask("",&taskHandle)); DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandle,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL)); DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",SAMPLE_FREQUENCY,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,numSamples)); //DAQmxErrChk (DAQmxCfgDigEdgeStartTrig(taskHandle,"/Dev1/PFI0",DAQmx_Val_Rising)); //DAQmxErrChk (DAQmxCfgDigEdgeRefTrig(taskHandle,"/Dev1/PFI0",DAQmx_Val_Rising,100)); // DAQmx Start Code printf("DAQmx Start Code\n"); DAQmxErrChk (DAQmxStartTask(taskHandle)); printf("Acquiring for %d seconds a total of %d samples at %f Hz\n", sampletime, numSamples, SAMPLE_FREQUENCY); // DAQmx Read Code printf("DAQmx Read Code\n"); DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,-1,sampletime+1,0,data,numSamples,&read,NULL)); printf("read = %d\n",read); parse_times(data, read, &state, pFile); if( read<numSamples ){ customerror("Error occurred. Acquired fewer than the requested number of samples. "); } printf("Acquired %d points\n",read); Error: if( DAQmxFailed(error) ) DAQmxGetExtendedErrorInfo(errBuff,2048); if( taskHandle!=0 ) { // DAQmx Stop Code DAQmxStopTask(taskHandle); DAQmxClearTask(taskHandle); } if( DAQmxFailed(error) ) printf("DAQmx Error: %s\n",errBuff); free(data); fclose(pFile); //printf("End of program, press Enter key to quit\n"); //getchar(); return 0; }