Skip to content

Commit

Permalink
* Moved nsx header-writing code into its own file. Not sure this was …
Browse files Browse the repository at this point in the history
…a great idea, may move it back

* Updated matlab helper functions.
* Removed vestigial code from when SystemTime was in NSxHeader. Same code is now in systemtime.h
  • Loading branch information
mrkrause committed Jan 16, 2019
1 parent cbeea4d commit c5a52bc
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 50 deletions.
4 changes: 3 additions & 1 deletion MatFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ MATFile::MATFile(const std::string& _filename, const std::string& _mode) {
}

MATFile::~MATFile() {
MW::matClose(mfp);
if(mode) {
MW::matClose(mfp);
}
}

void MATFile::close() {
Expand Down
13 changes: 3 additions & 10 deletions MatFile.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
//
// MatFile.h
//
//
// Created by Matthew Krause on 6/16/15.
//
//

#ifndef ____MatFile__
#define ____MatFile__
#pragma once
#ifndef MATFILE_H_INCLUDED
#define MATFILE_H_INCLUDED

#include <iostream>
#include <string>
Expand Down
12 changes: 0 additions & 12 deletions NSxHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,6 @@ std::ostream& operator<<(std::ostream& out, const NSxHeader& h) // output
return out;
}

std::ostream& operator<<(std::ostream& out, const SystemTime& t) {
out << t.year << '-' << t.month << '-' << t.day << ' ' << t.hour << ':' << t.minute << ':' << t.second << '.' << t.millisecond;
return out;
}

std::string SystemTime::str() {
std::ostringstream s;

s << *this;
return(s.str());

}

double NSxHeader::getSamplingFreq() const {
return double(timeResolution)/double(samplingPeriod);
Expand Down
4 changes: 2 additions & 2 deletions nsx2mat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
//

#include "NSxFile.h"
#include "Config.h"
#include "NSxConfig.h"

MW::mxArray* filterToMxArray(const Filter &f);


void NSxFile::writeMatHeader(const Config& config) {
void NSxFile::writeMatHeader(const NSxConfig& config) {

MATFile m(config.matlabHeaderFilename(), "wz");

Expand Down
14 changes: 14 additions & 0 deletions nsx2mat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// nsx2mat.h
//
//
// Created by Matthew Krause on 6/22/15.
//
//

#ifndef ____nsx2mat__
#define ____nsx2mat__

#include <stdio.h>

#endif /* defined(____nsx2mat__) */
6 changes: 3 additions & 3 deletions nsx2txt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
//
//
#include "NSxFile.h"
#include "Config.h"
#include "NSxConfig.h"
#include <fstream>

void NSxFile::writeTxtHeader(const Config& config) {
void NSxFile::writeTxtHeader(const NSxConfig& config) {

std::string filename = config.textHeaderFilename();
std::ofstream txtfile(filename, std::ofstream::out | std::ofstream::trunc);
Expand Down Expand Up @@ -47,4 +47,4 @@ void NSxFile::writeTxtHeader(const Config& config) {

}

}
}
8 changes: 0 additions & 8 deletions typeHelper.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
//
// typeHelper.cpp
//
//
// Created by Matthew Krause on 6/21/15.
//
//

#include "typeHelper.h"


Expand Down
22 changes: 8 additions & 14 deletions typeHelper.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
//
// typeHelper.h
//
//
// Created by Matthew Krause on 6/21/15.
//
//

#ifndef _typeHelper_h
#define _typeHelper_h
#pragma once
#ifndef TYPEHELPER_H_INCLUDED
#define TYPEHELPER_H_INCLUDED

#include <typeinfo>
#include <string>
Expand All @@ -16,10 +9,11 @@
#include <iostream>
#include <cstdint>


namespace MW {
// These are the original header files from the MathWorks.
#include "mat.h"
#include "matrix.h"
// These are the original header files from the MathWorks.
#include "mat.h"
#include "matrix.h"
};


Expand All @@ -31,7 +25,7 @@ MW::mxClassID typeHelper() {
}

template <>
MW::mxClassID typeHelper<std::uint8_t>();
MW::mxClassID typeHelper<std::uint8_t>();

template <>
MW::mxClassID typeHelper<std::int8_t>();
Expand Down

0 comments on commit c5a52bc

Please sign in to comment.