Skip to content
Snippets Groups Projects
IModelaProperty.java 3.06 KiB
Newer Older
  • Learn to ignore specific revisions
  • Thomas Oster's avatar
    Thomas Oster committed
    /**
    
    Thomas Oster's avatar
    Thomas Oster committed
     * This file is part of LibLaserCut.
    
    Thomas Oster's avatar
    Thomas Oster committed
     * Copyright (C) 2011 - 2013 Thomas Oster <thomas.oster@rwth-aachen.de>
     * RWTH Aachen University - 52062 Aachen, Germany
     *
    
    Thomas Oster's avatar
    Thomas Oster committed
     *     LibLaserCut is free software: you can redistribute it and/or modify
    
    Thomas Oster's avatar
    Thomas Oster committed
     *     it under the terms of the GNU Lesser General Public License as published by
     *     the Free Software Foundation, either version 3 of the License, or
     *     (at your option) any later version.
     *
    
    Thomas Oster's avatar
    Thomas Oster committed
     *     LibLaserCut is distributed in the hope that it will be useful,
    
    Thomas Oster's avatar
    Thomas Oster committed
     *     but WITHOUT ANY WARRANTY; without even the implied warranty of
     *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     *     GNU Lesser General Public License for more details.
     *
     *     You should have received a copy of the GNU Lesser General Public License
    
    Thomas Oster's avatar
    Thomas Oster committed
     *     along with LibLaserCut.  If not, see <http://www.gnu.org/licenses/>.
    
    Thomas Oster's avatar
    Thomas Oster committed
     **/
    
    package com.t_oster.liblasercut.drivers;
    
    import com.t_oster.liblasercut.LaserProperty;
    
    /**
     *
     * @author Thomas Oster <thomas.oster@rwth-aachen.de>
     */
    public class IModelaProperty implements LaserProperty
    {
    
    
    Thomas Oster's avatar
    Thomas Oster committed
      private static String DEPTH = "milling depth";
      private static String FEED_RATE = "feed rate";
      private static String SPINDLE_SPEED = "spindle speed";
    
    Thomas Oster's avatar
    Thomas Oster committed
      private static String TOOL = "tool";
      
    
    Thomas Oster's avatar
    Thomas Oster committed
      private double depth = 0;
      private double feedRate = 1;
      private int spindleSpeed = 100;
    
    Thomas Oster's avatar
    Thomas Oster committed
      private int tool = 1;
    
    Thomas Oster's avatar
    Thomas Oster committed
    
      public double getDepth()
      {
        return depth;
      }
    
      public double getFeedRate()
      {
        return feedRate;
      }
    
      public int getSpindleSpeed()
      {
        return spindleSpeed;
      }
    
      public int getTool()
      {
        return tool;
      }
    
    Thomas Oster's avatar
    Thomas Oster committed
      
      @Override
      public Object getMinimumValue(String name)
      {
        if (TOOL.equals(name))
        {
          return (Integer) 1;
        }
    
    Thomas Oster's avatar
    Thomas Oster committed
        else if (SPINDLE_SPEED.equals(name))
        {
          return (Integer) 100;
        }
    
    Thomas Oster's avatar
    Thomas Oster committed
        else
        {
          return (Double) 0d;
        }
      }
    
      @Override
      public Object getMaximumValue(String name)
      {
        return null;
      }
    
      @Override
      public Object[] getPossibleValues(String name)
      {
        return null;
      }
    
      @Override
      public LaserProperty clone()
      {
        IModelaProperty result = new IModelaProperty();
    
    Thomas Oster's avatar
    Thomas Oster committed
        for (String k : getPropertyKeys())
        {
          result.setProperty(k, getProperty(k));
        }
    
    Thomas Oster's avatar
    Thomas Oster committed
        return result;
      }
    
      @Override
      public String[] getPropertyKeys()
      {
    
    Thomas Oster's avatar
    Thomas Oster committed
        return new String[]{DEPTH, SPINDLE_SPEED, FEED_RATE, TOOL};
    
    Thomas Oster's avatar
    Thomas Oster committed
      }
    
      @Override
      public void setProperty(String key, Object value)
      {
    
    Thomas Oster's avatar
    Thomas Oster committed
        if (DEPTH.equals(key))
        {
          depth = (Double) value;
        }
        else if (SPINDLE_SPEED.equals(key))
    
    Thomas Oster's avatar
    Thomas Oster committed
        {
    
    Thomas Oster's avatar
    Thomas Oster committed
          spindleSpeed = (Integer) value;
    
    Thomas Oster's avatar
    Thomas Oster committed
        }
        else if (FEED_RATE.equals(key))
        {
          feedRate = (Double) value;
        }
        else if (TOOL.equals(key))
        {
          tool = (Integer) value;
        }
      }
    
      @Override
      public Object getProperty(String key)
      {
    
    Thomas Oster's avatar
    Thomas Oster committed
        if (DEPTH.equals(key))
        {
          return depth;
        }
        else if (SPINDLE_SPEED.equals(key))
    
    Thomas Oster's avatar
    Thomas Oster committed
        {
          return spindleSpeed;
        }
        else if (FEED_RATE.equals(key))
        {
          return feedRate;
        }
        else if (TOOL.equals(key))
        {
          return tool;
        }
        return null;
      }
    
    }