Package de.desy.tine.client

Examples of de.desy.tine.client.TLink


  private static String[] getDeviceNames64(String context,String server,String property,String filter,int timeout) throws IOException
  {
    DeviceNamesQueryParams dnqp = getDeviceNamesQueryProperty(context,server,property,filter,timeout);
    if (dnqp == null) return null;
   
    TLink tl;
    TDataType dout;
    int cc = 0,i;
    NAME64[] devices;
    String[] strdevs;
    int n = dnqp.size;

    //if (n*64 > maxQueryBufferSize) n = maxQueryBufferSize/64;
    devices = new NAME64[n];
    for (i=0; i<n; i++) devices[i] = new NAME64();
    if (devices.length == 0) return null;
    dout = new TDataType(devices);
    tl = new TLink(dnqp.target,dnqp.property,dout,null,TAccess.CA_READ);
    cc = tl.executeAndClose(timeout);
    if ((cc & TErrorList.CE_SENDDATA) == TErrorList.CE_SENDDATA)
    {
      if ((cc & TErrorList.has_query_function) == TErrorList.has_query_function)
      {
        devices_have_query_function = true;
View Full Code Here


    TDataType din = new TDataType(tag);
    TDataType dout = new TDataType(sf);
    String tgt;
    if (context == null || context.length() == 0) context = "DEFAULT";
    tgt = new String("/"+context+"/"+server+"/#0");
    TLink tl = new TLink(tgt,"STRUCTFORMAT",dout,din,TAccess.CA_READ);
    cc = tl.execute(TLink.defaultTimeout,true);
    if ((cc & TErrorList.CE_SENDDATA) == TErrorList.CE_SENDDATA) cc = 0;
    tl.close();
    if (cc == 0)
    {
      TStructDescription sd = new TStructDescription(tag);
      sd.beginDefinition();
      for (int i=0; i<64; i++)
View Full Code Here

        ntries = 2;
      }
    }
    for (int i=0; i<ntries; i++)
    {
      TLink tl = new TLink(dname,pname[i],dout,din,TAccess.CA_READ);
      cc = tl.execute(2000, true);
      targetTime[0] = tl.getLastDataTimeStamp();
      tl.close();
      if (cc == 0 && dout.getCompletionLength() > 0) break;
    }
    return cc;
 
View Full Code Here

  {
    THistoryRecordStruct[] hrs = new THistoryRecordStruct[1];
    THistorySpecification hsp = new THistorySpecification(pollInterval, archInterval, depthShort, depthLong, heartBeat, pTolerance, aTolerance, null);
    hrs[0] = new THistoryRecordStruct(device, property, datasiz, datafmt, hsp);
    String dev = "/"+context+"/"+server;
    TLink lnk = new TLink(dev,"ADDHISTORY",null,new TDataType(hrs),TAccess.CA_WRITE);
    return lnk.executeAndClose();
  }
View Full Code Here

    TDataType din = new TDataType(tag);
    TDataType dout = new TDataType(sf);
    String tgt;
    if (context == null || context.length() == 0) context = "DEFAULT";
    tgt = new String("/"+context+"/"+server+"/#0");
    TLink tl = new TLink(tgt,"STRUCTFORMAT",dout,din,TAccess.CA_READ);
    cc = tl.execute(TLink.defaultTimeout,true);
    if ((cc & TErrorList.CE_SENDDATA) == TErrorList.CE_SENDDATA) cc = 0;
    tl.close();
    if (cc == 0)
    {
      TStructDescription sd = new TStructDescription(tag);
      sd.beginDefinition();
      for (int i=0; i<64; i++)
View Full Code Here

    THistoryRecordStruct[] hrs = new THistoryRecordStruct[1];
    hrs[0] = new THistoryRecordStruct();
    String dev = "/"+context+"/"+server;
    TDataType dout = new TDataType(hrs);
    TDataType din = new TDataType(property.toCharArray());
    TLink lnk = new TLink(dev,"HISTORIES",dout,din,TAccess.CA_READ);
    int cc = lnk.executeAndClose();
    if (cc != 0) return null;
    if (dout.getCompletionLength() < 1) return null;
    return hrs[0];
  }
View Full Code Here

    TDataType dtprps;
    tagsString = isCentral ? "TAGS" : "HISTORIES";
    ntagsString = "N" + tagsString;
   
    String dname = "/" + context + "/" + server;
    TLink tl = new TLink(dname,ntagsString,dtnprps,dtsubs,TAccess.CA_READ);
    int cc = tl.execute(800, true);
    tl.close();
    if (cc != 0)
    { // TODO: throw an exception here
      return null;
    }
    if (nprps[0] > 0)
    {
      nlist = new NAME32[nprps[0]];
      dtprps = new TDataType(nlist);
      tl = new TLink(dname,tagsString,dtprps,dtsubs,TAccess.CA_READ);
      cc = tl.execute(800, true);
      tl.close();
      if (cc != 0)
      { // TODO: throw an exception here
        return null;
      }
    }
View Full Code Here

  {
    return getDevicePropertyInformationX("PROPS", context,server,device,property,timeout);
  }
  private static synchronized XPropertyQuery[] getDevicePropertyInformationX(String stockprop, String context,String server,String device,String property,int timeout)
  {
    TLink tl;
    TDataType dout, din;
    int cc = 0,i;
    String tgt, dev;
    XPropertyQuery[] xpq = null;
    XPropertyQuery xpq1 = new XPropertyQuery();
    byte[] blob = hByteBlobX;
    boolean hasTarget = true;
 
    if (server == null || server.length() == 0) return null;
    if (device == null || device.length() == 0)
      dev = new String("#0");
    else
      dev = device;
    if (context == null || context.length() == 0)
      tgt = new String("/DEFAULT/" + server + "/" + dev);
    else
      tgt = new String("/" + context + "/" + server + "/" + dev);
    int np = nicePropertyQuerySize;
    if (property == null || property.compareTo("*") == 0)
    {
      din = new TDataType();
      String target = "/" + context + "/" + server;
      try
      {
        np = getNumberOf("PROPERTIES", target, timeout);
      }
      catch (IOException e)
      {
        throw new RuntimeException("Could not acquire property information for " + server + " (" + TErrorList.getErrorString(cc) + ")");
      }
      int fudge_factor = np > 150 ? 1 : 2;
      blob = new byte[fudge_factor * np * XPropertyQuery.sizeInBytes]; // allow room for overloads
      hasTarget = false;
    }
    else
    {
      din = new TDataType(property);
    }
    dout = new TDataType(blob,"XPQS");

    while (np > 0)
    {
      try
      {
        tl = new TLink(tgt,stockprop,dout,din,TAccess.CA_READ);
        cc = tl.execute(timeout,true);
        srvAddr = tl.srvAddr;
        if ((cc & TErrorList.CE_SENDDATA) == TErrorList.CE_SENDDATA) cc = 0;
        tl.close();
      }
      catch (Exception e)
      {
        MsgLog.log("getDevicePropertyInformationX", e.getMessage(),TErrorList.non_existent_elem,e,0);
        cc = TErrorList.non_existent_elem;
      }
      if (cc == TErrorList.invalid_transport_size)
      {
        np /= 2;
        blob = new byte[np * XPropertyQuery.sizeInBytes]; // allow room for overloads
        dout = new TDataType(blob,"XPQS");
      }
      else
      {
        break;
      }
    }
    if (cc == 0) // it's at lease a 3.31 server
    {     
      try
      {
        TStructIo.bytesToStruct(xpq1, blob,0,XPropertyQuery.sizeInBytes);
      }
      catch (IOException e1) { e1.printStackTrace(); }

      int nxpq = dout.dCompletionLength;
      if (hasTarget)
      {
        if (xpq1.prpNumOverloads < 1) xpq1.prpNumOverloads = 1; // can't be less than 1 !
        nxpq = xpq1.prpNumOverloads;
        if (nxpq > nicePropertyQuerySize) nxpq = nicePropertyQuerySize;
      }
      if (nxpq == 0) return null;     
     
      if (xpq1.prpNumOverloads < 1) xpq1.prpNumOverloads = 1; // can't be less than 1 !
      if (nxpq > np) nxpq = np;
      xpq = new XPropertyQuery[nxpq];
      xpq[0] = xpq1;
      for (i=1; i<nxpq; i++)
      {
        xpq[i] = new XPropertyQuery();
        try {
          TStructIo.bytesToStruct(xpq[i],blob,i*XPropertyQuery.sizeInBytes,XPropertyQuery.sizeInBytes);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
      return xpq;
    }
    if (cc == TErrorList.link_not_open)
    {
      throw new RuntimeException("Could not acquire property information for " + server + " (" + TErrorList.getErrorString(cc) + ")");
    }
    if (cc == TErrorList.non_existent) return null;
    PropertyQueryLegacy[] pqx = null;
    PropertyQueryLegacy pqx1 = new PropertyQueryLegacy();
    dout = new TDataType(hByteBlobL,"PQSX");
    tl = new TLink(tgt,stockprop,dout,din,TAccess.CA_READ);
    cc = tl.execute(timeout,true);
    tl.close();
    if (cc == 0) // it's at lease a 3.20 server
    {
      byte b[] = pqx1.toByteArray();
      System.arraycopy(hByteBlobL,0,b,0,PropertyQueryLegacy.sizeInBytes);
      pqx1.toStruct();
      int npqx = np;
      if (hasTarget)
      {
        if (pqx1.prpNumOverloads < 1) pqx1.prpNumOverloads = 1; // can't be less than 1 !
        npqx = pqx1.prpNumOverloads;
      }
      if (npqx > nicePropertyQuerySize) npqx = nicePropertyQuerySize;
      pqx = new PropertyQueryLegacy[npqx];
      xpq = new XPropertyQuery[npqx];
      pqx[0] = pqx1;
      for (i=1; i<npqx; i++)
      {
        pqx[i] = new PropertyQueryLegacy();
        b = pqx[i].toByteArray();
        System.arraycopy(hByteBlobL,i*PropertyQueryLegacy.sizeInBytes,b,0,PropertyQueryLegacy.sizeInBytes);
        pqx[i].toStruct();
      }
      for (i=0; i<npqx; i++)
      {
        xpq[i] = new XPropertyQuery();
        xpq[i].prpFormat = pqx[i].prpFormat;
        xpq[i].prpFormatIn = pqx[i].prpFormatIn;
        xpq[i].prpSize = pqx[i].prpSize;
        xpq[i].prpSizeIn = pqx[i].prpSizeIn;
        xpq[i].prpAccess = pqx[i].prpAccess;
        xpq[i].prpDescription = pqx[i].prpDescription;
        xpq[i].prpName = pqx[i].prpName;
        xpq[i].prpNumOverloads = pqx[i].prpNumOverloads;
        xpq[i].prpTag = pqx[i].prpTag;
        xpq[i].prpTagIn = pqx[i].prpTagIn;
        xpq[i].prpRedirection = pqx[i].prpRedirection;
        xpq[i].prpHistoryDepthLong = pqx[i].prpHistoryDepthLong;
        xpq[i].prpHistoryDepthShort = pqx[i].prpHistoryDepthShort;
        xpq[i].prpUnits = pqx[i].prpUnits;
        xpq[i].prpMaxValue = pqx[i].prpMaxValue;
        xpq[i].prpMinValue = pqx[i].prpMinValue;
        xpq[i].prpGraphType = pqx[i].prpGraphType;
      }
      return xpq;
    }
    if (cc == TErrorList.link_not_open)
    {
      throw new RuntimeException("Could not acquire property information for " + server + " (" + TErrorList.getErrorString(cc) + ")");
    }
    // legacy server
    hLegacyByteBlob = null;
    String[] prps = getDeviceProperties(context,server,device);
    if (prps == null || prps.length == 0) return null;
    PropertyQuery[] pq = new PropertyQuery[prps.length];
    xpq = new XPropertyQuery[1];
    byte b[];
    if (hLegacyByteBlob == null) return null;
    for (i=0; i<prps.length; i++)
    {
      pq[i] = new PropertyQuery();
      b = pq[i].toByteArray();
      System.arraycopy(hLegacyByteBlob,i*PropertyQuery.sizeInBytes,b,0,PropertyQuery.sizeInBytes);
      pq[i].toStruct();
      if (pq[i].name.compareTo(property) != 0) continue;
      xpq[0] = new XPropertyQuery();
      xpq[0].prpFormat = pq[i].prpFormat;
      xpq[0].prpSize = pq[i].prpSize;
      xpq[0].prpAccess = pq[i].prpAccess;
      xpq[0].prpDescription = pq[i].prpDesc;
      xpq[0].prpName = pq[i].name;
      xpq[0].prpNumOverloads = 1;
      if ((pq[0].prpAccess & TAccess.CA_WRITE) == TAccess.CA_WRITE)
      {
         xpq[0].prpFormatIn = pq[i].prpFormat;
         xpq[0].prpSizeIn = pq[i].prpSize;
      }
      else    
      {
         xpq[0].prpFormatIn = (byte)TFormat.CF_NULL;
         xpq[0].prpSizeIn = 0;
      }
      USTRING[] egu = new USTRING[1];
      egu[0] = new USTRING();
      dout = new TDataType(egu);
      din = new TDataType();
      String prpegu = new String(property + ".EGU");
      tl = new TLink(tgt,prpegu,dout,din,TAccess.CA_READ);
      cc = tl.execute(timeout,false);
      tl.close();
      if (cc == 0)
      {
        xpq[0].prpMinValue = egu[0].f1val;
        xpq[0].prpMaxValue = egu[0].f2val;
        xpq[0].prpUnits = egu[0].str;
View Full Code Here

    if (server == null) server = "HISTORY";
    NAME64[] nlist = new NAME64[1000];
    TDataType dtprps = new TDataType(nlist);
   
    String dname = "/" + context + "/" + server;
    TLink tl = new TLink(dname,"*.SRCADDR",dtprps,null,TAccess.CA_READ);
    int cc = tl.executeAndClose(800);
    if (cc != 0)
    { // TODO: throw an exception here
      return null;
    }
    int listsize = dtprps.getCompletionLength();
View Full Code Here

    TDataType dtsubs;
    tagsString = "SUBSYSTEMS";
    ntagsString = "N" + tagsString;
   
    String dname = "/" + context + "/" + server;
    TLink tl = new TLink(dname,ntagsString,dtnsubs,null,TAccess.CA_READ);
    cc = tl.execute(800, true);
    tl.close();
    if (cc != 0)
    { // TODO: throw an exception here
      return null;
    }
    if (nsubs[0] > 0)
    {
      nlist = new NAME32[nsubs[0]];
      dtsubs = new TDataType(nlist);
      tl = new TLink(dname,tagsString,dtsubs,null,TAccess.CA_READ);
      cc = tl.execute(800, true);
      tl.close();
      if (cc != 0)
      { // TODO: throw an exception here
        return null;
      }
    }
View Full Code Here

TOP

Related Classes of de.desy.tine.client.TLink

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.