Package de.desy.tine.queryUtils

Source Code of de.desy.tine.queryUtils.THistoryQuery

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

import de.desy.tine.client.TLink;
import de.desy.tine.dataUtils.*;
import de.desy.tine.definitions.*;
import de.desy.tine.types.*;

public final class THistoryQuery
{
  public static boolean isMetaProperty(String key)
  {
    if (key.endsWith(".HST")) return true;
    if (key.endsWith(".HIST")) return true;
    if (key.endsWith(".ARCH")) return true;
    if (key.endsWith(".ARC")) return true;
    if (key.endsWith(".AR")) return true;
    return false;   
  }
  public static int getArchivedDataAsFloat(String fullName,long starttime,long stoptime,FLTINT[] fiArray)
  {
    String[] names;
    String srv, key;
    int[] npoints = new int[1];
    int cc;
   
    // parse the fullName (what are the rules here?)
    // "/context/server/name[property]" or "/context/server/name/property" ?
    names = TLink.splitDeviceAndPropertyFromName(fullName);
    if ((srv = names[0]) == null) return TErrorList.argument_list_error;
    if ((key = names[1]) == null) return TErrorList.argument_list_error;
   
    if (!srv.contains("HISTORY") && !isMetaProperty(key))
    { // not a central server and meta tag not yet appended
      key.concat(".HIST"); // append the lowest common denominator
    }
    double[] startstop = new double[2];
    startstop[0] = (double)(starttime/1000) + ((double)(starttime%1000)/1000);
    startstop[1] = (double)(stoptime/1000) + ((double)(stoptime%1000)/1000);

    TDataType npts = new TDataType(npoints);
    TDataType din = new TDataType(startstop);
    TLink nl = new TLink(srv,key,npts,din,TAccess.CA_READ);
    cc = nl.execute(1000,true); // number of points in region
    if (cc != 0) return -cc;

    TDataType dout = new TDataType(fiArray);
    TLink tl = new TLink(srv,key,dout,din,TAccess.CA_READ);
    cc = tl.execute(1000,true); // data returned
    if (cc != 0) return -cc;
   
    return npoints[0];
  }
}
TOP

Related Classes of de.desy.tine.queryUtils.THistoryQuery

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.