
7 - C Program Examples
Example 3
You can control up to 16 Agilent MCCDs from one PC and still achieve good system responsiveness, depending on the application program structure.
This following C program example uses a
#include <windows.h> #include <stdio.h> #include <time.h> #include "mccd.h"
#define MEAS_BUF_SIZE CF_MEAS_LOG_BUFSIZE #define LINE_SIZE 80
#define PASSWORD "mufasa"
//Structure for thread information typedef struct {
char *szAddr; char *szLogFile; HANDLE hStart;
} THREAD_INFO;
THREAD_INFO ThreadInfo[] = { {"15.14.250.130", "mccdlog0.txt", NULL}, {"15.14.250.124", "mccdlog1.txt", NULL}, };
// Local function prototypes
void GetTimeStamp(char *szTimeStamp);
void ErrorHandler(CF_HANDLE server, char *function, int errorcode); DWORD WINAPI ReadThread(LPVOID lpvThreadParm);
/***************************************************************************** Main function
*****************************************************************************/
void main (int argc, char *argv[])
{
DWORD dwThreadId;
HANDLE hReadThread0, hReadThread1;
//Create events to signal threads to start reading. ThreadInfo[0].hStart = CreateEvent(NULL, FALSE, FALSE, NULL); ThreadInfo[1].hStart = CreateEvent(NULL, FALSE, FALSE, NULL);
//Create threads to read log from MCCDs.
hReadThread0 = CreateThread(NULL, 0, ReadThread, (LPVOID)0, 0, &dwThreadId);
hReadThread1 = CreateThread(NULL, 0, ReadThread, (LPVOID)1, 0, &dwThreadId);