diff --git a/Gui/GUIutils/guiUtils.py b/Gui/GUIutils/guiUtils.py index 01073410..796a8bbb 100644 --- a/Gui/GUIutils/guiUtils.py +++ b/Gui/GUIutils/guiUtils.py @@ -145,20 +145,18 @@ def isActive(dbconnection): def SetupXMLConfig(Input_Dir, Output_Dir, BeBoardName=""): try: - os.system( - "cp {0}/CMSIT_{2}.xml {1}/CMSIT_2.xml".format( - Input_Dir, Output_Dir, BeBoardName - ) - ) + shutil.copyfile("{0}/CMSIT_{1}.xml".formgitat(Input_Dir, BeBoardName), + "{1}/CMSIT_2.xml".format(Output_Dir)) + + except OSError as e: logger.error(f"Failed to copy XML file: {e}") logger.error(traceback.format_exc()) try: - os.system( - "cp {0}/CMSIT_{2}.xml {1}/test/CMSIT_{2}.xml".format( - Output_Dir, os.environ.get("PH2ACF_BASE_DIR"), BeBoardName - ) - ) + shutil.copyfile( "{0}/CMSIT_{1}.xml".format(Output_Dir, BeBoardName), + "{0}/test/CMSIT_{1}.xml".format(os.environ.get("PH2ACF_BASE_DIR"), BeBoardName) + ) + logger.info("Copied XML file to test directory") except OSError as e: logger.error(f"Failed to copy XML file to test directory: {e}") @@ -274,18 +272,19 @@ def SetupXMLConfigfromFile(InputFile, Output_Dir, BeBoardName=""): logger.error(traceback.format_exc()) try: - os.system("cp {0} {1}/CMSIT_{2}.xml".format(InputFile, Output_Dir, BeBoardName)) # FIXME + shutil.copyfile(InputFile, + os.path.join(Output_Dir, f"CMSIT_{BeBoardName}.xml")) + except OSError: print("Can not copy the XML files {0} to {1}".format(InputFile, Output_Dir)) print(traceback.format_exc()) try: - os.system( - "cp {0}/CMSIT_{1}.xml {2}/test/CMSIT_{1}.xml".format( - Output_Dir, BeBoardName, os.environ.get("PH2ACF_BASE_DIR") + shutil.copyfile("{0}/CMSIT_{1}.xml".format(Output_Dir, BeBoardName), + "{0}/test/CMSIT_{1}.xml".format(os.environ.get("PH2ACF_BASE_DIR"), BeBoardName) ) - ) + except OSError: - print( + logger.error( "Can not copy {0}/CMSIT_{1}.xml to {2}/test/CMSIT_{1}.xml".format( Output_Dir, BeBoardName, os.environ.get("PH2ACF_BASE_DIR") ) @@ -302,24 +301,24 @@ def SetupRD53Config(Input_Dir, Output_Dir, RD53Dict): try: print("Doing the copy thing in guiUtils") shutil.copyfile( - "{0}/CMSIT_RD53_{1}_OUT.txt".format(Input_Dir, key), - "{0}/CMSIT_RD53_{1}_IN.txt".format(Output_Dir, key), + "{0}/CMSIT_RD53_{1}_OUT.txt".format(Input_Dir, key), + "{0}/CMSIT_RD53_{1}_IN.txt".format(Output_Dir, key) ) except OSError: - print( + logger.error( "Can not copy the RD53 configuration files to {0} for RD53 ID: {1}".format( Output_Dir, key ) ) print(traceback.format_exc()) try: - os.system( - "cp {0}/CMSIT_RD53_{1}_IN.txt {2}/test/CMSIT_RD53_{1}.txt".format( - Output_Dir, key, os.environ.get("PH2ACF_BASE_DIR") + shutil.copyfile( + "{0}/CMSIT_RD53_{1}_IN.txt".format(Output_Dir, key), + "{1}/test/CMSIT_RD53_{0}.txt".format(key, os.environ.get("PH2ACF_BASE_DIR") ) ) except OSError: - print( + logger.error( "Can not copy {0}/CMSIT_RD53_{1}_IN.txt to {2}/test/CMSIT_RD53_{1}.txt".format( Output_Dir, key, os.environ.get("PH2ACF_BASE_DIR") ) @@ -334,26 +333,24 @@ def SetupRD53Config(Input_Dir, Output_Dir, RD53Dict): def SetupRD53ConfigfromFile(InputFileDict, Output_Dir): for key in InputFileDict.keys(): try: - os.system( - "cp {0} {1}/CMSIT_RD53_{2}_IN.txt".format( - InputFileDict[key], Output_Dir, key - ) + shutil.copyfile( + InputFileDict[key], + "{0}/CMSIT_RD53_{1}_IN.txt".format(Output_Dir, key) ) except OSError: - print( + logger.error( "Can not copy the XML files {0} to {1}".format( InputFileDict[key], Output_Dir ) ) print(traceback.format_exc()) try: - os.system( - "cp {0}/CMSIT_RD53_{1}_IN.txt {2}/test/CMSIT_RD53_{1}.txt".format( - Output_Dir, key, os.environ.get("PH2ACF_BASE_DIR") - ) - ) + shutil.copyfile( + os.path.join(Output_Dir, f"CMSIT_RD53_{key}_IN.txt"), + os.path.join(os.environ.get("PH2ACF_BASE_DIR"), "test", f"CMSIT_RD53_{key}.txt") + ) except OSError: - print( + logger.error( "Can not copy {0}/CMSIT_RD53_{1}_IN.txt to {2}/test/CMSIT_RD53.txt".format( Output_Dir, key, os.environ.get("PH2ACF_BASE_DIR") ) diff --git a/Gui/QtGUIutils/QtApplication.py b/Gui/QtGUIutils/QtApplication.py index aefea7d7..aed5c7de 100644 --- a/Gui/QtGUIutils/QtApplication.py +++ b/Gui/QtGUIutils/QtApplication.py @@ -49,7 +49,6 @@ from Gui.python.logging_config import get_logger logger = get_logger(__name__) - class QtApplication(QWidget): globalStop = pyqtSignal() errorMessageBoxSignal = pyqtSignal(str) @@ -589,7 +588,7 @@ def createMain(self): if not site_settings.manual_powersupply_control: HVDevices = [] for device_name, device in site_settings.icicle_instrument_setup[ - "instrument_dict" + 'instrument_dict' ].items(): if "hv" in device_name: HVDevices.append(device) @@ -976,7 +975,8 @@ def connect_devices(self): if self.expertMode: if not self.default_checkbox.isChecked(): for key, value in self.connected_device_information.items(): - self.device_settings[key] = value + self.device_settings[key] = value + try: try: self.instruments = InstrumentCluster(**self.device_settings) @@ -1023,6 +1023,7 @@ def connect_devices(self): self.ArduinoGroup.setBaudRate(site_settings.defaultSensorBaudRate) self.ArduinoGroup.setArduinoPanel() + def disable_instrument_widgets(self): """ Use to disable the groupbox of LV, HV, relay board, and multimeter diff --git a/Gui/QtGUIutils/QtStartWindow.py b/Gui/QtGUIutils/QtStartWindow.py index ca86cba3..c22e4ee3 100644 --- a/Gui/QtGUIutils/QtStartWindow.py +++ b/Gui/QtGUIutils/QtStartWindow.py @@ -27,10 +27,10 @@ from Gui.GUIutils.settings import firmware_image, ModuleLaneMap from Gui.siteSettings import ( FC7List, + json_setup, ModuleCurrentMap, icicle_instrument_setup, WorkingChannels, - json_setup, cooler ) from icicle.icicle.instrument_cluster import DummyInstrument diff --git a/Gui/jsonFiles/instruments_osu_adcboardsldo.json b/Gui/jsonFiles/instruments_osu_adcboardsldo.json index 8694a630..df98aa70 100644 --- a/Gui/jsonFiles/instruments_osu_adcboardsldo.json +++ b/Gui/jsonFiles/instruments_osu_adcboardsldo.json @@ -27,5 +27,11 @@ "lv": {"instrument":"lv_1", "channel":1}, "hv": {"instrument":"hv", "channel":1} } + }, + + "fc7_address_dict":{ + "fc7.board.1" : "192.168.1.80", + "fc7.board.2" : "192.168.1.81", + "fc7.board.3" : "192.168.1.82" } } diff --git a/Gui/jsonFiles/instruments_osu_auto.json b/Gui/jsonFiles/instruments_osu_auto.json index f7947f3d..98d0f786 100644 --- a/Gui/jsonFiles/instruments_osu_auto.json +++ b/Gui/jsonFiles/instruments_osu_auto.json @@ -84,5 +84,11 @@ "hb": {"instrument":"hb", "channel":8}, "hv": {"instrument":"hv", "channel":1} } + }, + + "fc7_address_dict":{ + "fc7.board.1" : "192.168.1.80", + "fc7.board.2" : "192.168.1.81", + "fc7.board.3" : "192.168.1.82" } -} +} \ No newline at end of file diff --git a/Gui/python/TestHandler.py b/Gui/python/TestHandler.py index e815d2ad..3f6eb048 100644 --- a/Gui/python/TestHandler.py +++ b/Gui/python/TestHandler.py @@ -1323,12 +1323,13 @@ def copyMostRecentRootFile(self, RunNumber, base_dir, output_dir, test): # When using multiple FC7s root files will get overwritten so need to attach # what fc7 the test was run on to file name fc7_in_use: str = base_dir.split("/")[-1].replace(".", "_") + for file in matching_files: file_name: str = file.split("/")[-1] logger.debug( f"Copying {file} to {output_dir}/{fc7_in_use}_{file_name}" ) - os.system(f"cp {file} {output_dir}/{fc7_in_use}_{file_name}") + shutil.copyfile(file, f"{output_dir}/{fc7_in_use}_{file_name}") def saveTest(self, processIndex: int, process: QProcess): logger.debug("Inside saveTest") @@ -1350,39 +1351,56 @@ def saveTest(self, processIndex: int, process: QProcess): ) ) - if self.RunNumber == "-1": - os.system( - "cp {0}/test/Results/Run000000*.root {1}/".format( + if self.RunNumber == "-1": + dest_dir = os.path.join(self.output_dir, + self.firmware[processIndex].getBoardname() + ) + + for file_path in glob.glob( + os.path.join( os.environ.get("PH2ACF_BASE_DIR"), - os.path.join( - self.output_dir, self.firmware[processIndex].getBoardName() - ), + "test", + "Results", + "Run000000*.root" ) - ) + ): + try: + shutil.copy(file_path, dest_dir) + except (shutil.Error, IOError) as e: + logger.error(f"Error copying {file_path}: {e}") + elif "IVCurve" in self.currentTest: print("copying MonitorDQM.root file to output directory") + current_fc7: str = self.firmware[processIndex].getBoardName() - os.system( - "cp {0}/test/Results/Run{1}_MonitorDQM_Board_{2}*.root {3}/".format( - os.environ.get("PH2ACF_BASE_DIR"), - self.RunNumber, - self.firmware[processIndex].getBoardID(), - os.path.join( - self.output_dir, current_fc7 - ), - ) - ) - os.system( - "cp {0}/test/Results/Run{1}_CMSIT_{2}.xml {3}/".format( + + for file_path in glob.glob( + os.path.join( os.environ.get("PH2ACF_BASE_DIR"), + "test", + "Results", + "Run{0}_MonitorDQM_Board_{1}*.root".format( + self.RunNumber, self.firmware[processIndex].getBoardID())) + ): + shutil.copyfile( + file_path, + os.path.join( + self.output_dir, + current_fc7, + os.path.basename(file_path) + ) + ) + + shutil.copyfile( + "{0}/test/Results/Run{1}_CMSIT_{2}.xml".format(os.environ.get("PH2ACF_BASE_DIR"), self.RunNumber, - current_fc7, + current_fc7), os.path.join( self.output_dir, current_fc7 - ), + ) ) - ) + elif "IREF_GADC" in self.currentTest: print("copying MonitorDQM.root file to output directory") current_fc7: str = self.firmware[processIndex].getBoardName() diff --git a/Gui/python/TestValidator.py b/Gui/python/TestValidator.py index 18a9cc15..35480d65 100644 --- a/Gui/python/TestValidator.py +++ b/Gui/python/TestValidator.py @@ -95,6 +95,7 @@ def ResultGrader( f"{testIndexInSequence:02d}_{testName}", "sldo", ) + elif "Trimbit" in testName: relevant_files = [ outputDir + "/" + os.fsdecode(file) for file in os.listdir(outputDir) @@ -113,6 +114,7 @@ def ResultGrader( "trimbitscan", ) + elif "IREF" in testName: relevant_files = [ outputDir + "/" + os.fsdecode(file) for file in os.listdir(outputDir) if module_name in file or file.endswith(".xml") @@ -135,7 +137,6 @@ def ResultGrader( "irefgadc", ) - elif "CommunicationTest" in testName: module_name = module_data["module"].getModuleName() comm_result = communicationTestResults.get(module_name) diff --git a/Gui/siteConfig.py b/Gui/siteConfig.py index ec5d4e5c..822053e8 100644 --- a/Gui/siteConfig.py +++ b/Gui/siteConfig.py @@ -64,6 +64,7 @@ # Load instrument setup from json file # If the json filename contains 'auto', channels will be automatically assigned as listed in Working Channels + json_setup = 'jsonFiles/instruments_osu_adcboardsldo.json' with open(json_setup, 'r') as file: icicle_instrument_setup = json.load(file) @@ -119,12 +120,19 @@ forward_bias_voltage = 0.5 #positive voltage used to run a forward-reverse bias bump bond test + ## Update this dictionary for the IP addreses of your FC7 devices ## -FC7List = { - 'fc7.board.1' : '192.168.1.80', - 'fc7.board.2' : '192.168.1.81', - 'fc7.board.3' : '192.168.1.82', -} + +try: + json_setup = 'jsonFiles/instruments_osu_adcboardsldo.json' + with open(json_setup, 'r') as file: + icicle_instrument_setup = json.load(file) +except FileNotFoundError: + print("Error: 'data.json' not found.") + exit() + +FC7List = icicle_instrument_setup['fc7_address_dict'] +icicle_instrument_setup.pop('fc7_address_dict') ## Update this list with all working TEC channels in your coldbox ## Channel assignments will follow this list sequentially per number of modules entered in the GUI