Programming Reference:NatusADC: Difference between revisions
Dashmeetkaur (talk | contribs) No edit summary |
Dashmeetkaur (talk | contribs) No edit summary |
||
| Line 13: | Line 13: | ||
* Command Number: 0x01 | * Command Number: 0x01 | ||
* Parameters/Payload: 0xff | * Parameters/Payload: 0xff | ||
* Return | * Return Value: returns payload | ||
; CMD_GetInformation : To send the device information such as the number of channels and sampling rate to the client. | ; CMD_GetInformation : To send the device information such as the number of channels and sampling rate to the client. | ||
; CMD_GetChannelNames : To send the channel names as set by the device to the client. If no channel names are set, NULL is sent. | ; CMD_GetChannelNames : To send the channel names as set by the device to the client. If no channel names are set, NULL is sent. | ||
Revision as of 14:58, 23 May 2019
NatusADC module has 3 main classes - NatusPackageInterface, NatusDataServer and NatusClient. The overview of the NatusADC working is shown in the image below.

NatusPackageInterface
This class handles the communication between the server/device and the client. It should be included with both - NatusDataServer and NatusClient Class. The class performs the following functions -constructing TCP and UDP packets, calculating the CRC of a packet and checking the CRC on the receiving side, sending the packets over TCP/UDP port, receiving packets over TCP/UDP Port, reconstructing the data from the packets and listening for connections on device/server-side.
The format of the packets constructed along with each field size is as follows:

NatusDataServer
This class handles the server-side processing. It performs the following functions - starts-up the TCP and UDP server, check for new connections, gracefully disconnects from the client, registers various callbacks on client connection and deregister the callbacks when the client disconnects and responds to the following commands from the client via TCP protocol:
- CMD_Ping
- To check if the connection is successful and data can be sent and received.
- Command Number: 0x01
- Parameters/Payload: 0xff
- Return Value: returns payload
- CMD_GetInformation
- To send the device information such as the number of channels and sampling rate to the client.
- CMD_GetChannelNames
- To send the channel names as set by the device to the client. If no channel names are set, NULL is sent.
- CMD_StartStream
- To start sending channel data over UDP port.
- CMD_StopStream
- To stop sending channel data
- CMD_SelectChannels
- To send data only for the channels numbers mentioned in the payload
- CMD_SetBlockSize
- To set the number of blocks to send per packet.
- CMD_GetDecimationFactor
- To get the current decimation factor of the device/server.
- CMD_SetDecimationFactor
- To set the decimation factor of the device/server.
NatusClient
This class handles the client-side processing. It connects with the server/device, gets data from the operator module of the NatusADC and sends it to the server/device. It uses various commands as described in the NatusDataServer to set different parameters. Another important function of this class 'interpolateMissingBlocks' linearly interpolates the missing UDP packets which contain the channel data values. Eg.
Consider the scenario where 1 block is sent per packet and decimation factor is 1. Suppose we received packet 1 and 3, packet 2 was lost. Data for packet 2 is interpolated as follows:
Interpolation formula
Interpolated Value = ((Current Packet value – Previous Packet value) / (Current Packet Number – Previous Packet Number)) * (Interpolated Packet Number – Previous Packet Number) + Previous Packet Value

See also
Contributions:NatusADC, User Reference:DataIOFilter, Programming Reference:GenericADC Class