You are on page 1of 26

Olympus NDT Hardware DLL Interface

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

Device Enumeration Hex Value


SERIAL DEVICES
25DL Hardware.DeviceType.device_25dl 0x0008fff1
25DL HP Hardware.DeviceType.device_25dlhp 0x0008fff2
25DL RR Hardware.DeviceType.device_25dlrr 0x0008fff3
25DL Plus Hardware.DeviceType.device_25dlp 0x00080402
25HP Plus Hardware.DeviceType.device_25hpdlp 0x00080403
25MM Plus Hardware.DeviceType.device_25mmdlp 0x00080404
25MX Plus Hardware.DeviceType.device_25mxdlp 0x00080405
26DL Plus Hardware.DeviceType.device_26dlplus 0x0008fff5
26XTDL Hardware.DeviceType.device_26xtdl 0x0008fff4
36DL Plus Hardware.DeviceType.device_36dlp 0x00080201
37DL Plus Hardware.DeviceType.device_37dlp 0x00080202
8000 Hardware.DeviceType.device_8000 0x0008fff6
Magna Mike 8500 Hardware.DeviceType.device_8500 0x00080501
EPOCH 4 Hardware.DeviceType.device_epoch4 0x00070202
EPOCH 4B Hardware.DeviceType.device_epoch4b 0x00070205
35DL Hardware.DeviceType.device_35dl_rs232 0x00089302
35DL HP Hardware.DeviceType.device_35dlhp_rs232 0x00089303
38DLP Hardware.DeviceType.device_38dlp_rs232 0x00089304

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

USB DEVICES USING ACTIVESYNC


EPOCH XT Hardware.DeviceType.device_epochxt 0x00070206
EPOCH 1000i Hardware.DeviceType.device_epoch1000i 0x0007020a

Table 1

3. Device Interface Declaration


To declare a pointer to the device interface:

Device devPtr = new Device(DeviceType.GageType, strCommPort, true);

For Example:
a) Serial Device Declaration

Declaring a device interface for serial device using COM1 port .


The following codes define all serial devices in GageView so far.

For 25DL gage,


Device devPtr = new Device(DeviceType. device_25dl, "COM1", true);

For 25DL HP gage,


Device devPtr = new Device(DeviceType. device_25dlhp, "COM1", true);

For 25DL RR gage,


Device devPtr = new Device(DeviceType. device_25dlrr, "COM1", true);

For 25DL Plus gage,


Device devPtr = new Device(DeviceType. device_25dlp, "COM1", true);

For 25HP Plus gage,


Device devPtr = new Device(DeviceType. device_25hpdlp, "COM1", true);

For 25MM Plus gage,


Device devPtr = new Device(DeviceType. device_25mmdlp, "COM1", true);

For 25MX Plus gage,


Device devPtr = new Device(DeviceType. device_25mxdlp, "COM1", true);

For 26DL Plus gage,


Device devPtr = new Device(DeviceType. device_26dlplus, "COM1", true);

For 26XTDL gage,


Device devPtr = new Device(DeviceType. device_26xtdl, "COM1", true);

For 35DL gage using RS232 Communication Port,


Device devPtr = new Device(DeviceType. device_35dl_rs232, "COM1", true);

For 25DL HP gage using RS232 Communication Port,


Device devPtr = new Device(DeviceType. device_35dlhp_rs232, "COM1", true);

For 36DL Plus gage,


Device devPtr = new Device(DeviceType. device_36dlp, "COM1", true);

For 37DL Plus gage,


Device devPtr = new Device(DeviceType. device_37dlp, "COM1", true);

For 8000 gage,


Device devPtr = new Device(DeviceType. device_8000, "COM1", true);

For 8500 gage,


Device devPtr = new Device(DeviceType. device_8500, "COM1", true);

For EPOCH 4 gage,


Device devPtr = new Device(DeviceType. device_epoch4, "COM1", true);

For EPOCH 4B gage,


Device devPtr = new Device(DeviceType. device_epoch4b, "COM1", true);
For EPOCH LTC gage,
Device devPtr = new Device(DeviceType. device_epochltcolor, "COM1", true);

For 38DLP gage using RS232 Communication Port,


Device devPtr = new Device(DeviceType. device_38dlp_rs232, "COM1", true);

For EPOCH 600 gage,


Device devPtr = new Device(DeviceType. device_epoch600, "COM1", true);

b) USB Device Declaration

The following codes define all USB devices in GageView so far.

For 35DL gage using USB Communication Port,


Device devPtr = new Device(DeviceType.device_35dl, "USB", true);

For 35DL HP gage using USB Communication Port,


Device devPtr = new Device(DeviceType.device_35dlhp, "USB", true);

For MG2 gage,


Device devPtr = new Device(DeviceType. device_mg2, "USB", true);

For EPOCH 4 Plus gage,


Device devPtr = new Device(DeviceType. device_epoch4plus, "USB", true);

For EPOCH LT gage,


Device devPtr = new Device(DeviceType. device_epochlt, "USB", true);

For EPOCH XT gage,


Device devPtr = new Device(DeviceType. device_epochxt, "USB", true);

For 38DL Plus gage,


Device devPtr = new Device(DeviceType. device_38dlp, "USB", true);

For 45MG gage,


Device devPtr = new Device(DeviceType. device_38dlp, "USB", true);

4. Device Interface Usage

devPtr.method_name(parameters);

where method_name is one of the methods in Section B DLL Methods.

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

This method takes no 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

This method takes no 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

This method does not take any parameters.

Return Values

If the function succeeds, the return value is true otherwise the return value is false.

4. string ReadFile (int nIndex)


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

A string containing all the data of the specified file.

5. long GetDeviceID(string strdev)

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:

Device Name Description


MG2 any gage in the MG2 series
35 any gage in the 35 series
EPOCH 4PLUS" the EPOCH 4 Plus Flaw Detector
EPOCH LT the EPOCH LT Flaw Detector
EPOCH XT the EPOCH XT Flaw Detector
38DLP The 38DLP gage
45MG The 45MG gage

Table 2
Return Values

A long integer which is the Product ID number for the device. The following hex
values will be returned:

Device Name Hex Product ID Value


MG2 0x0068
35 0x006C
EPOCH 4PLUS" 0x0064
EPOCH LT 0x006A
EPOCH XT 0x0073
38DLP 0x0085
45MG 0x0086

Table 3

6. bool ConfigureDevice (long nDeviceType, string strComm)

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.

7. bool ConfigureDevice (long nDeviceType, string strComm, string strCommSettings,


string strProfile)

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.

Example: For the following serial port settings

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

The following is the format of the XML file:

<?xml version="1.0" encoding="utf-8"?>


<profile>
<section name="Serial Config COM1:">
<entry name="Port Name">COM1:</entry>
<entry name="Baud Rate">19200</entry>
<entry name="CTS Flow">False</entry>
<entry name="DSR Flow">False</entry>
<entry name="DTR Ctrl">1</entry>
<entry name="DSR Sense">False</entry>
<entry name="TX Continue">True</entry>
<entry name="TX Xoff Flow">True</entry>
<entry name="RX Xoff Flow">True</entry>
<entry name="Error Replace">False</entry>
<entry name="Null Discard">False</entry>
<entry name="RTS Control">1</entry>
<entry name="Abort On Error">False</entry>
<entry name="Xon Limit">0</entry>
<entry name="Xoff Limit">0</entry>
<entry name="Bits/Byte">8</entry>
<entry name="Parity">0</entry>
<entry name="Stop Bits">0</entry>
<entry name="Xon Char">17</entry>
<entry name="Xoff Char">19</entry>
<entry name="Error Char">63</entry>
<entry name="EOF Char">26</entry>
<entry name="Event Char">0</entry>
<entry name="Handshaking">3</entry>
<entry name="RX Q Length">0</entry>
<entry name="TX Q Length">0</entry>
<entry name="TX Timeout(M)">0</entry>
<entry name="TX Timeout(C)">0</entry>
<entry name="Receive Mode">False</entry>
</section>
</profile>

Return Values

If the function succeeds, the return value is true otherwise the return value is false.

8. int[] DeviceAvailableMem ()

The DeviceAvailableMem method reads available memory from device.

Parameters

This method does not take any parameters.

Return Values

A int[] structure which stored the available memory in the gage.

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 ()

The ReadDeviceDirectory method reads the directory of the device.

Parameters

This method takes no parameters.

Return Values

An array of strings which contains all the files in the gage directory.

10. string ReadDeviceDirectory_CommaSep ()

The ReadDeviceDirectory_CommaSep method reads the directory of the device and


returns a string which contains all the files in the gage directory separated by commas.
Parameters

This method takes no parameters.

Return Values

A string containing all the files separated by commas.

11. string ReadDeviceDirectory_CharSep (char cSeperator)

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.

12. bool SaveThicknessGageFile(string filename, string savepath)

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.

13. bool DeleteFile (string filename)

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.

14. bool WriteFile(string strFileName)

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.

15. string ReadThicknessGageFile (string filename)

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

A string containing all data of the specified file.

16. string ReadFile (int nIndex)

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

A string containing all the data of the specified file.

17. bool SetDeviceInactiveState (string strState)

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.

18. string GetDeviceInactiveState ()

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.

This command is only valid for MG2 gages.

Parameters

This method takes no parameters.

Return Values

A string ON if the inactive state is on, OFF if the inactive state is off.

19. bool SendString (string str)

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.

20. string GetResponseFromCommand (string str)

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

The response from the gage.


21. Clear ()

The Clear Method will clear any device communications.

Parameters

This method does not take any parameters.

Return Values

This method does not return a value.

22. bool SendCommand (string strCommand, out string strSent, bool bParse,
bool bMonitorCmd)

The SendCommand method sends a remote command to the device.

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

True - if the command was successful


False otherwise

23. string GetResponce (string strTerm)

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 response from the gage.

24. byte[] ReadFileByte (int nIndex)

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

A byte array containing all data of the specified file.

25. string ReadAppSetup(string buffer)

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

A string containing all data of the specified application setup.

For example to a 25dlplus gage:

String buffer ="APPSUREAD? \r\nSOBAPP_INDEX \r\nASI2


\r\nEOB3243 \r\n";

string strSetup = devPtr. ReadAppSetup(buffer);

strSetup stored the string as below:

"\r\nSOBAPP_SU \r\nAS02 USER-2 4 0.22600IN/us


\r\nAS1214.0 3240013442862 \r\nAS225 13967 1120 \r\nAS30
\r\nEOB253 \r\n\r\nOK\r\n"

26. string ReadTransducerList()

The ReadTransducerList method reads user defined application setup list from Thickness
gage only by using XDCRLIST? gage command.

Parameters

This method takes no parameters.

Return Values

A string containing user defined application setup list.

27. bool WriteAppSetup(string strFileName)

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.

28. bool CreateSurveyFile (string strFileName)

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.

29. bool CreateSurveyBoilerFTPFile (string OutputFtpFileName, string


SurveyName, string StartTube, string EndTube, string[] CustomPoints, string[]
CustomElevations, int IncFirstBy, int IncSecondBy, int PatternType)

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

strOutputFtpFileName The full file path name on the PC.

SurveyName The name of the file on the gage.

StartTube Length 1-20.

EndTube Length 1-20.

CustomPoints Custom Points List cannot more than 1000 items


Each Custom Point Length 1-20.
CustomElevations Custom Elevation List cannot more than 1000 items
Each Elevation Length 1-20.

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

A string containing version number of the hardware.dll file.

2. DllLocation

The DllLocation property returns the path of the hardware.dll file.

Return Values

A string containing hardware.dll file path.

3. GageVersion

The GageVersion property returns the version number of the gage.

Return Values

A string containing version number of the gage.

4. bool UploadComplete

The UploadComplete property returns the state of the upload process.

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.

ERROR_OPEN_PORT Error opening the communications


port.
ERROR_OPEN_FILE Error opening the file on the gage.

ERROR_UNSPORTED Unsupported command.

Table 4

6. DeviceAppSetupDir

The DllLocation property returns the Application Setup directory.

Return Values

A Hardware.EP4FileInfoCollection data type containing Application Setup directory.

EP4FileInfoCollection data structure is declared as follows:

public class EP4FileInfoCollection : IEnumerable


{
protected ArrayList ep4fileinfo;
protected bool dirty;
protected string data;

public EP4FileInfoCollection ()
{
ep4fileinfo = new ArrayList();
dirty = false;
}

public IEnumerator GetEnumerator()


{
dirty = false;
return (IEnumerator)(new EP4FileInfoEnumerator(this));
}

public string DirectoryData


{
get
{
return this.data;
}
set
{
this.data = value;
}
}
public int Add(Object value)
{
dirty = true;
return ep4fileinfo.Add(value);
}

public void Clear()


{
dirty = true;
ep4fileinfo.Clear();
return;
}

public int Count


{
get
{
return ep4fileinfo.Count;
}
}

public class EP4FileInfoEnumerator : IEnumerator


{
public EP4FileInfoEnumerator(EP4FileInfoCollection collection)
{
this.collection = collection;
position = -1;
}
protected int position;
protected EP4FileInfoCollection collection;

public Object Current


{
get
{
if (0 > position || position >= collection.ep4fileinfo.Count
|| collection.dirty)
throw new InvalidOperationException();

return collection.ep4fileinfo[position];
}
}

public void Reset()


{
collection.dirty = false;
position = -1;
}

public bool MoveNext()


{
if (collection.dirty)
throw new InvalidOperationException ();

position++;

return (position < collection.ep4fileinfo.Count);


}

}
}

An example for using this Property is as follows:

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

1. Communicating with 37dl plus gage.

using Hardware;
using PanUtilities;
using PanTypes;

Device devPtr = new Device(DeviceType.device_37dlp, "COM1", true);


devPtr.ConfigComm();
devPtr.InitDevice ();

//read device directory into listBox1


listBox1.Items.Clear();
string[] dir = devPtr.ReadDeviceDirectory ();
if (dir != null)
{
foreach (string str in dir)
{
listBox1.Items.Add(str);
}
else
{
MessageBox.Show ("Error Reading Device Directory");
}
}

//read a file from gage, the file was selected from listBox1, and save as test.txt int
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();

//write the file of C:\\test.txt to gage.


devPtr.WriteFile(C:\\test.txt);
while (devPtr.UploadCompleted == false)
{
int iprog = (int) devPtr.UploadProgres;
if (iprog >=0)
{
progressBar1.Value = (int) devPtr.UploadProgres;
progressBar1.Update();
System.Threading.Thread.Sleep (200);
}
}

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);
}

2. Sample code for communicating with MG2 gage

using Hardware;
using PanUtilities;
using PanTypes;

Device devPtr = new Device(DeviceType.device_mg2, "USB", true);


devPtr.InitDevice ();

//read device directory into listBox1


listBox1.Items.Clear();
string[] dir = devPtr.ReadDeviceDirectory ();
if (dir != null)
{
foreach (string str in dir)
{
listBox1.Items.Add(str);
}
}
else
{
MessageBox.Show ("Error Reading Device Directory");
}

//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();

//write the file of C:\\test.txt to gage.


devPtr.WriteFile(C:\\test.txt);
while (devPtr.UploadCompleted == false)
{
int iprog = (int) devPtr.UploadProgres;
if (iprog >=0)
{
progressBar1.Value = (int) devPtr.UploadProgres;
progressBar1.Update();
System.Threading.Thread.Sleep (200);
}
}

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;

Device devPtr = new Device(DeviceType.device_35dl, "USB", true);


devPtr.InitDevice ();

//read device directory into listBox1


listBox1.Items.Clear();
string[] dir = devPtr.ReadDeviceDirectory ();
if (dir != null)
{
foreach (string str in dir)
{
listBox1.Items.Add(str);
}
}
else
{
MessageBox.Show ("Error Reading Device Directory");
}

//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();

//write the file of C:\\test.txt to gage.


devPtr.WriteFile(C:\\test.txt);
while (devPtr.UploadCompleted == false)
{
int iprog = (int) devPtr.UploadProgres;
if (iprog >=0)
{
progressBar1.Value = (int) devPtr.UploadProgres;
progressBar1.Update();
System.Threading.Thread.Sleep (200);
}
}

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;

Device devPtr = new Device(DeviceType.device_35dl_rs232, "COM1", true);


devPtr.InitDevice ();

//read device directory into listBox1


listBox1.Items.Clear();
string[] dir = devPtr.ReadDeviceDirectory ();
if (dir != null)
{
foreach (string str in dir)
{
listBox1.Items.Add(str);
}
}
else
{
MessageBox.Show ("Error Reading Device Directory");
}

//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();

//write the file of C:\\test.txt to gage.


devPtr.WriteFile(C:\\test.txt);
while (devPtr.UploadCompleted == false)
{
int iprog = (int) devPtr.UploadProgres;
if (iprog >=0)
{
progressBar1.Value = (int) devPtr.UploadProgres;
progressBar1.Update();
System.Threading.Thread.Sleep (200);
}
}

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;

Device devPtr = new Device(DeviceType.device_38dlp, "USB", true);


devPtr.InitDevice ();

//read device directory into listBox1


listBox1.Items.Clear();
string[] dir = devPtr.ReadDeviceDirectory ();
if (dir != null)
{
foreach (string str in dir)
{
listBox1.Items.Add(str);
}
}
else
{
MessageBox.Show ("Error Reading Device Directory");
}
//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();

//write the file of C:\\test.txt to gage.


devPtr.WriteFile(C:\\test.txt);
while (devPtr.UploadCompleted == false)
{
int iprog = (int) devPtr.UploadProgres;
if (iprog >=0)
{
progressBar1.Value = (int) devPtr.UploadProgres;
progressBar1.Update();
System.Threading.Thread.Sleep (200);
}
}

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);
}

// Create a FTP Boiler file


string strFileName = "C:\\testCreate.txt";
string strSurveyName = "BOILLCR";

// Set up the start and end tub value


string StrStartTube = "1";
string strEndTube = "10";

// Set up the custom point list


string[] CustomPoints = new string[9];
CustomPoints[0] = "L1";
CustomPoints[1] = "L2";
CustomPoints[2] = "L3";
CustomPoints[3] = "C1";
CustomPoints[4] = "C2";
CustomPoints[5] = "C3";
CustomPoints[6] = "R1";
CustomPoints[7] = "R2";
CustomPoints[8] = "R3";

// Set up the Elevation list


string[] CustomElevations = new string[4];
CustomElevations[0] = "ELEV1";
CustomElevations[1] = "ELEV2";
CustomElevations[2] = "ELEV3";
CustomElevations[3] = "ELEV4";
// Create a FTP file now on PC side
if (devPtr.CreateSurveyBoilerFTPFile(strFileName, strSurveyName, StrStartTube, strEndTube,
CustomPoints, CustomElevations, (int)DATASET_INCREMENTS_TYPE.Tube,
(int)DATASET_INCREMENTS_TYPE.CustomPoint, (int)DATASET_PATTERN_TYPE.STANDARD))
{
MessageBox.Show("FTP File:" + strFileName + " is Created. ");
}

//write the Boiler FTP file to gage.


devPtr.CreateSurveyFile(strFileName);

while (devPtr.UploadCompleted == false)


{
int iprog = (int)devPtr.UploadProgres;
if (iprog >= 0)
{
progressBar1.Value = (int)devPtr.UploadProgres;
progressBar1.Update();
System.Threading.Thread.Sleep(200);
}
}

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;

Device devPtr = new Device(DeviceType.device_38dlp_rs232, "COM1", true);


devPtr.InitDevice ();

//read device directory into listBox1


listBox1.Items.Clear();
string[] dir = devPtr.ReadDeviceDirectory ();
if (dir != null)
{
foreach (string str in dir)
{
listBox1.Items.Add(str);
}
}
else
{
MessageBox.Show ("Error Reading Device Directory");
}

//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();

//write the file of C:\\test.txt to gage.


devPtr.WriteFile(C:\\test.txt);
while (devPtr.UploadCompleted == false)
{
int iprog = (int) devPtr.UploadProgres;
if (iprog >=0)
{
progressBar1.Value = (int) devPtr.UploadProgres;
progressBar1.Update();
System.Threading.Thread.Sleep (200);
}
}

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);
}

7. Sample code for communicating with Epoch 4/4B/Plus/LT gage

using Hardware;
using PanUtilities;
using PanTypes;

Device devPtr = new Device(Hardware.DeviceType.device_epochlt, "USB", true);


devPtr.InitDevice ();
//read device directory into listBox1
listBox1.Items.Clear();
string[] dir = devPtr.ReadDeviceDirectory ();
if (dir != null)
{
foreach (string str in dir)
{
listBox1.Items.Add(str);
}
}
else
{
MessageBox.Show ("Error Reading Device Directory");
}

//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.ReadFile(this.listBox1.SelectedIndex + 1);


// due to ReadFile(index)
// index value starts with 1 but this.listBox1.SelectedIndex value starts with // 0.

StreamWriter sw = new StreamWriter("C:\\test.txt");


sw.Write(data);
sw.Flush();
sw.Close();

//write the file of C:\\test.txt to gage.


devPtr.WriteFile(C:\\test.txt);
while (devPtr.UploadCompleted == false)
{
int iprog = (int) devPtr.UploadProgres;
if (iprog >=0)
{
progressBar1.Value = (int) devPtr.UploadProgres;
progressBar1.Update();
System.Threading.Thread.Sleep (200);
}
}

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);
}

8. Sample code for communicating with Epoch 600 / Epoch LTC

using Hardware;
using PanUtilities;
using PanTypes;

Device devPtr = new Device(Hardware.DeviceType.device_epoch600, "COM1", true);


devPtr.InitDevice ();
//read device directory into listBox1
listBox1.Items.Clear();
string[] dir = devPtr.ReadDeviceDirectory ();
if (dir != null)
{
foreach (string str in dir)
{
listBox1.Items.Add(str);
}
}
else
{
MessageBox.Show ("Error Reading Device Directory");
}

//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.

StreamWriter sw = new StreamWriter("C:\\test.txt");


sw.Write(data);
sw.Flush();
sw.Close();

//write the file of C:\\test.txt to gage.


devPtr.WriteFile(C:\\test.txt);
while (devPtr.UploadCompleted == false)
{
int iprog = (int) devPtr.UploadProgres;
if (iprog >=0)
{
progressBar1.Value = (int) devPtr.UploadProgres;
progressBar1.Update();
System.Threading.Thread.Sleep (200);
}
}

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);
}

You might also like