Browse Source

Improved UI

master
Youen Toupin 3 years ago
parent
commit
ed3e9f7dc4
  1. 4
      simulator/src/simulator-ui.ts
  2. 34
      simulator/src/simulator.html
  3. 12
      simulator/src/simulator.ts

4
simulator/src/simulator-ui.ts

@ -94,8 +94,8 @@ function initializeSimulator(container: HTMLElement) {
<p>Il faudra recharger le vhélio sur secteur environ ${simulationResult.gridChargeCount} fois sur l'année.</p> <p>Il faudra recharger le vhélio sur secteur environ ${simulationResult.gridChargeCount} fois sur l'année.</p>
<p>Cela coûtera ${Math.round(totalConsumedGridPower/1000*averageKwhCost*100)/100} sur l'année. Le vhélio sera rechargé à ${solarRechargeRatio}% par le soleil, ${100-solarRechargeRatio}% sur secteur.</p> <p>Cela coûtera ${Math.round(totalConsumedGridPower/1000*averageKwhCost*100)/100} sur l'année. Le vhélio sera rechargé à ${solarRechargeRatio}% par le soleil, ${100-solarRechargeRatio}% sur secteur.</p>
<p><br/></p> <p><br/></p>
<p>Vitesse moyenne : ${Math.round(simulationResult.averageSpeed*10.0)/10.0} km/h (${Math.round(simulationResult.flatTerrainSpeed*10.0)/10.0} km/h sur plat, ${Math.round(simulationResult.uphillSpeed*10.0)/10.0} km/h en côte, ${Math.round(simulationResult.downhillSpeed*10.0)/10.0} km/h en descente)</p> <p>Vitesse moyenne : ${Math.round(simulationResult.averageSpeed*10.0)/10.0} km/h (${Math.round(simulationResult.flatTerrainSpeed*10.0)/10.0} km/h sur plat, ${Math.round(simulationResult.uphillSpeed*10.0)/10.0} km/h en côte à ${Math.round((parameters.dailyAscendingElevation/1000.0)/(parameters.dailyDistance*(1.0-parameters.flatTerrainRatio)*0.5)*100.0)}%, ${Math.round(simulationResult.downhillSpeed*10.0)/10.0} km/h en descente)</p>
<p>Durée du trajet quotidien : ${dailyDurationHours}h ${dailyDurationMinutes}min. Distance annuelle : ${Math.round(simulationResult.cumulatedDistance)} km.</p> <p>Durée de trajet quotidien : ${dailyDurationHours}h ${dailyDurationMinutes}min. Distance annuelle : ${Math.round(simulationResult.cumulatedDistance)} km.</p>
`; `;
//<p>${Math.round(100*(simulationResult.cumulatedSolarRechargeEnergy/simulationResult.vehicle.batteryEfficiency) / simulationResult.totalProducedSolarEnergy)}% de l'énergie produite par le panneau photovoltaïque sera utilisée pour recharger le vhélio.</p> //<p>${Math.round(100*(simulationResult.cumulatedSolarRechargeEnergy/simulationResult.vehicle.batteryEfficiency) / simulationResult.totalProducedSolarEnergy)}% de l'énergie produite par le panneau photovoltaïque sera utilisée pour recharger le vhélio.</p>

34
simulator/src/simulator.html

@ -24,6 +24,22 @@
</div> </div>
</div> </div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Poids du pilote</label>
</div>
<div class="field-body">
<div class="field has-addons">
<p class="control is-expanded">
<input name="driver-weight" class="input" type="number" min="1" value="70"/>
</p>
<p class="control">
<a class="button is-static">kg</a>
</p>
</div>
</div>
</div>
<div class="field is-horizontal"> <div class="field is-horizontal">
<div class="field-label is-normal"> <div class="field-label is-normal">
<label class="label">Poids passagers et chargement</label> <label class="label">Poids passagers et chargement</label>
@ -125,22 +141,6 @@
</div> </div>
</div> </div>
</div> </div>
<div class="field is-horizontal">
<div class="field-label is-normal">
<label class="label">Poids pilote</label>
</div>
<div class="field-body">
<div class="field has-addons">
<p class="control is-expanded">
<input name="driver-weight" class="input" type="number" min="1" value="70"/>
</p>
<p class="control">
<a class="button is-static">kg</a>
</p>
</div>
</div>
</div>
<div class="field is-horizontal"> <div class="field is-horizontal">
<div class="field-label is-normal"> <div class="field-label is-normal">
@ -181,7 +181,7 @@
<div class="field-body"> <div class="field-body">
<div class="field has-addons"> <div class="field has-addons">
<p class="control is-expanded"> <p class="control is-expanded">
<input name="flat-ratio" class="input" type="number" min="0" max="100" value="75"/> <input name="flat-ratio" class="input" type="number" min="0" max="100" value="50"/>
</p> </p>
<p class="control"> <p class="control">
<a class="button is-static">%</a> <a class="button is-static">%</a>

12
simulator/src/simulator.ts

@ -143,22 +143,25 @@ namespace Simulator {
let outing: Outing = { distance: 0, ascendingElevation: 0 }; let outing: Outing = { distance: 0, ascendingElevation: 0 };
let consumption: ConsumptionData = { motorEnergy: 0, humanEnergy: 0, averageSpeed: 0 }; let consumption: ConsumptionData = { motorEnergy: 0, humanEnergy: 0, averageSpeed: 0 };
let resetConsumption = function(outConsumption: ConsumptionData) {
consumption.motorEnergy = 0; consumption.humanEnergy = 0; consumption.averageSpeed = 0;
};
let flatTerrainRatio = MathUtils.clamp(planning.flatTerrainRatio, 0.0, 1.0); let flatTerrainRatio = MathUtils.clamp(planning.flatTerrainRatio, 0.0, 1.0);
if(planning.dailyAscendingElevation <= 0) flatTerrainRatio = 1.0; if(planning.dailyAscendingElevation <= 0) flatTerrainRatio = 1.0;
let flatDistance = planning.dailyDistance * flatTerrainRatio; let flatDistance = planning.dailyDistance * flatTerrainRatio;
consumption = { motorEnergy: 0, humanEnergy: 0, averageSpeed: 0 }; resetConsumption(consumption);
vehicle.consumption(flatDistance, 0, consumption); vehicle.consumption(flatDistance, 0, consumption);
result.flatTerrainSpeed = consumption.averageSpeed; result.flatTerrainSpeed = consumption.averageSpeed;
let uphillDistance = planning.dailyDistance * (1.0 - flatTerrainRatio) * 0.5; let uphillDistance = planning.dailyDistance * (1.0 - flatTerrainRatio) * 0.5;
consumption = { motorEnergy: 0, humanEnergy: 0, averageSpeed: 0 }; resetConsumption(consumption);
vehicle.consumption(uphillDistance, planning.dailyAscendingElevation, consumption); vehicle.consumption(uphillDistance, planning.dailyAscendingElevation, consumption);
result.uphillSpeed = consumption.averageSpeed; result.uphillSpeed = consumption.averageSpeed;
let downhillDistance = planning.dailyDistance * (1.0 - flatTerrainRatio) * 0.5; let downhillDistance = planning.dailyDistance * (1.0 - flatTerrainRatio) * 0.5;
consumption = { motorEnergy: 0, humanEnergy: 0, averageSpeed: 0 }; resetConsumption(consumption);
vehicle.consumption(downhillDistance, -planning.dailyAscendingElevation, consumption); vehicle.consumption(downhillDistance, -planning.dailyAscendingElevation, consumption);
result.downhillSpeed = consumption.averageSpeed; result.downhillSpeed = consumption.averageSpeed;
@ -174,8 +177,7 @@ namespace Simulator {
planning.getOuting(day % 7, hour, outing); planning.getOuting(day % 7, hour, outing);
consumption.motorEnergy = 0; consumption.humanEnergy = 0; consumption.averageSpeed = 0; resetConsumption(consumption);
vehicle.consumption(outing.distance * flatTerrainRatio, 0, consumption); vehicle.consumption(outing.distance * flatTerrainRatio, 0, consumption);
vehicle.consumption(outing.distance * (1.0 - flatTerrainRatio) * 0.5, outing.ascendingElevation, consumption); vehicle.consumption(outing.distance * (1.0 - flatTerrainRatio) * 0.5, outing.ascendingElevation, consumption);
vehicle.consumption(outing.distance * (1.0 - flatTerrainRatio) * 0.5, -outing.ascendingElevation, consumption); vehicle.consumption(outing.distance * (1.0 - flatTerrainRatio) * 0.5, -outing.ascendingElevation, consumption);

Loading…
Cancel
Save