OSDN Git Service

parallel
authorhskwk <hosokawa.kenchi@gmail.com>
Sun, 1 Mar 2015 12:44:16 +0000 (21:44 +0900)
committerhskwk <hosokawa.kenchi@gmail.com>
Sun, 1 Mar 2015 12:44:16 +0000 (21:44 +0900)
psychlops/core/math/psychlops_m_interval.cpp
psychlops/core/math/psychlops_m_interval.h
psychlops/extension/devices/psychlops_devices_parallelport.h [new file with mode: 0644]
psychlops/extension/devices/psychlops_devices_util.h
psychlops/platform/win32/psychlops_devices_parallelport_Win32.cpp [new file with mode: 0644]
win32gl/dev/psychlopswin32.cbp
win32gl/test/Psychlops_win32cblibtest.cbp

index a925882..dc1cf1c 100644 (file)
@@ -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() {}\r
+
+       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; }
index 33db07f..3d8450a 100644 (file)
@@ -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 (file)
index 0000000..e9e34f4
--- /dev/null
@@ -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 {
+\r
+\r
+       class ParallelPort : public ITrigger\r
+       {\r
+               enum PIN { TWO=1, THREE=2, FOUR=4, FIVE=8, SIX=16, SEVEN=32, EIGHT=64, NINE=128 };\r
+               unsigned char pins;\r
+               void * handle;\r
+\r
+               public:\r
+               ParallelPort(size_t pin);\r
+               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);\r
+       };
+
+}
+
+}      /*      <- namespace Psycholops         */
+
+
+
+#endif
index 6af96d1..3ffccb5 100644 (file)
@@ -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 {
+/*\r
+ *  psychlops_devices_nidaqmxbase.h\r
+ *  Psychlops Standard Library (Universal)\r
+ *\r
+ *  Last Modified 2009/07/30 by Kenchi HOSOKAWA\r
+ *  (C) 2009 Kenchi HOSOKAWA, Kazushi MARUYA, Takao SATO\r
+ */\r
+\r
+#ifndef HEADER_PSYCHLOPS_DEVICES_UTIL\r
+#define HEADER_PSYCHLOPS_DEVICES_UTIL\r
+\r
+#include "../../core/devices/psychlops_io_analog.h"\r
+#include "../../core/devices/psychlops_io_clock.h"\r
+\r
+namespace Psychlops {\r
+\r
+namespace Devices {\r
 \r
 \r
        class DisplayFlash : public ITrigger, public Rectangle\r
@@ -31,44 +31,44 @@ namespace Devices {
                virtual void put(double);\r
        };\r
 \r
-
-       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
+\r
+       class OscillationSimulator : public AnalogInput {\r
+               public:\r
+               double frequency, amplitude, internal_phase;\r
+               double (*waveform)(double);\r
+\r
+               OscillationSimulator();\r
+               OscillationSimulator(double freq, double amp = 1, double phase = 0);\r
+               double get();\r
+       };\r
+\r
+\r
+       class ClockOscillator : public AnalogInput {\r
+               Clock clock;\r
+               public:\r
+               double frequency, amplitude, internal_phase;\r
+               double (*waveform)(double);\r
+\r
+               ClockOscillator();\r
+               ClockOscillator(double freq, double amp = 1, double phase = 0);\r
+               double get();\r
+       };\r
+\r
+\r
+       class MouseX : public AnalogInput {\r
+               double factor;\r
+               public:\r
+               MouseX();\r
+               MouseX(const double factor);\r
+               virtual ~MouseX();\r
+               virtual double get();\r
+//             virtual double normalize(double);\r
+       };\r
+\r
+}\r
+\r
+}      /*      <- namespace Psycholops         */\r
+\r
+\r
+\r
+#endif\r
diff --git a/psychlops/platform/win32/psychlops_devices_parallelport_Win32.cpp b/psychlops/platform/win32/psychlops_devices_parallelport_Win32.cpp
new file mode 100644 (file)
index 0000000..c9232fa
--- /dev/null
@@ -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 <windows.h>
+#include "../../core/math/psychlops_m_util.h"
+#include "../../extension/devices/psychlops_devices_parallelport.h"
+
+
+namespace Psychlops {
+namespace Devices {
+\r
+       //http://support.microsoft.com/kb/413279/JA\r
+       //https://msdn.microsoft.com/ja-jp/library/cc429198.aspx\r
+       //http://support.microsoft.com/kb/823179/ja
+
+       ParallelPort::ParallelPort(size_t pin) : pins(pin) {\r
+               handle = CreateFile("LPT1", GENERIC_WRITE, 0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);\r
+               if(handle == INVALID_HANDLE_VALUE) {\r
+                       std::cout << "Failed to open parallel port." <<std::endl;\r
+                       handle = 0;\r
+               }\r
+       }
+       ParallelPort::~ParallelPort() {\r
+               if(handle!=0) {\r
+                       CloseHandle(handle);\r
+               }\r
+       }\r
+
+       double ParallelPort::getLatency() { return -1; }
+       double ParallelPort::getJitterSD() { return -1; }
+       Interval ParallelPort::getRange() { Interval i; return 0<=i<=5; }
+       bool ParallelPort::isAnalog() { return false; }\r
+
+       double ParallelPort::get() { return 0; }
+       void ParallelPort::put(double v) { ; }
+       void ParallelPort::pulse(double v) {\r
+               unsigned char buff[1];\r
+               DWORD writtenbytes;\r
+               OVERLAPPED m_write;\r
+\r
+               buff[0] = pins;\r
+\r
+               WriteFile(handle, buff, 1, &writtenbytes, &m_write);\r
+       }
+       void ParallelPort::keep(double v) { ; }
+
+}
+}      /*      <- namespace Psycholops         */\r
+
index 285fb6a..b89599d 100644 (file)
                        <Option target="VC9 Devices" />
                </Unit>
                <Unit filename="../../psychlops/extension/devices/psychlops_devices_nidaqmxbase.h" />
+               <Unit filename="../../psychlops/extension/devices/psychlops_devices_parallelport.h" />
                <Unit filename="../../psychlops/extension/devices/psychlops_devices_util.cpp" />
                <Unit filename="../../psychlops/extension/devices/psychlops_devices_util.h" />
                <Unit filename="../../psychlops/extension/devices/psychlops_extentions_devices.h" />
                <Unit filename="../../psychlops/platform/win32/psychlops_app_state_Win32.h" />
                <Unit filename="../../psychlops/platform/win32/psychlops_app_thread_Win32.cpp" />
                <Unit filename="../../psychlops/platform/win32/psychlops_app_tweak_Win32.h" />
+               <Unit filename="../../psychlops/platform/win32/psychlops_devices_parallelport_Win32.cpp" />
                <Unit filename="../../psychlops/platform/win32/psychlops_io_API_Win32.cpp" />
                <Unit filename="../../psychlops/platform/win32/psychlops_io_API_Win32.h" />
                <Unit filename="../../psychlops/platform/win32/psychlops_io_clipboard_Win32.cpp" />
index b0cb6ef..b81356a 100644 (file)
                        <Option compile="0" />
                        <Option link="0" />
                </Unit>
-               <Unit filename="opencvtest.cpp" />
+               <Unit filename="opencvtest.cpp">
+                       <Option compile="0" />
+                       <Option link="0" />
+               </Unit>
                <Unit filename="shader/ShaderDot.cpp">
                        <Option compile="0" />
                        <Option link="0" />
                        <Option compile="0" />
                        <Option link="0" />
                </Unit>
-               <Unit filename="shader/ShaderLoader.cpp">
-                       <Option compile="0" />
-                       <Option link="0" />
-               </Unit>
+               <Unit filename="shader/ShaderLoader.cpp" />
                <Unit filename="shader/ShaderPlaidsBench.cpp">
                        <Option compile="0" />
                        <Option link="0" />