nicoaspra
commited on
Commit
·
b5a4200
1
Parent(s):
cf12252
change ui to streamlit
Browse files- README.md +7 -8
- __pycache__/streamlit.cpython-313.pyc +0 -0
- gcode_analyzer_ui copy.py +50 -0
- gcode_analyzer_ui.py +40 -44
- streamlit.py +50 -0
README.md
CHANGED
|
@@ -1,13 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
-
sdk:
|
| 7 |
-
sdk_version:
|
| 8 |
-
app_file:
|
| 9 |
pinned: false
|
| 10 |
-
short_description: verify and analyze your G-codes
|
| 11 |
---
|
| 12 |
|
| 13 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Sample Sl Gcode
|
| 3 |
+
emoji: 🔥
|
| 4 |
+
colorFrom: yellow
|
| 5 |
+
colorTo: green
|
| 6 |
+
sdk: streamlit
|
| 7 |
+
sdk_version: 1.40.1
|
| 8 |
+
app_file: app.py
|
| 9 |
pinned: false
|
|
|
|
| 10 |
---
|
| 11 |
|
| 12 |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
__pycache__/streamlit.cpython-313.pyc
ADDED
|
Binary file (2.77 kB). View file
|
|
|
gcode_analyzer_ui copy.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# gcode_analyzer_ui.py
|
| 2 |
+
|
| 3 |
+
import gradio as gr
|
| 4 |
+
from python_gcode_checker import run_checks
|
| 5 |
+
from settings_report_details import generate_detailed_report
|
| 6 |
+
|
| 7 |
+
def analyze_gcode(gcode, depth_max=0.1):
|
| 8 |
+
errors, warnings = run_checks(gcode, depth_max)
|
| 9 |
+
error_count = len(errors)
|
| 10 |
+
warning_count = len(warnings)
|
| 11 |
+
config_report = generate_detailed_report(gcode)
|
| 12 |
+
return (
|
| 13 |
+
f"Errors: {error_count}\n\n{format_issues(errors)}",
|
| 14 |
+
f"Warnings: {warning_count}\n\n{format_issues(warnings)}",
|
| 15 |
+
config_report,
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
def format_issues(issues):
|
| 19 |
+
formatted = []
|
| 20 |
+
for line_num, message in issues:
|
| 21 |
+
if line_num > 0:
|
| 22 |
+
formatted.append(f"Line {line_num}: {message}")
|
| 23 |
+
else:
|
| 24 |
+
formatted.append(message)
|
| 25 |
+
return "\n".join(formatted)
|
| 26 |
+
|
| 27 |
+
# Create a Gradio Interface layout
|
| 28 |
+
app = gr.Interface(
|
| 29 |
+
fn=analyze_gcode,
|
| 30 |
+
inputs=[
|
| 31 |
+
gr.Textbox(lines=20, label="Input G-code", placeholder="Enter G-code here..."),
|
| 32 |
+
gr.Number(value=0.1, label="Maximum Depth of Cut"),
|
| 33 |
+
],
|
| 34 |
+
outputs=[
|
| 35 |
+
gr.Textbox(label="Errors", interactive=False),
|
| 36 |
+
gr.Textbox(label="Warnings", interactive=False),
|
| 37 |
+
gr.Textbox(label="Configuration Settings", interactive=False),
|
| 38 |
+
],
|
| 39 |
+
description="""
|
| 40 |
+
### G-code Programming Assistant (v0.1)
|
| 41 |
+
|
| 42 |
+
Welcome to the G-code Assistant! This tool is solely for educational purposes, helping you verify and analyze your G-code for potential errors and warnings before actually running it on your machine.
|
| 43 |
+
|
| 44 |
+
**Note:** This tool is limited to simple carving operations on a CNC milling machine.
|
| 45 |
+
|
| 46 |
+
This is a beta version, and you're free to use it for checking your G-codes. If you encounter any issues or unexpected behavior, please contact the developer at **nico.aspra@bicol-u.edu.ph**.
|
| 47 |
+
""",
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
app.launch()
|
gcode_analyzer_ui.py
CHANGED
|
@@ -1,54 +1,50 @@
|
|
| 1 |
-
#
|
| 2 |
|
| 3 |
-
import
|
| 4 |
from python_gcode_checker import run_checks
|
| 5 |
from settings_report_details import generate_detailed_report
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
error_count = len(errors)
|
| 10 |
-
warning_count = len(warnings)
|
| 11 |
-
config_report = generate_detailed_report(gcode)
|
| 12 |
-
return f"Errors: {error_count}\n\n{format_issues(errors)}", f"Warnings: {warning_count}\n\n{format_issues(warnings)}", config_report
|
| 13 |
-
|
| 14 |
-
def format_issues(issues):
|
| 15 |
-
formatted = []
|
| 16 |
-
for line_num, message in issues:
|
| 17 |
-
if line_num > 0:
|
| 18 |
-
formatted.append(f"Line {line_num}: {message}")
|
| 19 |
-
else:
|
| 20 |
-
formatted.append(message)
|
| 21 |
-
return "\n".join(formatted)
|
| 22 |
-
|
| 23 |
-
with gr.Blocks() as app:
|
| 24 |
-
gr.Markdown("""
|
| 25 |
-
### G-code Programming Assistant (v0.1)
|
| 26 |
-
|
| 27 |
-
Welcome to the G-code Assistant! This tool is solely for educational purposes, helping you verify and analyze your G-code for potential errors and warnings before actually running it on your machine.
|
| 28 |
-
|
| 29 |
-
**Note:** This tool is limited to simple carving operations on a CNC milling machine.
|
| 30 |
-
|
| 31 |
-
This is a beta version, and you're free to use it for checking your G-codes. If you encounter any issues or unexpected behavior, please contact the developer at **nico.aspra@bicol-u.edu.ph**.
|
| 32 |
-
""")
|
| 33 |
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
|
|
|
| 37 |
|
| 38 |
-
|
|
|
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
output_warnings = gr.Textbox(label="Warnings", interactive=False)
|
| 43 |
-
output_config = gr.Textbox(label="Configuration Settings", interactive=False)
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
inputs=[gcode_input, depth_input],
|
| 48 |
-
outputs=[output_errors, output_warnings, output_config]
|
| 49 |
-
)
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
| 53 |
|
| 54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app.py
|
| 2 |
|
| 3 |
+
import streamlit as st
|
| 4 |
from python_gcode_checker import run_checks
|
| 5 |
from settings_report_details import generate_detailed_report
|
| 6 |
|
| 7 |
+
# Title and description
|
| 8 |
+
st.title("G-code Programming Assistant (v0.1)")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
+
st.markdown("""
|
| 11 |
+
Welcome to the G-code Assistant! This tool is solely for educational purposes, helping you verify and analyze your G-code for potential errors and warnings before actually running it on your machine.
|
| 12 |
+
|
| 13 |
+
**Note:** This tool is limited to simple carving operations on a CNC milling machine.
|
| 14 |
|
| 15 |
+
This is a beta version, and you're free to use it for checking your G-codes. If you encounter any issues or unexpected behavior, please contact the developer at **nico.aspra@bicol-u.edu.ph**.
|
| 16 |
+
""")
|
| 17 |
|
| 18 |
+
# Input for maximum depth of cut
|
| 19 |
+
depth_max = st.number_input("Maximum Depth of Cut", min_value=0.0, value=0.1, step=0.1, format="%.1f")
|
|
|
|
|
|
|
| 20 |
|
| 21 |
+
# Text area for G-code input
|
| 22 |
+
gcode_input = st.text_area("Input G-code", height=300, placeholder="Enter G-code here...")
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
+
# Button to analyze G-code
|
| 25 |
+
if st.button("Analyze G-code"):
|
| 26 |
+
# Run analysis functions
|
| 27 |
+
errors, warnings = run_checks(gcode_input, depth_max)
|
| 28 |
+
config_report = generate_detailed_report(gcode_input)
|
| 29 |
|
| 30 |
+
# Display results
|
| 31 |
+
st.subheader("Analysis Results")
|
| 32 |
+
|
| 33 |
+
# Display errors and warnings in a formatted way
|
| 34 |
+
if errors:
|
| 35 |
+
st.error(f"Errors: {len(errors)}\n" + "\n".join(f"Line {line}: {msg}" for line, msg in errors))
|
| 36 |
+
else:
|
| 37 |
+
st.success("No errors found.")
|
| 38 |
+
|
| 39 |
+
if warnings:
|
| 40 |
+
st.warning(f"Warnings: {len(warnings)}\n" + "\n".join(f"Line {line}: {msg}" for line, msg in warnings))
|
| 41 |
+
else:
|
| 42 |
+
st.info("No warnings found.")
|
| 43 |
+
|
| 44 |
+
# Display configuration report
|
| 45 |
+
st.subheader("Configuration Settings")
|
| 46 |
+
st.text(config_report)
|
| 47 |
+
|
| 48 |
+
# Footer
|
| 49 |
+
st.markdown("---")
|
| 50 |
+
st.markdown("Developed by **Aspra, N.**")
|
streamlit.py
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# app.py
|
| 2 |
+
|
| 3 |
+
import streamlit as st
|
| 4 |
+
from python_gcode_checker import run_checks
|
| 5 |
+
from settings_report_details import generate_detailed_report
|
| 6 |
+
|
| 7 |
+
# Title and description
|
| 8 |
+
st.title("G-code Programming Assistant (v0.1)")
|
| 9 |
+
|
| 10 |
+
st.markdown("""
|
| 11 |
+
Welcome to the G-code Assistant! This tool is solely for educational purposes, helping you verify and analyze your G-code for potential errors and warnings before actually running it on your machine.
|
| 12 |
+
|
| 13 |
+
**Note:** This tool is limited to simple carving operations on a CNC milling machine.
|
| 14 |
+
|
| 15 |
+
This is a beta version, and you're free to use it for checking your G-codes. If you encounter any issues or unexpected behavior, please contact the developer at **nico.aspra@bicol-u.edu.ph**.
|
| 16 |
+
""")
|
| 17 |
+
|
| 18 |
+
# Input for maximum depth of cut
|
| 19 |
+
depth_max = st.number_input("Maximum Depth of Cut", min_value=0.0, value=0.1, step=0.1, format="%.1f")
|
| 20 |
+
|
| 21 |
+
# Text area for G-code input
|
| 22 |
+
gcode_input = st.text_area("Input G-code", height=300, placeholder="Enter G-code here...")
|
| 23 |
+
|
| 24 |
+
# Button to analyze G-code
|
| 25 |
+
if st.button("Analyze G-code"):
|
| 26 |
+
# Run analysis functions
|
| 27 |
+
errors, warnings = run_checks(gcode_input, depth_max)
|
| 28 |
+
config_report = generate_detailed_report(gcode_input)
|
| 29 |
+
|
| 30 |
+
# Display results
|
| 31 |
+
st.subheader("Analysis Results")
|
| 32 |
+
|
| 33 |
+
# Display errors and warnings in a formatted way
|
| 34 |
+
if errors:
|
| 35 |
+
st.error(f"Errors: {len(errors)}\n" + "\n".join(f"Line {line}: {msg}" for line, msg in errors))
|
| 36 |
+
else:
|
| 37 |
+
st.success("No errors found.")
|
| 38 |
+
|
| 39 |
+
if warnings:
|
| 40 |
+
st.warning(f"Warnings: {len(warnings)}\n" + "\n".join(f"Line {line}: {msg}" for line, msg in warnings))
|
| 41 |
+
else:
|
| 42 |
+
st.info("No warnings found.")
|
| 43 |
+
|
| 44 |
+
# Display configuration report
|
| 45 |
+
st.subheader("Configuration Settings")
|
| 46 |
+
st.text(config_report)
|
| 47 |
+
|
| 48 |
+
# Footer
|
| 49 |
+
st.markdown("---")
|
| 50 |
+
st.markdown("Developed by **Aspra, N.**")
|