<div dir="ltr"><div>Yeah - this was copied code from kia/kona and is what triggered these ideas; I totally agree this shouldn't be doubled up on.</div><div><br></div><div>I've got some commits centred round Metrics that I'll just check over and push up ... and then I'll just have the single <span style="font-family:monospace">xiq.v.</span><span style="font-family:monospace">trip.consumption </span>metric (unless you have some ideas for the namespace) which will be much neater.</div><div><br></div><div>If it's ok with you then I might do that unit conversion proposal.</div><div>Would it ok if the unit specifications were the same as to the programatic codes in ovms_metrics.h?</div><div>(kWh, WattHours , MetersPSS ) </div><div>I would probably add a command</div><div><font face="monospace">metric units</font> <spec> <br></div><div>to list all (matching) units and their associated Labels.</div><div><br></div><div>//.ichael </div><div><br></div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 5 Nov 2022 at 18:48, Michael Balzer <<a href="mailto:dexter@expeedo.de">dexter@expeedo.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
Michael,<br>
<br>
adding unit conversion support to the shell and Duktape commands is
a good idea.<br>
<br>
Metrics are not meant to provide a user interface, they should be
defined to be efficient and non-redundant.<br>
<br>
Btw, metrics names also shall not use upper case characters, and
shall only use "." as a separator.<br>
<br>
Regards,<br>
Michael<br>
<br>
<br>
<div>Am 05.11.22 um 11:22 schrieb Michael
Geddes:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hi all,<br>
<div>Some of the code I copied from Kona/Kia code had both
kwh/100km and km/kwh metrics in the code as 'Other'. </div>
<div>Adding the various power consumption Units is not
particularly hard (I will have a pull-request soon) - though
the conversions between them all required some thought!</div>
<div>... but it also made me think these two metrics that are
(with the consumption units added) defined like this: </div>
<div><font face="monospace">m_v_trip_consumption1 =
MyMetrics.InitFloat("xiq.v.trip.consumption.KWh/100km", 10,
0, kWHP100K);<br>
m_v_trip_consumption2 = MyMetrics.InitFloat("<a href="http://xiq.v.trip.consumption.km/kWh" target="_blank">xiq.v.trip.consumption.km/kWh</a>",
10, 0, kPkWH);<br>
</font></div>
<div><br>
</div>
<div>These are effectively the same metric but in different
units!</div>
<div>I'm wondering if we would be better to have scripting and
Duktape support for converting metrics to different unit!
This might be also quite useful for those strange countries
that insist on using miles as a measurement.</div>
<div><br>
</div>
<div>On top of the 'metric list' and 'metric set' we could add a
'metric get' which gets a single value.. and add unit support
for get/set.</div>
<div><br>
</div>
<div>I've also got a pull request that improves the precision of
the km<->mi conversions and factors it out.</div>
<div><br>
</div>
<div>//.ichael</div>
</div>
<br>
<fieldset></fieldset>
<pre>_______________________________________________
OvmsDev mailing list
<a href="mailto:OvmsDev@lists.openvehicles.com" target="_blank">OvmsDev@lists.openvehicles.com</a>
<a href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev" target="_blank">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a>
</pre>
</blockquote>
<br>
<pre cols="72">--
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26</pre>
</div>
_______________________________________________<br>
OvmsDev mailing list<br>
<a href="mailto:OvmsDev@lists.openvehicles.com" target="_blank">OvmsDev@lists.openvehicles.com</a><br>
<a href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev" rel="noreferrer" target="_blank">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a><br>
</blockquote></div></div>