<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    Think of the tracing control in terms of a UI context: you would
    normally represent the bits by checkboxes, which could either react
    immediately on change or combined by a "Configure" button. In either
    case, you'd curse an API for needing different commands to be called
    depending on which checkbox combination has been set.<br>
    <br>
    Exposing bits directly (sort of) though is new to our API, not sure
    if I would do that. I'd rather introduce a call with an object
    argument for readability, resulting in an API call like …<br>
    <br>
    <font face="monospace">    OvmsPoller.Trace({ poller: true, txrx:
      false });</font><br>
    <br>
    … with defaults false for both members, so both are optional.
    Accordingly, `OvmsPoller.GetTraceStatus()` would return that very
    same object.<br>
    <br>
    Regards,<br>
    Michael<br>
    <br>
    <br>
    <div class="moz-cite-prefix">Am 07.07.24 um 02:43 schrieb Michael
      Geddes:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAH0p7uKWwMKW+N2-66uNnVTwpVX-9P2dOkTfW=cPOOG0FE5FbQ@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Soo.. for the start stop of the Poller itself we
        still have
        <blockquote style="margin:0 0 0 40px;border:none;padding:0px">
          <div><font face="monospace">OvmsPoller.Pause</font></div>
          <div><font face="monospace">OvmsPoller.Resume</font></div>
        </blockquote>
        <blockquote style="margin:0 0 0 40px;border:none;padding:0px">
          <div><font face="monospace">print(OvmsPoller.GetUserPaused())</font></div>
        </blockquote>
        <div>then for the timer we now have</div>
        <blockquote style="margin:0 0 0 40px;border:none;padding:0px">
          <div><font face="monospace">OvmsPoller.Times.Start</font></div>
          <span style="font-family:monospace">OvmsPoller.Times.Stop</span>
          <div><font face="monospace">print(</font>
            <span style="font-family:monospace">OvmsPoller.Times.GetStarted())</span> </div>
        </blockquote>
        <div>
          <div><br>
          </div>
          <div>For the tracing (which is simply setting 2 bits) I'm torn
            between having the following mirroring the commands:</div>
        </div>
        <blockquote style="margin:0 0 0 40px;border:none;padding:0px">
          <div>
            <div><font face="monospace">OvmsPoller.Trace.On(), </font></div>
          </div>
          <div>
            <div><font face="monospace">OvmsPoller.Trace.TxRx()</font></div>
          </div>
          <div>
            <div><font face="monospace">OvmsPoller.Trace.AllOn()</font></div>
          </div>
          <div>
            <div><font face="monospace">OvmsPoller.Trace.Off()</font></div>
          </div>
        </blockquote>
        <blockquote style="margin:0 0 0 40px;border:none;padding:0px">
          <div><font face="monospace">print(OvmsPoller.Trace.GetStatus())</font></div>
        </blockquote>
        <div>
          <div>Or to have 2 properties  'Trace.Poller' and 'Trace.TxRx'
            with "C" getter/setter (which I have implemented
            successfully)</div>
        </div>
        <blockquote style="margin:0 0 0 40px;border:none;padding:0px">
          <div>
            <div><font face="monospace">OvmsPoller.Trace.Poller = true</font></div>
          </div>
          <div>
            <div><font face="monospace">OvmsPoller.Trace.TxRx = false</font></div>
          </div>
          <div><font face="monospace">print(OvmsPoller.Trace.Poller)</font></div>
        </blockquote>
        <div><br>
        </div>
        <div>I don't know about the existing GetTrace() and
          SetTrace("on") - it does work but it's a bit clunky</div>
        <div><br>
        </div>
        The registering of the getter/setters was a bit of work - but in
        the end looks like this in code!<br>
        <blockquote style="margin:0 0 0 40px;border:none;padding:0px">
          <div>  Dukta<font face="monospace">peObjectRegistration*
              dto_trace =</font></div>
          <div><font face="monospace">    new
              DuktapeObjectRegistration("OvmsPollerTrace");</font></div>
          <div><font face="monospace"> 
dto_trace->RegisterDuktapeProperty(DukOvmsPollerTracePollerGet,DukOvmsPollerTracePollerSet,
              0, "Poller");</font></div>
          <div><font face="monospace"> 
dto_trace->RegisterDuktapeProperty(DukOvmsPollerTraceTxRxGet,DukOvmsPollerTraceTxRxSet,
              0, "TxRx");</font></div>
          <div><font face="monospace"> 
              dto->RegisterDuktapeObject(dto_trace, "Trace");</font></div>
        </blockquote>
        <div><br>
        </div>
        <div>I do like the splitting of functionality using 'Trace' and
          'Times' to mirror sub-commands.</div>
        <div><br>
        </div>
        <div>Thoughts?</div>
        <div><br>
        </div>
        <div>//.ichael</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Sat, 6 Jul 2024 at 16:07,
          Michael Geddes <<a
            href="mailto:frog@bunyip.wheelycreek.net"
            moz-do-not-send="true" class="moz-txt-link-freetext">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="auto">
            <div dir="auto">I'll change SetUserPaused. I flip flopped a
              bit on that so  happy to go with your suggestion which
              makes sense.</div>
            <div dir="auto"><br>
            </div>
            <div>The order doesn't matter on the dictionary.  A lot of
              JSON serialised like to alphabetise so aware of that.</div>
            <div dir="auto">Anyway internally it's a map which doesn't
              guarantee order afaik. Could be in hash order anyway!</div>
            <div dir="auto"><br>
            </div>
            <div dir="auto">Also That's partly why I had separate total
              properties on the base object.</div>
            <div dir="auto"><br>
            </div>
            <div dir="auto">Michael. <br>
              <br>
              <div class="gmail_quote" dir="auto">
                <div dir="ltr" class="gmail_attr">On Sat, 6 July 2024,
                  14:54 Michael Balzer via OvmsDev, <<a
                    href="mailto:ovmsdev@lists.openvehicles.com"
                    target="_blank" moz-do-not-send="true"
                    class="moz-txt-link-freetext">ovmsdev@lists.openvehicles.com</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 to me.<br>
                    <br>
                    IMO API calls representing direct shell commands
                    should not be represented as getters/setters in the
                    JS API, so ".Pause()" & ".Resume()" are better.
                    They are also more readable (e.g. "Resume()" vs
                    "SetUserPaused(false)") and leave room for future
                    command specific arguments.<br>
                    <br>
                    Using an object structure is OK for the times,
                    unless you want/need to make sure the same order as
                    with the other outputs (shell/data) will be kept
                    stable on any object transformation or transfer.
                    Object properties (if they are strings) are normally
                    kept in insertion order, but only within Javascript.
                    When deserializing JS objects into other
                    environments, the order isn't guaranteed.<br>
                    <br>
                    Regards,<br>
                    Michael<br>
                    <br>
                    <br>
                    <div>Am 06.07.24 um 03:12 schrieb Michael Geddes via
                      OvmsDev:<br>
                    </div>
                    <blockquote type="cite">
                      <div dir="ltr">
                        <div>please have a good look at the function
                          names.. when I have Get and Set prefixes..
                          should I have them.. etc to be consistent.</div>
                        <div><br>
                        </div>
                        <div>But  Just FYI (a couple of silly bugs
                          later) - This is the full output from a test
                          proving that both the 'Times' property works
                          and that at least as a concept- having the
                          "Poll:PRI" as a key works.</div>
                        <div>//.</div>
                        <div>----8<-------------------</div>
                        <div dir="ltr"><br>
                          <div><font
                              style="background-color:rgb(207,226,243)"
                              face="monospace">JSON.print(OvmsPoller.Times.GetStatus())</font><br>
                            <font
                              style="background-color:rgb(238,238,238)"
                              face="monospace"><br>
                              {<br>
                                "items": {<br>
                                  "Poll:PRI": {<br>
                                    "count_hz": 1.00600004196167,<br>
                                    "avg_util_pm": 0.5598000288009644,<br>
                                    "peak_util_pm": 0.6503999829292297,<br>
                                    "avg_time_ms": 0.05350000038743019,<br>
                                    "peak_time_ms": 0.9779999852180481<br>
                                  },<br>
                                  "Poll:SRX": {<br>
                                    "count_hz": 1.1330000162124634,<br>
                                    "avg_util_pm": 0.18970000743865967,<br>
                                    "peak_util_pm": 0.23240000009536743,<br>
                                    "avg_time_ms": 0.015799999237060547,<br>
                                    "peak_time_ms": 0.3319999873638153<br>
                                  },<br>
                                  "RxCan1[778]": {<br>
                                    "count_hz": 1.8489999771118164,<br>
                                    "avg_util_pm": 1.2870999574661255,<br>
                                    "peak_util_pm": 1.8909000158309937,<br>
                                    "avg_time_ms": 0.06909999996423721,<br>
                                    "peak_time_ms": 2.7119998931884766<br>
                                  },<br>
                                  "RxCan1[7bb]": {<br>
                                    "count_hz": 0.2240000069141388,<br>
                                    "avg_util_pm": 0.10409999638795853,<br>
                                    "peak_util_pm": 0.25859999656677246,<br>
                                    "avg_time_ms": 0.043800000101327896,<br>
                                    "peak_time_ms": 1.50600004196167<br>
                                  },<br>
                                  "RxCan1[7ea]": {<br>
                                    "count_hz": 1.0670000314712524,<br>
                                    "avg_util_pm": 0.4699000120162964,<br>
                                    "peak_util_pm": 0.7283999919891357,<br>
                                    "avg_time_ms": 0.04830000177025795,<br>
                                    "peak_time_ms": 1.5379999876022339<br>
                                  },<br>
                                  "RxCan1[7ec]": {<br>
                                    "count_hz": 1.8669999837875366,<br>
                                    "avg_util_pm": 0.8090000152587891,<br>
                                    "peak_util_pm": 0.9458000063896179,<br>
                                    "avg_time_ms": 0.04639999940991402,<br>
                                    "peak_time_ms": 2.2769999504089355<br>
                                  },<br>
                                  "TxCan1[770]": {<br>
                                    "count_hz": 0.9240000247955322,<br>
                                    "avg_util_pm": 0.039400000125169754,<br>
                                    "peak_util_pm":
                              0.054499998688697815,<br>
                                    "avg_time_ms":
                              0.0038999998942017555,<br>
                                    "peak_time_ms": 0.08699999749660492<br>
                                  },<br>
                                  "TxCan1[7b3]": {<br>
                                    "count_hz": 0.041999999433755875,<br>
                                    "avg_util_pm":
                              0.0035000001080334187,<br>
                                    "peak_util_pm":
                              0.008299999870359898,<br>
                                    "avg_time_ms": 0.008500000461935997,<br>
                                    "peak_time_ms": 0.09200000017881393<br>
                                  },<br>
                                  "TxCan1[7e2]": {<br>
                                    "count_hz": 0.21199999749660492,<br>
                                    "avg_util_pm": 0.01600000075995922,<br>
                                    "peak_util_pm":
                              0.020500000566244125,<br>
                                    "avg_time_ms": 0.006800000090152025,<br>
                                    "peak_time_ms": 0.08500000089406967<br>
                                  },<br>
                                  "TxCan1[7e4]": {<br>
                                    "count_hz": 0.21199999749660492,<br>
                                    "avg_util_pm": 0.006899999920278788,<br>
                                    "peak_util_pm":
                              0.009800000116229057,<br>
                                    "avg_time_ms": 0.002899999963119626,<br>
                                    "peak_time_ms": 0.05299999937415123<br>
                                  },<br>
                                  "Cmd:Thrtl": {<br>
                                    "count_hz": 0.014999999664723873,<br>
                                    "avg_util_pm":
                              0.0006000000284984708,<br>
                                    "peak_util_pm": 0,<br>
                                    "avg_time_ms": 0.004699999932199717,<br>
                                    "peak_time_ms": 0.04699999839067459<br>
                                  },<br>
                                  "Cmd:State": {<br>
                                    "count_hz": 0.039000000804662704,<br>
                                    "avg_util_pm": 0.002300000051036477,<br>
                                    "peak_util_pm":
                              0.007000000216066837,<br>
                                    "avg_time_ms": 0.006500000134110451,<br>
                                    "peak_time_ms": 0.09000000357627869<br>
                                  }<br>
                                },<br>
                                "tot_count_hz": 8.59000015258789,<br>
                                "tot_util_pm": 3.488300085067749,<br>
                                "tot_time_ms": 3.1019999980926514<br>
                              }</font></div>
                        </div>
                        <br>
                        <div class="gmail_quote">
                          <div dir="ltr" class="gmail_attr">On Wed, 3
                            Jul 2024 at 14:31, Michael Geddes <<a
                              href="mailto:frog@bunyip.wheelycreek.net"
                              rel="noreferrer" target="_blank"
                              moz-do-not-send="true"
                              class="moz-txt-link-freetext">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">OH, and also,
                              <div><br>
                              </div>
                              <div>What do you think of treating the O<span
                                  style="font-family:monospace">vmsPoller.Times.GetStatus()
                                </span><font face="arial, sans-serif">items
                                  as an associative array - or should I
                                  treat it as a normal array?</font></div>
                              <div><font face="arial, sans-serif"><br>
                                </font></div>
                              <div><font face="arial, sans-serif">//.ichael</font></div>
                            </div>
                            <br>
                            <div class="gmail_quote">
                              <div dir="ltr" class="gmail_attr">On Wed,
                                3 Jul 2024 at 14:24, Michael Geddes <<a
href="mailto:frog@bunyip.wheelycreek.net" rel="noreferrer"
                                  target="_blank" moz-do-not-send="true"
                                  class="moz-txt-link-freetext">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 figured I may as well
                                  add an OvmsPoller object to DukTape
                                  for Ovms.   I'm waiting to get back to
                                  my OVMS so that I can test it.. but
                                  this is the documentation I have for
                                  the stuff I have coded. Thoughts on
                                  this?
                                  <div><br>
                                  </div>
                                  <div>What do people think of
                                    OvmsPoller.Times sub-object?   I've
                                    added a general mechanism for
                                    this.  </div>
                                  <div><br>
                                  </div>
                                  <div>Also should I have
                                    OvmsPoller.Pause()  or
                                    OvmsPoller.SetUserPaused(true)  ?</div>
                                  <div>//.</div>
                                  <div><br>
                                  </div>
                                  <div><br>
                                  </div>
                                  <div><font face="monospace">OvmsPoller<br>
                                      ^^^^^^^^^^<br>
                                      The Ovms Poller object represents
                                      the poller sub-system. It contains
                                      the following methods:<br>
                                      <br>
                                      - ``ispaused =
                                      OvmsPoller.GetPaused()``: Return
                                      true if the poller is paused by
                                      the system/user.<br>
                                      - ``ispaused =
                                      OvmsPoller.GetUserPaused()``:
                                      Return true if the poller is
                                      paused by the user.<br>
                                      - ``OvmsPoller.Pause()``: Pause
                                      the poller (adds User poller
                                      pause)<br>
                                      - ``OvmsPoller.Resume()``: Remove
                                      the User poller pause.<br>
                                      <br>
                                      - ``tracemode =
                                      OvmsPoller.GetTrace()``: Return
                                      the current trace mode.<br>
                                      -
                                      ``OvmsPoller.SetTrace(tracemode)``:
                                      Set the current trace mode.<br>
                                      <br>
                                          The Traces still require that
                                      'Verbose' and 'Debug' levels
                                      (depending) for the 'vehicle-poll'<br>
                                          debug tag are set.<br>
                                          Trace modes for verbose
                                      logging can be one of:<br>
                                          - ``on``: On for poller loop<br>
                                          - ``txrx``: On for txrx queue
                                      (this can be hazardous for some
                                      cars)<br>
                                          - ``all``: On for both poller
                                      loop and txrx queuing<br>
                                          - ``off``: Logging Off<br>
                                          Note that only ``on`` and
                                      ``off`` are recommended.<br>
                                      <br>
                                      The poller object also contains a
                                      ``Times`` property for the OBD
                                      Poll-Time tracing<br>
                                      which contains the following
                                      methods:<br>
                                      - ``isrunning =
                                      OvmsPoller.Times.GetEnabled()``:
                                      Returns true if the time-tracing
                                      is enabled<br>
                                      -
                                      ``OvmsPoller.Times.SetEnabled(isrunning)``:
                                      Sets the enabled status of the
                                      timer-tracing<br>
                                      - ``OvmsPoller.Times.Reset()``:
                                      Reset the timers (doesn't affect
                                      their current state).<br>
                                      -
                                      ``OvmsPoller.Times.GetStatus()``:
                                      Gets the status of the various
                                      times. This returns an object<br>
                                          of this format:<br>
                                          .. code-block:: javascript<br>
                                          return_value = {<br>
                                            "items": {<br>
                                              "Poll:PRI" : {<br>
                                                "count_hz":    1,<br>
                                                "avg_util_pm": 0.529,<br>
                                                "peak_util_pm":0.652,<br>
                                                "avg_time_ms": 0.052,<br>
                                                "peak_time_ms":1.516<br>
                                              },<br>
                                              "Poll:SRX": {<br>
                                                "count_hz":    1.47,<br>
                                                "avg_util_pm": 0.302,<br>
                                                "peak_util_pm":0.44,<br>
                                                "avg_time_ms": 0.02,<br>
                                                "peak_time_ms":0.573<br>
                                              },<br>
                                              "RxCan1[778]": {<br>
                                                "count_hz":    0.74,<br>
                                                "avg_util_pm": 0.427,<br>
                                                "peak_util_pm":0.826,<br>
                                                "avg_time_ms": 0.063,<br>
                                                "peak_time_ms":1.872<br>
                                              },<br>
                                              "RxCan1[7a8]": {<br>
                                                "count_hz":    0.35,<br>
                                                "avg_util_pm": 0.183,<br>
                                                "peak_util_pm":0.355,<br>
                                                "avg_time_ms": 0.052,<br>
                                                "peak_time_ms":1.382<br>
                                              },<br>
                                              "TxCan1[7b3]": {<br>
                                                "count_hz":    0.07,<br>
                                                "avg_util_pm": 0.005,<br>
                                                "peak_util_pm":0.01,<br>
                                                "avg_time_ms": 0.007,<br>
                                                "peak_time_ms":0.099<br>
                                              },<br>
                                              "TxCan1[7c6]": {<br>
                                                "count_hz":    0,<br>
                                                "avg_util_pm": 0,<br>
                                                "peak_util_pm":0.009,<br>
                                                "avg_time_ms": 0.004,<br>
                                                "peak_time_ms":0.098<br>
                                              },<br>
                                              "Cmd:State": {<br>
                                                "count_hz":    0,<br>
                                                "avg_util_pm": 0,<br>
                                                "peak_util_pm":0,<br>
                                                "avg_time_ms": 0.011,<br>
                                                "peak_time_ms":0.109<br>
                                              }<br>
                                            },<br>
                                      <br>
                                            "tot_count_hz": 11.76,<br>
                                            "tot_util_pm": 6.247,<br>
                                            "tot_time_ms": 4.628<br>
                                          };</font><br>
                                  </div>
                                </div>
                              </blockquote>
                            </div>
                          </blockquote>
                        </div>
                      </div>
                      <br>
                      <fieldset></fieldset>
                      <pre>_______________________________________________
OvmsDev mailing list
<a href="mailto:OvmsDev@lists.openvehicles.com" rel="noreferrer"
                      target="_blank" moz-do-not-send="true"
                      class="moz-txt-link-freetext">OvmsDev@lists.openvehicles.com</a>
<a href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev"
                      rel="noreferrer" target="_blank"
                      moz-do-not-send="true"
                      class="moz-txt-link-freetext">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"
                    rel="noreferrer" target="_blank"
                    moz-do-not-send="true" class="moz-txt-link-freetext">OvmsDev@lists.openvehicles.com</a><br>
                  <a
href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev"
                    rel="noreferrer noreferrer" target="_blank"
                    moz-do-not-send="true" class="moz-txt-link-freetext">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a><br>
                </blockquote>
              </div>
            </div>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26</pre>
  </body>
</html>