2016年3月28日 星期一

java.util.prefs.WindowsPreferences WARNING: Could not open/create prefs root node Software\JavaSoft\Prefs at root 0x80000002. Windows RegCreateKeyEx(...) returned error code 5

Dennis answer is correct. However I would like to explain the solution in a bit more detailled way (for Windows User):
  1. Go into your Start Menu and type regedit into the search field.
  2. Navigate to path HKEY_LOCAL_MACHINE\Software\JavaSoft
  3. Right click on the JavaSoft folder and click on New -> Key
  4. Name the new Key Prefs and everything should work.

java.lang.outofmemoryerror java heap space eclipse


Solution :

 

1. Solution – VM arguments

On Eclipse menu, clicks Run -> Run Configurations.., select the Java application you want to run, clicks on theArguments tab, update the VM arguments with the following options
Bash
-Xms<size> - Set initial Java heap size
-Xmx<size> - Set maximum Java heap size
For example, -Xms512M -Xmx1024M
eclipse-out-of-memory

2. Mistake – eclipse.ini

The memory settings in eclipse.ini is allocated to Eclipse IDE only, not the program you want to run. A very common mistake is updated the heap size in eclipse.ini, and expects it to solve above out of memory problem.
Note
The Java application, Ant / Maven build scripts, or unit test cases, are run as an external tool from Eclipse, and it does not inherit the VM settings in eclipse.ini.
But, if your Eclipse IDE is always crashed by no reason, you can try to increase the heap size and perm gen ineclipse.ini.
/Users/mkyong/Downloads/eclipse/Eclipse.app/Contents/MacOS/eclipse.ini
Bash
 
 -startu
 openFile
 -showsplash
        //...
 -XX:MaxPermSize=512m
 -Xms512m
 -Xmx1024m
        //...
 -Xdock:icon=../Resources/Eclipse.icns
 -XstartOnFirstThread
P.S eclipse.ini is located in the Eclipse installation folder.

Ref : http://www.mkyong.com/eclipse/eclipse-java-lang-outofmemoryerror-java-heap-space/

2016年3月27日 星期日

2016年3月24日 星期四

sla 3d printer 研究筆記 : printObject


 private void printObject() throws Exception {
        System.out.println("Printing Object layers");

        CommandBase cmd;
        SVGElement element;

        // Object layers
        // loop layers
        int total = Consts.sFLAG_DEBUG_MODE ? Math.min(6, root.getNumChildren()) : root.getNumChildren();
        int layerSteps = printingInfo.getStepsPerLayer();
        int layerExpoTime = printingInfo.getLayerExpoTimeInMillis();

        int upSteps = printingInfo.getUpLiftSteps();
        int downSteps = upSteps - layerSteps;
        System.out.println(String.format("Object layers upSteps: %d, layerSteps: %d, downSteps: %d",
                upSteps, layerSteps, downSteps));

        for (int i = 1; i < total; i++) {
            layerIndex = i;

            // Go up
           
            cmd = PrinterScriptFactory.generatePlatformMovement(PlatformMovement.UP, upSteps);
            processCommand(cmd);

            // Wait a little bit
            cmd = PrinterScriptFactory.generatePauseCommand(delayAfterAction);
            processCommand(cmd);

            // Go down
            cmd = PrinterScriptFactory.generatePlatformMovement(PlatformMovement.DOWN, downSteps);
            processCommand(cmd);
           
            // Exposure layer
            element = children.get(i);
            publish(element);
           
           
            for (int restExpoTime = layerExpoTime; restExpoTime > 0; restExpoTime -= Consts.MAX_EXPOSURE_MILLIS) {
                int expoTime = restExpoTime >= Consts.MAX_EXPOSURE_MILLIS ? Consts.MAX_EXPOSURE_MILLIS : restExpoTime;
                cmd = PrinterScriptFactory.generatePauseCommand(expoTime);
                processCommand(cmd, expoTime);
            }
           

            publish(layerCircle);
            cmd = PrinterScriptFactory.generatePauseCommand(delayAfterAction);
            processCommand(cmd);
        }
    }

sla 3d printer 研究筆記 : printBaseLayer



1. printBaseLayer()

         int layerSteps = printingInfo.getStepsPerLayer();  //  預設值為   1
        int upSteps = printingInfo.getUpLiftSteps();           //  預設值為 4000
        int downSteps = upSteps - layerSteps;                     //   3999
        printingInfo.getBaseLayerNumber()

   public int getStepsPerLayer() {
        return layerHeightInUms;  // Future need to load device info for steps per um
    }
 
    public int getUpLiftSteps() {
        return upLiftSteps;
    }

PrintingInfo(int upLiftSteps, int baseLayerNumber, int baseExpoTimeInMillis,
                        int layerExpoTimeInMillis, int layerHeightInUms){
        setUpLiftSteps(upLiftSteps);
        setBaseLayerNumber(baseLayerNumber);
        setBaseExpoTime(baseExpoTimeInMillis);
        setLayerExpoTime(layerExpoTimeInMillis);
        setLayerHeight(layerHeightInUms);

}

            PrintingInfo info = new PrintingInfo(
                Integer.parseInt(mInputUpLiftSteps.getText()),
                Integer.parseInt(mInputBaseLayerNumber.getText()),
                Integer.parseInt(mInputBaseExpo.getText()),
                Integer.parseInt(mInputLayerExpo.getText()),
                Integer.parseInt(mInputLayerUm.getText())



  mInputLayerUm = new JTextField("1");    ->  預設值
        mInputLayerUm.setFont(Consts.APP_FONT);
        mInputLayerUm.setColumns(10);
        mInputLayerUm.setBounds(151, 23, 80, 30);
        stepMotorPane.add(mInputLayerUm);

   mInputUpLiftSteps = new JTextField(Integer.toString(Consts.PULL_UP_STEPS));
        mInputUpLiftSteps.setFont(Consts.APP_FONT);
        mInputUpLiftSteps.setColumns(10);
        mInputUpLiftSteps.setBounds(126, 105, 80, 30);
        stepMotorPane.add(mInputUpLiftSteps);

   mInputBaseLayerNumber = new JTextField("1");
        mInputBaseLayerNumber.setFont(Consts.APP_FONT);
        mInputBaseLayerNumber.setBounds(178, 59, 80, 30);
        mInputBaseLayerNumber.getDocument().addDocumentListener(new DocumentListener()

     mInputBaseExpo = new JTextField("30000");
        mInputBaseExpo.setFont(Consts.APP_FONT);
        mInputBaseExpo.setBounds(178, 101, 80, 30);
        mInputBaseExpo.getDocument().addDocumentListener(new DocumentListener() {


    public static final int PULL_UP_STEPS = 4000;

     所以 layerSteps   預設值為1
               upSteps      預設值為4000

  layerStep -  >  Layer Height
  upStep     ->    Up lift steps
  printingInfo.getBaseLayerNumber() ->   Base Layer Number






  SVGElement element = children.get(0);
        for (int i = 0; i < printingInfo.getBaseLayerNumber(); i++) {
       
            System.out.println("Printing base layer #" + (i + 1));
            if (i == 0) {
                // Get ready to exposure for base layer
                commandsList = PrinterScriptFactory.generateCommandForExpoBase();
                                    //  從  home down bottom ,  default 120000 step...
                for (int j = 0; j < commandsList.size(); j++) {
                    cmd = commandsList.get(i);
                    processCommand(cmd);
                }
                commandsList.clear();

                // Wait a little bit
                cmd = PrinterScriptFactory.generatePauseCommand(delayAfterAction);
                processCommand(cmd);
            } else {
                // uplift platform
                cmd = PrinterScriptFactory.generatePlatformMovement(PlatformMovement.UP, upSteps);
                processCommand(cmd);

                // Wait a little bit
                cmd = PrinterScriptFactory.generatePauseCommand(delayAfterAction);
                processCommand(cmd);

                // down platform
                cmd = PrinterScriptFactory.generatePlatformMovement(PlatformMovement.DOWN, downSteps);
                processCommand(cmd);

                // Wait a little bit
                cmd = PrinterScriptFactory.generatePauseCommand(delayAfterAction);
                processCommand(cmd);
            }

            // exposure base layer
            publish(element);

            for (int baseLayerExpoTime = printingInfo.getBaseExpoTimeInMillis();
                 baseLayerExpoTime > 0;
                 baseLayerExpoTime -= Consts.MAX_EXPOSURE_MILLIS) {

                int expoTime = baseLayerExpoTime >= Consts.MAX_EXPOSURE_MILLIS ? Consts.MAX_EXPOSURE_MILLIS : baseLayerExpoTime;
                cmd = PrinterScriptFactory.generatePauseCommand(expoTime);
                processCommand(cmd, expoTime);
            }

            publish(layerCircle);
            cmd = PrinterScriptFactory.generatePauseCommand(delayAfterAction);
            processCommand(cmd);
        }

============================================================

 public static List<CommandBase> generateCommandForExpoBase() {
        int stepsLeft = Consts.sFLAG_DEBUG_MODE ? 2400 : PrefUtils.getBaseLayerStepsFromTop();
        List<CommandBase> commandsList = generateCommandsForMovement(null, PlatformMovement.DOWN, stepsLeft);
        return commandsList;
    }

  public static int getBaseLayerStepsFromTop() {
        return getInstance().getInt(PREF_BASELAYER_STEPS_FROM_TOP, PREF_BASELAYER_STEPS_FROM_TOP_DEFAULT);
    }

private static final String PREF_BASELAYER_STEPS_FROM_TOP = "pref_baselayer_steps_from_top";
    private static final int PREF_BASELAYER_STEPS_FROM_TOP_DEFAULT = 120000;