diff options
author | Miika Turkia <miika.turkia@gmail.com> | 2013-03-08 21:44:10 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-03-08 11:54:11 -0800 |
commit | e362272edcf026150ea350efbf9713b406e9326e (patch) | |
tree | 89865bdea74bd63266bd63b5aa7d59410b11618f /parse-xml.c | |
parent | b5cd46aa3991d9e56aa0ca25125f5e7d1c1f15c2 (diff) | |
download | subsurface-e362272edcf026150ea350efbf9713b406e9326e.tar.gz |
Use information from proper table on DM4 import
Seems that DM4 has useless cylinder size data on global level and real
data on DiveMixture table. So using the correct data instead of the
global un-used value.
Similarly the DiveMixture table contains cylinder pressures. However, it
appears this information is available on DiveMixture table only in some
cases. So we use start and end pressures from DM table if available,
otherwise we use the global pressures. (My guess is that the DM table
has the pressure info only when the pressure has dropped from the
initial pressure reading that is reported in Dive table before the dive
is considered to have started.)
Signed-off-by: Miika Turkia <miika.turkia@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r-- | parse-xml.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/parse-xml.c b/parse-xml.c index 94ade6243..76c470506 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -1697,9 +1697,13 @@ extern int dm4_dive(void *param, int columns, char **data, char **column) * TODO: handle multiple cylinders */ cylinder_start(); - if (data[10]) - cur_dive->cylinder[cur_cylinder_index].start.mbar = (atoi(data[10])); - if (data[11]) + if (data[22] && atoi(data[22]) > 0) + cur_dive->cylinder[cur_cylinder_index].start.mbar = atoi(data[22]); + else if (data[10] && atoi(data[10]) > 0) + cur_dive->cylinder[cur_cylinder_index].start.mbar = atoi(data[10]); + if (data[23] && atoi(data[23]) > 0) + cur_dive->cylinder[cur_cylinder_index].end.mbar = (atoi(data[23])); + if (data[11] && atoi(data[11]) > 0) cur_dive->cylinder[cur_cylinder_index].end.mbar = (atoi(data[11])); if (data[12]) cur_dive->cylinder[cur_cylinder_index].type.size.mliter = (atof(data[12])) * 1000; @@ -1766,7 +1770,7 @@ int parse_dm4_buffer(const char *url, const char *buffer, int size, sqlite3 *handle; target_table = table; - char get_dives[] = "select D.DiveId,StartTime,Note,Duration,SourceSerialNumber,Source,MaxDepth,SampleInterval,StartTemperature,BottomTemperature,D.StartPressure,D.EndPressure,CylinderVolume,CylinderWorkPressure,SurfacePressure,DiveTime,SampleInterval,ProfileBlob,TemperatureBlob,PressureBlob,Oxygen,Helium FROM Dive AS D JOIN DiveMixture AS MIX ON D.DiveId=MIX.DiveId"; + char get_dives[] = "select D.DiveId,StartTime,Note,Duration,SourceSerialNumber,Source,MaxDepth,SampleInterval,StartTemperature,BottomTemperature,D.StartPressure,D.EndPressure,Size,CylinderWorkPressure,SurfacePressure,DiveTime,SampleInterval,ProfileBlob,TemperatureBlob,PressureBlob,Oxygen,Helium,MIX.StartPressure,MIX.EndPressure FROM Dive AS D JOIN DiveMixture AS MIX ON D.DiveId=MIX.DiveId"; retval = sqlite3_open(url,&handle); |