?? controllib.java~
字號:
/*
* ControlLib.java
*
* Created on May 30, 2002, 3:30 PM
*/
package jaga.pj.circuits.control;
import jaga.evolve.Population;
import jaga.pj.gral.PopulationLogReader;
import java.io.File;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Vector;
import java.util.Enumeration;
/**
*
* @author Michael Garvie
* @version
*/
public abstract class ControlLib extends Object {
public static final int GRAPH_SLEEP_MIN = 15;
public static final String FS = File.separator;
//public static final String gnuPlotLoc = "\"C:\\Program Files\\GNUPlot\\wgnupl32.exe\";
public static final String gnuPlotLoc = "/usr/local/bin/";
public static void writeGNUPlotScript( String dir, String logDir, String logFileName )
{
writeGNUPlotScript( dir, logDir, logFileName, 0 );
}
public static void writeGNUPlotScript( String dir, String logDir, String logFileName, int props )
{
writeGNUPlotScript( dir, logDir, logFileName, props, true );
}
public static void writeGNUPlotScript( String dir, String logDir, String logFileName, int props, boolean avg )
{
try{
String thisDirName = logDir + dir + FS;
new File( thisDirName ).mkdir();
BufferedWriter bw = new BufferedWriter( new FileWriter( thisDirName + "GNUPlotIt.plt" ) );
bw.write( getGNUPlotScript( thisDirName + logFileName, props, avg ) );
bw.write( "\npause -1\n" );
bw.flush();
bw.close();
bw = new BufferedWriter( new FileWriter( thisDirName + "GNUPlotIt.bat" ) );
bw.write( "\"C:\\Program Files\\GNUPlot\\wgnupl32.exe\" GNUPlotIt.plt" );
bw.flush();
bw.close();
bw = new BufferedWriter( new FileWriter( thisDirName + "plotit" ) );
bw.write( "gnuplot GNUPlotIt.plt" );
bw.flush();
bw.close();
}catch( IOException e )
{
System.out.println( e );
}
}
public static void writeWebGraphDaemon( String dir, String logDir, String logFileName, int props, boolean avg, String serverDir )
{
writeWebGraphDaemon( dir, logDir, logFileName, props, avg, serverDir, GRAPH_SLEEP_MIN );
}
public static void writeWebGraphDaemon( String dir, String logDir, String logFileName, int props, boolean avg, String serverDir, int graphSleepMin )
{
try{
String thisDirName = logDir + dir + FS;
new File( thisDirName ).mkdir();
BufferedWriter bw = new BufferedWriter( new FileWriter( thisDirName + "WebGraph.plt" ) );
bw.write( "set terminal png color\n" );
bw.write( "set output '" + serverDir + "WebGraph.png'\n" );
bw.write( getGNUPlotScript( thisDirName + logFileName, props, avg ) );
bw.flush();
bw.close();
bw = new BufferedWriter( new FileWriter( thisDirName + "webGraphDaemon" ) );
bw.write( "while [ t = t ]\ndo\n" );
bw.write( "gnuplot WebGraph.plt\n" );
bw.write( "convert " + serverDir + "WebGraph.png " + serverDir + "WebGraph.gif\n" );
bw.write( "cp " + serverDir + "WebGraph.gif " + serverDir + "WebGraph.class\n" );
bw.write( "sleep " + graphSleepMin + "m\n" );
bw.write( "done" );
bw.flush();
bw.close();
}catch( IOException e )
{
System.out.println( e );
}
}
protected static String getGNUPlotScript( String fileName, int props, boolean avg )
{
String rv = "set yrange [0:1]\nset nokey\n";
rv += "plot" + script4Client( fileName, props, avg );
return rv;
}
protected static String script4Client( String fileName, int props, boolean avg )
{
int colIndex = 2;
String rv = "'" + fileName + "' using 0:" + colIndex++ + " 'P0:G=%lf,T=%lf*100[^\\n]'";
String insert = "'P0:G=%lf,T=%lf";
for( int pl = 0; pl < props; pl++ )
{
insert += ",TP" + pl + "=%lf";
rv += ", '" + fileName + "' using 0:" + colIndex++ + insert + "%*40[^\\n]'";
}
if( avg )
{
rv += ", '" + fileName + "' using 0:" + colIndex++ + insert + ",A=%lf%*40[^\\n]'";
}
return rv;
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -