Commit 36e9645c authored by Remi Perenon's avatar Remi Perenon

Removal of SrcCpp folder since HDF5 is now moved to Fortran

parent 1944102c
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://www.osor.eu/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "NameServer.h"
#include "ArgumentHandler.h"
using namespace std;
ArgumentHandler* ArgumentHandler::_singleton = 0;
ArgumentHandler::ArgumentHandler(){
verboseMode=false;
replaceMode=true;
asciiFileName="";
nexusFileName="";
targetDirectory="";
}
ArgumentHandler::~ArgumentHandler(){
}
ArgumentHandler * ArgumentHandler::getArgumentHandlerInstance(){
if (_singleton == 0){
_singleton = new ArgumentHandler();
}
return _singleton;
}
void ArgumentHandler::reset()
{
if (_singleton)
{
delete _singleton;
_singleton = 0;
}
}
void ArgumentHandler::verboseOn(){
verboseMode = true;
}
void ArgumentHandler::replaceOff(){
replaceMode = true;
}
void ArgumentHandler::setAsciiFileName(string name){
asciiFileName = name;
}
void ArgumentHandler::setNexusFileName(string name){
nexusFileName=name;
}
void ArgumentHandler::setTargetDirectory(string name){
targetDirectory = name;
}
void ArgumentHandler::setDataFileConfig(string name){
dataFileConfig=name;
}
bool ArgumentHandler::isVerbose(){
return verboseMode;
}
bool ArgumentHandler::isReplace(){
return replaceMode;
}
string ArgumentHandler::getAsciiFileName(){
return asciiFileName;
}
string ArgumentHandler::getNexusFileName(){
return nexusFileName;
}
string ArgumentHandler::getTargetDirectory(){
return targetDirectory;
}
string ArgumentHandler::getDataFileConfig(){
return dataFileConfig;
}
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://www.osor.eu/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef ARGUMENTHANDLER_H
#define ARGUMENTHANDLER_H
#include <iostream>
#include <string>
class ArgumentHandler{
private:
static ArgumentHandler *_singleton;
bool verboseMode;
bool replaceMode;
std::string asciiFileName;
std::string nexusFileName;
std::string targetDirectory;
std::string dataFileConfig;
ArgumentHandler();
~ArgumentHandler();
public:
static ArgumentHandler * getArgumentHandlerInstance();
static void reset();
void verboseOn();
void replaceOff();
void setAsciiFileName(std::string name);
void setNexusFileName(std::string name);
void setTargetDirectory(std::string name);
void setDataFileConfig(std::string name);
bool isVerbose();
bool isReplace();
std::string getAsciiFileName();
std::string getNexusFileName();
std::string getTargetDirectory();
std::string getDataFileConfig();
};
#endif
#################################
# Command line arguments section
#################################
#cmake -DCMAKE_GENERATOR_PLATFORM=x64 ..
cmake_minimum_required(VERSION 2.8.0 FATAL_ERROR)
# A "trick" has been set on the build server to build with MinGW
# See See http://hdf-forum.184993.n3.nabble.com/HDF5-and-MinGW-td3393676.html for more details about this "trick"
if(MINGW_HDF_TRICK)
add_compile_options(-DMINGW_HDF_TRICK)
endif()
#################################
# Sources section
#################################
project(crysfml_cpp)
set(crysfml_cpp_sources ./NexusToCFML.cpp)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../cmake/")
add_library(crysfml_cpp STATIC ./NexusToCFML.cpp ./DataNexusLib.cpp ./blosc_filter.c ./HeaderBloc.cpp ./IntegerBloc.cpp ./FloatBloc.cpp ./DataBloc.cpp ./ArgumentHandler.cpp )
install(TARGETS crysfml_cpp
DESTINATION ${PROJECT_SOURCE_DIR}/../ifort64/LibC)
install(TARGETS crysfml_cpp
DESTINATION ${PROJECT_SOURCE_DIR}/../ifort64HDF/LibC)
#################################
# Dependencies section
#################################
# Boost
# Use proper "Findboost_cryfml.cmake"
find_package(boost_crysfml)
include_directories(${Boost_INCLUDE_DIR})
# HDF5
# Use proper "Findhdf5_cryfml.cmake"
find_package(hdf5_crysfml)
include_directories(${HDF5_INCLUDE_DIR})
# Nexus and blosc
find_package(nexus)
include_directories(${NEXUS_INCLUDE_DIR})
# Including blosc, useless on macOS and Linux
find_package(blosc)
include_directories(${BLOSC_INCLUDE_DIR})
\ No newline at end of file
This diff is collapsed.
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef DATABLOC_H
#define DATABLOC_H
#include "ArgumentHandler.h"
#include <napi.h>
class DataBloc {
private:
static DataBloc *_singleton;
/*!
* \Constructor
*/
DataBloc();
~DataBloc();
public:
static DataBloc * getDataBlocInstance();
static void reset();
void getDataBlocTime(float p4[], int size) ;
void getDataBlocMoni(float p4[], int size) ;
void getDataBlocTotalCount(float p4[], int size) ;
void getDataBlocAngle1(float p4[], int size) ;
// void getDataBlocDataFull(float p4[], int size) ;
void getDataBlocDataFull(int p4[], int size) ;
/*!
* \brief Getter of actual time of the counter is seconds
*
* \return actual time of the counter is seconds
*/
int save( ) ;
int read( ) ;
void setDataMode( bool dataRaw);
// double mean_of();
// double variance_of();
// double standard_deviation_of();
private:
void read_scan_var();
void decode_var_name();
void read_data();
void read_data2(int *pp);
void fastMemcpy(void *pvDest, void *pvSrc, size_t nBytes) ;
ArgumentHandler * m_AH;
std::string m_nxFileName;
bool m_is_scan;
int m_actual_step;
int m_total_steps;
int m_RecordNumber;
float* m_time;
float* m_monitor;
float* m_totaCount;
float* m_angles1;
float* m_angles2;
float* m_angles3;
float* m_angles4;
int m_index_time;
int m_index_monitor;
int m_index_totalCount;
int m_index_angles1;
int m_index_angles2;
int m_index_angles3;
int m_index_angles4;
int m_nb_prop;
int m_prop_index[7];
bool m_dataRaw;
int *m_dread_data;
};
#endif
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "DataNexusLib.h"
using namespace std;
int DataNexusLib::OpenPath(NXhandle myfile_id,string path1) {
if (NXopenpath(myfile_id, path1.c_str()) != NX_OK) {
cout << "Error open " <<path1 << endl;
return -1;
}
return 1;
}
int DataNexusLib::OpenPath(NXhandle myfile_id,string path1, string path2) {
if (NXopenpath(myfile_id, path1.c_str()) != NX_OK) {
cout << "Error open " <<path1 << endl;
return -1;
}
if (NXopenpath(myfile_id, path2.c_str()) != NX_OK) {
cout << "Error open " <<path2 << endl;
return -1;
}
return 1;
}
int DataNexusLib::OpenPath(NXhandle myfile_id,string path1, string path2, string path3) {
if (NXopenpath(myfile_id, path1.c_str()) != NX_OK) {
cout << "Error open " << path1 << endl;
return -1;
}
if (NXopenpath(myfile_id, path2.c_str()) != NX_OK) {
cout << "Error open " << path2 << endl;
return -1;
}
if (NXopenpath(myfile_id, path3.c_str()) != NX_OK) {
cout << "Error open " << path3 << endl;
return -1;
}
return 1;
}
string DataNexusLib::getStringValue(NXhandle myfile_id,string champ){
int NXtype, NXrank;
int NXdims[32];
void *data_buffer;
string err = "777";
string res;
if (NXopendata (myfile_id, champ.c_str())!=NX_OK){ cout << "FRA03"<< endl; return err;}
if (NXgetinfo (myfile_id, &NXrank, NXdims, &NXtype)!=NX_OK){ cout << "FRA04"<< endl; return err;}
if (NXmalloc ((void **) &data_buffer, NXrank, NXdims, NXtype)!=NX_OK){ cout << "FRA05"<< endl; return err;}
if (NXgetdata (myfile_id, data_buffer)!=NX_OK){ cout << "FRA06"<< endl; return err;}
res=(string)((char *) data_buffer);
// Debug cout << champ << " " << res << endl;
if (NXfree ((void **) &data_buffer) !=NX_OK) { cout << "FRA06"<< endl; return err;}
return res;
}
int DataNexusLib::getIntValue(NXhandle myfile_id,string champ){
int NXtype, NXrank;
int NXdims[32];
void *data_buffer;
int err = 777;
int resI;
if (NXopendata (myfile_id, champ.c_str())!=NX_OK){ cout << "FRA13"<< endl; return err;}
if (NXgetinfo (myfile_id, &NXrank, NXdims, &NXtype)!=NX_OK){ cout << "FRA14"<< endl; return err;}
if (NXmalloc ((void **) &data_buffer, NXrank, NXdims, NXtype)!=NX_OK){ cout << "FRA15"<< endl; return err;}
if (NXgetdata (myfile_id, data_buffer)!=NX_OK){ cout << "FRA16"<< endl; return err;}
resI=*((int *)data_buffer);
// Debug cout << champ << " (Int) = " << resI << endl;
if (NXfree ((void **) &data_buffer) !=NX_OK) { cout << "FRA17"<< endl; return err;}
return resI;
}
float DataNexusLib::getFloatValue(NXhandle myfile_id,string champ){
int NXtype, NXrank;
int NXdims[32];
void *data_buffer;
float err = 777;
float resI;
if (NXopendata (myfile_id, champ.c_str())!=NX_OK){ cout << "FRA23"<< endl; return err;}
if (NXgetinfo (myfile_id, &NXrank, NXdims, &NXtype)!=NX_OK){ cout << "FRA24"<< endl; return err;}
if (NXmalloc ((void **) &data_buffer, NXrank, NXdims, NXtype)!=NX_OK){ cout << "FRA25"<< endl; return err;}
if (NXgetdata (myfile_id, data_buffer)!=NX_OK){ cout << "FRA26"<< endl; return err;}
//resI=(int)((char *) data_buffer);
resI=*((float *)data_buffer);
// Debug cout << champ << " (float) = " << resI << endl;
if (NXfree ((void **) &data_buffer) !=NX_OK) { cout << "FRA27"<< endl; return err;}
return resI;
}
float DataNexusLib::getFloatIndexValue(NXhandle myfile_id,string champ,int index){
int NXtype, NXrank;
int NXdims[32];
void *data_buffer;
float err = 777;
float resF;
if (NXopendata (myfile_id, champ.c_str())!=NX_OK){ cout << "FRA33"<< endl; return err;}
if (NXgetinfo (myfile_id, &NXrank, NXdims, &NXtype)!=NX_OK){ cout << "FRA34"<< endl; return err;}
if (NXmalloc ((void **) &data_buffer, NXrank, NXdims, NXtype)!=NX_OK){ cout << "FRA35"<< endl; return err;}
if (index > (NXdims[0]-1) ){
cerr << "ERROR getFloatIndexValue bad index "<< index << endl;
return err;
}
if (NXgetdata (myfile_id, data_buffer)!=NX_OK){ cout << "FRA37"<< endl; return err;}
float * dataPtr = ((float *)data_buffer);
resF = dataPtr[index] ;
//if (resF<0.0000000001) resF = 0.0; ?? Why
// Debug cout << champ << " (float) = " << resF << endl;
if (NXfree ((void **) &data_buffer) !=NX_OK) { cout << "FRA38"<< endl; return err;}
return resF;
}
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef DATANEXUSLIB_H
#define DATANEXUSLIB_H
#include "ArgumentHandler.h"
#include "./napi.h"
class DataNexusLib {
public:
static int OpenPath(NXhandle myfile_id,std::string path1);
static int OpenPath(NXhandle myfile_id,std::string path1,std::string path2);
static int OpenPath(NXhandle myfile_id,std::string path1,std::string path2,std::string path3);
static std::string getStringValue(NXhandle myfile_id,std::string champ);
static int getIntValue(NXhandle myfile_id,std::string champ);
static float getFloatValue(NXhandle myfile_id,std::string champ);
static float getFloatIndexValue(NXhandle myfile_id,std::string champ,int index);
private:
};
#endif
This diff is collapsed.
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef FLOATBLOC_H
#define FLOATBLOC_H
#include "ArgumentHandler.h"
class FloatBloc {
private:
static FloatBloc *_singleton;
/*!
* \Constructor
*/
FloatBloc();
~FloatBloc();
public:
static FloatBloc * getFloatBlocInstance();
static void reset();
void getFloatBloc(float p4[], int size) ;
/*!
* \brief Getter of actual time of the counter is seconds
*
* \return actual time of the counter is seconds
*/
int save( ) ;
int read( ) ;
// double mean_of();
// double variance_of();
// double standard_deviation_of();
private:
ArgumentHandler * m_AH;
float m_qH ;
float m_qK ;
float m_qL ;
float m_phi ;
float m_chi;
//
float m_omega;
float m_2theta ;
float m_psi;
float m_ub11;
float m_ub12;
//
float m_ub13;
float m_ub21;
float m_ub22;
float m_ub23;
float m_ub31;
//
float m_ub32 ;
float m_ub33 ;
float m_wavelength ;
float m_spare1 ;
float m_danalyser;
//
float m_energy ;
float m_Hmax ;
float m_Kmax ;
float m_Lmax ;
float m_DeltaH;
//
float m_DeltaK ;
float m_DeltaL ;
float m_Deltaenergy ;
float m_Ki ;
float m_Ddetector;
//
float m_xoff ;
float m_zoff ;
float m_radius ;
float m_yoff ;
float m_attenuat;
//
float m_scan_start;
float m_scan_step ;
float m_scan_width ;
float m_preset ;
float m_addbkgstep;
//
float m_addbkgwidth;
float m_addbkgpreset ;
float m_couplingfactor ;
float m_spare2 ;
float m_spare3;
//
float m_Tset;
float m_Treg;
float m_Tsample;
float m_Voltmeter ;
float m_Magfield;
};
#endif
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*