From da69887d7c2522e3912c6d524351c47c68996c7b Mon Sep 17 00:00:00 2001 From: hskwk Date: Sun, 1 Mar 2015 21:44:16 +0900 Subject: [PATCH] parallel --- psychlops/core/math/psychlops_m_interval.cpp | 5 +- psychlops/core/math/psychlops_m_interval.h | 2 + .../devices/psychlops_devices_parallelport.h | 45 ++++++++ .../extension/devices/psychlops_devices_util.h | 116 ++++++++++----------- .../win32/psychlops_devices_parallelport_Win32.cpp | 55 ++++++++++ win32gl/dev/psychlopswin32.cbp | 2 + win32gl/test/Psychlops_win32cblibtest.cbp | 10 +- 7 files changed, 171 insertions(+), 64 deletions(-) create mode 100644 psychlops/extension/devices/psychlops_devices_parallelport.h create mode 100644 psychlops/platform/win32/psychlops_devices_parallelport_Win32.cpp diff --git a/psychlops/core/math/psychlops_m_interval.cpp b/psychlops/core/math/psychlops_m_interval.cpp index a925882..dc1cf1c 100644 --- a/psychlops/core/math/psychlops_m_interval.cpp +++ b/psychlops/core/math/psychlops_m_interval.cpp @@ -16,7 +16,10 @@ namespace Psychlops { Interval::Interval() : begin(NINF), end(INF) {} Interval::Interval(double floor_val, double ceil_val) : begin(floor_val, OPEN), end(ceil_val, OPEN) {} Interval::Interval(double floor_val, OPERATOR floor_op, double ceil_val, OPERATOR ceil_op) : begin(floor_val, floor_op), end(ceil_val, ceil_op) {} - Interval::~Interval() {} + Interval::~Interval() {} + + Interval& Interval::set(double floor_val, double ceil_val) { end.set(floor_val,OPEN); begin.set(ceil_val,OPEN); return *this; } + Interval& Interval::set(double floor_val, OPERATOR floor_op, double ceil_val, OPERATOR ceil_op) { end.set(floor_val, floor_op); begin.set(ceil_val, ceil_op); return *this; } Interval& Interval::operator <(double value) { end.set(value,OPEN); begin.set(NINF,CLOSE); return *this; } Interval& Interval::operator <=(double value) { end.set(value,CLOSE); begin.set(NINF,CLOSE); return *this; } diff --git a/psychlops/core/math/psychlops_m_interval.h b/psychlops/core/math/psychlops_m_interval.h index 33db07f..3d8450a 100644 --- a/psychlops/core/math/psychlops_m_interval.h +++ b/psychlops/core/math/psychlops_m_interval.h @@ -44,6 +44,8 @@ namespace Psychlops { Interval(double floor_val, double ceil_val); Interval(double floor_val, OPERATOR floor_op, double ceil_val, OPERATOR ceil_op); virtual ~Interval(); + Interval& set(double floor_val, double ceil_val); + Interval& set(double floor_val, OPERATOR floor_op, double ceil_val, OPERATOR ceil_op); Interval& operator <(double value); Interval& operator <=(double value); Interval& operator >(double value); diff --git a/psychlops/extension/devices/psychlops_devices_parallelport.h b/psychlops/extension/devices/psychlops_devices_parallelport.h new file mode 100644 index 0000000..e9e34f4 --- /dev/null +++ b/psychlops/extension/devices/psychlops_devices_parallelport.h @@ -0,0 +1,45 @@ +/* + * psychlops_devices_nidaqmxbase.h + * Psychlops Standard Library (Universal) + * + * Last Modified 2009/07/30 by Kenchi HOSOKAWA + * (C) 2009 Kenchi HOSOKAWA, Kazushi MARUYA, Takao SATO + */ + +#ifndef HEADER_PSYCHLOPS_DEVICES_PARALLELPORT +#define HEADER_PSYCHLOPS_DEVICES_PARALLELPORT + +#include "../../core/devices/psychlops_io_analog.h" + +namespace Psychlops { + +namespace Devices { + + + class ParallelPort : public ITrigger + { + enum PIN { TWO=1, THREE=2, FOUR=4, FIVE=8, SIX=16, SEVEN=32, EIGHT=64, NINE=128 }; + unsigned char pins; + void * handle; + + public: + ParallelPort(size_t pin); + virtual ~ParallelPort(); + virtual double getLatency(); + virtual double getJitterSD(); + virtual Interval getRange(); + virtual bool isAnalog(); + + virtual double get(); + virtual void put(double); + virtual void pulse(double); + virtual void keep(double); + }; + +} + +} /* <- namespace Psycholops */ + + + +#endif diff --git a/psychlops/extension/devices/psychlops_devices_util.h b/psychlops/extension/devices/psychlops_devices_util.h index 6af96d1..3ffccb5 100644 --- a/psychlops/extension/devices/psychlops_devices_util.h +++ b/psychlops/extension/devices/psychlops_devices_util.h @@ -1,20 +1,20 @@ -/* - * psychlops_devices_nidaqmxbase.h - * Psychlops Standard Library (Universal) - * - * Last Modified 2009/07/30 by Kenchi HOSOKAWA - * (C) 2009 Kenchi HOSOKAWA, Kazushi MARUYA, Takao SATO - */ - -#ifndef HEADER_PSYCHLOPS_DEVICES_UTIL -#define HEADER_PSYCHLOPS_DEVICES_UTIL - -#include "../../core/devices/psychlops_io_analog.h" -#include "../../core/devices/psychlops_io_clock.h" - -namespace Psychlops { - -namespace Devices { +/* + * psychlops_devices_nidaqmxbase.h + * Psychlops Standard Library (Universal) + * + * Last Modified 2009/07/30 by Kenchi HOSOKAWA + * (C) 2009 Kenchi HOSOKAWA, Kazushi MARUYA, Takao SATO + */ + +#ifndef HEADER_PSYCHLOPS_DEVICES_UTIL +#define HEADER_PSYCHLOPS_DEVICES_UTIL + +#include "../../core/devices/psychlops_io_analog.h" +#include "../../core/devices/psychlops_io_clock.h" + +namespace Psychlops { + +namespace Devices { class DisplayFlash : public ITrigger, public Rectangle @@ -31,44 +31,44 @@ namespace Devices { virtual void put(double); }; - - class OscillationSimulator : public AnalogInput { - public: - double frequency, amplitude, internal_phase; - double (*waveform)(double); - - OscillationSimulator(); - OscillationSimulator(double freq, double amp = 1, double phase = 0); - double get(); - }; - - - class ClockOscillator : public AnalogInput { - Clock clock; - public: - double frequency, amplitude, internal_phase; - double (*waveform)(double); - - ClockOscillator(); - ClockOscillator(double freq, double amp = 1, double phase = 0); - double get(); - }; - - - class MouseX : public AnalogInput { - double factor; - public: - MouseX(); - MouseX(const double factor); - virtual ~MouseX(); - virtual double get(); -// virtual double normalize(double); - }; - -} - -} /* <- namespace Psycholops */ - - - -#endif + + class OscillationSimulator : public AnalogInput { + public: + double frequency, amplitude, internal_phase; + double (*waveform)(double); + + OscillationSimulator(); + OscillationSimulator(double freq, double amp = 1, double phase = 0); + double get(); + }; + + + class ClockOscillator : public AnalogInput { + Clock clock; + public: + double frequency, amplitude, internal_phase; + double (*waveform)(double); + + ClockOscillator(); + ClockOscillator(double freq, double amp = 1, double phase = 0); + double get(); + }; + + + class MouseX : public AnalogInput { + double factor; + public: + MouseX(); + MouseX(const double factor); + virtual ~MouseX(); + virtual double get(); +// virtual double normalize(double); + }; + +} + +} /* <- namespace Psycholops */ + + + +#endif diff --git a/psychlops/platform/win32/psychlops_devices_parallelport_Win32.cpp b/psychlops/platform/win32/psychlops_devices_parallelport_Win32.cpp new file mode 100644 index 0000000..c9232fa --- /dev/null +++ b/psychlops/platform/win32/psychlops_devices_parallelport_Win32.cpp @@ -0,0 +1,55 @@ +/* + * psychlops_devices_nidaqmxbase.cpp + * Psychlops Standard Library (Universal) + * + * Last Modified 2009/04/14 by Kenchi HOSOKAWA + * (C) 2009 Kenchi HOSOKAWA, Kazushi MARUYA, Takao SATO + */ + + +#include +#include "../../core/math/psychlops_m_util.h" +#include "../../extension/devices/psychlops_devices_parallelport.h" + + +namespace Psychlops { +namespace Devices { + + //http://support.microsoft.com/kb/413279/JA + //https://msdn.microsoft.com/ja-jp/library/cc429198.aspx + //http://support.microsoft.com/kb/823179/ja + + ParallelPort::ParallelPort(size_t pin) : pins(pin) { + handle = CreateFile("LPT1", GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); + if(handle == INVALID_HANDLE_VALUE) { + std::cout << "Failed to open parallel port." < + @@ -413,6 +414,7 @@ + diff --git a/win32gl/test/Psychlops_win32cblibtest.cbp b/win32gl/test/Psychlops_win32cblibtest.cbp index b0cb6ef..b81356a 100644 --- a/win32gl/test/Psychlops_win32cblibtest.cbp +++ b/win32gl/test/Psychlops_win32cblibtest.cbp @@ -204,7 +204,10 @@ - + + - - +