Agilent Technologies E4370A Lawn Mower User Manual


 
7 - C Program Examples
106
} while(presentState != CF_INITIATED);
/* Start the sequence */
cfTrigger(server);
/* Wait for the sequence to end */
do {
cfGetRunState(server, &presentState);
/* sleep or do something else */
} while(presentState == CF_FORMING);
/* Read entire measurement log and write it to a disk file */
fp = fopen("logfile", "w");
for (read_pos = CF_READ_FIRST; ; ) {
cfReadMeasLog(server, &read_pos, CF_ALL_CELLS, CF_ALL_STEPS,
CF_MEAS_LOG_BUFSIZE, buf, &retcount);
if (retcount)
fputs(buf, fp);
else
break;
}
fclose(fp);
/* Close the server connection */
cfClose(server);
return(0);
}
/* Program the charge/discharge sequence */
void setup(CF_HANDLE server)
{
/* Step 1 and tests. */
cfSetSeqStep(server, 1, CF_CHARGE, 4.2, 0.295,
20 * SECONDS_PER_MINUTE, 0.0);
cfSetSeqTest(server, 1, CF_VOLT_GE, 3.8, CF_TEST_BEFORE,
5 * SECONDS_PER_MINUTE, CF_FAIL);
cfSetSeqTest(server, 1, CF_CURR_LE, 0.02, CF_TEST_AFTER,
5 * SECONDS_PER_MINUTE, CF_NEXT);
/* Step 2 is a rest step. */
cfSetSeqStep(server, 2, CF_REST, 0.0, 0.0);
10 * SECONDS_PER_MINUTE, 0.0);
/* Step 3 and tests. */
cfSetSeqStep(server, 3, CF_DISCHARGE, 3, 0.295,
15 * SECONDS_PER_MINUTE, 0.0);
cfSetSeqTest(server, 3, CF_VOLT_LE, 3, CF_TEST_BEFORE,
5 * SECONDS_PER_MINUTE, CF_FAIL);
cfSetSeqTest(server, 3, CF_VOLT_LE, 3, CF_TEST_AFTER,
5 * SECONDS_PER_MINUTE, CF_NEXT);
cfSetSeqTest(server, 3, CF_VOLT_GE, 3, CF_TEST_AT,
15 * SECONDS_PER_MINUTE, CF_FAIL);
/* Step 4 is a rest step. */
cfSetSeqStep(server, 4, CF_REST, 0.0, 0.0);
5 * SECONDS_PER_MINUTE, 0.0);
}