User Tools

Site Tools


ch10_13_handbook:python_code_using_dll

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Last revisionBoth sides next revision
ch10_13_handbook:python_code_using_dll [2014/08/12 11:30] – created pferrillch10_13_handbook:python_code_using_dll [2014/08/12 15:30] 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 91: Line 88:
              ('IEEE1394_FMT_0', 'IEEE 1394 Format 0', 0x58),              ('IEEE1394_FMT_0', 'IEEE 1394 Format 0', 0x58),
              ('IEEE1394_FMT_1', 'IEEE 1394 Format 1', 0x59),              ('IEEE1394_FMT_1', 'IEEE 1394 Format 1', 0x59),
-             ('MESSAGE', 'Message', 0x30)]+             ('MESSAGE', 'Message', 0x30), 
 +             ('TSPI_CTS_FMT_0', 'GPS NMEA-RTCM', 0x70), 
 +             ('TSPI_CTS_FMT_1', 'EAG ACMI', 0x71), 
 +             ('TSPI_CTS_FMT_2', 'ACTTS', 0x72), 
 +             ('CAN_BUS', 'CAN Bus', 0x78)]
  
     @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, attr, val)     setattr(DataType, attr, val)
- 
  
 # --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
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, pkt_header): def I106_Ch10ReadNextHeader(handle, pkt_header):
Line 135: Line 132:
     ret_status = IrigDataDll.enI106Ch10ReadNextHeader(handle, ctypes.byref(pkt_header))     ret_status = IrigDataDll.enI106Ch10ReadNextHeader(handle, ctypes.byref(pkt_header))
     return ret_status     return ret_status
- 
  
 def I106_Ch10ReadPrevHeader(handle, pkt_header): def I106_Ch10ReadPrevHeader(handle, pkt_header):
Line 143: Line 139:
     ret_status = IrigDataDll.enI106Ch10ReadPrevHeader(handle, ctypes.byref(pkt_header))     ret_status = IrigDataDll.enI106Ch10ReadPrevHeader(handle, ctypes.byref(pkt_header))
     return ret_status     return ret_status
- 
  
 def I106_Ch10ReadData(handle, buff_size, data_buff): def I106_Ch10ReadData(handle, buff_size, data_buff):
Line 158: Line 153:
     ret_status = IrigDataDll.enI106Ch10SetPos(handle, offset)     ret_status = IrigDataDll.enI106Ch10SetPos(handle, offset)
     return ret_status     return ret_status
- 
  
 def I106_Ch10GetPos(handle): def I106_Ch10GetPos(handle):
Line 165: Line 159:
     ret_status = IrigDataDll.enI106Ch10GetPos(handle, ctypes.byref(offset))     ret_status = IrigDataDll.enI106Ch10GetPos(handle, ctypes.byref(offset))
     return (ret_status, offset.value)     return (ret_status, offset.value)
- 
  
 # --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
Line 183: Line 176:
         self.Header  = Header()         self.Header  = Header()
         self.Buffer  = ctypes.create_string_buffer(0)         self.Buffer  = ctypes.create_string_buffer(0)
- 
  
     # Open and close     # Open and close
Line 192: Line 184:
         RetStatus, self._Handle = I106_Ch10Open(Filename, FileMode)         RetStatus, self._Handle = I106_Ch10Open(Filename, FileMode)
         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, self.Buffer._length_, self.Buffer)         RetStatus = I106_Ch10ReadData(self._Handle, self.Buffer._length_, self.Buffer)
         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, offset)         ret_status = I106_Ch10SetPos(self._Handle, offset)
         return ret_status         return ret_status
- 
  
     def get_pos(self):     def get_pos(self):
         (ret_status, offset) = I106_Ch10GetPos(self._Handle)         (ret_status, offset) = I106_Ch10GetPos(self._Handle)
         return (ret_status, offset)         return (ret_status, offset)
- 
  
 # --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
Line 289: Line 275:
     for DataTypeNum in Counts:     for DataTypeNum in Counts:
         print "Data Type %-16s Counts = %d" % ( DataType.name(DataTypeNum),  Counts[DataTypeNum])         print "Data Type %-16s Counts = %d" % ( DataType.name(DataTypeNum),  Counts[DataTypeNum])
- 
  
 </code> </code>
ch10_13_handbook/python_code_using_dll.txt · Last modified: 2014/08/12 15:56 by mcferrill

Except where otherwise noted, content on this wiki is licensed under the following license: CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki