Commit graph

13 commits

Author SHA1 Message Date
Dirk Hohndel
b1d1c88822 Fix uninitialized variable
s could be used without being set.

Also convert the file to utf-8 - for some reason it was created as
iso8859.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-09 21:25:20 -07:00
Dirk Hohndel
7f32f930ef Increase static buffer size
While 100 was almost certainly long enough for all the non-string data
that we'd find on a single line, it was a little too close for comfort.
So let's go total overkill and not worry about it.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-09 21:06:18 -07:00
Linus Torvalds
1fc783aed5 Read salinity from git objects
Simple oversight on the reading side.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-09 21:04:05 -07:00
Linus Torvalds
4312b155e1 parse divecomputer model nickname/firmware/serial information
This was the final piece we didn't read.  I can now read my XML file,
write it to a git repository, read it back, and write it to a new XML
file, and the final XML file is bit-for-bit identical with the original
one.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-09 19:36:40 -07:00
Linus Torvalds
6f3be56d8d Add event parsing to the git object tree loader
This makes us parse everything we save, and I can load my XML file, save
it as a git file, load that git file, save it as a new XML file, and the
end result is identical.

Well...  *ALMOST* identical.  We currently don't save the dive computer
nickname and serial/firmware information in the git repository, so that
does get lost in translation.  But all the actual dive data is there.

NOTE! I have currently only worked with my own dive files.  They are
reasonably complex and complete, and do have a lot of the interesting
cases covered (like multiple dive computers etc), but there's no CCR
information, and all the dives are in trips, so this does need more
testing. It's at the very least very close.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-09 19:36:39 -07:00
Linus Torvalds
6ef38967ff parse cylinder and weightsystem information
This makes the sample parsing helper function for key-value pair parsing
more generic, and uses it for parsing cylinders and weightsystems too.

Events still to go, and then we have the "setting" section (for dive
computer nicknames and firmware information) that we don't actually save
yet in the git format.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-09 19:36:38 -07:00
Linus Torvalds
820cbe96da Parse key/value pairs in dive computer samples too
This gets us the stopdepth, cns, bearing etc information.  We're getting
really close to parsing everything, but are still missing event parsing,
and cylinder/weight data.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-09 19:36:38 -07:00
Linus Torvalds
7991e36c56 Parse basic dive computer sample data
This doesn't yet parse the (less common) "key=value" type sample data,
so it's not complete, but the framework for that is in place too.

With this, we now parse all the basics, and the most noticeable missing
part is the cylinder and weigthsystem data.  Lack of cylinder data in
particular means that SAC-rates etc don't get calculated, but other than
that it looks almost complete - you don't miss the missing event and
sample details unless you look for them.

I'll get the missing pieces done too, but this basic sample parsing was
visually a big step.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-09 19:36:35 -07:00
Linus Torvalds
5fcb36f5a8 Parse basic trip and dive data from the git blobs
Some things are still missing: samples and events, and cylinder and
weightsystem information.  But most of the basics are there (although
the lack of sample data makes a big visual impact)

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-09 19:36:35 -07:00
Linus Torvalds
719656b438 Start actually parsing the git object data
This implements the simple line parser (including the multiline strings
with escape characters).  What a difference a good file format makes:
this is nothing like the pain that is XML.

That said, it only does the line/string parsing right now, it doesn't
actually then look at what the lines say.  So no human-noticeable
improvements in the actual data shown by subsurface.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-09 19:36:34 -07:00
Linus Torvalds
34fb8240da git repository reading: start reading the actual file contents
If we want to scale to thousands of dives, we'll eventually want to read
the dive computer files lazily when actually needed, but for now we do
everything synchronously.  Even if that may actually be slower than
parsing one big XML file.

The git object store is pretty efficient, but especially with some
history, the compression and delta application will certainly not be
free.

This does all the git object unpacking, but none of the actual data
parsing yet.  But as part of looking up the file objects, we do get the
dive number (which is in the name of the dive file).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-09 19:36:33 -07:00
Linus Torvalds
f0985644b6 git dive loading: actually insert the dives into the dive table
The biggest part of this commit is the comment about the woeful state of
the "git_tree_walk()" interface - the interface is not really very good
for seeing any recursive state, since it just walks the tree pretty much
linearly.

But the only real recursive state we care about is the trip, and in all
normal situations the "trip this dive is in" is the same thing as "what
was the last trip directory we traversed", so a linear walk works fine.

The one exception is if a dive isn't in a trip at all, in which case
"last trip directory" obviously isn't what we want.

But rather than do our own tree walking by hand (and just passing the
trip information in the natural recursive manner when traversing the
tree), we hack around it by just looking at the path to the dive.

That one-liner trivial hack has now generated about 20 lines of
explanation of it.

ANYWAY.  With this, we parse the dive and trip hierarchy properly, and
instead of just printing out the data, we might as well insert the dives
and trips into the subsurface data structures.

Note: the only data we have about the dive and trip right now is what is
visible in the directory structure, since we don't look at the actual
dive file at all (not even the name of it, which contains the dive
number).  So the end result will be just a sea of empty dives and the
trips they are contained in.  The dives have a date and time, and the
trip has a date, though.

So this is *not* useful for actually saving and loading data, but the
data we do load is easily visualized inside subsurface, so as I'm
starting to add real dive data parsing code, it will all be much more
visually satisfying.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-09 19:36:32 -07:00
Linus Torvalds
cc3a184adf Add initial parser for git trees
It doesn't actually parse the files themselves, but it does walk the
object tree and print out the dives and trips it finds.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2014-03-08 07:46:50 -08:00