From e362272edcf026150ea350efbf9713b406e9326e Mon Sep 17 00:00:00 2001 From: Miika Turkia Date: Fri, 8 Mar 2013 21:44:10 +0200 Subject: 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 Signed-off-by: Dirk Hohndel --- parse-xml.c | 12 ++++++++---- 1 file 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); -- cgit v1.2.3-70-g09d2