<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Robert,<br>
      <br>
      On 13/10/2014 11:25, Robert Helling wrote:<br>
    </div>
    <blockquote
      cite="mid:93039C13-63CB-4BA2-A69E-D6BA0675A53F@atdotde.de"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <br>
      <div>
        <div>On 13.10.2014, at 08:49, Willem Ferguson <<a
            moz-do-not-send="true"
            href="mailto:willemferguson@zoology.up.ac.za">willemferguson@zoology.up.ac.za</a>>
          wrote:</div>
        <div><br>
        </div>
        <div>Willem,</div>
        1) Your sensor data never reaches fill_pressures: You make the
        pressures struct (and I would like to add that using one
        structure to both pass data in and out of the function does not
        sound like such a great idea to me) be a member of the entry
        struct. But then, that gets never used as add_segments gets
        called which does not now about entry and thus creates a new
        pressures struct which has uninitialized values in it.</div>
      <div><br>
      </div>
      <div>One simple way to fix this would be to do the sensor voting
        logic not in fill_pressures but in a separate function and then
        feed the resulting majority vote for the po2 into add_segment.
        For example you could call that from profile.c with the entry as
        argument (or just a pointer to the sensors array) to obtain the
        po2. Then you could leave the data of the individual sensors out
        to the pressures struct.</div>
      <div><br>
      </div>
      <div>2) I can unbreak the OC part by at least</div>
      <div><br>
      </div>
      <div>
        <div style="margin: 0px; font-size: 11px;">th-ws-tmpim01:subsurface
          helling$ git diff</div>
        <div style="margin: 0px; font-size: 11px;"><b>diff --git
            a/dive.c b/dive.c</b></div>
        <div style="margin: 0px; font-size: 11px;"><b>index
            4d906e5..d624cce 100644</b></div>
        <div style="margin: 0px; font-size: 11px;"><b>--- a/dive.c</b></div>
        <div style="margin: 0px; font-size: 11px;"><b>+++ b/dive.c</b></div>
        <div style="margin: 0px; font-size: 11px;"><span style="color:
            #34bbc7">@@ -1623,7 +1623,7 @@</span> extern void
          fill_pressures(struct gas_pressures *pressures, const double
          amb_pre</div>
        <div style="margin: 0px; font-size: 11px;">                     
            pressures->o2 = po2;</div>
        <div style="margin: 0px; font-size: 11px;">               
          pressures->he = (amb_pressure - pressures->o2) *
          (double)get_he(mix) / (1000 - get_o2(mix));</div>
        <div style="margin: 0px; font-size: 11px;">               
          pressures->n2 = amb_pressure - pressures->o2 -
          pressures->he;</div>
        <div style="margin: 0px; font-size: 11px; color: rgb(195, 55,
          32);">-       } else if (!pressures->o2) { // Open circuit
          dives: no gas pressure values available, they need to be
          calculated</div>
        <div style="margin: 0px; font-size: 11px; color: rgb(52, 189,
          38);">+<span style="color: #000000">       </span>} else { //
          Open circuit dives: no gas pressure values available, they
          need to be calculated</div>
        <div style="margin: 0px; font-size: 11px;">               
          pressures->o2 = get_o2(mix) / 1000.0 * amb_pressure;</div>
        <div style="margin: 0px; font-size: 11px;">               
          pressures->he = get_he(mix) / 1000.0 * amb_pressure;</div>
        <div style="margin: 0px; font-size: 11px;">               
          pressures->n2 = (1000 - get_o2(mix) - get_he(mix)) / 1000.0
          * amb_pressure;</div>
        <div><br>
        </div>
        <div>3) In the case of two sensors, why does your for loop
          iterate over three sensors?</div>
        <div><br class="webkit-block-placeholder">
        </div>
        <div apple-content-edited="true">
          <div style="color: rgb(0, 0, 0); font-family: Menlo;
            font-style: normal; font-variant: normal; font-weight:
            normal; letter-spacing: normal; line-height: normal;
            orphans: 2; text-align: -webkit-auto; text-indent: 0px;
            text-transform: none; white-space: normal; widows: 2;
            word-spacing: 0px; -webkit-text-size-adjust: auto;
            -webkit-text-stroke-width: 0px; word-wrap: break-word;
            -webkit-nbsp-mode: space; -webkit-line-break:
            after-white-space; ">
            <div style="color: rgb(0, 0, 0); font-family: Menlo;
              font-style: normal; font-variant: normal; font-weight:
              normal; letter-spacing: normal; line-height: normal;
              orphans: 2; text-align: -webkit-auto; text-indent: 0px;
              text-transform: none; white-space: normal; widows: 2;
              word-spacing: 0px; -webkit-text-size-adjust: auto;
              -webkit-text-stroke-width: 0px; word-wrap: break-word;
              -webkit-nbsp-mode: space; -webkit-line-break:
              after-white-space; ">
              <div style="color: rgb(0, 0, 0); font-family: Menlo;
                font-style: normal; font-variant: normal; font-weight:
                normal; letter-spacing: normal; line-height: normal;
                orphans: 2; text-align: -webkit-auto; text-indent: 0px;
                text-transform: none; white-space: normal; widows: 2;
                word-spacing: 0px; -webkit-text-size-adjust: auto;
                -webkit-text-stroke-width: 0px; word-wrap: break-word;
                -webkit-nbsp-mode: space; -webkit-line-break:
                after-white-space; ">Best</div>
              <div style="color: rgb(0, 0, 0); font-family: Menlo;
                font-style: normal; font-variant: normal; font-weight:
                normal; letter-spacing: normal; line-height: normal;
                orphans: 2; text-align: -webkit-auto; text-indent: 0px;
                text-transform: none; white-space: normal; widows: 2;
                word-spacing: 0px; -webkit-text-size-adjust: auto;
                -webkit-text-stroke-width: 0px; word-wrap: break-word;
                -webkit-nbsp-mode: space; -webkit-line-break:
                after-white-space; ">Robert</div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    If I execute calculate_deco_information() AFTER get_pressures(),
    then, for OC as well as CCR dives, the ceilings appear correct
    because, now, there are calculated po2 values to work from, allowing
    calculation of pn2 values and ceilings. See line 962 in profile.c
    (latest master). But I do not know whether you would consider the
    swop of order a wise thing to do. But this does not solve the
    ceilings for dive plans. Please comment, will you?<br>
    <br>
    What I can do is this:<br>
    Create a function in profile.c that does the voting. It will reside
    in profile.c, be plot_info aware, and return a double, being the
    calculated po2 value. Now we can remove the sensor values from the
    pressures structure and return the sensor data to the "base level"
    of plot_info. This might also remove the need of a 5th calling
    parameter for get_pressures(). Please comment, will you?<br>
    <br>
    If it were possible, I want to solve this problem before I leave for
    meetings in east Africa on Wednesday and be away for two weeks.<br>
    <br>
    Thank you so much for your time committed to solve this.<br>
    Kind regards,<br>
    willem<br>
    <br>
    <br>
    <br>
    <br>
  </body>
</html>