LXDeviceAPI

Messages by LXDeviceAPI.

LXDeviceAPI send mesage to application program using win32 function SendMessage(.,.,wParam, lParam) . The message parameter wParam has informations to recognize the message type and what processing should be taken by application program.

Message Parameter – wParam

LXDeviceAPI send a wParam as an unsigned int type(byte size 4). Application program can take the information at each byte as follows;

wParam is divided into 4 bytes. Byte0 is lowest byte and Byte3 means highest byte.

Parameter  Written data Description
 wParam_Byte3  Device Handling ID.
  • Device Handling ID =  wParam_Byte3*256 +  wParam_Byte2. range : 1~65535
  • The message is sent by device correspond to “Device Handling ID”.
  • Related : Device Handling ID  can be retrived by return value of OpenDevice.
 wParam_Byte2
 wParam_Byte1  Message Type ID.
  • Identificating the message.
  • available values : MSGTYPEID#_DEVICE_LXDAPI, MSGTYPEID#_API_LXDAPI predefined on LXDeviceAPI.h.
  • Related Function : SetMessageDevice
wParam_Byte0  Message Type Sub ID.
  •  sub message type under Message Type ID.

Message Type vs. Meaning.

 Message Type ID  Message Type Sub ID  Meaning.
 MSGTYPEID0_DEVICE_LXDAPI  0 The number of sampling data is ready. App’s message handler must call the function GetStreamData to get the stream data from LXDeviceAPI. The “number of sampling” is defined by int numsample_return when calling the function OpenDevice.

Code Example1. function SetMessageDevice

#define WM_STREAM_DEVICE  WM_USER+203 // You must define the message without duplication with any other messages in your program.

void CLXDeviceAPI_Sample1View::OnMenuSetmessagedevice()
{
  // Mandatory for receiving the stream data from LXDeviceAPI.
  SetMessageDevice_LXDeviceAPI(m_iDeviceHandlingID, MSGTYPEID0_DEVICE_LXDAPI, this->m_hWnd, WM_STREAM_DEVICE,1); 
}

Code Example2. function StartStream

void CLXDeviceAPI_Sample1View::OnMenuStartstream()
{
  StartStream_LXDeviceAPI(m_iDeviceHandlingID);
}

Code Example3. Message Handler

After calling the function StartStream, the LXDeviceAPI sends a message when the number of sample data is ready. Your app’s message handler must call the function GetStreamData to get the stream data from LXDeviceAPI. The “number of sampling” is defined by int numsample_return when calling the function OpenDevice. If you stop the message from LXDeviceAPI, call the function StopStream or call the SetMessageDevice as last parameter = 0.

afx_msg LRESULT CLXDeviceAPI_Sample1View::OnStreamData(WPARAM wParam, LPARAM lParam)
{
 unsigned int uintWPARAM = (unsigned int)wParam; 
 unsigned char msgtype_id = (unsigned char)(uintWPARAM >> 8)  ; //get the lowest 2'nd byte(message type id).
 unsigned char msgtype_subid = (unsigned char)(uintWPARAM); //get the lowest 1st byte(message type sub id).

 switch (msgtype_id)
 {
 case MSGTYPEID0_DEVICE_LXDAPI: // for real time stream type messages. 

  switch (msgtype_subid)
  {
  case 0:

   GetStreamData_LXDeviceAPI(uintWPARAM); 


   // After call GetStreamData, the new stream data is allocated on ST_STREAMDATA_LXDAPI variable.
   // use stream data here. plotting, saving, calculating, etc. 

   break;

  } // switch (msgtype_subid)

  break;  // case MSGTYPEID0_DEVICE_LXDAPI: // for real time stream type messages. 
 }// switch (msgtype_id)


 return 0;
}