Agilent Technologies 86038B User Manual page 191

Photonic dispersion and loss analyzer
Table of Contents

Advertisement

Agilent 86038B Photonic Dispersion and Loss Analyzer, Second Edition
Note that because of the 'using' statement at the head of the file,
you did not have to type the whole root to eEventLogType – a
considerable typing savings.
Now you need to tell the pdlaClient about the new function.
First you have to find the delegate that knows how to handle
NewStatus events. The delegates are also found underneath the
ODACommon object where you found the eEventLogType.
Return to the Object Browser window and scroll down to find
the ODARemoting.NewStatusDelegate object. That is the
delegate you need to use for this event, and you will find
delegates for all the PDLA events in the same place, with the
same name as the event with the word Delegate appended. Note
that several similarly spelled versions appear, but you only want
the one spelled exactly the same as the event with the word
Delegate appended.
The steps below walk you through adding the appropriate
declarations to create the delegate and register our event
handler.
1 Add a display line to show a user status messages. Add a text
label as wide as the form, and call it lblStatus. Default the
text to "PDLA Status."
2 Go to the code window and find where you declared the
pdlaClient. Add the declaration of a local copy of the delegate
here:
// Declare event handlers for PDLA all!
private pdlaRemoting.NewStatusDelegate NewStatusHandler;
3 Find the declaration of Form1_Closing, and insert this
routine after it:
private void NewStatusEvent( string msg, ODACommon.eEventLogType e )
{
// Let the user know something happened
lblStatus.Text=msg;
}
4 Now, register the handler when the connection to the PDLA
is opened. Find the pbConnect_Click method, and add the
following lines
// Create our event handlers
this.NewStatusHandler = new ODARemoting.NewStatusDelegate(
this.NewStatusEvent );
// Register event handlers
pdlaClient.NewStatus += this.NewStatusHandler;
5 Since you registered the handler, you have to be careful to
unregister it when you are done talking to the PDLA. Find
191

Advertisement

Table of Contents
loading

Table of Contents