Package de.desy.tine.server.properties

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


      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

          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.RBSUMMARY_ID:
        case TMetaProperties.RBMAX_ID:
        case TMetaProperties.RBMIN_ID:
        case TMetaProperties.RBAVE_ID:
          {
            double[] sampleInterval = new double[] {0};
            if (din != null && (din.getArrayLength()) > 0)
            {
              if ((cc=din.getData(sampleInterval)) != 0) return (short)cc;
            }
            int index = 0;
            int[] idxr = new int[]{index};
            THistoryRecord hst = getLocalHistoryRecord(prp.getName(), devName, idxr);
            if (hst == null) return TErrorList.not_implemented;
            index = idxr[0];
            DSUMMARY ds = null;
            try
            {
              ds = hst.getDataSummaryFromSTS(sampleInterval[0]);
            }
            catch (TineRuntimeErrorException e)
            {
              return (short)e.getErrorCode();
            }
            switch (dout.dFormat)
            {
              case TFormat.CF_STRUCT:
                if (metaIndex != TMetaProperties.RBSUMMARY_ID)
                  return TErrorList.illegal_property;
                if (dout.getTag().compareTo("DSUMMARY") != 0)
                  return TErrorList.invalid_structure_tag;
                cc = dout.putData(ds);
                break;
              default:
                double[] vals = ds.getSummary();
                switch (metaIndex)
                {
                  case TMetaProperties.RBAVE_ID:
                    cc = dout.putData(vals,1,0);
                    break;
                  case TMetaProperties.RBMAX_ID:
                    cc = dout.putData(vals,1,2);
                    break;
                  case TMetaProperties.RBMIN_ID:
                    cc = dout.putData(vals,1,3);
                    break;
                  default:
                    cc = dout.putData(vals);
                    break;
                }
            }
            if (cc != 0) return (short)cc;
            dout.setDataTimeStamp(hst.getLastReadTimestamp());
            dout.setSystemDataStamp(hst.getLastReadSystemStamp());
          }
          return 0;
        case TMetaProperties.HST_ID:
          THistoryRecord hst = null;
          int index = 0, sample = 0;
          long start = 0;
          long stop = TDataTime.now() - 1000;
          int sysstart = 0, sysstop = 0;
          int cycnr = TEquipmentModuleFactory.getCycleNumber();
          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_INT32:
                int[] ival = (int[])din.getDataObject();
                switch (inputDataSize)
                {
                  case 6: sysstop = ival[5];
                    if (cycnr == 0) sysstop = 0;
                    if (sysstop > cycnr) sysstop = cycnr;
                  case 5: sysstart = ival[4];
                    if (cycnr == 0) sysstart = 0;
                  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_INT64:
                long[] lval = (long[])din.getDataObject();
                switch (inputDataSize)
                {
                  case 6: sysstop = (int)lval[5];
                    if (cycnr == 0) sysstop = 0;
                    if (sysstop > cycnr) sysstop = cycnr;
                  case 5: sysstart = (int)lval[4];
                    if (cycnr == 0) sysstart = 0;
                  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 6: sysstop = (int)dval[5];
                    if (cycnr == 0) sysstop = 0;
                    if (sysstop > cycnr) sysstop = cycnr;
                  case 5: sysstart = (int)dval[4];
                    if (cycnr == 0) sysstart = 0;
                  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;
            if (sysstart > 0) sysstop = sysstart; else stop = start;
            sample = 0;
            index = 0;
            lwr = upr = (float)0.0;         
          }
          // what the caller wants returned ....
          int[] idxr = new int[]{index};
          hst = getLocalHistoryRecord(prp.getName(), devName, idxr);
          if (hst == null) return TErrorList.not_implemented;
          index = idxr[0];
          if (start == 0)
          { // start still not set, so:
            start = stop - dataSize*hst.getHspec().getPollngRate();
          }
          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);
          }
          boolean isSummary = false;
          if (metaPropertyName.contains(".RB"))
          {
            if (metaPropertyName.contains(".RBAVE."))
            {
              index = 0;
              isSummary = true;
            }
            if (metaPropertyName.contains(".RBMAX."))
            {
              index = 2;
              isSummary = true;
            }
            if (metaPropertyName.contains(".RBMIN."))
            {
              index = 3;
              isSummary = true;
            }
            if (isSnapshot) return TErrorList.not_implemented;
          }         
          // snapshots always have index = 0
          if (start == stop && dataSize > 1) index = 0;
          data = makeLocalHistoryDataObject(dout.dFormat,dout.getTag(),dataSize);
          if (data == null) return TErrorList.illegal_format;
          int nr = hst.getDataFromLTS(index,start,stop,sysstart,sysstop,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 = !isSummary; // no STS Data in history call for Summary
          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());
              dout.setSystemDataStamp(hst.getLastReadSystemStamp());
              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,sysstart,sysstop,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());
          dout.setSystemDataStamp(hst.getLastReadSystemStamp());
          return 0;         
        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

      if (strValue == null || strValue.length() == 0) return 0;
      // parse access mode according to convention
      String accessString = strValue.trim().toUpperCase();
      short ta = 0;
      int idx = -1;
      TExportProperty txp = rHndlr.getExportProperty();
      if (txp == null) return TErrorList.code_failure;
      if ((idx=accessString.indexOf("XREAD")) >= 0)
      { // remove this from the accessString for further comparisons
        txp.hasExclusiveRead = true;
        String s = accessString.substring(0, idx);
        s += accessString.substring(idx+5, accessString.length());
        accessString = s;
      }
      if (accessString.indexOf("WRITE") >= 0) ta |=  TAccess.CA_WRITE;
      if (accessString.indexOf("READ") >= 0) ta |=  TAccess.CA_READ;
      if (accessString.indexOf("NETWORK") >= 0) ta |=  TAccess.CA_READ|TAccess.CA_NETWORK;
      if (accessString.indexOf("ASYNC") >= 0)
      {
        ta &= ~(TAccess.CA_WRITE);
        ta |=  TAccess.CA_READ|TAccess.CA_NOSYNC;     
      }
      if (accessString.indexOf("SAVERESTORE") >= 0) ta |=  TAccess.CA_SAVERESTORE;
      if (accessString.indexOf("HIST") >= 0) ta |=  TAccess.CA_HIST;
      if (accessString.indexOf("FORCEOUTPUT") >= 0) ta |=  TAccess.CA_FORCEOUTPUT;
      txp.setAccessMode(ta);
      if (txp.hasExclusiveRead && !TAccess.isRead((byte)ta))
      { // force read calls thru the security layer for this property !
        txp.hasUnlockedExclusiveRead = true;
      }
      return 0;
View Full Code Here

    private boolean isXaxis = false;
    expMaxValueHndlr(expRowHndlr rowHndlr,boolean xaxis) {rHndlr = rowHndlr; isXaxis = xaxis;}
    public int process(String strValue,int index)
    {
      if (strValue == null || strValue.length() == 0) return 0;
      TExportProperty txp = rHndlr.getExportProperty();
      if (txp == null) return TErrorList.code_failure;
      if (isXaxis)
        txp.setMaximumXValue(Float.valueOf(strValue).floatValue());
      else
        txp.setMaximumValue(Float.valueOf(strValue).floatValue());
      return 0;
    }
View Full Code Here

    private boolean isXaxis = false;
    expMinValueHndlr(expRowHndlr rowHndlr,boolean xaxis) {rHndlr = rowHndlr; isXaxis = xaxis;}
    public int process(String strValue,int index)
    {
      if (strValue == null || strValue.length() == 0) return 0;
      TExportProperty txp = rHndlr.getExportProperty();
      if (txp == null) return TErrorList.code_failure;
      if (isXaxis)
        txp.setMinimumXValue(Float.valueOf(strValue).floatValue());
      else
        txp.setMinimumValue(Float.valueOf(strValue).floatValue());
      return 0;
    }
View Full Code Here

    private boolean isXaxis = false;
    expUnitsHndlr(expRowHndlr rowHndlr,boolean xaxis) {rHndlr = rowHndlr; isXaxis = xaxis;}
    public int process(String strValue,int index)
    {
      if (strValue == null) return 0;
      TExportProperty txp = rHndlr.getExportProperty();
      if (txp == null) return TErrorList.code_failure;
      if (isXaxis)
        txp.setXUnits(strValue);
      else
        txp.setUnits(strValue);
      return 0;
    }
View Full Code Here

    public int getNumDevsHist() { return numDevsHint; }
    public TExportProperty getExportProperty() { return xp; }
    public TPropertyDescription getPropertyDescription() { return prpDesc; }
    expRowHndlr(String targetName)
    {
      xp = new TExportProperty();
      prpDesc = new TPropertyDescription();
      if (targetLocalName == null) targetLocalName = targetName;
    }
View Full Code Here

        }
      }
      xp.setDescription(prpDesc);
      registerProperty(xp,null);
      // allocate a new one
      xp = new TExportProperty();
      prpDesc = new TPropertyDescription();
      if (numDevsHint > numDevicesFromExportsFile)
        numDevicesFromExportsFile = numDevsHint;
      return 0;
    }
View Full Code Here

    public int process(String strValue,int index)
    {
      if (strValue == null || strValue.length() == 0) return 0;
      try
      {
        TExportProperty xp = rHndlr.getExportProperty();
        addPrpDbaItem(xp.getName(), xp.getAccessMode(), new Integer(strValue).intValue());
      }
      catch (Exception e)
      { // just dump the stack (parsing error?, xp == null ?)
        e.printStackTrace();
      }
View Full Code Here

TOP

Related Classes of de.desy.tine.server.properties.TExportProperty

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.