示例#1
0
  public void redrawGraphs() {
    long currentTime = System.currentTimeMillis();

    trimData(currentTime, 60);
    // double maxY=1;

    ArrayList<DataPoint> IcmpDataPts = new ArrayList<DataPoint>();
    for (int i = IcmpInformationArray.size() - 1; i >= 0; i--) {
      PingInfo currentInfo = IcmpInformationArray.get(i);
      if (currentInfo != null) {
        if (currentInfo.isSuccess()) {
          IcmpDataPts.add(
              new DataPoint(
                  currentInfo.timeDifferenceSeconds(currentTime), currentInfo.getPingTimeSec()));
          // if (currentInfo.getPingTimeSec()>maxY) maxY=currentInfo.getPingTimeSec();
        }
      }
    }
    icmpLineSeries.resetData(IcmpDataPts.toArray(new DataPoint[0]));

    ArrayList<DataPoint> HttpDataPts = new ArrayList<DataPoint>();
    for (int i = HttpInformationArray.size() - 1; i >= 0; i--) {
      PingInfo currentInfo = HttpInformationArray.get(i);
      if (currentInfo != null) {
        if (currentInfo.isSuccess()) {
          HttpDataPts.add(
              new DataPoint(
                  currentInfo.timeDifferenceSeconds(currentTime), currentInfo.getPingTimeSec()));
          // if (currentInfo.getPingTimeSec()>maxY) maxY=currentInfo.getPingTimeSec();
        }
      }
    }
    httpLineSeries.resetData(HttpDataPts.toArray(new DataPoint[0]));

    ArrayList<DataPoint> HttpsDataPts = new ArrayList<DataPoint>();
    for (int i = HttpsInformationArray.size() - 1; i >= 0; i--) {
      PingInfo currentInfo = HttpsInformationArray.get(i);
      if (currentInfo != null) {
        if (currentInfo.isSuccess()) {
          HttpsDataPts.add(
              new DataPoint(
                  currentInfo.timeDifferenceSeconds(currentTime), currentInfo.getPingTimeSec()));
          // if (currentInfo.getPingTimeSec()>maxY) maxY=currentInfo.getPingTimeSec();
        }
      }
    }
    httpsLineSeries.resetData(HttpsDataPts.toArray(new DataPoint[0]));

    // gv.getViewport().setMaxY(maxY);

  }
示例#2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    Log.i(LOG_TAG, "---New Session---");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    icmpPingSettings = new PingSettings();
    icmpPingSettings.setTimeout(1000);
    icmpPingSettings.setRepeat(3000);
    icmpPingSettings.setDomain("www.google.com");
    icmpPingSettings.setSlow(300);

    httpPingSettings = new PingSettings();
    httpPingSettings.setTimeout(1500);
    httpPingSettings.setRepeat(3000);
    httpPingSettings.setDomain("www.google.com");
    httpPingSettings.setSlow(500);

    httpsPingSettings = new PingSettings();
    httpsPingSettings.setTimeout(2000);
    httpsPingSettings.setRepeat(3000);
    httpsPingSettings.setDomain("www.google.com");
    httpsPingSettings.setSlow(1000);

    pingReceiver = new PingReceiver();

    gv = (GraphView) findViewById(R.id.graph_view);

    gv.setTitle("Ping Times");
    gv.getGridLabelRenderer().setHighlightZeroLines(true);
    gv.getGridLabelRenderer().setPadding(36);

    icmpLineSeries = new PointsGraphSeries<DataPoint>();
    icmpLineSeries.setColor(Color.parseColor("#A00000"));
    icmpLineSeries.setSize(10);
    icmpLineSeries.setTitle("ICMP");
    gv.addSeries(icmpLineSeries);

    httpLineSeries = new PointsGraphSeries<DataPoint>();
    httpLineSeries.setColor(Color.parseColor("#00A000"));
    httpLineSeries.setSize(10);
    httpLineSeries.setTitle("HTTP");
    gv.addSeries(httpLineSeries);

    httpsLineSeries = new PointsGraphSeries<DataPoint>();
    httpsLineSeries.setColor(Color.parseColor("#0000A0"));
    httpsLineSeries.setSize(10);
    httpsLineSeries.setTitle("HTTPS");
    gv.addSeries(httpsLineSeries);

    gv.getLegendRenderer().setVisible(true);
    gv.getLegendRenderer().setAlign(LegendRenderer.LegendAlign.MIDDLE);

    gv.getViewport().setXAxisBoundsManual(true);
    gv.getViewport().setMinX(0);
    gv.getViewport().setMaxX(60);

    // gv.getViewport().setYAxisBoundsManual(true);
    // gv.getViewport().setMinY(0);
    // gv.getViewport().setMaxY(1);

    alertToggle = (CheckBox) findViewById(R.id.alert_toggle);
    alertThresh = (EditText) findViewById(R.id.alert_input);
    alertToggle.setOnClickListener(this);

    icmp_set_btn = (Button) findViewById(R.id.icmp_settings);
    icmp_start_btn = (Button) findViewById(R.id.icmp_start);
    icmp_end_btn = (Button) findViewById(R.id.icmp_end);
    icmp_information = (TextView) findViewById(R.id.icmp_information);
    icmp_result = (TextView) findViewById(R.id.icmp_result);
    icmp_icon = (ImageView) findViewById(R.id.icmp_icon);

    icmp_start_btn.setOnClickListener(this);
    icmp_end_btn.setOnClickListener(this);
    icmp_set_btn.setOnClickListener(this);

    http_set_btn = (Button) findViewById(R.id.http_settings);
    http_start_btn = (Button) findViewById(R.id.http_start);
    http_end_btn = (Button) findViewById(R.id.http_end);
    http_information = (TextView) findViewById(R.id.http_information);
    http_result = (TextView) findViewById(R.id.http_result);
    http_icon = (ImageView) findViewById(R.id.http_icon);

    http_set_btn.setOnClickListener(this);
    http_start_btn.setOnClickListener(this);
    http_end_btn.setOnClickListener(this);

    https_set_btn = (Button) findViewById(R.id.https_settings);
    https_start_btn = (Button) findViewById(R.id.https_start);
    https_end_btn = (Button) findViewById(R.id.https_end);
    https_information = (TextView) findViewById(R.id.https_information);
    https_result = (TextView) findViewById(R.id.https_result);
    https_icon = (ImageView) findViewById(R.id.https_icon);

    https_set_btn.setOnClickListener(this);
    https_start_btn.setOnClickListener(this);
    https_end_btn.setOnClickListener(this);

    endHTTP();
    endHTTPS();
    endICMP();

    updateInformation();
  }