mirror of
https://github.com/lubosz/overte.git
synced 2025-04-10 03:42:45 +02:00
Adding the scripts for Jet
This commit is contained in:
parent
61c855a97b
commit
e1d063e908
5 changed files with 159 additions and 13 deletions
73
scripts/developer/utilities/lib/jet/jet.js
Normal file
73
scripts/developer/utilities/lib/jet/jet.js
Normal file
|
@ -0,0 +1,73 @@
|
|||
//
|
||||
// Job Engine & Task...
|
||||
// jet.js
|
||||
//
|
||||
// Created by Sam Gateau, 2018/03/28
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
"use strict";
|
||||
|
||||
// traverse task tree
|
||||
function task_traverse(root, functor, depth) {
|
||||
// if (root.isTask()) {
|
||||
depth++;
|
||||
for (var i = 0; i <root.getNumSubs(); i++) {
|
||||
var sub = root.getSubConfig(i);
|
||||
if (functor(sub, depth, i)) {
|
||||
task_traverse(sub, functor, depth)
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
function task_traverseTree(root, functor) {
|
||||
if (functor(root, 0, 0)) {
|
||||
task_traverse(root, functor, 0)
|
||||
}
|
||||
}
|
||||
|
||||
// Access job properties
|
||||
// return all the properties of a job
|
||||
function job_propKeys(job) {
|
||||
var keys = Object.keys(job)
|
||||
var propKeys = [];
|
||||
for (var k=0; k < keys.length;k++) {
|
||||
// Filter for relevant property
|
||||
var key = keys[k]
|
||||
if ((typeof job[key]) !== "function") {
|
||||
if ((key !== "objectName") && (key !== "cpuRunTime") && (key !== "enabled")) {
|
||||
propKeys.push(keys[k]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return propKeys;
|
||||
}
|
||||
|
||||
// Use this function to create a functor that will print the content of the Job visited calling the specified 'printout' function
|
||||
function job_print_functor(printout, maxDepth) {
|
||||
if (maxDepth === undefined) maxDepth = 100
|
||||
return function (job, depth, index) {
|
||||
var tab = " "
|
||||
var depthTab = "";
|
||||
for (var d = 0; d < depth; d++) { depthTab += tab }
|
||||
printout(depthTab + index + " " + job.objectName + " " + (job.enabled ? "on" : "off"))
|
||||
var keys = job_propKeys(job);
|
||||
for (var p=0; p < keys.length;p++) {
|
||||
var prop = job[keys[p]]
|
||||
printout(depthTab + tab + tab + typeof prop + " " + keys[p] + " " + prop);
|
||||
}
|
||||
|
||||
return true
|
||||
// return depth < maxDepth;
|
||||
}
|
||||
}
|
||||
|
||||
// Expose functions for regular js including this files through the 'Jet' object
|
||||
/*Jet = {}
|
||||
Jet.task_traverse = task_traverse
|
||||
Jet.task_traverseTree = task_traverseTree
|
||||
Jet.job_propKeys = job_propKeys
|
||||
Jet.job_print_functor = job_print_functor
|
||||
*/
|
48
scripts/developer/utilities/lib/jet/qml/TaskList.qml
Normal file
48
scripts/developer/utilities/lib/jet/qml/TaskList.qml
Normal file
|
@ -0,0 +1,48 @@
|
|||
//
|
||||
// jet/TaskList.qml
|
||||
//
|
||||
// Created by Sam Gateau, 2018/03/28
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
import QtQuick 2.7
|
||||
import QtQuick.Controls 1.4 as Original
|
||||
import QtQuick.Controls.Styles 1.4
|
||||
|
||||
import "qrc:///qml/styles-uit"
|
||||
import "qrc:///qml/controls-uit" as HifiControls
|
||||
|
||||
import "../jet.js" as Jet
|
||||
|
||||
Rectangle {
|
||||
id: root
|
||||
// width: parent ? parent.width : 200
|
||||
// height: parent ? parent.height : 400
|
||||
property var rootConfig : Workload
|
||||
|
||||
Original.TextArea {
|
||||
id: textArea
|
||||
width: parent.width
|
||||
height: parent.height
|
||||
text: ""
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
var message = ""
|
||||
var functor = Jet.job_print_functor(function (line) { message += line + "\n"; });
|
||||
Jet.task_traverseTree(rootConfig, functor);
|
||||
textArea.append(message);
|
||||
}
|
||||
function fromScript(mope) {
|
||||
var message ='Received \n';
|
||||
message += mope;
|
||||
textArea.append(message);
|
||||
}
|
||||
|
||||
function clearWindow() {
|
||||
textArea.remove(0,textArea.length);
|
||||
}
|
||||
}
|
1
scripts/developer/utilities/lib/jet/qml/qmldir
Normal file
1
scripts/developer/utilities/lib/jet/qml/qmldir
Normal file
|
@ -0,0 +1 @@
|
|||
TaskList 1.0 TaskList.qml
|
|
@ -23,13 +23,22 @@ Item {
|
|||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
height: 24
|
||||
|
||||
property var labelAreaWidthScale: 0.5
|
||||
|
||||
property bool integral: false
|
||||
property var config
|
||||
property string property
|
||||
property alias label: labelControl.text
|
||||
property alias min: sliderControl.minimumValue
|
||||
property alias max: sliderControl.maximumValue
|
||||
|
||||
property alias label: labelControl.text
|
||||
property bool showLabel: true
|
||||
|
||||
property bool showValue: true
|
||||
|
||||
|
||||
|
||||
signal valueChanged(real value)
|
||||
|
||||
Component.onCompleted: {
|
||||
|
@ -41,20 +50,12 @@ Item {
|
|||
HifiControls.Label {
|
||||
id: labelControl
|
||||
text: root.label
|
||||
enabled: true
|
||||
enabled: root.showLabel
|
||||
anchors.left: root.left
|
||||
anchors.right: root.horizontalCenter
|
||||
width: root.width * root.labelAreaWidthScale
|
||||
anchors.verticalCenter: root.verticalCenter
|
||||
}
|
||||
|
||||
HifiControls.Label {
|
||||
id: labelValue
|
||||
text: sliderControl.value.toFixed(root.integral ? 0 : 2)
|
||||
anchors.right: root.right
|
||||
anchors.bottom: root.bottom
|
||||
anchors.bottomMargin: 0
|
||||
}
|
||||
|
||||
|
||||
Binding {
|
||||
id: bindingControl
|
||||
target: root.config
|
||||
|
@ -66,7 +67,7 @@ Item {
|
|||
HifiControls.Slider {
|
||||
id: sliderControl
|
||||
stepSize: root.integral ? 1.0 : 0.0
|
||||
anchors.left: root.horizontalCenter
|
||||
anchors.left: labelControl.right
|
||||
anchors.right: root.right
|
||||
anchors.rightMargin: 0
|
||||
anchors.top: root.top
|
||||
|
@ -74,4 +75,17 @@ Item {
|
|||
|
||||
onValueChanged: { root.valueChanged(value) }
|
||||
}
|
||||
|
||||
HifiControls.Label {
|
||||
id: labelValue
|
||||
enabled: root.showValue
|
||||
text: sliderControl.value.toFixed(root.integral ? 0 : 2)
|
||||
anchors.right: labelControl.right
|
||||
anchors.rightMargin: 5
|
||||
anchors.verticalCenter: root.verticalCenter
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ import QtQuick.Layouts 1.3
|
|||
import "qrc:///qml/styles-uit"
|
||||
import "qrc:///qml/controls-uit" as HifiControls
|
||||
import "configSlider"
|
||||
import "../lib/jet/qml" as Jet
|
||||
|
||||
Rectangle {
|
||||
HifiConstants { id: hifi;}
|
||||
|
@ -274,6 +275,15 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
}
|
||||
Separator {}
|
||||
|
||||
Jet.TaskList {
|
||||
rootConfig: Render
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
height: 200
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue