Examples of TDevice


Examples of de.desy.tine.server.devices.TDevice

    TDataType din = new TDataType();
    TAccess access = new TAccess(TAccess.CA_ALARM + TAccess.CA_READ);
    TAlarmWatchEntry awe = null;
    TAlarmDefinition adef = null;
    TAlarm alm = null;
    TDevice dev = null;
    int cc = 0, cnt = 0, siz = 0, sev = 0, devNr, code = 0, asys = 0;
    String tag = null;
    float fvals[] = null;
    int ivals[] = null;
    byte[] abytes = null;
    synchronized (gAlarmWatchList)
    {
      TEquipmentModuleFactory f = getEquipmentModuleFactory();
      f.setCurrentContractEntry(f.awtcon);
      int awlength = gAlarmWatchList.size();
      for (int i=0; i<awlength; i++)
      {
        awe = (TAlarmWatchEntry)gAlarmWatchList.get(i);
        int chk = awe.checkNormal();
        if (chk != 0)
        {
          ivals = new int[awe.getSiz()];
          dout = new TDataType(ivals);
          cc = callProperty(awe.getPrp(),awe.getDev(),dout,din,access);
        }
        else
        {
          fvals = new float[awe.getSiz()];
          dout = new TDataType(fvals);
          cc = callProperty(awe.getPrp(),awe.getDev(),dout,din,access);
        }
        if (cc != 0) continue;
        boolean hasAlarm = false;
        devNr = deviceList.getDeviceNumber(awe.getDev());
        cnt = 0; siz = awe.getSiz();
        for (int j=0; j<siz; j++)
        {
          if (awe.getAtyp() == TArrayType.AT_CHANNEL) devNr = j;
          if (awe.getAtyp() != TArrayType.AT_WAVEFORM && siz == deviceList.getNumberOfDevices())
            devNr = j; /* assume array of devices */
          dev = deviceList.getDevice(devNr);
          hasAlarm = false;
          if (ivals != null)
          {   
            int nval = awe.getNormal();
            if ((chk == 1 && nval != (awe.getMask() & ivals[j])) ||
                (chk == -1 && nval == (awe.getMask() & ivals[j])) )
            {
             if (TEquipmentModuleFactory.debugLevel > 1)
               DbgLog.log("checkAlarmsInWatchTable", awe.getPrp()+" "+awe.getDev()+
                   " alarm state ! : "+(awe.getMask() & ivals[j])+" vs "+nval);
              code = awe.getCode();
              if (code == 0) code = TErrorList.invalid_data;
              sev = awe.getSev();
              asys = awe.getAsys();
              hasAlarm = true;
            }
            abytes = Swap.LongToBytes(ivals[j]);
          }
          else if (fvals != null)
          {
            if (fvals[j] > awe.getHi())
            {
              if (TEquipmentModuleFactory.debugLevel > 1)
                DbgLog.log("checkAlarmsInWatchTable", awe.getPrp()+" "+awe.getDev()+
                    " alarm state ! : "+fvals[j]+" > "+awe.getHi());
              code = awe.getCode();
              if (code == 0) code = awe.getCodeHigh();
              if (code == 0) code = TErrorList.value_too_high;
              sev = awe.getSev();
              asys = awe.getAsys();
              tag = awe.getTagHigh();
              hasAlarm = true;
            }
            else if (fvals[j] > awe.getHiwarn())
            {
              if (TEquipmentModuleFactory.debugLevel > 1)
                DbgLog.log("checkAlarmsInWatchTable", awe.getPrp()+" "+awe.getDev()+
                    " warn state ! : "+fvals[j]+" > "+awe.getHiwarn());
              code = awe.getCode();
              if (code == 0) code = awe.getCodeHigh();
              if (code == 0) code = TErrorList.warn_too_high;         
              sev = awe.getSev()-2;
              asys = awe.getAsys();
              tag = awe.getTagHigh();
              hasAlarm = true;
            }
            else if (fvals[j] < awe.getLo())
            {
              if (TEquipmentModuleFactory.debugLevel > 1)
                DbgLog.log("checkAlarmsInWatchTable", awe.getPrp()+" "+awe.getDev()+
                    " alarm state ! : "+fvals[j]+" < "+awe.getLo());
              code = awe.getCode();
              if (code == 0) code = awe.getCodeLow();
              if (code == 0) code = TErrorList.value_too_low;         
              sev = awe.getSev();
              asys = awe.getAsys();
              tag = awe.getTagLow();
              hasAlarm = true;
            }
            else if (fvals[j] < awe.getLowarn())
            {
              if (TEquipmentModuleFactory.debugLevel > 1)
                DbgLog.log("checkAlarmsInWatchTable", awe.getPrp()+" "+awe.getDev()+
                    " warn state ! : "+fvals[j]+" < "+awe.getLowarn());
              code = awe.getCode();
              if (code == 0) code = awe.getCodeLow();
              if (code == 0) code = TErrorList.warn_too_low;         
              sev = awe.getSev()-2;
              asys = awe.getAsys();
              tag = awe.getTagLow();
              hasAlarm = true;
            }
            abytes = Swap.Float(fvals[j]);
          }
          if (!hasAlarm)
          { // run through clearAlarm()
            dev.clearAlarm(TErrorList.invalid_data,awe);
            dev.clearAlarm(TErrorList.value_too_high,awe);
            dev.clearAlarm(TErrorList.value_too_low,awe);
            dev.clearAlarm(TErrorList.warn_too_high,awe);
            dev.clearAlarm(TErrorList.warn_too_low,awe);
            if (awe.getCode() > 0) dev.clearAlarm(awe.getCode(),awe);
            if (awe.getCodeHigh() > 0) dev.clearAlarm(awe.getCodeHigh(),awe);
            if (awe.getCodeLow() > 0) dev.clearAlarm(awe.getCodeLow(),awe);
            continue;
          }
          if (code == 0) continue;
          if (!awe.isPastFilter()) continue;
          cnt = awe.getCnt() + 1;
          awe.setCnt(cnt);
          if (cnt > awe.getCntThreshold() && dev != null)
          {
            alm = dev.setAlarm(code,abytes,awe);
            if (alm != null)
            {
              adef = alm.getAlmDef();
              if (sev != 0) adef.setAlarmSeverity(sev);
              if (asys != 0) adef.setAlarmSystem(asys);
View Full Code Here

Examples of de.desy.tine.server.devices.TDevice

   * Registers the equipment module's stock properties
   */
  private int prpQueryCall(String devName, TDataType dout, TDataType din, TAccess devAccess)
  { // use in calls for "PROPS" or "PROPERTIES"
    int cc = 0;
    TDevice dev = getDeviceList().getDevice(devName);
    LinkedList<String> lst = null;
    boolean checkWildCard = (devName.compareTo("*") != 0 && devName.indexOf("*") != -1);
   
    if (dev != null && (lst=dev.getPropertyList()) != null)
    {
      String[] slst = new String[lst.size()];
      lst.toArray(slst);
      if (checkWildCard) slst = StringToName.matchStringsInArray(slst,devName);
      if (dout.getFormat() == TFormat.CF_USTRING)
View Full Code Here

Examples of de.desy.tine.server.devices.TDevice

    return filter;
  }
  private int metaprpQueryCall(String devName, TDataType dout, TDataType din, TAccess devAccess)
  { // use in calls for "METAPROPERTIES"
    int cc = 0, filter = getMetaPrpsCallFilter(din);
    TDevice dev = getDeviceList().getDevice(devName);
    LinkedList<String> lst = null;
   
    if (dev != null && (lst=dev.getPropertyList()) != null)
    {
      String[] slst = new String[lst.size()];
      lst.toArray(slst);
      LinkedList<TExportProperty> plst = new LinkedList<TExportProperty>();
      LinkedList<TExportProperty> thesePrps;
View Full Code Here

Examples of de.desy.tine.server.devices.TDevice

    stockList.addProperty(TStockProperties.METAPROPS_STRUCT, metapropertiesStructHandler);
    stockList.addProperty(TStockProperties.DEVLOCATION, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        TDevice tdv = deviceList.getDevice(devName);
        if (tdv == null) return TErrorList.illegal_device;
        if (din != null && devAccess.isWrite())
        {
          int cc = 0;
          char[] newLocation = new char[64];
          if ((cc=din.getData(newLocation)) != 0) return cc;
          tdv.setLocation(new String(newLocation));         
        }       
        String dloc = tdv.getLocation();
        if (dloc == null) dloc = gEqmFactory.getFecLocation();
        if (dloc != null && dloc.startsWith("<"))
        { /* redirection character */
          String rdrstr = null, envstr;
          dloc = dloc.substring(1); dloc.trim();
          if (dloc.startsWith("$"))
          {
            int idx = dloc.indexOf('/');
            if (idx < 0) idx = dloc.length();
            envstr = dloc.substring(1, idx);
            rdrstr = System.getenv(envstr);
            if (rdrstr == null) MsgLog.log("TEquipmentModule:DEVLOCATION", "environment variable "+envstr+" not set",TErrorList.not_defined,null,0);
            dloc = dloc.substring(idx);
          }
          if (rdrstr == null) rdrstr = "";
          rdrstr += dloc;
          if (rdrstr.indexOf('[') < 0) rdrstr += "[Location]";
          return gEqmFactory.setRedirectionString(rdrstr);
        }      
        return dout.putData(dloc == null ? "" : dloc);
      }
    });   
    stockList.addProperty(TStockProperties.DEVMASK, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        TDevice tdv = deviceList.getDevice(devName);
        if (tdv == null) return TErrorList.illegal_device;
        if (din != null && devAccess.isWrite())
        {
          int cc = 0;
          int[] newMask = new int[1];
          if ((cc=din.getData(newMask)) != 0) return cc;
          tdv.setMask(newMask[0]);         
        }               
        int mask = tdv.getMask();
        return dout.putData(mask);
      }
    });   
    stockList.addProperty(TStockProperties.ZPOSITION, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        TDevice tdv = deviceList.getDevice(devName);
        if (tdv == null) return TErrorList.illegal_device;
        if (din != null && devAccess.isWrite())
        {
          int cc = 0;
          float[] newZPos = new float[1];
          if ((cc=din.getData(newZPos)) != 0) return cc;
          tdv.setZposition(newZPos[0]);         
        }               
        float p = tdv.getZposition();
        return dout.putData(p);
      }
    });   
    stockList.addProperty(TStockProperties.DEVONLINE, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        TDevice tdv = deviceList.getDevice(devName);
        if (tdv == null) return TErrorList.illegal_device;
        if (din != null && devAccess.isWrite())
        {
          int cc = 0;
          int[] newFlg = new int[1];
          if ((cc=din.getData(newFlg)) != 0) return cc;
          tdv.setOffline(newFlg[0] == 0 ? true : false);         
        }               
        boolean p = !tdv.isOffline();
        return dout.putData(p);
      }
    });   
    stockList.addProperty(TStockProperties.PROPERTIES, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        return prpQueryCall(devName,dout,din,devAccess);
      }
    });
    stockList.addProperty(TStockProperties.PROPERTIES_USTRING, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        return prpQueryCall(devName,dout,din,devAccess);
      }
    });
    stockList.addProperty(TStockProperties.PROPERTIES_STRUCT, propertiesStructHandler);
    stockList.addProperty(TStockProperties.PROPS, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        return prpQueryCall(devName,dout,din,devAccess);
      }
    });
    stockList.addProperty(TStockProperties.PROPS_USTRING, new TPropertyHandler()
        {
          public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
          {
            return prpQueryCall(devName,dout,din,devAccess);
          }
        });
    stockList.addProperty(TStockProperties.PROPS_STRUCT, propertiesStructHandler);
    stockList.addProperty(TStockProperties.NPROPERTIES, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        return dout.putData(propertyList.countUniqueProperties());
      }
    });
    // Same as NPROPERTIES
    stockList.addProperty(TStockProperties.NPROPS, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        return dout.putData(propertyList.countUniqueProperties());
      }
    });
    stockList.addProperty(TStockProperties.NDEVICES, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        //return dout.putData(deviceList.size());
        return dout.putData(deviceList.getNumberOfDevices());
      }
    });
    stockList.addProperty(TStockProperties.DEVICES, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        String[] namlst;
        if (devName.compareTo("*") != 0 && devName.indexOf("*") != -1)
        { // query for a subset of device names ...
          WildcardMatch wc = new WildcardMatch(devName);
          TDevice dev;
          LinkedList<String> nl = new LinkedList<String>();
          String dn;
          int n = 0, mask = 0;
          if (din != null && din.dArrayLength == 1 && din.dFormat == TFormat.CF_INT32)
          {
            int[] msk = new int[1];
            din.getData(msk);
            mask = msk[0];
          }
          for (int i=0; i<deviceList.getNumberOfDevices(); i++)
          {
            if ((dev=deviceList.getDevice(i)) == null) continue;
            if (dev.isOffline()) continue;
            if (mask > 0 && !dev.isMaskSet(mask)) continue;
            dn = dev.getName();
            if (!wc.matches(dn)) continue;
            nl.add(dn);
            n++;
          }
          namlst = nl.toArray(new String[n]);
        }
        else
        {
          namlst = deviceList.getDeviceNameList();
        }
        int cc = dout.putData(StringToName.stringArrayToName64(namlst));
        if (cc == 0)
        {
          if (dout.getArrayLength() > namlst.length) dout.setArrayLength(namlst.length);
          if (getDeviceList().isPropertyOriented())
            cc = TErrorList.has_query_function | TErrorList.CE_SENDDATA;
        }
        return cc;
      }
    });
    stockList.addProperty(TStockProperties.DEVDESCRIPTION, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        TDevice tdv = deviceList.getDevice(devName);
        if (tdv == null) return TErrorList.illegal_device;
        String dsc = tdv.getDescription();
        return dout.putData(dsc == null ? "" : dsc);
      }
    });   
    stockList.addProperty(TStockProperties.SRVSUBSYSTEM, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        String subs = getSubsystem();
        return dout.putData(subs == null ? "" : subs);
      }
    });   
    stockList.addProperty(TStockProperties.SRVIDLE, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        int cc = 0;
        int[] idleState = new int[1];
        if (din != null && devAccess.isWrite())
        {
          if ((cc=din.getData(idleState)) != 0) return cc;
          isIdle = idleState[0] == 0 ? false : true;
        }
        if (dout != null && dout.dArrayLength > 0)
        {
          idleState[0] = isIdle ? -1 : 0;
          cc = dout.putData(idleState);
        }
        return cc;
      }
    });
    stockList.addProperty(TStockProperties.SRVINIT, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        int cc = 0;
        if (!devAccess.isWrite()) return TErrorList.illegal_read_write;
        {
          if (eqpIni == null) return TErrorList.not_implemented;
          cc = eqpIni.initialize();
        }
        return cc;
      }
    });
    stockList.addProperty(TStockProperties.SRVADDR, new TPropertyHandler()
    {
      protected int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        NAME32[] n32 = new NAME32[dout.dArrayLength];
        String eqm, exp;
        TEquipmentModule eq;
        int cc = 0;
        if (gEqmFactory.isServiceRequest(moduleName))
        {
          NAME32[] tgt = new NAME32[3];
          if ((cc=din.getData(tgt)) != 0) return cc;
          String ctxName = tgt[0].getName();
          //String eqmName = tgt[1].getName();
          String expName = tgt[2].getName();
          if ((eq=gEqmFactory.getEquipmentModuleFromExportName(expName)) == null)
            return TErrorList.invalid_data;
          if (eq.context.compareToIgnoreCase(ctxName) != 0) return TErrorList.invalid_data;
          eqm = eq.moduleName;
          exp = eq.exportName;
        }       
        else
        {
          eqm = moduleName;
          exp = exportName;
        }
        cc = gEqmFactory.getSrvAddress(n32,eqm,exp);
        return (short) dout.putData(n32);
      }
    });
    stockList.addProperty(TStockProperties.USERS, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        NAME16[] n16 = getRegisteredUsers();
        if (din != null && din.dArrayLength > 0)
        {
          if (!TFormat.isString(din.dFormat)) return TErrorList.illegal_format;
          char[] data = new char[TStrings.PROPERTY_NAME_SIZE];
          int cc = din.getData(data);
          if (cc != 0) return cc;
          String str = new String(data).trim();
          TExportProperty txp = getPropertyList().getFirstProperty(str);
          if (txp != null)
          { // property name given as input
            n16 = txp.getRegisteredUsers();
          }
          else
          { // maybe a device name then ...
            TDevice dev = getDeviceList().getDevice(str);
            if (dev != null) n16 = dev.getRegisteredUsers();
            else return TErrorList.invalid_keyword;
          }
        }
        if (n16 == null)
        {
          n16 = new NAME16[1];
          n16[0] = new NAME16("");
        }
        dout.dArrayLength = n16 == null ? 0 : n16.length;
        return n16 == null ? 0 : dout.putData(n16);
      }
    });
    stockList.addProperty(TStockProperties.NUSERS, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        short n = (short)gRegisteredUsersList.size();
        if (din != null && din.dArrayLength > 0)
        {
          if (!TFormat.isString(din.dFormat)) return TErrorList.illegal_format;
          char[] data = new char[TStrings.PROPERTY_NAME_SIZE];
          int cc = din.getData(data);
          if (cc != 0) return cc;
          String str = new String(data).trim();
          TExportProperty txp = getPropertyList().getFirstProperty(str);
          if (txp != null)
          { // property name given as input
            n = (short)txp.getNumberRegisteredUsers();
          }
          else
          { // maybe a device name then ...
            TDevice dev = getDeviceList().getDevice(str);
            if (dev != null) n = (short)dev.getNumberRegisteredUsers();
            else return TErrorList.invalid_keyword;
          }
        }
        return dout.putData(n);
      }
    });
    stockList.addProperty(TStockProperties.ADDUSER, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        int cc;
        if (din != null && devAccess.isWrite())
        {
          NAME16[] usr = new NAME16[1];
          if ((cc=din.getData(usr)) != 0) return cc;
          return addRegisteredUser(usr[0].getName());
        }
        return TErrorList.illegal_read_write;
      }
    });
    stockList.addProperty(TStockProperties.DELUSER, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        int cc;
        if (din != null && devAccess.isWrite())
        {
          NAME16[] usr = new NAME16[1];
          if ((cc=din.getData(usr)) != 0) return cc;
          return removeRegisteredUser(usr[0].getName());
        }
        return TErrorList.illegal_read_write;
      }
    });
    stockList.addProperty(TStockProperties.IPNETS, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        NAME16[] n16 = getRegisteredNets();
        if (din != null && din.dArrayLength > 0)
        {
          if (!TFormat.isString(din.dFormat)) return TErrorList.illegal_format;
          char[] data = new char[TStrings.PROPERTY_NAME_SIZE];
          int cc = din.getData(data);
          if (cc != 0) return cc;
          String str = new String(data).trim();
          TExportProperty txp = getPropertyList().getFirstProperty(str);
          if (txp != null)
          { // property name given as input
            n16 = txp.getRegisteredNets();
          }
          else
          { // maybe a device name then ...
            TDevice dev = getDeviceList().getDevice(str);
            if (dev != null) n16 = dev.getRegisteredNets();
            else return TErrorList.invalid_keyword;
          }
        }
        dout.dArrayLength = n16 == null ? 0 : n16.length;
        return n16 == null ? 0 : dout.putData(n16);
      }
    });
    stockList.addProperty(TStockProperties.NIPNETS, new TPropertyHandler()
    {
      public int call(String devName, TDataType dout, TDataType din, TAccess devAccess)
      {
        short n = (short)gRegisteredNetsList.size();
        if (din != null && din.dArrayLength > 0)
        {
          if (!TFormat.isString(din.dFormat)) return TErrorList.illegal_format;
          char[] data = new char[TStrings.PROPERTY_NAME_SIZE];
          int cc = din.getData(data);
          if (cc != 0) return cc;
          String str = new String(data).trim();
          TExportProperty txp = getPropertyList().getFirstProperty(str);
          if (txp != null)
          { // property name given as input
            n = (short)txp.getNumberRegisteredUsers();
          }
          else
          { // maybe a device name then ...
            TDevice dev = getDeviceList().getDevice(str);
            if (dev != null) n = (short)dev.getNumberRegisteredNets();
            else return TErrorList.invalid_keyword;
          }
        }
        return dout.putData(n);
      }
View Full Code Here

Examples of de.desy.tine.server.devices.TDevice

  }
  private boolean isMemberDeviceAclList(TEquipmentModule eqm, TClient tc, String devName)
  {
    try
    {
      TDevice dev = eqm.getDeviceList().getDevice(devName);
      return dev.isMemberUsersList(tc) && dev.isMemberControlNets(tc);
    }
    catch (Exception ignore) {}
    return true;
  }
View Full Code Here

Examples of de.desy.tine.server.devices.TDevice

    if (em == null) return;
    if (srvCycleTime < lastCheckFreeBlocks + 60000) return;
    lastCheckFreeBlocks = srvCycleTime;
    String txt;
    MinDiskSpaceTblEntry te = null;
    TDevice td = null;
    for (i=0; i<minDiskSpaceTbl.size(); i++)
    {
      te = minDiskSpaceTbl.get(i);
      if (te.minFreeBlks <= 0) continue;
      td = em.getDeviceList().getDevice(0);
      td.clearAlarm(TErrorList.warn_disk_space);
      td.clearAlarm(TErrorList.low_disk_space);
      freeblks = getAvailableDiskSpaceInBlocks(te.path);
      if (freeblks < te.minFreeBlks)
      {
        txt = te.path+" "+freeblks+" kb";
        if (freeblks < te.minFreeBlks/10) code = TErrorList.low_disk_space;
        code = TAlarm.encodeDiskSpaceAlarm(i,code);
        td.setAlarm(code,txt.getBytes());
      }
    }
  }
View Full Code Here

Examples of de.desy.tine.server.devices.TDevice

    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);

    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, tct.din, 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, tct.din, 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, tct.din, 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;
        }
View Full Code Here

Examples of de.desy.tine.server.devices.TDevice

    boolean gateOffline = (gateType == TMetaProperties.GATE_ARRAY) && (gate == -1);
    boolean gateArray = (gateType == TMetaProperties.GATE_ARRAY) && (gate > 0);
    boolean gateData = true;
    Object hDataObject = dout.getDataObject();
    int size = dout.getArrayLength();
    TDevice dev;
    if (gateOffline || gateArray)
    { // need to have a valid device list
      if (devlst == null) return;
      if (devlst.getNumberOfDevices() != size) return;
      gateData = false;
    }
    switch (dout.getFormat())
    {
      case TFormat.CF_BYTE:
      {
        byte[] data = (byte[])hDataObject;
        for (i=0; i<size; i++)
        {
          if ((dev=devlst.getDevice(i)) == null) continue;
          if (gateOffline && dev.isOffline()) continue;
          if (gateArray && !dev.isMaskSet(gate)) continue;
          if (i > n) data[n] = data[i];
          if (gateData) data[n] &= gate;
          if (gateBoolean) data[n] = (byte)(data[n] == (byte)gate ? 1 : 0);
          n++;
        }
        if (n < size) dout.setArrayLength(n);
        dout.putData(data);
        break;
      }
      case TFormat.CF_INT16:
      {
        short[] data = (short[])hDataObject;
        for (i=0; i<size; i++)
        {
          if ((dev=devlst.getDevice(i)) == null) continue;
          if (gateOffline && dev.isOffline()) continue;
          if (gateArray && !dev.isMaskSet(gate)) continue;
          if (i > n) data[n] = data[i];
          if (gateData) data[n] &= gate;
          if (gateBoolean) data[n] = (short)(data[n] == (short)gate ? 1 : 0);
          n++;
        }
        if (n < size) dout.setArrayLength(n);
        dout.putData(data);
        break;
      }
      case TFormat.CF_INT32:
      {
        int[] data = (int[])hDataObject;
        for (i=0; i<size; i++)
        {
          if ((dev=devlst.getDevice(i)) == null) continue;
          if (gateOffline && dev.isOffline()) continue;
          if (gateArray && !dev.isMaskSet(gate)) continue;
          if (i > n) data[n] = data[i];
          if (gateData) data[n] &= gate;
          if (gateBoolean) data[n] = (int)(data[n] == (int)gate ? 1 : 0);
          n++;
        }
        if (n < size) dout.setArrayLength(n);
        dout.putData(data);
        break;
      }
      default:
        if (!gateArray) break;
        Object data = hDataObject;
        if (!data.getClass().isArray()) break;
        for (i=0; i<size; i++)
        {
          if ((dev=devlst.getDevice(i)) == null) continue;
          if (gateOffline && dev.isOffline()) continue;
          if (gateArray && !dev.isMaskSet(gate)) continue;
          if (i > n) Array.set(data, n, Array.get(data, i));
          n++;
        }
        if (n < size) dout.setArrayLength(n);
        dout.putData(data);
View Full Code Here

Examples of de.desy.tine.server.devices.TDevice

      tgtProperty = TMetaProperties.getTargetProperty(ts.contract.eqmProperty);
      if (pl.hasProperty(ts.contract.eqmProperty))
        chkFullPropertyForRedirection = true;
    }
    // check if device is categorically redirected ...
    TDevice td = eqm.getDeviceList().getDevice(tgtDevice);
    if (td != null && (rdirStr=td.getRedirection()) != null)
    {
      byte[] rdb = redirectionStringToBytes(rdirStr);
      System.arraycopy(rdb,0,errorData,0,rdb.length);
      return TErrorList.server_redirection;     
    }
View Full Code Here

Examples of de.desy.tine.server.devices.TDevice

  }
  public void setFecLinkErrorAlarm(TLink lnk,int mode)
  {
    if (eqmTable == null || eqmTable[0] == null || lnk == null) return;
    TEquipmentModule eqm = eqmTable[0]; // take the first one
    TDevice d = eqm.getDeviceList().getDevice(0);
    if (d == null) return;
    short flags = TAlarmDescriptor.NEW;
    if (mode == TMode.CM_SINGLE) flags = TAlarmDescriptor.TRANSIENT;
    d.setAlarm(TAlarm.encodeLinkErrorAlarm(lnk.linkId), lnk.getFullDeviceNameAndProperty().getBytes(), flags);
  }
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.