Package de.desy.tine.dataUtils

Examples of de.desy.tine.dataUtils.TDataType


          return false;
        }
      }
      TDataType[] tdt = new TDataType[n];
      int sizSr = sizIn * sizTg;
      for (int i=0; i<n; i++) tdt[i] = new TDataType(sizSr,fmt,tag);
      prp.setSaveRestoreData(tdt);
      return true;
    }
    catch (Exception any)
    {
View Full Code Here


    if (srLst.size() == 0) return;
    Iterator<String> it = srLst.iterator();
    String prp = null, dev = "", tag;
    TExportProperty p = null;
    TDataType[] srdt;
    TDataType tdt = null, ndt = new TDataType();
    int ndev, len = 0, siz = 1, cc = 0;
    short fmt;
    TAccess wacc = new TAccess(TAccess.CA_WRITE|TAccess.CA_SAVERESTORE);
    TAccess racc = new TAccess(TAccess.CA_READ|TAccess.CA_SAVERESTORE);
    ArrayList<String>alst = null;
    String[] dlst = null;
    TEquipmentModuleFactory f = TEquipmentModuleFactory.getInstance();
    TContractTable tct = new TContractTable();
    TClientEntry tce = new TClientEntry();
    tce.cln = new TClient();
    tce.cln.userName = "INITIALIZATION";
    tct.clt.add(tce);
    while (it.hasNext())
    {
      prp = it.next();
      it.remove();
      if ((p=propertyList.getFirstProperty(prp)) == null) continue;
      if ((srdt=p.getSaveRestoreDataSet()) == null) continue;
      alst = p.getDeviceList();
      dlst = (alst != null) ?
          alst.toArray(new String[0]) :
          deviceList.getDeviceNameList();
      if ((ndev=dlst.length) == 0) ndev = 1;
      siz = 1; hasSrValues = null;
      fmt = srdt[0].getFormat();
      tag = srdt[0].getTag();
      len = srdt.length;
      switch (fmt)
      {
        case TFormat.CF_STRUCT:
          int ssiz = TStructRegistry.getSizeInBytes(srdt[0].getTag());
          if (ssiz == 0) continue;
          siz = p.getOutputSize();
          hasSrValues = new boolean[siz];
          siz = ssiz;
          break;
        case TFormat.CF_IMAGE:
        case TFormat.CF_SPECTRUM:
          siz = p.getInputSize();
          hasSrValues = new boolean[ndev]; // no matter what
          break;
        default:
          siz = p.getInputSize();
          if (p.isMultiChannelArray()) siz = 1;
          if (siz > 1) hasSrValues = new boolean[ndev];
          break;
      }
      tdt = new TDataType(siz,fmt);
      tdt.setTag(tag);
     
      if (dlst != null && dlst.length > 0 && len > dlst.length)
      { // TODO: this should always be the case :
        len = dlst.length;
View Full Code Here

      lnk.dOutput.isDataObjectInSync = false;
      TLinkFactory.getInstance().fillinIncomingData(lnk);
    }
    else
    { // try to re-format (what came in to what the caller wants ...)
      TDataType dt = new TDataType(len,fmt);
      dt.update(d,1,0);
      lnk.dOutput.blksin = lnk.dOutput.bytesin = 0;
      dt.resetBuffersReady();
      Object srcData = dt.getDataObject();
      dt.getData(srcData);
      lnk.dOutput.putData(srcData);
      lnk.dOutput.hasBeenUpdated = dt.hasBeenUpdated = true;
      lnk.dOutput.dCompletionLength = len;
    }
  }
View Full Code Here

    if (deviceString == null) return false;
    return deviceString.indexOf('*') != -1;
  }
  private int doContractWithWildcardDevice(TContractTable tct)
  {
    TDataType drdb, dnull;
    int start = 0, len = 0, mask = 0;
    boolean isCont = false, chkMask = false, chkOffline = false;
    int cc = TErrorList.not_allowed, i, k;
    TAccess acc = new TAccess(tct.contract.dataAccess);
    int devlistsize = 0;  
    String[] devlist = null;
    int atype;
    NAME16FI[] nfi;
    NAME16II[] nii;
    TDevice dev;

    TEquipmentModule eqm = tct.eqm;
    TDeviceList dlst = eqm.getDeviceList();
    String devprp = tct.contract.eqmProperty;
    String devnam = tct.contract.eqmDeviceName;
    TExportProperty prp = eqm.propertyList.getFirstProperty(devprp);
    if ((atype=prp.getDescription().getArrayType()) == TArrayType.AT_SPECTRUM)
      return TErrorList.not_allowed;
    if (tct.dout == null || tct.dout.dArrayLength < 1) return TErrorList.not_allowed;
    if (!eqm.isDeviceSetLocal(devnam,devprp)) return TErrorList.data_not_local;

    if (prp.getDeviceList() != null)
    {
      devlistsize = prp.getDeviceList().size();
      devlist = new String[devlistsize];
      prp.getDeviceList().toArray(devlist);
    }
    if (devlistsize == 0)
    { // normal state of affairs: use the registered device list
      devlist = dlst.getDeviceNameList();
      devlistsize = devlist.length;
      chkOffline = true;
      if (tct.din != null && tct.din.dArrayLength == 1 && tct.din.dFormat == TFormat.CF_INT32)
      { // appears to be an input device mask
        int[] msk = new int[1];
        tct.din.getData(msk);
        mask = msk[0];
        if (mask != 0) chkMask = true;
      }
    }
    if ((atype & TArrayType.AT_CHANNEL) == TArrayType.AT_CHANNEL)
    {
      len = devlistsize;
      int endpoints[] = StringToName.getContiguousEndpoints(devlist,devnam);
      if (endpoints != null)
      {
        isCont = true;
        start = endpoints[0];
        len = endpoints[1] - endpoints[0] + 1;
      }
    }
    WildcardMatch wc = new WildcardMatch(devnam);
    dnull = new TDataType();
    switch (tct.dout.dFormat)
    {
      case TFormat.CF_NAME16DBLDBL:
      case TFormat.CF_NAME32DBLDBL:
      case TFormat.CF_NAME64DBLDBL:
      case TFormat.CF_USTRING:
      case TFormat.CF_NAME16FI:
        if (isCont)
        {
          int dsiz = tct.contract.dataSizeOut > len ? len : tct.contract.dataSizeOut;
          nfi = new NAME16FI[dsiz];
          float[] frb = new float[dsiz];
          drdb = new TDataType(frb);
          cc = tct.eqm.callProperty(devprp, devlist[start], drdb, dnull, acc);
          if (cc != 0) return cc;
          for (i=0, k=0; i<drdb.dArrayLength; i++)
          {
            dev = dlst.getDevice(i);
            if (chkMask) if (dev == null || !dev.isMaskSet(mask)) continue;
            if (chkOffline) if (dev == null || dev.isOffline()) continue;
            nfi[k] = new NAME16FI(devlist[start+i],0,frb[i]);
            k++;
          }
          tct.drb.dArrayLength = k;
        }
        else
        {
          int dsiz = tct.contract.dataSizeOut;
          nfi = new NAME16FI[dsiz];
          float[] frb = new float[1];
          drdb = new TDataType(frb);
          for (i=0, k=0; i<devlistsize && k<tct.dout.dArrayLength; i++)
          {
            if (!wc.matches(devlist[i])) continue;
            dev = dlst.getDevice(i);
            if (chkMask) if (dev == null || !dev.isMaskSet(mask)) continue;
            if (chkOffline) if (dev == null || dev.isOffline()) continue;
            cc = tct.eqm.callProperty(devprp, devlist[i], drdb, dnull, acc);
            if (cc == TErrorList.server_redirection) return TErrorList.data_not_local;
            nfi[k] = new NAME16FI(devlist[i],cc,frb[0]);
            k++;
          }
          tct.drb.dArrayLength = k;
        }
        tct.drb.putData(nfi);
        return 0;
      case TFormat.CF_NAME16II:
        if (isCont)
        {
          int dsiz = tct.contract.dataSizeOut > len ? len : tct.contract.dataSizeOut;
          nii = new NAME16II[dsiz];
          int[] irb = new int[dsiz];
          drdb = new TDataType(irb);
          cc = tct.eqm.callProperty(devprp, devlist[start], drdb, dnull, acc);
          if (cc != 0) return cc;
          for (i=0,k=0; i<drdb.dArrayLength; i++)
          {
            dev = dlst.getDevice(i);
            if (chkMask) if (dev == null || !dev.isMaskSet(mask)) continue;
            if (chkOffline) if (dev == null || dev.isOffline()) continue;
            nii[k] = new NAME16II(devlist[start+i],0,irb[i]);
            k++;
          }
          tct.drb.dArrayLength = k;
        }
        else
        {
          int dsiz = tct.contract.dataSizeOut;
          nii = new NAME16II[dsiz];
          int[] irb = new int[1];
          drdb = new TDataType(irb);
          for (i=0, k=0; i<devlistsize && k<tct.dout.dArrayLength; i++)
          {
            if (!wc.matches(devlist[i])) continue;
            cc = tct.eqm.callProperty(devprp, devlist[i], drdb, dnull, acc);
            if (cc == TErrorList.server_redirection) return TErrorList.data_not_local;
            nii[k] = new NAME16II(devlist[i],irb[0],cc);
            k++;
          }
          tct.drb.dArrayLength = k;
        }
        tct.drb.putData(nii);
        return 0;
      default:
        if (tct.dout.dFormat <= TFormat.CF_NAME32 && devnam.compareTo("*") == 0)
        { /* primitive format allowed in this case */
          if (isCont)
          {
            if (tct.drb.dArrayLength > len) tct.drb.dArrayLength = len;
            return tct.eqm.callProperty(devprp, devlist[0], tct.drb, dnull, acc);
          }
          drdb = new TDataType(1,tct.dout.dFormat);
          for (i=0; i<devlistsize && i<tct.dout.dArrayLength; i++)
          {
            cc = tct.eqm.callProperty(devprp, devlist[i], drdb, dnull, acc);
            if (cc != 0) break;
          }
View Full Code Here

    return cc;
  }
  private int doContractWithWildcardProperty(TContractTable tct)
  {
    LinkedList<String> lst = null;
    TDataType drdb;
    int cc = TErrorList.not_allowed, i, k, devnr;
    TAccess acc = new TAccess(tct.contract.dataAccess);
    int prplistsize = 0;  
    String[] prplist = null;
    NAME32DBLDBL[] ndd;
  
    TEquipmentModule eqm = tct.eqm;
    String devprp = tct.contract.eqmProperty;
    String devnam = tct.contract.eqmDeviceName;
    TExportProperty prp;
    if (tct.dout == null || tct.dout.dArrayLength < 1) return TErrorList.not_allowed;
    if ((devnr=eqm.getDeviceList().getDeviceNumber(tct.contract.eqmDeviceName)) < 0)
      return TErrorList.illegal_equipment_number;

    lst = eqm.getDeviceList().getDevice(devnr).getPropertyList();
    if (lst != null)
    {
      prplistsize = lst.size();
      prplist = new String[prplistsize];
      lst.toArray(prplist);
    }
    else
    {
      if (eqm.gPropertyNameList == null)
      { // just do this once
        if ((lst = eqm.getPropertyNames()) == null) return TErrorList.code_failure;
        prplistsize = lst.size();
        prplist = new String[prplistsize];
        lst.toArray(prplist);
        eqm.gPropertyNameList = prplist;
      }
      prplistsize = eqm.gPropertyNameList.length;
      prplist = eqm.gPropertyNameList;
    }
   
    WildcardMatch wc = new WildcardMatch(devprp);

    switch (tct.dout.dFormat)
    {
      case TFormat.CF_NAME16DBLDBL:
      case TFormat.CF_NAME32DBLDBL:
      case TFormat.CF_NAME64DBLDBL:
      case TFormat.CF_USTRING:
      case TFormat.CF_NAME16FI:
      case TFormat.CF_NAME16II:
        int dsiz = tct.contract.dataSizeOut;
        ndd = new NAME32DBLDBL[dsiz];
        double[] drb = new double[1];
        drdb = new TDataType(drb);
        for (i=0, k=0; i<prplistsize && k<tct.dout.dArrayLength; i++)
        {
          if (!wc.matches(prplist[i])) continue;
          prp = eqm.propertyList.getFirstProperty(prplist[i]);
          if (prp.getDescription().getArrayType() == TArrayType.AT_SPECTRUM) continue;
View Full Code Here

      }
      catch (Exception ignore) {};
    }
    if (ts.numblks == 1)
    { // just this one ...
      TDataType tdt;
      tdt = new TDataType(sizeIn, ts.contract.dataFormatIn);
      tdt.setTag(tagIn);
      return tdt;
    }
    if (debugLevel > 1) DbgLog.log("getInputDataTypeRepository","in-coming long datagram ...");
    clnInputData cip = null;
    for (int i = 0; i < clnInputDataTable.size(); i++)
    {
      cip = (clnInputData) clnInputDataTable.get(i);
      if (!cip.tc.IPaddress.equals(tc.IPaddress)) continue;
      if (cip.id != ts.id) continue;
      if (cip.starttime != ts.starttime) continue;
      if (debugLevel > 1) DbgLog.log("getInputDataTypeRepository","found it in list ...");
      return cip.din;
    }
    cip = new clnInputData();
    cip.id = ts.id;
    cip.starttime = ts.starttime;
    cip.tc = tc;
    cip.din = new TDataType(sizeIn, ts.contract.dataFormatIn,ts.numblks);
    cip.din.setTag(tagIn);
    clnInputDataTable.add(cip);
    if (debugLevel > 1) DbgLog.log("getInputDataTypeRepository","add it to list ...");
    return cip.din;
  }
View Full Code Here

  public boolean getSendSingleDelivery() { return canSendSingleDelivery; }
  private void getRequest(TClient tcaller, byte[] data)
  {
    Arrays.fill(requestBytes,(byte)0);
    byte[] d = requestBytes;
    TDataType din = null;
    int offset = 0, datasize = 0;
    int renewalMultiplier;
    int cc = 0, nreqs = 0;
    short bmode;
    boolean isTrueMCast = false;
    boolean isLegacy = false;
    boolean sendSingleDelivery = false;
    boolean chkResendData = false;
    boolean resendCurrentData = false;
    TClientEntry tce = null;
    TClient tc = tcaller;
    String astr = null;
    if (srvCycleTime < rejectEarlierThan) return;
    // peel off the header
    TReqHdr hdr = new TReqHdr(data, 0, TReqHdr.hdrSizeInBytes);
    tc.userName = hdr.getUserName();
    int tineProtocol = hdr.getProtocol();   
    if (tineProtocol < 5)
    {
      SendMessageToCaller(tc, null, TErrorList.illegal_protocol,null);
    }
    tc.tineProtocol = (short)tineProtocol;
    tc.revisionId = hdr.getRevisionId();
    if (tineProtocol < 6) isLegacy = true;
    int totalsize = hdr.getTotalSizeInBytes();
    int hdrSize = isLegacy ? TSubscription.hdrSizeInBytesLegacy : TSubscription.hdrSizeInBytes;
    int conSize = isLegacy ? TContractP5.hdrSizeInBytes : TContract.hdrSizeInBytes;
    offset += TReqHdr.hdrSizeInBytes;
    if (debugLevel > 3) DbgLog.log("getRequest",hdr.toString());
    TContractTable tct = null;
    long t_now = System.currentTimeMillis();
    while (offset < totalsize)
    { // peel off the TSubscription
      nreqs++; resendCurrentData = false;
      TSubscription sub = new TSubscription(tineProtocol, data, offset, hdrSize);
      tc = tcaller; // reset this in case of packed network requests
      bmode = TMode.getBaseMode(sub.mode);
      // Is the caller using alias names ?
      if ((astr=getNameFromAlias(sub.contract.eqmDeviceName)) != null) sub.contract.eqmDeviceName = astr;
      if ((astr=getNameFromAlias(sub.contract.eqmProperty)) != null) sub.contract.eqmProperty = astr;
      offset += hdrSize + conSize + sub.contract.extStringSize;
      if (debugLevel > 0 && sub.numblks == sub.blknum)
      {
        if (debugLevel > 2)
          DbgLog.log("getRequest",sub.toString());
        else
        {
          String msg = sub.contract.eqmName+" "+sub.contract.eqmDeviceName+" "+
            sub.contract.eqmProperty+" "+sub.pollingInterval+" msec "+
            "("+sub.numblks+" blks) "+TMode.toString(sub.mode);
          DbgLog.log("getRequest", msg);
        }
      }
      // prepare incoming data ...
      if ((datasize = sub.getInputDataSize()) > 0)
      {
        din = getInputDataTypeRepository(tc, sub);
        if (din.update(data, offset, datasize, sub.blknum, sub.blkid))
        {
          din.bytesin += datasize;
        }
        offset += datasize + (datasize % 2);
        if (din.blksin < din.numblks)
        {
          if (debugLevel > 2)
            DbgLog.log("getRequest","input data set "+din.blksin+" of "+din.numblks);
          continue;
        }
        if (din.numblks > 1 && debugLevel > 1)
          DbgLog.log("getRequest","long input data set ("+din.numblks+" blocks) complete");
        // when finished ...
        din.resetBuffersReady();
        din.getData();
        if (debugLevel > 3) DbgLog.log("getRequest","input data : \n" + din.toString());
      }
      // requested output data ...
      if ((cc=fixOutputDataTypeAndSize(sub)) != 0)
      { // default format ?
        SendMessageToCaller(tc, sub, cc, null);
View Full Code Here

    siz += FECInfo.getSizeInBytes();
    byte[] expAddr = new byte[siz];
    int cpsize = legacyEns ? SrvAddr.legacySizeInBytes : SrvAddr.sizeInBytes;
    System.arraycopy(da.toByteArray(legacyEns), 0, expAddr, 0, cpsize);
    System.arraycopy(inf.toByteArray(), 0, expAddr, cpsize, FECInfo.getSizeInBytes());
    TDataType din = new TDataType(expAddr, "");
    if (debugLevel > 0)
    {
      DbgLog.log("SendRegisteredExportToENS","fec -> " + gFecAddr.toString());
      DbgLog.log("SendRegisteredExportToENS","dev -> " + da.toString());
      DbgLog.log("SendRegisteredExportToENS","fec info -> " + inf.toString());
View Full Code Here

    }
    validateContextAndSubsystem(eqm);
   
    if (TSrvEntry.currentConfiguredNameServerTag != null)
    { // this should always point to the primary ENS
      TDataType dout = new TDataType();
      TDataType din = _prepExportDataType(eqm,srvName,inf,false);
      if (din == null) return; // stand-alone ? -> we're done
      int rc = _sndExportToEns(eqm,dout,din);
      if (rc == TErrorList.illegal_data_size)
      {
        din = _prepExportDataType(eqm,srvName,inf,true);
View Full Code Here

    n32[2] = new NAME32(cnt);
    n32[3] = new NAME32(String.valueOf(eqm.getGroupIndex()));
    n32[4] = new NAME32(sub);
    n32[5] = new NAME32(prefix);
    n32[6] = new NAME32(postfix);
    TDataType din = new TDataType(n32);
    TDataType dout = new TDataType();
    if (debugLevel > 0)
    {
      String dbgstr = "/"+cnt+"/"+exp+" -> ";
      DbgLog.log("joinEnsGroup",dbgstr+"joining group "+grp+" (index "+eqm.getGroupIndex()+")");
      if (prefix.length() > 0) DbgLog.log("joinEnsGroup","device prefix: "+prefix);
View Full Code Here

TOP

Related Classes of de.desy.tine.dataUtils.TDataType

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.