diff --git a/.gitignore b/.gitignore index f6e7a25..d569341 100644 --- a/.gitignore +++ b/.gitignore @@ -26,6 +26,7 @@ moc_* *.rej *.so *.so.* +*.json *_pch.h.cpp *_resource.rc *.qm diff --git a/firmwares/compareJSON.py b/firmwares/compareJSON.py new file mode 100644 index 0000000..b03053b --- /dev/null +++ b/firmwares/compareJSON.py @@ -0,0 +1,37 @@ +import json + +# Load the two JSON files +with open("x2745_DPP-PHA_2023091800_parameters.json") as f1: + old_params = json.load(f1) + +with open("x2745_DPP-PHA_2025012205_parameters.json") as f2: + new_params = json.load(f2) + +# Index by parameter name for easy lookup +old_dict = {param["name"]: param for param in old_params} +new_dict = {param["name"]: param for param in new_params} + +# 1. Find new parameter names +new_names = set(new_dict.keys()) - set(old_dict.keys()) +print("š New parameters in new version:") +for name in sorted(new_names): + print(f" - {name}") + +# 2. Compare allowed values for common parameters +print("\nš Parameters with changed allowed values:") +for name in sorted(set(old_dict.keys()) & set(new_dict.keys())): + old_vals = {v["value"]: v["description"] for v in old_dict[name].get("allowed_values", [])} + new_vals = {v["value"]: v["description"] for v in new_dict[name].get("allowed_values", [])} + + if old_vals != new_vals: + print(f" - {name}") + removed = set(old_vals) - set(new_vals) + added = set(new_vals) - set(old_vals) + changed = {k for k in old_vals if k in new_vals and old_vals[k] != new_vals[k]} + + if added: + print(f" ā Added: {sorted(added)}") + if removed: + print(f" ā Removed: {sorted(removed)}") + if changed: + print(f" š Modified descriptions: {sorted(changed)}") diff --git a/firmwares/firmware_backup_webpage.txt b/firmwares/firmware_backup_webpage.txt new file mode 100644 index 0000000..ec0b6f0 --- /dev/null +++ b/firmwares/firmware_backup_webpage.txt @@ -0,0 +1 @@ +https://fsunuc.physics.fsu.edu/wiki/index.php/FSU_SOLARIS_DAQ#Firmware \ No newline at end of file diff --git a/firmwares/web2JSON.py b/firmwares/web2JSON.py new file mode 100644 index 0000000..72eb762 --- /dev/null +++ b/firmwares/web2JSON.py @@ -0,0 +1,76 @@ +import requests +from bs4 import BeautifulSoup + +url = "http://192.168.0.102/documentation/a00103.html" +response = requests.get(url) +soup = BeautifulSoup(response.content, 'html.parser') + +print(url) + +# print(soup) + +# Get the entire div +project_div = soup.find('div', id='projectname') +print("Full Text:", project_div.get_text(strip=True)) + +# Get just the main project name (excluding the span) +project_name = project_div.contents[0].strip() +print("Name:", project_name) + +# Get the project number from the span +project_number = project_div.find('span', id='projectnumber').get_text(strip=True) +print("Number:", project_number) + +safe_name = project_name.replace(" ", "_") +filename = f"{safe_name}_{project_number}_parameters.json" + +import json + +data = [] + +# Iterate through all
+ desc_tag = h2.find_next_sibling('p') + if desc_tag: + param['description'] = desc_tag.get_text(strip=True) + + # Get the next two blockquotes: one for options, one for allowed values + blockquotes = desc_tag.find_all_next('blockquote', class_='doxtable', limit=2) + + # Parse Options + if len(blockquotes) > 0: + options = {} + for li in blockquotes[0].find_all('li'): + text = li.get_text(strip=True) + if ':' in text: + key, val = text.split(':', 1) + options[key.strip()] = val.strip() + param['options'] = options + + # Parse Allowed Values + if len(blockquotes) > 1: + allowed_values = [] + for li in blockquotes[1].find_all('li'): + b_tag = li.find('b') + em_tag = li.find('em') + if b_tag and em_tag: + allowed_values.append({ + 'value': b_tag.get_text(strip=True), + 'description': em_tag.get_text(strip=True) + }) + param['allowed_values'] = allowed_values + + data.append(param) + + +# print(parameters) + + +# Output as JSON +with open(filename, 'w') as f: + json.dump(data, f, indent=2) \ No newline at end of file