mpiControlCreate
Declaration
Description
mpiControlCreate creates
a Control object of the specified type and type-specific address. ControlCreate is the equivalent of a C++ constructor.
The type parameter determines the form of the address parameter:
If the "type" parameter is |
Then the form of the "address" parameter is |
MPIControlTypeDEFAULT |
implementation-specific |
MPIControlTypeMAPPED |
MPIControlAddress.mapped |
MPIControlTypeDEVICE |
MPIControlAddress.device |
MPIControlTypeCLIENT |
MPIControlAddress.client |
Remarks
This constructor does not reset or initialize the motion control device.
If
MPIControlType is
|
And
MPIControlAddress is |
Then the
Board Number is |
And the
"address" parameter
to be used is |
DEFAULT
|
Null
address |
0
address.number |
default address parameter
default address parameter |
DEVICE
|
Null
address |
0
address.number |
default device driver
address.type.device (if address.type.device is Null, then default device driver) |
CLIENT |
address |
specified by server |
address.type.client
(NOTE: address.number should be set to zero) |
- If the type is DEFAULT, then the address structure (if supplied) is referenced only for the board number. Note that even if the default type is DEVICE, the default device driver will be used and address.type.device will not be used.
- If the type is explicitly DEVICE, and the address is provided, then address.number will be used. If address.type.device is NULL, then the default device driver will be used. If address.type.device is not NULL, then the specified driver (DEVICE) will be used.
|
Return Values |
handle |
to a Control object |
MPIHandleVOID |
if the object could not be created |
|
Sample Code
|
Example #1
In general, if the caller specifies an explicit type (i.e., not DEFAULT), then the caller must
completely fill out the address.type structure.
A simple case that will work for almost anyone who wants to use board #0:
mpiControlCreate(MPIControlTypeDEFAULT, NULL);
Example #2
A simple case where board #1 is desired is:
{ MPIControl control; MPIControlAddress address;
address.number = 1;
control = mpiControlCreate(MPIControlTypeDEFAULT, &address);
}
Since the default MPIControlType = MPIControlTypeDEVICE, the address may be on the stack with garbage for the device driver name. This isn't a problem, however, because the board number is the only field in address that will be used when the caller specifies the DEFAULT MPIControlType.
Example #3
/* To remotely connect via client / server, you need to run
server.exe on your PC that has your XMP / ZMP in it. If you are using an eXMP, run server on your eXMP.
This code will connect to that instance of server.exe. */
MPIControl control; MPIControlAddress address;
/* Change this to the ip address of the computer
that has your XMP in it. */
address.type.client.server = "10.50.114.200";
/* Port 3300 is the default port for client / server */
address.type.client.port = 3300;
address.number = 0;
control = mpiControlCreate(MPIControlTypeCLIENT, &address);
|
See Also
MPIControl | MPIControlAddress | MPIControlType | mpiControlValidate
mpiControlInit | mpiControlDelete
|