Commit 1b60dd3d authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Try to optimize loading/resetting times

parent 7cd3ba7a
......@@ -125,10 +125,7 @@ Project {
name: "QML components";
fileTags: "qt.core.resource_data";
files: [
"components/AbstractDelegateActuator.qml",
"components/AbstractDelegateControlIO.qml",
"components/AbstractDelegateRoutine.qml",
"components/AbstractDelegateSensor.qml",
"components/AbstractDialogDetailsIO.qml",
"components/Circle.qml",
"components/ClickableTextLabel.qml",
......
......@@ -183,18 +183,27 @@ const Collection<PhysicalMarker> & Manager::getPhysicalMarkers (void) const {
}
void Manager::load (const QString & netDefUrl) {
static QElapsedTimer bench;
deinit ();
bench.restart ();
QQmlComponent compo (qmlEngine, QUrl (netDefUrl), QQmlComponent::PreferSynchronous);
WARN << "Network loaded and parsed in" << bench.elapsed () << "ms";
if (compo.isReady ()) {
bench.restart ();
QObject * rootObject = compo.create ();
WARN << "Network instantiated in" << bench.elapsed () << "ms";
if (NetworkDefinition * netDefObj = qobject_cast<NetworkDefinition *> (rootObject)) {
if (netDefObj->get_uid ().isEmpty ()) {
logWarning ("LOAD", netDefObj, "You should really set an UID on the NetworkDefinition to make snapshots a little safer !");
}
update_currentFileUrl (netDefUrl);
update_currentNetwork (netDefObj);
bench.restart ();
init ();
WARN << "Network initialized in" << bench.elapsed () << "ms";
bench.restart ();
update_hasValidNetwork (true);
WARN << "Network activated in" << bench.elapsed () << "ms";
}
else {
logError ("LOAD", rootObject, "Root object must be a NetworkDefinition !");
......@@ -257,6 +266,8 @@ void Manager::reset (void) {
}
void Manager::deinit (void) {
static QElapsedTimer bench;
bench.restart ();
update_ready (false);
if (m_currentNetwork) {
m_allowInit = false;
......@@ -327,12 +338,11 @@ void Manager::deinit (void) {
m_canBuses.clear ();
m_serialBuses.clear ();
m_dashboards.clear ();
QCoreApplication::processEvents ();
qmlEngine->collectGarbage ();
QCoreApplication::processEvents ();
qmlEngine->trimComponentCache ();
QCoreApplication::processEvents ();
}
WARN << "Network reset in" << bench.elapsed () << "ms";
}
void Manager::exportValues (const QString & filePath) {
......
import QtQuick 2.1;
import QtQmlTricks.UiElements 2.0;
import QtCAN.CanTestBench 2.0;
StretchColumnContainer {
spacing: Style.spacingSmall;
enabled: (actuator !== null);
property var actuator;
}
import QtQuick 2.1;
import QtQmlTricks.UiElements 2.0;
import QtCAN.CanTestBench 2.0;
Stretcher {
enabled: (io !== null);
property var io;
}
import QtQuick 2.1;
import QtQmlTricks.UiElements 2.0;
import QtCAN.CanTestBench 2.0;
StretchColumnContainer {
spacing: Style.spacingSmall;
enabled: (sensor !== null);
property var sensor;
function intToFloat (value, decimals) {
return (value / Math.pow (10, decimals));
}
function floatToInt (value, decimals) {
return (value * Math.pow (10, decimals));
}
}
......@@ -2,12 +2,12 @@ import QtQuick 2.1;
import QtQmlTricks.UiElements 2.0;
import QtCAN.CanTestBench 2.0;
AbstractDelegateActuator {
StretchColumnContainer {
id: base;
spacing: Style.spacingSmall;
enabled: (actuator !== null);
property AnalogActuator analogActuator : null;
property alias actuator : base.analogActuator;
property AbstractActuator actuator : null;
StretchRowContainer {
spacing: Style.spacingNormal;
......@@ -15,30 +15,30 @@ AbstractDelegateActuator {
SliderBar {
id: slider;
minValue: (analogActuator ? analogActuator.minRaw : 0);
maxValue: (analogActuator ? analogActuator.maxRaw : 1);
enabled: (analogActuator
&& ((analogActuator.sourceLink
&& analogActuator.sourceLink.detached)
|| !analogActuator.sourceLink));
minValue: (actuator ? actuator.minRaw : 0);
maxValue: (actuator ? actuator.maxRaw : 1);
enabled: (actuator
&& ((actuator.sourceLink
&& actuator.sourceLink.detached)
|| !actuator.sourceLink));
handleSize: (Style.fontSizeNormal + Style.spacingSmall * 2);
implicitWidth: -1;
showTooltipWhenMoved: false;
anchors.verticalCenter: parent.verticalCenter;
onEdited: { analogActuator.valRaw = value; }
onEdited: { actuator.valRaw = value; }
Binding on value { value: (analogActuator ? analogActuator.valRaw : 0); }
Binding on value { value: (actuator ? actuator.valRaw : 0); }
}
NumberBox {
enabled: slider.enabled;
padding: Style.spacingSmall;
decimals: 0;
minValue: (analogActuator ? analogActuator.minRaw : 0);
maxValue: (analogActuator ? analogActuator.maxRaw : 1);
minValue: (actuator ? actuator.minRaw : 0);
maxValue: (actuator ? actuator.maxRaw : 1);
anchors.verticalCenter: parent.verticalCenter;
onEdited: { analogActuator.valRaw = value; }
onEdited: { actuator.valRaw = value; }
Binding on value { value: (analogActuator ? analogActuator.valRaw : 0); }
Binding on value { value: (actuator ? actuator.valRaw : 0); }
}
}
StretchRowContainer {
......@@ -53,7 +53,7 @@ AbstractDelegateActuator {
}
Stretcher { }
TextLabel {
text: (analogActuator ? analogActuator.valRaw : "");
text: (actuator ? actuator.valRaw : "");
font.family: Style.fontFixedName;
anchors.baseline: lblActuatorRawVal.baseline;
}
......@@ -63,10 +63,10 @@ AbstractDelegateActuator {
anchors.baseline: lblActuatorRawVal.baseline;
}
TextLabel {
text: (analogActuator
text: (actuator
? "(" + [
analogActuator.minRaw,
analogActuator.maxRaw,
actuator.minRaw,
actuator.maxRaw,
].join (Style.charThreeDots) + ")"
: "");
color: Style.colorBorder;
......@@ -87,7 +87,7 @@ AbstractDelegateActuator {
}
Stretcher { }
TextLabel {
text: (analogActuator ? (100 * (analogActuator.valRaw - analogActuator.minRaw) / (analogActuator.maxRaw - analogActuator.minRaw)).toFixed () : "");
text: (actuator ? (100 * (actuator.valRaw - actuator.minRaw) / (actuator.maxRaw - actuator.minRaw)).toFixed () : "");
font.family: Style.fontFixedName;
anchors.baseline: lblActuatorPercent.baseline;
}
......@@ -119,20 +119,20 @@ AbstractDelegateActuator {
}
Stretcher { }
TextLabel {
text: (analogActuator ? format (analogActuator.valSpeed, analogActuator.decimals) : "");
text: (actuator ? format (actuator.valSpeed, actuator.decimals) : "");
font.family: Style.fontFixedName;
anchors.baseline: lblActuatorPhySpeed.baseline;
}
TextLabel {
text: (analogActuator ? analogActuator.unit : "");
text: (actuator ? actuator.unit : "");
font.pixelSize: Style.fontSizeSmall;
anchors.baseline: lblActuatorPhySpeed.baseline;
}
TextLabel {
text: (analogActuator
text: (actuator
? "(" + [
format (analogActuator.minSpeed, analogActuator.decimals),
format (analogActuator.maxSpeed, analogActuator.decimals),
format (actuator.minSpeed, actuator.decimals),
format (actuator.maxSpeed, actuator.decimals),
].join (Style.charThreeDots) + ")"
: "");
color: Style.colorBorder;
......@@ -142,13 +142,13 @@ AbstractDelegateActuator {
}
}
Repeater {
model: (analogActuator ? analogActuator.sourceLink : 0);
model: (actuator ? actuator.sourceLink : 0);
delegate: DelegateLinkSource {
link: modelData;
}
}
Repeater {
model: (analogActuator ? analogActuator.targetLink : 0);
model: (actuator ? actuator.targetLink : 0);
delegate: DelegateLinkTarget {
link: modelData;
}
......
......@@ -7,9 +7,7 @@ SliderBar {
handleSize: (barSize * 1.5);
minValue: (actuator ? actuator.minRaw : 0);
maxValue: (actuator ? actuator.maxRaw : 1);
editable: ((actuator.sourceLink
&& actuator.sourceLink.detached)
|| !actuator.sourceLink);
editable: (actuator && ((actuator.sourceLink && actuator.sourceLink.detached) || !actuator.sourceLink));
ExtraAnchors.horizontalFill: parent;
onEdited: { actuator.valRaw = value; }
......
......@@ -2,12 +2,12 @@ import QtQuick 2.1;
import QtQmlTricks.UiElements 2.0;
import QtCAN.CanTestBench 2.0;
AbstractDelegateSensor {
StretchColumnContainer {
id: base;
spacing: Style.spacingSmall;
enabled: (sensor !== null);
property AnalogSensor analogSensor : null;
property alias sensor : base.analogSensor;
property AnalogSensor sensor : null;
StretchRowContainer {
spacing: Style.spacingNormal;
......@@ -15,32 +15,32 @@ AbstractDelegateSensor {
SliderBar {
id: slider;
useSplit: (analogSensor ? analogSensor.useSplitPoint : false);
minValue: (analogSensor ? analogSensor.minPhy : 0);
maxValue: (analogSensor ? analogSensor.maxPhy : 1);
enabled: (analogSensor
&& ((analogSensor.sourceLink
&& (analogSensor.sourceLink.detached
|| analogSensor.sourceLink.reversed))
|| !analogSensor.sourceLink));
useSplit: (sensor ? sensor.useSplitPoint : false);
minValue: (sensor ? sensor.minPhy : 0);
maxValue: (sensor ? sensor.maxPhy : 1);
enabled: (sensor
&& ((sensor.sourceLink
&& (sensor.sourceLink.detached
|| sensor.sourceLink.reversed))
|| !sensor.sourceLink));
handleSize: (Style.fontSizeNormal + Style.spacingSmall * 2);
implicitWidth: -1;
showTooltipWhenMoved: false;
anchors.verticalCenter: parent.verticalCenter;
onEdited: { analogSensor.valPhy = value; }
onEdited: { sensor.valPhy = value; }
Binding on value { value: (analogSensor ? analogSensor.valPhy : 0); }
Binding on value { value: (sensor ? sensor.valPhy : 0); }
}
NumberBox {
enabled: slider.enabled;
padding: Style.spacingSmall;
decimals: (analogSensor ? analogSensor.decimals : 0);
minValue: (analogSensor ? intToFloat (analogSensor.minPhy, analogSensor.decimals) : 0);
maxValue: (analogSensor ? intToFloat (analogSensor.maxPhy, analogSensor.decimals) : 1);
decimals: (sensor ? sensor.decimals : 0);
minValue: (sensor ? intToFloat (sensor.minPhy, sensor.decimals) : 0);
maxValue: (sensor ? intToFloat (sensor.maxPhy, sensor.decimals) : 1);
anchors.verticalCenter: parent.verticalCenter;
onEdited: { analogSensor.valPhy = floatToInt (value, analogSensor.decimals); }
onEdited: { sensor.valPhy = floatToInt (value, sensor.decimals); }
Binding on value { value: (analogSensor ? intToFloat (analogSensor.valPhy, analogSensor.decimals) : 0); }
Binding on value { value: (sensor ? intToFloat (sensor.valPhy, sensor.decimals) : 0); }
}
}
StretchRowContainer {
......@@ -56,26 +56,26 @@ AbstractDelegateSensor {
Stretcher { }
TextLabel {
id: viewSensorPhyVal;
text: (analogSensor ? format (analogSensor.valPhy, analogSensor.decimals) : "");
text: (sensor ? format (sensor.valPhy, sensor.decimals) : "");
font.family: Style.fontFixedName;
color: (analogSensor
? (analogSensor.valPhy >= analogSensor.minPhy && analogSensor.valPhy <= analogSensor.maxPhy
color: (sensor
? (sensor.valPhy >= sensor.minPhy && sensor.valPhy <= sensor.maxPhy
? Style.colorForeground
: Style.colorError)
: Style.colorBorder);
anchors.baseline: lblSensorPhyVal.baseline;
}
TextLabel {
text: (analogSensor ? analogSensor.unit : "");
text: (sensor ? sensor.unit : "");
color: viewSensorPhyVal.color;
font.pixelSize: Style.fontSizeSmall;
anchors.baseline: lblSensorPhyVal.baseline;
}
TextLabel {
text: (analogSensor
text: (sensor
? "(" + [
format (analogSensor.minPhy, analogSensor.decimals),
format (analogSensor.maxPhy, analogSensor.decimals),
format (sensor.minPhy, sensor.decimals),
format (sensor.maxPhy, sensor.decimals),
].join (Style.charThreeDots) + ")"
: "");
color: Style.colorBorder;
......@@ -97,9 +97,9 @@ AbstractDelegateSensor {
Stretcher { }
TextLabel {
id: viewSensorPercent;
text: (analogSensor ? analogSensor.percents : "");
color: (analogSensor
? (analogSensor.percents >= (analogSensor.useSplitPoint ? -100 : 0) && analogSensor.percents <= 100
text: (sensor ? sensor.percents : "");
color: (sensor
? (sensor.percents >= (sensor.useSplitPoint ? -100 : 0) && sensor.percents <= 100
? Style.colorForeground
: Style.colorError)
: Style.colorBorder);
......@@ -113,8 +113,8 @@ AbstractDelegateSensor {
anchors.baseline: lblSensorPercent.baseline;
}
TextLabel {
text: (analogSensor
? (analogSensor.useSplitPoint
text: (sensor
? (sensor.useSplitPoint
? ("(-100" + Style.charThreeDots + "100)")
: ("(0" + Style.charThreeDots + "100)"))
: "");
......@@ -137,9 +137,9 @@ AbstractDelegateSensor {
Stretcher { }
TextLabel {
id: viewSensorRawVal;
text: (analogSensor ? analogSensor.valRaw : "");
color: (analogSensor
? (analogSensor.valRaw >= analogSensor.minRaw && analogSensor.valRaw <= analogSensor.maxRaw
text: (sensor ? sensor.valRaw : "");
color: (sensor
? (sensor.valRaw >= sensor.minRaw && sensor.valRaw <= sensor.maxRaw
? Style.colorForeground
: Style.colorError)
: Style.colorBorder);
......@@ -153,10 +153,10 @@ AbstractDelegateSensor {
anchors.baseline: lblSensorRawVal.baseline;
}
TextLabel {
text: (analogSensor
text: (sensor
? "(" + [
analogSensor.minRaw,
analogSensor.maxRaw,
sensor.minRaw,
sensor.maxRaw,
].join (Style.charThreeDots) + ")"
: "");
color: Style.colorBorder;
......@@ -166,13 +166,13 @@ AbstractDelegateSensor {
}
}
Repeater {
model: (analogSensor ? analogSensor.sourceLink : 0);
model: (sensor ? sensor.sourceLink : 0);
delegate: DelegateLinkSource {
link: modelData;
}
}
Repeater {
model: (analogSensor ? analogSensor.targetLinks : 0);
model: (sensor ? sensor.targetLinks : 0);
delegate: DelegateLinkTarget {
link: modelData;
}
......
......@@ -8,9 +8,7 @@ SliderBar {
useSplit: (sensor ? sensor.useSplitPoint : false);
minValue: (sensor ? sensor.minPhy : 0);
maxValue: (sensor ? sensor.maxPhy : 1);
editable: ((sensor.sourceLink
&& sensor.sourceLink.detached)
|| !sensor.sourceLink);
editable: (sensor && ((sensor.sourceLink && sensor.sourceLink.detached) || !sensor.sourceLink));
ExtraAnchors.horizontalFill: parent;
onEdited: { sensor.valPhy = value; }
......
......@@ -2,25 +2,17 @@
import QtQmlTricks.UiElements 2.0;
import QtCAN.CanTestBench 2.0;
AbstractDelegateControlIO {
SliderBar {
id: base;
enabled: (io && ((io.link && (io.link.detached || io.link.reversed)) || !io.link));
minValue: (io ? io.minRaw : 0);
maxValue: (io ? io.maxRaw : 1);
handleSize: Style.fontSizeNormal;
implicitWidth: Style.realPixels (80);
implicitHeight: slider.height;
showTooltipWhenMoved: true;
onEdited: { io.valRaw = value; }
property AnalogInput ain : null;
property AnalogInput io : null;
property alias io : base.ain;
SliderBar {
id: slider;
enabled: (ain && ((ain.link && (ain.link.detached || ain.link.reversed)) || !ain.link));
minValue: (ain ? ain.minRaw : 0);
maxValue: (ain ? ain.maxRaw : 1);
handleSize: Style.fontSizeNormal;
showTooltipWhenMoved: true;
ExtraAnchors.horizontalFill: parent;
onEdited: { ain.valRaw = value; }
Binding on value { value: (ain ? ain.valRaw : 0); }
}
Binding on value { value: (io ? io.valRaw : 0); }
}
......@@ -2,21 +2,13 @@ import QtQuick 2.1;
import QtQmlTricks.UiElements 2.0;
import QtCAN.CanTestBench 2.0;
AbstractDelegateControlIO {
id: base;
ProgressJauge {
id: basr;
minValue: (io ? io.minRaw : 0);
maxValue: (io ? io.maxRaw : 1);
implicitWidth: Style.realPixels (80);
implicitHeight: jauge.height;
property AnalogOutput aout : null;
property AnalogOutput io : null;
property alias io : base.aout;
ProgressJauge {
id: jauge;
minValue: (aout ? aout.minRaw : 0);
maxValue: (aout ? aout.maxRaw : 1);
ExtraAnchors.horizontalFill: parent;
Binding on value { value: (aout ? aout.valRaw : 0); }
}
Binding on value { value: (io ? io.valRaw : 0); }
}
......@@ -2,20 +2,12 @@ import QtQuick 2.1;
import QtQmlTricks.UiElements 2.0;
import QtCAN.CanTestBench 2.0;
AbstractDelegateControlIO {
CheckableBox {
id: base;
implicitWidth: checkbox.width;
implicitHeight: checkbox.height;
enabled: (io && ((io.link && io.link.detached) || !io.link));
onEdited: { io.value = value; }
property DigitalInput din : null;
property DigitalInput io : null;
property alias io : base.din;
CheckableBox {
id: checkbox;
enabled: (din && ((din.link && din.link.detached) || !din.link));
onEdited: { din.value = value; }
Binding on value { value: (din ? din.value : false); }
}
Binding on value { value: (io ? io.value : false); }
}
......@@ -2,27 +2,15 @@ import QtQuick 2.1;
import QtQmlTricks.UiElements 2.0;
import QtCAN.CanTestBench 2.0;
AbstractDelegateControlIO {
id: base;
implicitWidth: led.width;
implicitHeight: led.height;
property DigitalOutput dout : null;
property alias io : base.dout;
Circle {
id: led;
size: (Style.spacingNormal * 2.5);
color: (dout ? (value ? Style.colorSelection : Style.colorWindow) : Style.colorNone);
enabled: (dout !== null);
border {
width: Style.lineSize;
color: Style.colorBorder;
}
property bool value : false;
Binding on value { value: (dout ? dout.value : false); }
Circle {
id: io;
size: (Style.spacingNormal * 2.5);
color: (io ? (io.value ? Style.colorSelection : Style.colorWindow) : Style.colorNone);
enabled: (io !== null);
border {
width: Style.lineSize;
color: Style.colorBorder;
}
property DigitalOutput io : null;
}
......@@ -2,12 +2,12 @@ import QtQuick 2.1;
import QtQmlTricks.UiElements 2.0;
import QtCAN.CanTestBench 2.0;
AbstractDelegateActuator {
StretchColumnContainer {
id: base;
spacing: Style.spacingSmall;
enabled: (actuator !== null);
property DigitalActuator digitalActuator : null;
property alias actuator : base.digitalActuator;
property DigitalActuator actuator : null;
StretchRowContainer {
spacing: Style.spacingNormal;
......@@ -19,18 +19,18 @@ AbstractDelegateActuator {
}
CheckableBox {
size: Style.fontSizeBig;
enabled: (digitalActuator && digitalActuator.output
? digitalActuator.output.breakLink
enabled: (actuator && actuator.output
? actuator.output.breakLink
: false);
onEdited: { digitalActuator.value = value; }
onEdited: { actuator.value = value; }
Binding on value { value: (digitalActuator ? digitalActuator.value : false); }
Binding on value { value: (actuator ? actuator.value : false); }
}
TextLabel {
text: (digitalActuator
? (digitalActuator.value
? digitalActuator.trueLabel
: digitalActuator.falseLabel)
text: (actuator
? (actuator.value
? actuator.trueLabel
: actuator.falseLabel)
: "");
font.family: Style.fontFixedName;
anchors.verticalCenter: parent.verticalCenter;
......@@ -38,7 +38,7 @@ AbstractDelegateActuator {
Stretcher { }
}
Repeater {
model: (digitalActuator ? digitalActuator.sourceLink : 0);
model: (actuator ? actuator.sourceLink : 0);
delegate: DelegateLinkSource {
link: modelData;
}
......
......@@ -2,12 +2,12 @@ import QtQuick 2.1;
import QtQmlTricks.UiElements 2.0;
import QtCAN.CanTestBench 2.0;
AbstractDelegateSensor {
StretchColumnContainer {
id: base;
spacing: Style.spacingSmall;
enabled: (sensor !== null);
property DigitalSensor digitalSensor : null;
property alias sensor : base.digitalSensor;
property DigitalSensor sensor : null;
StretchRowContainer {
spacing: Style.spacingNormal;
......@@ -19,21 +19,21 @@ AbstractDelegateSensor {
}
CheckableBox {
size: Style.fontSizeBig;
enabled: (digitalSensor
&& ((digitalSensor.sourceLink
&& (digitalSensor.sourceLink.detached
|| digitalSensor.sourceLink.reversed))
|| !digitalSensor.sourceLink));
enabled: (sensor
&& ((sensor.sourceLink
&& (sensor.sourceLink.detached
|| sensor.sourceLink.reversed))
|| !sensor.sourceLink));
anchors.verticalCenter: parent.verticalCenter;
onEdited: { digitalSensor.value = value; }
onEdited: { sensor.value = value; }
Binding on value { value: (digitalSensor ? digitalSensor.value : false); }
Binding on value { value: (sensor ? sensor.value : false); }
}
TextLabel {
text: (digitalSensor
? (digitalSensor.value
? digitalSensor.trueLabel
: digitalSensor.falseLabel)
text: (sensor
? (sensor.value
? sensor.trueLabel
: sensor.falseLabel)
: "");
font.family: Style.fontFixedName;
anchors.verticalCenter: parent.verticalCenter;
......@@ -41,13 +41,13 @@ AbstractDelegateSensor {
Stretcher { }
}
Repeater {
model: (digitalSensor ? digitalSensor.sourceLink : 0);
model: (sensor ? sensor.sourceLink : 0);
delegate: DelegateLinkSource {
link: modelData;
}
}
Repeater {
model: (digitalSensor ? digitalSensor.targetLinks : 0);
model: (sensor ? sensor.targetLinks : 0);
delegate: DelegateLinkTarget {
link: modelData;
}
......
......@@ -2,12 +2,12 @@ import QtQuick 2.1;
import QtQmlTricks.UiElements 2.0;
import QtCAN.CanTestBench 2.0;
AbstractDelegateSensor {
StretchColumnContainer {
id: base;
spacing: Style.spacingSmall;
enabled: (actuator !== null);
property HybridActuator hybridActuator : null;
property alias actuator : base.hybridActuator;
property HybridActuator actuator : null;
StretchRowContainer {
spacing: Style.spacingNormal;
......@@ -19,19 +19,19 @@ AbstractDelegateSensor {
}
CheckableBox {
size: Style.fontSizeBig;