-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
89 lines (71 loc) · 2.72 KB
/
main.cpp
File metadata and controls
89 lines (71 loc) · 2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "../include/bfm.h"
// Note: THIS MUST STAY HERE AND NOT BE INCLUDED ELSEWHERE
#ifndef MEX_ADAPT
#define MEX_ADAPT
#include "cppmex/detail/mexIOAdapterImpl.hpp"
#include "cppmex/detail/mexExceptionImpl.hpp"
#include "cppmex/detail/mexExceptionType.hpp"
#include "cppmex/detail/mexErrorDispatch.hpp"
#include "cppmex/detail/mexEngineUtilImpl.hpp"
#include "cppmex/detail/mexTaskReferenceImpl.hpp"
#include "cppmex/detail/mexApiAdapterImpl.hpp"
#include "cppmex/detail/mexFutureImpl.hpp"
#include "cppmex/detail/mexFunctionAdapterImpl.hpp"
#endif
class MexFunction : public matlab::mex::Function {
public:
std::shared_ptr<matlab::engine::MATLABEngine> matlabPtr = getEngine();
matlab::data::ArrayFactory factory;
void operator()(matlab::mex::ArgumentList outputs, matlab::mex::ArgumentList inputs) {
this->matlabPtr->feval(u"disp", 0, {this->factory.createScalar("Entered c++\n")});
bfm::object_store *datastore = bfm::object_store::getInstance_mat(matlabPtr);
datastore->store_data(inputs[0],"RFData");
this->matlabPtr->feval(u"disp", 0, {this->factory.createScalar("Read in data\n")});
auto midProc = bfm::bfm_midproc(datastore);
midProc.generate(1, 1, 1, 1);
this->matlabPtr->feval(u"disp", 0, {this->factory.createScalar("Successfully beamformed. Passing outputs to MATLAB\n")});
for (int i = 0; i < 5; ++i) {
const matlab::data::Array *dat = datastore->pass_outputs_matlab();
this->matlabPtr->feval(u"disp", 0, {this->factory.createScalar("Got array\n")});
const float flt_dat = (*dat)[0][i];
this->matlabPtr->feval(u"disp", 0, {this->factory.createScalar("Got data member\n")});
this->matlabPtr->feval(u"disp", 0, {this->factory.createScalar(std::to_string((flt_dat)))});
}
//bfm::primitive_data RFData = datastore->get_outputs();
//bfm::plotGammaScaleImage<int16_t>(RFData,0.35,RFData.Dims[0],RFData.Dims[1],"RFData");
outputs[0] = *datastore->pass_outputs_matlab();
/* mockup:
* if (arglist[0])
* {
* auto preProc = bfm::bfm_preproc(datastore);
* preProc.generate(arglist[0]);
* }
*
* if (!arglist[1] && !arglist[2])
* {
* createArgumentListMex(outputdata);
* return;
* }
*
* if (arglist[1])
* {
* auto midProc = bfm::bfm_midproc(datastore);
* midProc.generate(arglist[1]);
* }
*
* if (!arglist[2])
* {
* createArgumentListMex(outputdata);
* return;
* }
* else
* {
* auto postProc = bfm::bfm_postproc(datastore);
* postProc.generate(arglist[2]);
* createArgumentListMex(outputdata);
* return;
* }
*
*/
}
};