private JButton findMarket = null;
private JLabel resultSummary = null;
private JLabel arbitrageResult = null;
+ private long startTime = 0;
private final static String PCTB_LIVE_HOST_URL = "http://pctb.crabdance.com/";
private final static String PCTB_TEST_HOST_URL = "http://pctb.ilk.org/";
}
}
+ private void progresslog(String s) {
+ long now = new Date().getTime();
+ System.out.println("progress "+(now - startTime)+"ms "+s);
+ }
+
private void progressNote(ProgressMonitor pm, String s) {
String arb = null;
if (arbitrageResult != null)
findMarket.setEnabled(false);
new Thread() {
public void run() {
+ startTime = new Date().getTime();
resultSummary.setText("");
arbitrageResult.setText("");
try {
* @exception Exception if an error we didn't expect occured
*/
private void runPCTB() throws Exception {
+ progresslog("starting");
+
String yarrgts = "";
ProgressMonitor pm = new ProgressMonitor(frame,"Processing Market Data","Getting table data",0,100);
pm.setMillisToDecideToPopup(0);
boolean doneyarrg = false, donepctb = false;
if (uploadToYarrg) {
+ progresslog("yarrg timestamp...");
yarrgts = getYarrgTimestamp();
+ progresslog("yarrg timestamp done.");
}
AccessibleTable accesstable = findMarketTable();
return;
}
+ progresslog("getisland...");
getIsland();
+ progresslog("getocean...");
getOcean();
+ progresslog("getocean done");
if (latch != null) {
latch.await(2, java.util.concurrent.TimeUnit.SECONDS);
}
+ progresslog("table check...");
+
String headings_expected[] = new String[]
{ "Commodity", "Trading outlet", "Buy price", "Will buy", "Sell price", "Will sell" };
ArrayList<ArrayList<String>> headers = getData(accesstable.getAccessibleColumnHeader());
}
}
+ progresslog("table read...");
+
ArrayList<ArrayList<String>> data = getData(accesstable);
if (showArbitrage) {
+ progresslog("arbitrage...");
calculateArbitrage(data);
+ progresslog("arbitrage done.");
}
if (uploadToYarrg && yarrgts != null) {
+ progresslog("yarrg prepare...");
progressNote(pm, "Yarrg: Preparing data");
pm.setProgress(10);
yarrgdata = yarrgsb.toString();
progressNote(pm, "Yarrg: Uploading");
+ progresslog("yarrg upload...");
if (islandName != null) {
doneyarrg = runYarrg(yarrgts, oceanName, islandName, yarrgdata);
} else {
System.out.println("Couldn't upload to Yarrg - no island name found");
}
+ progresslog("yarrg done.");
}
if (uploadToPCTB) {
+ progresslog("pctb prepare...");
progressNote(pm, "PCTB: Getting stall names");
pm.setProgress(20);
if(pm.isCanceled()) {
dos.writeBytes(getAbbrevStallList(stallMap));
writeBuySellOffers(buys,sells,offerCount,out);
out.finish();
+ progresslog("pctb send...");
InputStream in = sendInitialData(new ByteArrayInputStream(outStream.toByteArray()));
+ progresslog("pctb sent.");
if (in == null) return;
pm.setProgress(80);
if(pm.isCanceled()) {
return;
}
progressNote(pm, "PCTB: Waiting ...");
+ progresslog("pctb finish...");
donepctb = finishUpload(in);
+ progresslog("pctb done.");
}
pm.setProgress(100);
} else {
resultSummary.setText("uploaded nowhere!");
}
+ progresslog("done.");
}
/**