Commit graph

71 commits

Author SHA1 Message Date
Dirk Hohndel
c15f798a85 Remove the ability to 'Import' .SDA files
We can instead 'Open' these files as they are just bastardized XML files.

This gets us back to a more consistent point where 'Import' gets data
directly from the dive computer (and hopefully soon we will add the
ability to load a dive directly from a uemis SDA to libdivecomputer),
and 'Open' loads a file from the filesystem of the computer we are
running on (this last sentence phrased so awkwardly as the uemis Zurich
SDA is a computer and presents a file system when connected via USB - it
just doesn't have the dive data in an accessible format in that file
system).

As a bonus we get to throw away quite a bit of code (the uemis specific
file handling, mini-XML parser with helper functions, the file open dialog
in the importer). Yay!

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-03 08:34:56 -07:00
Linus Torvalds
8eeeb97b85 Update Mares IconHd parsing to current libdivecomputer interface
The libdivecomputer interfaces are pure crap.  There are no generic
"open the dive computer" or "create a parser for the dive computer"
interfaces, instead each dive computer you support has its own open and
parser generator interface.

And they change.  Happily fairly seldom, but they change.  And two days
ago, Jef changed the interface for the Mares Icon HD computer in order
to support the newer HD Net Ready variant.

I've asked Jef to make a sane interface for "open the dive computer" and
"just create the parser" for libdivecomputer, but he claims that he
cannot just track the device model details internally.  Which is
obviously a completely bogus claim, since the way *we* track the model
details is to just feed it back from the silly event.

libdivecomputer should just do that internally and not bother us with
its crazy internal model numbers.  But whatever.

In the meantime, work around this braindamage, and hope that
libdivecomputer comes to its senses some day.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-26 13:14:41 -07:00
Linus Torvalds
5c8305588b Stop libdivecomputer import when we start seeing old dives
I don't know about other dive computers, but the Suunto Vyper Air is
slow as hell to import all the dives from.  And libdivecomputer seems to
be importing dives "most recent first", so this just makes it stop
importing dives when it finds a dive that we've already seen.

Caveat: libdivecomputer has this fancy notion of "dive fingerprints",
and claims that's the way to do things.  That seems to be overly
complicated, and not worth the bother.

If you worry about the import finishing early due to already having some
dives with the same date in your dive list, just import starting from an
empty state, and thus get a pure "dive computer only" state with no
early out.  Then you can just load the old dives afterwards, and depend
on subsurface merging any duplicates.

But for normal operation, when you just want to import a couple of new
dives from your dive computer, the "exit import early when you see a
duplicate" is the right thing to do.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-26 13:04:14 -07:00
Linus Torvalds
3a77eb8510 Start handling dive events
Parse them, save them, take them from libdivecomputer.

This doesn't merge them or show them in the profile yet, though.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-22 18:02:54 -07:00
Linus Torvalds
d344d15a90 Improve libdivecomputer event printout
Ignore surface events - they are meaningless anyway and just add noise.

Print out other events properly, including correct time offset etc.

We still don't actually *save* the events, but now it might be worth
doign so.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-22 16:55:55 -07:00
Linus Torvalds
d463cace5e Clean up event handling from libdivecomputer
This just moves the event handling out into its own helper function.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-22 16:45:28 -07:00
Linus Torvalds
c0adfdc41b Fix progress bar during libdivecomputer imports
As reported by Mauro Dreissig, the progress bar doesn't work and causes
a SIGSEGV due to a missing allocation.  The code broke when Dirk
separated out the GUI from the core code, and I hadn't tried
divecomputer downloads since.

Reported-by: Mauro Dreissig <mukadr@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-22 16:38:24 -07:00
Dirk Hohndel
682135838f Separate out the UI from the program logic
The following are UI toolkit specific:
gtk-gui.c   - overall layout, main window of the UI
divelist.c  - list of dives subsurface maintains
equipment.c - equipment / tank information for each dive
info.c      - detailed dive info
print.c     - printing

The rest is independent of the UI:
main.c i    - program frame
dive.c i    - creates and maintaines the internal dive list structure
libdivecomputer.c
uemis.c
parse-xml.c
save-xml.c  - interface with dive computers and the XML files
profile.c   - creates the data for the profile and draws it using cairo

This commit should contain NO functional changes, just moving code around
and a couple of minor abstractions.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-20 12:48:56 -07:00
Linus Torvalds
9cf8d98711 Make 'struct DiveList' entirely internal to divelist.c
Passing it around is just annoying, and we only ever have one.  Let's
not burden all the users with the silly thing.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-20 10:06:24 -07:00
Linus Torvalds
8c18add46b Do libdivecomputer imports in a separate thread
This is the hackiest thing ever, unless you count the previous code that
was even hackier (and just called the gtk main routine at random
places).

The libdivecomputer library is not really set up to be part of the gtk
main loop, and cannot afford (for example) to have lots of mainloop
events while it's parsing.  Some dive computers are very timing
sensitive for the communication.

So just start a thread for doing the libdivecomputer stuff, and just
continually call the gtk main loop while that thread is running.  I'm
sure we could actually use some gtk signalling thing to make the thread
exit do the right thing, but instead we just poll the status every
100ms.

I did say it was hacky.  It does seem to work, though.  No more
temporary graying out of the windows when they don't react in a timely
manner because libdivecomputer does some blocking operation.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-15 22:58:02 -07:00
Linus Torvalds
3a6652634b Rename the project 'subsurface'
I never really liked 'diveclog' as a name - it's not like the C part is
all that important.  And while I could try to just make up another slang
word for despicable person (in the tradition of naming all my projects
after myself), I just can't see it.

So let's just call it "subsurface".

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-15 09:43:14 -07:00
Dirk Hohndel
518ec33ba3 First pass to parse uemis Zurich '.SDA' files
This is missing a ton of the information in the .SDA files It only
parses the divelog.SDA file, not the dive.SDA file It ignores the
information on the gas(es) used and all the data on the tanks.

It still draws some strange artefacts at the end of the dive

But it correctly hooks into the import dialogue, it gives you a file
select box (somewhere, I'm sure, a gtk developer cries quietly) and then
parses enough of this file to serve as a proof of concept.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-15 08:52:55 -07:00
Dirk Hohndel
b35e1bad8e Quick fix to hardcode device name only once
Linus clearly wanted to make SURE that we use /dev/ttyUSB0

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-14 11:37:25 -07:00
Linus Torvalds
4e7161efd6 Do some basic sanity testing on the libdivecomputer gasmix data
It's quite often obvious crap for the "doesn't exist" or "plain air" case.

So if it's reporting 100% O2, we just ignore it.  Sure, it could be
right, but for the dives I have I know it's just libdivecomputer being
wrong.

Same goes for obvious crap like 255% Helium.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-12 13:31:43 -07:00
Linus Torvalds
42f627b8b1 Libdivecomputer: start actually importing the dive data
So this actually reports the dive data that libdivecomputer generates.
It doesn't import special events etc, but neither do we for the xml
importer.

It is also slow as heck, since it doesn't try to do the "hey, I already
have this dive" logic and always imports everything, but the basics are
definitely there.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-12 13:25:05 -07:00
Linus Torvalds
d45db9fac7 libdivecomputer integration: add a progress bar
Instead of writing out the progress events, use them to update a real
progress bar.

Also, we need to handle gtk events while busy with the dive computer
reading.  That should *probably* be done with a threading model, because
libdivecomputer does seem to have some timing sensitivity - I'm getting
"failure to read memory block" if I make that loop do the standard

	while (gtk_events_pending())
		  gtk_main_iteration();

thing.  Besides, even if we did do that loop, it would still cause
problems when the libdivecomputer code is stuck reading a serial line
that doesn't respond or whatever.

But for now this ugly hack is "good enough" to get further.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-12 11:41:26 -07:00
Linus Torvalds
d5b7f7dc06 Libdivecomputer integration, part n+1
This actually gets me far enough that it prints out all the dives on my
dive computer.  It doesn't actually turn them into real dives yet,
though - only a series of ugly 'printf's so far.

And it hangs after printing the last dive. So I'm doing something wrong.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-12 11:05:32 -07:00
Linus Torvalds
7d8fed4eee More libdivecomputer boilerplate stuff
.. fill in the event parsing.  This doesn't generate the fingerprint
like the example does, I just don't care about that yet.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-12 10:37:54 -07:00
Linus Torvalds
6b0bb87f5b Further work on libdivecomputer integration
.. this now registers the dive parsing callback, and starts to parse the
data.  So I can see the last divetime on my Suunto Vyper Air now.

Still a lot more boilerplate stuff to go, though.  The libdivecomputer
interfaces really are pretty insane: why should the caller set up the
dive parsing for each computer type, when libdivecomputer knows what
types it has? IOW, much of that boilerplate should be hidden inside of
libdivecomputer, rather than exposed to the user.

But whatever.  I'm taking pieces from "examples/universal.c" as I go
along (it's under LGPL 2.1).  I want to do it in small chunks just to
feel that I understand what's going on, rather than just blindly copying
it all.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-12 10:27:35 -07:00
Linus Torvalds
a9f74044ae Flesh out the libdivecomputer interfaces some more
.. start some error reporting, and register some early (empty)
callbacks.

This still doesn't actually do anything.  But commit early, commit
often: when I start seriously breaking things, I want to have a "hey,
this still at least compiled" state.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-12 09:50:40 -07:00
Linus Torvalds
9cb60c9106 Start some very initial libdivecomputer integration
Ok, so this is quite broken right now: it doesn't actually really *do*
anything, and it now requires that you have libdivecomputer all set up
and installed.

That is fairly easy:

	mkdir ../src
	cd ../src
	git clone git://libdivecomputer.git.sourceforge.net/gitroot/libdivecomputer/libdivecomputer
	cd libdivecomputer
	autoreconf --install
	./configure
	make
	sudo make install

but you may feel that this is not exactly useful considering that
nothing actually *works* yet.

Some day.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-12 09:27:01 -07:00