alsterane / pylibnidaqmx

Automatically exported from code.google.com/p/pylibnidaqmx
Other
0 stars 0 forks source link

[Enhancement] DigitalInputOutputTask #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
You provide a read-only DigitalInputTask class and a write-only 
DigitalOutputTask, which makes sense regarding the semantics. However, as far 
as I know DO can always be read on NI hardware. I did not want to patch your 
code so that I have made the following trivial class for DIO

class DIOTask(DigitalOutputTask, DigitalInputTask):

    channel_type = "DO"

    def create_channel(self, *args, **kwargs):
        DigitalOutputTask.create_channel(self, *args, **kwargs)

and it works as expected on my hardware.

However, the solution on your side might be to simply inherit DigitalInputTask 
(instead of DigitalTask) in your declaration of DigitalOutputTask, line 2913 of 
libnidaqmx.py and provide a DigitalIOTask = DigitalOutputTask for the 
semantics. If you do not want to do this, I would still suggest to add my 
DIOTask to your library. I did not try to see what channel_type does, so I left 
it to "DO".

Thank you for your work anyway,
Mathias

Original issue reported on code.google.com by Mathias....@gmail.com on 17 Mar 2012 at 9:14

GoogleCodeExporter commented 9 years ago
To resolve the issue, I moved the read method from DigitalInputTask to under 
the DigitalTask class definition so that DigitalOutputTask instances can also 
read.
The patch is committed to svn repo.

Thanks for your feedback!

Original comment by pearu.peterson on 9 Apr 2012 at 8:01