B&B Electronics MODSCAN32 - Manual User Manual
Page 77

77
Methods
Update()
Instructs the control to update its data array with fresh data values from the
MODBUS slave device. Update will return an error, (FALSE), if the control’s
IO Point property definitions are invalid or if the control is busy processing a
previous Update() request. When the results of the data poll are obtained, the
control will trigger the Ready event. If the poll for data fails, the Busy status
indicator will go false, but the Ready event will not fire. The UpdateFinished
event will fire in either case, as long as the Update() method returns TRUE
.
IssueCmd()
This method is used to write a user-defined message to the attached modbus
slave. Data messages are transmitted to the designated slave unfiltered and the
response message is supplied via the ReadCmdResponse() method as an array
of bytes returned from the slave. If IssueCmd() returns TRUE, you are
guaranteed to receive a CustomCmdResponse Event, otherwise, the message
failed and was not transmitted to the slave. Arguments for the IssueCmd
method define the slave, (node), address, modbus message id, and the data bytes
to be transmitted. Data bytes are supplied as binary values, regardless of the
modbus transmission mode used, (RTU or ASCII). The control will assemble
the message appropriately for the connected device, combining the node, msg
id, data bytes, and checksum prior to transmission.
ReadCmdResponse()
This method is used to read the unfiltered byte response received from a
modbus slave in response to a command initiated with the IssueCmd() method.
Data bytes are returned in the supplied BUFFER, (up to the length specified by
MAXLEN). Data is always returned in binary regardless of the modbus
transmission mode used, (RTU or ASCII). For the ASCII representation, the
control strips off the leading ‘:’ character. If a valid modbus message was
received from the slave, the first byte of the buffer will contain the node
address, the second byte will contain the msg id, and the remaining bytes will
contain data as returned from the slave. The value returned from
ReadCmdResponse indicates the number of data bytes moved to the user
BUFFER.
ShowSvrApp()
This method may be used to hide or display the mbOCXsvr application. During
program development, it may be advantageous to keep the helper application
visible to assist trouble-shooting the communications between the ocx and
modbus device. The finished product embedding the control would probably
execute with the helper application invisible to prevent accidental closure by the
user.
ShowSvrApp(FALSE) hides the mbOCXsvr application.
ShowSvrApp(TRUE) shows the mbOCXsvr application.
CloseSvrApp()
This method may be used by the containing application to close the mbOCXsvr
helper application whenever the program terminates. Since multiple controls
may be sharing the mbOCXsvr, (possibly from different applications), the
helper application will not automatically terminate when a control exits. If a
single controlling application is used on a given machine, this method should be
executed when the last form closes to clean-up and exit the helper.