]> git.tdb.fi Git - ext/subsurface.git/commitdiff
Merge branch 'otu-tracking-v2' of git://github.com/dirkhh/subsurface
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 27 Sep 2011 17:46:42 +0000 (10:46 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 27 Sep 2011 17:46:42 +0000 (10:46 -0700)
* 'otu-tracking-v2' of git://github.com/dirkhh/subsurface:
  Make OTU column invisible by default
  Add OTU to divelist
  Calculate OTUs for every dive

Fix up trivial conflicts in dive.h (due to dive event handling also
adding a field to the dive structure)

1  2 
dive.h
parse-xml.c

diff --combined dive.h
index b121892e9296de5e8e2844124123fa0d728db9ea,5cb32412308ee2219efa8f1c2e5faabeadfc5ab1..42d91d630a0776f63b8605d61e6e5f1c429578a0
--- 1/dive.h
--- 2/dive.h
+++ b/dive.h
@@@ -134,6 -134,11 +134,11 @@@ static inline int to_PSI(pressure_t pre
        return pressure.mbar * 0.0145037738 + 0.5;
  }
  
+ static inline double to_ATM(pressure_t pressure)
+ {
+       return pressure.mbar / 1013.25;
+ }
  struct sample {
        duration_t time;
        depth_t depth;
        int cylinderindex;
  };
  
 +/*
 + * Events are currently pretty meaningless. This is
 + * just based on the random data that libdivecomputer
 + * gives us. I'm not sure what a real "architected"
 + * event model would actually look like, but right
 + * now you can associate a list of events with a dive,
 + * and we'll do something about it.
 + */
 +struct event {
 +      struct event *next;
 +      duration_t time;
 +      int type, flags, value;
 +      char name[];
 +};
 +
  #define MAX_CYLINDERS (8)
  
  struct dive {
        depth_t visibility;
        temperature_t airtemp, watertemp;
        cylinder_t cylinder[MAX_CYLINDERS];
+       int otu;
 +      struct event *events;
        int samples, alloc_samples;
        struct sample sample[];
  };
@@@ -243,8 -233,6 +249,8 @@@ extern struct dive *try_to_merge(struc
  
  extern void renumber_dives(int nr);
  
 +extern void add_event(struct dive *dive, int time, int type, int flags, int value, const char *name);
 +
  /* UI related protopypes */
  
  extern void init_ui(int argc, char **argv);
diff --combined parse-xml.c
index 50f83f68bf8845977739e0d2db821f58d1c2bd1f,8f916b09aea3ed02b2d7ebb7c927263eb2bd7a83..6eafb0d3aaf993bf8efc78b5d6916387ac0f3c0a
@@@ -92,14 -92,8 +92,14 @@@ const struct units IMPERIAL_units = 
   */
  static struct dive *dive;
  static struct sample *sample;
 +static struct {
 +      int active;
 +      duration_t time;
 +      int type, flags, value;
 +      const char *name;
 +} event;
  static struct tm tm;
 -static int event_index, cylinder_index;
 +static int cylinder_index;
  
  static enum import_source {
        UNKNOWN,
@@@ -564,32 -558,6 +564,32 @@@ static int uddf_fill_sample(struct samp
                0;
  }
  
 +static void eventtime(char *buffer, void *_duration)
 +{
 +      duration_t *duration = _duration;
 +      sampletime(buffer, duration);
 +      if (sample)
 +              duration->seconds += sample->time.seconds;
 +}
 +
 +static void try_to_fill_event(const char *name, char *buf)
 +{
 +      int len = strlen(name);
 +
 +      start_match("event", name, buf);
 +      if (MATCH(".event", utf8_string, &event.name))
 +              return;
 +      if (MATCH(".name", utf8_string, &event.name))
 +              return;
 +      if (MATCH(".time", eventtime, &event.time))
 +              return;
 +      if (MATCH(".type", get_index, &event.type))
 +              return;
 +      if (MATCH(".flags", get_index, &event.flags))
 +              return;
 +      nonmatch("event", name, buf);
 +}
 +
  /* We're in samples - try to convert the random xml value to something useful */
  static void try_to_fill_sample(struct sample *sample, const char *name, char *buf)
  {
@@@ -1083,7 -1051,7 +1083,7 @@@ static void match_standard_cylinder(cyl
                return;
  
        cuft = type->size.mliter / 28317.0;
-       cuft *= type->workingpressure.mbar / 1013.25;
+       cuft *= to_ATM(type->workingpressure);
        psi = type->workingpressure.mbar / 68.95;
  
        switch (psi) {
@@@ -1138,7 -1106,7 +1138,7 @@@ static void sanitize_cylinder_type(cyli
  
        if (input_units.volume == CUFT || import_source == SUUNTO) {
                volume_of_air = type->size.mliter * 28.317;     /* milli-cu ft to milliliter */
-               atm = type->workingpressure.mbar / 1013.25;     /* working pressure in atm */
+               atm = to_ATM(type->workingpressure);            /* working pressure in atm */
                volume = volume_of_air / atm;                   /* milliliters at 1 atm: "true size" */
                type->size.mliter = volume + 0.5;
        }
@@@ -1169,15 -1137,11 +1169,15 @@@ static void dive_end(void
  
  static void event_start(void)
  {
 +      memset(&event, 0, sizeof(event));
 +      event.active = 1;
  }
  
  static void event_end(void)
  {
 -      event_index++;
 +      if (event.name && strcmp(event.name, "surface") != 0)
 +              add_event(dive, event.time.seconds, event.type, event.flags, event.value, event.name);
 +      event.active = 0;
  }
  
  static void cylinder_start(void)
@@@ -1192,6 -1156,7 +1192,6 @@@ static void cylinder_end(void
  static void sample_start(void)
  {
        sample = prepare_sample(&dive);
 -      event_index = 0;
  }
  
  static void sample_end(void)
@@@ -1211,10 -1176,6 +1211,10 @@@ static void entry(const char *name, in
                return;
        memcpy(buf, raw, size);
        buf[size] = 0;
 +      if (event.active) {
 +              try_to_fill_event(name, buf);
 +              return;
 +      }
        if (sample) {
                try_to_fill_sample(sample, name, buf);
                return;