489 lines
21 KiB
QML
489 lines
21 KiB
QML
//========================================================================================================================================================================
|
|
// TEST !!!!!
|
|
//========================================================================================================================================================================
|
|
import QtQuick 2.12
|
|
|
|
import qt.koriolan.shipheart 1.0
|
|
|
|
|
|
Shipheart_page {
|
|
id: page_test_batterie
|
|
|
|
|
|
// Mis en forme :
|
|
readonly property double pourcentage_largeur_colonne_gauche: 0.75
|
|
readonly property double espace_colonnes_principales: 60
|
|
readonly property double pourcentage_hauteur_ligne_haut: 1
|
|
readonly property double espace_lignes_principales: 20
|
|
readonly property double affichage_hauteur_utile: shipheart_hauteur_page - shipheart_hauteur_bandeau_haut - shipheart_hauteur_bandeau_bas
|
|
|
|
|
|
readonly property int marge_haute_zone_barres: 50
|
|
readonly property int espace_barre_autonomie_barres_circuits: 40
|
|
readonly property int largeur_barre_autonomie: 80
|
|
readonly property int espace_barres_circuits: 10
|
|
readonly property int hauteur_nom_barres_circuits: 80
|
|
readonly property int rayon_barres: 3
|
|
|
|
readonly property int hauteur_barre_optimale: zone_affichage_haut_gauche.height - marge_haute_zone_barres - hauteur_nom_barres_circuits
|
|
|
|
|
|
readonly property double pourcentage_bandeau_bas_largeur_zone_retour: 1
|
|
|
|
|
|
readonly property int periode_init_raffraichissement_parametres: 1 // En ms
|
|
readonly property int periode_raffraichissement_parametres: 1000 // En ms
|
|
|
|
|
|
|
|
// Affichage :
|
|
property bool bouton_bandeau_bas_zone_retour_actif: false
|
|
property int protection_mode: 0
|
|
|
|
|
|
// Données :
|
|
property int autonomie_optimale: 0
|
|
property int autonomie_actuelle: 0
|
|
property int position_autonomie_actuelle: 0
|
|
property int nb_barres_circuits: 0
|
|
|
|
|
|
// Modèles :
|
|
// Note : les modèles chargés dans 'main.qml' n'ont pas à être rechargés dans les pages suivantes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//===========================================================
|
|
// Timer periode raffraichissement parametres :
|
|
//===========================================================
|
|
Timer {
|
|
id: timer_raffraichissement_parametres
|
|
interval: periode_init_raffraichissement_parametres
|
|
triggeredOnStart: false
|
|
running: true
|
|
repeat: true
|
|
onTriggered: {
|
|
if (interval == periode_init_raffraichissement_parametres) // Premier passage, 1ms après le premier chargement
|
|
{
|
|
interval = periode_raffraichissement_parametres;
|
|
init_page();
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// Titre de la page :
|
|
Shipheart_titre_1 {titre:qsTr("Batteries de servitude"); hauteur: shipheart_hauteur_bandeau_haut}
|
|
|
|
//-------------------------------------------------------
|
|
// Ecran Haut - Gauche :
|
|
//-------------------------------------------------------
|
|
Rectangle {
|
|
id: zone_affichage_haut_gauche
|
|
x: 0
|
|
y: shipheart_hauteur_bandeau_haut;
|
|
width: (shipheart_largeur_page * pourcentage_largeur_colonne_gauche) - (espace_colonnes_principales / 2)
|
|
height: (affichage_hauteur_utile * pourcentage_hauteur_ligne_haut) - (espace_lignes_principales / 2);
|
|
color: "transparent"
|
|
|
|
// Barre d'autonomie optimale :
|
|
Rectangle {
|
|
id: barre_autonomie_optimale
|
|
x: espace_colonnes_principales
|
|
y: marge_haute_zone_barres
|
|
width: largeur_barre_autonomie
|
|
height: hauteur_barre_optimale
|
|
color: couleur_gris_tres_pale_transparent
|
|
radius: rayon_barres
|
|
Text {
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
text: qsTr("Autonomie optimale")
|
|
font.pixelSize: 16
|
|
color: couleur_blanc_casse
|
|
rotation: 270
|
|
}
|
|
Text {
|
|
anchors.bottom: parent.top
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
text: Math.trunc(autonomie_optimale / 60) + ":" + String(Math.trunc(autonomie_optimale % 60)).padStart(2, '0')
|
|
font.pixelSize: 18
|
|
font.bold: true
|
|
color: couleur_gris_tres_tres_pale
|
|
}
|
|
}
|
|
|
|
|
|
Rectangle { // Zone des barres de circuits :
|
|
id: barres_circuits
|
|
|
|
x: barre_autonomie_optimale.x + barre_autonomie_optimale.width + espace_barre_autonomie_barres_circuits
|
|
y: marge_haute_zone_barres
|
|
width: parent.width - x - espace_barre_autonomie_barres_circuits - largeur_barre_autonomie
|
|
height: hauteur_barre_optimale
|
|
color: "transparent"
|
|
|
|
Repeater {
|
|
model: modele_barres_circuits
|
|
delegate: Rectangle {
|
|
|
|
x: ((width + espace_barres_circuits) * index) + (espace_barres_circuits / 2)
|
|
y: position
|
|
width: (barres_circuits.width / nb_barres_circuits) - espace_barres_circuits
|
|
height: barres_circuits.height - position
|
|
color: "transparent"
|
|
border {
|
|
color: couleur_gris_tres_pale_transparent
|
|
width: 1
|
|
}
|
|
Text { // Nombre d'heures d'autonomie (au-dessus de la barre)
|
|
anchors.bottom: barre_active_travaux.top
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
text: String(Math.trunc((valeur + valeur_travaux) / 60)).padStart(2, '0') + ":" + String(Math.trunc((valeur + valeur_travaux) % 60)).padStart(2, '0')
|
|
font.pixelSize: 16
|
|
color: couleur_gris_tres_tres_pale
|
|
}
|
|
Rectangle { // Barre de consommation "anormale" du circuit :
|
|
id: barre_active_travaux
|
|
width: parent.width
|
|
height: valeur_travaux * hauteur_barre_optimale / autonomie_optimale;
|
|
visible: (valeur_travaux > 0)
|
|
color: couleur_rouge_transparent
|
|
border.width: 0
|
|
radius: rayon_barres
|
|
|
|
Image { // Pictogramme au sein de la barre "anormale"
|
|
source: "/images/ak14.png"
|
|
sourceSize.height: ((parent.width * 0.4) > (parent.height * 0.9)) ? (parent.height * 0.9) : (parent.width * 0.4);
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
}
|
|
}
|
|
Rectangle { // Barre de consommation normale du circuit :
|
|
id: barre_active
|
|
y: barre_active_travaux.height
|
|
width: parent.width
|
|
height: valeur * hauteur_barre_optimale / autonomie_optimale;
|
|
color: couleur_orange_transparent
|
|
border.width: 0
|
|
radius: rayon_barres
|
|
}
|
|
Rectangle { // Libellé de la barre :
|
|
x: (parent.width / 2) * (-1)
|
|
y: barres_circuits.height - position + ((index % 2 === 0) ? 0 : (hauteur_nom_barres_circuits / 2))
|
|
width: parent.width * 2
|
|
height: hauteur_nom_barres_circuits / 2
|
|
color: "transparent"
|
|
Rectangle { // Trait vertical de liaison entre la barre et libellé
|
|
x: parent.width / 2
|
|
y: (index % 2 === 0) ? 5 : ((-1) * hauteur_nom_barres_circuits / 2) + 5
|
|
width: 2
|
|
height: (index % 2 === 0) ? 5 : (hauteur_nom_barres_circuits / 2) + 5
|
|
color: couleur_gris_fonce
|
|
}
|
|
Text {
|
|
anchors.fill: parent
|
|
verticalAlignment: Text.AlignVCenter
|
|
horizontalAlignment: Text.AlignHCenter
|
|
wrapMode: Text.Wrap
|
|
maximumLineCount: 2
|
|
elide: Text.ElideRight
|
|
text: libelle
|
|
font.pixelSize: 12
|
|
color: couleur_blanc_casse
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
ListModel {
|
|
id: modele_barres_circuits
|
|
}
|
|
}
|
|
|
|
// Barre d'autonomie actuelle :
|
|
Rectangle {
|
|
id: barre_autonomie_actuelle
|
|
x: barres_circuits.x + barres_circuits.width + espace_barre_autonomie_barres_circuits
|
|
y: marge_haute_zone_barres + position_autonomie_actuelle
|
|
width: largeur_barre_autonomie
|
|
height: hauteur_barre_optimale - position_autonomie_actuelle
|
|
color: couleur_blanc_casse_transparent
|
|
radius: rayon_barres
|
|
Rectangle { // Trait vertical de liaison entre la barre et la valeur de l'autonomie actuelle
|
|
x: parent.width / 2
|
|
y: ((-1) * position_autonomie_actuelle / 2) - 5
|
|
width: 2
|
|
height: (position_autonomie_actuelle / 2) - 5
|
|
color: couleur_gris_fonce
|
|
}
|
|
Text { // Valeur de l'autonomie actuelle
|
|
id: libelle_autonomie_actuelle
|
|
anchors.bottom: barre_autonomie_actuelle.top
|
|
anchors.bottomMargin: position_autonomie_actuelle / 2
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
text: String(Math.trunc(autonomie_actuelle / 60)).padStart(2, '0') + ":" + String(Math.trunc(autonomie_actuelle % 60)).padStart(2, '0')
|
|
font.pixelSize: 64
|
|
font.bold: true
|
|
color: couleur_gris_tres_tres_pale
|
|
}
|
|
Text { // Titre de l'autonomie actuelle
|
|
anchors.bottom: libelle_autonomie_actuelle.top
|
|
anchors.bottomMargin: 10
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
text: qsTr("Autonomie actuelle")
|
|
font.pixelSize: 24
|
|
font.bold: true
|
|
color: couleur_gris_fonce
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------------------------------------------------
|
|
// Ecran Droite :
|
|
//-------------------------------------------------------
|
|
Rectangle {
|
|
id: zone_affichage_droite
|
|
x: zone_affichage_haut_gauche.width + espace_colonnes_principales
|
|
y: shipheart_hauteur_bandeau_haut;
|
|
width: (shipheart_largeur_page * (1 - pourcentage_largeur_colonne_gauche)) - (espace_colonnes_principales / 2)
|
|
height: (affichage_hauteur_utile * pourcentage_hauteur_ligne_haut) - (espace_lignes_principales / 2);
|
|
color: "transparent"
|
|
|
|
Rectangle {
|
|
x: 0
|
|
y: 0//marge_haute_zone_barres
|
|
width: parent.width
|
|
height: position_autonomie_actuelle
|
|
color: "transparent"
|
|
Text { // Titre de l'autonomie maxi
|
|
anchors.bottom: valeur_autonomie_maxi.top
|
|
anchors.bottomMargin: 10
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
text: qsTr("Autonomie<br />maximale")
|
|
horizontalAlignment: Text.AlignHCenter
|
|
font.pixelSize: 24
|
|
font.bold: true
|
|
color: couleur_gris_fonce
|
|
}
|
|
Text { // Valeur de l'autonomie maxi
|
|
id: valeur_autonomie_maxi
|
|
|
|
anchors.bottom: image_tendance.top
|
|
anchors.bottomMargin: 30
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
text: "18:30"
|
|
font.pixelSize: 24
|
|
font.bold: true
|
|
color: couleur_gris_tres_tres_pale
|
|
}
|
|
Image {
|
|
id: image_tendance
|
|
|
|
source: "/images/fleche_tendance_haut_verte.png"
|
|
sourceSize.height: 100
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
}
|
|
Text { // Titre de la durée d'atteinte de l'autonomie maxi
|
|
id: libelle_duree_autonomie_maxi
|
|
|
|
anchors.top: image_tendance.bottom
|
|
anchors.topMargin: 30
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
text: qsTr("dans")
|
|
font.pixelSize: 24
|
|
font.bold: true
|
|
color: couleur_gris_fonce
|
|
}
|
|
Text { // Valeur de la durée d'atteinte de l'autonomie maxi
|
|
id: valeur_duree_autonomie_maxi
|
|
anchors.top: libelle_duree_autonomie_maxi.bottom
|
|
anchors.topMargin: 10
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
text: "06:30"
|
|
font.pixelSize: 24
|
|
font.bold: true
|
|
color: couleur_gris_tres_tres_pale
|
|
}
|
|
Text { // Titre de la durée d'atteinte de l'autonomie maxi
|
|
anchors.top: valeur_duree_autonomie_maxi.bottom
|
|
anchors.topMargin: 10
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
text: qsTr("environ")
|
|
font.pixelSize: 24
|
|
font.bold: true
|
|
color: couleur_gris_fonce
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
//-------------------------------------------------------
|
|
// Bandeau bas :
|
|
//-------------------------------------------------------
|
|
Row {
|
|
x: 0
|
|
y: shipheart_hauteur_page - shipheart_hauteur_bandeau_bas;
|
|
width: shipheart_largeur_page;
|
|
height: shipheart_hauteur_bandeau_bas;
|
|
spacing: 5
|
|
padding: 5
|
|
|
|
//.................................................
|
|
// Bouton retour
|
|
//.................................................
|
|
Rectangle {
|
|
id: bandeau_bas_zone_retour
|
|
width: (parent.width * pourcentage_bandeau_bas_largeur_zone_retour) - (2 * parent.padding)
|
|
height: shipheart_hauteur_bandeau_bas - parent.topPadding - parent.bottomPadding;
|
|
radius: shipheart_rayon_bouton
|
|
color: shipheart_couleur_fond_bouton
|
|
|
|
Image {
|
|
source: "/images/icone_retour.png"
|
|
sourceSize.height: 30
|
|
anchors {
|
|
verticalCenter: parent.verticalCenter
|
|
horizontalCenter: parent.horizontalCenter
|
|
}
|
|
}
|
|
|
|
MouseArea { // Zone d'interaction. On est obligé de la mettre dans la grille pour que Rectangle et MouseArea soient frères ou parent/enfant ET qu'on n'occupe qu'un espace dans la grille.
|
|
id: mouse_area_bandeau_bas_zone_retour
|
|
anchors.fill: parent
|
|
onClicked: {
|
|
shipheart_clic();
|
|
stackView.pop()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//===========================================================
|
|
// Economiseur : Doit être placé en fin de page pour fonctionner
|
|
//===========================================================
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
preventStealing: true // Permet que cela fonctionne même si un élément flickable (notamment) soit derrière et "vole" le click
|
|
enabled: flag_economiseur_actif
|
|
onClicked: {
|
|
mise_en_veille(0);
|
|
}
|
|
}
|
|
|
|
//=============================================================================================================
|
|
// Init de la page
|
|
//=============================================================================================================
|
|
function init_page()
|
|
{
|
|
var libelle, valeur, valeur_travaux;
|
|
var position;
|
|
|
|
autonomie_optimale = (14 * 60) + 20 // En minutes
|
|
autonomie_actuelle = autonomie_optimale;
|
|
position = 0;
|
|
valeur = 0;
|
|
valeur_travaux = 0;
|
|
modele_barres_circuits.clear();
|
|
|
|
|
|
//---------------------------------------
|
|
position += (valeur + valeur_travaux) * hauteur_barre_optimale / autonomie_optimale;
|
|
autonomie_actuelle -= (valeur + valeur_travaux);
|
|
libelle = "Vieillissement batterie";
|
|
valeur = 0;
|
|
valeur_travaux = 165;
|
|
modele_barres_circuits.append({"libelle": libelle, "valeur": valeur, "valeur_travaux": valeur_travaux, "position": position });
|
|
|
|
//---------------------------------------
|
|
position += (valeur + valeur_travaux) * hauteur_barre_optimale / autonomie_optimale;
|
|
autonomie_actuelle -= (valeur + valeur_travaux);
|
|
libelle = "Pilote automatique";
|
|
valeur = 130;
|
|
valeur_travaux = 0;
|
|
modele_barres_circuits.append({"libelle": libelle, "valeur": valeur, "valeur_travaux": valeur_travaux, "position": position });
|
|
|
|
//---------------------------------------
|
|
position += (valeur + valeur_travaux) * hauteur_barre_optimale / autonomie_optimale;
|
|
autonomie_actuelle -= (valeur + valeur_travaux);
|
|
libelle = "Réfrigérateur";
|
|
valeur = 40;
|
|
valeur_travaux = 65;
|
|
modele_barres_circuits.append({"libelle": libelle, "valeur": valeur, "valeur_travaux": valeur_travaux, "position": position });
|
|
|
|
//---------------------------------------
|
|
position += (valeur + valeur_travaux) * hauteur_barre_optimale / autonomie_optimale;
|
|
autonomie_actuelle -= (valeur + valeur_travaux);
|
|
libelle = "Prises USB";
|
|
valeur = 50;
|
|
valeur_travaux = 0;
|
|
modele_barres_circuits.append({"libelle": libelle, "valeur": valeur, "valeur_travaux": valeur_travaux, "position": position });
|
|
|
|
//---------------------------------------
|
|
position += (valeur + valeur_travaux) * hauteur_barre_optimale / autonomie_optimale;
|
|
autonomie_actuelle -= (valeur + valeur_travaux);
|
|
libelle = "Centrale de navigation";
|
|
valeur = 30;
|
|
valeur_travaux = 0;
|
|
modele_barres_circuits.append({"libelle": libelle, "valeur": valeur, "valeur_travaux": valeur_travaux, "position": position });
|
|
|
|
//---------------------------------------
|
|
position += (valeur + valeur_travaux) * hauteur_barre_optimale / autonomie_optimale;
|
|
autonomie_actuelle -= (valeur + valeur_travaux);
|
|
libelle = "Eclairage carré";
|
|
valeur = 15;
|
|
valeur_travaux = 0;
|
|
modele_barres_circuits.append({"libelle": libelle, "valeur": valeur, "valeur_travaux": valeur_travaux, "position": position });
|
|
|
|
//---------------------------------------
|
|
position += (valeur + valeur_travaux) * hauteur_barre_optimale / autonomie_optimale;
|
|
autonomie_actuelle -= (valeur + valeur_travaux);
|
|
libelle = "VHF";
|
|
valeur = 10;
|
|
valeur_travaux = 0;
|
|
modele_barres_circuits.append({"libelle": libelle, "valeur": valeur, "valeur_travaux": valeur_travaux, "position": position });
|
|
|
|
//---------------------------------------
|
|
position += (valeur + valeur_travaux) * hauteur_barre_optimale / autonomie_optimale;
|
|
autonomie_actuelle -= (valeur + valeur_travaux);
|
|
libelle = "Autres";
|
|
valeur = 25;
|
|
valeur_travaux = 0;
|
|
modele_barres_circuits.append({"libelle": libelle, "valeur": valeur, "valeur_travaux": valeur_travaux, "position": position });
|
|
|
|
|
|
position_autonomie_actuelle = position + ((valeur + valeur_travaux) * hauteur_barre_optimale / autonomie_optimale);
|
|
autonomie_actuelle -= (valeur + valeur_travaux);
|
|
if (autonomie_actuelle <= 0) console.log("!!! ERREUR : L'autonomie actuelle calculée est inférieures à 0 (la somme des consommations des circuits est supérieure à l'autonomie optimale)")
|
|
|
|
nb_barres_circuits = modele_barres_circuits.count;
|
|
}
|
|
|
|
|
|
//=============================================================================================================
|
|
// Mise à jour des valeurs saisies
|
|
//=============================================================================================================
|
|
function mise_a_jour()
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|