Search in sources :

Example 31 with TagTimeEntry

use of com.tencent.wstt.gt.ui.model.TagTimeEntry in project GT by Tencent.

the class GTMemoryDaemonHelper method startGWOrProfValid.

public static boolean startGWOrProfValid() {
    /*
		 * 判断GW和Prof的总数是否超上限,超上限则不允许checked,提示用户
		 */
    int total = 0;
    TagTimeEntry[] opPerfDatas = OpPerfBridge.getAllProfilerData();
    for (TagTimeEntry tte : opPerfDatas) {
        int single = 0;
        if (tte.hasChild()) {
            single = tte.getChildren()[0].getRecordSize();
            // 总值计算时,复数要乘倍数
            total += single * tte.getChildren().length;
        } else {
            single = tte.getRecordSize();
            total += single;
        }
    }
    if (GTTime.isEnable()) {
        List<GroupTimeEntry> timeGroupList = GTTimeInternal.getAllGroup();
        for (GroupTimeEntry gte : timeGroupList) {
            for (TagTimeEntry tte : gte.entrys()) {
                int single = tte.getRecordSize();
                total += single;
            }
        }
    }
    if (total >= GTMemoryDaemonThread.topLevelLimit) {
        ToastUtil.ShowLongToast(GTApp.getContext(), "More than " + GTMemoryDaemonThread.topLevelLimit + " GW or Prof records." + "You should save and clear records first.");
        return false;
    }
    return true;
}
Also used : TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry) GroupTimeEntry(com.tencent.wstt.gt.ui.model.GroupTimeEntry)

Example 32 with TagTimeEntry

use of com.tencent.wstt.gt.ui.model.TagTimeEntry in project GT by Tencent.

the class OpPerfBridge method addHistory.

public static void addHistory(OutPara op, String nowValue, long data) {
    // 要在总控开关打开的前提下才要进行历史记录
    if (!OpUIManager.gw_running) {
        return;
    }
    TagTimeEntry profilerEntry = opPerfManager.get(op.getKey());
    if (null == profilerEntry) {
        return;
    }
    if (// 有历史出参的告警
    op.isMonitor()) {
        int seq = profilerEntry.add(data);
        // 阈值对象对本次输入值进行是否预备告警的记录
        profilerEntry.getThresholdEntry().add(data, seq);
        profilerEntry.setLastValue(nowValue);
    } else {
    // 不记录历史数据的情况下统计告警,暂不使用
    // profilerEntry.getThresholdEntry().add(data);
    }
}
Also used : TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry)

Example 33 with TagTimeEntry

use of com.tencent.wstt.gt.ui.model.TagTimeEntry in project GT by Tencent.

the class OpPerfBridge method addHistory.

/**
 * 多维的历史数据,在UI上也需要展示多条曲线
 * @param key 对应出参的key
 * @param opValue 原始出参值
 * @param data 对应多维数据的值数组
 */
public static void addHistory(OutPara parentOp, String nowValue, long[] data) {
    // 要在总控开关打开的前提下才要进行历史记录
    if (!OpUIManager.gw_running) {
        return;
    }
    TagTimeEntry profilerEntry = opPerfManager.get(parentOp.getKey());
    if (null == profilerEntry) {
        return;
    }
    if (// 有历史出参的告警
    parentOp.isMonitor()) {
        profilerEntry.setLastValue(nowValue);
        int i = 0;
        for (TagTimeEntry subEntry : profilerEntry.getChildren()) {
            int seq = subEntry.add(data[i]);
            // 阈值对象对本次输入值进行是否预备告警的记录
            subEntry.getThresholdEntry().add(data[i], seq);
            i++;
        }
    } else // 没有记录历史出参的告警
    {
        int i = 0;
        for (TagTimeEntry subEntry : profilerEntry.getChildren()) {
            // 阈值对象对本次输入值进行是否预备告警的记录,暂不使用
            subEntry.getThresholdEntry().add(data[i]);
            i++;
        }
    }
}
Also used : TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry)

Example 34 with TagTimeEntry

use of com.tencent.wstt.gt.ui.model.TagTimeEntry in project GT by Tencent.

the class OpPerfManager method getAllEnable.

/**
 * 获取所有非disable态出参对应的性能对象数组
 * @return
 */
public synchronized TagTimeEntry[] getAllEnable() {
    List<TagTimeEntry> entryList = new ArrayList<TagTimeEntry>();
    for (TagTimeEntry tte : getAll()) {
        Client client = ClientManager.getInstance().getClient(tte.getExkey());
        OutPara op = client.getOutPara(tte.getName());
        if (null != op && op.getDisplayProperty() < OutPara.DISPLAY_DISABLE && op.isMonitor()) {
            entryList.add(tte);
        }
    }
    return entryList.toArray(EMPTY);
}
Also used : TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry) OutPara(com.tencent.wstt.gt.OutPara) ArrayList(java.util.ArrayList)

Example 35 with TagTimeEntry

use of com.tencent.wstt.gt.ui.model.TagTimeEntry in project GT by Tencent.

the class GTMulOpPerfDetailView method onDraw.

@Override
public void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    // 恢复默认的字号
    mPaint.setTextSize(12);
    // 恢复默认线条粗细
    mPaint.setStrokeWidth(0);
    // 恢复默认字间距
    singleTextInterval = 6;
    if (!measured) {
        canvasW = getMeasuredWidth();
        canvasH = getMeasuredHeight();
        // 相对于控件画布x轴的起始位置
        absX = (int) (canvasW / 11.23f);
        // 相对于控件画布x轴的结束位置
        absXMax = (int) (canvasW - canvasW / 19.82f);
        // 相对于控件画布y轴的起始位置
        absY = (int) (canvasH - canvasH / 4.51f);
        // 相对于控件画布y轴的结束位置
        absYMax = (int) (canvasH / 7.43f);
        // y轴数字对屏幕分辨率的适配
        if (devW == 720) {
            curScale = scaleY720;
        } else if (devW == 320) {
            absX = absX + 16;
            // 不减一下锚点线数值会出界
            absXMax = absXMax - 18;
            curScale = scaleY320;
        } else if (devW == 480) {
            absX = absX + 10;
            curScale = scaleY480;
        }
        w = absXMax - absX;
        h = absY - absYMax;
        middle = (absXMax - absX) / 2 + absX;
        anchorX = middle;
        curAve = absY;
        measured = true;
    }
    // 设置画布为黑色背景
    // canvas.drawColor(Color.BLACK);
    // 消除锯齿
    mPaint.setAntiAlias(true);
    // 设置图形为空心
    mPaint.setStyle(Paint.Style.STROKE);
    // 绘制x,y轴
    mPaint.setColor(Color.argb(0xff, 0x87, 0x8c, 0x98));
    // 设置线条粗细
    mPaint.setStrokeWidth(2);
    canvas.drawLine(absX, absY, absXMax, absY, mPaint);
    canvas.drawLine(absX, absYMax - 5, absX, absY, mPaint);
    // x最少显示10个数据,小于10个x坐标长度为10,从左开始显示
    if (curSize <= 5) {
        xGrid = 1;
    } else if (curSize > 5 && curSize <= xMin) {
        // 因为x轴显示时间了,最多显示10个1会展示不下
        xGrid = 2;
    } else {
        xGrid = 10;
    }
    /*
		 * 根据传入的参数绘制点折线
		 * 一个维度一个维度的画,兼容一维和二维的
		 */
    int j = 0;
    do {
        long preX = 0;
        float preY = 0;
        long preValue = 0;
        TagTimeEntry anchorEntry = dataSet;
        if (dataSet.getChildren().length > 0) {
            anchorEntry = dataSet.getChildren()[j];
        }
        // 阈值对象
        ThresholdEntry thresholdEntry = anchorEntry.getThresholdEntry();
        double upper = thresholdEntry.getUpperValue();
        double lower = thresholdEntry.getLowerValue();
        double dUpper = DoubleUtils.mul(upper, anchorEntry.getCarry_l2d());
        double dLower = DoubleUtils.mul(lower, anchorEntry.getCarry_l2d());
        long realUpper = (long) dUpper;
        long realLower = (long) dLower;
        boolean isWarningEable = thresholdEntry.isEnable();
        for (int i = 0; i < curSize; i++) {
            DrawEntry entry = cache[i][j];
            long point = entry.value;
            long x = absX + w * i / curSize;
            float y = calcY(point);
            entry.y = y;
            canvas.drawPoint(x, y, mPaint);
            if (// 画从前一点到当前点的线
            i > 0) {
                // 对于超出阈值的,需要标红线, 而且需要是有效阈值
                if (isWarningEable && (realUpper > realLower && (preValue > realUpper && point > realUpper || preValue < realLower && point < realLower))) {
                    // mPaint.setColor(Color.argb(0xff, 0xda, 0x7b, 0x2f));
                    mPaint.setColor(Color.argb(0xff, 0xff, 0x00, 0x00));
                } else {
                    mPaint.setColor(lineColors[j]);
                }
                // 设置线条粗细
                mPaint.setStrokeWidth(2);
                canvas.drawLine(x, y, preX, preY, mPaint);
            }
            // 单点
            if (isWarningEable && (realUpper > realLower && (point > realUpper || point < realLower))) {
                mPaint.setColor(Color.argb(0xff, 0xff, 0x00, 0x00));
            } else {
                mPaint.setColor(lineColors[j]);
            }
            mPaint.setStrokeWidth(3);
            canvas.drawPoint(x, y, mPaint);
            mPaint.setStrokeWidth(2);
            preX = x;
            preY = y;
            preValue = point;
            // 要将x位置的数字画在横坐标上,显示内容数字:i,内容位置 x, y是absY
            mPaint.setColor(Color.argb(0xff, 0x87, 0x8c, 0x98));
            // 设置线条粗细
            mPaint.setStrokeWidth(0);
            if (i % xGrid == 0) {
                canvas.drawText(Integer.toString(start + i), x, absY + 30, mPaint);
                canvas.drawText(GTUtils.getSystemTime(entry.time), x, absY + 45, mPaint);
            }
            if (curSize == xMax && i == curSize - 1) {
                canvas.drawText(Integer.toString(start + i), x, absY + 30, mPaint);
            }
            // 画垂直分割线,画一次就可以
            if (j == 0) {
                mPaint.setColor(Color.argb(0x3f, 0x87, 0x8c, 0x98));
                // 设置线条粗细
                mPaint.setStrokeWidth(1);
                if (i % xGrid == 0) {
                    canvas.drawLine(x, absY, x, absYMax - 5, mPaint);
                }
                if (curSize == xMax && i == curSize - 1) {
                    canvas.drawLine(x, absY, x, absYMax - 5, mPaint);
                }
            }
        }
        j++;
    } while (j < dataSet.getChildren().length);
    // TODO 绘制单位
    mPaint.setColor(Color.argb(0xff, 0x87, 0x8c, 0x98));
    // 设置线条粗细
    mPaint.setStrokeWidth(0);
    canvas.drawText(dataSet.getUnit(), absX - 10, absYMax - 15, mPaint);
    // 循环绘制y轴坐标数字,顺便画y轴间隔线
    mPaint.setColor(Color.argb(0xff, 0x87, 0x8c, 0x98));
    // 设置线条粗细
    mPaint.setStrokeWidth(0);
    yGrid = (int) ((curYMax - curYMin) / yMaxGridNum);
    for (int i = 0; i < yMaxGridNum + 1; i++) {
        long g = curYMin + i * yGrid;
        float y = calcY(g);
        double dg = DoubleUtils.div(g, dataSet.getCarry_l2d(), dataSet.getScale());
        String sdg = Double.toString(dg);
        mPaint.setColor(Color.argb(0xff, 0x87, 0x8c, 0x98));
        // 设置线条粗细
        mPaint.setStrokeWidth(0);
        if (sdg.length() > curScale) {
            canvas.drawText(Double.toString(dg).substring(0, curScale), absX - 40, y, mPaint);
        } else {
            canvas.drawText(Double.toString(dg), absX - 40, y, mPaint);
        }
        mPaint.setColor(Color.argb(0x3f, 0x87, 0x8c, 0x98));
        // 设置线条粗细
        mPaint.setStrokeWidth(1);
        canvas.drawLine(absX, y, absXMax, y, mPaint);
    }
    // 画平均值,只在数据源是一维时候画
    if (curYMax != 0 && dataSet.getChildren().length < 2) {
        mPaint.setColor(Color.argb(0xff, 0x14, 0x8d, 0xc0));
        // 设置线条粗细
        mPaint.setStrokeWidth(2);
        canvas.drawLine(absX, curAve, absXMax, curAve, mPaint);
    }
    mPaint.setColor(Color.argb(0xff, 0x87, 0x8c, 0x98));
    // 设置线条粗细
    mPaint.setStrokeWidth(1);
    // 在长按中,需画锚点线
    if (isInLongFlip) {
        // canvas.drawLine(anchorX, 0, anchorX, canvasH, mPaint);
        canvas.drawLine(anchorX, absY, anchorX, absYMax - 14, mPaint);
    }
    // 恢复线条粗细
    mPaint.setStrokeWidth(0);
    /*
		 * 下面的设置对应长按的文本与各曲线的标识文字
		 */
    // 时间文字显示的位置,默认小屏下取middle - 80
    float timeTextLocation = middle - 80;
    // 设置字体大小,需要为大颗粒手机适配
    if (devW > 480) {
        mPaint.setTextSize(24);
        singleTextInterval = 15f;
        timeTextLocation = middle - 155;
    } else if (devW == 480) {
        mPaint.setTextSize(16);
        singleTextInterval = 10f;
        timeTextLocation = middle - 100;
    }
    float offsetY = absYMax - 15;
    // x位置放在单位之后,单位的位置是absX - 10
    float offsetX = absX - 10 + dataSet.getUnit().length() * singleTextInterval + 16;
    if (// TODO 平时显示各条线代表的含义
    !isInLongFlip) {
        // 每一项的偏移位
        float oppositeX = 0;
        for (int i = 0; i < dataSet.getChildren().length; i++) {
            String subKey = dataSet.getChildren()[i].getName();
            // 各条线对应的颜色
            mPaint.setColor(lineColors[i]);
            mPaint.setStrokeWidth(2);
            canvas.drawLine(offsetX + oppositeX, offsetY - 4, offsetX + oppositeX + 16, offsetY - 4, mPaint);
            // 恢复线条粗细
            mPaint.setStrokeWidth(0);
            canvas.drawText(subKey, offsetX + oppositeX + 20, offsetY, mPaint);
            // 下条线标识文本的相对修正位置,因为subKey长度不定,后面的不要折叠了
            oppositeX += subKey.length() * singleTextInterval + 20 + 4;
        }
    }
    // 显示当前y值
    if (null == anchorY) {
        return;
    }
    if (anchorY[0] != 0) {
        // 灰色显示时间
        mPaint.setColor(Color.argb(0xff, 0x87, 0x8c, 0x98));
        canvas.drawText(GTUtils.getSystemTime(anchorTime[0]), timeTextLocation, offsetY, mPaint);
        // 黄色显示当前次数
        mPaint.setColor(Color.argb(0xff, 0xd2, 0x90, 0x29));
        String sAnchorSeq = Integer.toString(anchorSeq[0] + start);
        // 修正位置,因为sAnchorSeq长度不定
        float al = sAnchorSeq.length() * singleTextInterval;
        canvas.drawText(sAnchorSeq, middle, offsetY, mPaint);
        String sbValue = "";
        for (int i = 0; i < anchorY.length; i++) {
            TagTimeEntry anchorEntry = dataSet.getSubTagEntrys()[i];
            double dY = DoubleUtils.div(anchorValue[i], anchorEntry.getCarry_l2d(), anchorEntry.getScale());
            sbValue = sbValue + Double.toString(dY);
            if (i != anchorY.length - 1) {
                sbValue = sbValue + "|";
            }
        }
        // 绿色显示值
        float middleAl = middle + al;
        mPaint.setColor(Color.argb(0xff, 0x38, 0xad, 0x29));
        canvas.drawText(sbValue, middleAl + 10, offsetY, mPaint);
    }
}
Also used : TagTimeEntry(com.tencent.wstt.gt.ui.model.TagTimeEntry) ThresholdEntry(com.tencent.wstt.gt.ui.model.ThresholdEntry) Paint(android.graphics.Paint)

Aggregations

TagTimeEntry (com.tencent.wstt.gt.ui.model.TagTimeEntry)35 GroupTimeEntry (com.tencent.wstt.gt.ui.model.GroupTimeEntry)11 TimeEntry (com.tencent.wstt.gt.ui.model.TimeEntry)5 File (java.io.File)5 FileWriter (java.io.FileWriter)5 IOException (java.io.IOException)5 Builder (android.app.AlertDialog.Builder)4 DialogInterface (android.content.DialogInterface)4 Intent (android.content.Intent)4 View (android.view.View)4 TextView (android.widget.TextView)4 ArrayList (java.util.ArrayList)4 Bundle (android.os.Bundle)3 OnClickListener (android.view.View.OnClickListener)3 ImageButton (android.widget.ImageButton)3 ImageView (android.widget.ImageView)3 LinearLayout (android.widget.LinearLayout)3 RelativeLayout (android.widget.RelativeLayout)3 OutPara (com.tencent.wstt.gt.OutPara)3 GWSaveEntry (com.tencent.wstt.gt.log.GWSaveEntry)3