ch10_13_handbook:python_code_using_dll
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| ch10_13_handbook:python_code_using_dll [2014/08/12 11:30] – created pferrill | ch10_13_handbook:python_code_using_dll [2014/08/12 15:56] (current) – mcferrill | ||
|---|---|---|---|
| Line 21: | Line 21: | ||
| # IRIG 106 data structures | # IRIG 106 data structures | ||
| # --------------------------------------------------------------------------- | # --------------------------------------------------------------------------- | ||
| - | |||
| class Header(ctypes.Structure): | class Header(ctypes.Structure): | ||
| Line 44: | Line 43: | ||
| # IRIG 106 constants | # IRIG 106 constants | ||
| # --------------------------------------------------------------------------- | # --------------------------------------------------------------------------- | ||
| - | |||
| class FileMode(): | class FileMode(): | ||
| Line 55: | Line 53: | ||
| READ_IN_ORDER = 4 # Open an existing file for reading in time order | READ_IN_ORDER = 4 # Open an existing file for reading in time order | ||
| READ_NET_STREAM = 5 # Open network data stream | READ_NET_STREAM = 5 # Open network data stream | ||
| - | |||
| class DataType(object): | class DataType(object): | ||
| Line 61: | Line 58: | ||
| # List of tuples of format (var, label, value). | # List of tuples of format (var, label, value). | ||
| - | types = [('UART_FMT_0', 'UART', | + | types = [('USER_DEFINED', 'User Defined', |
| - | | + | |
| - | | + | ('COMPUTER_1', |
| - | | + | |
| - | | + | |
| - | | + | ('RECORDING_EVENT', |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| - | | + | |
| + | | ||
| + | | ||
| + | | ||
| + | | ||
| @classmethod | @classmethod | ||
| Line 100: | Line 101: | ||
| if num == val and label is not None: | if num == val and label is not None: | ||
| return label | return label | ||
| - | |||
| # Populate DataType attirbutes from types list. | # Populate DataType attirbutes from types list. | ||
| for attr, label, val in DataType.types: | for attr, label, val in DataType.types: | ||
| setattr(DataType, | setattr(DataType, | ||
| - | |||
| # --------------------------------------------------------------------------- | # --------------------------------------------------------------------------- | ||
| Line 120: | Line 119: | ||
| file_name, file_mode) | file_name, file_mode) | ||
| return status, handle | return status, handle | ||
| - | |||
| def I106_Ch10Close(handle): | def I106_Ch10Close(handle): | ||
| Line 127: | Line 125: | ||
| ret_status = IrigDataDll.enI106Ch10Close(handle) | ret_status = IrigDataDll.enI106Ch10Close(handle) | ||
| return ret_status | return ret_status | ||
| - | |||
| def I106_Ch10ReadNextHeader(handle, | def I106_Ch10ReadNextHeader(handle, | ||
| Line 135: | Line 132: | ||
| ret_status = IrigDataDll.enI106Ch10ReadNextHeader(handle, | ret_status = IrigDataDll.enI106Ch10ReadNextHeader(handle, | ||
| return ret_status | return ret_status | ||
| - | |||
| def I106_Ch10ReadPrevHeader(handle, | def I106_Ch10ReadPrevHeader(handle, | ||
| Line 143: | Line 139: | ||
| ret_status = IrigDataDll.enI106Ch10ReadPrevHeader(handle, | ret_status = IrigDataDll.enI106Ch10ReadPrevHeader(handle, | ||
| return ret_status | return ret_status | ||
| - | |||
| def I106_Ch10ReadData(handle, | def I106_Ch10ReadData(handle, | ||
| Line 158: | Line 153: | ||
| ret_status = IrigDataDll.enI106Ch10SetPos(handle, | ret_status = IrigDataDll.enI106Ch10SetPos(handle, | ||
| return ret_status | return ret_status | ||
| - | |||
| def I106_Ch10GetPos(handle): | def I106_Ch10GetPos(handle): | ||
| Line 165: | Line 159: | ||
| ret_status = IrigDataDll.enI106Ch10GetPos(handle, | ret_status = IrigDataDll.enI106Ch10GetPos(handle, | ||
| return (ret_status, | return (ret_status, | ||
| - | |||
| # --------------------------------------------------------------------------- | # --------------------------------------------------------------------------- | ||
| Line 183: | Line 176: | ||
| self.Header | self.Header | ||
| self.Buffer | self.Buffer | ||
| - | |||
| # Open and close | # Open and close | ||
| Line 192: | Line 184: | ||
| RetStatus, self._Handle = I106_Ch10Open(Filename, | RetStatus, self._Handle = I106_Ch10Open(Filename, | ||
| return RetStatus | return RetStatus | ||
| - | |||
| def close(self): | def close(self): | ||
| Line 198: | Line 189: | ||
| RetStatus = I106_Ch10Close(self._Handle) | RetStatus = I106_Ch10Close(self._Handle) | ||
| return RetStatus | return RetStatus | ||
| - | |||
| # Read / Write | # Read / Write | ||
| Line 218: | Line 208: | ||
| RetStatus = I106_Ch10ReadData(self._Handle, | RetStatus = I106_Ch10ReadData(self._Handle, | ||
| return RetStatus | return RetStatus | ||
| - | |||
| def packet_headers(self): | def packet_headers(self): | ||
| Line 226: | Line 215: | ||
| yield self.Header | yield self.Header | ||
| RetStatus = self.read_next_header() | RetStatus = self.read_next_header() | ||
| - | |||
| # Other utility functions | # Other utility functions | ||
| Line 233: | Line 221: | ||
| ret_status = I106_Ch10SetPos(self._Handle, | ret_status = I106_Ch10SetPos(self._Handle, | ||
| return ret_status | return ret_status | ||
| - | |||
| def get_pos(self): | def get_pos(self): | ||
| (ret_status, | (ret_status, | ||
| return (ret_status, | return (ret_status, | ||
| - | |||
| # --------------------------------------------------------------------------- | # --------------------------------------------------------------------------- | ||
| Line 289: | Line 275: | ||
| for DataTypeNum in Counts: | for DataTypeNum in Counts: | ||
| print "Data Type %-16s Counts = %d" % ( DataType.name(DataTypeNum), | print "Data Type %-16s Counts = %d" % ( DataType.name(DataTypeNum), | ||
| - | |||
| </ | </ | ||
ch10_13_handbook/python_code_using_dll.1407861026.txt.gz · Last modified: 2014/08/12 11:30 by pferrill
