[PATCH] Use information from proper table on DM4 import

Miika Turkia miika.turkia at gmail.com
Fri Mar 8 11:44:10 PST 2013


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 at gmail.com>
---
 parse-xml.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/parse-xml.c b/parse-xml.c
index a5b2f5c..064f329 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -1678,9 +1678,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;
@@ -1747,7 +1751,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);
 
-- 
1.7.9.5



More information about the subsurface mailing list