schillerCFK commited on
Commit
4c0c588
·
verified ·
1 Parent(s): e16a815

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -50,7 +50,7 @@ def submit_rzf_order(w, p, s, q, focus, spot, coaxial, ellipse, dim_d, dim_l, wi
50
  "訂單編號": datetime.now().strftime("RZF%Y%m%d%H%M%S"),
51
  "提交時間": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
52
  "波長": w, "功率(mW)": p, "光斑樣式": s, "數量": q,
53
- "焦距(mm)": focus, "光點大小/長度": spot, "同軸度(°)": coaxial, "橢圓率(%)": ellipse,
54
  "機構尺寸(D*L)": f"{dim_d}*{dim_l}", "線材材質": wire_m, "線材長度(mm)": wire_l, "線材顏色": wire_c, "連接器規格": connector
55
  }
56
  df = pd.DataFrame([new_data])
@@ -119,7 +119,7 @@ def calc_angle_from_offset(distance, dist_unit, offset, off_type, off_unit):
119
  )
120
 
121
  fig = draw_coaxiality_plot(distance_mm, r)
122
- return text_result, fig, round(mrad, 4)
123
 
124
  def calc_offset_from_angle(distance, dist_unit, angle, ang_type):
125
  if distance <= 0: return "❌ 距離必須大於 0", None, gr.update()
@@ -157,7 +157,7 @@ def calc_offset_from_angle(distance, dist_unit, angle, ang_type):
157
  )
158
 
159
  fig = draw_coaxiality_plot(distance_mm, r)
160
- return text_result, fig, round(mrad, 4)
161
 
162
  # --- 光束發散 (Beam Divergence) 邏輯 ---
163
 
@@ -437,7 +437,8 @@ with gr.Blocks(title=COMPANY_NAME) as demo:
437
  focus_in = gr.Number(label="焦距 (mm)", value=0)
438
  spot_in = gr.Textbox(label="光點大小") # 標籤會動態改變
439
  with gr.Row():
440
- coaxial_in = gr.Number(label="同軸度 (mRad/°)", value=0); ellipse_in = gr.Number(label="橢圓率 (%)", value=0)
 
441
  with gr.Column():
442
  gr.Markdown("### 🔩 機構與線材規格")
443
  with gr.Row(): dim_d = gr.Number(label="直徑", value=10); dim_l = gr.Number(label="長度", value=30)
 
50
  "訂單編號": datetime.now().strftime("RZF%Y%m%d%H%M%S"),
51
  "提交時間": datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
52
  "波長": w, "功率(mW)": p, "光斑樣式": s, "數量": q,
53
+ "焦距(mm)": focus, "光點大小/長度": spot, "同軸度(mRad/°)": coaxial, "橢圓率(%)": ellipse,
54
  "機構尺寸(D*L)": f"{dim_d}*{dim_l}", "線材材質": wire_m, "線材長度(mm)": wire_l, "線材顏色": wire_c, "連接器規格": connector
55
  }
56
  df = pd.DataFrame([new_data])
 
119
  )
120
 
121
  fig = draw_coaxiality_plot(distance_mm, r)
122
+ return text_result, fig, f"{mrad:.4f} mRad"
123
 
124
  def calc_offset_from_angle(distance, dist_unit, angle, ang_type):
125
  if distance <= 0: return "❌ 距離必須大於 0", None, gr.update()
 
157
  )
158
 
159
  fig = draw_coaxiality_plot(distance_mm, r)
160
+ return text_result, fig, f"{mrad:.4f} mRad"
161
 
162
  # --- 光束發散 (Beam Divergence) 邏輯 ---
163
 
 
437
  focus_in = gr.Number(label="焦距 (mm)", value=0)
438
  spot_in = gr.Textbox(label="光點大小") # 標籤會動態改變
439
  with gr.Row():
440
+ coaxial_in = gr.Dropdown(choices=["≤ 1 mRad", "≤ 3 mRad", "≤ 5 mRad", "≤ 8 mRad", "≤ 10 mRad"], label="同軸度 (mRad/°)", value="≤ 3 mRad", allow_custom_value=True)
441
+ ellipse_in = gr.Number(label="橢圓率 (%)", value=0)
442
  with gr.Column():
443
  gr.Markdown("### 🔩 機構與線材規格")
444
  with gr.Row(): dim_d = gr.Number(label="直徑", value=10); dim_l = gr.Number(label="長度", value=30)