aboutsummaryrefslogtreecommitdiffstats
path: root/core
AgeCommit message (Collapse)Author
2017-08-29Store a table of deco stops in plannerGravatar Robert C. Helling
... in addition to struct diveplan which combines all kinds of information Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29Cache all Buehlmann factorsGravatar Robert C. Helling
not just the last one. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29Allow for o2 breaks in binary search stop time finderGravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29Find deco stop time by binary search instead of iterationGravatar Robert C. Helling
This allows to go to much smaller granularity without severe performance penalty. It should also increase performance for long decompression times. Currently this leads to missing cached tissue factors, the caching has to be adopted to this. Also, for the time being this breaks the bottom gas breaks feature. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29Make plan take dive and decotimestep as argumentsGravatar Robert C. Helling
...rather than use a global variable and a macro. This should be a no-op in preparation to allow planning several versions of a dive. Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-29Change color to red if minimum gas is violated.Gravatar Robert C. Helling
Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-26Another signed/unsigned warningGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-08-26Adjust signature to match data we needGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-08-26Remove unused functionGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-08-26Assignment instead of test for equalityGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-08-26Time is unsigned hereGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-08-26Remove some unused variablesGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-08-26Hide signed/unsigned comparison warningGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-08-24Shearwater PerdixGravatar Miika Turkia
Reportedly the case 2 corresponds to Perdix, so it might be that both Petrel and Perdix use same model number (or the model is mistaken before). Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-08-24Support for air pressure on Shearwater Desktop importGravatar Miika Turkia
Fixes #548 Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-08-24Grab correct dive number on Shearwater Desktop importGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-08-21Improve error message when opening dive computer failsGravatar Dirk Hohndel
Instead of the (usually incorrect) text about insufficient privileges, just mention a generic error and suggest that the user creates a libdivecomputer log file. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-08-20Update the OSTC dive computer configuration to use the generic 'timesync' ↵Gravatar Linus Torvalds
interface Jef made the OSTC interface be a generic 'dc_device_timesync()' and so the old OSTC-specific code doesn't exist any more. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-08-10fix weights roundingGravatar Jan Mulder
Simplify and fix prestation of weights. Due to the attempt to round only the grams part (by just adding 50 to it, and truncating afterwards) a weird effect was introduced. For example, a value 0.98 was presented as 0.10. Just replay the old logic, and see what happens. Rewrote the logic to a simpler and better one. fixes: #532 Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-08-10DLF: Parse more measurements, import GPSGravatar Anton Lundin
This add support for parsing more measurements, and now imports GPS data to. Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-08-10DLF: Parse Divesoft Liberty data betterGravatar Anton Lundin
There is something with ndl / tts / temp in the Liberty DLF files. If that bit is set, the values are bogus. There is something more to it here which I haven't figured out. Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-08-10DLF: Parse diluent changes as a gaschange eventGravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-08-10DLF: Import setpoint changes.Gravatar Anton Lundin
Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-08-10DLF: Restructure loop into a for loopGravatar Anton Lundin
We always step forward 16 bytes, so make it a for loop so a continue won't throw us into a eternal loop. Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-08-04configure ostc3: Correct code for right buttonGravatar Anton Lundin
Back when I wrote this code I made a typo. This fixes it. Reported-By: Alexander Gottwald <jugendtrainingtsck@gmail.com> Signed-off-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-08-03Fix Poseidon MkVI txt file import sensor pressuresGravatar Linus Torvalds
When I unified the sample pressures in commit 11a0c0cc7018 ("Unify sample pressure and o2pressure as pressure[2] array") I did all the obvious conversions, including the conversion of the Poseidon txt file import: case POSEIDON_PRESSURE: - sample->cylinderpressure.mbar = lrint(val * 1000); + sample->pressure[0].mbar = lrint(val * 1000); break; case POSEIDON_O2CYLINDER: - sample->o2cylinderpressure.mbar = lrint(val * 1000); + sample->pressure[1].mbar = lrint(val * 1000); break; which was ObviouslyCorrect(tm). But as so often is the case, obvious doesn't actually exist. The old "o2cylinderpressure[]" model had an implicit sensor associated with it, and that implicit sensor mapping wasn't obvious, and didn't get fixed. It turns out that the way the Poseidon sensor mapping works, the O2 cylinder is cylinder 0, and the diluent cylinder is cylinder 1, so just use the add_sample_pressure() helper to set both sensor index and pressure value. And since we now do all the sensor indexing right, we can also get rid of some manual cylinder sample pressure code, because the generic dive fixup will just DTRT. It used to screw up because the diluent sensor number was wrong before, and the import code tried to work around that by hand. Reported-by: Anton Lundin <glance@acc.umu.se> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-08-03Always show the ascent to the initial deco stopGravatar Robert C. Helling
...even when not showing transitions, this makes the first stop look more like a stop (since it does not include several minutes of ascent). Signed-off-by: Robert C. Helling <helling@atdotde.de>
2017-08-01android: access() is declared in unistd.hGravatar Anton Lundin
Calling access() makes no sense at all on android, but this atleast fixes a compilation error on ndk 15+. Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-08-01Null check before writing to pointerGravatar Anton Lundin
In the serial api for libdivecomputer is ok to send NULL as the int pointer actual, if you dont't care about how many bytes that where actually read or written. This makes sure we don't crash if the ble backend where ever used with such a backend. Signed-off-by: Anton Lundin <glance@acc.umu.se>
2017-07-30For more manual gas pressure detailsGravatar Linus Torvalds
So the manual gas pressure case keeps showing issues, and in many ways it really is a fairly complex thing, since it needs interpolation of the intermediate pressures - possibly over several gas changes. So you might have beginning and ending pressures for one cylinder, but then use another cylinder in between. We've historically got all the code to do this, but the big rewrite for multiple cylinder pressures didn't get all the details right, and so here's a few more fixes for the case that was shown by a dive by Robert Helling. Hopefully we're approaching the old code situation, except now with concurrent gas pressure handling support. Reported-by: Robert Helling <helling@atdotde.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-30Fix another cylinder pressure plotting special caseGravatar Linus Torvalds
The core to plot manually entered pressures without any sample data did the obvious thing: it ended the pressures at the end of the dive as indicated by the last sample. However, that obvious thing didn't actually work, because sometimes the last sample is long long after the dive has actually ended, and we have no plot_info data for that. This depends on the dive computer used: most dive computers will not report samples after the end (even if they may internally remember them in case the diver just came up to the surface temporarily), but some definitely do. The OSTC3 is a prime example of that. Anyway, the code was fragile and wrong - even if passed a time past the end of the plot_info data, "add_plot_pressure()" should just have associated that with the last entry instead. Which also allows us to simplify the whole endtime logic entirely, and just use INT_MAX for it. Gaetan Bisson's test-case also showed another oddity: we would plot the gas pressure even for cylinders that had no has use (ie beginning and ending pressures were the same). That's kind of pointless in so many ways. So limit the manual pressure population to cylinders that actually have seen use. Reported-by: Gaetan Bisson <bisson@archlinux.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-30worldmap-save: don't use an API keyGravatar Lubomir I. Ivanov
The Google Maps API V3 *does* require a key if one needs to generate a lot of payed trafic and monitor said trafic, otherwise it doesn't: https://stackoverflow.com/a/8785844 Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-29Correctly create cloud account from mobileGravatar Jan Mulder
The creation of a cloud account from mobile was broken. This fixes it. Basically, we need to go online for a moment, and setup a correct local and remote repo for the cloud storage. Tested for the following scenarios: 1) inital account creation including PIN handling from mobile, from a clean install . 2) open an already validated cloud account from a clean install. 3) open no-cloud style local account. 4) Switch between 2 already validated could accounts. 5) Try to create a cloud account without data connection. Notice that scenario 4) does not work perfectly. A restart of the app is needed to see the new logbook. So that is to be fixed. Scenario 5) seems a non realistic corner case. This does not work in a gracefull way. The user needs to remove the app, install it again, and retry with data connection. Further notice this is backgroud/core processing only. So no QML UI changes as proposed (for example) bij Davide. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-29strstr is a case sensitive compareGravatar Jan Mulder
strstr is a case sensitive compare and the string reported from libgit2 reads "reference" and not "Reference". Further investigation reveals commit 909d5494368a0080 of libgit2. Here, the change is made from Reference to reference, breaking our rather poor way of detecting something from an error string. So, to be future-proof to more libgit2 oddities, it might be wise to use strcasestr in this situation. But this seems a not fully supported variant of strstr, so leave it at this point. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-29Fix small memory leakGravatar Jan Mulder
Add 2 forgotten free() statements for the temporary used string buffers. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-28Import all pressure sensors from Liquivision logsGravatar Linus Torvalds
The other pressure sensors were disabled on import because we didn't use to handle multiple sensors well at all. Now it "JustWorks(tm)". Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-28Fix manual pressures for cylinders with no gas switchesGravatar Linus Torvalds
"If it hasn't been tested, it doesn't work". All my testing of the multiple sensor pressures have been with some reasonably "interesting" dives: they actually *have* sensor pressures. But that test coverage means that I missed the truly trivial case of just having manual pressures for a single cylinder. Because there's only a single cylinder, it doesn't have any cylinder changes, and because there were no cylinder changes, it never filled in the use range for that cylinder. So then it never showed the pressure profile at all. Duh. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-28Calculate momentary SAC rates with the right gasesGravatar Linus Torvalds
The momentary SAC rate got broken by the multiple ressure handling too, and always used just the first cylinder. This uses the new "get_gasmix()" helper to see what you're breathing, and will do the SAC rate over all the cylinders that contain that gas. So it should now DTRT even for sidemount diving (assuming you had the same gas in the sidemount cylinders). NOTE! We could just do the SAC rate over *all* the gases you have pressures for, and maybe that's the right thing to do. The ones you are not breating from shouldn't have their pressure change. But maybe some people add their drysuit argon gas to the gas list? So this may need more work, but it's a step in the right direction. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-28Use the right gasmix for deco calculationsGravatar Linus Torvalds
In commit e1b880f4 "Profile support for multiple concurrent pressure sensors" I had mindlessly hacked away at some of the sensor lookups from the plot entries to make it all build, and forgotten about my butchery. Thankfully Jan and Davide noticed in their multi-cylinder deco dives that the deco calculations were no longer correct. This uses the newly introduced "get_gasmix()" helper to look up the currently breathing gasmix, and fixes the deco calculations. Reported-and-tested-by: Jan Mulder <jlmulder@xs4all.nl> Reported-by: Davide DB <dbdavide@gmail.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-28Add "get_gasmix()" helper function to iterate over gas changesGravatar Linus Torvalds
We have a few places that used to get the gasmix by looking at the sensor index in the plot data, which really doesn't work any more. To make it easier for those users to convert to the new world order, this adds a "get_gasmix()" function. The gasmix function takes as its argument the dive, the dive computer, and the time. In addition, for good performance (to avoid looping over the event list over and over and over again) it maintains a pointer to the next gas switch event, and the previous gas. Those need to be initialized to NULL by the caller, so the standard use-case pattern basically looks like this: struct gasmix *gasmix = NULL; struct event *ev = NULL; loop over samples or plot events in increasing time order: { ... gasmix = get_gasmix(dive, dc, time, &ev, gasmix); ... } and then you can see what the currently breathing gas is at that time. If for some reason you need to walk backwards in time, you can just pass in a NULL gasmix again, which will reset the event iterator (at the cost of now having to walk all the events again). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-27Profile support for multiple concurrent pressure sensorsGravatar Linus Torvalds
This finally handles multiple cylinder pressures, both overlapping and consecutive, and it seems to work on the nasty cases I've thrown at it. Want to just track five different cylinders all at once, without any pesky gas switch events? Sure, you can do that. It will show five different gas pressures for your five cylinders, and they will go down as you breathe down the cylinders. I obviously don't have any real data for that case, but I do have a test file with five actual cylinders that all have samples over the whole course of the dive. The end result looks messy as hell, but what did you expect? HOWEVER. The only way to do this sanely was - actually make the "struct plot_info" have all the cylinder pressures (so no "sensor index and pressure" - every cylinder has a pressure for every plot info entry) This obviously makes the plot_info much bigger. We used to have MAX_CYLINDERS be a fairly generous 8, which seems sane. The planning code made that 8 be 20. That seems questionable. But whatever. The good news is that the plot-info should hopefully get freed, and only be allocated one dive at a time, so the fact that it is big and nasty shouldn't be a scaling issue, though. - the "populate_pressure_information()" function had to be rewritten quite a bit. The good news is that it's actually simpler now, although I would not go so far as to really call it simple. It's still complicated and suble, but now it explicitly just does one cylinder at a time. It *used* to have this insanely complicated "keep track of the pressure ranges for every cylinder at once". I just couldn't stand that model and keep my sanity, so it now just tracks one cylinder at a time, and doesn't have an array of live data, instead the caller will just call it for each cylinder. - get rid of some of our hackier stuff, like the code that populates the plot_info data code with the currently selected cylinder number, and clears out any other pressures. That obviously does *not* work when you may not have a single primary cylinder any more. Now, the above sounds like all good things. Yeah, it mostly is. BUT. There's a few big downsides from the above: - there's no sane way to do this as a series of small changes. The change to make the plot_info take an array of cylinder pressures rather than the sensor+pressure model really isn't amenable to "fix up one use at a time". When you switch over to the new data structure model, you have to switch over to the new way of populating the pressure ranges. The two just go hand in hand. - Some of our code *depended* on the "sensor+pressure" model. I fixed all the ones I could sanely fix. There was one particular case that I just couldn't sanely fix, and I didn't care enough about it to do something insane. So the only _known_ breakage is the "TankItem" profile widget. That's the bar at the bottom of the profile that shows which cylinder is in use right now. You'd think that would be trivial to fix up, and yes it would be - I could just use the regular model of firstcyl = explicit_first_cylinder(dive, dc) .. then iterate over the gas change events to see the others .. but the problem with the "TankItem" widget is that it does its own model, and it has thrown away the dive and the dive computer information. It just doesn't even know. It only knows what cylinders there are, and the plot_info. And it just used to look at the sensor number in the plot_info, and be done with that. That number no longer exists. - I have tested it, and I think the code is better, but hey, it's a fairly large patch to some of the more complex code in our code base. That "interpolate missing pressure fields" code really isn't pretty. It may be prettier, but.. Anyway, without further ado, here's the patch. No sign-off yet, because I do think people should look and comment. But I think the patch is fine, and I'll fix anythign that anybody can find, *except* for that TankItem thing that I will refuse to touch. That class is ugly. It needs to have access to the actual dive. Note how it actually does remove more lines than it adds, and that's despite added comments etc. The code really is simpler, but there may be cases in there that need more work. Known missing pieces that don't currently take advantage of concurrent cylinder pressure data: - the momentary SAC rate coloring for dives will need more work - dive merging (but we expect to generally normally not merge dive computers, which is the main source of sensor data) - actually taking advantage of different sensor data from different dive computers But most of all: Testing. Lots and lots of testing to find all the corner cases. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-25Add support for loading and saving multiple pressure samplesGravatar Linus Torvalds
This does both the XML and the git save format, because the changes really are the same, even if the actual format differs in some details. See how the two "save_samples()" routines both do the same basic setup, for example. This is fairly straightforward, with the possible exception of the odd sensor = sample->sensor[0]; default in the git pressure loading code. That line just means that if we do *not* have an explicit cylinder index for the pressure reading, we will always end up filling in the new pressure as the first pressure (because the cylinder index will match the first sensor slot). So that makes the "add_sample_pressure()" case always do the same thing it used to do for the legacy case: fill in the first slot. The actual sensor index may later change, since the legacy format has a "sensor=X" key value pair that sets the sensor, but it will also use the first sensor slot, making it all do exactly what it used to do. And on the other hand, if we're loading new-style data with cylinder pressure and sensor index together, we just end up using the new semantics for add_sample_pressure(), which tries to keep the same slot for the same sensor, but does the right thing if we already have other pressure values. The XML code has no such issues at all, since it can't share the cases anyway, and we need to have different node names for the different sensor values and cannot just have multiple "pressure" entries. Have I mentioned how much I despise XML lately? Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-25Make sample pressure helper functions available to everybodyGravatar Linus Torvalds
We had a "add_sample_pressure()" helper functions that was local to just the libdivecomputer downloading code, but it really is applicable to pretty much any code that adds cylinder pressure data to a sample. Also add another helper: "legacy_format_o2pressures()" which checks the sample data to see if we can use the legacy format, and returns the o2 pressure sensor to use for that legacy format. Because both the XML and the git save format will need a way to save the compatible old-style information, when possible, but save an extended format for when we have data from multiple concurrent sensors. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-25Mobile: honour location service time thresholdGravatar Jan Mulder
Independ of the settings, the threshold to reset the GPS data was hard coded to 5 minutes. Now, honour the entered (and updated during a session) time to refresh the GPS data in the location service. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
2017-07-25Try to sanely download multiple concurrent cylinder pressuresGravatar Linus Torvalds
This tries to sanely handle the case of a dive computer reporting multiple cylinder pressures concurrently. NOTE! There are various "interesting" situations that this whole issue brings up: - some dive computers may report more cylinder pressures than we have slots for. Currently we will drop such pressures on the floor if they come for the same sample, but if they end up being spread across multiple samples we will end up re-using the slots with different sensor indexes. That kind of slot re-use may or may not end up confusing other subsurface logic - for example, make things believe there was a cylidner change event. - some dive computers might send only one sample at a time, but switch *which* sample they send on a gas switch event. If they also report the correct sensor number, we'll now start reporting that pressure in the second slot. This should all be fine, and is the RightThing(tm) to do, but is different from what we used to do when we only ever used a single slot. - When people actually use multiple sensors, our old save format will start to need fixing. Right now our save format comes from the CCR model where the second sensor was always the Oxygen sensor. We save that pressure fine (except we save it as "o2pressure" - just an odd historical naming artifact), but we do *not* save the actual sensor index, because in our traditional format that was always implicit in the data ("it's the oxygen cylinder"). so while this code hopefully makes our libdivecomputer download do the right thing, there *will* be further fallout from having multiple cylinder pressure sensors. We're not done yet. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2017-07-24CCR is now detected from the log dataGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-07-24Map Divinglog's visibility to our starsGravatar Miika Turkia
good (1) = 5 medium (2) = 3 bad (3) = 1 There seems also to be 0 used in the log, even though it is not mentioned in the valid selections. This is not giving any stars for this option... Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-07-24Detect CCR/PSCR from Divinglog importGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-07-24Fix CCR detection on Divinglog importGravatar Miika Turkia
Note that I have not been able to do a positive test for this due to lack of CCR sample data. But at least OC dives are now categorized correctly. Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
2017-07-24Add visibility support to Divinglog importGravatar Miika Turkia
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>