Package de.desy.tine.server.devices

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


    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

      int ndevs = dlst.getNumberOfDevices();
      if (ndevs == 0) return TErrorList.device_not_connected;
      if (deviceNumber < 0 && deviceNumber >= ndevs) return TErrorList.illegal_equipment_number;
      if (!isPrpOriented)
      {
        TDevice tdv = dlst.getDevice(deviceNumber);
        if (tdv == null) return TErrorList.device_not_connected;
        String oldName = tdv.getName();
        if (deviceName.compareTo(oldName) != 0)
        {
          dlst.renameDevice(oldName,deviceName);
        }
        if (deviceRedirection != null && deviceRedirection.length() > 0)
        {
          tdv.setRedirection(deviceRedirection);
          deviceRedirection = null; // reset this !
        }
        if (deviceDescription != null && deviceDescription.length() > 0)
        {
          tdv.setDescription(deviceDescription);
          deviceDescription = null; // reset this !
        }
        if (prpListFile != null && prpListFile.length() > 0)
        {
          getRegisteredPropertyListFromFile(tdv,prpListFile);
          propertyList.setDeviceOriented(true);
          prpListFile = null; // reset this !
        }
        if (deviceLocation != null && deviceLocation.length() > 0)
        {
          tdv.setLocation(deviceLocation);
        }
        if (deviceMask != 0) tdv.setMask(deviceMask);
        if (deviceOffline != 0) tdv.setOffline(true);
        if (deviceZPosition != 0) tdv.setZposition(deviceZPosition);
      }
      else
      {
        if (prp != null)
        {
View Full Code Here

  {
    if (numberOfDevices <= 0) return;
    TDevice[] devices = new TDevice[numberOfDevices];
    for (int i=0; i<numberOfDevices; i++)
    {
      devices[i] = new TDevice(i);
      devices[i].setEqm(this);
      deviceList.addDevice(devices[i]);
    }
  }
View Full Code Here

                catch (Exception ignore) {}; // then mask stays = 0
              }
            }
            if (chkOn || chkMask)
            {
              TDevice dev;
              LinkedList<String> dl = new LinkedList<String>();
              for (int i=0; i<deviceList.getNumberOfDevices(); i++)
              {
                if ((dev=deviceList.getDevice(i)) == null) continue;
                if (chkOn && dev.isOffline()) continue;
                if (chkMask && !dev.isMaskSet(mask)) continue;
                dl.add(dev.getName());
              }
              slst = dl.toArray(new String[0]);
            }
          }
          return (short)dout.putData(StringToName.stringArrayToName64(slst));
View Full Code Here

          int ndevs = dlst.getNumberOfDevices();
          if (ndevs == 0) return TErrorList.device_not_connected;
          LinkedList<DeviceCfg> dl = ec.getDeviceList();
          for (DeviceCfg dc : dl)
          {
            TDevice tdv = dlst.getDevice(dc.getNumber().getValue());
            if (tdv == null) return TErrorList.device_not_connected;
            prpSet = dc.getPropertySet();
            if (prpSet != null && prpSet.length() > 0)
            { // is there a device-specific property list ?
              for (NameCfgList nc : nl)
              { // yes ! find it
                if (nc.getName().compareToIgnoreCase(prpSet) == 0)
                { // assign the names list
                  tdv.setPropertyList(nc.getMembers());
                }
              }
              propertyList.setDeviceOriented(true);
            }
            String oldName = tdv.getName();
            if (dc.getName().compareTo(oldName) != 0)
            {
              dlst.renameDevice(oldName,dc.getName());
            }
            deviceRedirection = dc.getRedirection();
            if (deviceRedirection != null && deviceRedirection.length() > 0)
            {
              tdv.setRedirection(deviceRedirection);
              deviceRedirection = null; // reset this !
            }
            deviceDescription = dc.getDescription();
            if (deviceDescription != null && deviceDescription.length() > 0)
            {
              tdv.setDescription(deviceDescription);
              deviceDescription = null; // reset this !
            }
          }
          break;
        }
View Full Code Here

TOP

Related Classes of de.desy.tine.server.devices.TDevice

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.