Package de.desy.tine.client

Source Code of de.desy.tine.client.TWildcardGroupCallback

/*
* Created on Jul 12, 2006
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package de.desy.tine.client;

import de.desy.tine.dataUtils.TDataType;
import de.desy.tine.definitions.TErrorList;
import de.desy.tine.definitions.TFormat;
import de.desy.tine.server.logger.DbgLog;
import de.desy.tine.server.logger.MsgLog;
import de.desy.tine.types.*;

public class TWildcardGroupCallback implements TLinkCallback
{
  public void callback(TLink link)
  {
    int lstid = link.callbackId;
    TWildcardLink wc = link.twcl;
    int wccc;
    int i, k;
    int debug = TLinkFactory.debugLevel;
    NAME16FI[] nfi;
    NAME16II[] nii;

    if (wc == null || wc.status == null)
    {
      MsgLog.log("TWildcardGroupCallback", "called with no wildcard link",TErrorList.code_failure,null,0);
      return;
    }
    if (wc.status[lstid] == TErrorList.not_ready) wc.numPending--;
    wc.status[lstid] = link.linkStatus;
    if (debug > 1)
      DbgLog.log("TWildcardGroupCallback","grp cb : (" + lstid + ") : <" + link.linkStatus + "> pending : " + wc.numPending + " from " + wc.length);   
    if (link.linkStatus == TErrorList.link_blacklisted) link.close();
    if (link.linkStatus == TErrorList.illegal_property) link.close();
    /* TODO: the illegal_format check is here only because DOOCS returns it ! */
    if (link.linkStatus == TErrorList.illegal_format) link.close();

    if (wc.numPending > 0) return;

    if (debug > 1)
      DbgLog.log("TWildcardGroupCallback","wildcard group all in !!!!!!!!");
    k = 0; /* count the legal links */
    switch (wc.format)
    {
      case TFormat.CF_USTRING:
      case TFormat.CF_NAME16DBLDBL:
      case TFormat.CF_NAME32DBLDBL:
      case TFormat.CF_NAME64DBLDBL:
        TDataType d = wc.parent.getOutputDataObject();
        nfi = new NAME16FI[d.dArrayLength];
        for (i=0; i<wc.length && k<d.dArrayLength; i++)
        {
          //if (wc.links[i].linkStatus == TErrorList.illegal_format) continue;         
          if (wc.status[i] == TErrorList.illegal_format) continue;
          if (wc.status[i] == TErrorList.illegal_property) continue;
          if (wc.status[i] == TErrorList.link_blacklisted) continue;
          nfi[k] = new NAME16FI(wc.list[i],wc.status[i],((float[])wc.links[i].getOutputDataObject().getDataObject())[0]);
          k++;
        }
        d.putData(nfi);
        break;
      case TFormat.CF_NAME16FI:
        nfi = (NAME16FI[])wc.parent.getOutputDataObject().getDataObject();
        for (i=0; i<wc.length && k<wc.parent.dOutput.dArrayLength; i++)
        {
          //if (wc.links[i].linkStatus == TErrorList.illegal_format) continue;         
          if (wc.status[i] == TErrorList.illegal_format) continue;
          if (wc.status[i] == TErrorList.illegal_property) continue;
          if (wc.status[i] == TErrorList.link_blacklisted) continue;
          nfi[k].setName(wc.list[i]);
          nfi[k].fval = ((float[])wc.links[i].getOutputDataObject().getDataObject())[0];
          nfi[k].ival = wc.status[i];
          k++;
        }
        break;
      case TFormat.CF_NAME16II:
        nii = (NAME16II[])wc.parent.getOutputDataObject().getDataObject();
        for (i=0; i<wc.length && k<wc.parent.dOutput.dArrayLength; i++)
        {
          if (wc.status[i] == TErrorList.illegal_format) continue;
          if (wc.status[i] == TErrorList.illegal_property) continue;
          if (wc.status[i] == TErrorList.link_blacklisted) continue;
          nii[k].setName(wc.list[i]);
          nii[k].i1val = ((int[])wc.links[i].getOutputDataObject().getDataObject())[0];
          nii[k].i2val = wc.status[i];
          k++;
        }
        break;
      default:
        if (wc.format <= TFormat.CF_NAME32 && wc.parent.devName.indexOf("*") == 0)
        {
          for (i=0; i<wc.length && k<wc.parent.dOutput.dArrayLength; i++)
          {
            if (wc.status[i] == TErrorList.illegal_format) continue;
            if (wc.status[i] == TErrorList.illegal_property) continue;
            if (wc.status[i] == TErrorList.link_blacklisted) continue;
            wc.parent.getOutputDataObject().dataCopy(wc.links[i].getOutputDataObject(),k);
            k++;
          }
        }
        else
        {
          for (i=0; i<wc.length; i++)
          {
            wc.status[i] = TErrorList.illegal_format;
            wc.links[i].close();
          }
        }
        break;
    }
    wc.numActive = k;
    wccc = link.linkStatus;
    wc.numPending = wc.numActive;
    for (i=0; i<wc.length; i++)
    {
      if (wc.status[i] == TErrorList.illegal_format) continue;
      if (wc.status[i] == TErrorList.illegal_property) continue;
      if (wc.status[i] == TErrorList.link_blacklisted) continue;
      if (wccc != 0 && wc.status[i] == 0) wccc = 0; /* at least one success */
      wc.status[i] = TErrorList.not_ready;
    }
    wc.parent.dOutput.setArrayLength(k);
    wc.parent.linkStatus = wccc;
    wc.parent.linkStatusSource = link.linkStatusSource;
    wc.parent.getOutputDataObject().dCompletionLength = k;
    if (wc.tlcb != null) wc.tlcb.callback(wc.parent);
    else if (wc.tcb != null) wc.tcb.callback(wc.parent.linkId,wccc);
    else wc.parent.wakeUpCall();
    wc.canNotify = true;   
    return;
  }
}
TOP

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

TOP
Copyright © 2018 www.massapi.com. 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.