Version 13 (modified by 7 years ago) ( diff ) | ,
---|
MnBdSetEvent
Specify an event function to be called when a specified response is received from the main board
void MnBdSetEvent(int item, MNBD_EVENT_FNC event);
Parameters
- item - response item such as MNBD_REQ_GET_WT
- event - event function that is called when the response is received
Return Value
This function does not return any value
Remarks
The application must have a background event that calls MnBdRead to facilitate this.
Examples
// Global CMillisecondTimer timerReqWeight; int nextReqScale = 1; ... MnBdStartup(); SetBackgroundEvent(BackgroundEventComm); MnBdSetEvent(MNBD_REQ_GET_WT, MnBdEventWtRcv); timerReqWeight.Start(100, true); ... MNBD_EVENT(WtRcv) { if(IsGrossWtChanged(nDev)) { DisplayText(0, (FONT_HEIGHT * nDev), GetChangedGrossWt(nDev), 0, BIG_FONT); } return 0; } BACKGROUND_EVENT(Comm) { // Use MnBdRead directly to prevent overhead of MnBdProcess int n; // in case we have more I/O cards than scales change this for(n = 0; n <= GetNumScales(); n++) { // 0 = MNBD_DEV, 1 .. Scales and I/O cards MnBdRead(n); } if(timerReqWeight.IsExpired() == true) { MnBdRequest(nextReqScale, MNBD_REQ_GET_WT, NO_WAIT_ACK); if(nextReqScale == GetNumScales()) nextReqScale = 1; else nextReqScale++; } return 0; }
See Also
Note:
See TracWiki
for help on using the wiki.