EasyManua.ls Logo

Vishay 7000 - Sample Code

Vishay 7000
142 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Vishay Micro-Measurements System 7000 Programmer’s Reference Manual
Page 45 of 142
3.14.2.7 Sample Code
This Microsoft Visual Studio C# code snippet shows a basic technique for decoding the data found in a
System 7000 data file from a single card. It assumes that all 8 channels have been assigned to the same
recording group, but the technique shown can easily be expanded to include all groups. In this sample,
the decoded values are written to a console window. In your application you will store and analyze the
data as appropriate. This snippet has been written to make it easy to understand; it is recommended that
you optimize the logic as needed for your requirements. This snippet is included as a sample for the
ActiveX interface.
byte[] inByte = new byte[6]; // byte is an unsigned 8-bit integer
sbyte[] dataByte = new sbyte[4]; // sbyte is a signed, 8-bit integer
byte statusByte;
byte dataType;
byte scanIDSize;
byte extendedStatusByte;
byte groupARecorded;
byte groupBRecorded;
byte groupCRecorded;
byte groupDRecorded;
byte absDataSize;
ulong scanID; // (ulong is a 64-bit, unsigned integer)
int[] groupAValue = new int[8]; // maximum of 8 channels on a card
int[] groupBValue = new int[8];
// For this sample, hard code the number of channels in each group
int numChannelsinGroupA = 8;
try
{
// Open an existing binary file - a .7KD, System 7000 Data File
BinaryReader inFile = new BinaryReader(File.Open("C:\\Temp\\00011234.7KD",FileMode.Open));
// Each iteration of the loop will process a single scan
// Start by reading 1 byte from the file stream (this single, first byte
// is our status byte
scanID = 0;
while (inFile.Read(inByte, 0, 1) != 0)
{
// Decode the status byte
statusByte = inByte[0];
// 0 = relative data, 1 = absolute data
dataType = (byte)(statusByte & (byte)0x01);
// 00 = auto-increment, 01 = 16 bits, 02 = 32 bits, 11 = 48 bits
scanIDSize = (byte)((statusByte & (byte)0x06) >> 1);
// 00 = No, 01 = Yes
extendedStatusByte = (byte)((statusByte & (byte)0x08) >> 3);
groupARecorded = (byte)((statusByte & (byte)0x10) >> 4);
groupBRecorded = (byte)((statusByte & (byte)0x20) >> 5);
groupCRecorded = (byte)((statusByte & (byte)0x40) >> 6);
groupDRecorded = (byte)((statusByte & (byte)0x50) >> 7);
// if we have an extended status byte, read the absolute data size
if (extendedStatusByte == 1)
{
// Read one byte from our file stream
if (inFile.Read(inByte, 0, 1) == 0) throw new System.ApplicationException();
// 0 = 16 bits, 1 = 32 bits
absDataSize = (byte)(inByte[0] & (byte)0x01);
}
else
{
// If there is no extended status byte assume the data size is 16 bits
absDataSize = 0;
}
// Next in the file stream is the scan id
if (scanIDSize == 00)
{
// auto-increment the scan id
scanID++;
}
else if (scanIDSize == 01)
{
// read in a 16-bit (2 byte) scan id

Table of Contents