ret = HPCS_E_PARSE_ERROR;
goto out;
}
- pret = autodetect_file_type(datafile, &mdata->file_type);
+ pret = autodetect_file_type(datafile, &mdata->file_type, guess_p_meaning(mdata));
if (pret != PARSE_OK) {
PR_DEBUG("Cannot determine the type of file\n");
ret = HPCS_E_PARSE_ERROR;
pret = read_floating_signal(datafile, &mdata->data, &mdata->data_count, CE_CCD_STEP, mdata->sampling_rate);
break;
case HPCS_TYPE_CE_CURRENT:
- pret = read_fixed_signal(datafile, &mdata->data, &mdata->data_count, CE_CURRENT_STEP, mdata->sampling_rate);
+ pret = read_fixed_signal(datafile, &mdata->data, &mdata->data_count, guess_current_step(mdata), mdata->sampling_rate);
break;
case HPCS_TYPE_CE_DAD:
pret = read_fixed_signal(datafile, &mdata->data, &mdata->data_count, CE_DAD_STEP, mdata->sampling_rate);
break;
case HPCS_TYPE_CE_POWER:
+ case HPCS_TYPE_CE_PRESSURE:
+ case HPCS_TYPE_CE_TEMPERATURE:
case HPCS_TYPE_CE_VOLTAGE:
- pret = read_fixed_signal(datafile, &mdata->data, &mdata->data_count, CE_PWR_VOLT_STEP, mdata->sampling_rate);
+ pret = read_fixed_signal(datafile, &mdata->data, &mdata->data_count, CE_WORK_PARAM_STEP, mdata->sampling_rate);
break;
case HPCS_TYPE_UNKNOWN:
ret = HPCS_E_UNKNOWN_TYPE;
return ret;
}
-static enum HPCS_ParseCode autodetect_file_type(FILE* datafile, enum HPCS_File_Type* file_type)
+static enum HPCS_ParseCode autodetect_file_type(FILE* datafile, enum HPCS_File_Type* file_type, const bool p_means_pressure)
{
char* type_id;
enum HPCS_ParseCode pret;
*file_type = HPCS_TYPE_CE_CURRENT;
else if (hpce_id == FILE_TYPE_HPCE_POWER)
*file_type = HPCS_TYPE_CE_POWER;
+ else if (hpce_id == FILE_TYPE_HPCE_POWER_PRESSURE)
+ *file_type = p_means_pressure ? HPCS_TYPE_CE_PRESSURE : HPCS_TYPE_CE_POWER;
+ else if (hpce_id == FILE_TYPE_HPCE_TEMPERATURE)
+ *file_type = HPCS_TYPE_CE_TEMPERATURE;
else if (hpce_id == FILE_TYPE_HPCE_VOLTAGE)
*file_type = HPCS_TYPE_CE_VOLTAGE;
else
return DCHECK_E_NO_MARKER;
}
+static HPCS_step guess_current_step(struct HPCS_MeasuredData* const mdata)
+{
+ if (strcmp(mdata->cs_ver, CHEMSTAT_VER_B0625) == 0)
+ return CE_CURRENT_STEP;
+
+ return CE_WORK_PARAM_STEP;
+}
+
+static bool guess_p_meaning(struct HPCS_MeasuredData* const mdata)
+{
+ if (strcmp(mdata->cs_ver, CHEMSTAT_VER_B0625) == 0)
+ return false;
+
+ return true;
+}
+
static enum HPCS_ParseCode read_dad_wavelength(FILE* datafile, struct HPCS_Wavelength* const measured, struct HPCS_Wavelength* const reference)
{
char* start_idx, *interv_idx, *end_idx, *temp, *str;
+#include <stdbool.h>
#include <stdio.h>
enum HPCS_DataCheckCode {
const char* FILE_TYPE_ID_HPCE = "HPCE";
const char FILE_TYPE_HPCE_CCD = 'L';
const char FILE_TYPE_HPCE_CURRENT = 'C';
+const char FILE_TYPE_HPCE_POWER_PRESSURE = 'P';
+const char FILE_TYPE_HPCE_POWER = 'E';
+const char FILE_TYPE_HPCE_TEMPERATURE = 'T';
const char FILE_TYPE_HPCE_VOLTAGE = 'V';
-const char FILE_TYPE_HPCE_POWER = 'P';
/* Char and text values */
const char* WAVELENGTH_MEASURED_TEXT = "Sig=";
const HPCS_step CE_CURRENT_STEP = 0.01;
const HPCS_step CE_CCD_STEP = 0.0000596046450027643;
const HPCS_step CE_DAD_STEP = 0.000476837158203;
-const HPCS_step CE_PWR_VOLT_STEP = 0.001;
+const HPCS_step CE_WORK_PARAM_STEP = 0.001;
/* Offsets containing data of interest in .ch files */
const HPCS_offset DATA_OFFSET_FILE_DESC = 0x15B;
const HPCS_offset DATA_OFFSET_DEVSIG_INFO = 0x1075;
const HPCS_offset DATA_OFFSET_DATA_START = 0x1800;
+/* Known ChemStation format versions */
+const char* CHEMSTAT_VER_B0625 = "B.06.25 [0003]";
+
/* Values of markers found in .ch files */
const char BIN_MARKER_A = 0x10;
const char BIN_MARKER_END = 0x00;
const char* HPCS_E_UNKNOWN_TYPE_STR = "The specified file contains an unknown type of measurement.";
const char* HPCS_E__UNKNOWN_EC_STR = "Unknown error code.";
-static enum HPCS_ParseCode autodetect_file_type(FILE* datafile, enum HPCS_File_Type* file_type);
+static enum HPCS_ParseCode autodetect_file_type(FILE* datafile, enum HPCS_File_Type* file_type, const bool p_means_pressure);
static enum HPCS_DataCheckCode check_for_marker(const char* const segment, size_t* const next_marker_idx);
+static HPCS_step guess_current_step(struct HPCS_MeasuredData* const mdata);
+static bool guess_p_meaning(struct HPCS_MeasuredData* const mdata);
static enum HPCS_ParseCode read_dad_wavelength(FILE* datafile, struct HPCS_Wavelength* const measured, struct HPCS_Wavelength* const reference);
static uint8_t month_to_number(const char* const month);
static enum HPCS_ParseCode read_date(FILE* datafile, struct HPCS_Date* const date);