public void readFromCore(CMMCore core, String deviceName, String propertyName, boolean cached) {
    device = deviceName;
    name = propertyName;
    try {
      readOnly = core.isPropertyReadOnly(deviceName, propertyName);
      preInit = core.isPropertyPreInit(deviceName, propertyName);
      hasRange = core.hasPropertyLimits(deviceName, propertyName);
      lowerLimit = core.getPropertyLowerLimit(deviceName, propertyName);
      upperLimit = core.getPropertyUpperLimit(deviceName, propertyName);
      type = core.getPropertyType(deviceName, propertyName);
      StrVector values = core.getAllowedPropertyValues(deviceName, propertyName);
      allowed = new String[(int) values.size()];
      for (int k = 0; k < values.size(); k++) {
        allowed[k] = values.get(k);
      }

      sort();

      String coreVal;
      if (cached) coreVal = core.getPropertyFromCache(deviceName, propertyName);
      else coreVal = core.getProperty(deviceName, propertyName);
      setValueFromCoreString(coreVal);
    } catch (Exception e) {
      ReportingUtils.logError(e);
    }
  }
Beispiel #2
0
  public PropertyItem[] getProperties() {
    StrVector propNamesVect;
    Vector<PropertyItem> props = new Vector<PropertyItem>();
    try {
      core_.setAutoFocusDevice(devName_);
      propNamesVect = core_.getDevicePropertyNames(devName_);
      for (int i = 0; i < propNamesVect.size(); i++) {
        PropertyItem p = new PropertyItem();
        p.device = devName_;
        p.name = propNamesVect.get(i);
        p.value = core_.getProperty(devName_, p.name);
        p.readOnly = core_.isPropertyReadOnly(devName_, p.name);
        if (core_.hasPropertyLimits(devName_, p.name)) {
          p.lowerLimit = core_.getPropertyLowerLimit(devName_, p.name);
          p.upperLimit = core_.getPropertyUpperLimit(devName_, p.name);
        }

        StrVector vals = core_.getAllowedPropertyValues(devName_, p.name);
        p.allowed = new String[(int) vals.size()];
        for (int j = 0; j < vals.size(); j++) p.allowed[j] = vals.get(j);

        props.add(p);
      }
    } catch (Exception e) {
      ReportingUtils.logError(e);
    }

    return props.toArray(new PropertyItem[0]);
  }
Beispiel #3
0
 public String[] getPropertyNames() {
   Vector<String> propNames = new Vector<String>();
   try {
     core_.setAutoFocusDevice(devName_);
     StrVector propNamesVect = core_.getDevicePropertyNames(devName_);
     for (int i = 0; i < propNamesVect.size(); i++)
       if (!core_.isPropertyReadOnly(devName_, propNamesVect.get(i))
           && !core_.isPropertyPreInit(devName_, propNamesVect.get(i)))
         propNames.add(propNamesVect.get(i));
   } catch (Exception e) {
     ReportingUtils.logError(e);
   }
   return (String[]) propNames.toArray();
 }
Beispiel #4
0
  public PropertyItem getProperty(String name) throws MMException {
    try {
      if (core_.hasProperty(devName_, name)) {
        PropertyItem p = new PropertyItem();
        p.device = devName_;
        p.name = name;
        p.value = core_.getProperty(devName_, p.name);
        p.readOnly = core_.isPropertyReadOnly(devName_, p.name);
        if (core_.hasPropertyLimits(devName_, p.name)) {
          p.lowerLimit = core_.getPropertyLowerLimit(devName_, p.name);
          p.upperLimit = core_.getPropertyUpperLimit(devName_, p.name);
        }

        StrVector vals = core_.getAllowedPropertyValues(devName_, p.name);
        p.allowed = new String[(int) vals.size()];
        for (int j = 0; j < vals.size(); j++) p.allowed[j] = vals.get(j);
        return p;
      } else {
        throw new MMException("Unknown property: " + name);
      }
    } catch (Exception e) {
      throw new MMException(e.getMessage());
    }
  }