OSDN Git Service

123
authorhskwk <hosokawa.kenchi@gmail.com>
Mon, 16 Mar 2015 14:22:05 +0000 (23:22 +0900)
committerhskwk <hosokawa.kenchi@gmail.com>
Mon, 16 Mar 2015 14:22:05 +0000 (23:22 +0900)
psychlops/core/devices/psychlops_io_analog.cpp
psychlops/core/devices/psychlops_io_analog.h
psychlops/extension/devices/psychlops_devices_parallelport.h
psychlops/extension/devices/psychlops_extentions_devices.h
psychlops/platform/win32/psychlops_devices_parallelport_Win32.cpp
win32gl/test/compilenew.cpp

index 557e382..baff599 100644 (file)
@@ -22,16 +22,9 @@ namespace Psychlops {
        void Trigger::set(ITrigger *v) { instance = v; }
        void Trigger::set(ITrigger &v) { instance = &v; }
        Trigger::~Trigger() { if(instance==0) delete instance; }
-       double Trigger::getLatency() { if(instance!=0) return instance->getLatency(); else throw trg_no_inst; }
-       double Trigger::getJitterSD() { if(instance!=0) return instance->getJitterSD(); else throw trg_no_inst; }
-       Interval Trigger::getRange() { if(instance!=0) return instance->getRange(); else throw trg_no_inst; }
-       bool Trigger::isAnalog() { if(instance!=0) return instance->isAnalog(); else throw trg_no_inst; }
-
-       double Trigger::get() { if(instance!=0) return instance->get(); else throw trg_no_inst; }
-       void Trigger::put(double v) { if(instance!=0) instance->put(v); else throw trg_no_inst; }
-       void Trigger::pulse(double v) { if(instance!=0) instance->pulse(v); else throw trg_no_inst; }
-       void Trigger::keep(double v) { if(instance!=0) instance->keep(v); else throw trg_no_inst; }
-       
+
+       void Trigger::trigger() { if(instance!=0) instance->trigger(); else throw trg_no_inst; }
+
 
 
        AnalogInput::~AnalogInput() {
index 12506aa..067d809 100644 (file)
@@ -17,15 +17,7 @@ namespace Psychlops {
        {
                public:
                virtual ~ITrigger();
-               virtual double getLatency() = 0;
-               virtual double getJitterSD() = 0;
-               virtual Interval getRange() = 0;
-               virtual bool isAnalog() = 0;
-
-               virtual double get() = 0;
-               virtual void put(double) = 0;
-               virtual void pulse(double) = 0;
-               virtual void keep(double) = 0;
+               virtual void trigger() = 0;
        };
 
        class Trigger : public ITrigger
@@ -40,15 +32,8 @@ namespace Psychlops {
                void set(ITrigger *);
                void set(ITrigger &);
                virtual ~Trigger();
-               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);
+               virtual void trigger();
        };
 
 
index 860d3d7..a317e48 100644 (file)
@@ -18,22 +18,18 @@ namespace Devices {
 \r
        class GenericParallelPort : public ITrigger\r
        {\r
+               public:\r
                enum PIN { D0=1, D1=2, D2=4, D3=8, D4=16, D5=32, D6=64, D7=-128 };\r
+\r
+               private:\r
                char pins;\r
                void * handle;\r
 \r
                public:\r
-               GenericParallelPort(size_t pin);\r
+               GenericParallelPort(std::string port_name, size_t pin);\r
                virtual ~GenericParallelPort();
-               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
+
+               virtual void trigger();\r
        };
 
 }
index 938945b..40d5a96 100644 (file)
@@ -10,6 +10,7 @@
 #define HEADER_PSYCHLOPS_EXTENTIONS_DEVICES\r
 \r
 #include "psychlops_devices_util.h"\r
+#include "psychlops_devices_parallelport.h"\r
 #include "psychlops_devices_crs_bits.h"\r
 \r
 \r
index 9f8e0f0..e333375 100644 (file)
@@ -19,35 +19,27 @@ namespace Devices {
        //https://msdn.microsoft.com/ja-jp/library/cc429198.aspx\r
        //http://support.microsoft.com/kb/823179/ja
 
-       GenericParallelPort::GenericParallelPort(size_t pin) : pins(pin) {\r
-               if (!(handle = CreateDC(NULL , "TRIGGER_PARALLEL" , NULL , NULL))) {\r
-                       printf("Parallel port was not found.");\r
+       GenericParallelPort::GenericParallelPort(std::string port_name, size_t pin) : pins(pin) {\r
+               if (!(handle = CreateDC(NULL , port_name.c_str() , NULL , NULL))) {\r
                        handle = 0;\r
+                       throw new Exception("Parallel port was not found.");\r
                }\r
        }
        GenericParallelPort::~GenericParallelPort() {\r
                if(handle!=0) {\r
-                       DeleteDC(handle);\r
+                       DeleteDC((HDC)handle);\r
                }\r
        }\r
 
-       double GenericParallelPort::getLatency() { return -1; }
-       double GenericParallelPort::getJitterSD() { return -1; }
-       Interval GenericParallelPort::getRange() { Interval i; return 0<=i<=5; }
-       bool GenericParallelPort::isAnalog() { return false; }\r
-
-       double GenericParallelPort::get() { return 0; }
-       void GenericParallelPort::put(double v) { ; }
-       void GenericParallelPort::pulse(double v) {\r
+       void GenericParallelPort::trigger() {\r
                DOCINFO diInfo = {0};\r
                diInfo.cbSize = sizeof (DOCINFO);\r
                diInfo.lpszDocName = "";\r
-               if (t%100 == 0 && StartDoc(handle , &diInfo) > 0) {\r
-                       TextOut(handle , 0 , 0 , pins , 1);\r
-                       EndDoc(handle);\r
+               if (StartDoc((HDC)handle , &diInfo) > 0) {\r
+                       TextOut((HDC)handle , 0 , 0 , &pins , 1);\r
+                       EndDoc((HDC)handle);\r
                }\r
        }
-       void GenericParallelPort::keep(double v) { ; }
 
 }
 }      /*      <- namespace Psycholops         */\r
index 814ba72..c1ae204 100644 (file)
@@ -22,8 +22,7 @@ void psychlops_main() {
        Psychlops::Ellipse rect(100,100);\r
        rect.fill = Color::red;\r
 \r
-\r
-       data_bits[0] = 1 + 4 + 8; // choose bit\r
+       Devices::GenericParallelPort trigger("USB_PARALLEL", 1+8);\r
 \r
        int t=0;\r
 \r
@@ -34,10 +33,10 @@ void psychlops_main() {
                //if(t%100 == 0)\r
                //      rs = CreateProcess("C:\\Windows\\System32\\print.exe",(LPTSTR)" /D:LPT1 D:\\Users\\hskwk\\Desktop\\zzz.txt",NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&si,&pi);\r
 \r
+               if(t%120==0) trigger.trigger();\r
+\r
                Display::flip(); // Flip frame buffers\r
        }\r
-\r
-       DeleteDC(hdc);\r
 }\r
 ///- Stimulus drawing function\r
 \r