7 - C Program Examples
{
cfGetDigitalPort(hServer, &nDigitalPort); if (nDigitalPort & DIG_START_BUTTON)
break;
/* Sleep for 1 second. */ Sleep(1000);
}
/*
*Turn off the READY light and turn on the TEST light
*to indicate to the operator that cell forming has started.
*/
cfGetDigitalPort(hServer, &nDigitalPort); nDigitalPort &= ~DIG_READY_LIGHT; nDigitalPort = DIG_TEST_LIGHT; cfSetDigitalPort(hServer, nDigitalPort);
/* Initiate the sequence. */ cfInitiate(hServer);
/*
*Wait for sequencer to transition to initiated state.
*This may take up to 1 minute while data logs are erased.
*/
while (1)
{
cfGetRunState(hServer, &nRunState); if (nRunState == CF_INITIATED)
break;
Sleep(1000);
}
/* Trigger the sequence. */ cfTrigger(hServer); printf("Forming sequence started.\n");
/*
*The sequence is now running.
*Display the sequencer state until it finishes.
*/
while (1)
{
Sleep(5000);
cfGetRunState(hServer, &nRunState);
printf("Runstate = %s\r", RunStateToString(nRunState)); if (nRunState == CF_IDLE)
break;
}
/* The sequence is finished. */
/* Read the entire measurement log to a file. */ if((hFile = fopen(LOG_FILE, "w")) != NULL)
{
readPos = CF_READ_FIRST; while (1)
{
cfReadMeasLog(hServer, &readPos, CF_ALL_CELLS, CF_ALL_STEPS, MEAS_BUF_SIZE, szMeasBuffer, &nMeasBufCount);
if (nMeasBufCount == 0) break;
fwrite(szMeasBuffer, sizeof(char), nMeasBufCount, hFile);
}
fclose(hFile);
}