Examples of TExportProperty


Examples of de.desy.tine.server.properties.TExportProperty

  }
  private LinkedList<String> srLst = new LinkedList<String>();
  public int restorePropertyValues(String prpName,TDataType target)
  {
    if (prpName == null || target == null) return TErrorList.invalid_parameter;
    TExportProperty prp = propertyList.getFirstProperty(prpName);
    if (prp == null) return TErrorList.illegal_property;
    TInitializer initializer = TInitializerFactory.getInstance().getInitializer();
    String fn = initializer.getFecHome();
    String filename = prpName+"-settings.csv";
    csv csvFile = null;
View Full Code Here

Examples of de.desy.tine.server.properties.TExportProperty

    return savePropertyValues(prpName,null,source);
  }
  public int savePropertyValues(String prpName,String devName,TDataType source)
  {
    if (prpName == null || source == null) return TErrorList.invalid_parameter;
    TExportProperty prp = propertyList.getFirstProperty(prpName);
    if (prp == null) return TErrorList.illegal_property;
    try
    {
      ArrayList<String>alst = prp.getDeviceList();
      String[] dlst = (alst != null) ?
          alst.toArray(new String[0]) :
          deviceList.getDeviceNameList();
      TInitializer initializer = TInitializerFactory.getInstance().getInitializer();
      String fn = initializer.getFecHome()+File.separator;
      if (moduleName != null && new File(fn+moduleName+File.separator).exists())
        fn += moduleName+File.separator;
      String filename = fn + prpName+"-settings.csv";
      String nl = System.getProperty("line.separator");
      FileWriter fw = new FileWriter(filename);
      String ln = "DEVICES, VALUES"+nl;
      fw.write(ln);
      int len = dlst != null ? dlst.length : 1;
      String dev = "";
      int devnr = getDeviceNumber(devName, prpName);
      if (devnr < 0) devnr = 0;
      Object obj = source.getDataObject();
      boolean isSrArray = source.isArrayOfPrimitives() && !prp.isMultiChannelArray();
      for (int i=0; i<len; i++)
      {
        dev = dlst != null ? dlst[i] : "#"+i;
        if (isSrArray)
        {
          ln = dev+", <$FILE"+nl;
          if (i == devnr)
          { // the targeted device
            int alen = prp.getInputSize();
            int offset = i * alen;
            int p = filename.lastIndexOf('.');
            if (p < 1) return TErrorList.invalid_name;
            String vfn = filename.substring(0, p) + "." + i;
            DataOutputStream dos = new DataOutputStream(new FileOutputStream(vfn));          
View Full Code Here

Examples of de.desy.tine.server.properties.TExportProperty

  protected void applyStoredPropertyValues()
  {
    if (srLst.size() == 0) return;
    Iterator<String> it = srLst.iterator();
    String prp = null, dev = "";
    TExportProperty p = null;
    TDataType srdt = null, tdt = null, ndt = new TDataType();
    int len = 0, siz = 1, cc = 0;
    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.getSaveRestoreData()) == null) continue;
      alst = p.getDeviceList();
      dlst = (alst != null) ?
          alst.toArray(new String[0]) :
          deviceList.getDeviceNameList();
      siz = 1; hasSrValues = null;
      if (srdt.isArrayOfPrimitives())
      {
        siz = p.getInputSize();
        if (siz > 1) hasSrValues = new boolean[siz];
      }
      tdt = new TDataType(siz,srdt.getFormat());
      len = srdt.getArrayLength();
      if (dlst != null && dlst.length > 0 && len > dlst.length)
View Full Code Here

Examples of de.desy.tine.server.properties.TExportProperty

  {
    TStrings.validatePropertyName(prpName);
    if (prpDesc == null) prpDesc = new TPropertyDescription(null);
    if (prpDesc.getArrayRowLength() == 0) prpDesc.setArrayRowLength(dout.dArrayLength);
    if (dout.dArrayLength == 1) prpDesc.setArrayType(TArrayType.AT_SCALAR);
    TExportProperty prp = new TExportProperty(prpId, prpName, acc, din, dout);
    prp.setDescription(prpDesc);
    propertyList.addProperty(this, prp, null);
    if (prpName.endsWith(".NAM")) deviceList.setPropertyOriented(true);
    if ((acc & TAccess.CA_SAVERESTORE) != 0 && validateSaveRestoreProperty(prp))
    {
      if (!srLst.contains(prpName)) srLst.add(prpName);
    }
    if ((acc & TAccess.CA_HIST) != 0)
    { // add a 'quick' history
      int fmt = prp.getOutputFormat();
      int siz = prp.getOutputSize();
      int idx = gEqmFactory.getNextHistoryRecordIndex(getLocalName(),prpName,"#0",fmt,siz);
      int cc = addLocalHistoryRecord(idx, "#0", prpName, siz, fmt);
      if (cc != 0) TFecLog.log("could not add "+prpName+" to local history subsystem: "+TErrorList.getErrorString(cc));
    }   
  }
View Full Code Here

Examples of de.desy.tine.server.properties.TExportProperty

      if (cc != 0) TFecLog.log("could not add "+prpName+" to local history subsystem: "+TErrorList.getErrorString(cc));
    }
    String aprpnam = gEqmFactory.getAliasFromName(prp.getName());
    if (aprpnam != null)
    { // register the alias as well !
      TExportProperty aprp = new TExportProperty(prp);
      aprp.setName(aprpnam);
      propertyList.addProperty(this,aprp, handler);
    }
    if (prp.getName().endsWith(".NAM")) deviceList.setPropertyOriented(true);
  }
View Full Code Here

Examples of de.desy.tine.server.properties.TExportProperty

          String[] slst = deviceList.getDeviceNameList();
          return (short)dout.putData(StringToName.stringArrayToName16(slst));     
        }
      }
      if (!propertyList.hasProperty(propertyName)) return TErrorList.illegal_property;
      TExportProperty prp = propertyList.getFirstProperty(propertyName);
      if (prp == null) return TErrorList.illegal_property;
      TPropertyEGU egu;
      int cc = 0;
      float[] fv = new float[1];
      switch (metaIndex)
      {
        case TMetaProperties.URL_ID:
          return (short) dout.putData(prp.getDescription().getUrl());
        case TMetaProperties.DSC_ID:
          return (short) dout.putData(prp.getDescription().getText());
        case TMetaProperties.MAX_ID:
        case TMetaProperties.XMAX_ID:
          egu = metaIndex == TMetaProperties.XMAX_ID ?
              prp.getDescription().getXRange() : prp.getDescription().getYRange();
          if (devAccess.isWrite())
          {
            if (din.dArrayLength != 1) return TErrorList.dimension_error;
            if (!TFormat.isNumberFormat(din.dFormat)) return TErrorList.illegal_format;
            if ((cc=din.getData(fv)) != 0) return (short)cc;
            egu.setMaxValue(fv[0]);
            if (dout.dArrayLength == 0) return 0;
          }                            
          if (!TFormat.isNumberFormat(dout.dFormat)) return TErrorList.illegal_format;
          fv[0] = egu.getMaxValue();
          return (short) dout.putData(fv);
        case TMetaProperties.MIN_ID:
        case TMetaProperties.XMIN_ID:
          egu = metaIndex == TMetaProperties.XMIN_ID ?
              prp.getDescription().getXRange() : prp.getDescription().getYRange();
          if (devAccess.isWrite())
          {
            if (din.dArrayLength != 1) return TErrorList.dimension_error;
            if (!TFormat.isNumberFormat(din.dFormat)) return TErrorList.illegal_format;
            if ((cc=din.getData(fv)) != 0) return (short)cc;
            egu.setMinValue(fv[0]);
            if (dout.dArrayLength == 0) return 0;
          }                            
          if (!TFormat.isNumberFormat(dout.dFormat)) return TErrorList.illegal_format;
          fv[0] = egu.getMinValue();
          return (short) dout.putData(fv);
        case TMetaProperties.XEGU_ID:
        case TMetaProperties.EGU_ID: // to satisfy DOOCS calls ...
          egu = metaIndex == TMetaProperties.XEGU_ID ?
                              prp.getDescription().getXRange() :
                              prp.getDescription().getYRange();
                             
          if (devAccess.isWrite())
          {
            switch (din.dFormat)
            {
              case TFormat.CF_NAME16:
              case TFormat.CF_NAME32:
              case TFormat.CF_NAME64:
                if (din.getArrayLength() != 1) return TErrorList.dimension_error;
              case TFormat.CF_TEXT:
                char[] newUnits = new char[64];
                cc = din.getData(newUnits);
                if (cc != 0) return (short)cc;
                egu.setUnits(new String(newUnits));
                break;
              case TFormat.CF_FLOAT:
              case TFormat.CF_DOUBLE:
              case TFormat.CF_DLONG:
              case TFormat.CF_LONG:
              case TFormat.CF_SHORT:
                if (din.dArrayLength != 2) return TErrorList.dimension_error;
                float[] yrng = new float[2];
                cc = din.getData(yrng);
                if (cc != 0) return (short)cc;
                egu.setMinValue(yrng[0]);
                egu.setMaxValue(yrng[1]);
                break;
              case TFormat.CF_USTRING:
                if (din.getArrayLength() != 1) return TErrorList.dimension_error;
                USTRING[] u = new USTRING[1];
                cc = din.getData(u);
                if (cc != 0) return (short)cc;
                egu.setUnits(u[0].getString());
                egu.setMinValue(u[0].f1val);
                egu.setMaxValue(u[0].f2val);
                egu.setGraphType((short)u[0].ival);
                break;
              default:
                return TErrorList.illegal_format;
            }           
            if (dout.dArrayLength == 0) return 0;
          }                            
          switch (dout.dFormat)
          {
            case TFormat.CF_TEXT:
            case TFormat.CF_NAME16:
            case TFormat.CF_NAME32:
            case TFormat.CF_NAME64:
              return (short) dout.putData(egu.getUnits());
            case TFormat.CF_FLOAT:
            case TFormat.CF_DOUBLE:
            case TFormat.CF_DLONG:
            case TFormat.CF_LONG:
            case TFormat.CF_SHORT:
              float[] yrng = new float[2];
              yrng[0] = egu.getMinValue();
              yrng[1] = egu.getMaxValue();
              return (short) dout.putData(yrng);
            case TFormat.CF_USTRING:
              USTRING[] u = new USTRING[1];
              u[0] = new USTRING(egu.getGraphType(),
                                 egu.getMinValue(),
                                 egu.getMaxValue(),
                                 0,
                                 egu.getUnits());
              return (short) dout.putData(u);
            default:
              return TErrorList.illegal_format;
          }
        case TMetaProperties.HST_ID:
          THistoryRecord hst = null;
          int listsize = gLclHstList.size();
          int index = 0, sample = 0;
          long start = 0;
          long stop = System.currentTimeMillis()-1000;
          float lwr = 0, upr = 0;
          Object data = null;
          int dataSize = 0, inputDataSize = 0;
          boolean isCentralArchiveRequest = false;
         
          if (TMetaProperties.isCentralArchive(metaPropertyName))
          {
            isCentralArchiveRequest = true;
          }
          boolean isSnapshot = TMetaProperties.isHistorySnapshot(metaPropertyName);
          dataSize = dout.getArrayLength();
          if (dout.dFormat == TFormat.CF_HISTORY)
          { // trap this early
            int hsiz = TFormat.getCarriedFormatSize(dout.getTag());
            if (hsiz > 0) dataSize /= hsiz + TFormat.getHistoryHeaderSize();
          }
          start = stop - dataSize * 1000; // millisecond timestamps here!
          // check the time range and/or filtering criteria the caller has given us ...
          if (din != null && (inputDataSize=din.getArrayLength()) > 0)
          {
            switch (din.getFormat())
            {
              case TFormat.CF_LONG:
                int[] ival = (int[])din.getDataObject();
                switch (inputDataSize)
                {
                  case 4: sample = ival[3];
                  case 3: index = ival[2];
                  case 2: if (ival[1] < (int)(stop/1000)) stop = ((long)ival[1])*1000;
                  case 1: start = ((long)ival[0])*1000;
                  default: break;
                }
                if (sample < 0) sample = 0;
                break;
               
              case TFormat.CF_DLONG:
                long[] lval = (long[])din.getDataObject();
                switch (inputDataSize)
                {
                  case 4: sample = (int)lval[3];
                  case 3: index = (int)lval[2];
                  case 2: if (lval[1] < stop/1000) stop = (long)(lval[1]*1000);
                  case 1: start = (long)(lval[0]*1000);
                  default: break;
                }
                if (sample < 0) sample = 0;
                break;
               
              case TFormat.CF_DOUBLE:
                double[] dval = (double[])din.getDataObject();
                switch (inputDataSize)
                {
                  case 4: sample = (int)dval[3];
                  case 3: index = (int)dval[2];
                  case 2: if (dval[1] < stop/1000) stop = (long)(dval[1]*1000);
                  case 1: start = (long)(dval[0]*1000);
                  default: break;
                }
                if (sample < 0) sample = 0;
                break;
              case TFormat.CF_FWINDOW:
                FWINDOW[] fw = (FWINDOW[])din.getDataObject();
                start = ((FWINDOW[])fw)[0].i1val * 1000;
                stop = ((FWINDOW[])fw)[0].i2val * 1000;
                lwr = ((FWINDOW[])fw)[0].f1val;
                upr = ((FWINDOW[])fw)[0].f2val;
                if (lwr < upr) sample = -1;
                break;
              default:
                return TErrorList.illegal_format;
            }
          }
          else
          { // no input given
            if (dataSize == 1)
            {
              start = stop;
              isSnapshot = true;
            }
          }
          if (isSnapshot)
          {
            if (start < 1) return TErrorList.argument_list_error;
            stop = start;
            sample = 0;
            index = 0;
            lwr = upr = (float)0.0;         
          }
          // what the caller wants returned ....
          boolean literalDevice = false;
          for (int i=0; i<listsize; i++)
          { // go thru the list to see if the requested device was stored literally
            hst = (THistoryRecord)gLclHstList.get(i);
            if (hst.getPrp().compareToIgnoreCase(prp.getName()) != 0) continue;
            if (hst.getDev().compareTo(devName) != 0) continue;
            literalDevice = true;
            break;
          }
          for (int i=0; i<listsize; i++)
          {
            hst = (THistoryRecord)gLclHstList.get(i);
            if (hst.getPrp().compareToIgnoreCase(prp.getName()) == 0)
            {
              if (hst.getDev().compareTo(devName) != 0)
              { // should we look for a match in the device name ?
                if (index == 0 && !literalDevice)
                  index = getDeviceList().getDeviceNumber(devName);
                else
                  continue;
              }
              if (isCentralArchiveRequest)
              {
                String rmtsrv = hst.getRemoteHistoryServer();
                if (rmtsrv == null || rmtsrv.length() == 0)
                { // try the central archive systematics ...
                  rmtsrv = "/"+getContext()+"/HISTORY/"+devName+"["+getExportName()+"."+propertyName+"]";
                }
                return (short)gEqmFactory.setRedirectionString(rmtsrv);
              }
              // snapshots always have index = 0
              if (start == stop && dataSize > 1) index = 0;
              switch (dout.dFormat)
              {
                case TFormat.CF_BYTE:
                  data = new byte[dataSize]; break;
                case TFormat.CF_SHORT:
                  data = new short[dataSize]; break;
                case TFormat.CF_LONG:
                  data = new int[dataSize]; break;
                case TFormat.CF_DLONG:
                  data = new long[dataSize]; break;               
                case TFormat.CF_INTINT:
                  data = new INTINT[dataSize]; break;
                case TFormat.CF_FLOAT:
                  data = new float[dataSize]; break;
                case TFormat.CF_FLTINT:
                  data = new FLTINT[dataSize]; break;
                case TFormat.CF_INTFLTINT:
                  data = new INTFLTINT[dataSize]; break;
                case TFormat.CF_DOUBLE:
                  data = new double[dataSize]; break;
                case TFormat.CF_DBLDBL:
                  data = new DBLDBL[dataSize]; break;
                case TFormat.CF_DBLTIME:
                  data = new DBLTIME[dataSize]; break;
                case TFormat.CF_NAME16: 
                  data = new NAME16[dataSize]; break;
                case TFormat.CF_NAME16I: 
                  data = new NAME16I[dataSize]; break;
                case TFormat.CF_NAME32: 
                  data = new NAME32[dataSize]; break;
                case TFormat.CF_NAME32I: 
                  data = new NAME32I[dataSize]; break;
                case TFormat.CF_NAME64: 
                  data = new NAME64[dataSize]; break;
                case TFormat.CF_NAME64I: 
                  data = new NAME64I[dataSize]; break;
                case TFormat.CF_HISTORY:
                  data = new HISTORY[dataSize];
                  // create the first one so as to pass the tag along
                  short f = TFormat.getFormatCode(dout.getTag());
                  if (f == TFormat.CF_NULL) return TErrorList.illegal_format;
                  TDataType d = new TDataType(1,f);
                  ((HISTORY[])data)[0] = new HISTORY(d);
                  break;
                default:
                  data = TFormat.makeCompoundDataObjectArray(dout.dFormat, dout.getTag(), dataSize);
                  break;
              }
              int nr = hst.getDataFromLTS(index,start,stop,lwr,upr,data,dataSize,0,sample);
              if (nr < 0)
              {
                if (nr == -TErrorList.server_redirection)
                {
                  String rmtsrv = hst.getRemoteHistoryServer();
                  if (rmtsrv == null || rmtsrv.length() == 0) return TErrorList.not_implemented;
                  return (short)gEqmFactory.setRedirectionString(rmtsrv);
                }
                return (short)-nr;
              }
              boolean needStsData = true;
              if (nr > 0)
              {
                if (isSnapshot || nr >= dataSize - 1)
                { // found the snapshot in or filled the buffer from LTS
                  dout.putData(data);
                  dout.setDataTimeStamp(hst.getLastReadTimestamp());
                  return 0;
                }
                start = hst.getLastReadTimestamp() + 1;
                if (start >= stop) needStsData = false; // we're finished
              }
              if (needStsData)
              { // still recent points to acquire
                nr = hst.getDataFromSTS(index,start,stop,lwr,upr,data,dataSize,nr,sample);
                if (nr < 0) return (short)-nr;
              }
              if (dataSize > 1 && nr < dataSize) dout.dArrayLength = nr;
              dout.putData(data);
              dout.setDataTimeStamp(hst.getLastReadTimestamp());
              return 0;
            }
          }
          return TErrorList.not_implemented;
        case TMetaProperties.NAM_ID:
          // if .NAM properties are registered they are handled with the normal property handler
          String[] slst = deviceList.getDeviceNameList();
          ArrayList<String> lst = prp.getDeviceList();
          if (lst != null && lst.size() > 0)
          {
            slst = new String[lst.size()];
            lst.toArray(slst);
          }
View Full Code Here

Examples of de.desy.tine.server.properties.TExportProperty

        if (ec.getName().compareTo(eqmName) == 0)
        {
          LinkedList<PropertyCfg> pl = ec.getPropertyList();
          for (PropertyCfg pc : pl)
          {
            TExportProperty xp = new TExportProperty(
              pc.getId().getValue(),pc.getName(),pc.getDescription(),
              pc.getSizeOut().getValue(),(short)pc.getDTypeOut().getValue(),pc.getDTagOut(),
              pc.getSizeIn().getValue(),(short)pc.getDTypeIn().getValue(),pc.getDTagIn(),
              (short)pc.getAccess().getValue());
            if (pc.getDeadband().getValue() > 0)
              xp.setAccessDeadband(pc.getDeadband().getValue());
            xp.getDescription().setArrayType((short)pc.getDArrayTypeOut());
            max = pc.getXmax().getValue();
            min = pc.getXmin().getValue();
            if (min > max) TFecLog.log(eqmName,"x min > x max for property "+pc.getName());
            xp.getDescription().setXRange(new TPropertyEGU(pc.getXEgu(),min,max));
            max = pc.getMax().getValue();
            min = pc.getMin().getValue();
            if (min > max) TFecLog.log(eqmName,"min > max for property "+pc.getName());
            xp.getDescription().setYRange(new TPropertyEGU(pc.getEgu(),min,max));
            // TODO:
            //expp.getDescription().setArrayNumRows(pc.getNumRows().getValue());
            xp.getDescription().setRedirection(pc.getRedirection());
            xp.hasExclusiveRead = pc.hasExclusiveRead;
            xp.hasUnlockedExclusiveRead = pc.hasUnlockedExclusiveRead;
            xp.isEnforceOutput = pc.isEnforceOutput;
            registerProperty(xp,null);
           
            dv = pc.getDevices();
            if (dv != null && dv.size() > 0)
            {
              int nr = 0;
              ArrayList<String> lst = new ArrayList<String>(dv.size());
              for (String d : dv)
              {
                lst.add(nr++,d);
              }
              xp.setDeviceList(lst);
              getDeviceList().setPropertyOriented(true);
            }
          }
          grp = ec.getGroup();
          if (grp != null && grp.length() > 0)
View Full Code Here

Examples of de.desy.tine.server.properties.TExportProperty

    return rc;
  }
  public int getRegisteredNamesFromPropertyFile(String propertyName)
  {
    TInitializer initializer = TInitializerFactory.getInstance().getInitializer();
    TExportProperty prp = propertyList.getFirstProperty(propertyName);
    String devFileName = propertyName + "-names.csv";
    csv devNamesFile = new csv(initializer.getFecHome()+File.separator+getLocalName()+File.separator+devFileName);
    int rc = devNamesFile == null ?
        TErrorList.file_error :
        getRegisteredDevicesFromFile(devNamesFile,new devNameRowHndlr(prp));
View Full Code Here

Examples of de.desy.tine.server.properties.TExportProperty

    if (rc == 0) device.setPropertyList(namhdlr.prpLst);
    return rc;
  }
  public boolean isDeviceSetLocal(String devName, String propertyName)
  {
    TExportProperty prp = propertyList.getFirstProperty(propertyName);
    WildcardMatch wc = new WildcardMatch(devName);   
    String tgt;
    TDevice[] dlst = getDeviceList().getDeviceList();
    for (int i=0; i<dlst.length; i++)
    {
      if ((tgt=dlst[i].getRedirection()) != null)
      {
        if (wc.matches(tgt)) return false;
      }
    }   
    if ((tgt=prp.getDescription().getRedirection()) != null)
    {
      if (wc.matches(tgt)) return false;     
    }
    return true; /* appears to be local so-far */   
  }
View Full Code Here

Examples of de.desy.tine.server.properties.TExportProperty

    {
      if (devName == null) return -TErrorList.argument_list_error;
      if (devName.startsWith("#")) return Integer.parseInt(devName.substring(1));
      if (deviceList.isPropertyOriented() && devProperty != null)
      {
        TExportProperty prp = propertyList.getFirstProperty(devProperty);
        if (prp != null)
        {
          ArrayList<String> lst = prp.getDeviceList();
          if (lst != null) return lst.indexOf(devName);
        }
      }
      return deviceList.getDeviceNumber(devName);
    }
View Full Code Here
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.