<html><head></head><body><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div></div>
        <div>Thank you guys!</div><div>I think I am ready with something I want to create pull request on. Do I do this through my own repository, or can I just send someone a diff?</div><div>Nikolay</div><div><br></div>
        
        </div><div id="yahoo_quoted_2418342972" class="yahoo_quoted">
            <div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">
                
                <div>
                    On Thursday, July 19, 2018, 12:37:58 PM GMT+2, Michael Balzer <dexter@expeedo.de> wrote:
                </div>
                <div><br></div>
                <div><br></div>
                <div><div id="yiv7607073491"><div>
    Nikolay,<br clear="none">
    <br clear="none">
    <blockquote type="cite">
      </blockquote></div><div><blockquote class="yiv7607073491" type="cite">
        <div class="yiv7607073491">
          <div class="yiv7607073491" style="">
            <div class="yiv7607073491">
              <div class="yiv7607073491">
                <div class="yiv7607073491">- what is the best way to compare
                  OvmsMetricStrings? Or should I dublicate the state in
                  an enum and use that?</div>
                <div class="yiv7607073491">- what is the best way to compare the
                  OvmsMetricFloat to a literal float?</div>
              </div>
            </div>
          </div>
        </div>
      </blockquote>
    
    <br clear="none">
    If you want to compare a state code encoded as a string, you can
    simply compare the std::string returned by AsString() with hard
    coded strings, e.g.<br clear="none">
    <br clear="none">
    <tt>    std::string charge_state =
      StdMetrics.ms_v_charge_state->AsString();</tt><tt><br clear="none">
    </tt><tt>    if (charge_state == "charging")</tt><tt><br clear="none">
    </tt><tt>        …</tt><tt><br clear="none">
    </tt><br clear="none">
    If you'd rather use the old numeric state codes, there are utility
    functions in the ovms_utils module for encoding / decoding them.<br clear="none">
    <br clear="none">
    As Mark wrote, you get the float value by the AsFloat() method and
    can compare that directly to a float literal. We haven't added
    comparison operators to the metrics classes yet, just assignment
    (and that needs casts in many cases). If you'd like to add more
    operators/types, go ahead.<br clear="none">
    <br clear="none">
    <br clear="none">
    <blockquote type="cite"><br clear="none" class="yiv7607073491">
      <blockquote class="yiv7607073491" type="cite">
        <div class="yiv7607073491">
          <div class="yiv7607073491" style="">
            <div class="yiv7607073491">
              <div class="yiv7607073491">
                <div class="yiv7607073491">- what is the current way of doing <span class="yiv7607073491">net_req_notification</span></div>
              </div>
            </div>
          </div>
        </div>
      </blockquote>
      <div><br clear="none" class="yiv7607073491">
      </div>
      <div>Not required in v3. If you change a metric that needs
        notification, the serverv2 and serverv3 will act appropriately.</div>
    </blockquote>
    <br clear="none">
    And if you want to customize standard notifications, you can do so
    by overloading the vehicle methods:<br clear="none">
    <br clear="none">
    <tt>    virtual void NotifyChargeState();</tt><tt><br clear="none">
    </tt><tt>    virtual void NotifyChargeStart();</tt><tt><br clear="none">
    </tt><tt>    virtual void NotifyHeatingStart();</tt><tt><br clear="none">
    </tt><tt>    virtual void NotifyChargeStopped();</tt><tt><br clear="none">
    </tt><tt>    virtual void NotifyChargeDone();</tt><tt><br clear="none">
    </tt><tt>    virtual void NotifyValetEnabled();</tt><tt><br clear="none">
    </tt><tt>    virtual void NotifyValetDisabled();</tt><tt><br clear="none">
    </tt><tt>    virtual void NotifyValetHood();</tt><tt><br clear="none">
    </tt><tt>    virtual void NotifyValetTrunk();</tt><tt><br clear="none">
    </tt><tt>    virtual void NotifyAlarmSounding();</tt><tt><br clear="none">
    </tt><tt>    virtual void NotifyAlarmStopped();</tt><tt><br clear="none">
    </tt><tt>    virtual void Notify12vCritical();</tt><tt><br clear="none">
    </tt><tt>    virtual void Notify12vRecovered();</tt><br clear="none">
    <br clear="none">
    If you want to add vehicle specific notifications, take a look at
    the Twizy module (rt_notify).<br clear="none">
    <br clear="none">
    You can simply send a notification from any command output by
    issuing MyNotify.NotifyCommand() (att: stack intensive) or send any
    string by MyNotify.NotifyString(). There are also varargs versions
    with "f" suffix acting like printf.<br clear="none">
    <br clear="none">
    For building strings from command methods, there is the StringWriter
    class, that's a std::string that can be used as an OvmsWriter.
    Example:<br clear="none">
    <br clear="none">
    <tt>    StringWriter buf(200);</tt><tt><br clear="none">
    </tt><tt>    CommandStat(COMMAND_RESULT_NORMAL, &buf);</tt><tt><br clear="none">
    </tt><tt>    MyNotify.NotifyString("info", "charge.sufficient",
      buf.c_str());</tt><br clear="none">
    <br clear="none">
    Best practice is to send notifications from within an event handler
    (e.g. Ticker1), so they run asynchronously in the event task context
    instead of blocking something.<br clear="none">
    <br clear="none">
    Regards,<br clear="none">
    Michael<br clear="none">
    <br clear="none">
    PS: we should start collecting these pieces for the developer
    manual, the general system API is quite mature now<div class="yiv7607073491yqt4097312186" id="yiv7607073491yqtfd36178"><br clear="none">
    <br clear="none">
    <br clear="none">
    </div><blockquote type="cite"><div class="yiv7607073491yqt4097312186" id="yiv7607073491yqtfd98875">On
      19 Jul 2018, at 6:00 AM, Nikolay Shishkov <<a rel="nofollow" shape="rect" class="yiv7607073491" ymailto="mailto:nshishkov@yahoo.com" target="_blank" href="mailto:nshishkov@yahoo.com">nshishkov@yahoo.com</a>> wrote:
      </div><div><div class="yiv7607073491yqt4097312186" id="yiv7607073491yqtfd84373">
        </div><blockquote class="yiv7607073491" type="cite"><div class="yiv7607073491yqt4097312186" id="yiv7607073491yqtfd08496"><br clear="none" class="yiv7607073491Apple-interchange-newline">
          </div><div class="yiv7607073491"><div class="yiv7607073491yqt4097312186" id="yiv7607073491yqtfd35976">
            </div><div class="yiv7607073491"><div class="yiv7607073491yqt4097312186" id="yiv7607073491yqtfd14102">
              </div><div class="yiv7607073491" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;"><div class="yiv7607073491yqt4097312186" id="yiv7607073491yqtfd61138">
                <div class="yiv7607073491" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;">
                  <div class="yiv7607073491" style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:13px;">
                    <div class="yiv7607073491">Hi, </div>
                    <div class="yiv7607073491">I am working on the Think City EV code
                      and have some questions.</div>
                    <div class="yiv7607073491">- what is the best way to signal that
                      the charging connector is plugged?
                      ms_v_charge_pilot?</div>
                    <div class="yiv7607073491">previously it was cardoorbits1. </div>
                    <div class="yiv7607073491"><br clear="none" class="yiv7607073491">
                    </div>
                    <div class="yiv7607073491">- what is the best way to compare
                      OvmsMetricStrings? Or should I dublicate the state
                      in an enum and use that?</div>
                    <div class="yiv7607073491"><br clear="none" class="yiv7607073491">
                    </div>
                    <div class="yiv7607073491">- what is the best way to compare the
                      OvmsMetricFloat to a literal float?</div>
                    <div class="yiv7607073491"><br clear="none" class="yiv7607073491">
                    </div>
                    <div class="yiv7607073491">- what is the current way of doing <span class="yiv7607073491">net_req_notification</span></div>
                    <div class="yiv7607073491"><br clear="none" class="yiv7607073491">
                    </div>
                    <div class="yiv7607073491">Thanks in advance,</div>
                    <div class="yiv7607073491">Nikolay</div>
                  </div>
                </div>
                </div><div class="yiv7607073491yahoo_quoted" id="yiv7607073491yahoo_quoted_1950539485"><div class="yiv7607073491yqt4097312186" id="yiv7607073491yqtfd09252">
                  </div><div class="yiv7607073491" style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;"><div class="yiv7607073491yqt4097312186" id="yiv7607073491yqtfd20374">
                    <div class="yiv7607073491"> On Tuesday, July 17, 2018, 3:37:49 AM
                      GMT+2, Mark Webb-Johnson <<a rel="nofollow" shape="rect" class="yiv7607073491" ymailto="mailto:mark@webb-johnson.net" target="_blank" href="mailto:mark@webb-johnson.net">mark@webb-johnson.net</a>>
                      wrote: </div></div>
                    <br clear="none">
                  </div>
                </div>
              </div>
            </div>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <br clear="none">
    <pre class="yiv7607073491moz-signature">-- 
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
</pre><div class="yiv7607073491yqt4097312186" id="yiv7607073491yqtfd11498">
  </div></div></div><div class="yqt4097312186" id="yqtfd59892">_______________________________________________<br clear="none">OvmsDev mailing list<br clear="none"><a shape="rect" ymailto="mailto:OvmsDev@lists.openvehicles.com" href="mailto:OvmsDev@lists.openvehicles.com">OvmsDev@lists.openvehicles.com</a><br clear="none"><a shape="rect" href="http://lists.openvehicles.com/mailman/listinfo/ovmsdev" target="_blank">http://lists.openvehicles.com/mailman/listinfo/ovmsdev</a><br clear="none"></div></div>
            </div>
        </div></div></body></html>