Correctly copy all information in an event

Instead of trying to use add_event() to reinsert events we simply copy the
memory and adjust the pointers.

Using add_event() lost the gas mix and gas index information on gaschange
events - and this prevent switches between cylinders with the same gasmix
to be rendered correctly.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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 <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
CCR patch: Calculate the correct partial gas pressures for CCR dives

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.

[Dirk Hohndel: yet again massive whitespace cleanup]

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
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 <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Ignore pictures when parsing divelogs.de import

Do not do XML parse on pictures. Currently just ignore them, in the
future we might want to save them somewhere and include them in
Subsurface logs.

Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
CCR patch: Reorganise the oxygen partial pressure calculations

This patch responds to the side effects that the CCR code has had with
respect to ceilings in OC dives and dive plans. Dive ceilings are now
calculated correctly again.

The following were performed:
1) remove the oxygen sensor and setpoint fields from the gas_pressures
   structure.
2) Re-insert setpoint and oxygen sensor fields in the plot_data structure.
3) Remove the algorithm that reads the o2 sensor data and calculates the
   pressures.po2 value from function fill_pressures() in dive.c and save
   it as a separate function calc_ccr_po2() in profile.c.
4) Activate calc_ccr_po2 from function fill_pressures() in profile.c.
5) Move the relative position of the call to fill_pressures() within the
   function create_polt_info_new() in profile.c.

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Check that the model is a supported one

This code adds some crude checks to verify that the device is a
supported one before we actually read/write from it. This is to
white/black-list devices so we don't write or read memory that we don't
know anything about.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Fix compilation on other Unix besides Linux

The linux.c file is really for just generic Unix systems, so adapt the
.pro file logic to match.

Signed-off-by: Thiago Macieira <thiago@macieira.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Setup defaults for some of the OSTC3 settings

This is still missing lots of values which are now set to 0 with rather
unfortunate consequences (for example, setting Saturation and Desaturation
to 0 turns off the NDL / Deco calculations). So this code right now is
quite broken.

But at least this fixes the reported crash and gets some valid data
initialized.

Fixes #744

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Export to DiveShare

Adds the possibility of exporting dives to DiveShare.

Signed-off-by: Salvo 'LtWorf' Tomaselli <tiposchi@tiscali.it>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Reshuffle CCR voting logic and minor clean ups

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
CCR patch: Correction of inconsistency in profile.c

fill_o2_values() in profile.c: Robert identified the inconsistency of po2
assignmemts when using OC dives as opposed to CCR dives.
This is corrected here. OC dives still need to be processed in this function
because the po2 values have not been initialised anywhere else before
thos code executes.

Signed-off-by: willem ferguson <willemferguson@zoology.up.ac.za>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Read and write desaturation from OSTC3's

This adds missing code to read and write the desaturation factor to and
from OSTC3's.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
255% as limit for Saturation/Desaturation on OSTC3

The default max value for a QSpinBox is 99. The default Saturation
factor for the OSTC3 is 110%. This code raises the max values to 255
which is as far as i've read the ostc3_interface.odt the max value.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Remove double include

Signed-off-by: Giuseppe Bilotta <giuseppe.bilotta@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Set limits for Saturation/Desaturation on OSTC3

The default max value for a QSpinBox is 99. The default Saturation
factor for the OSTC3 is 110%. This code sets the max, min and default
values on those spinboxes.
The values comes from me reading the assembler code for the OSTC3.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Don't allow writing before we got data

Don't allow creation of backup files or writes to the computer before we
know we got some data, either from a backup file or from the actual
device.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Enable/Disable Update Firmware button based on dc

Disable the Update Firmware button if you choose a device that we don't
support update firmware for.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Make ConfigureDiveComputerDialog ui a class member

Almost all of our other classes have the ui class as a class member in
the controller code. This switches ConfigureDiveComputerDialog to that
model.

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Save columnwith of Ostc3 settings tables

Signed-off-by: Anton Lundin <glance@acc.umu.se>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>