summaryrefslogtreecommitdiffstats
path: root/uemis.c
AgeCommit message (Collapse)Author
2013-02-08Do more dive fixup for each dive computerGravatar Linus Torvalds
In commit b6c9301e5847 ("Move more dive computer filled data to the divecomputer structure") we moved the fields that get filled in by the dive computers to be per-divecomputer data structures. This patch re-creates some of those fields back in the "struct dive", but now the fields are initialized to be a reasonable average from the dive computer data. We already did some of this for the temperature min/max fields for the statistics, so this just continues that trend. The goal is to make it easy to look at "dive values" without having to iterate over dive computers every time you do. Just do it once in "fixup_dive()" instead. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-30Massive cleanupGravatar Dirk Hohndel
Mostly coding style and whitespace changes plus making lots of functions static that have no need to be extern. This also helped find a bit of code that is actually no longer used. This should have absolutely no functional impact - all changes should be purely cosmetic. But it removes a bunch of lines of code and makes the rest easier to read. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-24Centralization for Kelvin and Standardization to milliKelvinGravatar Jan Schubert
This centralizes all occurrences of Kelvin to dive.h and standardizes all usages to milliKelvin. [Dirk Hohndel: renamed the constant plus minor white space cleanup] Signed-off-by: Jan Schubert <Jan.Schubert@GMX.li> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23Move more dive computer filled data to the divecomputer structureGravatar Linus Torvalds
This moves the fields 'duration', 'surfacetime', 'maxdepth', 'meandepth', 'airtemp', 'watertemp', 'salinity' and 'surface_pressure' to the per-divecomputer data structure. They are filled in by the dive computer, and normally not edited. NOTE! All actual *use* of this data was then changed from dive->field to dive->dc.field programmatically with a shell-script and sed, and the result then edited for details. So while the XML save and restore code has been updated, all the displaying etc will currently always just show the first dive computer entry. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2013-01-23Ensure each dive has its own copy of the location text (UEMIS importer)Gravatar Dirk Hohndel
Since multiple dives can reference the same divesite we need to do the strdup when the value gets assigned, not when it gets passed into the helper function. This also validates the location string as on my divecomputer there is an invalid divespot 0 that has a corrupted UTF8 string as location name. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-30First step in cleaning up cylinder pressure sensor logicGravatar Linus Torvalds
This clarifies/changes the meaning of our "cylinderindex" entry in our samples. It has been rather confused, because different dive computers have done things differently, and the naming really hasn't helped. There are two totally different - and independent - cylinder "indexes": - the pressure sensor index, which indicates which cylinder the sensor data is from. - the "active cylinder" index, which indicates which cylinder we actually breathe from. These two values really are totally independent, and have nothing what-so-ever to do with each other. The sensor index may well be fixed: many dive computers only support a single pressure sensor (whether wireless or wired), and the sensor index is thus always zero. Other dive computers may support multiple pressure sensors, and the gas switch event may - or may not - indicate that the sensor changed too. A dive computer might give the sensor data for *all* cylinders it can read, regardless of which one is the one we're actively breathing. In fact, some dive computers might give sensor data for not just *your* cylinder, but your buddies. This patch renames "cylinderindex" in the samples as "sensor", making it quite clear that it's about which sensor index the pressure data in the sample is about. The way we figure out which is the currently active gas is with an explicit has change event. If a computer (like the Uemis Zurich) joins the two concepts together, then a sensor change should also create a gas switch event. This patch also changes the Uemis importer to do that. Finally, it should be noted that the plot info works totally separately from the sample data, and is about what we actually *display*, not about the sample pressures etc. In the plot info, the "cylinderindex" does in fact mean the currently active cylinder, and while it is initially set to match the sensor information from the samples, we then walk the gas change events and fix it up - and if the active cylinder differs from the sensor cylinder, we clear the sensor data. [Dirk Hohndel: this conflicted with some of my recent changes - I think I merged things correctly...] Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-30Update deco handlingGravatar Dirk Hohndel
This commit makes deco handling in Subsurface more compatible with the way libdivecomputer creates the data. Previously we assumed that having a stopdepth or stoptime and no ndl meant that we were in deco. But libdivecomputer supports many dive computers that provide the deco state of the diver but with no information about the next stop or the time needed there. In order to be able to model this in Subsurface this adds an in_deco flag to the samples. This is only stored to the XML file when it changes so it doesn't add much overhead but will allow us to display some deco information on dive computers like the Atomic Aquatics Cobalt or many of the Suuntos (among others). The commit also removes the old event based deco code that was commented out already. And fixes the code so that the deco / ndl information is stored for the very last sample as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-07Add CNS and pO2 tracking in the samplesGravatar Dirk Hohndel
This adds the new members to the sample structure and fills them from supported dive computers (Uemis SDA and OSTC / Shearwater Predator, assuming you have libdivecomputer 0.3). Save relvant values of this to the XML file and load it back. Handle the new fields when merging dives. At this stage we don't DO anything with this, all we do is extract them from the dive computer, save them to the XML file and load them back. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-07Initialize helper structure to 0sGravatar Dirk Hohndel
We check the pointers that are part of this structure for NULL before accessing them - but that means we need to zero out the structure for this to work. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-05Turn latitude and longitude into integer micro-degree valuesGravatar Linus Torvalds
This actually makes us internally use 'micro-degrees' for latitude and longitude, and we never turn them into floating point either at parse time or save time. That said, the Uemis downloader internally does still use atof() when converting things, which is likely a bug (locale issues and all that), but I'll ask Dirk to check it out. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-12-04Support the new NDL / deco code in the Uemis downloaderGravatar Dirk Hohndel
This also replaces the old heuristic for when we are in deco with the (hopefully correct) bits in the sample flags. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-30Make more uemis functions staticGravatar Dirk Hohndel
These are no longer called from other parts of the code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-30Convert Uemis downloader to directly create divesGravatar Dirk Hohndel
The initial downloader reused the XML parsing of SDA files that was implemented early in order to support the information extracted from the SDA with the java applet. But creating this intermediary XML file and handing it off to the XML import function always seemed like an ugly way to do things. This became even more obvious when adding more features to the Uemis downloader. This commit completely changes the downloader to instead create dives and record them directly. This also adds support for divespots (which are stored in a seperate database that needs to be queried after the divelog and dive entries have been combined - the Uemis firmware clearly was written by monkeys on crack - oh wait: I'm trusting these same people to get the deco right?). This commit leaves the SDA import capability in the XML parser intact. I'll remove that later. Because of this it actually adds a few lines of code, but the overall change will be a substantial code deletion. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-28Track Uemis last dive downloaded on a per data-file basisGravatar Dirk Hohndel
Actually, it's even better than that. Thanks to the new divecomputer datastructure we can now simply look up in the dive_table which dives have been downloaded from this specific Uemis SDA. This patch removes the old gconf based code - which leads to one unfortunate problem: the first time a Uemis SDA owner runs this version of Subsurface against their data file ALL dives will be downloaded again (which may not be a bad thing as we have improved a few other details of Uemis support so now they get their deco information, surface pressure and other data that we have started to support since 2.1). Still, this is not ideal. But I didn't want to keep the legacy code around since this new solution is so much cleaner. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-28Updating events for libdivecomputer 0.3 (and tracking uemis support)Gravatar Dirk Hohndel
I was a little too eager to add the deco feature to Subsurface. Jef and I went back and forth a few more times and the definition of those events changed. I guess I shouldn't have commited that code until the corresponding libdivecomputer code had been pushed. This commit now brings us in sync with the current master of libdivecomputer (but should compile with 0.2 as well - only deco events won't work then). One issue that I see is that deco / ndl aren't really a good fit for the event model. I actually disabled the drawing of the little yellow triangles for ndl events as for example on the Uemis those events are created whenever the remaining non stop time changes - and that can be every few seconds. The correct solution may be to treat this as a function of the samples, but for now this works and is tested with both OSTC and Uemis SDA. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-25Improve on divecomputer data handlingGravatar Linus Torvalds
This simplifies the vendor/product fields into just a single "model" string for the dive computer, since we can't really validly ever use it any other way anyway. Also, add 'deviceid' and 'diveid' fields: they are just 32-bit hex values that are unique for that particular dive computer model. For libdivecomputer, they are basically the first word of the SHA1 of the data that libdivecomputer gives us. (Trying to expose it in some other way is insane - different dive computers use different models for the ID, so don't try to do some kind of serial number or something like that) For the Uemis Zurich, which doesn't use the libdivecomputer import, we currently only set the model name. The computer does have some kind of device ID string, and we could/should just do the same "SHA1 over the ID" to give it a unique ID, but the pseudo-xml parsing confuses me, so I'll let Dirk fix that up. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-23Move events and samples into a 'struct divecomputer'Gravatar Linus Torvalds
For now we only have one fixed divecomputer associated with each dive, so this doesn't really change any current semantics. But it will make it easier for us to associate a dive with multiple dive computers. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-23Allocate dive samples separately from 'struct dive'Gravatar Linus Torvalds
We used to avoid some extra allocations by just allocating the dive samples as part of the 'struct dive' allocation itself, but that ends up complicating things, and will make it impossible to have multiple different sets of samples (for multiple dive computers). So stop doing it. Just allocate the dive samples array separately. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-12Extract salinity for Uemis SDA and improve depth calculationGravatar Dirk Hohndel
THe Uemis SDA allows the user to set it up for salt water and fresh water use. We should take this into consideration for the water pressure to depth conversion. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10Convert Uemis deco stop hold time to secondsGravatar Dirk Hohndel
This is actually stored in minutes (which seems odd, given they allocate 16 bits for it... how much deco do these people want to be prepared for??) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10Use correct surface pressure to detect ceiling with Uemis ZurichGravatar Dirk Hohndel
The dive data contains the surface pressure prior to the dive, and that is what we need to compare p_amb_tol to, not the standard 1013mbar. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-11-10Create the correct ceiling events for Uemis ZurichGravatar Dirk Hohndel
The hold_depth field is rather misleading as it normally gives the safety stop depth and only when the p_amb_tol goes "below the surface" does it switch to showing the first deco stop depth. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-28Display air temperature in the info notebook pageGravatar Dirk Hohndel
So far we don't parse air temperature data via libdivecomputer. Nor are we set up to allow the user to manually enter it. We can parse it when downloading from a Uemis Zurich, though. This feature was suggested via trac.hohndel.org; this commit implements only part of what is requested there, so I simply reference the ticket here without closing it. References ticket #7 Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-25Expand Uemis Zurich download supportGravatar Dirk Hohndel
With this commit we not only use the getDivelogs command but also the getDive command for each of the dives that was downloaded. Oddly, that makes quite a bit of redundant (and at times slightly contradictory) data available, but also many new things. We now get weight, suit and notes that were stored with a dive in the logbook on the divecomputer. There are a ton more data available that we don't use, yet. For example information about altitude, a decoindex, dive type and dive activity, other equipment information, etc. I still need to decide how much of this I want to make available in Subsurface (and how I want to present this - after all most of this is not available from other dive computers). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-21Fix the way we handle translated event namesGravatar Dirk Hohndel
Here is what Linus reported: I think you have made a mistake in trying to translate some of libdivecomputer.c Translating some of those things based on locale is *wrong*, because they are saved in the XML file. That covers at least the warnings: they'll get translated when you import them, and then saved to the XML file as that translation, but now if you start subsurface in another locale, they will not get translated back. So translating XML file contents is fundamentally buggy. It just shouldn't be done. So all the "translations" for the event handling are buggy, and generate crap. Please don't do that. Leave them as English. And of course he is absolutely right. However, instead of not translating them at all, this commit fixes things a better way - we now mark the strings for translation but store the original English strings everywhere (in the in-memory data structure as well as in the XML file). Only when we actually display something on the screen (in a tooltip or in the filter dialog) do we actually translate the strings into the native language. This should address both Linus' issue and the desire to have localized event texts. Reported-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-10-11Conversion to gettext to allow localizationGravatar Dirk Hohndel
This is just the first step - convert the string literals, try to catch all the places where this isn't possible and the program needs to convert string constants at runtime (those are the N_ macros). Add a very rough first German localization so I can at least test what I have done. Seriously, I have never used a localized OS, so I am certain that I have many of the 'standard' translations wrong. Someone please take over :-) Major issues with this: - right now it hardcodes the search path for the message catalog to be ./locale - that's of course bogus, but it works well while doing initial testing. Once the tooling support is there we just should use the OS default. - even though de_DE defaults to ISO-8859-15 (or ISO-8859-1 - the internets can't seem to agree) I went with UTF-8 as that is what Gtk appears to want to use internally. ISO-8859-15 encoded .mo files create funny looking artefacts instead of Umlaute. - no support at all in the Makefile - I was hoping someone with more experience in how to best set this up would contribute a good set of Makefile rules - likely this will help fix the first issue in that it will also install the .mo file(s) in the correct place(s) For now simply run msgfmt -c -o subsurface.mo deutsch.po to create the subsurface.mo file and then move it to ./locale/de_DE.UTF-8/LC_MESSAGES/subsurface.mo If you make changes to the sources and need to add new strings to be translated, this is what seems to work (again, should be tooled through the Makefile): xgettext -o subsurface-new.pot -s -k_ -kN_ --add-comments="++GETTEXT" *.c msgmerge -s -U po/deutsch.po subsurface-new.pot If you do this PLEASE do one commit that just has the new msgid as changes in line numbers create a TON of diff-noise. Do changes to translations in a SEPARATE commit. - no testing at all on Windows or Mac It builds on Windows :-) Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-09-26Fix stupid packing error on WindowsGravatar Dirk Hohndel
I guess no one has ever tried to import Uemis dive data under Windows. The glib-2 libraries for Windows (at least the ones that are part of the mingw package, but my guess is this is true for all of them), force the whole program to be compiled with Windows packing rules for structures. That broke the structure we use for decoding Uemis binary data. This commit changes the data structure to no longer use unaligned 16bit values but instead two 8bit values and assemble them in the actual code. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2012-01-05Oddly, finishing a sample doesn't require a sampleGravatar Dirk Hohndel
So let's not pass it around Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-12-14Return is not a functionGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-11-01Even more places with pressure and volume conversionsGravatar Dirk Hohndel
Amazing at how many spots we are re-implementing the wheel. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-24Stop including regex.hGravatar Dirk Hohndel
I removed the regex code from the uemis parser a long time ago, but forgot to remove the #include <regex.h> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-20Fixed off by one error in uemis importerGravatar Dirk Hohndel
I clearly had never tried this with a dive that used the "just air" setting the uemis. With this fix the cylinder data for that one tank is read correctly. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-04Fix small typo in uemis event nameGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-03Much nicer implementation of uemis sample parsing - and add events, tooGravatar Dirk Hohndel
This is something I wanted to do for a while. Every uemis sample is simply a packed structure with no padding. Instead of grabbing random bytes from the middle of an unstructured data blob let's just define the structure and access its members. And while we do that, add support for the more useful uemis events as well. A couple of the warnings are disabled by default (compile time flag) as they are just crazy - any normal dive will give you dozens and dozens of speed warnings. Same goes for the PO2 green warning (I haven't looked but this seems to trigger on a PO2 over 1.0 or something). Completely useless and just hides actually useful info. I still want to redo the way we visualize events in general - just printing the text ontop of the profile really is suboptimal. Especially as the uemis really seems to love to repeat several of the warnings quite frequently. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-03Add working pressure to uemis tank dataGravatar Dirk Hohndel
Turns out they use 202.6bar as default working pressure. WTF? Also I had misunderstood the way I should record the pressure internally (which happened to work since I didn't set the working pressure). This is now fixed as well. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-03Remove the ability to 'Import' .SDA filesGravatar Dirk Hohndel
We can instead 'Open' these files as they are just bastardized XML files. This gets us back to a more consistent point where 'Import' gets data directly from the dive computer (and hopefully soon we will add the ability to load a dive directly from a uemis SDA to libdivecomputer), and 'Open' loads a file from the filesystem of the computer we are running on (this last sentence phrased so awkwardly as the uemis Zurich SDA is a computer and presents a file system when connected via USB - it just doesn't have the dive data in an accessible format in that file system). As a bonus we get to throw away quite a bit of code (the uemis specific file handling, mini-XML parser with helper functions, the file open dialog in the importer). Yay! Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-02Integrate loading of uemis SDA files into the regular xml parsingGravatar Dirk Hohndel
There are a few interesting issues with this: - this requires a change to the SDA file format; thankfully I control that format, too (the default files are not valid XML files) - once again, the fact that adding samples can change the dive pointer messes with me - I decided to change the interface of ALL of the XXX_dive_match functions to take a struct dive** I know this is not ideal as all the other functions don't need that - but I would have hated the inconsistency - there is the issue that we now overload two _different_ uemis formats in the same function - that's certainly a potential point of confusion - a minor detail is the problem that the SDA format is kinda odd to parse and that we trigger on the duration field by it being the only float. Yeah, that's not ideal - but again, I control the format, so I _know_ this is true. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-02First steps towards integrating SDA files into the default XML loadingGravatar Dirk Hohndel
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-10-02prepare_sample reallocs the dive - don't keep pointers aroundGravatar Dirk Hohndel
Thanks Valgrind This diff looks pointless at first until you see that I reference dive again earlier in the loop and then after the end of the loop. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-29Correctly parse the braindamaged tank size information from uemisGravatar Dirk Hohndel
Admittedly the cuft ratings are stupid, but still, it's not that hard. In order to correctly describe a tank based on the cuft system you need to know the cuft AND the working pressure. But the uemis Zurich always assumes that the working pressure is 200bar. That's pretty close to 3000psi and therefore works "good enough" for Aluminum tanks - but in general this will of course fail (e.g. for HP or LP tanks). Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-29Fix uemis parser to work with base64 data that isn't a multiple of 3Gravatar Dirk Hohndel
I had forgotten the '=' sign as valid character in base64 code Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-20Separate out the UI from the program logicGravatar Dirk Hohndel
The following are UI toolkit specific: gtk-gui.c - overall layout, main window of the UI divelist.c - list of dives subsurface maintains equipment.c - equipment / tank information for each dive info.c - detailed dive info print.c - printing The rest is independent of the UI: main.c i - program frame dive.c i - creates and maintaines the internal dive list structure libdivecomputer.c uemis.c parse-xml.c save-xml.c - interface with dive computers and the XML files profile.c - creates the data for the profile and draws it using cairo This commit should contain NO functional changes, just moving code around and a couple of minor abstractions. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
2011-09-15Fix depth calculations in SDA importGravatar Dirk Hohndel
stole and fixed Linus' code in the uemis XML importer Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-15Fix incorrect data dereferenceGravatar Dirk Hohndel
This caused incorrect "missing Dive100" messages when importing SDA file from the uemis Zurich. Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-09-15First pass to parse uemis Zurich '.SDA' filesGravatar Dirk Hohndel
This is missing a ton of the information in the .SDA files It only parses the divelog.SDA file, not the dive.SDA file It ignores the information on the gas(es) used and all the data on the tanks. It still draws some strange artefacts at the end of the dive But it correctly hooks into the import dialogue, it gives you a file select box (somewhere, I'm sure, a gtk developer cries quietly) and then parses enough of this file to serve as a proof of concept. Signed-off-by: Dirk Hohndel <dirk@hohndel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>