adjust to new revision, main.cpp fix help message typo
This commit is contained in:
parent
584243f466
commit
3c91583ede
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
eatraw
|
eatraw
|
||||||
eatdev
|
eatdev
|
||||||
|
imctermite
|
||||||
|
|
||||||
nohup.out
|
nohup.out
|
||||||
|
|
||||||
|
154
makefile
154
makefile
@ -1,92 +1,112 @@
|
|||||||
#-----------------------------------------------------------------------------#
|
#-----------------------------------------------------------------------------#
|
||||||
|
|
||||||
# choose shell
|
# name of executable and CLI tool
|
||||||
SHELL:=/bin/bash
|
EXE = imctermite
|
||||||
|
|
||||||
RAW = ../raw/
|
|
||||||
|
|
||||||
# directory names
|
# directory names
|
||||||
SRC = src/
|
SRC = src/
|
||||||
LIB = lib/
|
LIB = lib/
|
||||||
CYT = cyt/
|
CYT = cyt/
|
||||||
|
|
||||||
# name of executable
|
# list headers
|
||||||
EXE = eatraw
|
HPP = $(wildcard $(LIB)/*.hpp)
|
||||||
|
|
||||||
# compiler and its options
|
# choose compiler and its options
|
||||||
CCC = g++ -std=c++11
|
CC = g++ -std=c++17
|
||||||
#OPT = -O3 -Wall -mavx -mno-tbm -mf16c -mno-f16c
|
#OPT = -O3 -Wall -mavx -mno-tbm -mf16c -mno-f16c
|
||||||
OPT = -O3 -Wall -Werror
|
OPT = -O3 -Wall -Werror -Wunused-variable -Wsign-compare
|
||||||
|
|
||||||
|
# determine git version/commit tag
|
||||||
|
GTAG := $(shell git tag | tail -n1)
|
||||||
|
GHSH := $(shell git rev-parse HEAD | head -c8)
|
||||||
|
|
||||||
|
# define install location
|
||||||
|
INST := /usr/local/bin
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------#
|
#-----------------------------------------------------------------------------#
|
||||||
# C++
|
# C++ and CLI tool
|
||||||
|
|
||||||
# build executable
|
# build exectuable
|
||||||
$(EXE) : $(SRC)main.cpp $(LIB)raweat.hpp $(LIB)hexshow.hpp $(LIB)rawmerge.hpp output
|
$(EXE) : main.o
|
||||||
$(CCC) $(OPT) $< -o $@
|
$(CC) $(OPT) $^ -o $@
|
||||||
|
|
||||||
# development version
|
# build main.cpp and include git version/commit tag
|
||||||
eatdev : $(SRC)main_dev.cpp $(LIB)raweat.hpp
|
main.o : src/main.cpp $(HPP)
|
||||||
$(CCC) $(OPT) $< -o $@
|
@cp $< $<.cpp
|
||||||
|
@sed -i 's/TAGSTRING/$(GTAG)/g' $<.cpp
|
||||||
|
@sed -i 's/HASHSTRING/$(GHSH)/g' $<.cpp
|
||||||
|
$(CC) -c $(OPT) -I $(LIB) $<.cpp -o $@
|
||||||
|
@rm $<.cpp
|
||||||
|
|
||||||
# build target for conversion set of .raw files
|
install : $(EXE)
|
||||||
eatall : $(SRC)eatall.cpp $(LIB)raweat.hpp
|
cp $< $(INST)/
|
||||||
$(CCC) $(OPT) $< -o $@
|
|
||||||
|
uninstall : $(INST)/$(EXE)
|
||||||
|
rm $<
|
||||||
|
|
||||||
# remove executable
|
|
||||||
clean :
|
clean :
|
||||||
rm -f $(EXE)
|
rm -vf $(EXE)
|
||||||
rm -f eatall
|
rm -v *.o
|
||||||
rm -f eatdev
|
|
||||||
rm -rf output/
|
# # build CLI executable
|
||||||
|
# $(EXE) : $(SRC)main.cpp $(LIB)raweat.hpp $(LIB)hexshow.hpp $(LIB)rawmerge.hpp output
|
||||||
|
# $(CCC) $(OPT) $< -o $@
|
||||||
|
|
||||||
|
# # development version
|
||||||
|
# eatdev : $(SRC)main_dev.cpp $(LIB)raweat.hpp
|
||||||
|
# $(CCC) $(OPT) $< -o $@
|
||||||
|
#
|
||||||
|
# # build target for conversion set of .raw files
|
||||||
|
# eatall : $(SRC)eatall.cpp $(LIB)raweat.hpp
|
||||||
|
# $(CCC) $(OPT) $< -o $@
|
||||||
|
|
||||||
# check existence of name of executable globally
|
# check existence of name of executable globally
|
||||||
chexe:=$(shell command -v $(EXE))
|
# chexe:=$(shell command -v $(EXE))
|
||||||
|
#
|
||||||
|
# # install executable if name does not exist yet
|
||||||
|
# install : $(EXE)
|
||||||
|
# ifeq ($(chexe),)
|
||||||
|
# cp $(EXE) /usr/local/bin/
|
||||||
|
# else
|
||||||
|
# @echo "executable with name already exists! choose different name!"
|
||||||
|
# @exit 1
|
||||||
|
# endif
|
||||||
|
|
||||||
# install executable if name does not exist yet
|
# # uninstall
|
||||||
install : $(EXE)
|
# uninstall :
|
||||||
ifeq ($(chexe),)
|
# rm /usr/local/bin/$(EXE)
|
||||||
cp $(EXE) /usr/local/bin/
|
|
||||||
else
|
|
||||||
@echo "executable with name already exists! choose different name!"
|
|
||||||
@exit 1
|
|
||||||
endif
|
|
||||||
|
|
||||||
# uninstall
|
|
||||||
uninstall :
|
|
||||||
rm /usr/local/bin/$(EXE)
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------#
|
#-----------------------------------------------------------------------------#
|
||||||
# Python
|
# Python
|
||||||
|
#
|
||||||
# build python module
|
# # build python module
|
||||||
py : $(CYT)setup_raw_eater.py $(CYT)raw_eater.pyx $(CYT)raw_eater.pxd $(LIB)raweat.hpp \
|
# py : $(CYT)setup_raw_eater.py $(CYT)raw_eater.pyx $(CYT)raw_eater.pxd $(LIB)raweat.hpp \
|
||||||
$(CYT)setup_raw_meat.py $(CYT)raw_meat.pyx $(CYT)raw_meat.pxd $(LIB)rawmerge.hpp \
|
# $(CYT)setup_raw_meat.py $(CYT)raw_meat.pyx $(CYT)raw_meat.pxd $(LIB)rawmerge.hpp \
|
||||||
output
|
# output
|
||||||
python3 $(CYT)setup_raw_eater.py build_ext --inplace
|
# python3 $(CYT)setup_raw_eater.py build_ext --inplace
|
||||||
python3 $(CYT)setup_raw_meat.py build_ext --inplace
|
# python3 $(CYT)setup_raw_meat.py build_ext --inplace
|
||||||
cp raw_eater.cpython-*.so pyt/
|
# cp raw_eater.cpython-*.so pyt/
|
||||||
cp raw_meat.cpython-*.so pyt/
|
# cp raw_meat.cpython-*.so pyt/
|
||||||
rm *.so
|
# rm *.so
|
||||||
|
#
|
||||||
py-install: $(CYT)setup_raw_eater.py $(CYT)raw_eater.pyx $(CYT)raw_eater.pxd $(LIB)raweat.hpp \
|
# py-install: $(CYT)setup_raw_eater.py $(CYT)raw_eater.pyx $(CYT)raw_eater.pxd $(LIB)raweat.hpp \
|
||||||
$(CYT)setup_raw_meat.py $(CYT)raw_meat.pyx $(CYT)raw_meat.pxd $(LIB)rawmerge.hpp
|
# $(CYT)setup_raw_meat.py $(CYT)raw_meat.pyx $(CYT)raw_meat.pxd $(LIB)rawmerge.hpp
|
||||||
python3 $(CYT)setup_raw_eater.py install --record files_raw_eater.txt
|
# python3 $(CYT)setup_raw_eater.py install --record files_raw_eater.txt
|
||||||
python3 $(CYT)setup_raw_meat.py install --record files_raw_meat.txt
|
# python3 $(CYT)setup_raw_meat.py install --record files_raw_meat.txt
|
||||||
|
#
|
||||||
py-clean :
|
# py-clean :
|
||||||
rm -f raw_eater.cpython-*.so
|
# rm -f raw_eater.cpython-*.so
|
||||||
rm -f pyt/raw_eater.cpython-*.so
|
# rm -f pyt/raw_eater.cpython-*.so
|
||||||
rm -f $(CYT)raw_eater.cpp
|
# rm -f $(CYT)raw_eater.cpp
|
||||||
rm -f raw_meat.cpython-*.so
|
# rm -f raw_meat.cpython-*.so
|
||||||
rm -f pyt/raw_meat.cpython-*.so
|
# rm -f pyt/raw_meat.cpython-*.so
|
||||||
rm -f $(CYT)raw_meat.cpp
|
# rm -f $(CYT)raw_meat.cpp
|
||||||
rm -rf build/
|
# rm -rf build/
|
||||||
rm -f *.txt
|
# rm -f *.txt
|
||||||
rm -rf output/
|
# rm -rf output/
|
||||||
|
#
|
||||||
# prepare directory for test output
|
# # prepare directory for test output
|
||||||
output :
|
# output :
|
||||||
mkdir -pv output/
|
# mkdir -pv output/
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------#
|
#-----------------------------------------------------------------------------#
|
||||||
|
92
makefile-old
Normal file
92
makefile-old
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
#-----------------------------------------------------------------------------#
|
||||||
|
|
||||||
|
# choose shell
|
||||||
|
SHELL:=/bin/bash
|
||||||
|
|
||||||
|
RAW = ../raw/
|
||||||
|
|
||||||
|
# directory names
|
||||||
|
SRC = src/
|
||||||
|
LIB = lib/
|
||||||
|
CYT = cyt/
|
||||||
|
|
||||||
|
# name of executable
|
||||||
|
EXE = eatraw
|
||||||
|
|
||||||
|
# compiler and its options
|
||||||
|
CCC = g++ -std=c++11
|
||||||
|
#OPT = -O3 -Wall -mavx -mno-tbm -mf16c -mno-f16c
|
||||||
|
OPT = -O3 -Wall -Werror
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------#
|
||||||
|
# C++
|
||||||
|
|
||||||
|
# build executable
|
||||||
|
$(EXE) : $(SRC)main.cpp $(LIB)raweat.hpp $(LIB)hexshow.hpp $(LIB)rawmerge.hpp output
|
||||||
|
$(CCC) $(OPT) $< -o $@
|
||||||
|
|
||||||
|
# development version
|
||||||
|
eatdev : $(SRC)main_dev.cpp $(LIB)raweat.hpp
|
||||||
|
$(CCC) $(OPT) $< -o $@
|
||||||
|
|
||||||
|
# build target for conversion set of .raw files
|
||||||
|
eatall : $(SRC)eatall.cpp $(LIB)raweat.hpp
|
||||||
|
$(CCC) $(OPT) $< -o $@
|
||||||
|
|
||||||
|
# remove executable
|
||||||
|
clean :
|
||||||
|
rm -f $(EXE)
|
||||||
|
rm -f eatall
|
||||||
|
rm -f eatdev
|
||||||
|
rm -rf output/
|
||||||
|
|
||||||
|
# check existence of name of executable globally
|
||||||
|
chexe:=$(shell command -v $(EXE))
|
||||||
|
|
||||||
|
# install executable if name does not exist yet
|
||||||
|
install : $(EXE)
|
||||||
|
ifeq ($(chexe),)
|
||||||
|
cp $(EXE) /usr/local/bin/
|
||||||
|
else
|
||||||
|
@echo "executable with name already exists! choose different name!"
|
||||||
|
@exit 1
|
||||||
|
endif
|
||||||
|
|
||||||
|
# uninstall
|
||||||
|
uninstall :
|
||||||
|
rm /usr/local/bin/$(EXE)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------#
|
||||||
|
# Python
|
||||||
|
|
||||||
|
# build python module
|
||||||
|
py : $(CYT)setup_raw_eater.py $(CYT)raw_eater.pyx $(CYT)raw_eater.pxd $(LIB)raweat.hpp \
|
||||||
|
$(CYT)setup_raw_meat.py $(CYT)raw_meat.pyx $(CYT)raw_meat.pxd $(LIB)rawmerge.hpp \
|
||||||
|
output
|
||||||
|
python3 $(CYT)setup_raw_eater.py build_ext --inplace
|
||||||
|
python3 $(CYT)setup_raw_meat.py build_ext --inplace
|
||||||
|
cp raw_eater.cpython-*.so pyt/
|
||||||
|
cp raw_meat.cpython-*.so pyt/
|
||||||
|
rm *.so
|
||||||
|
|
||||||
|
py-install: $(CYT)setup_raw_eater.py $(CYT)raw_eater.pyx $(CYT)raw_eater.pxd $(LIB)raweat.hpp \
|
||||||
|
$(CYT)setup_raw_meat.py $(CYT)raw_meat.pyx $(CYT)raw_meat.pxd $(LIB)rawmerge.hpp
|
||||||
|
python3 $(CYT)setup_raw_eater.py install --record files_raw_eater.txt
|
||||||
|
python3 $(CYT)setup_raw_meat.py install --record files_raw_meat.txt
|
||||||
|
|
||||||
|
py-clean :
|
||||||
|
rm -f raw_eater.cpython-*.so
|
||||||
|
rm -f pyt/raw_eater.cpython-*.so
|
||||||
|
rm -f $(CYT)raw_eater.cpp
|
||||||
|
rm -f raw_meat.cpython-*.so
|
||||||
|
rm -f pyt/raw_meat.cpython-*.so
|
||||||
|
rm -f $(CYT)raw_meat.cpp
|
||||||
|
rm -rf build/
|
||||||
|
rm -f *.txt
|
||||||
|
rm -rf output/
|
||||||
|
|
||||||
|
# prepare directory for test output
|
||||||
|
output :
|
||||||
|
mkdir -pv output/
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------#
|
112
newmakefile
112
newmakefile
@ -1,112 +0,0 @@
|
|||||||
#-----------------------------------------------------------------------------#
|
|
||||||
|
|
||||||
# name of executable and CLI tool
|
|
||||||
EXE = imctermite
|
|
||||||
|
|
||||||
# directory names
|
|
||||||
SRC = src/
|
|
||||||
LIB = lib/
|
|
||||||
CYT = cyt/
|
|
||||||
|
|
||||||
# list headers
|
|
||||||
HPP = $(wildcard $(LIB)/*.hpp)
|
|
||||||
|
|
||||||
# choose compiler and its options
|
|
||||||
CC = g++ -std=c++17
|
|
||||||
#OPT = -O3 -Wall -mavx -mno-tbm -mf16c -mno-f16c
|
|
||||||
OPT = -O3 -Wall -Werror -Wunused-variable -Wsign-compare
|
|
||||||
|
|
||||||
# determine git version/commit tag
|
|
||||||
GTAG := $(shell git tag | tail -n1)
|
|
||||||
GHSH := $(shell git rev-parse HEAD | head -c8)
|
|
||||||
|
|
||||||
# define install location
|
|
||||||
INST := /usr/local/bin
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------#
|
|
||||||
# C++ and CLI tool
|
|
||||||
|
|
||||||
# build exectuable
|
|
||||||
$(EXE) : main.o
|
|
||||||
$(CC) $(OPT) $^ -o $@
|
|
||||||
|
|
||||||
# build main.cpp and include git version/commit tag
|
|
||||||
main.o : src/main.cpp $(HPP)
|
|
||||||
@cp $< $<.cpp
|
|
||||||
@sed -i 's/TAGSTRING/$(GTAG)/g' $<.cpp
|
|
||||||
@sed -i 's/HASHSTRING/$(GHSH)/g' $<.cpp
|
|
||||||
$(CC) -c $(OPT) -I $(LIB) $<.cpp -o $@
|
|
||||||
@rm $<.cpp
|
|
||||||
|
|
||||||
install : $(EXE)
|
|
||||||
cp $< $(INST)/
|
|
||||||
|
|
||||||
uninstall : $(INST)/$(EXE)
|
|
||||||
rm $<
|
|
||||||
|
|
||||||
clean :
|
|
||||||
rm -vf $(EXE)
|
|
||||||
rm -v *.o
|
|
||||||
|
|
||||||
# # build CLI executable
|
|
||||||
# $(EXE) : $(SRC)main.cpp $(LIB)raweat.hpp $(LIB)hexshow.hpp $(LIB)rawmerge.hpp output
|
|
||||||
# $(CCC) $(OPT) $< -o $@
|
|
||||||
|
|
||||||
# # development version
|
|
||||||
# eatdev : $(SRC)main_dev.cpp $(LIB)raweat.hpp
|
|
||||||
# $(CCC) $(OPT) $< -o $@
|
|
||||||
#
|
|
||||||
# # build target for conversion set of .raw files
|
|
||||||
# eatall : $(SRC)eatall.cpp $(LIB)raweat.hpp
|
|
||||||
# $(CCC) $(OPT) $< -o $@
|
|
||||||
|
|
||||||
# check existence of name of executable globally
|
|
||||||
# chexe:=$(shell command -v $(EXE))
|
|
||||||
#
|
|
||||||
# # install executable if name does not exist yet
|
|
||||||
# install : $(EXE)
|
|
||||||
# ifeq ($(chexe),)
|
|
||||||
# cp $(EXE) /usr/local/bin/
|
|
||||||
# else
|
|
||||||
# @echo "executable with name already exists! choose different name!"
|
|
||||||
# @exit 1
|
|
||||||
# endif
|
|
||||||
|
|
||||||
# # uninstall
|
|
||||||
# uninstall :
|
|
||||||
# rm /usr/local/bin/$(EXE)
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------#
|
|
||||||
# Python
|
|
||||||
#
|
|
||||||
# # build python module
|
|
||||||
# py : $(CYT)setup_raw_eater.py $(CYT)raw_eater.pyx $(CYT)raw_eater.pxd $(LIB)raweat.hpp \
|
|
||||||
# $(CYT)setup_raw_meat.py $(CYT)raw_meat.pyx $(CYT)raw_meat.pxd $(LIB)rawmerge.hpp \
|
|
||||||
# output
|
|
||||||
# python3 $(CYT)setup_raw_eater.py build_ext --inplace
|
|
||||||
# python3 $(CYT)setup_raw_meat.py build_ext --inplace
|
|
||||||
# cp raw_eater.cpython-*.so pyt/
|
|
||||||
# cp raw_meat.cpython-*.so pyt/
|
|
||||||
# rm *.so
|
|
||||||
#
|
|
||||||
# py-install: $(CYT)setup_raw_eater.py $(CYT)raw_eater.pyx $(CYT)raw_eater.pxd $(LIB)raweat.hpp \
|
|
||||||
# $(CYT)setup_raw_meat.py $(CYT)raw_meat.pyx $(CYT)raw_meat.pxd $(LIB)rawmerge.hpp
|
|
||||||
# python3 $(CYT)setup_raw_eater.py install --record files_raw_eater.txt
|
|
||||||
# python3 $(CYT)setup_raw_meat.py install --record files_raw_meat.txt
|
|
||||||
#
|
|
||||||
# py-clean :
|
|
||||||
# rm -f raw_eater.cpython-*.so
|
|
||||||
# rm -f pyt/raw_eater.cpython-*.so
|
|
||||||
# rm -f $(CYT)raw_eater.cpp
|
|
||||||
# rm -f raw_meat.cpython-*.so
|
|
||||||
# rm -f pyt/raw_meat.cpython-*.so
|
|
||||||
# rm -f $(CYT)raw_meat.cpp
|
|
||||||
# rm -rf build/
|
|
||||||
# rm -f *.txt
|
|
||||||
# rm -rf output/
|
|
||||||
#
|
|
||||||
# # prepare directory for test output
|
|
||||||
# output :
|
|
||||||
# mkdir -pv output/
|
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------#
|
|
92
src/main-old.cpp
Normal file
92
src/main-old.cpp
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
//---------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
#include <iomanip>
|
||||||
|
#include <iostream>
|
||||||
|
#include "../lib/raweat.hpp"
|
||||||
|
#include "../lib/rawmerge.hpp"
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
int main(int argc, char* argv[])
|
||||||
|
{
|
||||||
|
|
||||||
|
if ( argc != 3 ) //or ( argc == 1 && std::string(argv[1]) == str::string("--help") )
|
||||||
|
{
|
||||||
|
std::cout<<"\n"<<"Usage: ./eatit INPUTFILE OUTPUTFILE"<<"\n"
|
||||||
|
<<"Convert any file in imc-format .raw to plain text .csv"<<"\n"
|
||||||
|
<<"Example: ./eatit Druck_THZ_DK.raw druck_thz_dk.csv"<<"\n\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get name/path of file from CLI argument
|
||||||
|
std::string rawfile(argv[1]);
|
||||||
|
|
||||||
|
// declare instance of 'raw_eater' (and decode data)
|
||||||
|
raw_eater eatraw; //rawfile,false);
|
||||||
|
|
||||||
|
// set file to be decoded
|
||||||
|
eatraw.set_file(rawfile,true);
|
||||||
|
|
||||||
|
// do conversion
|
||||||
|
eatraw.setup_and_conversion(false);
|
||||||
|
|
||||||
|
// eatraw.show_markers();
|
||||||
|
|
||||||
|
// std::cout<<"\n";
|
||||||
|
// std::map<std::string,std::vector<unsigned char>> marks = eatraw.get_markers();
|
||||||
|
// for ( auto mrk: marks )
|
||||||
|
// {
|
||||||
|
// // get data
|
||||||
|
// std::vector<unsigned char> dat = eatraw.get_marker_data(mrk.first);
|
||||||
|
//
|
||||||
|
// // print marker name, length and data
|
||||||
|
// std::cout<<mrk.first<<" : "<<dat.size()<<'\n';
|
||||||
|
// std::cout<<std::setfill('-')<<std::setw(96)<<'\n'<<std::setfill(' ');
|
||||||
|
// eatraw.show_hex(dat,32,512);
|
||||||
|
// std::cout<<"\n";
|
||||||
|
//
|
||||||
|
// std::vector<std::string> segvec = eatraw.get_segment(mrk.first);
|
||||||
|
// std::cout<<"number of elements in segment: "<<segvec.size()<<"\n\n";
|
||||||
|
// //for ( auto el: segvec ) std::cout<<el<<"\n";
|
||||||
|
// }
|
||||||
|
|
||||||
|
// get array of encoded data
|
||||||
|
// std::vector<double> maindata = eatraw.get_data();
|
||||||
|
// std::cout<<"\nsize of data array: "<<maindata.size()<<"\n\n";
|
||||||
|
// for ( unsigned long int i = 0; i < 10; i++ ) std::cout<<mydata[i]<<"\n";
|
||||||
|
|
||||||
|
// write data in csv-file
|
||||||
|
if ( eatraw.get_valid() )
|
||||||
|
{
|
||||||
|
eatraw.write_table(std::string(argv[2]),' ');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout<<"=> invalid/corrupt .raw file\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
// declare instance of 'raw_merger'
|
||||||
|
raw_merger eatmea;
|
||||||
|
|
||||||
|
// add channels
|
||||||
|
eatmea.add_channel(rawfile,false);
|
||||||
|
eatmea.add_channel("smp/VehicleSpeed_HS.raw",false);
|
||||||
|
// eatmea.add_channel("smp/Mercedes_E-Klasse-2019-08-08/Flex_StWhl_AnglSpd.raw",false);
|
||||||
|
// eatmea.add_channel("smp/Rangerover_Evoque_F-RR534_2019-05-07/Temp_Disc_FR.raw",false);
|
||||||
|
|
||||||
|
// write merged table
|
||||||
|
if ( eatmea.get_num_channels() > 0 )
|
||||||
|
{
|
||||||
|
eatmea.write_table_all("output/allchannels.csv",' ');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::cout<<"no valid channel added\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------//
|
239
src/main.cpp
239
src/main.cpp
@ -1,90 +1,191 @@
|
|||||||
//---------------------------------------------------------------------------//
|
//---------------------------------------------------------------------------//
|
||||||
|
|
||||||
#include <iomanip>
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "../lib/raweat.hpp"
|
#include <filesystem>
|
||||||
#include "../lib/rawmerge.hpp"
|
|
||||||
|
#include "imc_key.hpp"
|
||||||
|
#include "imc_block.hpp"
|
||||||
|
#include "imc_raw.hpp"
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
const std::string gittag("TAGSTRING");
|
||||||
|
const std::string githash("HASHSTRING");
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
// define type of key-value map object
|
||||||
|
typedef std::map<std::string,std::string> optkeys;
|
||||||
|
|
||||||
|
optkeys parse_args(int argc, char* argv[], bool list_args = false)
|
||||||
|
{
|
||||||
|
if ( list_args )
|
||||||
|
{
|
||||||
|
std::cout<<"number of CLI-arguments: "<<argc<<"\n";
|
||||||
|
for ( int i = 0; i < argc; i++ ) std::cout<<i<<": "<<argv[i]<<"\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
// declare empty key-value object
|
||||||
|
optkeys prsdkeys;
|
||||||
|
|
||||||
|
// parse all CLI arguments
|
||||||
|
for ( int i = 1; i < argc; i++ )
|
||||||
|
{
|
||||||
|
if ( std::string(argv[i]) == std::string("--showmeta")
|
||||||
|
|| std::string(argv[i]) == std::string("-m") )
|
||||||
|
{
|
||||||
|
prsdkeys.insert(std::pair<std::string,std::string>("showmeta",argv[i]));
|
||||||
|
}
|
||||||
|
else if ( std::string(argv[i]) == std::string("--listgroups")
|
||||||
|
|| std::string(argv[i]) == std::string("-g") )
|
||||||
|
{
|
||||||
|
prsdkeys.insert(std::pair<std::string,std::string>("listgroups",argv[i]));
|
||||||
|
}
|
||||||
|
else if ( std::string(argv[i]) == std::string("--listchannels")
|
||||||
|
|| std::string(argv[i]) == std::string("-c") )
|
||||||
|
{
|
||||||
|
prsdkeys.insert(std::pair<std::string,std::string>("listchannels",argv[i]));
|
||||||
|
}
|
||||||
|
else if ( std::string(argv[i]) == std::string("--listblocks")
|
||||||
|
|| std::string(argv[i]) == std::string("-b") )
|
||||||
|
{
|
||||||
|
prsdkeys.insert(std::pair<std::string,std::string>("listblocks",argv[i]));
|
||||||
|
}
|
||||||
|
else if ( std::string(argv[i]) == std::string("--filename")
|
||||||
|
|| std::string(argv[i]) == std::string("-f") )
|
||||||
|
{
|
||||||
|
if ( i+1 == argc || argv[i+1][0] == '-' )
|
||||||
|
{
|
||||||
|
std::cerr<<"invalid or missing --filename argument\n";
|
||||||
|
prsdkeys.insert(std::pair<std::string,std::string>("invalid","filename"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prsdkeys.insert(std::pair<std::string,std::string>("filename",argv[i+1]));
|
||||||
|
i = i + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ( std::string(argv[i]) == std::string("--help")
|
||||||
|
|| std::string(argv[i]) == std::string("-h") )
|
||||||
|
{
|
||||||
|
prsdkeys.insert(std::pair<std::string,std::string>("help",argv[i]));
|
||||||
|
}
|
||||||
|
else if ( std::string(argv[i]) == std::string("--version")
|
||||||
|
|| std::string(argv[i]) == std::string("-v") )
|
||||||
|
{
|
||||||
|
prsdkeys.insert(std::pair<std::string,std::string>("version",argv[i]));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// check for invalid arguments
|
||||||
|
if ( argv[i][0] == '-' )
|
||||||
|
{
|
||||||
|
std::cerr<<"invalid or unkown argument: "<<argv[i]<<"\n";
|
||||||
|
prsdkeys.insert(std::pair<std::string,std::string>("invalid",argv[i]));
|
||||||
|
}
|
||||||
|
// or missing filenames
|
||||||
|
else if ( std::string(argv[i]).find(".raw") == std::string::npos )
|
||||||
|
{
|
||||||
|
std::cerr<<"doesn't look like a .raw file (make sure to include extension in filename!): "
|
||||||
|
<<argv[i]<<"\n";
|
||||||
|
prsdkeys.insert(std::pair<std::string,std::string>("invalid",argv[i]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return prsdkeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------//
|
||||||
|
|
||||||
|
void show_version()
|
||||||
|
{
|
||||||
|
std::cout<<"imctermite ["<<gittag<<"-g"<<githash<<"]"<<"\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
void show_usage()
|
||||||
|
{
|
||||||
|
std::cout<<"\n"
|
||||||
|
<<"imctermite ["<<gittag<<"-g"<<githash<<"] (github.com/RecordEvolution/IMCtermite.git)"
|
||||||
|
<<"\n\n"
|
||||||
|
<<"Decode IMC raw files and dump data as *.csv"
|
||||||
|
<<"\n\n"
|
||||||
|
<<"Usage:\n\n"
|
||||||
|
<<" imctermite <raw-file> [options]"
|
||||||
|
<<"\n\n"
|
||||||
|
<<"Options:"
|
||||||
|
<<"\n\n"
|
||||||
|
<<" -m, --showmeta show meta information about IMC dataset\n"
|
||||||
|
<<" -g, --listgroups list channelgroups\n"
|
||||||
|
<<" -c, --listchannels list channels\n"
|
||||||
|
<<" -b, --listblocks list IMC key-blocks\n"
|
||||||
|
<<" -f, --filename filename for csv output\n"
|
||||||
|
<<" -h, --help show this help message \n"
|
||||||
|
<<" -v, --version display version\n"
|
||||||
|
<<"\n";
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------//
|
//---------------------------------------------------------------------------//
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
// parse CLI arguments
|
||||||
|
optkeys cfgopts = parse_args(argc,argv);
|
||||||
|
|
||||||
if ( argc != 3 ) //or ( argc == 1 && std::string(argv[1]) == str::string("--help") )
|
// exit on any invalid arguments
|
||||||
|
if ( cfgopts.count("invalid") > 0 ) return 1;
|
||||||
|
|
||||||
|
if ( cfgopts.count("version") == 1 )
|
||||||
{
|
{
|
||||||
std::cout<<"\n"<<"Usage: ./eatit INPUTFILE OUTPUTFILE"<<"\n"
|
show_version();
|
||||||
<<"Convert any file in imc-format .raw to plain text .csv"<<"\n"
|
}
|
||||||
<<"Example: ./eatit Druck_THZ_DK.raw druck_thz_dk.csv"<<"\n\n";
|
else if ( cfgopts.count("help") == 1 )
|
||||||
return 0;
|
{
|
||||||
|
show_usage();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// check for at least one file argument
|
||||||
|
if ( cfgopts.size() == (unsigned int)argc-1 )
|
||||||
|
{
|
||||||
|
std::cerr<<"no .raw file given => check --help for usage\n";
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get name/path of file from CLI argument
|
|
||||||
std::string rawfile(argv[1]);
|
std::string rawfile(argv[1]);
|
||||||
|
|
||||||
// declare instance of 'raw_eater' (and decode data)
|
// check existence of file
|
||||||
raw_eater eatraw; //rawfile,false);
|
std::filesystem::path rawpath = rawfile;
|
||||||
|
if ( !std::filesystem::exists(rawpath) )
|
||||||
|
{
|
||||||
|
std::cerr<<"file does not exist: "<<rawfile<<"\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// set file to be decoded
|
// initialize "imc::raw" instance
|
||||||
eatraw.set_file(rawfile,true);
|
imc::raw imcraw;
|
||||||
|
try {
|
||||||
|
imcraw.set_file(rawfile);
|
||||||
|
} catch (const std::exception& e ) {
|
||||||
|
std::cerr<<"failed to set raw-file: "<<e.what()<<"\n";
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// do conversion
|
// list blocks
|
||||||
eatraw.setup_and_conversion(false);
|
for ( imc::block blk: imcraw.blocks() )
|
||||||
|
{
|
||||||
|
std::cout<<blk.get_info()<<"\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// eatraw.show_markers();
|
// for ( std::map<std::string,imc::key>::iterator it = imc::keys.begin();
|
||||||
|
// it != imc::keys.end(); ++it )
|
||||||
// std::cout<<"\n";
|
|
||||||
// std::map<std::string,std::vector<unsigned char>> marks = eatraw.get_markers();
|
|
||||||
// for ( auto mrk: marks )
|
|
||||||
// {
|
// {
|
||||||
// // get data
|
// std::cout<<it->second.get_info()<<"\n";
|
||||||
// std::vector<unsigned char> dat = eatraw.get_marker_data(mrk.first);
|
|
||||||
//
|
|
||||||
// // print marker name, length and data
|
|
||||||
// std::cout<<mrk.first<<" : "<<dat.size()<<'\n';
|
|
||||||
// std::cout<<std::setfill('-')<<std::setw(96)<<'\n'<<std::setfill(' ');
|
|
||||||
// eatraw.show_hex(dat,32,512);
|
|
||||||
// std::cout<<"\n";
|
|
||||||
//
|
|
||||||
// std::vector<std::string> segvec = eatraw.get_segment(mrk.first);
|
|
||||||
// std::cout<<"number of elements in segment: "<<segvec.size()<<"\n\n";
|
|
||||||
// //for ( auto el: segvec ) std::cout<<el<<"\n";
|
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
// get array of encoded data
|
// std::vector<unsigned char> buff;
|
||||||
// std::vector<double> maindata = eatraw.get_data();
|
// imc::block blk(imc::keys.at("CF"),0,100,"data.raw",&buff);
|
||||||
// std::cout<<"\nsize of data array: "<<maindata.size()<<"\n\n";
|
// std::cout<<blk.get_info()<<"\n";
|
||||||
// for ( unsigned long int i = 0; i < 10; i++ ) std::cout<<mydata[i]<<"\n";
|
|
||||||
|
|
||||||
// write data in csv-file
|
|
||||||
if ( eatraw.get_valid() )
|
|
||||||
{
|
|
||||||
eatraw.write_table(std::string(argv[2]),' ');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cout<<"=> invalid/corrupt .raw file\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------//
|
|
||||||
|
|
||||||
// declare instance of 'raw_merger'
|
|
||||||
raw_merger eatmea;
|
|
||||||
|
|
||||||
// add channels
|
|
||||||
eatmea.add_channel(rawfile,false);
|
|
||||||
eatmea.add_channel("smp/VehicleSpeed_HS.raw",false);
|
|
||||||
// eatmea.add_channel("smp/Mercedes_E-Klasse-2019-08-08/Flex_StWhl_AnglSpd.raw",false);
|
|
||||||
// eatmea.add_channel("smp/Rangerover_Evoque_F-RR534_2019-05-07/Temp_Disc_FR.raw",false);
|
|
||||||
|
|
||||||
// write merged table
|
|
||||||
if ( eatmea.get_num_channels() > 0 )
|
|
||||||
{
|
|
||||||
eatmea.write_table_all("output/allchannels.csv",' ');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
std::cout<<"no valid channel added\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
193
src/newmain.cpp
193
src/newmain.cpp
@ -1,193 +0,0 @@
|
|||||||
//---------------------------------------------------------------------------//
|
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
#include <filesystem>
|
|
||||||
|
|
||||||
#include "imc_key.hpp"
|
|
||||||
#include "imc_block.hpp"
|
|
||||||
#include "imc_raw.hpp"
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------//
|
|
||||||
|
|
||||||
const std::string gittag("TAGSTRING");
|
|
||||||
const std::string githash("HASHSTRING");
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------//
|
|
||||||
|
|
||||||
// define type of key-value map object
|
|
||||||
typedef std::map<std::string,std::string> optkeys;
|
|
||||||
|
|
||||||
optkeys parse_args(int argc, char* argv[], bool list_args = false)
|
|
||||||
{
|
|
||||||
if ( list_args )
|
|
||||||
{
|
|
||||||
std::cout<<"number of CLI-arguments: "<<argc<<"\n";
|
|
||||||
for ( int i = 0; i < argc; i++ ) std::cout<<i<<": "<<argv[i]<<"\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// declare empty key-value object
|
|
||||||
optkeys prsdkeys;
|
|
||||||
|
|
||||||
// parse all CLI arguments
|
|
||||||
for ( int i = 1; i < argc; i++ )
|
|
||||||
{
|
|
||||||
if ( std::string(argv[i]) == std::string("--showmeta")
|
|
||||||
|| std::string(argv[i]) == std::string("-m") )
|
|
||||||
{
|
|
||||||
prsdkeys.insert(std::pair<std::string,std::string>("showmeta",argv[i]));
|
|
||||||
}
|
|
||||||
else if ( std::string(argv[i]) == std::string("--listgroups")
|
|
||||||
|| std::string(argv[i]) == std::string("-g") )
|
|
||||||
{
|
|
||||||
prsdkeys.insert(std::pair<std::string,std::string>("listgroups",argv[i]));
|
|
||||||
}
|
|
||||||
else if ( std::string(argv[i]) == std::string("--listchannels")
|
|
||||||
|| std::string(argv[i]) == std::string("-c") )
|
|
||||||
{
|
|
||||||
prsdkeys.insert(std::pair<std::string,std::string>("listchannels",argv[i]));
|
|
||||||
}
|
|
||||||
else if ( std::string(argv[i]) == std::string("--listblocks")
|
|
||||||
|| std::string(argv[i]) == std::string("-b") )
|
|
||||||
{
|
|
||||||
prsdkeys.insert(std::pair<std::string,std::string>("listblocks",argv[i]));
|
|
||||||
}
|
|
||||||
else if ( std::string(argv[i]) == std::string("--filename")
|
|
||||||
|| std::string(argv[i]) == std::string("-f") )
|
|
||||||
{
|
|
||||||
if ( i+1 == argc || argv[i+1][0] == '-' )
|
|
||||||
{
|
|
||||||
std::cerr<<"invalid or missing --filename argument\n";
|
|
||||||
prsdkeys.insert(std::pair<std::string,std::string>("invalid","filename"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
prsdkeys.insert(std::pair<std::string,std::string>("filename",argv[i+1]));
|
|
||||||
i = i + 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if ( std::string(argv[i]) == std::string("--help")
|
|
||||||
|| std::string(argv[i]) == std::string("-h") )
|
|
||||||
{
|
|
||||||
prsdkeys.insert(std::pair<std::string,std::string>("help",argv[i]));
|
|
||||||
}
|
|
||||||
else if ( std::string(argv[i]) == std::string("--version")
|
|
||||||
|| std::string(argv[i]) == std::string("-v") )
|
|
||||||
{
|
|
||||||
prsdkeys.insert(std::pair<std::string,std::string>("version",argv[i]));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// check for invalid arguments
|
|
||||||
if ( argv[i][0] == '-' )
|
|
||||||
{
|
|
||||||
std::cerr<<"invalid or unkown argument: "<<argv[i]<<"\n";
|
|
||||||
prsdkeys.insert(std::pair<std::string,std::string>("invalid",argv[i]));
|
|
||||||
}
|
|
||||||
// or missing filenames
|
|
||||||
else if ( std::string(argv[i]).find(".raw") == std::string::npos )
|
|
||||||
{
|
|
||||||
std::cerr<<"doesn't look like a .raw file (make sure to include extension in filename!): "
|
|
||||||
<<argv[i]<<"\n";
|
|
||||||
prsdkeys.insert(std::pair<std::string,std::string>("invalid",argv[i]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return prsdkeys;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------//
|
|
||||||
|
|
||||||
void show_version()
|
|
||||||
{
|
|
||||||
std::cout<<"imctermite ["<<gittag<<"-g"<<githash<<"]"<<"\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
void show_usage()
|
|
||||||
{
|
|
||||||
std::cout<<"\n"
|
|
||||||
<<"imctermite ["<<gittag<<"-g"<<githash<<"] (github.com/RecordEvolution/IMCtermite.git)"
|
|
||||||
<<"\n\n"
|
|
||||||
<<"Decode IMC raw files and dump data as *.csv"
|
|
||||||
<<"\n\n"
|
|
||||||
<<"Usage:\n\n"
|
|
||||||
<<" imctermite <raw-file> [options]"
|
|
||||||
<<"\n\n"
|
|
||||||
<<"Options:"
|
|
||||||
<<"\n\n"
|
|
||||||
<<" -m, --showmeta show meta information about IMC dataset\n"
|
|
||||||
<<" -g, --listgroups list channelgroups\n"
|
|
||||||
<<" -c, --listchannels list channels\n"
|
|
||||||
<<" -b, --listblocks list IMC key-blocks\n"
|
|
||||||
<<"- f, --filename filename for csv output\n"
|
|
||||||
<<" -h, --help show this help message \n"
|
|
||||||
<<" -v, --version display version\n"
|
|
||||||
<<"\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------//
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
|
||||||
{
|
|
||||||
// parse CLI arguments
|
|
||||||
optkeys cfgopts = parse_args(argc,argv);
|
|
||||||
|
|
||||||
// exit on any invalid arguments
|
|
||||||
if ( cfgopts.count("invalid") > 0 ) return 1;
|
|
||||||
|
|
||||||
if ( cfgopts.count("version") == 1 )
|
|
||||||
{
|
|
||||||
show_version();
|
|
||||||
}
|
|
||||||
else if ( cfgopts.count("help") == 1 )
|
|
||||||
{
|
|
||||||
show_usage();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// check for at least one file argument
|
|
||||||
if ( cfgopts.size() == (unsigned int)argc-1 )
|
|
||||||
{
|
|
||||||
std::cerr<<"no .raw file given => check --help for usage\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
std::string rawfile(argv[1]);
|
|
||||||
|
|
||||||
// check existence of file
|
|
||||||
std::filesystem::path rawpath = rawfile;
|
|
||||||
if ( !std::filesystem::exists(rawpath) )
|
|
||||||
{
|
|
||||||
std::cerr<<"file does not exist: "<<rawfile<<"\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// initialize "imc::raw" instance
|
|
||||||
imc::raw imcraw;
|
|
||||||
try {
|
|
||||||
imcraw.set_file(rawfile);
|
|
||||||
} catch (const std::exception& e ) {
|
|
||||||
std::cerr<<"failed to open and parse raw-file: "<<e.what()<<"\n";
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// list blocks
|
|
||||||
for ( imc::block blk: imcraw.blocks() )
|
|
||||||
{
|
|
||||||
std::cout<<blk.get_info()<<"\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// for ( std::map<std::string,imc::key>::iterator it = imc::keys.begin();
|
|
||||||
// it != imc::keys.end(); ++it )
|
|
||||||
// {
|
|
||||||
// std::cout<<it->second.get_info()<<"\n";
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// std::vector<unsigned char> buff;
|
|
||||||
// imc::block blk(imc::keys.at("CF"),0,100,"data.raw",&buff);
|
|
||||||
// std::cout<<blk.get_info()<<"\n";
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------//
|
|
Loading…
x
Reference in New Issue
Block a user