Professional Documents
Culture Documents
A. C# Usage
Important Note:
File wd_utils.dll has to be copied into the same folder as .exe application file.
File wd_utils.dll is at C:\Program Files\Panametrics-NDT\Olympus Ultrasonic
Measurement Device Driver & Library folder where is the same folder as Hardware.dll
1. using Statement
Include the following line in the file that declares the variable which will interface with the
device.
using Hardware;
using PanUtilities;
using PanTypes;
2. Device Codes
USB DEVICES
35DL Hardware.DeviceType.device_35dl 0x00080302
35DL HP Hardware.DeviceType.device_35dlhp 0x00080303
MG2 Hardware.DeviceType.device_mg2 0x00080203
EPOCH 4 Plus Hardware.DeviceType.device_epoch4plus 0x00070203
EPOCH LT Hardware.DeviceType.device_epochlt 0x00070204
38DLP Hardware.DeviceType.device_38dlp 0x00080204
EPOCH 600 Hardware.DeviceType.device_epoch600 0x0007020b
45MG Hardware.DeviceType. device_45mg 0x00080205
Table 1
For Example:
a) Serial Device Declaration
devPtr.method_name(parameters);
B. DLL Methods
The following functions are most important functions in the Hardware.dll in order to interface with
all types of gages.
1. bool ConfigComm()
The ConfigComm method allows the user to configure the serial communication settings
for a device. It displays all the available serial ports in the Computer System. The user
chooses which COM port the device is connected to, the Baud Rate, data bits, stop bit,
parity, and handshaking. The settings must match the settings on the device.
By calling this method, a Configure Serial Port Dialog Box will be displayed as follows:
- Selecting Save will store the settings for the device and use these settings
upon opening the devices.
- Selecting Cancel will not change any settings.
Parameters
Return Values
If the function succeeds, the return value is true otherwise the return value is false.
2. bool InitDevice ()
The InitDevice opens the device and connects based upon the gage type and comm port that
it was assigned to when the new Device constructor was called.
Parameters
Return Values
If the function succeeds, the return value is true otherwise the return value is false.
3. bool CloseDevice()
The CloseDevice method closes the communications port which the device is connected to.
Parameters
Return Values
If the function succeeds, the return value is true otherwise the return value is false.
Parameters
nIndex
The index number (starting from 1) of the file on the gage to read.
Return Values
The GetDeviceID method will return the Product ID number for a USB device given the
name of the device. If the device is not a USB device, the value returned will be 0.
Parameters
strdev
A string which represents the device name. The following are valid strings for this
parameter:
Table 2
Return Values
A long integer which is the Product ID number for the device. The following hex
values will be returned:
Table 3
The ConfigureDevice method will setup the device port given the device number and
communications type and attempt to open the port in order to communicate with the device.
Parameters
nDeviceType
The device code number obtained from Table 1 in Section A of this document.
strComm
A string representing the type of communications to use, COM# where # is the serial
port number, USB, or ASYNC.
Return Values
If the function succeeds, the return value is true otherwise the return value is false.
The ConfigureDevice method will setup the device port given the device number and
communications type and attempt to open the port in order to communicate with the device.
Parameters
nDeviceType
The device code number obtained from Table 1 in Section A of this document.
strComm
A string representing the type of communications to use, COM# where # is the
serial port number, USB, or ASYNC.
strCommSettings
A string representing the comm port, baud rate, number of bits, parity and number of
stop bits. This setting is valid for Serial Port communications only. For USB and
ASYNC, this string can be set to . Each parameter is separated by a comma.
Comm Port: 1
Baud Rate: 19200
Data Bits: 8
Parity: None
Stop Bits: 0
strCommSettings = "COM1:,19200,8,0,0"
strProfile
The path to an XML file which stores the comm port settings. This path must be the
folder location where the executable file resides and has the form:
ApplicationName.exe.xml
Return Values
If the function succeeds, the return value is true otherwise the return value is false.
8. int[] DeviceAvailableMem ()
Parameters
Return Values
For thickness gages, int[0] stores availlable IDS without Waveform, int[1] stores
availlable IDS with Waveform, and int[2] stores the conversion factor.
For Flaw Detector gages, int[0] stores available memory from device.
9. string[] ReadDeviceDirectory ()
Parameters
Return Values
An array of strings which contains all the files in the gage directory.
Return Values
The ReadDeviceDirectory_ CharSep method reads the directory of the device and returns
a string which contains all the files in the gage directory separated by a character.
Parameters
cSeperator
The character to separate files names.
Return Values
A string containing all the files separated by specified separator passed as parameter.
The SaveThicknessGageFile method reads a specified file from the Thickness gage and
saves it to a file on the PC. This method is only for Thickness gages, not for Flaw
Detector Gages.
Parameters
filename
The name of the file on the gage to read.
savepath
The path including filename to save the data to. If savepath is blank, the file will be saved
as filename.txt in the application folder.
Return Values
If the function succeeds, the return value is true otherwise the return value is false.
The DeleteFile method will delete a file from the device given the filename.
Parameters
filename
The filename to delete.
For thickness gages, the filename is the actual filename on the device.
For the EPOCH 4, 4B, 4Plus, & LT, the filename is the index number of the file
to delete in string format, i.e. 12 will delete the file located at location number
12. For these devices, the number must be greater than 9.
For the EPOCH XT, the filename is the actual filename on the device.
Return Values
If the function succeeds, the return value is true otherwise the return value is false.
The WriteFile method writes specified file from PC to gage. It is for both Thickness gages
and Flaw Detector Gages.
Parameters
strFileName
The full file path name on the PC.
Return Values
If the function succeeds, the return value is true otherwise the return value is false.
The ReadThicknessGageFile method reads a specified file from the Thickness gage. This
method is only for Thickness gages, not for Flaw Detector Gages.
Parameters
filename
The name of the file on the gage to read.
Return Values
The ReadFile method reads a specified file from the Flaw Detector Gage. This method is
only for Flaw Detector Gages (EPOCH 4/4B/PLUS/LT), not for Thickness Gages.
Parameters
nIndex
The index number (starting from 1) of the file on the gage to read.
Return Values
The SetDeviceInactiveState sets the inactive state of the gage. When the inactive state
is ON, the gage will turn off automatically if the device is inactive for a certain period of
time. This is the default state of the gage.
This command is only valid for MG2 gages.
Parameters
Strstate
ON if the inactive state is to be turned on, OFF if the inactive state is to be turned
off.
Return Values
A string ON if the inactive state is on, OFF if the inactive state is off.
The GetDeviceInactiveState returns the inactive state of the gage. When the inactive
state is ON, the gage will turn off automatically if the device is inactive for a certain period
of time. This is the default state of the gage.
Parameters
Return Values
A string ON if the inactive state is on, OFF if the inactive state is off.
The SendString method sends a string to the gage. This command can be used for both
Thickness gages and Flaw Detectors.
Parameters
str
The string to send to the gage
Return Values
If the function succeeds, the return value is true otherwise the return value is false.
The GetResponseFromGage method sends a query command string to the gage and waits
for a response from the gage. If the command is successful, the return value will be the
result of the query string, otherwise the string will be blank. This command can be used for
both Thickness gages and Flaw Detectors.
Parameters
str
The string to send to the gage
Return Values
Parameters
Return Values
22. bool SendCommand (string strCommand, out string strSent, bool bParse,
bool bMonitorCmd)
Parameters
strCommand
The remote command to send to the gage
strSent
The remot command which was sent to the gage.
bParse
set to false
bMonitorCmd
true - if this command is to be sent to a Thickness gage in monitor mode
false - otherwise
Return Values
The GetResponce method retrieves the response that was received from the gage when
the SendCommand method was called.
Parameters
strTerm
The command terminator usually a carriage return and line feed string.
Return Values
The ReadFileByte method reads a specified file from the Flaw Detector Gage. This method
is only for Flaw Detector Gages (EPOCH 4/4B/PLUS/LT), not for Thickness Gages.
Parameters
nIndex
The index number (starting from 1) of the file on the gage to read.
Return Values
The ReadAppSetup method reads a specified application setup from Thickness gage.
Parameters
buffer
The command block used to read the specified application setup.
Please see thickness gages FTP document for detail information.
Return Values
The ReadTransducerList method reads user defined application setup list from Thickness
gage only by using XDCRLIST? gage command.
Parameters
Return Values
The WriteAppSetup method writes specifed Application Setup file from PC to gage.
It is for Thickness gages only.
Parameters
strFileName
The full file path name in PC.
Return Values
If the function succeeds, the return value is true otherwise the return value is false.
The CreateSurveyFile method writes specified file from PC to gage. It is for 38DLP Thickness
gages(FTP file does not contain survey ID list information).
Parameters
strFileName
The full file path name on the PC.
Return Values
If the function succeeds, the return value is true otherwise the return value is false.
The CreateSurveyBoilerFTPFile method creates a FTP format file on PC. It is only used for
38DLP Thickness gages. FTP code will be generated to create a boiler survey file on 38DLP
gage.
Parameters
IncFirstBy DATASET_INCREMENTS_TYPE.Tube,
DATASET_INCREMENTS_TYPE.Elevation or
DATASET_INCREMENTS_TYPE.CustomPoint.
IncSecondBy DATASET_INCREMENTS_TYPE.Tube,
DATASET_INCREMENTS_TYPE. Elevation, or
DATASET_INCREMENTS_TYPE. CustomPoint
PatternType DATASET_PATTERN_TYPE.STANDARD or
DATASET_PATTERN_TYPE.ZIGZAG.
Return Values
If the function succeeds, the return value is true otherwise the return value is false.
30. bool GetAllFilesMeas (string strFileName)
The GetAllFilesMeas method writes All file(s) Measurement from gage to PC in XML format.
It is for EpochXT gage only.
Parameters
strFileName
The full file path name on the PC.
Return Values
If the function succeeds, the return value is true otherwise the return value is false.
C. DLL Properties
1. DllVersion
The DllVersion property returns the version number of the hardware.dll file.
Return Values
2. DllLocation
Return Values
3. GageVersion
Return Values
4. bool UploadComplete
Return Values
True if the upload from device to PC has completed, False if the PC is still receiving
data from the device.
5. string ErrorFlag
The ErrorFlag property returns a string representation of the last error that the device
communications has encountered.
Return Values
Return String Description
NO_ERROR, No error was encountered during the
upload
NOT_ENOUGH_MEM There was not enough memory on the
device to upload the file
ERROR_WRITING An error was encountered while
writing data to the device.
ERROR_INIT_DEVICE Failed to initialize the device.
Table 4
6. DeviceAppSetupDir
Return Values
public EP4FileInfoCollection ()
{
ep4fileinfo = new ArrayList();
dirty = false;
}
return collection.ep4fileinfo[position];
}
}
position++;
}
}
Hardware.EP4FileInfoCollection TransducerInfo ;
TransducerInfo = devPtr.DeviceAppSetupDir;
foreach(EP4FileInfo TrInfo in TransducerInfo)
{
if (icount == 0)
TrInfo.Note = "Active";
AddListViewItem ( NodeType.DeviceTransducer, TrInfo );
icount++;
}
D. Sample C# Code
using Hardware;
using PanUtilities;
using PanTypes;
//read a file from gage, the file was selected from listBox1, and save as test.txt int
the root directory of the C drive:
if (devPtr.UploadRet == false)
{
devPtr.Clear ();
string strErr = devPtr.LastError.ToString();
MessageBox.Show (strErr, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MessageBox.Show ("Upload Complete", "Upload", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
//read application setup list from gage and stored it into listBox1
Hardware.EP4FileInfoCollection TransducerInfo;
TransducerInfo = devPtr.DeviceAppSetupDir;
foreach (EP4FileInfo TrInfo in TransducerInfo)
{
listBox1.Items.Add(TrInfo.FullName);
}
using Hardware;
using PanUtilities;
using PanTypes;
//read a file from gage, the file was selected from listBox1, and save as test.txt in
the root directory of the C drive:
string data =
devPtr.ReadThicknessGageFile(listBox1.SelectedItems[0].ToString());
StreamWriter sw = new StreamWriter("C:\\test.txt");
sw.Write(data);
sw.Flush();
sw.Close();
if (devPtr.UploadRet == false)
{
devPtr.Clear ();
string strErr = devPtr.LastError.ToString();
MessageBox.Show (strErr, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MessageBox.Show ("Upload Complete", "Upload", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
3. Sample code for communicating with 35DL gage using USB port
using Hardware;
using PanUtilities;
using PanTypes;
//read a file from gage, the file was selected from listBox1, and save as test.txt in
the root directory of the C drive:
string data =
devPtr.ReadThicknessGageFile(listBox1.SelectedItems[0].ToString());
StreamWriter sw = new StreamWriter("C:\\test.txt");
sw.Write(data);
sw.Flush();
sw.Close();
if (devPtr.UploadRet == false)
{
devPtr.Clear ();
string strErr = devPtr.LastError.ToString();
MessageBox.Show (strErr, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MessageBox.Show ("Upload Complete", "Upload", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
//read application setup list from gage and stored it into listBox1
Hardware.EP4FileInfoCollection TransducerInfo;
TransducerInfo = devPtr.DeviceAppSetupDir;
foreach (EP4FileInfo TrInfo in TransducerInfo)
{
listBox1.Items.Add(TrInfo.FullName);
}
4. Sample code for communicating with 35DL gage using RS232 port
using Hardware;
using PanUtilities;
using PanTypes;
//read a file from gage, the file was selected from listBox1, and save as test.txt in
the root directory of the C drive:
string data =
devPtr.ReadThicknessGageFile(listBox1.SelectedItems[0].ToString());
int iLoc = data.IndexOf("OK\r\n");
if (iLoc >= 0)
data = data.Substring(0, iLoc);
StreamWriter sw = new StreamWriter("C:\\test.txt");
sw.Write(data);
sw.Flush();
sw.Close();
if (devPtr.UploadRet == false)
{
devPtr.Clear ();
string strErr = devPtr.LastError.ToString();
MessageBox.Show (strErr, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MessageBox.Show ("Upload Complete", "Upload", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
//read application setup list from gage and stored it into listBox1
Hardware.EP4FileInfoCollection TransducerInfo;
TransducerInfo = devPtr.DeviceAppSetupDir;
foreach (EP4FileInfo TrInfo in TransducerInfo)
{
listBox1.Items.Add(TrInfo.FullName);
}
5. Sample code for communicating with 38DLP gage using USB port
using Hardware;
using PanUtilities;
using PanTypes;
string data =
devPtr.ReadThicknessGageFile(listBox1.SelectedItems[0].ToString());
StreamWriter sw = new StreamWriter("C:\\test.txt");
sw.Write(data);
sw.Flush();
sw.Close();
if (devPtr.UploadRet == false)
{
devPtr.Clear ();
string strErr = devPtr.LastError.ToString();
MessageBox.Show (strErr, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MessageBox.Show ("Upload Complete", "Upload", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
if (devPtr.UploadRet == false)
{
devPtr.Clear();
string strErr = devPtr.LastError.ToString();
MessageBox.Show(strErr, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
string strMessage = "Upload " + strSurveyName + " Complete";
MessageBox.Show(strMessage, "Upload", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
//read application setup list from gage and stored it into listBox1
Hardware.EP4FileInfoCollection TransducerInfo;
TransducerInfo = devPtr.DeviceAppSetupDir;
foreach (EP4FileInfo TrInfo in TransducerInfo)
{
listBox1.Items.Add(TrInfo.FullName);
}
6. Sample code for communicating with 38dlp gage using RS232 port
using Hardware;
using PanUtilities;
using PanTypes;
//read a file from gage, the file was selected from listBox1, and save as test.txt in
the root directory of the C drive:
string data =
devPtr.ReadThicknessGageFile(listBox1.SelectedItems[0].ToString());
int iLoc = data.IndexOf("OK\r\n");
if (iLoc >= 0)
data = data.Substring(0, iLoc);
StreamWriter sw = new StreamWriter("C:\\test.txt");
sw.Write(data);
sw.Flush();
sw.Close();
if (devPtr.UploadRet == false)
{
devPtr.Clear ();
string strErr = devPtr.LastError.ToString();
MessageBox.Show (strErr, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
MessageBox.Show ("Upload Complete", "Upload", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
//read application setup list from gage and stored it into listBox1
Hardware.EP4FileInfoCollection TransducerInfo;
TransducerInfo = devPtr.DeviceAppSetupDir;
foreach (EP4FileInfo TrInfo in TransducerInfo)
{
listBox1.Items.Add(TrInfo.FullName);
}
using Hardware;
using PanUtilities;
using PanTypes;
//read a file from gage, the file was selected from listBox1, and save as test.txt in
the root directory of the C drive:
if (devPtr.UploadRet == false)
{
devPtr.Clear ();
string strErr = devPtr.LastError.ToString();
MessageBox.Show (strErr, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
else
{
MessageBox.Show ("Upload Complete", "Upload", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
using Hardware;
using PanUtilities;
using PanTypes;
//read a file from gage, the file was selected from listBox1, and save as test.txt in
the root directory of the C drive:
string data =
devPtr.ReadThicknessGageFile(listBox1.SelectedItems[0].ToString());
// due to ReadFile(index)
// index value starts with 1 but this.listBox1.SelectedIndex value starts with // 0.
if (devPtr.UploadRet == false)
{
devPtr.Clear ();
string strErr = devPtr.LastError.ToString();
MessageBox.Show (strErr, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
else
{
MessageBox.Show ("Upload Complete", "Upload", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}