Package de.desy.tine.client

Examples of de.desy.tine.client.TLink


  private static int getNumberOf(String property,String target,int timeout) throws IOException
  {
    int cc = TErrorList.non_existent_elem;
    short[] n = new short[1];
    TDataType dout;
    TLink tl;
    String propertyq;
   
    if (property == null || target == null) return -TErrorList.argument_list_error;
  
    dout = new TDataType(n);
    propertyq = new String("N" + property);
    try
    {
      tl = new TLink(target,propertyq,dout,null,TAccess.CA_READ);
      cc = tl.execute(timeout,true);
      srvAddr = tl.srvAddr;
      tl.close();
    }
    catch (Exception e)
    {
      cc = TErrorList.host_not_resolved;
    }
View Full Code Here


    if (!TLinkFactory.getInstance().isRunningStandAlone())
    {   
      int cc,n,i;
      TDataType dout;
      TDataType din;
      TLink tl;
      NAME32[] taglist32;
      String[] strlist;
 
      if (serverName == null || serverName.compareToIgnoreCase("ALL") == 0)
      {
        din = new TDataType();
      }
      else if (importance == null)
      {
        din = new TDataType(serverName);
      }
      else
      {
        if (importance.length() == 0) importance = "ALL";
        NAME32[] n32a = new NAME32[2];
        n32a[0] = new NAME32(serverName);
        n32a[1] = new NAME32(importance);
        din = new TDataType(n32a);
      }
      taglist32 = new NAME32[niceContextsQuerySize];
      for (i=0; i<niceContextsQuerySize; i++) taglist32[i] = new NAME32();
      if (taglist32.length == 0) return null;
      dout = new TDataType(taglist32);
      tl = new TLink("/SITE/ENS","CONTEXTS",dout,din,TAccess.CA_READ);
      cc = tl.execute(TLink.defaultTimeout,true);
      tl.close();
      n = dout.getCompletionLength();
      if (cc == 0)
      { // this worked, so we're finished
        strlist = new String[n];
        for (i=0; i<n; i++) strlist[i] = taglist32[i].name;     
View Full Code Here

      al.add("\tclient-side sck recv buffers: "+tsrvs.getClnRecvBuffers());
    }

    int rc;
    boolean isOffline = false;
    TLink lnk;
    TDataType tdt;
    NAME32[] n32 = new NAME32[100];
    al.add("security :");
    tdt = new TDataType(n32);
    lnk = new TLink(tgt,"USERS",tdt,null,TAccess.CA_READ);   
    rc = lnk.executeAndClose();
    if (rc == TErrorList.link_timeout || rc == TErrorList.connection_timeout)
      isOffline = true;
    if (rc == 0 && tdt.getCompletionLength() > 0)
    {
      al.add("WRITE access open to Users : ");
      for (int i=0; i<tdt.getCompletionLength(); i++)
        al.add("\t"+n32[i].name);
    }
    else
    {
      if (!isOffline) al.add("WRITE access open to : ALL users");
    }
    lnk = new TLink(tgt,"IPNETS",tdt,null,TAccess.CA_READ);   
    rc = isOffline ? TErrorList.connection_timeout : lnk.executeAndClose();
    if (rc == 0 && tdt.getCompletionLength() > 0)
    {
      al.add("WRITE access open to Network Addresses : ");
      for (int i=0; i<tdt.getCompletionLength(); i++)
        al.add("\t"+n32[i].name);
    }
    else
    {
      if (!isOffline) al.add("WRITE access open to : ALL network addresses");
    }
    al.add("servers running on same host :");   
    ServerQuery[] sqhst = TQuery.getDeviceServersEx(context, ip,"ALL");
    for (ServerQuery sq : sqhst) al.add("\t"+sq.getName());

    String[] alst = ENSTools.getServerAliasList(tgt);
    if (alst != null && alst.length > 0)
    {
      al.add("aliases for "+tgt+":");   
      for (String s : alst) al.add("\t"+s+ " -> "+tgt);
    }
    if (!isOffline)
    {
      String[] devs = TQuery.getDeviceNames(context, server);
      if (devs != null)
      {
        al.add(tgt+" has "+devs.length+" devices");
        if (TQuery.devices_have_query_function)
        {
          al.add(tgt+" has property query precedence (classic property server model)");
          tgtdev = "#0";
        }
        if (devs.length > 0 && tgtdev == null) tgtdev = devs[0];
        //for (String s: devs) al.add(s);
      }
   
      String[] prps = TQuery.getDeviceProperties(context, server, tgtdev);
      if (prps != null)
      {
        al.add(tgt+" has "+prps.length+" properties");
        if (TQuery.properties_have_query_function)
        {
          al.add(tgt+" has device query precedence (classic device server model)");
        }
        if (devs.length > 0 && tgtdev == null) tgtdev = devs[0];
        //for (String s: prps) al.add(s);
      }
      TPropertyQuery pztpq[] = null;
      long t0;
      String rdr = null, lclhststr = null;
      int callsOK = 0;
      int callsErr = 0;
      int callsNA = 0;
      int len = prps.length;
      if (limit > 0 && limit < len) len = limit;
      for (int i=0; prps != null && i<len; i++)
      {
        pztpq = TQuery.getPropertyInformation(context, server, tgtdev, prps[i]);
        if (pztpq == null)
        {
          callsErr++;
          continue;
        }
        for (TPropertyQuery p: pztpq)
        {
          if (TAccess.isRead(p.prpAccess))
          {
            al.add("read "+p.prpName+" : "+p.prpDescription);
            lclhststr = p.prpHistoryDepthShort == 0 ? "none" :
                        p.prpHistoryDepthShort < 0 ? "redirected" :
                        p.prpHistoryDepthLong > 0 ? ""+p.prpHistoryDepthLong+" month(s)" :
                        ""+p.prpHistoryDepthShort+" entries in ring buffer";
            al.add("\tlocal history : "+lclhststr);
            al.add("\tarray type : "+TArrayType.toString(p.prpArrayType));
            if (p.prpRedirection.length() > 0)
              al.add("\tis redirected to "+p.prpRedirection);
            if (p.prpSizeIn > 0) al.add("\ttakes input: "+p.prpSizeIn+" "+TFormat.toString(p.prpFormatIn)+" elements");
            al.add("\tresults:");
            if (p.prpFormat == TFormat.CF_STRUCT)
            {
              int ssiz = 0;
              if ((ssiz=TStructRegistry.getSizeInBytes(p.prpTag)) <= 0)
              {
                TQuery.AcquireAndRegisterStructInfo(context, server, p.prpTag);
                ssiz = TStructRegistry.getSizeInBytes(p.prpTag,context,server);
              }
              if (ssiz > 0) tdt = new TDataType(new byte[ssiz],p.prpTag);
              else
              {
                al.add("\tunable to acquire and register structure tag "+p.prpTag);
                tdt = new TDataType(p.prpSize,p.prpFormat);
              }
            }
            else if (p.prpFormat == TFormat.CF_AIMAGE || p.prpFormat == TFormat.CF_ASPECTRUM)
            {
              al.add("\t"+lnk.getFullDeviceNameAndProperty()+" adjustable format not accessed");
              callsNA++;  
              continue;
            }
            else
            {
              tdt = new TDataType(p.prpSize,p.prpFormat);
            }
            lnk = new TLink(tgt+"/"+tgtdev,p.prpName,tdt,null,TAccess.CA_READ);
            t0 = System.currentTimeMillis();
            rc = lnk.executeAndClose();
            if (rc == TErrorList.illegal_read_write && p.prpSizeIn > 0)
            {
              al.add("\t"+lnk.getFullDeviceNameAndProperty()+" not accessed: requires input data");
              callsNA++;
            }
            else
            {
              al.add("\t"+lnk.getFullDeviceNameAndProperty()+" "+p.prpSize+" "+
                TFormat.toString(p.prpFormat)+" value(s) in "+
                (System.currentTimeMillis()-t0)+" ms : "+lnk.getLastError());
              TDataType dout = lnk.getOutputDataObject();
              switch (dout.dFormat)
              {
                case TFormat.CF_STRUCT:
                  al.add("\tStructure type "+dout.getTag());
                  break;
                case TFormat.CF_BITFIELD8:
                case TFormat.CF_BITFIELD16:
                case TFormat.CF_BITFIELD32:
                case TFormat.CF_BITFIELD64:
                  al.add("\tBitfield type "+dout.getTag());
                  break;
                case TFormat.CF_IMAGE:
                  IMAGE img = (IMAGE)dout.getDataObject();
                  al.add("\tImage; Frame size "+img.getFrameHeader().appendedFrameSize+" bytes");
                  break;
                default:
                  if (dout.dCompletionLength <= 10)
                  {
                    dout.setArrayDelimiter(" ");
                    al.add("\tvalues: "+dout.toString());                 
                  }
                  else
                  {
                    al.add("\treceived "+dout.dCompletionLength+" values");
                  }
                  break;
              }
              if (TErrorList.hasData(rc)) callsOK++; else callsErr++;
            }
            if ((rdr=lnk.getRedirectionKey()) != null && rdr.length() > 0)
            {
              al.add("\t"+"redirected to "+rdr);
            }
          }
          else
View Full Code Here

     */
    @Override
    public <T> Map.Entry<T, Timestamp> readAttribute(final String attrName) throws ClientException {
        Future<TLink> futureLink = getFutureLink(attrName);
        try {
            TLink tLink = futureLink.get();
            int rc = tLink.execute();
            if (rc != TErrorList.success) {
                throw new RuntimeException("TLink has failed: " + TErrorList.getErrorString(rc));
            }
            TDataType dout = tLink.dOutput;
            long time = tLink.getLastTimeStamp();
            Timestamp timestamp = new Timestamp(time);
            return new AbstractMap.SimpleImmutableEntry<T, wpn.hdri.ss.data.Timestamp>((T) getDataObject(dout), timestamp);
        } catch (Exception e) {
            throw new ClientException("Read from " + getDeviceName() + "/" + attrName + " failed.", e);
        }
View Full Code Here

                                    TPropertyQuery meta = getTPropertyQuery(attrName);
                                    int size = getTPropertySize(meta);
                                    short dataFormat = getTPropertyFormat(meta);
                                    TDataType dout = new TDataType(size, dataFormat);
                                    // get a reference array : synchronous call ...
                                    TLink result = new TLink(getDeviceName(), attrName, dout, null, TAccess.CA_READ);
                                    return result;
                                }
                            });

View Full Code Here

    @Override
    public void subscribeEvent(final String attrName, final EventCallback cbk) throws ClientException {
        Future<TLink> futureLink = getFutureLink(attrName);
        try {
            final TLink link = futureLink.get();
            final TDataType dout = link.dOutput;
            long time = link.getLastTimeStamp();
            //read data for the first time
            cbk.onEvent(new EventData<Object>(getDataObject(dout), time));
            //attach event listener
            int rc = link.attach(TMode.CM_DATACHANGE, new TCallback() {
                @Override
                public void callback(int LinkIndex, int LinkStatus) {
                    if (TErrorList.isLinkSuccess(LinkStatus)) {
                        long time = link.getLastTimeStamp();
                        cbk.onEvent(new EventData<Object>(getDataObject(dout), time));
                    } else {
                        cbk.onError(new Exception(TErrorList.getErrorString(LinkStatus)));
                    }
                }
            });
            if (rc < 0) {
                throw new IllegalStateException(link.getLastError());
            }
        } catch (Exception e) {
            throw new ClientException("Failed subscribe to " + getDeviceName() + "/" + attrName, e);
        }
    }
View Full Code Here

    @Override
    public void unsubscribeEvent(String attrName) throws ClientException {
        Future<TLink> futureLink = tlinks.remove(attrName);
        try {
            final TLink link = futureLink.get();
            int rc = link.close();
            if (rc < 0) {
                throw new ClientException(link.getLastError(), null);
            }
        } catch (Exception e) {
            throw new ClientException("Failed subscribe to " + getDeviceName() + "/" + attrName, e);
        }
    }
View Full Code Here

      if (!isArchiveQueryProperty(property))
        pname = pname + ".HIST"; // meta extension not given, try this ...
    }
    try
    {
      TLink tl = new TLink(dname,pname,dout,din,TAccess.CA_READ);
      cc = tl.execute(timeout, true);
      tl.close();
    }
    catch (UnresolvedAddressException e)
    {
      cc = TErrorList.address_unresolved;
    }
View Full Code Here

    {
      if (isCentralArchiveServer(server) || isCentralArchiver(server))
      { // call to a central archive server
        String[] keysrcs = new String[100];
        dout = new TDataType(keysrcs);
        TLink tl = new TLink(dname,"KEYWORD.SOURCE",dout,null,TAccess.CA_READ);
        cc = tl.executeAndClose(timeout);
        if (cc == 0)
        {
          int len =dout.getCompletionLength();
          if (len < 100) keysrcs = Arrays.copyOf(keysrcs, len);
          src = keysrcs;
View Full Code Here

      { // call to a central archive server
      FLTFLT[] dtols = new FLTFLT[1];
        dtols[0] = tols;
        din = new TDataType(startstop);
        dout = new TDataType(dtols);
        TLink tl = new TLink(dname,"KEYWORD.TOLERANCE",dout,din,TAccess.CA_READ);
        cc = tl.executeAndClose(timeout);
      }
      else
      {
        THistoryRecordStruct[] hrs = new THistoryRecordStruct[1];
        hrs[0] = new THistoryRecordStruct();
        din = new TDataType(property);
        dout = new TDataType(hrs);
        TLink tl = new TLink(dname,"HISTORIES",dout,din,TAccess.CA_READ);
        cc = tl.executeAndClose(timeout);
        if (cc == 0)
        {
          tols.f1val = hrs[0].getAbsoluteTolerance();
          tols.f2val = hrs[0].getPercentTolerance();
        }
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.