OSDN Git Service

first
[psychlops/cpp.git] / psychlops / extension / devices / psychlops_devices_util.cpp
1 /*
2  *  psychlops_devices_nidaqmxbase.cpp
3  *  Psychlops Standard Library (Universal)
4  *
5  *  Last Modified 2009/04/14 by Kenchi HOSOKAWA
6  *  (C) 2009 Kenchi HOSOKAWA, Kazushi MARUYA, Takao SATO
7  */
8
9 #include "../../core/ApplicationInterfaces/psychlops_code_exception.h"
10 #include "../../core/devices/psychlops_io_hid.h"
11 #include "../../core/graphic/psychlops_g_canvas.h"
12 #include "../../core/math/psychlops_math.h"
13
14 #include "psychlops_devices_util.h"
15
16
17 namespace Psychlops {
18
19 namespace Devices {
20
21         double through(double x) {
22                 return x;
23         }
24 \r
25 \r
26         DisplayFlash::~DisplayFlash() { ; }\r
27         double DisplayFlash::getLatency() { return 0; }\r
28         double DisplayFlash::getJitterSD() { return 0; }\r
29         Interval DisplayFlash::getRange() { Interval i; return 0<=i<=5; }\r
30         bool DisplayFlash::isAnalog() { return false; }\r
31         double DisplayFlash::get() { return 0; }\r
32         void DisplayFlash::put(double v) { Color col(v); draw(col);; }\r
33 \r
34
35         OscillationSimulator::OscillationSimulator()
36         {
37                 normalize = &through;
38                 waveform = &sin;
39         }
40         OscillationSimulator::OscillationSimulator(double freq, double amp, double phase)
41         {
42                 normalize = &through;
43                 waveform = &sin;
44                 frequency = freq;
45                 amplitude = amp;
46                 internal_phase = phase;
47         }
48         double OscillationSimulator::get()
49         {
50                 internal_phase += frequency;
51                 return amplitude*waveform(internal_phase*2*PI);
52         }
53
54
55         const double ONESEC = 2.0*PI/1000.0;
56         ClockOscillator::ClockOscillator()
57         {
58                 normalize = &through;
59                 waveform = &sin;
60         }
61         ClockOscillator::ClockOscillator(double freq, double amp, double phase)
62         {
63                 normalize = &through;
64                 waveform = &sin;
65                 frequency = freq;
66                 amplitude = amp;
67                 internal_phase = phase;
68         }
69         double ClockOscillator::get()
70         {
71                 clock.update();
72                 return amplitude*waveform(frequency*clock.at_msec()*ONESEC+internal_phase);
73         }
74
75
76
77         MouseX::MouseX(const double fac) : factor(fac) {
78                 normalize = &through;
79         }
80         MouseX::MouseX() {
81                 normalize = &through;
82                 if(Drawable::prime_is_a_canvas()) factor=1.0/Drawable::prime->getWidth();
83                 else factor=1;
84         }
85         MouseX::~MouseX() {
86         }
87         double MouseX::get() {
88                 return normalize(factor*Mouse::uniX);
89         }
90 }
91
92
93 }       /*      <- namespace Psycholops         */
94
95