The API publishes 2 events that can be subscribed to:

  • CommandEvent

This event is published when a component is performing a command, i.e a device is sent a SCPI command or a calibration is executing.

The event handler must have the following signature:

public delegate void CommandEvent(int eventId, string senderName, string eventDescription, string detailStr, bool updateFlag);


The parameters  are:

    • eventId

The event ID is an integer value and is unique for each event during an execution of a calibration or sequence. This value is used when an event updates its description or detail string. For example, when a calibration  file is requested from a device, the request will be published as an event with the eventId set to 17 and the detail set to "awaiting response". Once the file is transferred the event will update with the eventId set to 17, the updateFlag set to true and the detail string set to "20,368 bytes transfered".

    • senderName

The sender name will be the name of the component, as defined in the configuration file, that is generating the event. For example, if a SCPI command is being sent, senderName will be the device name, if a calibration is being started it will be the name of the calibration.

    • eventDescription

The event description is a text string that describes the event that is being published. For example it could be the SCPI command that was sent, or the switch path that is being set.

    • detailStr

The detail string is a text string that is typically the response received from a SCPI command. This could be an ACK or the response sent to a query.

    • updateFlag

The update flag is a boolean that signals whether this event is an original event or an update to a previous event. Typically this flag will be sent when an event takes a long time such as a query response. The original event that is published when the query is sent will have this flag set to false. When the response comes back the event will have the same event ID as the original and the update flag set to true with the detail string containing the response.

  • Error Event

This event is published when an error is detected, i.e a validation error, a timeout error.

The event handler must have the following signature:

public delegate void ErrorEvent(string error);

The parameters  are:

    • error

The error is a text string that contains the error message. If an exception caused the error then this string will contain the exception message.

For more detail please see the interface module: IApi.cs.

Below is an example code snippet.

using AteSystems.InCal;

public void Example()
{
   // Get a reference to the API interface
   AteSystems.InCal.IApi api = AteSystems.InCal.API.Initialize(@"C:\Temp\MyConfig.ini", catchExceptions:true);
   // Subscribe to the event
   api.ErrorEvent += ErrorMessageEvent;
   api.CommandEvent += ScpiCommandEvent;
   // Call the API function
   api.Calibrate(calName, pnaName);
   // Unsubscribe from the event
   api.ErrorEvent -= ErrorMessageEvent;
   api.CommandEvent -= ScpiCommandEvent;
}

private void ErrorMessageEvent(string error)
{
   // handle the error
}

private void ScpiCommandEvent(int eventId, string name, string command, string response, bool update)
{
   // handle the command notification, perhaps display it in a list
}