进行一些适配性UI修改

This commit is contained in:
2025-10-16 13:51:10 +08:00
parent 7edbda02f6
commit 4ff69b622d
4 changed files with 57 additions and 3 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 709 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 695 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 574 KiB

+57 -3
View File
@@ -1,3 +1,38 @@
"""
================================================================================
自动控制原理AI+数智平台 (Automatic Control Theory AI+ Platform)
================================================================================
版权声明 (Copyright Notice):
本项目由"西北工业大学2025年校级本科生建设项目"资助
Funded by Northwestern Polytechnical University 2025 Undergraduate
Construction Project
项目信息 (Project Information):
课程名称:《自动控制理论》
Course: Automatic Control Theory
负责人:魏鹏飞
Supervisor: Wei Pengfei
联系方式:pengfeiwei@nwpu.edu.cn
Email: pengfeiwei@nwpu.edu.cn
机构:西北工业大学
Institution: Northwestern Polytechnical University (NWPU)
功能简介 (Features):
- 时域分析:阶跃响应、脉冲响应、性能指标计算
- 频域分析:Bode图、Nyquist图、稳定裕度分析
- 根轨迹分析:动态轨迹绘制、增益调节、极点跟踪
- AI智能问答:基于DeepSeek/Gemini的专业教学助手
最后更新 (Last Updated): 2025-10-16
版本 (Version): 1.0.0
================================================================================
"""
import gradio as gr import gradio as gr
import numpy as np import numpy as np
import control as ct import control as ct
@@ -477,6 +512,20 @@ with gr.Blocks(title="自动控制原理学习网站", css=custom_css) as demo:
gr.Markdown("<h1 class='main-title'> 自动控制原理AI+数智平台</h1>") gr.Markdown("<h1 class='main-title'> 自动控制原理AI+数智平台</h1>")
gr.Markdown("<p class='subtitle'>交互式控制系统分析与设计工具 | 时域·频域·根轨迹·AI问答</p>") gr.Markdown("<p class='subtitle'>交互式控制系统分析与设计工具 | 时域·频域·根轨迹·AI问答</p>")
# 项目信息和版权声明
gr.HTML("""
<div style='text-align: center; padding: 10px; background: linear-gradient(135deg, #f5f7fa 0%, #e8eaf6 100%); border-radius: 8px; margin-bottom: 20px; font-size: 0.9em;'>
<p style='margin: 5px 0; color: #555;'>
<strong>📚 课程:</strong>《自动控制理论》 |
<strong>👨‍🏫 负责人:</strong>魏鹏飞 |
<strong>📧 联系:</strong><a href='mailto:pengfeiwei@nwpu.edu.cn' style='color: #667eea; text-decoration: none;'>pengfeiwei@nwpu.edu.cn</a>
</p>
<p style='margin: 5px 0; color: #666; font-size: 0.85em;'>
🎓 西北工业大学2025年校级本科生建设项目资助 | Northwestern Polytechnical University
</p>
</div>
""")
with gr.Tabs() as tabs: with gr.Tabs() as tabs:
with gr.TabItem("时域分析 (Time Domain)", id=0): with gr.TabItem("时域分析 (Time Domain)", id=0):
with gr.Row(): with gr.Row():
@@ -581,7 +630,7 @@ with gr.Blocks(title="自动控制原理学习网站", css=custom_css) as demo:
with gr.Column(scale=1): with gr.Column(scale=1):
with gr.Group(): with gr.Group():
gr.Markdown("<div class='card-title'>🎚️ 调整系统增益</div>") gr.Markdown("<div class='card-title'>🎚️ 调整系统增益</div>")
log_k_slider_freq = gr.Slider(minimum=-1, maximum=3, value=1, step=0.01, label="对数增益 log10(K)") log_k_slider_freq = gr.Slider(minimum=-4, maximum=4, value=1, step=0.01, label="对数增益 log10(K)")
k_number_display_freq = gr.Number(value=10.0, label="增益 K (Gain)", interactive=False) k_number_display_freq = gr.Number(value=10.0, label="增益 K (Gain)", interactive=False)
with gr.Group(): with gr.Group():
@@ -688,7 +737,7 @@ with gr.Blocks(title="自动控制原理学习网站", css=custom_css) as demo:
with gr.TabItem("根轨迹 (Root Locus)", id=2): with gr.TabItem("根轨迹 (Root Locus)", id=2):
with gr.Row(): with gr.Row():
with gr.Column(scale=1): with gr.Column(scale=1):
gr.Markdown("### 1. 调整系统增益"); log_k_slider_rl = gr.Slider(minimum=-1, maximum=3, value=1, step=0.01, label="对数增益 log10(K)") gr.Markdown("### 1. 调整系统增益"); log_k_slider_rl = gr.Slider(minimum=-4, maximum=4, value=1, step=0.01, label="对数增益 log10(K)")
k_number_display = gr.Number(value=10.0, label="增益 K (Gain)", interactive=False); gr.Markdown("### 2. 当前增益下的闭环极点") k_number_display = gr.Number(value=10.0, label="增益 K (Gain)", interactive=False); gr.Markdown("### 2. 当前增益下的闭环极点")
rl_poles_display = gr.Textbox(label="Closed-Loop Pole Locations", lines=4, interactive=False) rl_poles_display = gr.Textbox(label="Closed-Loop Pole Locations", lines=4, interactive=False)
with gr.Column(scale=2): with gr.Column(scale=2):
@@ -1003,4 +1052,9 @@ with gr.Blocks(title="自动控制原理学习网站", css=custom_css) as demo:
if __name__ == "__main__": if __name__ == "__main__":
# 需要安装 aiohttp: pip install aiohttp # 需要安装 aiohttp: pip install aiohttp
demo.launch(debug=True)
demo.launch(
server_name="0.0.0.0", # 监听所有网络接口
server_port=7860, # 指定一个端口
share=False # 关闭Gradio的临时分享
)