Main Page | Features | Central Services | csv-Files | Types | Transfer | Access | API-C | API-VB/ActiveX | API-Java | Examples | Downloads
Public Member Functions
de.desy.tine.client.TLink Class Reference

TLink.java. More...

List of all members.

Public Member Functions

void setNotificationTolerance (float absoluteValue, float percentValue)
 Sets the tolerance level for asynchronous event notification.
int getLinkStatus ()
 Returns the current status for this link.
String getContext ()
 Returns the context of this link.
String getDeviceServer ()
 Returns the device server addressed in this link.
String getDeviceName ()
 Returns the device (module) name addressed in this link.
String getProperty ()
 Returns the device property addressed in this link.
String getFullDeviceName ()
 Returns the fully qualified device name addressed in this link.
String getFullDeviceNameAndProperty ()
 Returns the fully qualified device name and property addressed in this link.
TDataType getOutputDataObject ()
 Returns the output data object as a TDataType.
TDataType getInputDataObject ()
 Returns the output data input as a TDataType.
long getLastTimeStamp ()
 The last link timestamp.
double getLastDataTimeStamp ()
 The last link timestamp as a TINE double timestamp value.
String getLastError ()
 The last link status in plain text.
String getError (int code)
 The specified error code in plain text.
int setErrorValue (double errValue)
 Specifies an error value to fill in associated data buffers in case of link error.
int setErrorValue (String errString)
 Specifies an error string to fill in associated data buffers in case of link error.
 TLink (String deviceName, String deviceProperty, TDataType dout, TDataType din, short devaccess)
 Defines a tine Data link.
 TLink (String devname, String devproperty, TDataType dout, TDataType din, int devaccess)
 Defines a tine Data link.
 TLink (String fullDeviceNameAndProperty, TDataType dout, TDataType din, short devaccess)
 Defines a tine Data link.
 TLink (String deviceName, String deviceProperty)
 Defines a read-only tine Data link with default behavior.
 TLink (String fullDeviceNameAndProperty)
 Defines a read-only tine Data link with default behavior.
 TLink (String globalKeyword, TDataType dout)
 Defines a tine GLobal Data link.
int attach (int mode, TCallback f)
 Attaches the data sets to the created link at the default polling rate (1000 msec)
synchronized int Twait ()
 Stop thread execution until this link has been signalled.
int execute ()
 Executes a synchronous link using the data sets supplied at link creation.
int executeAndClose ()
 Executes a synchronous link using the data sets supplied at link creation and Closes the link upon completion.
int execute (int timeout, short appendMode)
 Executes a synchronous link using the data sets supplied at link creation.
int execute (int timeout, boolean retryOnError)
 Executes a synchronous link using the data sets supplied at link creation.
int executeAndClose (int timeout, short appendMode)
 Executes a synchronous link using the data sets supplied at link creation and Closes the link upon completion.
synchronized int execute (int timeout, short appendMode, boolean retryOnError)
 Executes a synchronous link using the data sets supplied at link creation.
int execute (int timeout)
 Executes a synchronous link using the data sets supplied at link creation.
int executeAndClose (int timeout)
 Executes a synchronous link using the data sets supplied at link creation and Closes the link upon completion.
int cancel ()
 Terminates an active link.
int close ()
 Terminates an active link.
int attach (int mode, TCallback f, int pollrate)
 Attaches the data sets to the created link at the given polling rate.
synchronized int attach (int mode, TCallback f, int pollInterval, int notificationId)
 Attaches the data sets to the created link at the given polling rate and signals the callback routine using the give notification parameter.
int attach (int mode, TLinkCallback f, int pollrate)
 Attaches the data sets to the created link at the given polling rate and signals the callback routine using a reference to the TLink instance.
synchronized int attach (int mode, TLinkCallback f, int pollingInterval, Object reference)
 Attaches the data sets to the created link at the given polling rate and signals the callback routine using a reference to the TLink instance.
synchronized int receive (TCallback f)
 Attaches the data sets to the global link and signals the callback routine using the assigned link id.
synchronized int receive (TCallback f, int notificationId)
 Attaches the data sets to the global link and signals the callback routine using a reference to the given notifcation ID in the callback.
synchronized int receive (TLinkCallback f)
 Attaches the data sets to the global link and signals the callback routine using a reference to the referenced TLink object.
void waitForLinkCompletion ()
 Stops thread execution until this link has completed.
String getArrayDelimiter ()
 Gets the array delimiter for use in the toString() method of associated TDataType objects.
void setArrayDelimiter (String delimiter)
 Sets the array delimiter for use in the toString() method of associated TDataType objects.

Detailed Description

TLink.java.

User interface calls to access tine data links.

The methods presented here deal with linking local application data with remote data sources. Primarily you will need to create a TLink object, passing the necessary identifying parameters of the remote server to which the link is to be established. When the TLink object is instantiated, you will then need to retrieve the data using one of the retrieval methods, e.g. execute() for synchronous acquisition, or attach() for asynchronous acquisition, or receive() for the acquisition of network globals.


Constructor & Destructor Documentation

de.desy.tine.client.TLink.TLink ( String  deviceName,
String  deviceProperty,
TDataType  dout,
TDataType  din,
short  devaccess 
)

Defines a tine Data link.

This defines a tine Data Link, verifies that the requested deviceName exists and returns a non-null link object if successful. This does not establish the link! You must use either the execute method or the attach method to establish the link.

Parameters:
devnameis the fully specified device name as in /<context>/<server>/<device> or <server>/<device>
devpropertyis the desired property
doutis a reference to the output data object (which will receive the data from the server)
dinis a reference to the input data object (which will send data to the server)
devaccessis the requested control access mode (TMode.CA_READ, TMode.CA_WRITE etc.)
Returns:
A valid TLink instance if successful or null if not
Exceptions:
UnresolvedAddressExceptionif fullDeviceNameAndProperty does not point to a valid address (i.e. if the address pointed to is unable to be resolved by the system)
InvalidDataReferenceExceptionif the output data object used (dout above) is already used as the output data object in another TLink. For instance, TLink("/TEST/Server1/Device1","Property1",dout,null,TAccess.CA_READ) already exists. An attempt to create TLink("/TEST/Server1/Device1","Property2",dout,null,TAccess.CA_READ) will throw this exception as 'dout' is the same object already in use in the

Example:

    ...
    int cc = 0;
    int[] echobuf = new int[512];
    int[] echoin = new int[512];

    for (int i=0; i<512; i++) echoin[i] = i;

    TDataType dout = new TDataType(echobuf);
    TDataType din = new TDataType(echoin);

    TLink ech = new TLink("/TEST/ECHOSERVER/DEVICE_0","ECHO",dout,din,TAccess.CA_READ);

    if ((cc=ech.execute()) != 0)  // synchronous access ...
    {
      String msg = "err: " + cc;
      System.out.println(msg);
    }
    ech.cancel();                 // remove the TLink completely
    for (int i=0; i<512; i += 8)
    {
      System.out.println(echobuf[i] + " " + echobuf[i+1] + " " + echobuf[i+2] + " " + echobuf[i+3] + " " +
                         echobuf[i+4] + " " + echobuf[i+5] + " " + echobuf[i+6] + " " + echobuf[i+7] + " ");
    }
    ...
See also:
de.desy.tine.client.TLink.attach
de.desy.tine.client.TLink.execute
de.desy.tine.dataUtils.TDataType.TDataType
de.desy.tine.client.TLink.TLink ( String  devname,
String  devproperty,
TDataType  dout,
TDataType  din,
int  devaccess 
)

Defines a tine Data link.

This defines a tine Data Link, verifies that the requested deviceName exists and returns a non-null link object if successful. This does not establish the link! You must use either the execute method or the attach method to establish the link.

Parameters:
devnameis the fully specified device name as in /<context>/<server>/<device> or <server>/<device>
devpropertyis the desired property
doutis a reference to the output data object (which will receive the data from the server)
dinis a reference to the input data object (which will send data to the server)
devaccessis the requested control access mode (TMode.CA_READ, TMode.CA_WRITE etc.)
Returns:
A valid TLink instance if successful or null if not
Exceptions:
UnresolvedAddressExceptionif fullDeviceNameAndProperty does not point to a valid address (i.e. if the address pointed to is unable to be resolved by the system)
InvalidDataReferenceExceptionif the output data object used (dout above) is already used as the output data object in another TLink. For instance, TLink("/TEST/Server1/Device1","Property1",dout,null,TAccess.CA_READ) already exists. An attempt to create TLink("/TEST/Server1/Device1","Property2",dout,null,TAccess.CA_READ) will throw this exception as 'dout' is the same object already in use in the

Example:

    ...
    int cc = 0;
    int[] echobuf = new int[512];
    int[] echoin = new int[512];

    for (int i=0; i<512; i++) echoin[i] = i;

    TDataType dout = new TDataType(echobuf);
    TDataType din = new TDataType(echoin);

    TLink ech = new TLink("/TEST/ECHOSERVER/DEVICE_0","ECHO",dout,din,TAccess.CA_READ);

    if ((cc=ech.execute()) != 0)  // synchronous access ...
    {
      String msg = "err: " + cc;
      System.out.println(msg);
    }
    ech.cancel();                 // remove the TLink completely
    for (int i=0; i<512; i += 8)
    {
      System.out.println(echobuf[i] + " " + echobuf[i+1] + " " + echobuf[i+2] + " " + echobuf[i+3] + " " +
                         echobuf[i+4] + " " + echobuf[i+5] + " " + echobuf[i+6] + " " + echobuf[i+7] + " ");
    }
    ...
See also:
de.desy.tine.client.TLink.attach
de.desy.tine.client.TLink.execute
de.desy.tine.dataUtils.TDataType.TDataType
de.desy.tine.client.TLink.TLink ( String  fullDeviceNameAndProperty,
TDataType  dout,
TDataType  din,
short  devaccess 
)

Defines a tine Data link.

This defines a tine Data Link, verifies that the requested deviceName exists and returns a non-null link object if successful. This does not establish the link! You must use either the execute method or the attach method to establish the link.

Parameters:
fullDeviceNameAndPropertyis the fully specified, property-appended device name as in /<context>/<server>/<device>/<property> or <server>/<device>/<property>
doutis a reference to the output data object (which will receive the data from the server)
dinis a reference to the input data object (which will send data to the server)
devaccessis the requested control access mode (TMode.CA_READ, TMode.CA_WRITE etc.)
Returns:
A valid TLink instance if successful
Exceptions:
UnresolvedAddressExceptionif fullDeviceNameAndProperty does not point to a valid address (i.e. if the address pointed to is unable to be resolved by the system)
InvalidDataReferenceExceptionif the output data object used (dout above) is already used as the output data object in another TLink. For instance, TLink("/TEST/Server1/Device1","Property1",dout,null,TAccess.CA_READ) already exists. An attempt to create TLink("/TEST/Server1/Device1","Property2",dout,null,TAccess.CA_READ) will throw this exception as 'dout' is the same object already in use in the initial link.

Example:

    ...
    int cc = 0;
    float[] xorbit = new float[141];

    TDataType dout = new TDataType(xorbit);

    TLink xorb = new TLink("/HERA/HEPBPM/WL197 MX/ORBIT.X",dout,null,TAccess.CA_READ);

    if ((id=xorb.attach(TMode.CM_POLL,xorbCb,1000)) < 0)  // asynchronous access ...
    {
      String msg = "err: " + xorb.linkStatus;
      System.out.println(msg);
      xorb.cancel();                 // remove the TLink completely
      System.exit(1);
    }
    // link data is handled in callback routine xorbCb ...
    ...
See also:
de.desy.tine.client.TLink.attach
de.desy.tine.client.TLink.execute
de.desy .tine.dataUtils.TDataType.TDataType
de.desy.tine.client.TLink.TLink ( String  deviceName,
String  deviceProperty 
)

Defines a read-only tine Data link with default behavior.

This defines a tine Data Link, verifies that the requested deviceName exists and returns a non-null link object if successful. This does not establish the link! You must use either the execute method or the attach method to establish the link.

Parameters:
devnameis the fully specified device name as in /<context>/<server>/<device> or <server>/<device>
devpropertyis the desired property
Returns:
A valid TLink instance if successful or null if not
Exceptions:
UnresolvedAddressExceptionif fullDeviceNameAndProperty does not point to a valid address (i.e. if the address pointed to is unable to be resolved by the system)
InvalidDataReferenceExceptionif the output data object used (dout above) is already used as the output data object in another TLink. For instance, TLink("/TEST/Server1/Device1","Property1",dout,null,TAccess.CA_READ) already exists. An attempt to create TLink("/TEST/Server1/Device1","Property2",dout,null,TAccess.CA_READ) will throw this exception as 'dout' is the same object already in use in the

Example:

    ...

    TLink idc = new TLink("/HERA/HEEIDC/GEAR0","Current");

    int cc = idc.execute(1000);

    int dsize = idc.dOutput.getLastDataSize();
    int dfmt = idc.dOutput.getFormat();

    System.out.println("completion " + cc + " size " + dsize + " format " + dfmt);

    idc.setArrayDelimiter(", ");
    System.out.println(idc.dOutput.toString());    

    ...
See also:
de.desy.tine.client.TLink.attach
de.desy.tine.client.TLink.execute
de.desy.tine.client.TLink.TLink ( String  fullDeviceNameAndProperty)

Defines a read-only tine Data link with default behavior.

This defines a tine Data Link, verifies that the requested deviceName exists and returns a non-null link object if successful. This does not establish the link! You must use either the execute method or the attach method to establish the link.

Parameters:
fullDeviceNameAndPropertyis the fully specified, property-appended device name as in /<context>/<server>/<device>/<property> or <server>/<device>/<property>
Returns:
A valid TLink instance if successful or null if not
Exceptions:
UnresolvedAddressExceptionif fullDeviceNameAndProperty does not point to a valid address (i.e. if the address pointed to is unable to be resolved by the system)
InvalidDataReferenceExceptionif the output data object used (dout above) is already used as the output data object in another TLink. For instance, TLink("/TEST/Server1/Device1","Property1",dout,null,TAccess.CA_READ) already exists. An attempt to create TLink("/TEST/Server1/Device1","Property2",dout,null,TAccess.CA_READ) will throw this exception as 'dout' is the same object already in use in the

Example:

    ...

    TLink idc = new TLink("/HERA/HEEIDC/GEAR0/Current");

    int cc = idc.execute(1000);

    int dsize = idc.dOutput.getLastDataSize();
    int dfmt = idc.dOutput.getFormat();

    System.out.println("completion " + cc + " size " + dsize + " format " + dfmt);

    idc.setArrayDelimiter(", ");
    System.out.println(idc.dOutput.toString());    

    ...
See also:
de.desy.tine.client.TLink.attach
de.desy.tine.client.TLink.execute
de.desy.tine.client.TLink.TLink ( String  globalKeyword,
TDataType  dout 
)

Defines a tine GLobal Data link.

This defines a tine Data Link and assumes that the requested parameter is a network global, available on the tine multicast group. This method does not establish the link! You must use either the execute method or the attach method to establish the link.

Parameters:
globalKeywordis the desired network global parameter
doutis a reference to the output data object (which will receive the network global data).
Returns:
A valid TLink instance if successful or null if not

Example:

    ...

    float[] glbcurrent = new float[1];

    dout = new TDataType(glbcurrent);

    TLink glbcur = new TLink("HECur",dout);

    glbcur.receive((TCallback)null); // just attach the value to glbcurrent ...

    ...
See also:
de.desy.tine.client.TLink.attach
de.desy.tine.client.TLink.receive
de.desy.tine.dataUtils.TDataType.TDataType

Member Function Documentation

int de.desy.tine.client.TLink.attach ( int  mode,
TCallback  f 
)

Attaches the data sets to the created link at the default polling rate (1000 msec)

Asynchronous. This method attaches the data sets to the created link using the calling parameters provided at instantiation. The arriving data will automatically update the output data set and then fire the callback method provided. If the callback is not needed, a null can be passed for this parameter.

Parameters:
modeis the tine control mode parameter, that is one of TMode.CM_POLL, TMode.CM_REFRESH, TMode.SINGLE, etc. in possible combination with TMode.CM_NETWORK or TMode.CM_CONNECT, etc.
fis the 'callback function' to be called whenever either new data arrive or a change in link status occurs. The callback function should instantiate a class you create which implements the TCallback() class interface.
Returns:
A positive link handle if successful, otherwise -1. On failure the linkStatus property of TLink can be examined.

Example:

  public class OrbitCallback implements TCallback
  {
    public void callback(int id, int cc)
    {
      if (cc != 0)
      {
        System.out.println("Orbit Link Error : " + TErrorList.getErrorString(cc));
        return;
      }
      orbitChart.update();
    }
  }
  public int MonitorOrbit()
  {
    int cc = 0;
    float[] xorbit = new float[141];

    TDataType dout = new TDataType(xorbit);

    OrbitCallback xorbCb = new OrbitCallback();  // create a callback instance ...

    TLink xorb = new TLink("/HERA/HEPBPM/WL197 MX/ORBIT.X",dout,null,TAccess.CA_READ);

    if ((id=xorb.attach(TMode.CM_POLL,xorbCb)) < 0)  // asynchronous access ...
    {
      String msg = "err: " + xorb.linkStatus;
      System.out.println(msg);
      xorb.cancel();                 // remove the TLink completely
      System.exit(1);
    }
    // link data is handled in callback routine xorbCb ...
    ...
  }
See also:
de.desy.tine.client.TLink.TLink
de.desy.tine.client.TLink.TLinkCallback
de.desy.tine.client.TLink.execute
int de.desy.tine.client.TLink.attach ( int  mode,
TCallback  f,
int  pollrate 
)

Attaches the data sets to the created link at the given polling rate.

Asynchronous. This method attaches the data sets to the created link using the calling parameters provided at instantiation. The arriving data will automatically update the output data set and then fire the callback method provided. If the callback is not needed, a null can be passed for this parameter.

Parameters:
modeis the tine control mode parameter, that is one of TMode.CM_POLL, TMode.CM_REFRESH, TMode.SINGLE, etc. in possible combination with TMode.CM_NETWORK or TMode.CM_CONNECT, etc.
fis the 'callback function' to be called whenever either new data arrive or a change in link status occurs. The callback function should instantiate a class you create which implements the TCallback() class interface.
pollrateis the desired polling rate (at the server) in milliseconds.
Returns:
A positive link handle if successful, otherwise -1. On failure the linkStatus property of TLink can be examined.

Example:

  public class OrbitCallback implements TCallback
  {
    public void callback(int id, int cc)
    {
      if (cc != 0)
      {
        System.out.println("Orbit Link Error : " + TErrorList.getErrorString(cc));
        return;
      }
      orbitChart.update();
    }
  }
  public int MonitorOrbit()
  {
    int cc = 0;
    float[] xorbit = new float[141];

    TDataType dout = new TDataType(xorbit);

    OrbitCallback xorbCb = new OrbitCallback();  // create a callback instance ...

    TLink xorb = new TLink("/HERA/HEPBPM/WL197 MX/ORBIT.X",dout,null,TAccess.CA_READ);

    if ((id=xorb.attach(TMode.CM_POLL,xorbCb,1000)) < 0)  // asynchronous access ...
    {
      String msg = "err: " + xorb.linkStatus;
      System.out.println(msg);
      xorb.cancel();                 // remove the TLink completely
      System.exit(1);
    }
    // link data is handled in callback routine xorbCb ...
    ...
  }
See also:
de.desy.tine.client.TLink.TLink
de.desy.tine.client.TLink.TLinkCallback
de.desy.tine.client.TLink.execute
synchronized int de.desy.tine.client.TLink.attach ( int  mode,
TCallback  f,
int  pollInterval,
int  notificationId 
)

Attaches the data sets to the created link at the given polling rate and signals the callback routine using the give notification parameter.

Asynchronous. This method attaches the data sets to the created link using the calling parameters provided at instantiation. The arriving data will automatically update the output data set and then fire the callback method provided. If the callback is not needed, a null can be passed for this parameter.

Parameters:
modeis the tine control mode parameter, that is one of TMode.CM_POLL, TMode.CM_REFRESH, TMode.SINGLE, etc. in possible combination with TMode.CM_NETWORK or TMode.CM_CONNECT, etc.
fis the 'callback function' to be called whenever either new data arrive or a change in link status occurs. The callback function should instantiate a class you create which implements the TCallback() class interface.
pollIntervalis the desired polling interval (at the server) in milliseconds.
notificationIdis the desired identifier to be passed to the supplied callback routine when it is fired.
Returns:
A positive link handle if successful, otherwise -1. On failure the linkStatus property of TLink can be examined.

Example:

  private int xid = 0;
  private int yid = 1;

  public class OrbitCallback implements TCallback
  {
    public void callback(int id, int cc)
    {
      if (cc != 0)
      {
        System.out.println("Orbit Link Error : " + TErrorList.getErrorString(cc));
        return;
      }
      orbitChart[id].update();
    }
  }
  public int MonitorOrbit()
  {
    OrbitCallback orbCb = new OrbitCallback();  // create a callback instance ...

    int cc = 0;
    float[] xorbit = new float[141];

    TDataType dout = new TDataType(xorbit);

    TLink xorb = new TLink("/HERA/HEPBPM/WL197 MX/ORBIT.X",dout,null,TAccess.CA_READ);

    if (xorb.attach(TMode.CM_POLL,orbCb,500,xid) < 0)  // asynchronous access ...
    {
      String msg = "err: " + xorb.linkStatus;
      System.out.println(msg);
      xorb.cancel();                 // remove the TLink completely
      System.exit(1);
    }

    float[] yorbit = new float[141];

    dout = new TDataType(yorbit);

    TLink yorb = new TLink("/HERA/HEPBPM/WL164 MY/ORBIT.Y",dout,null,TAccess.CA_READ);

    if (yorb.attach(TMode.CM_POLL,orbCb,500,yid) < 0)  // asynchronous access ...
    {
      String msg = "err: " + yorb.linkStatus;
      System.out.println(msg);
      yorb.cancel();                 // remove the TLink completely
      System.exit(1);
    }
    // link data is handled in callback routine xorbCb ...
    ...
  }
See also:
de.desy.tine.client.TLink.TLink
de.desy.tine.client.TLink.TCallback
de.desy.tine.client.TLink.execute
int de.desy.tine.client.TLink.attach ( int  mode,
TLinkCallback  f,
int  pollrate 
)

Attaches the data sets to the created link at the given polling rate and signals the callback routine using a reference to the TLink instance.

Asynchronous. This method attaches the data sets to the created link using the calling parameters provided at instantiation. The arriving data will automatically update the output data set and then fire the callback method provided. If the callback is not needed, a null can be passed for this parameter. This is the preferred AttachLink method to use. The Callback instantiates a TLinkCallback() interface which provides a TLink object as parameter.

Parameters:
modeis the tine control mode parameter, that is one of TMode.CM_POLL, TMode.CM_REFRESH, TMode.SINGLE, etc. in possible combination with TMode.CM_NETWORK or TMode.CM_CONNECT, etc.
fis the 'callback function' to be called whenever either new data arrive or a change in link status occurs. The callback function should instantiate a class you create which implements the TLinkCallback() class interface.
pollrateis the desired polling rate (at the server) in milliseconds.
Returns:
A positive link handle if successful, otherwise -1. On failure the linkStatus property of TLink can be examined.

Example:

  private int xid = 0;
  private int yid = 1;

  public class OrbitCallback implements TLinkCallback
  {
    public void callback(TLink lnk)
    {
      if (lnk.getLinkStatus() != 0)
      {
        System.out.println("Link Error : " + lnk.getProperty() + " -> " + lnk.getLastError());
        return;
      }
      orbitChart.update(lnk.getProperty());
    }
  }
  public int MonitorOrbit()
  {
    OrbitCallback orbCb = new OrbitCallback();  // create a callback instance ...

    int cc = 0;
    float[] xorbit = new float[141];

    TDataType dout = new TDataType(xorbit);

    TLink xorb = new TLink("/HERA/HEPBPM/WL197 MX/ORBIT.X",dout,null,TAccess.CA_READ);

    if (xorb.attach(TMode.CM_POLL,orbCb,500) < 0)  // asynchronous access ...
    {
      String msg = "err: " + xorb.linkStatus;
      System.out.println(msg);
      xorb.cancel();                 // remove the TLink completely
      System.exit(1);
    }

    float[] yorbit = new float[141];

    dout = new TDataType(yorbit);

    TLink yorb = new TLink("/HERA/HEPBPM/WL164 MY/ORBIT.Y",dout,null,TAccess.CA_READ);

    if (yorb.attach(TMode.CM_POLL,orbCb,500) < 0)  // asynchronous access ...
    {
      String msg = "err: " + yorb.linkStatus;
      System.out.println(msg);
      yorb.cancel();                 // remove the TLink completely
      System.exit(1);
    }
    // link data is handled in callback routine xorbCb ...
    ...
  }
See also:
de.desy.tine.client.TLink.TLink
de.desy.tine.client.TLink.TLinkCallback
de.desy.tine.client.TLink.execute
synchronized int de.desy.tine.client.TLink.attach ( int  mode,
TLinkCallback  f,
int  pollingInterval,
Object  reference 
)

Attaches the data sets to the created link at the given polling rate and signals the callback routine using a reference to the TLink instance.

Asynchronous. This method attaches the data sets to the created link using the calling parameters provided at instantiation. The arriving data will automatically update the output data set and then fire the callback method provided. If the callback is not needed, a null can be passed for this parameter. This is the preferred AttachLink method to use. The Callback instantiates a TLinkCallback() interface which provides a TLink object as parameter.

Parameters:
modeis the tine control mode parameter, that is one of TMode.CM_POLL, TMode.CM_REFRESH, TMode.SINGLE, etc. in possible combination with TMode.CM_NETWORK or TMode.CM_CONNECT, etc.
fis the 'callback function' to be called whenever either new data arrive or a change in link status occurs. The callback function should instantiate a class you create which implements the TLinkCallback() class interface.
pollingIntervalis the desired polling rate (at the server) in milliseconds.
referenceis an optional reference to any object of the caller's choosing. As the callback returns a reference to the original link, this extra reference can be used to quickly find a table entry position for example.
Returns:
A positive link handle if successful, otherwise -1. On failure the linkStatus property of TLink can be examined.
See also:
de.desy.tine.client.TLink.TLink
de.desy.tine.client.TLink.TLinkCallback
de.desy.tine.client.TLink.execute
int de.desy.tine.client.TLink.close ( )

Terminates an active link.

Synonymous with cancel().

int de.desy.tine.client.TLink.execute ( )

Executes a synchronous link using the data sets supplied at link creation.

Synchronous. This method executes the link using the data sets and parameters provided at instantiation. The call will block for 1000 msec or until the call completes.

Note:
The TLink object created will remain resident until a call to the cancel() method is made. Thus repeated calls to execute() can be made without invoking separate calls to TLink().
Returns:
0 if successful, otherwise a tine return code which can be interpreted using getError() or getLastError().
Exceptions:
BoundToInactiveLinkException(unchecked) if the link calling the method is bound to another TLink (the parent link) and the parent link is currently inactive (while has has not yet been accessed). For instance

TLink lnk1 = new TLink("/TEST/Svr1/Dev1","Prp1",dout,din,TAccess.CA_READ);

TLink lnk2 = new TLink("/TEST/Svr1/Dev1","Prp1",dout,din,TAccess.CA_READ);

lnk2.execute();

will generate this exception as lnk2 is identical to lnk1, which was created first (and is therefore the parent link) but has not yet been activated via a call to attach() or execute().

Example:

    ...

    TLink idc = new TLink("/HERA/HEEIDC/GEAR0","Current");

    int cc = idc.execute();

    int dsize = idc.dOutput.getLastDataSize();
    int dfmt = idc.dOutput.getFormat();

    System.out.println("completion " + cc + " size " + dsize + " format " + dfmt);

    idc.setArrayDelimiter(", ");
    System.out.println(idc.dOutput.toString());    

    ...
See also:
de.desy.tine.client.TLink.TLink
de.desy.tine.client.TLink.attach
int de.desy.tine.client.TLink.execute ( int  timeout,
short  appendMode 
)

Executes a synchronous link using the data sets supplied at link creation.

Synchronous. This method executes the link using the data sets and parameters provided at instantiation. The call will block for the duration of the timeout specified or until the call completes.

Parameters:
timeoutThe amount of time in milliseconds to block execution until the call completes.
appendModewill be appended to the tine Control Mode, which is TMode.CM_SINGLE. (e.g. TMode.CM_CONNECT).
Note:
The TLink object created will remain resident until a call to the cancel() method is made. Thus repeated calls to execute() can be made without invoking separate calls to TLink().
Returns:
0 if successful, otherwise a tine return code which can be interpreted using getError() or getLastError().
Exceptions:
BoundToInactiveLinkException(unchecked) if the link calling the method is bound to another TLink (the parent link) and the parent link is currently inactive (while has has not yet been accessed). For instance

TLink lnk1 = new TLink("/TEST/Svr1/Dev1","Prp1",dout,din,TAccess.CA_READ);

TLink lnk2 = new TLink("/TEST/Svr1/Dev1","Prp1",dout,din,TAccess.CA_READ);

lnk2.execute();

will generate this exception as lnk2 is identical to lnk1, which was created first (and is therefore the parent link) but has not yet been activated via a call to attach() or execute().

Example:

    ...

    TLink idc = new TLink("/HERA/HEEIDC/GEAR0","Current");

    int cc = idc.execute(500,TMode.CM_CONNECT);

    int dsize = idc.dOutput.getLastDataSize();
    int dfmt = idc.dOutput.getFormat();

    System.out.println("completion " + cc + " size " + dsize + " format " + dfmt);

    idc.setArrayDelimiter(", ");
    System.out.println(idc.dOutput.toString());    

    ...
See also:
de.desy.tine.client.TLink.TLink
de.desy.tine.client.TLink.attach
int de.desy.tine.client.TLink.execute ( int  timeout,
boolean  retryOnError 
)

Executes a synchronous link using the data sets supplied at link creation.

Synchronous. This method executes the link using the data sets and parameters provided at instantiation. The call will block for the duration of the timeout specified or until the call completes.

Parameters:
timeoutThe amount of time in milliseconds to block execution until the call completes.
retryOnErrorif 'true' will instruct the tine engine to issue an automatic retry following a connection timeout.
Note:
The TLink object created will remain resident until a call to the cancel() method is made. Thus repeated calls to execute() can be made without invoking separate calls to TLink().
Returns:
0 if successful, otherwise a tine return code which can be interpreted using getError() or getLastError().
Exceptions:
BoundToInactiveLinkException(unchecked) if the link calling the method is bound to another TLink (the parent link) and the parent link is currently inactive (while has has not yet been accessed). For instance TLink lnk1 = new TLink("/TEST/Svr1/Dev1","Prp1",dout,din,TAccess.CA_READ); TLink lnk2 = new TLink("/TEST/Svr1/Dev1","Prp1",dout,din,TAccess.CA_READ); lnk2.execute(); will generate this exception as lnk2 is identical to lnk1, which was created first (and is therefore the parent link) but has not yet been activated via a call to attach() or execute().

Example:

    ...

    TLink idc = new TLink("/HERA/HEEIDC/GEAR0","Current");

    int cc = idc.execute(500,true);

    int dsize = idc.dOutput.getLastDataSize();
    int dfmt = idc.dOutput.getFormat();

    System.out.println("completion " + cc + " size " + dsize + " format " + dfmt);

    idc.setArrayDelimiter(", ");
    System.out.println(idc.dOutput.toString());    

    ...
See also:
de.desy.tine.client.TLink.TLink
de.desy.tine.client.TLink.attach
synchronized int de.desy.tine.client.TLink.execute ( int  timeout,
short  appendMode,
boolean  retryOnError 
)

Executes a synchronous link using the data sets supplied at link creation.

Synchronous. This method executes the link using the data sets and parameters provided at instantiation. The call will block for the duration of the timeout specified or until the call completes.

Parameters:
timeoutThe amount of time in milliseconds to block execution until the call completes.
appendModewill be appended to the tine Control Mode, which is TMode.CM_SINGLE. (e.g. TMode.CM_CONNECT).
retryOnErrorif 'true' will instruct the tine engine to issue an automatic retry following a connection timeout.
Note:
The TLink object created will remain resident until a call to the cancel() method is made. Thus repeated calls to execute() can be made without invoking separate calls to TLink().
Returns:
0 if successful, otherwise a tine return code which can be interpreted using getError() or getLastError().
Exceptions:
BoundToInactiveLinkException(unchecked) if the link calling the method is bound to another TLink (the parent link) and the parent link is currently inactive (while has has not yet been accessed). For instance

TLink lnk1 = new TLink("/TEST/Svr1/Dev1","Prp1",dout,din,TAccess.CA_READ);

TLink lnk2 = new TLink("/TEST/Svr1/Dev1","Prp1",dout,din,TAccess.CA_READ);

lnk2.execute();

will generate this exception as lnk2 is identical to lnk1, which was created first (and is therefore the parent link) but has not yet been activated via a call to attach() or execute().

Example:

    ...

    TLink idc = new TLink("/HERA/HEEIDC/GEAR0","Current");

    int cc = idc.execute(500,TMode.CM_CONNECT,true);

    int dsize = idc.dOutput.getLastDataSize();
    int dfmt = idc.dOutput.getFormat();

    System.out.println("completion " + cc + " size " + dsize + " format " + dfmt);

    idc.setArrayDelimiter(", ");
    System.out.println(idc.dOutput.toString());    

    ...
See also:
de.desy.tine.client.TLink.TLink
de.desy.tine.client.TLink.attach
int de.desy.tine.client.TLink.execute ( int  timeout)

Executes a synchronous link using the data sets supplied at link creation.

Synchronous. This method executes the link using the data sets and parameters provided at instantiation. The call will block for the duration of the timeout specified or until the call completes.

Parameters:
timeoutThe amount of time in milliseconds to block execution until the call completes.
Note:
The TLink object created will remain resident until a call to the cancel() method is made. Thus repeated calls to execute() can be made without invoking separate calls to TLink().
Returns:
0 if successful, otherwise a tine return code which can be interpreted using getError() or getLastError().
Exceptions:
BoundToInactiveLinkException(unchecked) if the link calling the method is bound to another TLink (the parent link) and the parent link is currently inactive (while has has not yet been accessed). For instance

TLink lnk1 = new TLink("/TEST/Svr1/Dev1","Prp1",dout,din,TAccess.CA_READ);

TLink lnk2 = new TLink("/TEST/Svr1/Dev1","Prp1",dout,din,TAccess.CA_READ);

lnk2.execute();

will generate this exception as lnk2 is identical to lnk1, which was created first (and is therefore the parent link) but has not yet been activated via a call to attach() or execute().

Example:

    ...

    TLink idc = new TLink("/HERA/HEEIDC/GEAR0","Current");

    int cc = idc.execute(500);

    int dsize = idc.dOutput.getLastDataSize();
    int dfmt = idc.dOutput.getFormat();

    System.out.println("completion " + cc + " size " + dsize + " format " + dfmt);

    idc.setArrayDelimiter(", ");
    System.out.println(idc.dOutput.toString());    

    ...
See also:
de.desy.tine.client.TLink.TLink
de.desy.tine.client.TLink.attach
int de.desy.tine.client.TLink.executeAndClose ( )

Executes a synchronous link using the data sets supplied at link creation and Closes the link upon completion.

Synchronous. This method executes the link using the data sets and parameters provided at instantiation. The call will block for the duration of the timeout specified or until the call completes. When the link has completed (successfully or not) the TLink will be automatically closed and hence removed from the link tables, obviating the need for an additional call to closeLink().

Returns:
0 if successful, otherwise a tine return code which can be interpreted using getError() or getLastError().
Exceptions:
BoundToInactiveLinkException(unchecked) if the link calling the method is bound to another TLink (the parent link) and the parent link is currently inactive (while has has not yet been accessed). For instance

TLink lnk1 = new TLink("/TEST/Svr1/Dev1","Prp1",dout,din,TAccess.CA_READ);

TLink lnk2 = new TLink("/TEST/Svr1/Dev1","Prp1",dout,din,TAccess.CA_READ);

lnk2.execute();

will generate this exception as lnk2 is identical to lnk1, which was created first (and is therefore the parent link) but has not yet been activated via a call to attach() or execute().

See also:
de.desy.tine.client.TLink.TLink
de.desy.tine.client.TLink.attach
int de.desy.tine.client.TLink.executeAndClose ( int  timeout,
short  appendMode 
)

Executes a synchronous link using the data sets supplied at link creation and Closes the link upon completion.

Synchronous. This method executes the link using the data sets and parameters provided at instantiation. The call will block for the duration of the timeout specified or until the call completes. When the link has completed (successfully or not) the TLink will be automatically closed and hence removed from the link tables, obviating the need for an additional call to closeLink().

Parameters:
timeoutThe amount of time in milliseconds to block execution until the call completes.
appendModewill be appended to the tine Control Mode, which is TMode.CM_SINGLE. (e.g. TMode.CM_CONNECT).
Returns:
0 if successful, otherwise a tine return code which can be interpreted using getError() or getLastError().
Exceptions:
BoundToInactiveLinkException(unchecked) if the link calling the method is bound to another TLink (the parent link) and the parent link is currently inactive (while has has not yet been accessed). For instance

TLink lnk1 = new TLink("/TEST/Svr1/Dev1","Prp1",dout,din,TAccess.CA_READ);

TLink lnk2 = new TLink("/TEST/Svr1/Dev1","Prp1",dout,din,TAccess.CA_READ);

lnk2.execute();

will generate this exception as lnk2 is identical to lnk1, which was created first (and is therefore the parent link) but has not yet been activated via a call to attach() or execute().

Exceptions:
BoundToInactiveLinkException(unchecked) if the link calling the method is bound to another TLink (the parent link) and the parent link is currently inactive (while has has not yet been accessed). For instance

TLink lnk1 = new TLink("/TEST/Svr1/Dev1","Prp1",dout,din,TAccess.CA_READ);

TLink lnk2 = new TLink("/TEST/Svr1/Dev1","Prp1",dout,din,TAccess.CA_READ);

lnk2.execute();

will generate this exception as lnk2 is identical to lnk1, which was created first (and is therefore the parent link) but has not yet been activated via a call to attach() or execute().

See also:
de.desy.tine.client.TLink.TLink
de.desy.tine.client.TLink.attach
int de.desy.tine.client.TLink.executeAndClose ( int  timeout)

Executes a synchronous link using the data sets supplied at link creation and Closes the link upon completion.

Synchronous. This method executes the link using the data sets and parameters provided at instantiation. The call will block for the duration of the timeout specified or until the call completes. When the link has completed (successfully or not) the TLink will be automatically closed and hence removed from the link tables, obviating the need for an additional call to closeLink().

Parameters:
timeoutThe amount of time in milliseconds to block execution until the call completes.
Returns:
0 if successful, otherwise a tine return code which can be interpreted using getError() or getLastError().
Exceptions:
BoundToInactiveLinkException(unchecked) if the link calling the method is bound to another TLink (the parent link) and the parent link is currently inactive (while has has not yet been accessed). For instance

TLink lnk1 = new TLink("/TEST/Svr1/Dev1","Prp1",dout,din,TAccess.CA_READ);

TLink lnk2 = new TLink("/TEST/Svr1/Dev1","Prp1",dout,din,TAccess.CA_READ);

lnk2.execute();

will generate this exception as lnk2 is identical to lnk1, which was created first (and is therefore the parent link) but has not yet been activated via a call to attach() or execute().

See also:
de.desy.tine.client.TLink.TLink
de.desy.tine.client.TLink.attach
String de.desy.tine.client.TLink.getArrayDelimiter ( )

Gets the array delimiter for use in the toString() method of associated TDataType objects.

Returns:
The delimiter in use in separating data variables in a string dump (default ",")
String de.desy.tine.client.TLink.getContext ( )

Returns the context of this link.

Returns:
The Context of the current link
String de.desy.tine.client.TLink.getDeviceName ( )

Returns the device (module) name addressed in this link.

Returns:
The device (module) name addressed in the current link
String de.desy.tine.client.TLink.getDeviceServer ( )

Returns the device server addressed in this link.

Returns:
The device server addressed in the current link
String de.desy.tine.client.TLink.getError ( int  code)

The specified error code in plain text.

Parameters:
codeIs the tine error code for which the error text is desired
Returns:
The specified error code in plain text
String de.desy.tine.client.TLink.getFullDeviceName ( )

Returns the fully qualified device name addressed in this link.

Returns:
The the fully qualified device name addressed in the current link
String de.desy.tine.client.TLink.getFullDeviceNameAndProperty ( )

Returns the fully qualified device name and property addressed in this link.

Returns:
The the fully qualified device name and property addressed in the current link
TDataType de.desy.tine.client.TLink.getInputDataObject ( )

Returns the output data input as a TDataType.

Returns:
The input data type
double de.desy.tine.client.TLink.getLastDataTimeStamp ( )

The last link timestamp as a TINE double timestamp value.

Returns:
The last link timestamp as a UTC java long value (seconds since 1.1.1970 with decimal fractional)
String de.desy.tine.client.TLink.getLastError ( )

The last link status in plain text.

Returns:
The last link status in plain text
long de.desy.tine.client.TLink.getLastTimeStamp ( )

The last link timestamp.

Returns:
The last link timestamp as a UTC java long value (milliseconds since 1.1.1970)
int de.desy.tine.client.TLink.getLinkStatus ( )

Returns the current status for this link.

Returns:
The Link status as tine error code
TDataType de.desy.tine.client.TLink.getOutputDataObject ( )

Returns the output data object as a TDataType.

Returns:
The output data type
String de.desy.tine.client.TLink.getProperty ( )

Returns the device property addressed in this link.

Returns:
The device property addressed in the current link
synchronized int de.desy.tine.client.TLink.receive ( TLinkCallback  f)

Attaches the data sets to the global link and signals the callback routine using a reference to the referenced TLink object.

Asynchronous. This method attaches the data sets to the created link using the calling parameters provided at instantiation. The arriving data will automatically update the output data set and then fire the callback method provided. If the callback is not needed, a null can be passed for this parameter. Using the receive() method assumes that the data requested are global available. This is the preferred receive method to use. The Callback instantiates a TLinkCallback() interface which provides a TLink object as parameter.

Parameters:
fis the 'callback function' to be called whenever either new data arrive or a change in link status occurs. The callback function should instantiate a class you create which implements the TLinkCallback() class interface.
Returns:
A positive link handle if successful, otherwise -1. On failure the linkStatus property of TLink can be examined.

Example:

  private int eid = 0;
  private int cid = 1;
  public float[] energy = new float[1];
  public float[] current = new float[1];

  public class glbCallback implements TLinkCallback
  {
    public void callback(TLink lnk)
    {
      if (lnk.getLinkStatus() != 0)
      {
        System.out.println("Link Error : " + lnk.getProperty() + " -> " + lnk.getLastError());
        return;
      }
      if (lnk.getProperty().compareTo("HEMAGEN") == 0) System.out.println("energy  : " + energy[0]);
      if (lnk.getProperty().compareTo("HEDCCur") == 0) System.out.println("current : " + current[0]);
    }
  }
  public int MonitorGlobals()
  {
    glbCallback glbCb = new glbCallback();  // create a callback instance ...

    int cc = 0;
 
    TDataType dout = new TDataType(energy);

    TLink ene = new TLink("HEMAGEN",dout);

    if (ene.receive(glbCb) < 0)  // asynchronous global access ...
    {
      String msg = "err: " + ene.getLinkStatus;
      System.out.println(msg);
      ene.cancel();                 // remove the TLink completely
      System.exit(1);
    }
    ene.waitForLinkCompletion();    // make sure the first energy value is available
                                    // before continuing

    dout = new TDataType(current);

    TLink cur = new TLink("HEDCCur",dout);

    if (cur.receive(glbCb) < 0)  // asynchronous access ...
    {
      String msg = "err: " + cur.getLinkStatus;
      System.out.println(msg);
      cur.cancel();                 // remove the TLink completely
      System.exit(1);
    }
    // link data is handled in callback routine glbbCb ...
    ...
  }
See also:
de.desy.tine.client.TLink.TLink
de.desy.tine.client.TLink.TLinkCallback
de.desy.tine.client.TLink.receive(TCallback f)
synchronized int de.desy.tine.client.TLink.receive ( TCallback  f,
int  notificationId 
)

Attaches the data sets to the global link and signals the callback routine using a reference to the given notifcation ID in the callback.

Asynchronous. This method attaches the data sets to the created link using the calling parameters provided at instantiation. The arriving data will automatically update the output data set and then fire the callback method provided. If the callback is not needed, a null can be passed for this parameter. Using the receive() method assumes that the data requested are global available.

Parameters:
fis the 'callback function' to be called whenever either new data arrive or a change in link status occurs. The callback function should instantiate a class you create which implements the TCallback() class interface.
notificationIdis the desired identifier to be passed to the supplied callback routine when it is fired.
Returns:
A positive link handle if successful, otherwise -1. On failure the linkStatus property of TLink can be examined.

Example:

  private int eid = 0;
  private int cid = 1;
  public float[] energy = new float[1];
  public float[] current = new float[1];

  public class glbCallback implements TCallback
  {
    public void callback(int id, int cc)
    {
      if (cc != 0)
      {
        System.out.println("globals Link Error : " + TErrorList.getErrorString(cc));
        return;
      }
      glb[id].update();  // for example ...
    }
  }
  public int MonitorGlobals()
  {
    glbCallback glbCb = new glbCallback();  // create a callback instance ...

    int cc = 0;
 
    TDataType dout = new TDataType(energy);

    TLink ene = new TLink("HEMAGEN",dout);

    if (ene.receive(glbCb,eid) < 0)  // asynchronous global access ...
    {
      String msg = "err: " + ene.getLinkStatus;
      System.out.println(msg);
      ene.cancel();                 // remove the TLink completely
      System.exit(1);
    }

    dout = new TDataType(current);

    TLink cur = new TLink("HEDCCur",dout);

    if (cur.receive(glbCb,500,cid) < 0)  // asynchronous global access ...
    {
      String msg = "err: " + cur.getLinkStatus;
      System.out.println(msg);
      cur.cancel();                 // remove the TLink completely
      System.exit(1);
    }
    // link data is handled in callback routine glbbCb ...
    ...
  }
See also:
de.desy.tine.client.TLink.TLink
de.desy.tine.client.TLink.TLinkCallback
de.desy.tine.client.TLink.receive(TCallback f)
synchronized int de.desy.tine.client.TLink.receive ( TCallback  f)

Attaches the data sets to the global link and signals the callback routine using the assigned link id.

Asynchronous. This method attaches the data sets to the created link using the calling parameters provided at instantiation. The arriving data will automatically update the output data set and then fire the callback method provided. If the callback is not needed, a null can be passed for this parameter. Using the receive() method assumes that the data requested are global available.

Parameters:
fis the 'callback function' to be called whenever either new data arrive or a change in link status occurs. The callback function should instantiate a class you create which implements the TCallback() class interface.
Returns:
A positive link handle if successful, otherwise -1. On failure the linkStatus property of TLink can be examined.

Example:

  public class glbCallback implements TCallback
  {
    public void callback(int id, int cc)
    {
      if (cc != 0)
      {
        System.out.println("Global Link Error : " + TErrorList.getErrorString(cc));
        return;
      }
      eneDisplay.update(); // <- for example ...
    }
  }
  public int MonitorEnergy()
  {
    int cc = 0;
    float[] energy_e = new float[1];

    TDataType dout = new TDataType(energy_e);

    glbCallback eneCb = new glbCallback();  // create a callback instance ...

    TLink ene = new TLink("HEMAGEN",dout);

    if ((id=ene.receive(eneCb)) < 0)  // asynchronous access of global variable ...
    {
      String msg = "err: " + xorb.getLinkStatus;
      System.out.println(msg);
      ene.cancel();                 // remove the TLink completely
      System.exit(1);
    }
    // link data is handled in callback routine eneCb ...
    ...
  }
See also:
de.desy.tine.client.TLink.TLink
de.desy.tine.client.TLink.TLinkCallback
de.desy.tine.client.TLink.receive(TCallback f,int notificationId)
de.desy.tine.client.TLink.receive(TLinkCallback f)
void de.desy.tine.client.TLink.setArrayDelimiter ( String  delimiter)

Sets the array delimiter for use in the toString() method of associated TDataType objects.

Parameters:
delimiteris the string delimiter to use in separating data variables in a string dump (default ",")
int de.desy.tine.client.TLink.setErrorValue ( String  errString)

Specifies an error string to fill in associated data buffers in case of link error.

Parameters:
errStringIs the string to use in case of link errors

0 if successful

int de.desy.tine.client.TLink.setErrorValue ( double  errValue)

Specifies an error value to fill in associated data buffers in case of link error.

Parameters:
errValueIs the error value to use in case of link errors

0 if successful

void de.desy.tine.client.TLink.setNotificationTolerance ( float  absoluteValue,
float  percentValue 
)

Sets the tolerance level for asynchronous event notification.

Link callback notification can be suppressed if changes in the link data do not exceed the tolerance applied in this call. The tolerance can have an absolute part (in the units of the data) and/or a percent part.

Parameters:
absoluteValueis the absolute tolerance any particular data element is allowed to have before an event notification is called.
percentValueis the percent tolerance any particular data element is allowed to have before an event notification is called.
void de.desy.tine.client.TLink.waitForLinkCompletion ( )

Stops thread execution until this link has completed.

Useful for grouped asynchronous links.


The documentation for this class was generated from the following file: