When another component sends to you data, it sends it by the FetchMessage and calls the Fetch method. In here you can handle the processing of the data. As we saw before in sending data, the data is converted to variants and then sent. The data is in Murmex again converted to bits and bytes, which need to be converted back to the original data. Luckily the FetchMessage contains all the information to convert back to the original data.
The Type Cast is intrinsically different from the data type conversion. Remember that a double-precision floating-point number (DBL) is stored in 64 bits / 8 bytes. When converting it to a byte (U8) representation, it reduces precision and range as the U8 is stored in 1 byte. Thus 456.789 in DBL becomes truncated to 255 in U8 and thus losing information. However, when type casting an 8 bytes large DBL to the type U8, you get an array of 8 elements out. Back converting the 8 value large array of U8 to DBL gives an array of 1 value large of the original data.
Convert scalar data to original format
- The data is in the FetchMessage. Use the method Get data to extract the array of data channels.
- Each channel is a cluster with the contents. The data is stored in an array of U8 (bytes). Convert the data back, depending on the data type, with a case structure and use the method Type Cast. If you use mixed data types, decide for example to convert all data types to DBL.
Convert array data to original format
- Like before we type cast the data to the right type, but now use as input an array. However, when the input is a UInt32, we type cast first the byte stream to an I32 array and then convert it to DBL.
- To convert the array of data to the original size, use the information of the dimensions.
- Waveforms can also be received. Use the dt to set the sampling rate of the waveform.
- Digital waveforms can be sent and set as well. Rather use here the method from the waveform palette Binary U32 to digital.
- When handling mixed waveforms types, rather use the waveform parameter from the cluster and use the conditional auto-indexing feature for adding elements to an output array.