Wasatch.NET 2.4.14
.NET application driver for Wasatch Photonics spectrometers
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
WasatchNET.ParseData Class Reference

A class to access fields of various primitive types embedded at arbitrary indexes within a byte array. Used by EEPROM. More...

Static Public Member Functions

static ushort shortAsUshort (short n)
 Return the UInt16 with the same internal bit-structure as a given Int16.
 
static bool toBool (byte[] buf, int index)
 
static float toFloat (byte[] buf, int index)
 
static short toInt16 (byte[] buf, int index)
 
static int toInt32 (byte[] buf, int index)
 
static String toString (byte[] buf, int index=0, int len=0)
 
static ushort toUInt16 (byte[] buf, int index)
 
static uint toUInt32 (byte[] buf, int index)
 
static byte toUInt8 (byte[] buf, int index)
 
static bool writeBool (bool value, byte[] buf, int index)
 
static bool writeByte (byte value, byte[] buf, int index)
 
static bool writeFloat (float value, byte[] buf, int index)
 
static bool writeInt16 (Int16 value, byte[] buf, int index)
 
static bool writeString (string value, byte[] buf, int index, int maxLen)
 
static bool writeUInt16 (UInt16 value, byte[] buf, int index)
 
static bool writeUInt32 (UInt32 value, byte[] buf, int index)
 

Detailed Description

A class to access fields of various primitive types embedded at arbitrary indexes within a byte array. Used by EEPROM.

Differs from Unpack in that these functions all take an offset, don't have to perform a null-check and supports different types. Also, supports write as well as read.

Member Function Documentation

◆ shortAsUshort()

static ushort WasatchNET.ParseData.shortAsUshort ( short  n)
inlinestatic

Return the UInt16 with the same internal bit-structure as a given Int16.

Spectrometer.sendCmd() takes a ushort argument, because most spectrometer commands pass ushort values. However, setting detector offset is a signed short. I think the easiest solution (rather than overloading sendCmd) is to just pass the ushort which would be deserialized to the desired short. We don't want to cast directly from short to ushort or it'll probably truncate negative values. These things are easier in C.

◆ toBool()

static bool WasatchNET.ParseData.toBool ( byte[]  buf,
int  index 
)
inlinestatic

◆ toFloat()

static float WasatchNET.ParseData.toFloat ( byte[]  buf,
int  index 
)
inlinestatic

◆ toInt16()

static short WasatchNET.ParseData.toInt16 ( byte[]  buf,
int  index 
)
inlinestatic

◆ toInt32()

static int WasatchNET.ParseData.toInt32 ( byte[]  buf,
int  index 
)
inlinestatic

◆ toString()

static String WasatchNET.ParseData.toString ( byte[]  buf,
int  index = 0,
int  len = 0 
)
inlinestatic

◆ toUInt16()

static ushort WasatchNET.ParseData.toUInt16 ( byte[]  buf,
int  index 
)
inlinestatic

◆ toUInt32()

static uint WasatchNET.ParseData.toUInt32 ( byte[]  buf,
int  index 
)
inlinestatic

◆ toUInt8()

static byte WasatchNET.ParseData.toUInt8 ( byte[]  buf,
int  index 
)
inlinestatic

◆ writeBool()

static bool WasatchNET.ParseData.writeBool ( bool  value,
byte[]  buf,
int  index 
)
inlinestatic

◆ writeByte()

static bool WasatchNET.ParseData.writeByte ( byte  value,
byte[]  buf,
int  index 
)
inlinestatic

◆ writeFloat()

static bool WasatchNET.ParseData.writeFloat ( float  value,
byte[]  buf,
int  index 
)
inlinestatic

◆ writeInt16()

static bool WasatchNET.ParseData.writeInt16 ( Int16  value,
byte[]  buf,
int  index 
)
inlinestatic

◆ writeString()

static bool WasatchNET.ParseData.writeString ( string  value,
byte[]  buf,
int  index,
int  maxLen 
)
inlinestatic

◆ writeUInt16()

static bool WasatchNET.ParseData.writeUInt16 ( UInt16  value,
byte[]  buf,
int  index 
)
inlinestatic

◆ writeUInt32()

static bool WasatchNET.ParseData.writeUInt32 ( UInt32  value,
byte[]  buf,
int  index 
)
inlinestatic

The documentation for this class was generated from the following file: