Scope
StimulationVector.cpp
1 #include "StdAfx.h"
2 #include "StimulationVector.h"
3 
4 namespace scope {
5 
6 StimulationVector::StimulationVector()
7  : vecptr(std::make_shared<std::vector<uint8_t>>(round2ui32(parameters.duration() * 10000), 0U)) {
8 }
9 
11  uint32_t onsamples = round2ui32(parameters.ontime() * 10000);
12  uint32_t offsamples = round2ui32(parameters.offtime() * 10000);
13  uint32_t onsetsamples = round2ui32(parameters.onset() * 10000);
14  uint32_t durationsamples = round2ui32(parameters.duration() * 10000);
15 
16  vecptr->resize(durationsamples);
17  std::fill_n(vecptr->begin(), onsetsamples, 0U); // Just to be safe
18  std::vector<uint8_t>::iterator it(vecptr->begin() + onsetsamples);
19  do {
20  if ( (it + onsamples) > vecptr->end() )
21  break;
22  std::fill_n(it, onsamples, 2^8);
23  it += onsamples;
24  if ( (it + offsamples) > vecptr->end() )
25  break;
26  it += offsamples;
27  } while (1);
28 }
29 
30 }
ScopeNumber< double > ontime
on time of one stimulation pulse
Definition: Scope.h:51
ScopeNumber< double > offtime
off time after stimulation pulse
Definition: Scope.h:54
parameters::Stimulation parameters
parameter set
STL namespace.
ScopeNumber< double > onset
onset of stimulation
Definition: Scope.h:45
ScopeNumber< double > duration
total duration of stimulation
Definition: Scope.h:48
This is the include file for standard system include files, or project specific include files that ar...
void UpdateVector()
Recalculates the stimulation vector.
std::shared_ptr< std::vector< uint8_t > > const vecptr
pointer to data vector