sistemata la colonna dei target
This commit is contained in:
parent
45c40f76e5
commit
03d6af5f3e
30
TestEnvironment/env/leo_grifo_pdf2report.py
vendored
30
TestEnvironment/env/leo_grifo_pdf2report.py
vendored
@ -153,9 +153,12 @@ class PDFClass:
|
|||||||
"""
|
"""
|
||||||
logging.info("Setting PDF name")
|
logging.info("Setting PDF name")
|
||||||
|
|
||||||
|
# Use test ID as base name (falls back to file_name) and include seconds
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
date_name = now.strftime("%Y%m%d_%H%M")
|
date_name = now.strftime("%Y%m%d_%H%M%S")
|
||||||
file_name_only = f"{json_test['file_name']}_{date_name}"
|
base = json_test.get('ID') or json_test.get('file_name') or 'testReport'
|
||||||
|
# PDF will use suffix '_report' so final file is <base>_<timestamp>_report.pdf
|
||||||
|
file_name_only = f"{base}_{date_name}_report"
|
||||||
file_name = os.path.join(new_path, file_name_only)
|
file_name = os.path.join(new_path, file_name_only)
|
||||||
|
|
||||||
logging.info(f"Test: {file_name}")
|
logging.info(f"Test: {file_name}")
|
||||||
@ -401,20 +404,21 @@ class PDFClass:
|
|||||||
target_text = '-'
|
target_text = '-'
|
||||||
target_result_text = '-'
|
target_result_text = '-'
|
||||||
else:
|
else:
|
||||||
# Target test was performed - show results
|
# Target test was performed - show results based on detection
|
||||||
t_info = run.get('target_simulated')
|
|
||||||
if t_info:
|
|
||||||
try:
|
|
||||||
target_text = f"{t_info.get('distance')}m @ cycle {t_info.get('appeared_after_cycles', t_info.get('found_at_iter','?'))}"
|
|
||||||
except Exception:
|
|
||||||
target_text = str(t_info)
|
|
||||||
else:
|
|
||||||
target_text = '-'
|
|
||||||
|
|
||||||
# Target test result
|
|
||||||
if target_detected:
|
if target_detected:
|
||||||
|
# PASS: target was detected - show details (distance @ cycle)
|
||||||
|
t_info = run.get('target_simulated')
|
||||||
|
if t_info:
|
||||||
|
try:
|
||||||
|
target_text = f"{t_info.get('distance')}m @ cycle {t_info.get('appeared_after_cycles', t_info.get('found_at_iter','?'))}"
|
||||||
|
except Exception:
|
||||||
|
target_text = "Detected"
|
||||||
|
else:
|
||||||
|
target_text = "Detected"
|
||||||
target_result_text = "PASS"
|
target_result_text = "PASS"
|
||||||
else:
|
else:
|
||||||
|
# FAIL: target was NOT detected - no details to show
|
||||||
|
target_text = '-'
|
||||||
target_result_text = "FAIL"
|
target_result_text = "FAIL"
|
||||||
|
|
||||||
for cell_text in (str(run['repetition']), status_text, pbit_time,
|
for cell_text in (str(run['repetition']), status_text, pbit_time,
|
||||||
|
|||||||
@ -34,7 +34,7 @@ Power Cycling Timing (aligned with target2):
|
|||||||
- Power OFF: wait_before=1s (stabilization before action), wait_after=4s (settle time)
|
- Power OFF: wait_before=1s (stabilization before action), wait_after=4s (settle time)
|
||||||
- Power ON: wait_after=100ms (initialization delay)
|
- Power ON: wait_after=100ms (initialization delay)
|
||||||
|
|
||||||
Author: Test Automation Team
|
Author: Luca Vallongo
|
||||||
Date: 2026-01-29
|
Date: 2026-01-29
|
||||||
Last Updated: 2026-02-02 (aligned with target2 timing and behavior)
|
Last Updated: 2026-02-02 (aligned with target2 timing and behavior)
|
||||||
"""
|
"""
|
||||||
@ -415,7 +415,8 @@ def export_statistics_to_csv(custom_statistics, test_name, output_folder):
|
|||||||
logging.info(f"Created output folder: {output_folder}")
|
logging.info(f"Created output folder: {output_folder}")
|
||||||
|
|
||||||
# Create CSV filename with absolute path
|
# Create CSV filename with absolute path
|
||||||
csv_filename = f"{test_name}_statistics.csv"
|
# Use singular suffix '_statistic' to align with PDF naming ordering
|
||||||
|
csv_filename = f"{test_name}_statistic.csv"
|
||||||
csv_path = os.path.join(output_folder, csv_filename)
|
csv_path = os.path.join(output_folder, csv_filename)
|
||||||
|
|
||||||
logging.info(f"Exporting statistics to CSV: {csv_path}")
|
logging.info(f"Exporting statistics to CSV: {csv_path}")
|
||||||
@ -2210,6 +2211,19 @@ def test_proc():
|
|||||||
run_stats['target_iterations'] = tgt_result['iterations']
|
run_stats['target_iterations'] = tgt_result['iterations']
|
||||||
run_stats['target_detected'] = target_found
|
run_stats['target_detected'] = target_found
|
||||||
run_stats['target_test_time'] = target_test_time
|
run_stats['target_test_time'] = target_test_time
|
||||||
|
|
||||||
|
# Update target_simulated with actual test results (for PDF table)
|
||||||
|
# This replaces the pre-test mock data with real post-test data
|
||||||
|
if target_found and tgt_result.get('range'):
|
||||||
|
run_stats['target_simulated'] = {
|
||||||
|
'distance': int(tgt_result['range']),
|
||||||
|
'appeared_after_cycles': tgt_result.get('iterations', 0),
|
||||||
|
'found_at_iter': tgt_result.get('iterations', 0),
|
||||||
|
'hits': tgt_result['hits']
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
# Target not detected - clear any pre-test mock data
|
||||||
|
run_stats['target_simulated'] = None
|
||||||
|
|
||||||
# Restore STANDBY after target test ( simple command)
|
# Restore STANDBY after target test ( simple command)
|
||||||
logging.info('[Target Test] Restoring STANDBY mode')
|
logging.info('[Target Test] Restoring STANDBY mode')
|
||||||
@ -2367,7 +2381,8 @@ def test_proc():
|
|||||||
# Also write JSON statistics file alongside CSV for structured consumption
|
# Also write JSON statistics file alongside CSV for structured consumption
|
||||||
try:
|
try:
|
||||||
if csv_path and os.path.isdir(pdf_folder):
|
if csv_path and os.path.isdir(pdf_folder):
|
||||||
json_filename = f"{csv_base_name}_statistics.json"
|
# JSON statistics file - singular 'statistic' to match CSV
|
||||||
|
json_filename = f"{csv_base_name}_statistic.json"
|
||||||
json_path = os.path.join(pdf_folder, json_filename)
|
json_path = os.path.join(pdf_folder, json_filename)
|
||||||
with open(json_path, 'w', encoding='utf-8') as jf:
|
with open(json_path, 'w', encoding='utf-8') as jf:
|
||||||
json.dump(custom_statistics, jf, ensure_ascii=False, indent=2)
|
json.dump(custom_statistics, jf, ensure_ascii=False, indent=2)
|
||||||
|
|||||||
@ -205,8 +205,8 @@ IF !EXIT_CODE! EQU 0 (
|
|||||||
ECHO.
|
ECHO.
|
||||||
ECHO Results available in:
|
ECHO Results available in:
|
||||||
ECHO - Log: %TEST_ENV%\LOG\GRIFO_M_PBIT.log
|
ECHO - Log: %TEST_ENV%\LOG\GRIFO_M_PBIT.log
|
||||||
ECHO - PDF: %TEST_ENV%\pdf_reports\GRIFO_M_PBIT\GRIFO_M_PBIT_*.pdf
|
ECHO - PDF: %TEST_ENV%\pdf_reports\GRIFO_M_PBIT\GRIFO_M_PBIT_*_report.pdf
|
||||||
ECHO - CSV: %TEST_ENV%\pdf_reports\GRIFO_M_PBIT\GRIFO_M_PBIT_*_statistics.csv
|
ECHO - CSV: %TEST_ENV%\pdf_reports\GRIFO_M_PBIT\GRIFO_M_PBIT_*_statistic.csv
|
||||||
ECHO.
|
ECHO.
|
||||||
ECHO Check PDF report for detailed test results and statistics.
|
ECHO Check PDF report for detailed test results and statistics.
|
||||||
ECHO.
|
ECHO.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user