2929}
3030
3131from .sciopy_dataclasses import EitMeasurementSetup
32- from sciopydev .sciopy .usb_message_parser import (MessageParser , make_eitframes_hex , get_data_as_matrix ,
33- make_results_folder )
32+ from sciopydev .sciopy .usb_message_parser import (
33+ MessageParser ,
34+ make_eitframes_hex ,
35+ get_data_as_matrix ,
36+ make_results_folder ,
37+ )
3438
3539
3640class EIT_16_32_64_128 :
@@ -152,7 +156,6 @@ def disconnect_device(self):
152156 """
153157 self .device .close ()
154158
155-
156159 def send_message (self , message ):
157160 """
158161 Wrapper function to send a byte array to the device. Communication method is based on the defined serial
@@ -166,7 +169,6 @@ def send_message(self, message):
166169 elif self .serial_protocol == "FS" :
167170 self .device .write (message )
168171
169-
170172 def read_message (self ):
171173 """
172174 Wrapper function to read single bytes from the device. Communication method is based on the defined serial
@@ -253,7 +255,9 @@ def write_command_string(self, command):
253255 """
254256 self .cMessageParser .bPrintMessages = self .print_msg
255257 self .send_message (command )
256- self .cMessageParser .read_usb_till_timeout (bSaveData = False , bDeleteDataFrame = True )
258+ self .cMessageParser .read_usb_till_timeout (
259+ bSaveData = False , bDeleteDataFrame = True
260+ )
257261
258262 # --- sciospec device commands
259263
@@ -482,8 +486,9 @@ def ResetMeasurementSetup(self):
482486 self .write_command_string (bytearray ([0xB0 , 0x01 , 0x01 , 0xB0 ]))
483487 self .print_msg = False
484488
485-
486- def update_measurement_mode (self , meamode : str = "skip4" , boundary : str = "external" ):
489+ def update_measurement_mode (
490+ self , meamode : str = "skip4" , boundary : str = "external"
491+ ):
487492 """
488493 Updates the measurement modes out of the options "singleended", "skip0", "skip2" or "skip4"
489494
@@ -492,20 +497,27 @@ def update_measurement_mode(self, meamode: str = "skip4", boundary: str = "exter
492497 boundary (str): Return if the boundary for skip patterns is internal of a channel group or external for all
493498 optional channels
494499 """
495- meamodeoptions = {"singleended" : 0x01 , "skip0" : 0x02 , "skip2" : 0x03 , "skip4" : 0x04 }
500+ meamodeoptions = {
501+ "singleended" : 0x01 ,
502+ "skip0" : 0x02 ,
503+ "skip2" : 0x03 ,
504+ "skip4" : 0x04 ,
505+ }
496506 self .print_msg = True
497507 try :
498508 cmd = meamodeoptions [meamode ]
499509 except :
500- print ("Option for measurement mode is unknown. Measurement mode ist set to single-ended." )
510+ print (
511+ "Option for measurement mode is unknown. Measurement mode ist set to single-ended."
512+ )
501513 cmd = 0x01
502514 if boundary == "external" :
503515 bnd = 0x02
504516 else :
505517 bnd = 0x01
506518 self .write_command_string (bytearray ([0xB0 , 0x03 , 0x08 , cmd , bnd , 0xB0 ]))
507519 self .print_msg = False
508- #todo read out ACK messages
520+ # todo read out ACK messages
509521
510522 def GetMeasurementSetup (self , setup_of : str ):
511523 """
@@ -542,7 +554,7 @@ def GetMeasurementSetup(self, setup_of: str):
542554 print ("TBD: Translation" )
543555 self .print_msg = False
544556
545- #todo
557+ # todo
546558 def StartStopMeasurementFast (self , return_as = "pot_mat" ):
547559 """
548560 Starts and stops a measurement process using the configured serial protocol (HS or FS).
@@ -582,9 +594,15 @@ def StartStopMeasurementFast(self, return_as="pot_mat"):
582594 elif return_as == "pot_mat" :
583595 return self .get_data_as_matrix ()
584596
585-
586- def StartStopMeasurementNew (self , timeout :int = 0 , return_as = "pot_mat" , bSaveData :bool = False , bDeleteData :bool = False ,
587- sSavepath :str = "C/" , bResultsFolder = True ):
597+ def StartStopMeasurementNew (
598+ self ,
599+ timeout : int = 0 ,
600+ return_as = "pot_mat" ,
601+ bSaveData : bool = False ,
602+ bDeleteData : bool = False ,
603+ sSavepath : str = "C/" ,
604+ bResultsFolder = True ,
605+ ):
588606 """
589607 Starts and stops a measurement process using the configured serial protocol (HS or FS).
590608 Sends appropriate commands to the device to initiate and terminate measurement.
@@ -611,24 +629,40 @@ def StartStopMeasurementNew(self, timeout:int=0, return_as="pot_mat", bSaveData:
611629
612630 # Start measurement
613631 self .cMessageParser .clear_out_data ()
614- sCurrentPath = make_results_folder (bResultsFolder , bSaveData , sSavepath ) # No new path is created if bResultsFolder=False
615-
632+ sCurrentPath = make_results_folder (
633+ bResultsFolder , bSaveData , sSavepath
634+ ) # No new path is created if bResultsFolder=False
635+
616636 self .send_message (bytearray ([0xB4 , 0x01 , 0x01 , 0xB4 ]))
617637 self .cMessageParser .bPrintMessages = False
618638 if timeout != 0 :
619- self .cMessageParser .read_usb_for_seconds (timeout , bSaveData = bSaveData , bDeleteDataFrame = bDeleteData ,
620- sSavePath = sCurrentPath ,bResultsFolder = False )
639+ self .cMessageParser .read_usb_for_seconds (
640+ timeout ,
641+ bSaveData = bSaveData ,
642+ bDeleteDataFrame = bDeleteData ,
643+ sSavePath = sCurrentPath ,
644+ bResultsFolder = False ,
645+ )
621646 else :
622- if self .setup .burst_count == 0 :
647+ if self .setup .burst_count == 0 :
623648 print ("Burst count for this setup needs to be >=1" )
624649 return
625- self .cMessageParser .read_usb_till_timeout (bSaveData = bSaveData , bDeleteDataFrame = bDeleteData ,sSavePath = sSavepath , bResultsFolder = False )
650+ self .cMessageParser .read_usb_till_timeout (
651+ bSaveData = bSaveData ,
652+ bDeleteDataFrame = bDeleteData ,
653+ sSavePath = sSavepath ,
654+ bResultsFolder = False ,
655+ )
626656
627657 # Stop measurement
628658 self .send_message (bytearray ([0xB4 , 0x01 , 0x00 , 0xB4 ]))
629659 # All data is returned if wanted
630- data = self .cMessageParser .read_usb_till_timeout (bSaveData = bSaveData , bDeleteDataFrame = bDeleteData ,
631- sSavePath = sCurrentPath , bResultsFolder = False )
660+ data = self .cMessageParser .read_usb_till_timeout (
661+ bSaveData = bSaveData ,
662+ bDeleteDataFrame = bDeleteData ,
663+ sSavePath = sCurrentPath ,
664+ bResultsFolder = False ,
665+ )
632666
633667 if bDeleteData :
634668 return
@@ -639,8 +673,6 @@ def StartStopMeasurementNew(self, timeout:int=0, return_as="pot_mat", bSaveData:
639673 elif return_as == "eitframe" :
640674 return data
641675
642-
643-
644676 def get_data_as_matrix (self ):
645677 """
646678 Converts the raw EIT data into a 3D matrix of potentials.
0 commit comments