/* mcdoutw1.c -- A sample Igor external operation mcdoutw1 is a Igor XOP (external operation) skeleton for a 1st attemp at writing an XOP. The syntax for mcdoutw1 is: mcdoutw1 int */ #include "XOPStandardHeaders.h" // Include ANSI headers, Mac headers, IgorXOP.h, XOP.h and XOPSupport.h #include "..\cbw.h" // Include measurement computing header for mcdaq functions. #include "mcdoutw1.h" // Global Variables (none) // need to insert and restructure to call measurement computing functions for // digital output to USB-DIO96H/50 board // // // call port config routine // cbDConfigPort(int BoardNum, int PortNum, int Direction) // BoardNum may be 0 to 99 // PortNum FIRSTPORTA FIRSTPORTB FIRSTPORTCL SECONDPORTA SECONDPORTB SECONDPORTCL // THIRDPORTA THIRDPORTB FOURTHPORTA FOURTHPORTB // Direction = DIGITALOUT // // call port write routine // cbDOut(int BoardNum, int PortNum, unsigned short DataValue) // BoardNum can be 0 to 99 // PortNum FIRSTPORTA FIRSTPORTB FIRSTPORTCL SECONDPORTA SECONDPORTB SECONDPORTCL // THIRDPORTA THIRDPORTB FOURTHPORTA FOURTHPORTB // DataValue - 0 to 255 // // XOP pass thru suggest using mcdoutw1(variable, string, variable) // /* mcdoutw1config(BoardNum, PortNum, int Direction) configures Port for output. */ static void mcdoutw1config(int BoardNum, int PortNum) { int BoardNum, PortNum; int Direction = DIGITALOUT; cbDConfigPort(BoardNum, PortNum, Direction); return 0; } /* mcdoutw1(waveH) Carries out operation described at top of file. Returns 0 if everything allright or error code otherwise. */ static int mcdoutw1(int BoardNum, int PortNum, int datavalue) { int BoardNum, PortNum; unsigned short DataValue; mcdoutw1config(BoardNum, Portnum); cbDOut(BoardNum, PortNum, DataValue) return 0; } #pragma pack(2) // All structures passed to Igor are two-byte aligned. struct mcdoutw1RuntimeParams { // Flag parameters. // Main parameters. // Parameters for simple main group #0. int n1Encountered; double n1; int n1ParamsSet[1]; // Parameters for simple main group #1. int s1Encountered; Handle s1; int s1ParamsSet[1]; // Parameters for simple main group #2. int n2Encountered; double n2; int n2ParamsSet[1]; // These are postamble fields that Igor sets. int calledFromFunction; // 1 if called from a user function, 0 otherwise. int calledFromMacro; // 1 if called from a macro, 0 otherwise. }; typedef struct mcdoutw1RuntimeParams mcdoutw1RuntimeParams; typedef struct mcdoutw1RuntimeParams* mcdoutw1RuntimeParamsPtr; #pragma pack() // Reset structure alignment to default. /* Domcdoutw1Operation(operationInfo) Domcdoutw1Operation is called when the user invokes the mcdoutw1 operation from the command line, from a macro or from a user function. It returns 0 if everything went OK or error code otherwise. */ extern "C" int Executemcdoutw1(mcdoutw1RuntimeParamsPtr p) { int err = 0; // Main parameters. if (p->n1Encountered) { // Parameter: p->n1 } if (p->s1Encountered) { // Parameter: p->s1 (test for NULL handle before using) } if (p->n2Encountered) { // Parameter: p->n2 } return err; } static int Registermcdoutw1(void) { const char* cmdTemplate; const char* runtimeNumVarList; const char* runtimeStrVarList; // NOTE: If you change this template, you must change the mcdoutw1RuntimeParams structure as well. cmdTemplate = "mcdoutw1 number:n1, string:s1, number:n2"; runtimeNumVarList = ""; runtimeStrVarList = ""; return RegisterOperation(cmdTemplate, runtimeNumVarList, runtimeStrVarList, sizeof(mcdoutw1RuntimeParams), (void*)Executemcdoutw1, 0); } static int RegisterOperations(void) // Register any operations with Igor. { int result; // Register mcdoutw1 operation. if (result = Registermcdoutw1()) return result; // There are no more operations added by this XOP. return 0; } /* XOPEntry() This is the entry point from the host application to the XOP for all messages after the INIT message. */ extern "C" void XOPEntry(void) { XOPIORecResult result = 0; switch (GetXOPMessage()) { // We don't need to handle any messages for this XOP. } SetXOPResult(result); } /* Main(ioRecHandle) This is the initial entry point at which the host application calls XOP. The message sent by the host must be INIT. Main does any necessary initialization and then sets the XOPEntry field of the ioRecHandle to the address to be called for future messages. */ HOST_IMPORT int Main(IORecHandle ioRecHandle) { int result; XOPInit(ioRecHandle); // Do standard XOP initialization. SetXOPEntry(XOPEntry); // Set entry point for future calls. if (igorVersion < 610) { // Requires Igor Pro 6.10 or later. SetXOPResult(IGOR_OBSOLETE); // OLD_IGOR is defined in mcdoutw1.h and there are corresponding error strings in mcdoutw1.r and mcdoutw1WinCustom.rc. return EXIT_FAILURE; } if (result = RegisterOperations()) { SetXOPResult(result); return EXIT_FAILURE; } SetXOPResult(0); return EXIT_SUCCESS; }