Example usage for org.jfree.data.time Millisecond Millisecond

List of usage examples for org.jfree.data.time Millisecond Millisecond

Introduction

In this page you can find the example usage for org.jfree.data.time Millisecond Millisecond.

Prototype

public Millisecond() 

Source Link

Document

Constructs a millisecond based on the current system time.

Usage

From source file:windows.sensorWindow.java

/**
 * add a value to the second field of a sensor (used for sensors with 2
 * measurements)//from   w ww .  j a v a  2  s .com
 * 
 * @param sensorUID
 * @param value
 */
public void add2ndValue(String sensorUID, double value) {
    // TODO: make this method more elegant by evolving
    // plotStateMap.get-things

    if (seriesCollectionMap2.containsKey(sensorUID))
        seriesCollectionMap2.get(sensorUID).getSeries(0).addOrUpdate(new Millisecond(), value);

    // add measurement value
    if (values2Map.containsKey(sensorUID))
        values2Map.get(sensorUID).addValue(value);

    // check whether the value is below the thresholds
    if (markerMapMin2Critical.containsKey(sensorUID)) {
        // critical
        if ((value < markerMapMin2Critical.get(sensorUID).getValue())
                || (value > markerMapMax2Critical.get(sensorUID).getValue())) {
            plot2StateMap.put(sensorUID, 3);
        }

        // warning
        else if ((value < markerMapMin2Warning.get(sensorUID).getValue())
                || (value > markerMapMax2Warning.get(sensorUID).getValue())) {
            plot2StateMap.put(sensorUID, 2);
        }

        // normal level
        else {
            plot2StateMap.put(sensorUID, 1);
        }
    }

    // color the plot's background according to it's current state,
    // but only if the state of the 2nd plot is below the state of the
    // current plot
    // a higher state means higher warning level and therefore a higher
    // priority
    if (plot1StateMap.get(sensorUID) <= plot2StateMap.get(sensorUID)) {
        switch (plot2StateMap.get(sensorUID)) {
        case 1:
            plotMap.get(sensorUID).setBackgroundPaint(Color.white);
            break;
        case 2:
            plotMap.get(sensorUID).setBackgroundPaint(Color.yellow);
            break;
        case 3:
            plotMap.get(sensorUID).setBackgroundPaint(Color.red);
            break;
        }
    }

    /*
     * // check whether the value is below the threshold if
     * (markerMapMin2Critical.containsKey(sensorUID)) { if ( (value >
     * markerMapMin2Critical.get(sensorUID).getValue()) && (value <=
     * (markerMapMin2Warning.get(sensorUID).getValue())) ) { //under warning
     * level plot1StateMap.put(sensorUID,2);
     * plotMap.get(sensorUID).setBackgroundPaint(Color.yellow); } else if
     * (value <= markerMapMin2Critical.get(sensorUID).getValue()) { //under
     * threshold level plot1StateMap.put(sensorUID,3);
     * plotMap.get(sensorUID).setBackgroundPaint(Color.pink); } else {
     * //normal level
     * //plotMap.get(sensorUID).setBackgroundPaint(Color.white);
     * 
     * // check whether the value is above the threshold if
     * (markerMapMax2Critical.containsKey(sensorUID)) { if ( (value <
     * markerMapMax2Critical.get(sensorUID).getValue()) && (value >=
     * (markerMapMax2Warning.get(sensorUID).getValue())) ) { //between the
     * warning and critical plot1StateMap.put(sensorUID,2);
     * plotMap.get(sensorUID).setBackgroundPaint(Color.yellow); } else if
     * (value >= markerMapMax2Critical.get(sensorUID).getValue()) { //above
     * the max threshold level plot1StateMap.put(sensorUID,3);
     * plotMap.get(sensorUID).setBackgroundPaint(Color.pink); } else {
     * //normal level if (plot1StateMap.get(sensorUID) != 1) {
     * plot1StateMap.put(sensorUID,0);
     * plotMap.get(sensorUID).setBackgroundPaint(Color.white); } } }
     * 
     * } }
     */
}

From source file:windows.sensorWindow.java

/**
 * function for auto updating the plot,//  w ww  . ja  v  a  2  s  .c  om
 */
public void autoUpdatePlot() {
    new Thread(new Runnable() {
        public void run() {
            System.out.println("THREAD STARTED");
            int cnt = 0;
            // TODO: stop functionality
            while (true) {
                try {
                    Thread.sleep(100);
                } catch (Exception e) {
                }
                cnt++;
                Millisecond ms = new Millisecond();
                for (int i = 0; i < connectionData.presentedBrickList.size(); i++) {
                    Brick tmpBrick = connectionData.presentedBrickList.get(i);
                    for (int i2 = 0; i2 < tmpBrick.ctrlTmplruns.length; i2++) {
                        if (tmpBrick.ctrlTmplruns[i2] == true) {
                            addTmplValue(tmpBrick.uid, ms);
                        }
                    }
                }
            }
        }
    }).start();
}

From source file:windows.sensorWindow.java

/**
 * add a value to the main field of the sensor
 * //  w  w  w  . j a va  2 s.co  m
 * @param sensorUID
 * @param value
 */
public void addValue(String sensorUID, double value) {
    // TODO: make this method more elegant by evolving
    // plotStateMap.get-things

    // if (seriesCollectionMap.containsKey(sensorUID))
    // seriesCollectionMap.get(sensorUID).getSeries(0).add(new
    // Millisecond(), value);
    Millisecond ms = new Millisecond();

    if (seriesCollectionMap.containsKey(sensorUID)) {
        seriesCollectionMap.get(sensorUID).getSeries(0).addOrUpdate(ms, value);
    }

    // add timestamp to slider
    sliderData.addMS(ms);

    // if we have moved the slider at least once, but now it is on it's
    // start position
    // which means we want to auto-update the charts again
    if (sliderUpdate == true) {
        DateRange range = new DateRange(sliderData.getMilliseconds(0).getFirstMillisecond(),
                sliderData.getMilliseconds(sliderValuesNumber).getFirstMillisecond());
        plot.getDomainAxis().setRange(range);
    }

    // add measurement value
    if (valuesMap.containsKey(sensorUID))
        valuesMap.get(sensorUID).addValue(value);

    // if template control is turned on and template control variables exist
    // proof whether current value is in template's area
    Brick tmpBrick = Brick.getBrick(connectionData.BrickList, sensorUID);
    if ((Brick.getBrick(connectionData.BrickList, sensorUID).ctrlTmpl[0] == true)
            && (tmplCollection1_1.containsKey(sensorUID)) && (tmplStartMs.containsKey(sensorUID))
            && ((tmpBrick.ctrlTmplruns[0] == true) || (tmpBrick.ctrlTmplruns[0] == true))) {
        long timeNow = System.currentTimeMillis();
        double tmplValue = tmpBrick.tmplPlot[0].getYValue(timeNow, tmplStartMs.get(sensorUID));
        if (((tmplValue + tmpBrick.tmpl1Width) < value) || ((tmplValue - tmpBrick.tmpl1Width) > value)) {
            // set alarm state
            plot1StateMap.put(sensorUID, 3);
        }
    }

    // check whether the value is below the threshold
    if (markerMapMin1Critical.containsKey(sensorUID)) {
        // critical
        if ((value < markerMapMin1Critical.get(sensorUID).getValue())
                || (value > markerMapMax1Critical.get(sensorUID).getValue())) {
            if (plot1StateMap.get(sensorUID) < 3) {
                plot1StateMap.put(sensorUID, 3);
            }
        }

        // warning
        else if ((value < markerMapMin1Warning.get(sensorUID).getValue())
                || (value > markerMapMax1Warning.get(sensorUID).getValue())) {
            if (plot1StateMap.get(sensorUID) < 2) {
                plot1StateMap.put(sensorUID, 2);
            }
        }

        // normal level
        else {
            if (plot1StateMap.get(sensorUID) < 1) {
                plot1StateMap.put(sensorUID, 1);
            }
        }
    }

    // color the plot's background according to it's current state,
    // but only if the state of the 2nd plot is below the state of the
    // current plot
    // a higher state means higher warning level and therefore a higher
    // priority
    if (plot2StateMap.get(sensorUID) <= plot1StateMap.get(sensorUID)) {
        switch (plot1StateMap.get(sensorUID)) {
        case 1:
            plotMap.get(sensorUID).setBackgroundPaint(Color.white);
            break;
        case 2:
            plotMap.get(sensorUID).setBackgroundPaint(Color.yellow);
            break;
        case 3:
            plotMap.get(sensorUID).setBackgroundPaint(Color.red);
            break;
        }
    }
    /*
     * // check whether the value is below the threshold if
     * (markerMapMin1Critical.containsKey(sensorUID)) { if ( (value >
     * markerMapMin1Critical.get(sensorUID).getValue()) && (value <=
     * (markerMapMin1Warning.get(sensorUID).getValue())) ) { //under warning
     * level if (plotStateMap.get(sensorUID)<2) {
     * plotStateMap.put(sensorUID,2);
     * plotMap.get(sensorUID).setBackgroundPaint(Color.yellow); } } else if
     * (value <= markerMapMin1Critical.get(sensorUID).getValue()) { //under
     * threshold level if (plotStateMap.get(sensorUID)<3) {
     * plotStateMap.put(sensorUID,3);
     * plotMap.get(sensorUID).setBackgroundPaint(Color.pink); } } else {
     * //normal level
     * //plotMap.get(sensorUID).setBackgroundPaint(Color.white);
     * 
     * // check whether the value is above the threshold if
     * (markerMapMax1Critical.containsKey(sensorUID)) { if ( (value <
     * markerMapMax1Critical.get(sensorUID).getValue()) && (value >=
     * (markerMapMax1Warning.get(sensorUID).getValue())) ) { //between the
     * warning and critical plotStateMap.put(sensorUID,2);
     * plotMap.get(sensorUID).setBackgroundPaint(Color.yellow); } else if
     * (value >= markerMapMax1Critical.get(sensorUID).getValue()) { //above
     * the max threshold level plotStateMap.put(sensorUID,3);
     * plotMap.get(sensorUID).setBackgroundPaint(Color.pink); } else {
     * //normal level
     * 
     * //if (!(plotMap.get(sensorUID).getBackgroundPaint() == Color.pink) &&
     * // !(plotMap.get(sensorUID).getBackgroundPaint() == Color.yellow))
     * 
     * if (plotStateMap.get(sensorUID) != 1) {
     * plotStateMap.put(sensorUID,0);
     * plotMap.get(sensorUID).setBackgroundPaint(Color.white); } if
     * (plotStateMap.get(sensorUID) == 1) {
     * plotMap.get(sensorUID).setBackgroundPaint(Color.gray); } } } } }
     */
}

From source file:com.testmax.framework.BasePage.java

private void invokeWsPerformance(PerformerBase httpResuest) {
    long starttime = System.currentTimeMillis();
    long timer = 0;
    int invoked = 0;
    try {/*from  www .  j a  v a  2 s  . co m*/

        while (timer <= this.timeout) {
            this.executeWsPerformance(httpResuest);
            timer = (System.currentTimeMillis() - starttime) / 1000;
            synchronized (draw) {
                invoked++;
                executeGraph.ts.addOrUpdate(new Millisecond(), PerformerBase.executionCount);
                responseGraph.ts.addOrUpdate(new Millisecond(), PerformerBase.avgOKTime);
                elaspedTimeGraph.ts.addOrUpdate(new Millisecond(), PerformerBase.elaspedTime);
                activeThreadGraph.ts.addOrUpdate(new Millisecond(), PerformerBase.activeThread);
            }
        }

        synchronized (httpResuest) {
            if (httpResuest != null) {

                int totalInvoked = (this.actionResult.get(httpResuest.getActionName()) == null ? 0
                        : this.actionResult.get(httpResuest.getActionName())) + invoked;

                this.actionResult.put(httpResuest.getActionName(), totalInvoked);
                threadExit = threadExit + 1;
                httpResuest.closeDriver();
                WmLog.getCoreLogger().info("Exiting Thread=" + threadExit + " >>> Total Thread Count="
                        + newThreadCount + " >>> Action=" + httpResuest.getActionName());
                System.out.println("Exiting Thread=" + threadExit + " >>> Total Thread Count=" + newThreadCount
                        + " >>> Action=" + httpResuest.getActionName());

            }
        }

        WmLog.getCoreLogger().info("Time Elasped (sec) =" + timer + "(sec)");
        System.out.println("Time Elasped (sec)=" + timer + "(sec)");

        //Add graph for Execution Count           
        //if(this.threadCount-1== HttpThread.getThreadExit() && new File(ConfigLoader.getWmOutputReportPath()).mkdir()){
        if (threadExit == newThreadCount && new File(ConfigLoader.getWmOutputReportPath()).mkdir()) {

            saveGraph(executeGraph, ConfigLoader.getWmOutputReportPath() + "execution.jpg", "Execution Graph",
                    "Time", "Execution Count");

            //Add graph for Response Count
            saveGraph(responseGraph, ConfigLoader.getWmOutputReportPath() + "response.jpg", "Response Graph",
                    "Time", "Response Time (ms)");

            //Add graph for Elasped Count
            saveGraph(elaspedTimeGraph, ConfigLoader.getWmOutputReportPath() + "elaspedtime.jpg",
                    "Elasped Time Graph", "Time", "Elasped Time (ms)");

            //Add graph for Elasped Count
            saveGraph(activeThreadGraph, ConfigLoader.getWmOutputReportPath() + "activeuser.jpg",
                    "Active User Graph", "Time", "Elasped Time (ms)");

            //reset Jenkins Signals
            httpResuest.resetJenkinSignal();

            //set any additional custom data retrieved during performance test
            this.perfSummaryReportData = httpResuest.getPerformanceSummaryReportData();

            createHtmlReport(this.action);

        }

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}