<div dir="ltr"><div dir="ltr">Yeah, ok.<br></div><div dir="ltr"><br></div><div>I will get all the other 'user unit' stuff done as a line in the sand, and then move to working out the web stuff.  I'm still finding my way though all the client side javascript, which looks very cool.. but I've not really done jQuery before (just enough to recognise it).</div><div><br></div><div>Subscribing to metrics with/without user units makes a lot of sense.  Obviously the default needs to be 'Subscribe to all metrics but not user units' to maintain compatibility... but I was also thinking it might be nice if we could filter down even the normal subscribed events.</div><div>We could have:</div><div>* Web socket command to  filter units (flag on websocket to say 'filtered' + flag bitset on each 

metric  similar to 'dirty')<br></div><div>Then either:</div><div>* Web socket command to turn on user units (single flag on that websocket)</div><div>or </div><div>* Web socket command to turn on user units for specific metrics (flag bitset on each metric)</div><div><br></div><div>A parameter to the URI for the websocket could start the socket in 'filtered' mode to avoid the initial rush of metrics.</div><div><br></div><div>This could drastically reduce traffic and time for the metrics command to execute.  It would be possible to also check (on a 'filtered' websocket) for any changes to metrics for that websocket slot before queueing the 'metric update' socket command.</div><div><br></div><div>//.ichael</div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 17 Nov 2022 at 00:35, 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>
    I don't have much spare time currently, just some quick first
    comments: it's important to implement this as lightweight as
    possible, both in terms of network load and client CPU & memory
    requirements. Some devices already have issues, which can be seen by
    the "websocket overflow" messages. The web UI also should stay
    usable via cellular.<br>
    <br>
    My impression is the new scheme, while only slightly raising the
    client requirements, adds substantially to the network requirements.<br>
    <br>
    An option could be to separate the units -- or more, back when
    implementing this I thought about separating the names later on.
    Another question is if we normally generally need both the native
    and the converted values in the web UI. We maybe could provide an
    option to switch to converted values, or add an option to retreive
    or subscribe to a set of converted metrics on demand.<br>
    <br>
    Standard plugins like ABRP and PwrMon rely on getting metric
    (native) units, and there probably are non-public plugins, e.g. for
    engineering & scientific projects, that depend on metric units
    to do their calculations and don't need anything else. We shouldn't
    make life harder for these applications without good reason.<br>
    <br>
    Regards,<br>
    Michael<br>
    <br>
    <br>
    <div>Am 15.11.22 um 01:26 schrieb Michael
      Geddes:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="ltr">
        <div dir="ltr">If you're ok with the [default] option I'll stick
          with that. I mean in some ways it would be nice to have a
          button choice</div>
        <div dir="ltr">metric | usa | europe | asia | custom   etc and I
          kind of considered something like that but figured it's only a
          handful of choices.. and it's an embedded device.. so simpler
          is better.</div>
        <div dir="ltr"><br>
        </div>
        <div>On a related note - I was thinking how it would be nice if
          the dashboard (etc) had access to the 'user' units, so went
          hunting down that little rabbit hole. Quite a nice mechanism
          with the web socket updating the "metrics" object in the UI. </div>
        <div>This is a snippet of one idea, which is that for any metric
          that has the possibility of a user unit, we set the extra
          values of the metric with '#unit' and '#user' appended - see
          below. (I've chosen '#' arbitrarily.. but it could be '/' or
          ':' or '>'  but maybe not '.' )</div>
        <br>
        v.p.odometer#unit: "M"<br>
        v.p.odometer#user: 6754.91<br>
        v.p.satcount: 13<br>
        v.p.speed: 0<br>
        v.p.speed#unit: "km/h"<br>
        v.p.speed#user: null<br>
        <b>v.p.trip: 28</b><br>
        <b>v.p.trip#unit: "M"<br>
          v.p.trip#user: 17.3984</b>
        <div><br>
        </div>
        <div>Then we can use this in the dials to populate the values
          and captions! (not that I like Miles).</div>
        <div>I</div>
        <div>
          <div><br>
          </div>
          <div><img src="cid:18482be34d5cb971f161" alt="image.png" width="217" height="136"><br>
          </div>
          <div><br>
          </div>
          <div>The other (similar) way was to have something like the
            following:</div>
          <div>"v.p.trip#user" : { "value": 17.3984, "unit": "M" }</div>
          <div>It wouldn't make the total message any shorter.. soo..
            dunno.</div>
          <div><br>
          </div>
          <div>There's also some complications with setting up the dials
            (for min/max values) - like for the speed.</div>
          <div><br>
          </div>
          <div>Notice also that I'm returning null for undefined values.
            It's nice - but I'm not sure how javascript handles null
            when used / printed etc.</div>
          <div><br>
          </div>
          <div>//.ichael</div>
          <div><br>
          </div>
          <div>
            <div class="gmail_quote">
              <div dir="ltr" class="gmail_attr">On Sun, 13 Nov 2022 at
                21:06, Michael Balzer <<a href="mailto:dexter@expeedo.de" target="_blank">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>
                  looks good.<br>
                  <br>
                  I think having an explicit 'default' option is better
                  than taking the 'Metric' equivalent for that, as in
                  your example you already show unit alternatives within
                  the metric system to support different scalings (kW /
                  W, kWh / Wh). (Btw… waiting for someone to miss
                  Horsepower & BTU here ;-))<br>
                  <br>
                  @Patrick, I think that also answers your implicit
                  question:<br>
                  <blockquote type="cite">
                    <pre>The default button makes it unclear what the actual setting is.
</pre>
                  </blockquote>
                  <br>
                  The default (native unit) is always metric, but you
                  may have a mix of scalings, as we try to find the one
                  that fits best for the given application when defining
                  a metric. For example the current driving energy
                  consumption is stored natively in Wh/km, while the
                  energy used or regenerated is in kWh, and the odometer
                  & trip counters are in km, while the altitude ist
                  in m.<br>
                  <br>
                  Regards,<br>
                  Michael<br>
                  <br>
                  <br>
                  <div>Am 13.11.22 um 08:42 schrieb Michael Geddes:<br>
                  </div>
                  <blockquote type="cite">
                    <div dir="ltr">Greetings,<br>
                      <div>so this is my idea of being able to select
                        which units various groups use (in addition to
                        Distance).</div>
                      <div>This can be then accessed by the special
                        'user' unit code.  (or  'metrics list -u ' )</div>
                      <div>The idea of [Default] selection below  simply
                        means storing the value to blank - meaning use
                        whatever unit the particular metric uses.  The
                        other idea I had was to actually default it to
                        the equivalent of 'Metric' special unit code and
                        not have the [Default] button.</div>
                      <div><br>
                      </div>
                      <div><br>
                      </div>
                      <img src="cid:18482be34d5cb971f162" alt="image.png" width="472" height="395"><br>
                      <div><br>
                      </div>
                      <div>Currently I've made it so that if there are
                        more than 3 choices other than [default] that it
                        uses the choice/combo box rather than the Radio
                        buttons. (ie this list is auto-generated from
                        the Metric Units table and the Metric Groups
                        table).</div>
                      <div><br>
                      </div>
                      <div>Thoughts / comments?</div>
                      <div><br>
                      </div>
                      <div>//.ichael </div>
                    </div>
                    <br>
                    <div class="gmail_quote">
                      <div dir="ltr" class="gmail_attr">On Sat, 12 Nov
                        2022 at 17:35, Michael Geddes <<a href="mailto:frog@bunyip.wheelycreek.net" target="_blank">frog@bunyip.wheelycreek.net</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 dir="ltr">
                          <div dir="ltr"><a href="https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/pull/771" target="_blank">https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/pull/771</a><br>
                            <div><br>
                            </div>
                            <div>I'm hoping this P/R is ok in this form
                              (made of 5 separate commits).</div>
                            <div><br>
                            </div>
                            <div>I will have a look at implementing the
                              "user" unit code.  The base for how it
                              would work is already a part of the above
                              pull request.  I'll just look at the
                              module configuration for distance.</div>
                            <div><br>
                            </div>
                            <div>The 'power consumption' is one where
                              it's not just a check-box.. there're 5
                              possible choice!</div>
                            <div><br>
                            </div>
                            <div>I should also add 'bar' for pressure
                              given that for some reason that's still a
                              thing people want.</div>
                            <div><br>
                            </div>
                            <div>//.ichael</div>
                          </div>
                          <br>
                          <div class="gmail_quote">
                            <div dir="ltr" class="gmail_attr">On Sat, 12
                              Nov 2022 at 16:24, Michael Balzer <<a href="mailto:dexter@expeedo.de" target="_blank">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> I think this is pretty decent &
                                complete now.<br>
                                <br>
                                I also like the approach of the 'user'
                                unit code. Moving all user unit prefs
                                into the module configuration is an old
                                todo. Currently only the distance unit
                                is defined at the module side,
                                temperature and pressure are App prefs.<br>
                                <br>
                                Regards,<br>
                                Michael<br>
                                <br>
                                <br>
                                <div>Am 11.11.22 um 09:54 schrieb
                                  Michael Geddes:<br>
                                </div>
                                <blockquote type="cite">
                                  <div dir="ltr">Ok - so here's what I
                                    have implemented for Duktape and
                                    Metrics. (I added IsDefined() as
                                    well).
                                    <div>Any thoughts on this?<br>
                                      <div><br>
                                        <div>Noting</div>
                                        <div>   OvmsMetrics.Float(
                                          {metric} ) -> Outputs
                                          metric as float (same)</div>
                                        <div>   OvmsMetrics.Float(
                                          {metric}, {unit}) ->
                                          Outputs metric as float
                                          converted to given unit  (new)</div>
                                        <div>   OvmsMetrics.Value(
                                          {metric} )   -> Outputs
                                          Metric in native value (same)</div>
                                        <div>   OvmsMetrics.Value(
                                          {metric} , false)   ->
                                          Outputs Metric as string and
                                          no units (same) </div>
                                           OvmsMetrics.Value( {metric}
                                        ,  {unit})  -> Outputs Metric
                                        converted to given unit as
                                        native value. (new)
                                        <div>  OvmsMetrics.Value(
                                          {metric} ,  {unit}, false ) 
                                          -> Outputs Metric converted
                                          to given unit as string
                                          including any unit specifier.
                                          (new)
                                          <div>also 
                                            OvmsMetric.GetValues(
                                            {metric} [,{unit}] [,
                                            {converted} ] )  Adds
                                            similar behaviour to Value()
                                            above.</div>
                                          <div>also the special units '<b>imperial</b>'
                                            and '<b>metric</b>' will
                                            convert to the associated
                                            imperial / metric version of
                                            the units as appropriate.</div>
                                          <div><br>
                                            <div><font face="monospace">(function()
                                                {<br>
                                                   dump = function
                                                (metric) { print(
                                                metric+ " ["+(typeof
                                                metric)+"]\n"  ); }<br>
                                                   dump_obj = function
                                                (obj )  {<br>
                                                     print('--- Object
                                                ----\n')<br>
                                                     for (var k in obj)
                                                {<br>
                                                       xk = obj[k];<br>
                                                       print( k+':'+ xk
                                                + ' ['+typeof xk+
                                                "]\n");<br>
                                                     }<br>
                                                   }<br>
                                                 
                                                 dump(OvmsMetrics.Value("xiq.v.trip.consumption"));<br>
                                                 
                                                 dump(OvmsMetrics.Value("xiq.v.trip.consumption",
                                                false));<br>
                                                 
                                                 dump(OvmsMetrics.Value("xiq.v.trip.consumption","kmpkwh"));<br>
                                                 
                                                 dump(OvmsMetrics.Value("xiq.v.trip.consumption",
                                                "mipkwh", false));<br>
                                                 
                                                 dump(OvmsMetrics.AsFloat("xiq.v.trip.consumption"));<br>
                                                 
                                                 dump(OvmsMetrics.AsFloat("xiq.v.trip.consumption","kmpkwh"));<br>
                                                 
                                                 dump(OvmsMetrics.Value("xiq.v.trip.consumption","imperial"))<br>
                                                 
                                                 dump(OvmsMetrics.Value("xiq.v.trip.consumption","imperial",
                                                false))<br>
                                                 
                                                 dump_obj(OvmsMetrics.GetValues("trip",
                                                "metric"))<br>
                                                 
                                                 dump_obj(OvmsMetrics.GetValues("trip",
                                                "imperial", false))<br>
                                                })();<br>
                                              </font></div>
                                            <div><br>
                                            </div>
                                            <div>With this output:</div>
                                            <div>
                                              <div>
                                                <pre id="m_-5441616086226233372m_8405494616978842232m_-5904723395924573806m_1733173679174480992m_-138117451584655546m_5484224439251412587gmail-output" style="box-sizing:border-box;overflow:auto;font-family:ui-monospace,"Cascadia Mono","Segoe UI Mono",Hack,"Source Code Pro","Roboto Mono",Menlo,Monaco,Consolas,monospace;font-size:13px;padding:9.5px;margin-top:0px;margin-bottom:10px;line-height:1.42857;color:rgb(0,34,0);word-break:break-all;background-color:rgb(245,245,245);border:1px solid rgb(204,204,204);border-radius:4px;height:406px;white-space:pre-wrap">19.2308 [number]
19.2308 [string]
5.2 [number]
3.23112mi/kWh [string]
19.2308 [number]
5.2 [number]
309.49 [number]
309.49Wh/mi [string]
--- Object ----
v.p.trip:13 [number]
xiq.e.trip:0 [number]
xiq.e.trip.energy.recuperated:0 [number]
xiq.e.trip.energy.used:0 [number]
xiq.v.trip.consumption:19.2308 [number]
--- Object ----
v.p.trip:8.07781M [string]
xiq.e.trip:0M [string]
xiq.e.trip.energy.recuperated:0kWh [string]
xiq.e.trip.energy.used:0kWh [string]
xiq.v.trip.consumption:309.49Wh/mi [string]</pre>
                                              </div>
                                            </div>
                                          </div>
                                        </div>
                                      </div>
                                    </div>
                                  </div>
                                  <br>
                                  <div class="gmail_quote">
                                    <div dir="ltr" class="gmail_attr">On
                                      Wed, 9 Nov 2022 at 05:47, Michael
                                      Geddes <<a href="mailto:frog@bunyip.wheelycreek.net" target="_blank">frog@bunyip.wheelycreek.net</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 dir="ltr">Yeah - I like
                                        HasValue.  I implemented
                                        IsDefined() but I will rename
                                        it.. that's a much clearer name.
                                        <div><br>
                                        </div>
                                        <div>Another thought. How about
                                          if we did this (but also with
                                          GetValues() as well - see the
                                          special values below) </div>
                                        <div><br>
                                          <div>OvmsMetrics.Value("xiq.v.trip.consumption",
                                             true)  -> <span style="background-color:rgb(245,245,245);color:rgb(0,34,0);font-family:ui-monospace,"Cascadia Mono","Segoe UI Mono",Hack,"Source Code Pro","Roboto Mono",Menlo,Monaco,Consolas,monospace;font-size:13px;white-space:pre-wrap">17.0582</span><span style="background-color:rgb(245,245,245);color:rgb(0,34,0);font-family:ui-monospace,"Cascadia Mono","Segoe UI Mono",Hack,"Source Code Pro","Roboto Mono",Menlo,Monaco,Consolas,monospace;font-size:13px;white-space:pre-wrap">  (Number)</span><br>
                                          </div>
                                          <div>
                                            <div>OvmsMetrics.Value("xiq.v.trip.consumption",
                                               false)  -> <span style="background-color:rgb(245,245,245);color:rgb(0,34,0);font-family:ui-monospace,"Cascadia Mono","Segoe UI Mono",Hack,"Source Code Pro","Roboto Mono",Menlo,Monaco,Consolas,monospace;font-size:13px;white-space:pre-wrap">17.0582</span><span style="background-color:rgb(245,245,245);color:rgb(0,34,0);font-family:ui-monospace,"Cascadia Mono","Segoe UI Mono",Hack,"Source Code Pro","Roboto Mono",Menlo,Monaco,Consolas,monospace;font-size:13px;white-space:pre-wrap">  (String)</span></div>
                                          </div>
                                        </div>
                                        <div>OvmsMetrics.Value("xiq.v.trip.consumption",
                                          "mipkwh", true)  -> <span style="background-color:rgb(245,245,245);color:rgb(0,34,0);font-family:ui-monospace,"Cascadia Mono","Segoe UI Mono",Hack,"Source Code Pro","Roboto Mono",Menlo,Monaco,Consolas,monospace;font-size:13px;white-space:pre-wrap">3.64264</span><span style="background-color:rgb(245,245,245);color:rgb(0,34,0);font-family:ui-monospace,"Cascadia Mono","Segoe UI Mono",Hack,"Source Code Pro","Roboto Mono",Menlo,Monaco,Consolas,monospace;font-size:13px;white-space:pre-wrap">  (Number)</span><br>
                                        </div>
                                        <div>OvmsMetrics.Value("xiq.v.trip.consumption",
                                          "mipkwh", false)  -> <span style="background-color:rgb(245,245,245);color:rgb(0,34,0);font-family:ui-monospace,"Cascadia Mono","Segoe UI Mono",Hack,"Source Code Pro","Roboto Mono",Menlo,Monaco,Consolas,monospace;font-size:13px;white-space:pre-wrap">3.64264Mi/kWh</span><span style="background-color:rgb(245,245,245);color:rgb(0,34,0);font-family:ui-monospace,"Cascadia Mono","Segoe UI Mono",Hack,"Source Code Pro","Roboto Mono",Menlo,Monaco,Consolas,monospace;font-size:13px;white-space:pre-wrap">  (String)</span><br>
                                        </div>
                                        <div> OvmsMetrics.Value("xiq.v.trip.consumption",
                                          "native", false)  -> <span style="font-size:13px;background-color:rgb(245,245,245);color:rgb(0,34,0);font-family:ui-monospace,"Cascadia Mono","Segoe UI Mono",Hack,"Source Code Pro","Roboto Mono",Menlo,Monaco,Consolas,monospace;white-space:pre-wrap">17.0582km/kWh</span><span style="font-size:13px;background-color:rgb(245,245,245);color:rgb(0,34,0);font-family:ui-monospace,"Cascadia Mono","Segoe UI Mono",Hack,"Source Code Pro","Roboto Mono",Menlo,Monaco,Consolas,monospace;white-space:pre-wrap">  (String)</span>  </div>
                                        <div><br>
                                        </div>
                                        <div>and</div>
                                        <div>
                                          <div>OvmsMetrics.Value("xiq.v.trip.consumption",
                                            "imperial", false)  -> <span style="background-color:rgb(245,245,245);color:rgb(0,34,0);font-family:ui-monospace,"Cascadia Mono","Segoe UI Mono",Hack,"Source Code Pro","Roboto Mono",Menlo,Monaco,Consolas,monospace;font-size:13px;white-space:pre-wrap">3.64264Mi/kWh</span><span style="background-color:rgb(245,245,245);color:rgb(0,34,0);font-family:ui-monospace,"Cascadia Mono","Segoe UI Mono",Hack,"Source Code Pro","Roboto Mono",Menlo,Monaco,Consolas,monospace;font-size:13px;white-space:pre-wrap">  (String)</span><br>
                                          </div>
                                        </div>
                                        <div><br>
                                        </div>
                                        <div>I have already implemented
                                          the special values 'native'
                                          (existing), 'imperial' and
                                          'metric'.  </div>
                                        <div><br>
                                        </div>
                                        <div>I was also thinking that in
                                          the future you could have
                                          'user'. Where for each group
                                          of values:</div>
                                        <div>'temperature', 'distance',
                                          'shortdistance', 'power' etc..
                                          you could have a user
                                          preference. I probably won't
                                          implement it now,.but it could
                                          be cool that any UI could just
                                          ask for the user defined units
                                          (rather than having a separate
                                          choice).</div>
                                        <div><br>
                                        </div>
                                        <div><br>
                                        </div>
                                        <div><br>
                                        </div>
                                        <div>//.ichael</div>
                                      </div>
                                      <br>
                                      <div class="gmail_quote">
                                        <div dir="ltr" class="gmail_attr">On Tue, 8
                                          Nov 2022 at 21:57, Mark
                                          Webb-Johnson <<a href="mailto:mark@webb-johnson.net" target="_blank">mark@webb-johnson.net</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>
                                            <div dir="ltr" style="color:rgb(0,0,0)">Or
                                              perhaps something more
                                              specific?</div>
                                            <div dir="ltr" style="color:rgb(0,0,0)"><br>
                                            </div>
                                            <div dir="ltr" style="color:rgb(0,0,0)"> 
                                                HasValue()</div>
                                            <div dir="ltr" style="color:rgb(0,0,0)"><br>
                                            </div>
                                            <div dir="ltr" style="color:rgb(0,0,0)">Mark</div>
                                            <div><br>
                                              <blockquote type="cite">
                                                <div>On 8 Nov 2022, at
                                                  9:01 PM, Michael
                                                  Balzer <<a href="mailto:dexter@expeedo.de" target="_blank">dexter@expeedo.de</a>> wrote:</div>
                                                <br>
                                                <div>
                                                  <div>
                                                    <div>
                                                      <div>Signed PGP
                                                        part</div>
                                                      <div>
                                                        <div> That's
                                                          basically a
                                                          good approach,
                                                          but be aware
                                                          'IsDefined()'
                                                          has an
                                                          ambiguous
                                                          meaning here,
                                                          as with the
                                                          API stem
                                                          "OvmsMetrics"
                                                          it would
                                                          naturally be
                                                          expected to
                                                          mean "is this
                                                          metric
                                                          defined", not
                                                          "does this
                                                          metric have a
                                                          defined
                                                          value".<br>
                                                          <br>
                                                          An undefined
                                                          metric
                                                          currently can
                                                          be derived
                                                          from
                                                          'Values()'
                                                          returning
                                                          undefined, but
                                                          that's more an
                                                          undocumented
                                                          side effect
                                                          than intended.<br>
                                                          <br>
                                                          Maybe
                                                          'GetDefined()'
                                                          could be a
                                                          better name,
                                                          leveraging
                                                          this
                                                          behaviour,
                                                          i.e. returning
                                                          'undefined'
                                                          for an
                                                          actually
                                                          undefined
                                                          metric, and
                                                          'null' for a
                                                          defined metric
                                                          without a
                                                          value.<br>
                                                          <br>
                                                          Regards,<br>
                                                          Michael<br>
                                                          <br>
                                                          <br>
                                                          <div>Am
                                                          08.11.22 um
                                                          13:46 schrieb
                                                          Michael
                                                          Geddes:<br>
                                                          </div>
                                                          <blockquote type="cite">
                                                          <div dir="ltr">
                                                          <div>Ah yes.
                                                          Arrays - will
                                                          check those. 
                                                          Yeah, how
                                                          about we add a
                                                          'IsDefined'
                                                          method to
                                                          metrics
                                                          instead of the
                                                          null thing (it
                                                          does sound
                                                          like it will
                                                          upset too many
                                                          applecarts).</div>
                                                          <div><br>
                                                          </div>
                                                          <div>//.</div>
                                                          <br>
                                                          <div class="gmail_quote">
                                                          <div dir="ltr" class="gmail_attr">On Tue, 8 Nov 2022 at 20:35, Michael Balzer <<a href="mailto:dexter@expeedo.de" target="_blank">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>
                                                          looks all good
                                                          to me, once
                                                          again nice
                                                          find with the
                                                          decode
                                                          argument.
                                                          Adding decode
                                                          to the Value()
                                                          call was only
                                                          for symmetry
                                                          IIRC, the main
                                                          use was with
                                                          GetValues() (<a href="https://docs.openvehicles.com/en/latest/userguide/scripting.html#ovmsmetrics" target="_blank">https://docs.openvehicles.com/en/latest/userguide/scripting.html#ovmsmetrics</a>).<br>
                                                          <br>
                                                          Don't forget
                                                          to test
                                                          arrays, e.g.
                                                          "v.t.pressure"
                                                          &
                                                          "v.t.temp".<br>
                                                          <br>
                                                          Returning null
                                                          for an
                                                          undefined
                                                          metric seems
                                                          like a natural
                                                          choice, but is
                                                          a rather deep
                                                          change, as for
                                                          consistency
                                                          not only the
                                                          Duktape
                                                          metrics API
                                                          but also the
                                                          Web UI metrics
                                                          API would need
                                                          to be changed
                                                          accordingly.
                                                          Unless you've
                                                          got a real use
                                                          case that
                                                          needs that, we
                                                          should be
                                                          careful.<br>
                                                          <br>
                                                          Regards,<br>
                                                          Michael<br>
                                                          <br>
                                                          <br>
                                                          <div>Am
                                                          07.11.22 um
                                                          15:00 schrieb
                                                          Michael
                                                          Geddes:<br>
                                                          </div>
                                                          <blockquote type="cite">
                                                          <div dir="ltr">
                                                          <div dir="ltr">I
                                                          have figured
                                                          out a bunch of
                                                          stuff and have
                                                          implemented
                                                          the following:
                                                          (having done
                                                          away with
                                                          needing
                                                          AsFloatUnit)
                                                          <div><br>
                                                          </div>
                                                          <div>OvmsMetrics.Value(
                                                          {metric} [,
                                                          {decode}])</div>
                                                          <div>OvmsMetrics.Value(
                                                          {metric},
                                                          {unit}
                                                          [,{decode}])</div>
                                                          <div><br>
                                                          </div>
                                                          <div>It turns
                                                          out that the
                                                          [decode] flag
                                                          wasn't working
                                                          anyway (since
                                                          the function
                                                          was being
                                                          registered as
                                                          only having 1
                                                          param)...</div>
                                                          <div>This way
                                                          it is still
                                                          really 1
                                                          function.. but
                                                          I check it the
                                                          second
                                                          parameter is a
                                                          'boolean', and
                                                          if not.. try
                                                          the second
                                                          form. </div>
                                                          <div><br>
                                                          </div>
                                                          <div>OvmsMetrics.AsFloat(
                                                          {metric}
                                                          [,{unit}] )</div>
                                                          <div><br>
                                                          </div>
                                                          <div>and add
                                                          the function</div>
                                                          <div><br>
                                                          </div>
                                                          <div>Ovms.Metrics.ValueUnit(
                                                          {metric}
                                                          [,{unit}]) </div>
                                                          <div>This
                                                          prints the
                                                          value and the
                                                          unit.</div>
                                                          <div><br>
                                                          </div>
                                                          <div>Here's a
                                                          sample
                                                          function and
                                                          the output!
                                                          This also
                                                          shows the
                                                          types of the
                                                          output.</div>
                                                          <div><br>
                                                          </div>
                                                          <div><font face="monospace">(function()
                                                          {<br>
                                                             x =
                                                          OvmsMetrics.Value("xiq.v.trip.consumption");<br>
                                                             print(
                                                          (typeof x) +
                                                          ": "+  x+"\n"
                                                           );<br>
                                                             x =
                                                          OvmsMetrics.Value("xiq.v.trip.consumption",
                                                          false);<br>
                                                             print(
                                                          (typeof x) +
                                                          ": "+  x +"\n"
                                                          );<br>
                                                             x =
                                                           OvmsMetrics.Value("xiq.v.trip.consumption","kmpkwh")<br>
                                                             print(
                                                          (typeof x) +
                                                          ": "+ x
                                                          +"\n");<br>
                                                             x =
                                                           OvmsMetrics.Value("xiq.v.trip.consumption",
                                                          "mipkwh",
                                                          false) <br>
                                                             print(
                                                          (typeof x) +
                                                          ": "+ x
                                                          +"\n");<br>
                                                             x =
                                                           OvmsMetrics.ValueUnit("xiq.v.trip.consumption")<br>
                                                             print(
                                                          (typeof x) +
                                                          ": "+ x
                                                          +"\n");<br>
                                                             x =
                                                           OvmsMetrics.ValueUnit("xiq.v.trip.consumption","mipkwh")<br>
                                                             print(
                                                          (typeof x) +
                                                          ": "+ x
                                                          +"\n");<br>
                                                             x =
                                                           OvmsMetrics.AsFloat("xiq.v.trip.consumption")<br>
                                                             print(
                                                          (typeof x) +
                                                          ": "+ x
                                                          +"\n");<br>
                                                             x =
                                                           OvmsMetrics.AsFloat("xiq.v.trip.consumption","kmpkwh")<br>
                                                             print(
                                                          (typeof x) +
                                                          ": "+ x
                                                          +"\n");<br>
                                                          })();</font><br>
                                                          </div>
                                                          <div><br>
                                                          </div>
                                                          <div>
                                                          <pre id="m_-5441616086226233372m_8405494616978842232m_-5904723395924573806m_1733173679174480992m_-138117451584655546m_5484224439251412587m_-6783916119872647666m_7514939671383041717m_-2249740601380801512gmail-output" style="box-sizing:border-box;overflow:auto;font-family:ui-monospace,"Cascadia Mono","Segoe UI Mono",Hack,"Source Code Pro","Roboto Mono",Menlo,Monaco,Consolas,monospace;font-size:13px;padding:9.5px;margin-top:0px;margin-bottom:10px;line-height:1.42857;color:rgb(0,34,0);word-break:break-all;background-color:rgb(245,245,245);border:1px solid rgb(204,204,204);border-radius:4px;height:165px;white-space:pre-wrap">number: 17.0582
string: 17.0582
number: 5.86227
string: 3.64264
string: 17.0582kWh/100km
string: 3.64264mi/kWh
number: 17.0582
number: 5.86227</pre>
                                                          </div>
                                                          <div><br>
                                                          </div>
                                                          <div><br>
                                                          </div>
                                                          <div>It still
                                                          might be an
                                                          idea to use
                                                          'null' as a
                                                          return value
                                                          if the metrics
                                                          is<font face="monospace">
                                                          !IsDefined() </font><font face="arial,
                                                          sans-serif">but
                                                          that would be
                                                          changing the
                                                          existing
                                                          behaviour
                                                          slightly.</font></div>
                                                          <div><font face="arial,
                                                          sans-serif"><br>
                                                          </font></div>
                                                          <div><font face="arial,
                                                          sans-serif">//.ichael</font></div>
                                                          <div><br>
                                                          </div>
                                                          </div>
                                                          <div class="gmail_quote">
                                                          <div dir="ltr" class="gmail_attr">On Mon, 7 Nov 2022 at 08:12, Michael Geddes <<a href="mailto:frog@bunyip.wheelycreek.net" target="_blank">frog@bunyip.wheelycreek.net</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 dir="ltr">I've
                                                          worked out
                                                          what the
                                                          decode flag is
                                                          for and how it
                                                          works, and I
                                                          think how
                                                          optional
                                                          params work. <br>
                                                          <div>I'm
                                                          pretty sure I
                                                          won't  need
                                                          the
                                                          'AsFloatUnit'
                                                          function; the
                                                          unit would be
                                                          an option to
                                                          AsFloat();
                                                          I'll know that
                                                          soon.</div>
                                                          <div><br>
                                                          </div>
                                                          <div>The
                                                          'Value'
                                                          function is
                                                          more
                                                          complicated
                                                          because of the
                                                          optional
                                                          decode bool. I
                                                          guess I could
                                                          add the Unit
                                                          to the end of
                                                          that.</div>
                                                          <div><br>
                                                          </div>
                                                          <div>ValueUnit
                                                          could be still
                                                          useful then to
                                                          provide a
                                                          'Value +
                                                          Unit'.</div>
                                                          <div><br>
                                                          </div>
                                                          <div>Question: 
                                                          Is there a
                                                          reason we
                                                          shouldn't be
                                                          returning
                                                          with  <span style="color:rgb(220,220,170);background-color:rgb(30,30,30);font-family:Consolas,"Courier New",monospace;font-size:14px;white-space:pre-wrap">duk_push_null</span> 
                                                            if the
                                                          metric
                                                          !IsDefined() 
                                                          in both
                                                          AsFloat() and
Value(metric,true) cases?</div>
                                                          <div><br>
                                                          </div>
                                                          <div>//.ichael</div>
                                                          </div>
                                                          <br>
                                                          <div class="gmail_quote">
                                                          <div dir="ltr" class="gmail_attr">On Sun, 6 Nov 2022 at 11:22, Michael Geddes <<a href="mailto:frog@bunyip.wheelycreek.net" target="_blank">frog@bunyip.wheelycreek.net</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 dir="ltr">
                                                          <div>Right, so
                                                          I've
                                                          implemented
                                                          some stuff
                                                          that seems to
                                                          work quite
                                                          well. <br>
                                                          </div>
                                                          <div><br>
                                                          </div>
                                                          <div><a href="https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/pull/764" target="_blank">https://github.com/openvehicles/Open-Vehicle-Monitoring-System-3/pull/764</a> 
                                                          should be
                                                          ready now
                                                          after a couple
                                                          of stupid
                                                          mistakes
                                                          slipped
                                                          through. 
                                                           This
                                                          absolutely
                                                          needs somebody
                                                          to review it
                                                          please!
                                                          (There's a
                                                          reason why
                                                          I've converted
                                                          some if()'s to
                                                          switch() -
                                                          which is that
                                                          it will be
                                                          used in the
                                                          follow-up
                                                          commit).</div>
                                                          <div><br>
                                                          </div>
                                                          <div>The
                                                          commit that
                                                          will follow on
                                                          from that it
                                                          implements the
                                                          new Units:
                                                          kWh/100km,
                                                          km/kWh  and 
                                                          mi/kWh.</div>
                                                          <div><br>
                                                          </div>
                                                          <div>This is a
                                                          summary of
                                                          what I've
                                                          implemented
                                                          for scripting
                                                          - including
                                                          showing the
                                                          unit codes I
                                                          have so far. 
                                                          I've
                                                          considered a
                                                          few things:</div>
                                                          <div>  *
                                                          Should some of
                                                          the longer
                                                          unit codes be
                                                          shortened  (eg
                                                          mi, mins, m,
                                                          ft, deg, perc)</div>
                                                          <div>  * The
                                                          unit codes
                                                          could be much
                                                          more re<font face="arial,
                                                          sans-serif">gular
                                                          and separated
                                                          by dots  eg:  </font></div>
                                                          <div><font face="arial,
                                                          sans-serif"> 
                                                               
                                                          watthours
                                                          -> w.h</font></div>
                                                          <div><font face="arial,
                                                          sans-serif"> 
                                                               
                                                          kwhp100km
                                                          ->
                                                          kw.h_100km or
                                                          kw.h/100km</font></div>
                                                          <div><font face="arial,
                                                          sans-serif"> 
                                                                miph
                                                          ->  mi_h or
                                                          mi/h  (or
                                                          should it be
                                                          mph).</font></div>
                                                          <div><font face="arial,
                                                          sans-serif"> 
                                                                psi
                                                          -> <a href="http://p_in.in/" target="_blank">p_in.in</a> or p/<a href="http://in.in/" target="_blank">in.in</a> or <a href="http://lb_in.in/" target="_blank">lb_in.in</a> (yes, slightly
                                                          weird, but
                                                          predictable)</font></div>
                                                          <div><font face="arial,
                                                          sans-serif"> </font><br>
                                                          </div>
                                                          <b style="font-family:monospace">OVMS#
                                                          metric units</b><br>
                                                          <font face="monospace"> 
                                                                  km :
                                                          km</font><br>
                                                          <font face="monospace"> 
                                                               miles : M</font><br>
                                                          <font face="monospace"> 
                                                              meters : m</font><br>
                                                          <font face="monospace"> 
                                                                feet :
                                                          ft</font><br>
                                                          <font face="monospace"> 
                                                             celcius :
                                                          °C</font><br>
                                                          <font face="monospace"> 
                                                          fahrenheit :
                                                          °F</font><br>
                                                          <font face="monospace"> 
                                                                 kpa :
                                                          kPa</font><br>
                                                          <font face="monospace"> 
                                                                  pa :
                                                          Pa</font><br>
                                                          <font face="monospace"> 
                                                                 psi :
                                                          psi</font><br>
                                                          <font face="monospace"> 
                                                               volts : V</font><br>
                                                          <font face="monospace"> 
                                                                amps : A</font><br>
                                                          <font face="monospace"> 
                                                            </font>amphours<font face="monospace"> : Ah</font><br>
                                                          <font face="monospace"> 
                                                                  kw :
                                                          kW</font><br>
                                                          <font face="monospace"> 
                                                                 kwh :
                                                          kWh</font><br>
                                                          <font face="monospace"> 
                                                               watts : W</font><br>
                                                          <font face="monospace"> 
                                                           </font>watthours<font face="monospace"> : Wh</font><br>
                                                          <font face="monospace"> 
                                                             seconds :
                                                          Sec</font><br>
                                                          <font face="monospace"> 
                                                             minutes :
                                                          Min </font><br>
                                                          <font face="monospace"> 
                                                               hours :
                                                          Hour</font><br>
                                                          <font face="monospace"> 
                                                                 utc :
                                                          UTC</font><br>
                                                          <font face="monospace"> 
                                                             degrees : °</font><br>
                                                          <font face="monospace"> 
                                                                kmph :
                                                          km/h</font><br>
                                                          <font face="monospace"> 
                                                                </font>miph<font face="monospace"> : Mph</font><br>
                                                          <font face="monospace"> 
                                                              </font>kmphps<font face="monospace"> : km/h/s</font><br>
                                                          <font face="monospace"> 
                                                              </font>miphps<font face="monospace"> : Mph/s</font><br>
                                                          <font face="monospace"> 
                                                                mpss :
                                                          m/s²</font><br>
                                                          <font face="monospace"> 
                                                                 dbm :
                                                          dBm</font><br>
                                                          <font face="monospace"> 
                                                                  sq :
                                                          sq</font><br>
                                                          <font face="monospace"> 
                                                             percent : %</font><br>
                                                          <font face="monospace"> 
                                                               whpkm :
                                                          Wh/km</font><br>
                                                          <font face="monospace"> 
                                                               </font>whpmi<font face="monospace"> : Wh/mi</font><br>
                                                          <font face="monospace"> 
                                                           kwhp100km :
                                                          kWh/100km</font><br>
                                                          <font face="monospace"> 
                                                              </font>kmpkwh<font face="monospace"> : km/kWh</font><br>
                                                          <font face="monospace"> 
                                                              </font>mipkwh<font face="monospace"> : mi/kWh</font><br>
                                                          <font face="monospace"> 
                                                                  nm :
                                                          Nm</font><br>
                                                          <font face="monospace"><br>
                                                          <b>OVMS#
                                                          metric unit mi</b><br>
                                                                 miles :
                                                          M<br>
                                                               minutes :
                                                          Min<br>
                                                                  miph :
                                                          Mph<br>
                                                                miphps :
                                                          Mph/s<br>
                                                                 whpmi :
                                                          Wh/mi<br>
                                                                mipkwh :
                                                          mi/kWh</font><br>
                                                          <br>
                                                          <b style="font-family:monospace">OVMS#
                                                          metric get
                                                          xiq.v.trip.consumption<br>
                                                          </b><font face="monospace">17.0597kWh/100km</font><br>
                                                          <b style="font-family:monospace">OVMS#
                                                          metric get
                                                          xiq.v.trip.consumption
                                                          kpkwh<br>
                                                          </b><font face="monospace">5.86177km/kWh</font><br>
                                                          <b style="font-family:monospace">OVMS#
                                                          metric get
                                                          xiq.v.trip.consumption
                                                          mpkwh<br>
                                                          </b><font face="monospace">3.64233mi/kWh</font><br>
                                                          <br>
                                                          <b style="font-family:monospace">OVMS#
                                                          metric set
                                                          xiq.c.speed 5
                                                          miph<br>
                                                          </b><font face="monospace">Metric
                                                          set</font><br>
                                                          <b style="font-family:monospace">OVMS#
                                                          metric get
                                                          xiq.c.speed<br>
                                                          </b><font face="monospace">8.04673km/h</font><br>
                                                          <b style="font-family:monospace">OVMS#
                                                          metric get
                                                          xiq.c.speed
                                                          miph<br>
                                                          </b><font face="monospace">5Mph</font><br>
                                                          <br>
                                                          <font face="arial,
                                                          sans-serif">And
                                                          then in
                                                          DukTape -
                                                          there are some
                                                          questions I
                                                          have about the
implementation:</font>
                                                          <div><font face="arial,
                                                          sans-serif">*
                                                          Names of
                                                          functions?
                                                          Better ideas? </font></div>
                                                          <div><font face="arial,
                                                          sans-serif">*
                                                          Should
                                                          ValueUnit
                                                          output the
                                                          units?</font></div>
                                                          <div><font face="arial,
                                                          sans-serif">*
                                                          In Value()
                                                          there is the
                                                          line  </font> 
                                                          bool decode =
duk_opt_boolean(ctx, 1, true);</div>
                                                          <div>    *
                                                          What does
                                                          'decode' mean
                                                          here?</div>
                                                          <div>    * Do
                                                          I need it for
                                                          ValueUnit() ?</div>
                                                          <div><br>
                                                          <div><b><br>
                                                          <font face="monospace">(function()
                                                          {</font><br>
                                                          <font face="monospace"> 
                                                           print(
                                                          OvmsMetrics.Value("xiq.v.trip.consumption"));</font><br>
                                                          <font face="monospace"> 
                                                           print("\n")</font><br>
                                                          <font face="monospace"> 
                                                           print(
                                                          OvmsMetrics.ValueUnit("xiq.v.trip.consumption",""));</font><br>
                                                          <font face="monospace"> 
                                                           print("\n")</font><br>
                                                          <font face="monospace"> 
                                                           print(
                                                          OvmsMetrics.ValueUnit("xiq.v.trip.consumption","</font>mipkwh<font face="monospace">"));</font><br>
                                                          <font face="monospace"> 
                                                           print("\n")</font><br>
                                                          <br>
                                                          <font face="monospace"> 
                                                           print(
                                                          OvmsMetrics.AsFloatUnit("xiq.v.trip.consumption","</font>kmpkwh<font face="monospace">"));</font><br>
                                                          <font face="monospace">})();</font></b><br>
                                                          <font face="monospace">---
                                                          Output ---</font><br>
                                                          <font face="monospace">17.0597</font><br>
                                                          <font face="monospace">17.0597kWh/100km</font><br>
                                                          <font face="monospace">3.64233mi/kWh</font><br>
                                                          <font face="monospace">5.86177</font><br>
                                                          <font face="monospace">------</font><br>
                                                          <br>
                                                          </div>
                                                          </div>
                                                          <div>The basic
                                                          stuff all
                                                          works - it's
                                                          just quibbling
                                                          over the
                                                          details.. but
                                                          let's get them
                                                          right!</div>
                                                          <div><br>
                                                          </div>
                                                          <div>//.ichael</div>
                                                          </div>
                                                          <br>
                                                          <div class="gmail_quote">
                                                          <div dir="ltr" class="gmail_attr">On Sat, 5 Nov 2022 at 20:09, Michael Geddes <<a href="mailto:frog@bunyip.wheelycreek.net" target="_blank">frog@bunyip.wheelycreek.net</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 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" target="_blank">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>
                                                          </blockquote>
                                                          </div>
                                                          </blockquote>
                                                          </div>
                                                          </blockquote>
                                                          </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>
                                                          <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>
                                                      </div>
                                                    </div>
                                                    <br>
                                                  </div>
                                                </div>
                                              </blockquote>
                                            </div>
                                            <br>
                                          </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>
                                    </blockquote>
                                  </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>
                      </blockquote>
                    </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>
        </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>