• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15import { hideFloatWindow } from '../common/ui/floatwindow/utils/FloatWindowUtils'
16import { FloatWindowComponent } from '../common/FloatWindowComponent'
17import { TaskStatus }  from '../common/profiler/base/ProfilerConstant';
18
19@Entry
20@Component
21struct ShellBackTempLineChartPage {
22  data: number[]= [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] //数据集合
23
24  @State shellBackTemp: number= 0 //数值
25  @State random: number= 0 //用于刷新的随机数
26  offsetX: number = -1 //悬浮框移动触摸点 X
27  offsetY: number = -1 //悬浮框移动触摸点 X
28  private floatName: string= "shellBackTemp"
29  task_state = 1
30
31  aboutToAppear() {
32    globalThis.LineChartCollect = setInterval(() => {
33      this.task_state = globalThis.task_status
34      if (this.task_state == TaskStatus.task_running) {
35        if (this.data.length >= 22) {
36
37          this.data.shift() //移除第一个元素
38        }
39        if (globalThis.shellBackTemp== undefined) {
40          this.shellBackTemp = 0
41        } else {
42          this.shellBackTemp = globalThis.shellBackTemp
43          console.log("shellBackTemp---------------------" + this.shellBackTemp)
44          if (this.shellBackTemp == 0) {
45            this.data.push(0)
46          } else {
47            console.log("shellBackTemp---------------------" + this.shellBackTemp)
48            let lineCount: number = parseInt(this.shellBackTemp.toString())/ 1e3
49            console.log("shellBackTemp---------------------lineCount:" + lineCount)
50            this.data.push(Math.abs(lineCount)) //在末尾填充一个元素
51          }
52          this.random = Math.random()
53        }
54      } else {
55        //暂停
56      }
57    }, 1000)
58  }
59
60  build() {
61    Stack({ alignContent: Alignment.Top }) {
62      FloatWindowComponent({ title: `sp_shellBackTemp`, data: this.data })
63      Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
64        Text("壳温"  + ":" )
65          .fontSize('10fp')
66          .fontColor($r("app.color.color_fff"))
67          .margin({ left: 5, top: 1 }) //文本显示
68        Text(  parseInt(this.shellBackTemp.toString())/ 1e3 + "℃")
69          .fontSize('20fp')
70          .fontColor('#FF0000')
71          .fontWeight(5)
72          .margin({ left: 1,top: 1 }) //文本显示
73        Text(this.random + "")
74          .fontSize('1fp')
75          .fontColor($r("app.color.color_fff")).visibility(Visibility.None)
76
77        Image($r("app.media.icon_close_small")).width('20vp').height('20vp').onClick(() => {
78          hideFloatWindow("sp_shellBackTemp")
79
80        }).align(Alignment.TopEnd)
81      }.height('20vp').width('100%')
82
83
84    }
85  }
86}