enum HPCS_ParseCode pret;
enum HPCS_RetCode ret;
enum HPCS_GenType gentype;
+ enum HPCS_ChemStationVer cs_ver;
if (mdata == NULL)
return HPCS_E_NULLPTR;
goto out;
}
- pret = read_file_header(datafile, mdata);
+ pret = read_file_header(datafile, &cs_ver, mdata);
if (pret != PARSE_OK) {
PR_DEBUG("Cannot read the header\n");
ret = HPCS_E_PARSE_ERROR;
pret = read_signal(datafile, &mdata->data, &mdata->data_count, CE_CCD_STEP, mdata->sampling_rate);
break;
case HPCS_TYPE_CE_CURRENT:
- pret = read_signal(datafile, &mdata->data, &mdata->data_count, guess_current_step(mdata), mdata->sampling_rate);
+ pret = read_signal(datafile, &mdata->data, &mdata->data_count, guess_current_step(cs_ver), mdata->sampling_rate);
break;
case HPCS_TYPE_CE_DAD:
pret = read_signal(datafile, &mdata->data, &mdata->data_count, CE_DAD_STEP, mdata->sampling_rate);
break;
case HPCS_TYPE_CE_POWER:
case HPCS_TYPE_CE_VOLTAGE:
- pret = read_signal(datafile, &mdata->data, &mdata->data_count, guess_elec_sigstep(mdata), mdata->sampling_rate);
+ pret = read_signal(datafile, &mdata->data, &mdata->data_count, guess_elec_sigstep(cs_ver, mdata->file_type), mdata->sampling_rate);
break;
case HPCS_TYPE_CE_PRESSURE:
pret = read_signal(datafile, &mdata->data, &mdata->data_count, CE_WORK_PARAM_STEP, mdata->sampling_rate);
enum HPCS_ParseCode pret;
enum HPCS_RetCode ret;
enum HPCS_GenType gentype;
+ enum HPCS_ChemStationVer cs_ver;
if (mdata == NULL)
return HPCS_E_NULLPTR;
goto out;
}
- pret = read_file_header(datafile, mdata);
+ pret = read_file_header(datafile, &cs_ver, mdata);
if (pret != PARSE_OK)
ret = HPCS_E_PARSE_ERROR;
else
return DCHECK_NO_MARKER;
}
+static enum HPCS_ChemStationVer detect_chemstation_version(const char*const version_string)
+{
+ if (!strcmp(version_string, CHEMSTAT_B0625_STR))
+ return CHEMSTAT_B0625;
+ else if (!strcmp(version_string, CHEMSTAT_B0625_STR))
+ return CHEMSTAT_B0626;
+ else if (strlen(version_string) == 0)
+ return CHEMSTAT_UNTAGGED;
+
+ return CHEMSTAT_UNKNOWN;
+}
+
+
static bool file_type_description_is_readable(const char*const description)
{
if (!strcmp(FILE_DESC_LC_DATA_FILE, description))
return ret;
}
-static HPCS_step guess_current_step(const struct HPCS_MeasuredData* mdata)
+static HPCS_step guess_current_step(const enum HPCS_ChemStationVer version)
{
- if (strcmp(mdata->cs_ver, CHEMSTAT_VER_B0625) == 0)
+ if (version != CHEMSTAT_B0625)
return CE_CURRENT_STEP;
return CE_WORK_PARAM_OLD_STEP * 10.0;
}
-static HPCS_step guess_elec_sigstep(const struct HPCS_MeasuredData* mdata)
+static HPCS_step guess_elec_sigstep(const enum HPCS_ChemStationVer version, const enum HPCS_FileType file_type)
{
- if (strcmp(mdata->cs_ver, CHEMSTAT_VER_B0625)) {
- switch (mdata->file_type) {
+ if (version != CHEMSTAT_B0625) {
+ switch (file_type) {
case HPCS_TYPE_CE_POWER:
return CE_ENERGY_STEP;
default:
return CE_WORK_PARAM_STEP;
}
-static bool guess_p_meaning(const struct HPCS_MeasuredData* mdata)
-{
- if (strcmp(mdata->cs_ver, CHEMSTAT_VER_B0625) == 0)
- return false;
-
- return true;
-}
-
-static void guess_sampling_rate(struct HPCS_MeasuredData* mdata)
+static void guess_sampling_rate(const enum HPCS_ChemStationVer version, struct HPCS_MeasuredData *mdata)
{
- if (strcmp(mdata->cs_ver, CHEMSTAT_VER_B0625)) {
+ switch (version) {
+ case CHEMSTAT_UNTAGGED:
switch (mdata->file_type) {
case HPCS_TYPE_CE_DAD:
mdata->sampling_rate *= 10;
default:
mdata->sampling_rate = CE_WORK_PARAM_SAMPRATE;
}
+ break;
+ case CHEMSTAT_B0626:
+ switch (mdata->file_type) {
+ case HPCS_TYPE_CE_DAD:
+ mdata->sampling_rate /= 100;
+ break;
+ default:
+ mdata->sampling_rate = CE_WORK_PARAM_SAMPRATE;
+ break;
+ }
+ break;
+ default:
+ break;
}
}
#endif
}
+static bool p_means_pressure(const enum HPCS_ChemStationVer version)
+{
+ if (version == CHEMSTAT_B0625)
+ return false;
+
+ return true;
+}
+
static enum HPCS_ParseCode parse_native_method_info_line(char** name, char** value, HPCS_NChar* line)
{
#ifdef _WIN32
return PARSE_OK;
}
-static enum HPCS_ParseCode read_file_header(FILE* datafile, struct HPCS_MeasuredData* mdata)
+static enum HPCS_ParseCode read_file_header(FILE* datafile, enum HPCS_ChemStationVer* cs_ver, struct HPCS_MeasuredData* mdata)
{
enum HPCS_ParseCode pret;
PR_DEBUG("Cannot read sampling rate of the file\n");
return pret;
}
- pret = autodetect_file_type(datafile, &mdata->file_type, guess_p_meaning(mdata));
+
+ *cs_ver = detect_chemstation_version(mdata->cs_rev);
+ if (pret != PARSE_OK) {
+ PR_DEBUG("Cannot detect ChemStation version\n");
+ return pret;
+ }
+
+ pret = autodetect_file_type(datafile, &mdata->file_type, p_means_pressure(*cs_ver));
if (pret != PARSE_OK) {
PR_DEBUG("Cannot determine the type of file\n");
return pret;
if (mdata->file_type == HPCS_TYPE_CE_DAD) {
pret = read_dad_wavelength(datafile, &mdata->dad_wavelength_msr, &mdata->dad_wavelength_ref);
if (pret != PARSE_OK && pret != PARSE_W_NO_DATA) {
- PR_DEBUG("Cannot read wavelength\n");
- return pret;
+ PR_DEBUG("Cannot read wavelength\n");
+ return pret;
}
}
- guess_sampling_rate(mdata);
+ guess_sampling_rate(*cs_ver, mdata);
return PARSE_OK;
}
/* Known file descriptions */
const char FILE_DESC_LC_DATA_FILE[] = "LC DATA FILE";
+enum HPCS_ChemStationVer {
+ CHEMSTAT_UNTAGGED,
+ CHEMSTAT_B0625,
+ CHEMSTAT_B0626,
+ CHEMSTAT_UNKNOWN
+};
+
/* Known ChemStation format versions */
-const char CHEMSTAT_VER_B0625[] = "B.06.25 [0003]";
+const char CHEMSTAT_B0625_STR[] = "B.06.25 [0003]";
+const char CHEMSTAT_B0626_STR[] = "B.06.25 [0010]";
/* Values of markers found in .ch files */
const char BIN_MARKER_A = 0x10;
static enum HPCS_ParseCode autodetect_file_type(FILE* datafile, enum HPCS_FileType* file_type, const bool p_means_pressure);
static enum HPCS_DataCheckCode check_for_marker(const char* segment, size_t* const next_marker_idx);
+static enum HPCS_ChemStationVer detect_chemstation_version(const char*const version_string);
static bool gentype_is_readable(const enum HPCS_GenType gentype);
-static HPCS_step guess_current_step(const struct HPCS_MeasuredData* mdata);
-static HPCS_step guess_elec_sigstep(const struct HPCS_MeasuredData *mdata);
-static bool guess_p_meaning(const struct HPCS_MeasuredData* mdata);
-static void guess_sampling_rate(struct HPCS_MeasuredData* mdata);
+static HPCS_step guess_current_step(const enum HPCS_ChemStationVer version);
+static HPCS_step guess_elec_sigstep(const enum HPCS_ChemStationVer version, const enum HPCS_FileType file_type);
+static void guess_sampling_rate(const enum HPCS_ChemStationVer version, struct HPCS_MeasuredData* mdata);
static bool file_type_description_is_readable(const char*const description);
static enum HPCS_ParseCode next_native_line(HPCS_UFH fh, HPCS_NChar* line, int32_t length);
static HPCS_UFH open_data_file(const char* filename);
static enum HPCS_ParseCode parse_native_method_info_line(char** name, char** value, HPCS_NChar* line);
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* month);
+static bool p_means_pressure(const enum HPCS_ChemStationVer version);
static enum HPCS_ParseCode read_date(FILE* datafile, struct HPCS_Date* date);
-static enum HPCS_ParseCode read_file_header(FILE* datafile, struct HPCS_MeasuredData* mdata);
+static enum HPCS_ParseCode read_file_header(FILE* datafile, enum HPCS_ChemStationVer* cs_ver, struct HPCS_MeasuredData* mdata);
static enum HPCS_ParseCode read_file_type_description(FILE* datafile, char** const description);
static enum HPCS_ParseCode read_generic_type(FILE* datafile, enum HPCS_GenType* gentype);
static enum HPCS_ParseCode read_method_info_file(HPCS_UFH fh, struct HPCS_MethodInfo* minfo);