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 */ 15 16import {BaseElement, element} from "../../../../base-ui/BaseElement.js"; 17import {LitTable} from "../../../../base-ui/table/lit-table.js"; 18import {SelectionParam} from "../../../bean/BoxSelection.js"; 19import {getTabFps} from "../../../database/SqlLite.js"; 20import {Utils} from "../base/Utils.js"; 21 22@element('tabpane-fps') 23export class TabPaneFps extends BaseElement { 24 private tbl: LitTable | null | undefined; 25 private range: HTMLLabelElement | null | undefined; 26 27 set data(val: SelectionParam | any) { 28 this.range!.textContent = "Selected range: " + parseFloat(((val.rightNs - val.leftNs) / 1000000.0).toFixed(5)) + " ms" 29 getTabFps(val.leftNs, val.rightNs).then((result) => { 30 if (result != null && result.length > 0) { 31 let index = result.findIndex((d) => d.startNS >= val.leftNs); 32 if (index != -1) { 33 let arr = result.splice(index > 0 ? index - 1 : index) 34 arr.map(e => e.timeStr = Utils.getTimeString(e.startNS)) 35 this.tbl!.dataSource = arr 36 } else { 37 let last = result[result.length - 1] 38 last.timeStr = Utils.getTimeString(last.startNS) 39 this.tbl!.dataSource = [last] 40 } 41 } else { 42 this.tbl!.dataSource = [] 43 } 44 }); 45 } 46 47 initElements(): void { 48 this.tbl = this.shadowRoot?.querySelector<LitTable>('#tb-fps'); 49 this.range = this.shadowRoot?.querySelector('#time-range') 50 } 51 52 initHtml(): string { 53 return ` 54<style> 55:host{ 56 display: flex; 57 flex-direction: column; 58 padding: 10px 10px; 59} 60</style> 61<label id="time-range" style="width: 100%;height: 20px;text-align: end;font-size: 10pt;margin-bottom: 5px">Selected range:0.0 ms</label> 62<lit-table id="tb-fps" style="height: auto"> 63 <lit-table-column width="1fr" title="Time" data-index="timeStr" key="timeStr" align="flex-start"></lit-table-column> 64 <lit-table-column width="1fr" title="FPS" data-index="fps" key="fps" align="flex-start" ></lit-table-column> 65</lit-table> 66 `; 67 } 68 69}