diff --git a/Framework/DataHandling/CMakeLists.txt b/Framework/DataHandling/CMakeLists.txt index e30f516e5cb8afd614bcc0103ad352257c90c9fb..ca5ee47b5d52480e6bb0055518f1b1251efe52de 100644 --- a/Framework/DataHandling/CMakeLists.txt +++ b/Framework/DataHandling/CMakeLists.txt @@ -91,6 +91,7 @@ set ( SRC_FILES src/LoadParameterFile.cpp src/LoadPreNexus.cpp src/LoadPreNexusMonitors.cpp + src/LoadPSIMuonBin.cpp src/LoadQKK.cpp src/LoadRKH.cpp src/LoadRaw/byte_rel_comp.cpp @@ -279,6 +280,7 @@ set ( INC_FILES inc/MantidDataHandling/LoadParameterFile.h inc/MantidDataHandling/LoadPreNexus.h inc/MantidDataHandling/LoadPreNexusMonitors.h + inc/MantidDataHandling/LoadPSIMuonBin.h inc/MantidDataHandling/LoadQKK.h inc/MantidDataHandling/LoadRKH.h inc/MantidDataHandling/LoadRaw3.h diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadPSIMuonBin.h b/Framework/DataHandling/inc/MantidDataHandling/LoadPSIMuonBin.h new file mode 100644 index 0000000000000000000000000000000000000000..731d1fba64a353b2129e26fcb971d6685670c578 --- /dev/null +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadPSIMuonBin.h @@ -0,0 +1,80 @@ +#ifndef MANTID_DATAHANDLING_LOADPSIMUONBIN_H_ +#define MANTID_DATAHANDLING_LOADPSIMUONBIN_H_ + +#include "MantidDataHandling/LoadRawHelper.h" +#include "MantidDataObjects/Workspace2D.h" +#include <cstdint> + +namespace Mantid { +namespace DataHandling { + +class DLLExport LoadPSIMuonBin + : public API::IFileLoader<Kernel::FileDescriptor> { +public: + /// Default constructor + LoadPSIMuonBin(); + /// Algorithm's name for identification overriding a virtual method + const std::string name() const override; + /// Summary of algorithms purpose + const std::string summary() const override; + + /// Algorithm's version for identification overriding a virtual method + int version() const override; + + /// Algorithm's category for identification overriding a virtual method + const std::string category() const override; + + /// Returns a confidence value that this algorithm can load a file + int confidence(Mantid::DescriptorType &descriptor) const override; + + /// Returns a value indicating whether or not loader wants to load multiple + /// files into a single workspace + bool loadMutipleAsOne() override; + +private: + /// Overwrites Algorithm method. + void init() override; + /// Overwrites Algorithm method + void exec() override; + + // Define the variables of the header + int16_t tdcResolution; + int16_t tdcOverflow; + int16_t numberOfRuns; + int16_t lengthOfHistograms; + int16_t numberOfHistograms; + char sample[11]; // char arrays are 1 larger to allow for '/0' if needed + char temp[11]; + char field[11]; + char orientation[11]; + char comment[63]; + char dateStart[10]; + char dateEnd[10]; + char timeStart[9]; + char timeEnd[9]; + int32_t totalEvents; + int32_t labelsOfHistograms[16]; + int16_t integerT0[16]; + int16_t firstGood[16]; + int16_t lastGood[16]; + float real_t0[16]; + int32_t scalars[18]; + char labels_scalars[18][5]; // 18 lots of 4 char arrays with '/0' at the end + float histogramBinWidth; + float temperatures[4]; + float temperatureDeviation[4]; + float monLow[4]; //No idea what this is + float monHigh[4]; + int32_t monNumberOfevents; + char monDeviation[12]; + int16_t numberOfDataRecordsFile; //numdef + int16_t lengthOfDataRecordsBin; //lendef + int16_t numberOfDataRecordsHistogram; //kdafhi + int16_t numberOfHistogramsPerRecord; //khidaf + int32_t periodOfSave; + int32_t periodOfMon; +} +} // namespace DataHandling +} // namespace Mantid + +#endif /*MANTID_DATAHANDLING_LOADPSIMUONBIN_H_*/ \ No newline at end of file diff --git a/Framework/DataHandling/src/LoadPSIMuonBin.cpp b/Framework/DataHandling/src/LoadPSIMuonBin.cpp new file mode 100644 index 0000000000000000000000000000000000000000..f0933b04e293fb92f49425e16dd30b11e3d704e7 --- /dev/null +++ b/Framework/DataHandling/src/LoadPSIMuonBin.cpp @@ -0,0 +1,79 @@ +#include "MantidDataHandling/LoadPSIMuonBin.h" + +#include <fstream> + +namespace Mantid { +namespace DataHandling { + +DECLARE_FILELOADER_ALGORITHM(LoadPSIMuonBin) + +// Algorithm's name for identification. @see Algorithm::name +const std::string LoadPSIMuonBin::name() const { return "LoadPSIMuonBin"; } + +// Algorithm's version for identification. @see Algorithm::version +int LoadPSIMuonBin::version() const { return 1; } + +const std::string LoadPSIMuonBin::summary() const { + return "Loads a data file that is in PSI Muon Binary format into a " + "workspace (Workspace2D class)."; +} + +// Algorithm's category for identification. @see Algorithm::category +const std::string LoadPSIMuonBin::category() const { + return "DataHandling\\PSIMuonBin"; +} + +// Default constructor TODO: Delete if not needed +LoadPSIMuonBin::LoadPSIMuonBin() {} + +/** + * @brief + * + * @param descriptor + * @return int + */ +int LoadPSIMuonBin::confidence(DescriptorType &descriptor) const override {} + +// version 1 does not however there is an issue open to create a version which +// handles temperatures aswell +bool LoadPSIMuonBin::loadMutipleAsOne() override { return false; } + +void LoadPSIMuonBin::init() { + const std::vector<std::string> exts{".bin"}; + declareProperty(Kernel::make_unique<FileProperty>("Filename", "", + FileProperty::Load, exts), + "The name of the Bin file to load"); + + declareProperty(Kernel::make_unique<WorkspaceProperty<Workspace>>( + "OutputWorkspace", "", Mantid::Direction::Output), + "An output workspace."); +} + +void LoadPSIMuonBin::exec() { + + if (sizeOf(float) != 4) { + // assumpetions made about the binary input won't work but since there is no + // way to guarantee floating points are 32 bits on all Operating systems here + // we are. + } + + std::string binFilename = getPropertyValue("Filename"); + // std::vector<Histogram> readHistogramData; + + // ifstream *binFile; + // binFile.open(fileName, ios_base::binary); + + const int sizeOfHeader = 1024; + const char binFileHeaderBuffer[sizeofHeader]; + // binFile.read(binFileHeaderBuffer, sizeOfHeader); + + std::string fileFormat(binFileHeaderBuffer, 2); + + if (fileFormat != "1N") { + // Throw Error for file type + } + + std::memcpy(&tdcResolution, binFileHeaderBuffer + 2, 2); // get resolution +} +} // namespace DataHandling +} // namespace Mantid \ No newline at end of file diff --git a/buildconfig/windows/visual-studio.bat.in b/buildconfig/windows/visual-studio.bat.in old mode 100644 new mode 100755