Files
castelion_radar_alinx_kintex/python/data_recorder.py

46 lines
1.5 KiB
Python
Executable File

import socket
import numpy as np
import ctypes
from ctypes import cdll
import data_structures
import threading
import queue
import os
import mmap
class DataRecorder:
def __init__(self,
host="192.168.2.128",
port=1234,
packet_size=4096):
self.lib = cdll.LoadLibrary('../cpp/data_recorder.so')
self.lib.DataRecorder_new.argtypes = [ctypes.c_int32]
self.lib.DataRecorder_new.restype = ctypes.c_int64
self.lib.DataRecorder_get_recording_rate.argtypes = [ctypes.c_int64]
self.lib.DataRecorder_get_recording_rate.restype = ctypes.c_float
# self.lib.DataRecorder_get_current_recording_size.argtypes = [ctypes.c_int64]
# self.lib.DataRecorder_get_current_recording_size.restype = ctypes.c_float
self.lib.DataRecorder_start_recording.argtypes = [ctypes.c_int64, ctypes.c_char_p, ctypes.c_int64, ctypes.c_int32]
self.lib.DataRecorder_start_recording.restype = ctypes.c_int32
self.lib.DataRecorder_stop_recording.argtypes = [ctypes.c_int64]
self.lib.DataRecorder_stop_recording.restype = ctypes.c_int32
self.obj = self.lib.DataRecorder_new(port)
def start_recording(self, filename, write_to_disk=False):
filename = filename.encode('utf-8')
filename = ctypes.c_char_p(filename)
self.lib.DataRecorder_start_recording(self.obj, filename, -1, 1)
def stop_recording(self):
self.lib.DataRecorder_stop_recording(self.obj)