📄 linkdump.java
字号:
/******************************************************************************* ** BonnMotion - a mobility scenario generation and analysis tool ** ** Copyright (C) 2002, 2003 University of Bonn ** ** ** ** This program is free software; you can redistribute it and/or modify ** ** it under the terms of the GNU General Public License as published by ** ** the Free Software Foundation; either version 2 of the License, or ** ** (at your option) any later version. ** ** ** ** This program is distributed in the hope that it will be useful, ** ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** ** GNU General Public License for more details. ** ** ** ** You should have received a copy of the GNU General Public License ** ** along with this program; if not, write to the Free Software ** ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ** *******************************************************************************/package edu.bonn.cs.iv.bonnmotion.apps;import java.io.*;import edu.bonn.cs.iv.bonnmotion.*;/** Application that dumps the link durations in a movement scenario to the standard output. */public class LinkDump extends App { protected String name = null; protected double radius = 0.0; protected double begin = 0.0; protected double end = Double.MAX_VALUE; protected boolean donly = false; protected boolean all = true; protected double duration = 0; protected MobileNode node[] = null; public LinkDump(String[] args) throws FileNotFoundException, IOException { go( args ); } public void go( String[] args ) throws FileNotFoundException, IOException { parse(args); if ((name == null) || (radius == 0.0)) { printHelp(); System.exit(0); } Scenario s = new Scenario(name); // get my args duration = s.getDuration(); node = s.getNode(); if (duration < end) end = duration; for (int j = 0; j < node.length; j++) { for (int k = j+1; k < node.length; k++) { double[] lsc = MobileNode.pairStatistics(node[j], node[k], 0.0, duration, radius, false); boolean first = true; for (int l = 1; l < lsc.length - 1; l += 2) { if ((all && (lsc[l] <= end) && (lsc[l + 1] >= begin)) || ((! all) && (lsc[l] > begin) && (lsc[l + 1] < end))) { if (all) { if (lsc[l] < begin) lsc[l] = begin; if (lsc[l + 1] > end) lsc[l] = end; } if (donly) { System.out.println(lsc[l + 1] - lsc[l]); } else { if (first) { System.out.print(j + " " + k); first = false; } System.out.print(" " + lsc[l] + "-" + lsc[l + 1]); } } } if (! first) System.out.println(""); } } } protected boolean parseArg(char key, String val) { switch (key) { case 'b': begin = Double.parseDouble(val); return true; case 'd': donly = true; return true; case 'e': end = Double.parseDouble(val); return true; case 'f': name = val; return true; case 'r': radius = Double.parseDouble(val); return true; case 'w': all = false; return true; default: return super.parseArg(key, val); } } public static void printHelp() { App.printHelp(); System.out.println("LinkDump:"); System.out.println("\t-b <begin of time span>"); System.out.println("\t-d [print link durations only]"); System.out.println("\t-b <end of time span>"); System.out.println("\t-f <scenario name>"); System.out.println("\t-r <transmission range>"); System.out.println("\t-w [print only links that go up and down after begin and before end of time span]"); } public static void main(String[] args) throws FileNotFoundException, IOException { new LinkDump(args); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -