def test1(): """Test basic functionality of the MultiForkFilterchain """ valkkafs = ValkkaFS.newFromDirectory( dirname = "/home/sampsa/tmp/testvalkkafs", blocksize = 512*1024, n_blocks = 10, verbose = True ) valkkafsmanager = ValkkaFSManager(valkkafs) openglthread = createTestThreads() fc = PlaybackFilterchain( openglthreads = [openglthread], valkkafsmanager = valkkafsmanager, slot = 2, _id = 123 ) window_id = openglthread.createWindow() view_port = ViewPort(window_id = window_id, x_screen_num = 0) n = 2 print("\nadd view port\n") fc.addViewPort(view_port) print("\nsleep\n") time.sleep(n) print("\ndel view port\n") fc.delViewPort(view_port) print("\nsleep\n") time.sleep(n) fc. requestClose() valkkafsmanager.requestClose() openglthread. requestClose() fc. waitClose() valkkafsmanager.waitClose() openglthread. waitClose()
def format_slot(self): """Gather info and format ValkkaFS """ partition_uuid = None if self.block_fs_rb.isChecked(): self.partition_uuid = self.block_fs_combo.currentText() print("format_slot: block fs checked", self.partition_uuid) partition_uuid = self.partition_uuid print("formatting valkkafs") print("partition", partition_uuid) # return self.fs = ValkkaFS.newFromDirectory( dirname=self.dirname, blocksize=self.blocksize * 1024 * 1024, # back to bytes n_blocks=self.n_blocks, device_size=None, # calculate from blocksize and n_blocks partition_uuid=partition_uuid, verbose=True)
def test1(): """Test basic functionality of the MultiForkFilterchain """ valkkafs = ValkkaFS.newFromDirectory( dirname="/home/sampsa/tmp/testvalkkafs", blocksize=512 * 1024, n_blocks=10, verbose=True) valkkafsmanager = ValkkaFSManager(valkkafs) livethread, usbdevicethread, openglthread = createTestThreads() address = "rtsp://*****:*****@192.168.0.124" context_type = ContextType.live #address = "/dev/video0" #context_type = ContextType.usb # record_type = RecordType.never #record_type = RecordType.always #record_type = RecordType.movement fc = MultiForkFilterchain(context_type=context_type, openglthreads=[openglthread], livethread=livethread, usbdevicethread=usbdevicethread, address=address, slot=2, _id=123) window_id = openglthread.createWindow() view_port = ViewPort(window_id=window_id, x_screen_num=0) n = 2 print("\nadd view port\n") fc.addViewPort(view_port) print("\nsleep\n") time.sleep(n) print("\ndel view port\n") fc.delViewPort(view_port) print("\nsleep\n") time.sleep(n) print("\nsetRecording (always)\n") fc.setRecording(12345, RecordType.always, valkkafsmanager) print("\nsleep\n") time.sleep(n) print("\nclearRecording\n") fc.clearRecording() print("\nsleep\n") time.sleep(n) print("\nsetRecording (movement)\n") fc.setRecording(12345, RecordType.movement, valkkafsmanager) print("\nsleep\n") time.sleep(n) print("\nsetRecording getShmem\n") name = fc.getShmem() print("\nsleep\n") time.sleep(n) print("\nsetRecording releaseShmem\n") fc.releaseShmem(name) print("\nsleep\n") time.sleep(n) print("\nclearRecording\n") fc.clearRecording() print("\nsleep\n") time.sleep(n) fc.requestClose() valkkafsmanager.requestClose() livethread.requestClose() usbdevicethread.requestClose() openglthread.requestClose() fc.waitClose() valkkafsmanager.waitClose() livethread.waitClose() usbdevicethread.waitClose() openglthread.waitClose()
def __init__(self, dirname, parent=None, blocksize_limits=(1, 1024 * 100), n_blocks_limits=(4, 999999)): # 1 MB -> 100 GB, -> 100 TB self.dirname = dirname self.fs = ValkkaFS.loadFromDirectory(dirname=self.dirname) self.blocksize_limits = blocksize_limits self.n_blocks_limits = n_blocks_limits self.main_widget = QWidget(parent) self.main_lay = QGridLayout(self.main_widget) # self.record_checkbox = QCheckBox("Enable Recording", self.main_widget) # not in this widget self.label1 = QLabel("Filesystem Specs", self.main_widget) self.blocksize_label = QLabel("Blocksize (MB)", self.main_widget) # self.blocksize_value = QLineEdit(self.main_widget) # self.blocksize_value.setValidator(QIntValidator(blocksize_limits[0], blocksize_limits[1])) self.blocksize_value = QSpinBox(self.main_widget) self.blocksize_value.setRange(blocksize_limits[0], blocksize_limits[1]) self.n_blocks_label = QLabel("Number of blocks", self.main_widget) # self.n_blocks_value = QLineEdit(self.main_widget) # self.n_blocks_value.setValidator(QIntValidator(n_blocks_limits[0], n_blocks_limits[1])) self.n_blocks_value = QSpinBox(self.main_widget) self.n_blocks_value.setRange(n_blocks_limits[0], n_blocks_limits[1]) self.totalsize_label = QLabel("Total size (MB)", self.main_widget) self.totalsize_value = QLineEdit(self.main_widget) self.totalsize_value.setReadOnly(True) self.label2 = QLabel("Record Type", self.main_widget) self.regular_file_rb = QRadioButton("Regular File") self.block_fs_rb = QRadioButton("Dedicated block device") # self.regular_file_button = QPushButton("Choose File") # this is automagic self.block_fs_combo = QComboBox(self.main_widget) self.label3 = QLabel("Actions", self.main_widget) self.format_button = QPushButton("FORMAT", self.main_widget) self.format_label = QLabel( "Applies filesystem changes (clears ValkkaFS)") self.save_button = QPushButton("SAVE", self.main_widget) self.save_label = QLabel("Applies other changes") self.cancel_button = QPushButton("CANCEL", self.main_widget) self.cancel_label = QLabel("Exits without applying any changes") # self.main_lay.addWidget(self.record_checkbox, 0, 0) self.main_lay.addWidget(self.label1, 1, 0) self.main_lay.addWidget(self.blocksize_label, 2, 0) self.main_lay.addWidget(self.blocksize_value, 2, 1) self.main_lay.addWidget(self.n_blocks_label, 3, 0) self.main_lay.addWidget(self.n_blocks_value, 3, 1) self.main_lay.addWidget(self.totalsize_label, 4, 0) self.main_lay.addWidget(self.totalsize_value, 4, 1) self.main_lay.addWidget(self.label2, 5, 0) self.main_lay.addWidget(self.regular_file_rb, 6, 0) # self.main_lay.addWidget(self.regular_file_button, 6, 1) self.main_lay.addWidget(self.block_fs_rb, 7, 0) self.main_lay.addWidget(self.block_fs_combo, 7, 1) self.main_lay.addWidget(self.label3, 8, 0) self.main_lay.addWidget(self.format_button, 9, 0) self.main_lay.addWidget(self.format_label, 9, 1) self.main_lay.addWidget(self.save_button, 10, 0) self.main_lay.addWidget(self.save_label, 10, 1) self.main_lay.addWidget(self.cancel_button, 11, 0) self.main_lay.addWidget(self.cancel_label, 11, 1) # self.blocksize_value.textChanged.connect(self.blocksize_slot) # self.n_blocks_value.textChanged.connect(self.n_blocks_slot) self.blocksize_value.valueChanged.connect(self.blocksize_slot) self.n_blocks_value.valueChanged.connect(self.n_blocks_slot) # self.regular_file_button.clicked.connect(self.regular_file_slot) self.block_fs_combo.currentIndexChanged.connect(self.block_device_slot) self.format_button.clicked.connect(self.format_slot) """ self.save_button.clicked.connect(self.save_slot) self.cancel_button.clicked.connect(self.cancel_slot) """ """TODO - Numerical values limit to blocksize and number of blocks - Total size can't be modified by the user - Default values for both - Default filesystem type = regular file - scan block devices => construct combobox - choose file : launch file selection dialog """ self.initValues()