Re: Problems with ceiling for CCR dive

2014-10-12 Thread Willem Ferguson

Robert,

On 12/10/2014 22:16, Robert C. Helling wrote:

On 12 Oct 2014, at 18:41, Willem Ferguson  
wrote:


 CCR patch: Calculate the correct partial gas pressures for CCR dives

You seem to have removed the logic that the deco/planner uses to detect if we 
are in CCR mode, namely that there is pO2 provided.

You have changed the interface of the fill_pressures function. If you do so, 
make sure this does not break stuff. If you use Qt Creator that has the “find 
usages” function which is very useful for this kind of task.

Can you fix this?

Best
Robert

--


I think we have different understandings of the logic.

Your understanding: if a po2 is supplied, this means CCR and the value 
of po2 by itself is sufficient to detect a CCR dive. Therefore the code 
can use po2 to test for CCR-type calculations.


My understanding: For CCR dives NO po2 is supplied, only the o2 sensor 
data. In order to detect a CCR dive, one needs to interrogate 
dc->dctype. If dc->dctype is CCR, then it is a CCR dive and, in 
get_pressures(), one first needs to calculate the po2, given the sensor 
data. That is the reason for feeding the o2 sensor data to function 
get_pressures(), making use of the gas_pressures structure.


The second last option on get_pressures() (the one that tests for po2) 
does, at present, NOT cover CCR because the preceeding section covers 
CCR. I left this section that tests for po2 for a non-CCR case (maybe 
SCR??) that may potentially insert po2 somewhere among the calculations.


The calculate_deco_information() function assumes a po2 value which, in 
the case of CCR dive,has not been calculated yet. It first needs to be 
calculated. The header of calculate_deco_information explicitly mentions 
that it uses po2 to detect CCR-type dives and that it should execute 
BEFORE get_pressures(), i.e. before the po2 has been calculated. This is 
the most likely source of the problem.


The question is: should CCR po2 be calculated within get_pressures(), or 
somewhere else? My feeling is yes, this is the functional block that 
calculates all the partial pressures. Why should the calculation of po2 
be done elsewhere?


However, the calculation of po2 could potentially be moved to 
populate_plot_entries(). If you feel this would be better, I would do 
this with pleasure. But then the calculations of partial gas pressures 
would be spread over different functions. However, you guys that have 
been involved in this project so long have miles more experience than 
me, so I would be more than happy to do this in a way you think logical.


Please share your thoughts  and/or suggestions :-)
Kind regards,
willem

___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: Problems with ceiling for CCR dive

2014-10-12 Thread Robert C. Helling

On 12 Oct 2014, at 18:41, Willem Ferguson  
wrote:

Willem,

> Attached a screenshot of the present state of the Poseidon CCR dive profile. 
> The ceiling is not correct. Where does the software that draws the ceiling 
> get the information from in order to draw the ceiling? The pn2 graph (top 
> one) looks more or less ok? The po2 graph is the bottom one.

the version I had on my laptop didn’t have that problem but, as you noticed, 
the latest master has. So I did a git bisect and guess what I found:

th-nb-tmpmbp02:subsurface Robert.Helling$ git bisect good
bc9df4652ffe0cc9d6f579bfd66a4857be57d3b2 is the first bad commit
commit bc9df4652ffe0cc9d6f579bfd66a4857be57d3b2
Author: willem ferguson 
Date:   Sun Oct 12 20:46:41 2014 +0200

CCR patch: Calculate the correct partial gas pressures for CCR dives

You seem to have removed the logic that the deco/planner uses to detect if we 
are in CCR mode, namely that there is pO2 provided.

You have changed the interface of the fill_pressures function. If you do so, 
make sure this does not break stuff. If you use Qt Creator that has the “find 
usages” function which is very useful for this kind of task.

Can you fix this?

Best
Robert

--  
.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oO 
Robert C. Helling Elite Master Course Theoretical and Mathematical Physics  
  Scientific Coordinator   
  Ludwig Maximilians Universitaet Muenchen, Dept. Physik
print "Just another   Phone: +49 89 2180-4523  Theresienstr. 39, rm. B339   
stupid .sig\n";   http://www.atdotde.de 



signature.asc
Description: Message signed with OpenPGP using GPGMail
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: DLD Changes

2014-10-12 Thread Rainer Mohr

Hi Robert,

Am 12.10.14 21:47, schrieb Robert Helling:
the image data design of subsurface is by far not final and indeed we 
currently access images by their local filename. The problems with 
that are obvious and as soon as you want to take your log to a 
different computer you are in trouble. OTOH you don’t want to download 
some hundreds of pictures from a web server every time you scroll 
through you dive log, so at least some cache has to be local. We still 
have to figure out how to do this right.


Totally agree on that, it needs to be local, so you can view it on the 
liveaboard, when you need it.




But for the time being, why do you include the actual image in your 
download api and not just a URL? You are running a web service that 
actually hosts those pictures. So downloading would be much faster and 
if some downloader would really want the image file it could still GET 
them from the URL without any hassle. What do you think?


Well, the idea behind the way it's implemented now is: You want to 
transfer your log with all data from one machine to another and have it 
available offline. That includes the pictures and you get them with one 
request (and a big file) in one go. The alternative is off course to 
just provide URLs to the pictures and keep the DLD file small, but that 
would result in another 2090 HTTP Requests just to get all the pictures 
in my case


The API does offer a bit more than subsurface uses at the moment though, 
which would abolish the need to download all this data every time: There 
is a call to /xml_available_dives.php , that gives you a list of all 
dives with ID, date and time as well as the last-change-timestamp of the 
dive. Based on that list, you COULD compare which dives are already 
there based on date and time (which should be unique for each dive as 
most people can't do two dives at the same moment) and just request the 
IDs you don't have yet (or wish to update based on the last change 
timestamp). the IDs are an optional parameter to the retrieval call for 
the DLD and will then limit the export to only those.


Using that, each dive would only be downloaded once, including the 
pictures...


But I'm open to discussions about this.

Rainer
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: DiveShare patch

2014-10-12 Thread Dirk Hohndel
On Sun, Oct 12, 2014 at 07:41:41PM +0200, Salvo Tomaselli wrote:
> Greetings,
> 
> I made this patch that adds a new export option, to diveshare.

Nice

> Dives can still be anonymous, but users can click a button and 
> go on a page where they have a secret string that they can paste 
> so that dives go to their account directly.
> 
> Let me know if this can be merged or needs some fixes.

I'd like to see a few changes... see below

> Feel free to test it, but make sure that you don't test it with 
> any data that you wouldn't want to be public.

I have NOT tested this, just read the code...

> diff --git a/qt-ui/diveshareexportdialog.cpp b/qt-ui/diveshareexportdialog.cpp
> new file mode 100644
> index 000..a44c2ee
> --- /dev/null
> +++ b/qt-ui/diveshareexportdialog.cpp
[...]
> +void DiveShareExportDialog::finishedSlot(QNetworkReply* reply) {
> + this->ui->progressBar->setVisible(false);
> + if (reply->error() != 0) {
> + const char* error;
> + switch (reply->error()) {
> + case QNetworkReply::ConnectionRefusedError:
> + error = "the remote server refused the connection (the 
> server is not accepting requests)";
> + break;
> + case QNetworkReply::RemoteHostClosedError:
> + error ="the remote server closed the connection 
> prematurely, before the entire reply was received and processed";
> + break;
> + case QNetworkReply::HostNotFoundError:
> + error ="the remote host name was not found (invalid 
> hostname)";
> + break;
> + case QNetworkReply::TimeoutError:
> + error ="the connection to the remote server timed out";
> + break;

and lots and lots more...
do we need all these errors? I.e., can they all happen?
please mark all the texts for translation since they are user facing.

> + case QNetworkReply::TemporaryNetworkFailureError:
> + error ="the connection was broken due to disconnection 
> from the network, however the system has initiated roaming to another access 
> point. The request should be resubmitted and will be processed as soon as the 
> connection is re-established.";

While we have no hard line length limit, this one seems a bit excessive...

> +void DiveShareExportDialog::doUpload() {
[...]
> +
> + //generate json
> + struct membuffer buf = { 0 };
> + export_list(&buf, "/tmp",  this->exportSelected, false);

A path like this will work on Linux and Mac, but not on Windows

This is what jumped out at me after casually reading through the code.
I'll have to spend more time with some of the protocol stuff (or get
Thiago to review that part).

The reason I didn't pull it and said "let's fix it in future commits" is
that I worry that this is completely untested under Windows and I want to
make sure that we continue to have working "daily" builds on that
platform...

/D
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: DLD Changes

2014-10-12 Thread Rainer Mohr

Hi Miika,

Am 12.10.14 21:38, schrieb Miika Turkia:

I get no data with the alldata parameter.


Jep, Bug found and fixed. I assumed your account has a folder with 
documents, which you don't :-)

Please try again...




BTW the additional tanks are not translated on your web page.


Hmm, I see. It depends on the subdomain you POST to. www results in 
"flasche" white en results in "tank".

Thats not good, will rethink that.

Rainer
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: DLD Changes

2014-10-12 Thread Robert Helling

On 12 Oct 2014, at 21:17, Rainer Mohr  wrote:

Rainer,

> I have implemented this on the export page to try it out. 
> https://en.divelogs.de/DLDexport.php?alldata=true (if signed in) will give 
> you an "extended" DLD containing your certifications, documents, Pictures, 
> video-urls, etc. The XML files point to the files included in the zip, so it 
> should be parseable. My main concern is the size and the performance. I just 
> exported mine and it results in a 480MB DLD-file containing over 2000 
> pictures That not only takes a while to put together, but also consumes a 
> lot of ressources. I have no problem to build it in to the API, as most logs 
> don't contain that much data, but it might be a bit slowish for those who put 
> everything they see on their SD card (like me :) ), so timeouts could occur.

the image data design of subsurface is by far not final and indeed we currently 
access images by their local filename. The problems with that are obvious and 
as soon as you want to take your log to a different computer you are in 
trouble. OTOH you don’t want to download some hundreds of pictures from a web 
server every time you scroll through you dive log, so at least some cache has 
to be local. We still have to figure out how to do this right.

But for the time being, why do you include the actual image in your download 
api and not just a URL? You are running a web service that actually hosts those 
pictures. So downloading would be much faster and if some downloader would 
really want the image file it could still GET them from the URL without any 
hassle. What do you think?

Best
Robert


signature.asc
Description: Message signed with OpenPGP using GPGMail
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: DLD Changes

2014-10-12 Thread Miika Turkia
On Sun, Oct 12, 2014 at 10:17 PM, Rainer Mohr  wrote:

>  Hi Miika,
>
> Am 12.10.14 20:52, schrieb Miika Turkia:
>
>  What is the status of picture support on the API? IIRC you mentioned
> that you are working on it, but I don't think it existed the last time I
> checked.
>
>
> I have implemented this on the export page to try it out.
> https://en.divelogs.de/DLDexport.php*?alldata=true* (if signed in) will
> give you an "extended" DLD containing your certifications, documents,
> Pictures, video-urls, etc. The XML files point to the files included in the
> zip, so it should be parseable. My main concern is the size and the
> performance. I just exported mine and it results in a 480MB DLD-file
> containing over 2000 pictures That not only takes a while to put
> together, but also consumes a lot of ressources. I have no problem to build
> it in to the API, as most logs don't contain that much data, but it might
> be a bit slowish for those who put everything they see on their SD card
> (like me :) ), so timeouts could occur.
>

I get no data with the alldata parameter.

>
> Please just add a picture or two on your subsurface test account and
> export the file via the url above. If you say you could work with that,
> I'll implement that. Same goes for other direction, if you can put together
> the DLD file with the pictures like that...
>
>   The import to Subsurface is now implemented. The export is a bit more
> "interesting" as we do not have concept of main tank. I think to just use
> the first in the XML as the main cylinder and the others as additional.
> Does this make sense?
>
>
> Damn, you're fast :-)
>

It was perfect timing, I just had finished upgrading my NAS when your mail
arrived.


> Yes, the first tank as the main cylinder is perfect, it doesn't really
> matter for any SAC calculations, as all tanks are taken into account. The
> only difference it makes, is that the first "tab" on the dive page is your
> main tank and is not deleteable and the others are the additional tanks. So
> just take the first as the main tank...
>

As Dirk pointed out the main cylinder is the one with a gas change event
during the first minute. Otherwise it is the first one. (I already had that
logic in the conversion, but just didn't remember.)

BTW the additional tanks are not translated on your web page.

>
> Let my know how to proceed with the API...
>

I have not started to use the picture stuff on Subsurface, at least not
yet, so I am wrong person to give any comment on this issue. Does anyone
else have opinion on this? Would it be useful to have picture support on
the import/export?

miika
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: DLD Changes

2014-10-12 Thread Miika Turkia
On Sun, Oct 12, 2014 at 9:56 PM, Dirk Hohndel  wrote:

> On Sun, Oct 12, 2014 at 09:52:36PM +0300, Miika Turkia wrote:
> > > So the DLD Format just got a few new fields. Example attached. The
> > >  is completely optional and always additional to the
> main
> > > tank which continues to live directly in the .
> > > Also please note, that a new tag  for Helium percentage has been
> > > added to the main tank and all additional tanks.
> > >
> >
> > The import to Subsurface is now implemented. The export is a bit more
> > "interesting" as we do not have concept of main tank. I think to just use
> > the first in the XML as the main cylinder and the others as additional.
> > Does this make sense?
>
> We used to have code somewhere that said "if there's a gaschange event in
> the first 30 seconds (or maybe it was minute), then assume that's the main
> tank in use. For example the Cobalt always sends the first gas in use as
> part of the first sample...
> I've seen many instances where the main (only) gas in use is not the first
> one on the Cobalt.
>

Correct, the DLD export does indeed already have such a feature. Anyway
here is the export part.

miika
From 4875cb6b0212aca86ce0294271e7036e99d5979d Mon Sep 17 00:00:00 2001
From: Miika Turkia 
Date: Sun, 12 Oct 2014 22:19:26 +0300
Subject: [PATCH] Export additional tanks to divelogs.de

All recorded cylinders are exported to divelogs.de. This potentially
includes cylinders that have not been used.

The start and end pressure for additional cylinders is taken from the
cylinder information. Main tank gets this information from first and
last pressure reading or from the cylinder information if samples are
not available. This should be ok when there is only one cylinder with
pressure sensor, but does not probably work for people having multiple
sensors.

Signed-off-by: Miika Turkia 
---
 xslt/divelogs-export.xslt | 46 ++
 1 file changed, 46 insertions(+)

diff --git a/xslt/divelogs-export.xslt b/xslt/divelogs-export.xslt
index ec39ba2..b3b8dfa 100644
--- a/xslt/divelogs-export.xslt
+++ b/xslt/divelogs-export.xslt
@@ -107,6 +107,49 @@
   
 
 
+
+  
+  
+
+  
+
+  
+
+  
+
+
+
+  
+
+  
+
+
+  
+
+  
+
+
+  
+
+
+  
+
+
+  
+
+
+  
+
+
+  
+
+
+  
+
+  
+  
+
+
 
   
 
@@ -115,6 +158,9 @@
 
   
 
+
+  
+
 
   
 
-- 
1.9.1

___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: [CCR PATCH] Calculate correct po2 values (patch 3 of 3)

2014-10-12 Thread Dirk Hohndel
On Sun, Oct 12, 2014 at 09:05:23PM +0200, Willem Ferguson wrote:
> Subject: [PATCH 2/2] CCR patch: Calculate the correct partial gas pressures
>  for CCR dives (patch 3 of 3 dealing with po2 calculations)

That is an impressively convoluted and confusing Subject...

> This patch adds code to the function fillpressures() in dive.c to
> allow calculating o2 pressures, based on the data from the po2
> sensors in the system. The following changes were made:
> 1) add code to perform po2 calculations for CCR with 1, 2 or 3
>oxygen sesnors.
> 2) Add four fields to the gas_pressures structure in dive.h. This
>allows communication of data between the function that calls
>get_pressures() and the return of partail pressure values to the
>calling function.
> 3) Delete the fields for setpoint and gas partial pressures from
>the structure plot_info. All partial pressures (from instruments
>as well as calculated) now reside in the pressures structure
>that forms part of plot_info.
> 4) Perform changes in several parts of profile.c to make use of the
>pressures structure in plot_info.

This seems rather invasive - not sure if this could have been reasonably
broken down into smaller pieces...

> NB: Please ignore the changes to the xml file, reflected in the patch
> file. I cannot convince git to ignore that file on my machine.

OK.

I also dealt with the massive amount of whitespace / coding style crap in
your patch. I keep doing that and keep hoping that you at some point will
look at the modifications that I make or at the notes in CodingStyle.
We have settings for many of the common editors. Is there a reason why
your patches always are so much work to apply?

/D
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: DLD Changes

2014-10-12 Thread Rainer Mohr

Hi Miika,

Am 12.10.14 20:52, schrieb Miika Turkia:
What is the status of picture support on the API? IIRC you mentioned 
that you are working on it, but I don't think it existed the last time 
I checked.


I have implemented this on the export page to try it out. 
https://en.divelogs.de/DLDexport.php*?alldata=true* (if signed in) will 
give you an "extended" DLD containing your certifications, documents, 
Pictures, video-urls, etc. The XML files point to the files included in 
the zip, so it should be parseable. My main concern is the size and the 
performance. I just exported mine and it results in a 480MB DLD-file 
containing over 2000 pictures That not only takes a while to put 
together, but also consumes a lot of ressources. I have no problem to 
build it in to the API, as most logs don't contain that much data, but 
it might be a bit slowish for those who put everything they see on their 
SD card (like me :) ), so timeouts could occur.


Please just add a picture or two on your subsurface test account and 
export the file via the url above. If you say you could work with that, 
I'll implement that. Same goes for other direction, if you can put 
together the DLD file with the pictures like that...


The import to Subsurface is now implemented. The export is a bit more 
"interesting" as we do not have concept of main tank. I think to just 
use the first in the XML as the main cylinder and the others as 
additional. Does this make sense?


Damn, you're fast :-)
Yes, the first tank as the main cylinder is perfect, it doesn't really 
matter for any SAC calculations, as all tanks are taken into account. 
The only difference it makes, is that the first "tab" on the dive page 
is your main tank and is not deleteable and the others are the 
additional tanks. So just take the first as the main tank...


Let my know how to proceed with the API...

Rainer

___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: almost missed it - statistics update

2014-10-12 Thread Dirk Hohndel
oops, completely missed this email...

On Mon, Oct 06, 2014 at 07:46:49PM +0200, Krzysztof Arentowicz wrote:
> W dniu 28.09.2014 o 05:50, Dirk Hohndel pisze:
> >> Another idea if we want to work with PADI.  They have a online dive
> >> logging and sharing website, scubaearth.com (and I'm sure other
> > 
> > That is a very cool idea. I assume that several people here are PADI
> > instructors... do we happen to have a PADI Master Instructor or even a
> > Course Director on the list? That might make it easier to reach out to
> > PADI. I will ask a good friend who is an SDI and TDI master instructor to
> > try and get me in contact with them.
> 
> SSI also has its online divelog (a little bit coarse and behind the time, but 
> stil)
> A few weeks ago during my Instructor Evaluation exam I had a chance to talk 
> to Ronny Kain who is SSI Instructor Certifier and I did a presentation of 
> Subsurface
> for him.
> This was just after 4.2 release. He seemed very interested with the program 
> and the idea of exporting data to SSI webpage.
> He was about to look into this further.
> Did anyone from SSI contact you about this?

Not that I remember, but since I missed your email (it arrived while I was
flying to Bonaire) I need to make sure that nothing else fell through the
cracks...

> Also, I include Subsurface as part of my OWD trainings. When we reach topic 
> of computers and dive planning, the next thing I do is show them how to 
> download
> dive data to Subsurface.
> I did not reach too many people yet, but I try to do my job spreading the 
> word ;)

That is excellent. I talked to a couple of dive shop owners / instructors
here in Bonaire this week (one couple owns a diveshop that has the third
highest number of PADI certifications per year) and they also seemed
interested.

/D
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: DLD Changes

2014-10-12 Thread Dirk Hohndel
On Sun, Oct 12, 2014 at 09:52:36PM +0300, Miika Turkia wrote:
> > So the DLD Format just got a few new fields. Example attached. The
> >  is completely optional and always additional to the main
> > tank which continues to live directly in the .
> > Also please note, that a new tag  for Helium percentage has been
> > added to the main tank and all additional tanks.
> >
> 
> The import to Subsurface is now implemented. The export is a bit more
> "interesting" as we do not have concept of main tank. I think to just use
> the first in the XML as the main cylinder and the others as additional.
> Does this make sense?

We used to have code somewhere that said "if there's a gaschange event in
the first 30 seconds (or maybe it was minute), then assume that's the main
tank in use. For example the Cobalt always sends the first gas in use as
part of the first sample...
I've seen many instances where the main (only) gas in use is not the first
one on the Cobalt.

/D
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: DLD Changes

2014-10-12 Thread Miika Turkia
On Sun, Oct 12, 2014 at 9:27 PM, Rainer Mohr  wrote:

> Hi Miika,
>
> As you are the XML and XSLT Master, here comes a request to you for the
> divelogs sync:
> I just released a new version which finally supports multiple tanks. I had
> lots of requests for this, most coming from Subsurface users who want all
> their tanks transferred to divelogs.
>

What is the status of picture support on the API? IIRC you mentioned that
you are working on it, but I don't think it existed the last time I checked.


> So the DLD Format just got a few new fields. Example attached. The
>  is completely optional and always additional to the main
> tank which continues to live directly in the .
> Also please note, that a new tag  for Helium percentage has been
> added to the main tank and all additional tanks.
>

The import to Subsurface is now implemented. The export is a bit more
"interesting" as we do not have concept of main tank. I think to just use
the first in the XML as the main cylinder and the others as additional.
Does this make sense?


> This will work in both directions off course and the API has already been
> updated, so feel free to try and play around.
>

I only have single tank dives, so I leave the testing to others.

miika
From 03113346b008df2fff36604abef296a6eace62a1 Mon Sep 17 00:00:00 2001
From: Miika Turkia 
Date: Sun, 12 Oct 2014 21:42:09 +0300
Subject: [PATCH] Support for importing additional tanks

This patch adds support for importing additional cylinders from
divelogs.de. This also adds support for He on the import.

Signed-off-by: Miika Turkia 
---
 xslt/divelogs.xslt | 38 +-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/xslt/divelogs.xslt b/xslt/divelogs.xslt
index 2f191ae..067a726 100644
--- a/xslt/divelogs.xslt
+++ b/xslt/divelogs.xslt
@@ -75,11 +75,15 @@
 
   
 
-  
   
 
   
 
+
+  
+
+  
+
 
   
 
@@ -101,6 +105,38 @@
 
   
 
+  
+
+  
+
+  
+  
+
+  
+
+  
+  
+
+  
+  
+
+  
+  
+
+  
+
+  
+  
+
+  
+
+  
+  
+
+  
+
+  
+
   
 
   
-- 
1.9.1

___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


DLD Changes

2014-10-12 Thread Rainer Mohr

Hi Miika,

As you are the XML and XSLT Master, here comes a request to you for the 
divelogs sync:
I just released a new version which finally supports multiple tanks. I 
had lots of requests for this, most coming from Subsurface users who 
want all their tanks transferred to divelogs.


So the DLD Format just got a few new fields. Example attached. The 
 is completely optional and always additional to the 
main tank which continues to live directly in the .
Also please note, that a new tag  for Helium percentage has been 
added to the main tank and all additional tanks.


This will work in both directions off course and the API has already 
been updated, so feel free to try and play around.


If I can do anything to help, please shout!
Thanks and regards,
Rainer


  1
  840568
  01.01.2014
  12:31:00
  3810
  9000
  30.2
  15.4
  
  
  
  
  29.0
  29.0
  29.0
  
  
  
  
  1
  6.00
  210.00
  50.00
  230.00
  4.00
  32.0
  
  

  
  
  0
  10.50
  210.00
  140.00
  207.00
  19.0
  30.0


  
  
  1
  11.40
  210.00
  80.00
  207.30
  40.0
  

  
  
  
  
  
  

___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: [PATCH 6/7] This adds a ui for Suunto Vyper settings

2014-10-12 Thread Tomaz Canabrava
On Sun, Oct 12, 2014 at 2:21 PM, Anton Lundin  wrote:

> On 12 October, 2014 - Dirk Hohndel wrote:
>
> > On Sun, Oct 12, 2014 at 04:55:00PM +0200, Anton Lundin wrote:
> > > On 12 October, 2014 - Anton Lundin wrote:
> > >
> > > > This builds up a ui to use for all the settings for the Suunto Vyper
> > > > family devices. Some of the fields are pure information, eg, max
> depth
> > > > and number of dives, so they are marked read-only.
> > > >
> > >
> > > I would love if someone with a better knowledge about qt could answer
> > > this:
> > >
> > > Can you re-use common fields between the two different tab widgets, eg
> > > Serial number, Custom Text and so on between the OSTC3 and the Suunto
> > > Vyper configuration panels?
>
>
not in a easy way, unless it's the same dialog ( then we can just create a
class with it and reuse )
normally it's just more trouble than it's worth it.


> > Tomaz? Thiago?
> >
> > > In this patch i just add another set of the same ones. Is that the
> right
> > > way to do it?
> >
> > I don't know a different way. This is a cool patch series. Thanks.
> > I'm doing test builds right now and expect to push it in a minute.
> > Sadly I don't have access to one of those older devices (Tomaz has my
> > Mosquito, Linus' Gekko got lost... the other Suuntos I have access to are
> > the newer ones like Linus' Vyper Air and HelO₂), so I can't test it.
> >
>
> I've poked Robert and Miika and from what i could read between the lines
> they both had something compatible.
>
> I've have gotten the question about how "safe" the code is to run
> against a device, and I've ran the code against my Suunto Vyper without
> bricking it, and i wrote some strange things to it while developing the
> code so it should be considered as pretty safe.
>
>
> //Anton
>
>
> --
> Anton Lundin+46702-161604
> ___
> subsurface mailing list
> subsurface@subsurface-divelog.org
> http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
>
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: [PATCH 1/7] Initialize everything to zero in devicedetails

2014-10-12 Thread Anton Lundin
On 12 October, 2014 - Anton Lundin wrote:

> Before this, if you did click save backup xml before you read the data,
> you would get a xml file full of bogus. This initializes everything to
> zero.
> 
> Signed-off-by: Anton Lundin 
> ---
>  devicedetails.cpp | 50 --
>  1 file changed, 48 insertions(+), 2 deletions(-)
> 
> diff --git a/devicedetails.cpp b/devicedetails.cpp
> index 4f4d040..d192c67 100644
> --- a/devicedetails.cpp
> +++ b/devicedetails.cpp
> @@ -1,9 +1,55 @@
>  #include "devicedetails.h"
>  
> +// This can probably be done better by someone with better c++-FU
> +const struct gas zero_gas = {0};
> +const struct setpoint zero_setpoint = {0};
> +
>  DeviceDetails::DeviceDetails(QObject *parent) :
...
> + m_gas1(zero_gas),
...
> + m_sp1(zero_setpoint),


I was also wondering if any one with could point me to a better way of
zero-initializing these member structs?

The only recommendations i got from goggling about it was that they
should be converted to c++ classes...


//Anton


-- 
Anton Lundin+46702-161604
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: [PATCH 6/7] This adds a ui for Suunto Vyper settings

2014-10-12 Thread Anton Lundin
On 12 October, 2014 - Dirk Hohndel wrote:

> On Sun, Oct 12, 2014 at 04:55:00PM +0200, Anton Lundin wrote:
> > On 12 October, 2014 - Anton Lundin wrote:
> > 
> > > This builds up a ui to use for all the settings for the Suunto Vyper
> > > family devices. Some of the fields are pure information, eg, max depth
> > > and number of dives, so they are marked read-only.
> > > 
> > 
> > I would love if someone with a better knowledge about qt could answer
> > this:
> > 
> > Can you re-use common fields between the two different tab widgets, eg
> > Serial number, Custom Text and so on between the OSTC3 and the Suunto
> > Vyper configuration panels?
> 
> Tomaz? Thiago?
> 
> > In this patch i just add another set of the same ones. Is that the right
> > way to do it?
> 
> I don't know a different way. This is a cool patch series. Thanks.
> I'm doing test builds right now and expect to push it in a minute.
> Sadly I don't have access to one of those older devices (Tomaz has my
> Mosquito, Linus' Gekko got lost... the other Suuntos I have access to are
> the newer ones like Linus' Vyper Air and HelO₂), so I can't test it.
> 

I've poked Robert and Miika and from what i could read between the lines
they both had something compatible.

I've have gotten the question about how "safe" the code is to run
against a device, and I've ran the code against my Suunto Vyper without
bricking it, and i wrote some strange things to it while developing the
code so it should be considered as pretty safe.


//Anton


-- 
Anton Lundin+46702-161604
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: Problems with ceiling for CCR dive

2014-10-12 Thread Robert C. Helling
Willem,



> Am 12.10.2014 um 18:41 schrieb Willem Ferguson 
> :
> 
> The ceiling is not correct.

Would you mind sending me the xml? I hope I can find some time tomorrow to look 
into this. 

Best 
Robert
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: Problems with ceiling for CCR dive

2014-10-12 Thread Anton Lundin
On 12 October, 2014 - Willem Ferguson wrote:

> Robert,
> 
> Attached a screenshot of the present state of the Poseidon CCR dive profile.
> The ceiling is not correct. Where does the software that draws the ceiling
> get the information from in order to draw the ceiling? The pn2 graph (top
> one) looks more or less ok? The po2 graph is the bottom one.
> 

I'm guessing you're screenshot is from Poseidon_MkVI_6-14_import.xml,
and if i look into that file, i see that at 7:00 it says in the xml:
sensor1="1.17 bar" sensor2="1.15 bar", and when subsurface have loaded
that file it says that you're breathing a ppO2 of 0.51 bar at 7:00.
Thats probably why the deco is way off.

All the deco/ceiling calculations are done in
calculate_deco_information(), and thats using entry->pressures.o2 to
compute the deco info based in ppO2.

//Anton

-- 
Anton Lundin+46702-161604
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: [PATCH 6/7] This adds a ui for Suunto Vyper settings

2014-10-12 Thread Dirk Hohndel
On Sun, Oct 12, 2014 at 04:55:00PM +0200, Anton Lundin wrote:
> On 12 October, 2014 - Anton Lundin wrote:
> 
> > This builds up a ui to use for all the settings for the Suunto Vyper
> > family devices. Some of the fields are pure information, eg, max depth
> > and number of dives, so they are marked read-only.
> > 
> 
> I would love if someone with a better knowledge about qt could answer
> this:
> 
> Can you re-use common fields between the two different tab widgets, eg
> Serial number, Custom Text and so on between the OSTC3 and the Suunto
> Vyper configuration panels?

Tomaz? Thiago?

> In this patch i just add another set of the same ones. Is that the right
> way to do it?

I don't know a different way. This is a cool patch series. Thanks.
I'm doing test builds right now and expect to push it in a minute.
Sadly I don't have access to one of those older devices (Tomaz has my
Mosquito, Linus' Gekko got lost... the other Suuntos I have access to are
the newer ones like Linus' Vyper Air and HelO₂), so I can't test it.


/D
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


[PATCH] Remove unused variables

2014-10-12 Thread Anton Lundin
Signed-off-by: Anton Lundin 
---
 profile.c | 5 +
 qt-ui/profile/diveprofileitem.cpp | 6 +++---
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/profile.c b/profile.c
index 79917d6..4f6517b 100644
--- a/profile.c
+++ b/profile.c
@@ -824,7 +824,6 @@ static void calculate_gas_information_new(struct dive 
*dive, struct plot_info *p
 {
int i;
double amb_pressure;
-   struct gas_pressures pressures;
 
for (i = 1; i < pi->nr; i++) {
int fo2, fhe;
@@ -894,9 +893,7 @@ static void debug_print_profiledata(struct plot_info *pi)
  */
 void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct 
plot_info *pi)
 {
-   FILE *f1;
-   int i, o2, he, o2low;
-   struct plot_data *entry;
+   int o2, he, o2low;
init_decompression(dive);
/* Create the new plot data */
free((void *)last_pi_entry_new);
diff --git a/qt-ui/profile/diveprofileitem.cpp 
b/qt-ui/profile/diveprofileitem.cpp
index ef75f2f..10fb626 100644
--- a/qt-ui/profile/diveprofileitem.cpp
+++ b/qt-ui/profile/diveprofileitem.cpp
@@ -352,7 +352,7 @@ DivePercentageItem::DivePercentageItem(int i)
 
 void DivePercentageItem::modelDataChanged(const QModelIndex &topLeft, const 
QModelIndex &bottomRight)
 {
-   int last = -300, last_printed_hr = 0, sec = 0;
+   int sec = 0;
 
// We don't have enougth data to calculate things, quit.
if (!shouldCalculateStuff(topLeft, bottomRight))
@@ -401,7 +401,7 @@ DiveAmbPressureItem::DiveAmbPressureItem()
 
 void DiveAmbPressureItem::modelDataChanged(const QModelIndex &topLeft, const 
QModelIndex &bottomRight)
 {
-   int last = -300, last_printed_hr = 0, sec = 0;
+   int sec = 0;
 
// We don't have enougth data to calculate things, quit.
if (!shouldCalculateStuff(topLeft, bottomRight))
@@ -450,7 +450,7 @@ DiveGFLineItem::DiveGFLineItem()
 
 void DiveGFLineItem::modelDataChanged(const QModelIndex &topLeft, const 
QModelIndex &bottomRight)
 {
-   int last = -300, last_printed_hr = 0, sec = 0;
+   int sec = 0;
 
// We don't have enougth data to calculate things, quit.
if (!shouldCalculateStuff(topLeft, bottomRight))
-- 
1.9.1

___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


Re: [PATCH 6/7] This adds a ui for Suunto Vyper settings

2014-10-12 Thread Anton Lundin
On 12 October, 2014 - Anton Lundin wrote:

> This builds up a ui to use for all the settings for the Suunto Vyper
> family devices. Some of the fields are pure information, eg, max depth
> and number of dives, so they are marked read-only.
> 

I would love if someone with a better knowledge about qt could answer
this:

Can you re-use common fields between the two different tab widgets, eg
Serial number, Custom Text and so on between the OSTC3 and the Suunto
Vyper configuration panels?


In this patch i just add another set of the same ones. Is that the right
way to do it?


//Anton


-- 
Anton Lundin+46702-161604
___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


[PATCH 6/7] This adds a ui for Suunto Vyper settings

2014-10-12 Thread Anton Lundin
This builds up a ui to use for all the settings for the Suunto Vyper
family devices. Some of the fields are pure information, eg, max depth
and number of dives, so they are marked read-only.

Signed-off-by: Anton Lundin 
---
 qt-ui/configuredivecomputerdialog.cpp |   7 +
 qt-ui/configuredivecomputerdialog.ui  | 480 --
 2 files changed, 466 insertions(+), 21 deletions(-)

diff --git a/qt-ui/configuredivecomputerdialog.cpp 
b/qt-ui/configuredivecomputerdialog.cpp
index cfc1b8d..39ec9fb 100644
--- a/qt-ui/configuredivecomputerdialog.cpp
+++ b/qt-ui/configuredivecomputerdialog.cpp
@@ -462,6 +462,13 @@ void 
ConfigureDiveComputerDialog::on_DiveComputerList_currentRowChanged(int curr
selected_vendor = "Heinrichs Weikamp";
selected_product = "OSTC 3";
break;
+   case 1:
+   selected_vendor = "Suunto";
+   selected_product = "Vyper";
+   break;
+   default:
+   /* Not Supported */
+   return;
}
 
int dcType = DC_TYPE_SERIAL;
diff --git a/qt-ui/configuredivecomputerdialog.ui 
b/qt-ui/configuredivecomputerdialog.ui
index 2a2d89b..94390e9 100644
--- a/qt-ui/configuredivecomputerdialog.ui
+++ b/qt-ui/configuredivecomputerdialog.ui
@@ -17,7 +17,7 @@

 
  
-  
+  

 Device or mount point

@@ -160,12 +160,20 @@
  :/icons/ostc3.png:/icons/ostc3.png

   
+  
+   
+Suunto Vyper Family
+   
+  
  
  
-  
+  
+   1
+  
+  

 
- 
+ 
   
0
   
@@ -175,7 +183,7 @@


 
- 
+ 
   
Serial No.
   
@@ -186,13 +194,19 @@
 
 
  
+  
+   
+1
+0
+   
+  
   
true
   
  
 
 
- 
+ 
   
Firmware version
   
@@ -209,7 +223,7 @@
  
 
 
- 
+ 
   
Custom text
   
@@ -229,7 +243,7 @@
  
 
 
- 
+ 
   
Language
   
@@ -297,7 +311,7 @@
  
 
 
- 
+ 
   
Date format
   
@@ -326,7 +340,7 @@
  
 
 
- 
+ 
   
Saturation
   
@@ -343,7 +357,7 @@
  
 
 
- 
+ 
   
Desaturation
   
@@ -360,7 +374,7 @@
  
 
 
- 
+ 
   
Last deco
   
@@ -377,7 +391,7 @@
  
 
 
- 
+ 
   
Brightness
   
@@ -406,7 +420,7 @@
  
 
 
- 
+ 
   
Sampling rate
   
@@ -430,7 +444,7 @@
  
 
 
- 
+ 
   
Units
   
@@ -454,7 +468,7 @@
  
 
 
- 
+ 
   
Dive mode color
   
@@ -488,7 +502,7 @@
  
 
 
- 
+ 
   
Salinity (0-5%)
   
@@ -593,7 +607,7 @@

 Gas settings

-   
+   
 
  
   
@@ -845,6 +859,382 @@
 

   
+  
+   
+
+ 
+  
+   0
+  
+  
+   
+Basic settings
+   
+   
+
+ 
+  
+   
+1
+0
+   
+  
+  
+   true
+  
+  
+   200
+  
+ 
+
+
+ 
+  
+   Safety level
+  
+ 
+
+
+ 
+  
+   
+A0 (0m - 300m)
+   
+  
+  
+   
+A1 (300m - 1500m)
+   
+  
+  
+   
+A2 (1500m - 3000m)
+   
+  
+ 
+
+
+ 
+   

[PATCH 7/7] Connect the Suunto Vyper Configuration ui

2014-10-12 Thread Anton Lundin
This code connects up the configuration ui with the backing
data structures thats gets read/written to/from the devices.

Signed-off-by: Anton Lundin 
---
 qt-ui/configuredivecomputerdialog.cpp | 66 +++
 qt-ui/configuredivecomputerdialog.h   |  4 +++
 2 files changed, 70 insertions(+)

diff --git a/qt-ui/configuredivecomputerdialog.cpp 
b/qt-ui/configuredivecomputerdialog.cpp
index 39ec9fb..635740a 100644
--- a/qt-ui/configuredivecomputerdialog.cpp
+++ b/qt-ui/configuredivecomputerdialog.cpp
@@ -116,6 +116,18 @@ void ConfigureDiveComputerDialog::fill_computer_list()
 
 void ConfigureDiveComputerDialog::populateDeviceDetails()
 {
+   switch(ui->dcStackedWidget->currentIndex()) {
+   case 0:
+   populateDeviceDetailsOSTC3();
+   break;
+   case 1:
+   populateDeviceDetailsSuuntoVyper();
+   break;
+   }
+}
+
+void ConfigureDiveComputerDialog::populateDeviceDetailsOSTC3()
+{
deviceDetails->setCustomText(ui->customTextLlineEdit->text());
deviceDetails->setDiveMode(ui->diveModeComboBox->currentIndex());
deviceDetails->setSaturation(ui->saturationSpinBox->value());
@@ -236,6 +248,23 @@ void ConfigureDiveComputerDialog::populateDeviceDetails()
deviceDetails->setSp5(sp5);
 }
 
+void ConfigureDiveComputerDialog::populateDeviceDetailsSuuntoVyper()
+{
+   deviceDetails->setCustomText(ui->customTextLlineEdit_1->text());
+   
deviceDetails->setSamplingRate(ui->samplingRateComboBox_1->currentIndex() == 3 
? 60 : (ui->samplingRateComboBox_1->currentIndex() + 1) * 10);
+   deviceDetails->setAltitude(ui->altitudeRangeComboBox->currentIndex());
+   
deviceDetails->setPersonalSafety(ui->personalSafetyComboBox->currentIndex());
+   deviceDetails->setTimeFormat(ui->timeFormatComboBox->currentIndex());
+   deviceDetails->setUnits(ui->unitsComboBox_1->currentIndex());
+   deviceDetails->setDiveMode(ui->diveModeComboBox_1->currentIndex());
+   deviceDetails->setLightEnabled(ui->lightCheckBox->isChecked());
+   deviceDetails->setLight(ui->lightSpinBox->value());
+   
deviceDetails->setAlarmDepthEnabled(ui->alarmDepthCheckBox->isChecked());
+   
deviceDetails->setAlarmDepth(units_to_depth(ui->alarmDepthDoubleSpinBox->value()));
+   deviceDetails->setAlarmTimeEnabled(ui->alarmTimeCheckBox->isChecked());
+   deviceDetails->setAlarmTime(ui->alarmTimeSpinBox->value());
+}
+
 void ConfigureDiveComputerDialog::readSettings()
 {
ui->statusLabel->clear();
@@ -293,6 +322,18 @@ void 
ConfigureDiveComputerDialog::deviceDetailsReceived(DeviceDetails *newDevice
 
 void ConfigureDiveComputerDialog::reloadValues()
 {
+   switch(ui->dcStackedWidget->currentIndex()) {
+   case 0:
+   reloadValuesOSTC3();
+   break;
+   case 1:
+   reloadValuesSuuntoVyper();
+   break;
+   }
+}
+
+void ConfigureDiveComputerDialog::reloadValuesOSTC3()
+{
ui->serialNoLineEdit->setText(deviceDetails->serialNo());
ui->firmwareVersionLineEdit->setText(deviceDetails->firmwareVersion());
ui->customTextLlineEdit->setText(deviceDetails->customText());
@@ -390,6 +431,31 @@ void ConfigureDiveComputerDialog::reloadValues()
ui->ostc3SetPointTable->setItem(4, 2, new 
QTableWidgetItem(QString::number(deviceDetails->sp5().depth)));
 }
 
+void ConfigureDiveComputerDialog::reloadValuesSuuntoVyper()
+{
+   const char *depth_unit;
+   
ui->maxDepthDoubleSpinBox->setValue(get_depth_units(deviceDetails->maxDepth(), 
NULL, &depth_unit));
+   ui->maxDepthDoubleSpinBox->setSuffix(depth_unit);
+   ui->totalTimeSpinBox->setValue(deviceDetails->totalTime());
+   ui->numberOfDivesSpinBox->setValue(deviceDetails->numberOfDives());
+   ui->modelLineEdit->setText(deviceDetails->model());
+   
ui->firmwareVersionLineEdit_1->setText(deviceDetails->firmwareVersion());
+   ui->serialNoLineEdit_1->setText(deviceDetails->serialNo());
+   ui->customTextLlineEdit_1->setText(deviceDetails->customText());
+   
ui->samplingRateComboBox_1->setCurrentIndex(deviceDetails->samplingRate() == 60 
? 3 : (deviceDetails->samplingRate() / 10) - 1);
+   ui->altitudeRangeComboBox->setCurrentIndex(deviceDetails->altitude());
+   
ui->personalSafetyComboBox->setCurrentIndex(deviceDetails->personalSafety());
+   ui->timeFormatComboBox->setCurrentIndex(deviceDetails->timeFormat());
+   ui->unitsComboBox_1->setCurrentIndex(deviceDetails->units());
+   ui->diveModeComboBox_1->setCurrentIndex(deviceDetails->diveMode());
+   ui->lightCheckBox->setChecked(deviceDetails->lightEnabled());
+   ui->lightSpinBox->setValue(deviceDetails->light());
+   ui->alarmDepthCheckBox->setChecked(deviceDetails->alarmDepthEnabled());
+   
ui->alarmDepthDoubleSpinBox->setValue(get_depth_units(deviceDetails->alarmDepth(),
 NULL, &depth_unit));
+   ui->alarmDepthDoubleSpinBox->setSuffix(depth

[PATCH 5/7] This adds read/write of Suunto Vyper configs

2014-10-12 Thread Anton Lundin
This implements the reading and writing of the configuration varables
from the Suunto Vyper family devices.

Everything here is implemented based on the excellent information on:
http://www.sarnau.info/papers:suunto_vyper

Signed-off-by: Anton Lundin 
---
 configuredivecomputerthreads.cpp | 167 ++-
 1 file changed, 165 insertions(+), 2 deletions(-)

diff --git a/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp
index 7554467..6f0ff9a 100644
--- a/configuredivecomputerthreads.cpp
+++ b/configuredivecomputerthreads.cpp
@@ -44,6 +44,25 @@
 #define OSTC3_PRESSURE_SENSOR_OFFSET   0x35
 #define OSTC3_SAFETY_STOP  0x36
 
+#define SUUNTO_VYPER_MAXDEPTH 0x1e
+#define SUUNTO_VYPER_TOTAL_TIME   0x20
+#define SUUNTO_VYPER_NUMBEROFDIVES0x22
+#define SUUNTO_VYPER_COMPUTER_TYPE0x24
+#define SUUNTO_VYPER_FIRMWARE 0x25
+#define SUUNTO_VYPER_SERIALNUMBER 0x26
+#define SUUNTO_VYPER_CUSTOM_TEXT  0x2c
+#define SUUNTO_VYPER_SAMPLING_RATE0x53
+#define SUUNTO_VYPER_ALTITUDE_SAFETY  0x54
+#define SUUNTO_VYPER_TIMEFORMAT   0x60
+#define SUUNTO_VYPER_UNITS0x62
+#define SUUNTO_VYPER_MODEL0x63
+#define SUUNTO_VYPER_LIGHT0x64
+#define SUUNTO_VYPER_ALARM_DEPTH_TIME 0x65
+#define SUUNTO_VYPER_ALARM_TIME   0x66
+#define SUUNTO_VYPER_ALARM_DEPTH  0x68
+#define SUUNTO_VYPER_CUSTOM_TEXT_LENGHT   30
+
+
 ReadSettingsThread::ReadSettingsThread(QObject *parent, device_data_t *data)
: QThread(parent), m_data(data)
 {
@@ -57,8 +76,112 @@ void ReadSettingsThread::run()
rc = dc_device_open(&m_data->device, m_data->context, 
m_data->descriptor, m_data->devname);
if (rc == DC_STATUS_SUCCESS) {
DeviceDetails *m_deviceDetails = new DeviceDetails(0);
+   switch (dc_device_get_type(m_data->device)) {
+   case DC_FAMILY_SUUNTO_VYPER:
+   supported = true;
+   unsigned char data[SUUNTO_VYPER_CUSTOM_TEXT_LENGHT + 1];
+   rc = dc_device_read(m_data->device, 
SUUNTO_VYPER_MAXDEPTH, data, 2);
+   if (rc == DC_STATUS_SUCCESS) {
+   // in ft * 128.0
+   int depth = feet_to_mm(data[0] << 8 ^ data[1]) 
/ 128;
+   m_deviceDetails->setMaxDepth(depth);
+   }
+   rc = dc_device_read(m_data->device, 
SUUNTO_VYPER_TOTAL_TIME, data, 2);
+   if (rc == DC_STATUS_SUCCESS) {
+   int total_time = data[0] << 8 ^ data[1];
+   m_deviceDetails->setTotalTime(total_time);
+   }
+   rc = dc_device_read(m_data->device, 
SUUNTO_VYPER_NUMBEROFDIVES, data, 2);
+   if (rc == DC_STATUS_SUCCESS) {
+   int number_of_dives = data[0] << 8 ^ data[1];
+   
m_deviceDetails->setNumberOfDives(number_of_dives);
+   }
+   rc = dc_device_read(m_data->device, 
SUUNTO_VYPER_COMPUTER_TYPE, data, 1);
+   if (rc == DC_STATUS_SUCCESS) {
+   const char *model;
+   switch(data[0]) {
+   case 0x03:
+   model = "Stinger";
+   break;
+   case 0x04:
+   model = "Mosquito";
+   break;
+   case 0x0A:
+   model = "new Vyper";
+   break;
+   case 0x0C:
+   model = "Vyper or Cobra";
+   break;
+   case 0x0B:
+   model = "Vytec";
+   break;
+   case 0x0D:
+   model = "Gekko";
+   break;
+   default:
+   model = "UNKNOWN";
+   }
+   m_deviceDetails->setModel(model);
+   }
+   rc = dc_device_read(m_data->device, 
SUUNTO_VYPER_FIRMWARE, data, 1);
+   if (rc == DC_STATUS_SUCCESS) {
+   
m_deviceDetails->setFirmwareVersion(QString::number(data[0]) + ".0.0");
+   }
+   rc = dc_device_read(m_data->device, 
SUUNTO_VYPER_SERIALNUMBER, data, 4);
+   if (rc == DC_STATUS_SUCCESS) {
+ 

[PATCH 4/7] This saves and restores Suunto Vyper configs

2014-10-12 Thread Anton Lundin
Signed-off-by: Anton Lundin 
---
 configuredivecomputer.cpp | 48 +++
 1 file changed, 48 insertions(+)

diff --git a/configuredivecomputer.cpp b/configuredivecomputer.cpp
index 5fe5a4a..addc2a7 100644
--- a/configuredivecomputer.cpp
+++ b/configuredivecomputer.cpp
@@ -181,6 +181,26 @@ bool ConfigureDiveComputer::saveXMLBackup(QString 
fileName, DeviceDetails *detai
writer.writeTextElement("DateFormat", 
QString::number(details->dateFormat()));
writer.writeTextElement("CompassGain", 
QString::number(details->compassGain()));
 
+   // Suunto vyper settings.
+   writer.writeTextElement("Altitude", 
QString::number(details->altitude()));
+   writer.writeTextElement("PersonalSafety", 
QString::number(details->personalSafety()));
+   writer.writeTextElement("TimeFormat", 
QString::number(details->timeFormat()));
+
+   writer.writeStartElement("Light");
+   writer.writeAttribute("enabled", 
QString::number(details->lightEnabled()));
+   writer.writeCharacters(QString::number(details->light()));
+   writer.writeEndElement();
+
+   writer.writeStartElement("AlarmTime");
+   writer.writeAttribute("enabled", 
QString::number(details->alarmTimeEnabled()));
+   writer.writeCharacters(QString::number(details->alarmTime()));
+   writer.writeEndElement();
+
+   writer.writeStartElement("AlarmDepth");
+   writer.writeAttribute("enabled", 
QString::number(details->alarmDepthEnabled()));
+   writer.writeCharacters(QString::number(details->alarmDepth()));
+   writer.writeEndElement();
+
writer.writeEndElement();
writer.writeEndElement();
 
@@ -213,6 +233,7 @@ bool ConfigureDiveComputer::restoreXMLBackup(QString 
fileName, DeviceDetails *de
while (!reader.atEnd()) {
if (reader.isStartElement()) {
QString settingName = reader.name().toString();
+   QXmlStreamAttributes attributes = reader.attributes();
reader.readNext();
QString keyString = reader.text().toString();
 
@@ -394,6 +415,33 @@ bool ConfigureDiveComputer::restoreXMLBackup(QString 
fileName, DeviceDetails *de
 
if (settingName == "CompassGain")
details->setCompassGain(keyString.toInt());
+
+   if (settingName == "Altitude")
+   details->setAltitude(keyString.toInt());
+
+   if (settingName == "PersonalSafety")
+   details->setPersonalSafety(keyString.toInt());
+
+   if (settingName == "TimeFormat")
+   details->setTimeFormat(keyString.toInt());
+
+   if (settingName == "Light") {
+   if (attributes.hasAttribute("enabled"))
+   
details->setLightEnabled(attributes.value("enabled").toString().toInt());
+   details->setLight(keyString.toInt());
+   }
+
+   if (settingName == "AlarmDepth") {
+   if (attributes.hasAttribute("enabled"))
+   
details->setAlarmDepthEnabled(attributes.value("enabled").toString().toInt());
+   details->setAlarmDepth(keyString.toInt());
+   }
+
+   if (settingName == "AlarmTime") {
+   if (attributes.hasAttribute("enabled"))
+   
details->setAlarmTimeEnabled(attributes.value("enabled").toString().toInt());
+   details->setAlarmTime(keyString.toInt());
+   }
}
reader.readNext();
}
-- 
1.9.1

___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


[PATCH 1/7] Initialize everything to zero in devicedetails

2014-10-12 Thread Anton Lundin
Before this, if you did click save backup xml before you read the data,
you would get a xml file full of bogus. This initializes everything to
zero.

Signed-off-by: Anton Lundin 
---
 devicedetails.cpp | 50 --
 1 file changed, 48 insertions(+), 2 deletions(-)

diff --git a/devicedetails.cpp b/devicedetails.cpp
index 4f4d040..d192c67 100644
--- a/devicedetails.cpp
+++ b/devicedetails.cpp
@@ -1,9 +1,55 @@
 #include "devicedetails.h"
 
+// This can probably be done better by someone with better c++-FU
+const struct gas zero_gas = {0};
+const struct setpoint zero_setpoint = {0};
+
 DeviceDetails::DeviceDetails(QObject *parent) :
-   QObject(parent)
+   QObject(parent),
+   m_data(0),
+   m_serialNo(""),
+   m_firmwareVersion(""),
+   m_customText(""),
+   m_syncTime(false),
+   m_gas1(zero_gas),
+   m_gas2(zero_gas),
+   m_gas3(zero_gas),
+   m_gas4(zero_gas),
+   m_gas5(zero_gas),
+   m_dil1(zero_gas),
+   m_dil2(zero_gas),
+   m_dil3(zero_gas),
+   m_dil4(zero_gas),
+   m_dil5(zero_gas),
+   m_sp1(zero_setpoint),
+   m_sp2(zero_setpoint),
+   m_sp3(zero_setpoint),
+   m_sp4(zero_setpoint),
+   m_sp5(zero_setpoint),
+   m_ccrMode(0),
+   m_diveMode(0),
+   m_decoType(0),
+   m_pp02Max(0),
+   m_pp02Min(0),
+   m_futureTTS(0),
+   m_gfLow(0),
+   m_gfHigh(0),
+   m_aGFLow(0),
+   m_aGFHigh(0),
+   m_aGFSelectable(0),
+   m_saturation(0),
+   m_desaturation(0),
+   m_lastDeco(0),
+   m_brightness(0),
+   m_units(0),
+   m_samplingRate(0),
+   m_salinity(0),
+   m_diveModeColor(0),
+   m_language(0),
+   m_dateFormat(0),
+   m_compassGain(0),
+   m_pressureSensorOffset(0)
 {
-
 }
 
 device_data_t *DeviceDetails::data() const
-- 
1.9.1

___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


[PATCH 2/7] Remove double-assignment to rc varable

2014-10-12 Thread Anton Lundin
Signed-off-by: Anton Lundin 
---
 configuredivecomputerthreads.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/configuredivecomputerthreads.cpp b/configuredivecomputerthreads.cpp
index 04954ad..7554467 100644
--- a/configuredivecomputerthreads.cpp
+++ b/configuredivecomputerthreads.cpp
@@ -54,7 +54,7 @@ void ReadSettingsThread::run()
 {
bool supported = false;
dc_status_t rc;
-   rc = rc = dc_device_open(&m_data->device, m_data->context, 
m_data->descriptor, m_data->devname);
+   rc = dc_device_open(&m_data->device, m_data->context, 
m_data->descriptor, m_data->devname);
if (rc == DC_STATUS_SUCCESS) {
DeviceDetails *m_deviceDetails = new DeviceDetails(0);
 #if DC_VERSION_CHECK(0, 5, 0)
@@ -328,7 +328,7 @@ void WriteSettingsThread::run()
 {
bool supported = false;
dc_status_t rc;
-   rc = rc = dc_device_open(&m_data->device, m_data->context, 
m_data->descriptor, m_data->devname);
+   rc = dc_device_open(&m_data->device, m_data->context, 
m_data->descriptor, m_data->devname);
if (rc == DC_STATUS_SUCCESS) {
 #if DC_VERSION_CHECK(0,5,0)
if (dc_device_get_type(m_data->device) == DC_FAMILY_HW_OSTC3) {
@@ -520,7 +520,7 @@ void FirmwareUpdateThread::run()
 {
bool supported = false;
dc_status_t rc;
-   rc = rc = dc_device_open(&m_data->device, m_data->context, 
m_data->descriptor, m_data->devname);
+   rc = dc_device_open(&m_data->device, m_data->context, 
m_data->descriptor, m_data->devname);
if (rc == DC_STATUS_SUCCESS) {
 #if DC_VERSION_CHECK(0, 5, 0)
if (dc_device_get_type(m_data->device) == DC_FAMILY_HW_OSTC3) {
-- 
1.9.1

___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


[PATCH 3/7] Add backing stores for Suunto Vyper configurations

2014-10-12 Thread Anton Lundin
This adds varables to store all the settings for the Suunto Vyper
family.

Signed-off-by: Anton Lundin 
---
 devicedetails.cpp | 145 +-
 devicedetails.h   |  52 
 2 files changed, 196 insertions(+), 1 deletion(-)

diff --git a/devicedetails.cpp b/devicedetails.cpp
index d192c67..ccd7689 100644
--- a/devicedetails.cpp
+++ b/devicedetails.cpp
@@ -10,6 +10,7 @@ DeviceDetails::DeviceDetails(QObject *parent) :
m_serialNo(""),
m_firmwareVersion(""),
m_customText(""),
+   m_model(""),
m_syncTime(false),
m_gas1(zero_gas),
m_gas2(zero_gas),
@@ -48,7 +49,19 @@ DeviceDetails::DeviceDetails(QObject *parent) :
m_language(0),
m_dateFormat(0),
m_compassGain(0),
-   m_pressureSensorOffset(0)
+   m_pressureSensorOffset(0),
+   m_maxDepth(0),
+   m_totalTime(0),
+   m_numberOfDives(0),
+   m_altitude(0),
+   m_personalSafety(0),
+   m_timeFormat(0),
+   m_lightEnabled(false),
+   m_light(0),
+   m_alarmTimeEnabled(false),
+   m_alarmTime(0),
+   m_alarmDepthEnabled(false),
+   m_alarmDepth(0)
 {
 }
 
@@ -92,6 +105,16 @@ void DeviceDetails::setCustomText(const QString &customText)
m_customText = customText;
 }
 
+QString DeviceDetails::model() const
+{
+   return m_model;
+}
+
+void DeviceDetails::setModel(const QString &model)
+{
+   m_model = model;
+}
+
 int DeviceDetails::brightness() const
 {
return m_brightness;
@@ -481,3 +504,123 @@ void DeviceDetails::setPressureSensorOffset(int 
pressureSensorOffset)
 {
m_pressureSensorOffset = pressureSensorOffset;
 }
+
+int DeviceDetails::maxDepth() const
+{
+   return m_maxDepth;
+}
+
+void DeviceDetails::setMaxDepth(int maxDepth)
+{
+   m_maxDepth = maxDepth;
+}
+
+int DeviceDetails::totalTime() const
+{
+   return m_totalTime;
+}
+
+void DeviceDetails::setTotalTime(int totalTime)
+{
+   m_totalTime = totalTime;
+}
+
+int DeviceDetails::numberOfDives() const
+{
+   return m_numberOfDives;
+}
+
+void DeviceDetails::setNumberOfDives(int numberOfDives)
+{
+   m_numberOfDives = numberOfDives;
+}
+
+int DeviceDetails::altitude() const
+{
+   return m_altitude;
+}
+
+void DeviceDetails::setAltitude(int altitude)
+{
+   m_altitude = altitude;
+}
+
+int DeviceDetails::personalSafety() const
+{
+   return m_personalSafety;
+}
+
+void DeviceDetails::setPersonalSafety(int personalSafety)
+{
+   m_personalSafety = personalSafety;
+}
+
+int DeviceDetails::timeFormat() const
+{
+   return m_timeFormat;
+}
+
+void DeviceDetails::setTimeFormat(int timeFormat)
+{
+   m_timeFormat = timeFormat;
+}
+
+bool DeviceDetails::lightEnabled() const
+{
+   return m_lightEnabled;
+}
+
+void DeviceDetails::setLightEnabled(bool lightEnabled)
+{
+   m_lightEnabled = lightEnabled;
+}
+
+int DeviceDetails::light() const
+{
+   return m_light;
+}
+
+void DeviceDetails::setLight(int light)
+{
+   m_light = light;
+}
+
+bool DeviceDetails::alarmTimeEnabled() const
+{
+   return m_alarmTimeEnabled;
+}
+
+void DeviceDetails::setAlarmTimeEnabled(bool alarmTimeEnabled)
+{
+   m_alarmTimeEnabled = alarmTimeEnabled;
+}
+
+int DeviceDetails::alarmTime() const
+{
+   return m_alarmTime;
+}
+
+void DeviceDetails::setAlarmTime(int alarmTime)
+{
+   m_alarmTime = alarmTime;
+}
+
+bool DeviceDetails::alarmDepthEnabled() const
+{
+   return m_alarmDepthEnabled;
+}
+
+void DeviceDetails::setAlarmDepthEnabled(bool alarmDepthEnabled)
+{
+   m_alarmDepthEnabled = alarmDepthEnabled;
+}
+
+int DeviceDetails::alarmDepth() const
+{
+   return m_alarmDepth;
+}
+
+void DeviceDetails::setAlarmDepth(int alarmDepth)
+{
+   m_alarmDepth = alarmDepth;
+}
diff --git a/devicedetails.h b/devicedetails.h
index 372d5cd..4953f72 100644
--- a/devicedetails.h
+++ b/devicedetails.h
@@ -35,6 +35,9 @@ public:
QString customText() const;
void setCustomText(const QString &customText);
 
+   QString model() const;
+   void setModel(const QString &model);
+
int brightness() const;
void setBrightness(int brightness);
 
@@ -152,11 +155,48 @@ public:
int pressureSensorOffset() const;
void setPressureSensorOffset(int pressureSensorOffset);
 
+   int maxDepth() const;
+   void setMaxDepth(int maxDepth);
+
+   int totalTime() const;
+   void setTotalTime(int totalTime);
+
+   int numberOfDives() const;
+   void setNumberOfDives(int numberOfDives);
+
+   int altitude() const;
+   void setAltitude(int altitude);
+
+   int personalSafety() const;
+   void setPersonalSafety(int personalSafety);
+
+   int timeFormat() const;
+   void setTimeFormat(int timeFormat);
+
+   bool lightEnabled() const;
+   void setLightEnabled(bool lightEnabled);
+
+   int light() const;
+   void setLight(int light);
+
+   bool alarmTimeEnabl

Start sanitizing gaschange event information

2014-10-12 Thread Willem Ferguson
What this also does is to lay one of  the foundations of dealing with 
sidemount dives where two or more cylinders have the same gas mix.

Thanks, Linus, I have been waiting long for this one.
Kind regards,
willem

___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


[CCR PATCH] Process o2 sensor partial pressure data. (patch 2 of 3)

2014-10-12 Thread Willem Ferguson

This patch does three things:
1) A new function fill_o2_values() is added to profile.c. This
   fills all oxygen senssor and setpoint values that have been
   zeroed before in order to save space in the dive log. This
   recreates the full set of sensor values obtained from the
   original CCR xml log file.
2) Function fill_o2_values() is activated in function create_
   plot_info_new() in profile.c
3) The calling parameters to function fill_pressures() in dive.c
   are changed. The last parameter is now a pointer to a structure
   of divecomputer. This will be needed in the last patch of the
   present series of three patches.

Signed-off-by: willem ferguson 

>From a5ac2baca19dad4cb54e729b298896e6d3399e7f Mon Sep 17 00:00:00 2001
From: willem ferguson 
Date: Sun, 12 Oct 2014 14:46:20 +0200
Subject: [PATCH 4/4] CCR patch Oxygen partial pressures (patch 2 of 3)

This patch does three things:
1) A new function fill_o2_values() is added to profile.c. This
   fills all oxygen sesnsor and setpoint values that have been
   zeroed before in order to save space in the dive log. This
   recreates the full set of sensor values obtained from the
   original CCR xml log file.
2) Function fill_o2_values() is activated in function create_
   plot_info_new() in profile.c
3) The calling parameters to function fill_pressures() in dive.c
   are changed. The last parameter is now a pointer to a structure
   of divecomputer. This will be needed in the last patch of the
   present seies of three patches.

Signed-off-by: willem ferguson 
---
 deco.c|  2 +-
 dive.c|  2 +-
 dive.h|  5 -
 profile.c | 44 ++--
 4 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/deco.c b/deco.c
index ec281b1..42580d3 100644
--- a/deco.c
+++ b/deco.c
@@ -190,7 +190,7 @@ double add_segment(double pressure, const struct gasmix *gasmix, int period_in_s
 	int fo2 = get_o2(gasmix), fhe = get_he(gasmix);
 	struct gas_pressures pressures;
 
-	fill_pressures(&pressures, pressure, gasmix, (double) ccpo2 / 1000.0, dive->dc.dctype);
+	fill_pressures(&pressures, pressure, gasmix, (double) ccpo2 / 1000.0, &(dive->dc));
 
 	if (buehlmann_config.gf_low_at_maxdepth && pressure > gf_low_pressure_this_dive)
 		gf_low_pressure_this_dive = pressure;
diff --git a/dive.c b/dive.c
index 9972212..b0c69ac 100644
--- a/dive.c
+++ b/dive.c
@@ -1483,7 +1483,7 @@ int gasmix_distance(const struct gasmix *a, const struct gasmix *b)
 }
 
 /* Compute partial gas pressures in bar from gasmix and ambient pressures, possibly for OC or CCR, to be extended to PSCT */
-extern void fill_pressures(struct gas_pressures *pressures, const double amb_pressure, const struct gasmix *mix, double po2, const enum dive_comp_type type)
+extern void fill_pressures(struct gas_pressures *pressures, const double amb_pressure, const struct gasmix *mix, double po2, const struct divecomputer *dc)
 {
 	if (po2) {
 		/* we have an O₂ partial pressure in the sample - so this
diff --git a/dive.h b/dive.h
index eb89091..8b4ceab 100644
--- a/dive.h
+++ b/dive.h
@@ -119,7 +119,6 @@ struct gas_pressures {
 	double o2, n2, he;
 };
 
-extern void fill_pressures(struct gas_pressures *pressures, const double amb_pressure, const struct gasmix *mix, double po2, const enum dive_comp_type type);
 extern void sanitize_gasmix(struct gasmix *mix);
 extern int gasmix_distance(const struct gasmix *a, const struct gasmix *b);
 extern struct gasmix *get_gasmix_from_event(struct event *ev);
@@ -242,6 +241,10 @@ struct divecomputer {
 	struct divecomputer *next;
 };
 
+
+extern void fill_pressures(struct gas_pressures *pressures, const double amb_pressure, const struct gasmix *mix, double po2, const struct divecomputer *dc);
+
+
 #define MAX_CYLINDERS (8)
 #define MAX_WEIGHTSYSTEMS (6)
 #define W_IDX_PRIMARY 0
diff --git a/profile.c b/profile.c
index 71a9164..8dab283 100644
--- a/profile.c
+++ b/profile.c
@@ -833,7 +833,7 @@ static void calculate_gas_information_new(struct dive *dive, struct plot_info *p
 		fo2 = get_o2(&dive->cylinder[cylinderindex].gasmix);
 		fhe = get_he(&dive->cylinder[cylinderindex].gasmix);
 
-		fill_pressures(&entry->pressures, amb_pressure, &dive->cylinder[cylinderindex].gasmix, entry->pressures.o2, dive->dc.dctype);
+		fill_pressures(&entry->pressures, amb_pressure, &dive->cylinder[cylinderindex].gasmix, entry->pressures.o2, &(dive->dc));
 
 		/* Calculate MOD, EAD, END and EADD based on partial pressures calculated before
 		 * so there is no difference in calculating between OC and CC
@@ -859,6 +859,46 @@ static void calculate_gas_information_new(struct dive *dive, struct plot_info *p
 	}
 }
 
+void fill_o2_values(struct divecomputer *dc, struct plot_info *pi)
+/* For CCR:
+ * In the samples from each dive computer, any duplicate values for the 
+ * oxygen sensors were removed (i.e. set to 0) in order to conserve
+ * storage space (see function fuxup_dive_dc). But for drawing the prodile
+ * a complete series of valid o2 pressure val

[PATCH 1/1] Start sanitizing gaschange event information

2014-10-12 Thread Linus Torvalds

From: Linus Torvalds 
Date: Sun, 17 Aug 2014 12:26:21 -0600
Subject: [PATCH 1/1] Start sanitizing gaschange event information

Decode the gasmix data into a sane format when creating the event, and
add the (currently unused) ability to specify a gas change to a
particular cylinder rather than (or in addition to) the gasmix.

Signed-off-by: Linus Torvalds 
---

This is entirely independent of the uemis downloader patches, so sent as a 
separate series of a single patch. 

I've been carrying this along for a longish while now, and quite frankly, 
on its own it does very little indeed, but it cleans up how we handle gas 
change events internally, and it at least makes it *possible* to indicate 
which cylinder you are using even if you have multiple cylinders with the 
same gas, because now our gaschange has both gas mix information _and_ the 
cylinder index.

A cylinder index of "-1" means that we should take the index based purely 
on the gasmix, the way we traditionally do. But you could now set it to 
some other cylinder explicitly, even if we don't actually have the 
interfaces to do that yet.

So think of this as cleanup and preparation, but no new actual features.

 dive.c  |  68 +---
 dive.h  |  22 ++-
 load-git.c  |  21 ++-
 parse-xml.c | 136 
 profile.c   |  22 ---
 qt-ui/profile/diveeventitem.cpp |   8 +--
 save-git.c  |  27 +---
 save-xml.c  |  27 +---
 8 files changed, 234 insertions(+), 97 deletions(-)

diff --git a/dive.c b/dive.c
index 9972212aa5d4..e7bf685e65da 100644
--- a/dive.c
+++ b/dive.c
@@ -26,7 +26,31 @@ static const char *default_tags[] = {
QT_TRANSLATE_NOOP("gettextFromC", "deco")
 };
 
-void add_event(struct divecomputer *dc, int time, int type, int flags, int 
value, const char *name)
+int event_is_gaschange(struct event *ev)
+{
+   return ev->type == SAMPLE_EVENT_GASCHANGE ||
+   ev->type == SAMPLE_EVENT_GASCHANGE2;
+}
+
+/*
+ * Does the gas mix data match the legacy
+ * libdivecomputer event format? If so,
+ * we can skip saving it, in order to maintain
+ * the old save formats. We'll re-generate the
+ * gas mix when loading.
+ */
+int event_gasmix_redundant(struct event *ev)
+{
+   int value = ev->value;
+   int o2, he;
+
+   o2 = (value & 0x) * 10;
+   he = (value >> 16) * 10;
+   return  o2 == ev->gas.mix.o2.permille &&
+   he == ev->gas.mix.he.permille;
+}
+
+struct event *add_event(struct divecomputer *dc, int time, int type, int 
flags, int value, const char *name)
 {
struct event *ev, **p;
unsigned int size, len = strlen(name);
@@ -34,7 +58,7 @@ void add_event(struct divecomputer *dc, int time, int type, 
int flags, int value
size = sizeof(*ev) + len + 1;
ev = malloc(size);
if (!ev)
-   return;
+   return NULL;
memset(ev, 0, size);
memcpy(ev->name, name, len);
ev->time.seconds = time;
@@ -42,6 +66,22 @@ void add_event(struct divecomputer *dc, int time, int type, 
int flags, int value
ev->flags = flags;
ev->value = value;
 
+   /*
+* Expand the events into a sane format. Currently
+* just gas switches
+*/
+   switch (type) {
+   case SAMPLE_EVENT_GASCHANGE2:
+   /* High 16 bits are He percentage */
+   ev->gas.mix.he.permille = (value >> 16) * 10;
+   /* Fallthrough */
+   case SAMPLE_EVENT_GASCHANGE:
+   /* Low 16 bits are O2 percentage */
+   ev->gas.mix.o2.permille = (value & 0x) * 10;
+   ev->gas.index = -1;
+   break;
+   }
+
p = &dc->events;
 
/* insert in the sorted list of events */
@@ -50,6 +90,7 @@ void add_event(struct divecomputer *dc, int time, int type, 
int flags, int value
ev->next = *p;
*p = ev;
remember_event(name);
+   return ev;
 }
 
 static int same_event(struct event *a, struct event *b)
@@ -107,14 +148,11 @@ void update_event_name(struct dive *d, struct event 
*event, char *name)
 /* this returns a pointer to static variable - so use it right away after 
calling */
 struct gasmix *get_gasmix_from_event(struct event *ev)
 {
-   static struct gasmix g;
-   g.o2.permille = g.he.permille = 0;
-   if (ev && (ev->type == SAMPLE_EVENT_GASCHANGE || ev->type == 
SAMPLE_EVENT_GASCHANGE2)) {
-   g.o2.permille = 10 * ev->value & 0x;
-   if (ev->type == SAMPLE_EVENT_GASCHANGE2)
-   g.he.permille = 10 * (ev->value >> 16);
-   }
-   return &g;
+   static struct gasmix dummy;
+   if (ev && event_is_gaschange(ev))
+   return &ev->gas.mix;
+
+   return &dummy;
 }
 
 int get_pressure_units(int mb, const char **units)
@@ -1543,6 +1581

[PATCH 2/2] Teach uemis downloader about downloading into private trips

2014-10-12 Thread Linus Torvalds

From: Linus Torvalds 
Date: Sun, 12 Oct 2014 07:11:34 -0400
Subject: [PATCH 2/2] Teach uemis downloader about downloading into private trips

Now that we pass in the full device_data_t information, we can look at
the "create_private_dive" flag and decide just how to record newly
downloaded dives properly.

Signed-off-by: Linus Torvalds 
---
 uemis-downloader.c | 21 -
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/uemis-downloader.c b/uemis-downloader.c
index 4e0545193158..256f139047b6 100644
--- a/uemis-downloader.c
+++ b/uemis-downloader.c
@@ -120,6 +120,17 @@ static struct dive *uemis_start_dive(uint32_t deviceid)
return dive;
 }
 
+static void record_uemis_dive(device_data_t *devdata, struct dive *dive)
+{
+   if (devdata->create_new_trip) {
+   if (!devdata->trip)
+   devdata->trip = create_and_hookup_trip_from_dive(dive);
+   else
+   add_dive_to_trip(dive, devdata->trip);
+   }
+   record_dive(dive);
+}
+
 /* send text to the importer progress bar */
 static void uemis_info(const char *fmt, ...)
 {
@@ -681,7 +692,7 @@ static void parse_tag(struct dive *dive, char *tag, char 
*val)
  * index into yet another data store that we read out later. In order to
  * correctly populate the location and gps data from that we need to remember
  * the adresses of those fields for every dive that references the divespot. */
-static bool process_raw_buffer(uint32_t deviceid, char *inbuf, char 
**max_divenr, bool keep_number, int *for_dive)
+static bool process_raw_buffer(device_data_t *devdata, uint32_t deviceid, char 
*inbuf, char **max_divenr, bool keep_number, int *for_dive)
 {
char *buf = strdup(inbuf);
char *tp, *bp, *tag, *type, *val;
@@ -784,14 +795,14 @@ static bool process_raw_buffer(uint32_t deviceid, char 
*inbuf, char **max_divenr
 * be a short read because of some error */
if (done && ++bp < endptr && *bp != '{' && strstr(bp, "{{")) {
done = false;
-   record_dive(dive);
+   record_uemis_dive(devdata, dive);
mark_divelist_changed(true);
dive = uemis_start_dive(deviceid);
}
}
if (log) {
if (dive->dc.diveid) {
-   record_dive(dive);
+   record_uemis_dive(devdata, dive);
mark_divelist_changed(true);
} else { /* partial dive */
free(dive);
@@ -875,7 +886,7 @@ const char *do_uemis_import(device_data_t *data)
success = uemis_get_answer(mountpath, "getDivelogs", 3, 0, 
&result);
/* process the buffer we have assembled */
if (mbuf)
-   if (!process_raw_buffer(deviceidnr, mbuf, &newmax, 
keep_number, NULL)) {
+   if (!process_raw_buffer(data, deviceidnr, mbuf, 
&newmax, keep_number, NULL)) {
/* if no dives were downloaded, mark end 
appropriately */
if (end == -2)
end = start - 1;
@@ -930,7 +941,7 @@ const char *do_uemis_import(device_data_t *data)
success = uemis_get_answer(mountpath, "getDive", 3, 0, &result);
if (mbuf) {
int divenr;
-   (void)process_raw_buffer(deviceidnr, mbuf, &newmax, 
false, &divenr);
+   (void)process_raw_buffer(data, deviceidnr, mbuf, 
&newmax, false, &divenr);
 #if UEMIS_DEBUG & 2
fprintf(debugfile, "got dive %d, looking for dive 
%d\n", divenr, i);
 #endif
-- 
2.1.2.336.g325602c

___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface


[PATCH 1/2] Pass the whole 'device_data_t' to the uemis downloader

2014-10-12 Thread Linus Torvalds

From: Linus Torvalds 
Date: Sun, 12 Oct 2014 06:57:32 -0400
Subject: [PATCH 1/2] Pass the whole 'device_data_t' to the uemis downloader

Not only does it make it look more like the libdivecomputer downloaders,
but the uemis downloader needs it in order to support all the flags we
have.  Notably "download into private trip".

Signed-off-by: Linus Torvalds 
---
 libdivecomputer.h  | 2 +-
 qt-ui/downloadfromdivecomputer.cpp | 2 +-
 uemis-downloader.c | 4 +++-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/libdivecomputer.h b/libdivecomputer.h
index f277e298fe1a..af51854a0d1f 100644
--- a/libdivecomputer.h
+++ b/libdivecomputer.h
@@ -33,7 +33,7 @@ typedef struct device_data_t
 } device_data_t;
 
 const char *do_libdivecomputer_import(device_data_t *data);
-const char *do_uemis_import(const char *mountpath, short force_download);
+const char *do_uemis_import(device_data_t *data);
 
 extern int import_thread_cancelled;
 extern const char *progress_bar_text;
diff --git a/qt-ui/downloadfromdivecomputer.cpp 
b/qt-ui/downloadfromdivecomputer.cpp
index fe5d4ee9a26b..112d1058652a 100644
--- a/qt-ui/downloadfromdivecomputer.cpp
+++ b/qt-ui/downloadfromdivecomputer.cpp
@@ -477,7 +477,7 @@ void DownloadThread::run()
const char *errorText;
import_thread_cancelled = false;
if (!strcmp(data->vendor, "Uemis"))
-   errorText = do_uemis_import(data->devname, 
data->force_download);
+   errorText = do_uemis_import(data);
else
errorText = do_libdivecomputer_import(data);
if (errorText)
diff --git a/uemis-downloader.c b/uemis-downloader.c
index 608d3c6eaaba..4e0545193158 100644
--- a/uemis-downloader.c
+++ b/uemis-downloader.c
@@ -824,8 +824,10 @@ static char *uemis_get_divenr(char *deviceidstr)
return strdup(divenr);
 }
 
-const char *do_uemis_import(const char *mountpath, short force_download)
+const char *do_uemis_import(device_data_t *data)
 {
+   const char *mountpath = data->devname;
+   short force_download = data->force_download;
char *newmax = NULL;
int start, end = -2, i, offset;
uint32_t deviceidnr;
-- 
2.1.2.336.g325602c

___
subsurface mailing list
subsurface@subsurface-divelog.org
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface