Implementing the talker function – Yokogawa PC-Based MX100 User Manual

Page 486

Advertising
background image

8-12

IM MX190-01E

Implementing the Talker Function

Program Example 4

This program retrieves the system configuration data. The program executes the TS
and CF commands of the DARWIN communication function.

//////////////////////////////////////////////////////////////
// DARWIN sample for talker
#include <stdio.h>
#include "DAQDARWIN.h"////////////////////////////////////////
//////////////////////
int main(int argc, char* argv[])
{
int rc; //return code
DAQDARWIN comm; //discriptor
char line[BUFSIZ];
int len;
#ifdef WIN32
HMODULE pDll; //DLL handle
//callback
DLLOPENDARWIN openDARWIN;
DLLCLOSEDARWIN closeDARWIN;
DLLSENDLINEDARWIN sendLineDARWIN;
DLLRECEIVELINEDARWIN receiveLineDARWIN;
DLLSENDTRIGGERDARWIN sendTriggerDARWIN;
DLLRUNCOMMANDDARWIN runCommandDARWIN;
//laod
pDll = LoadLibrary("DAQDARWIN");
//get address
openDARWIN = (DLLOPENDARWIN)GetProcAddress(pDll,
"openDARWIN");
closeDARWIN = (DLLCLOSEDARWIN)GetProcAddress(pDll,
"closeDARWIN");
sendLineDARWIN = (DLLSENDLINEDARWIN)GetProcAddress(pDll,
"sendLineDARWIN");
receiveLineDARWIN =
(DLLRECEIVELINEDARWIN)GetProcAddress(pDll,
"receiveLineDARWIN");
sendTriggerDARWIN =
(DLLSENDTRIGGERDARWIN)GetProcAddress(pDll,
"sendTriggerDARWIN");
runCommandDARWIN = (DLLRUNCOMMANDDARWIN)GetProcAddress(pDll,
"runCommandDARWIN");
#endif //WIN32
//connect
comm = openDARWIN("192.168.1.11", &rc);
//talker
sprintf(line, ìTS%d” DAQDARWIN_TALK_SYSINFODATA);
rc = runCommandDARWIN(comm, line);
rc = sendTriggerDARWIN(comm);
rc = sendLineDARWIN(comm, "CF0";

do {
rc = receiveLineDARWIN(comm, line, BUFSIZ, &len);
} while ((rc == 0) && (line[0] != 'E');

8.2 Programming - DARWIN/Visual C -

Advertising