public void printModel(Model pm,String sdfilename, boolean autostart, int line) throws InterruptedException {
		if (state.connecting) {
			cons.appendText("Still connecting. Please wait until connecting is established.");
			return;
		}
		if (!state.connected) {
			cons.appendText("Not connected");
			return;
		}
		startline=0; //reset startline (resume)
		
		if(sdfilename == null){
			//Direct printing
			cons.appendText("Add model to print queue");
			printQueue.addModel(pm);	
			startline=line;
			if (state.debug)
				cons.appendText("Filling print queue, Printing:" + state.printing);
		}else if (pm != null ){
			//Stream to SD Card
			printQueue.putAuto(GCodeFactory.getGCode("M21", -21));
			printQueue.putAuto(GCodeFactory.getGCode("M28 "+sdfilename, -28));
			state.streaming=true;
			GCode finishstream = GCodeFactory.getGCode("M29 "+sdfilename, -29);
			if(autostart){
				GCode selectfile = GCodeFactory.getGCode("M23 "+sdfilename, -23);
				GCode printfile =  GCodeFactory.getGCode("M24", -24);
				printQueue.addModel(pm,finishstream,selectfile,printfile);
				state.sdprint=true;
			}else{
				printQueue.addModel(pm,finishstream);
			}
			if (state.debug)
				cons.appendText("Filling queue to stream, streaming:" + state.printing);
		}else{
			//Print from SD Card
			printQueue.putAuto(GCodeFactory.getGCode("M23 "+sdfilename, -23));
			printQueue.putAuto(GCodeFactory.getGCode("M24", -24));
			state.sdprint=true;
			if (state.debug)
				cons.appendText("SD print, Printing:" + state.printing);
           }
				
		setPrintMode(true,false);
		
	}