Merge pull request 'bug-fix' (#10) from bug-fix into master

Reviewed-on: http://mkb.local:3000/yuysh/Manlink_Doc/pulls/10
This commit is contained in:
2025-08-25 13:31:55 +08:00
5 changed files with 118 additions and 189 deletions
+38 -74
View File
@@ -7,122 +7,86 @@ on:
jobs: jobs:
deploy: deploy:
# 只在PR被成功merge到master时运行
if: github.event.pull_request.merged == true && github.base_ref == 'master' if: github.event.pull_request.merged == true && github.base_ref == 'master'
runs-on: linux runs-on: linux
steps: steps:
# 第一步:获取master分支最新代码 # 第一步:更新主工作树
- name: Fetch latest master branch code - name: Update main worktree
run: | run: |
echo "=== Fetching latest master branch code ===" echo "=== Updating main worktree ==="
# 确保目录存在
if [ ! -d "/home/ly0kos/work/test_env" ]; then
echo "Cloning repository..."
git clone http://localhost:3000/yuysh/Manlink_Doc.git /home/ly0kos/work/test_env
fi
cd /home/ly0kos/work/test_env cd /home/ly0kos/work/test_env
# 清理任何未提交的更改
git reset --hard
git clean -fd
# 获取所有远程更新
git fetch --all --prune git fetch --all --prune
# 切换到master分支并获取最新代码
git checkout master git checkout master
git pull origin master --force git pull origin master
echo "✓ Latest master code fetched" echo "✓ Main worktree updated"
echo "Current commit: $(git log --oneline -1)"
# 第二步:复用生产虚拟环境 # 第二步:复用共享虚拟环境
- name: Reuse or update production Python environment - name: Reuse shared virtual environment
run: | run: |
echo "Setting up production Python environment" echo "=== Using shared virtual environment ==="
cd /home/ly0kos/work/test_env cd /home/ly0kos/work/test_env
source .venv-shared/bin/activate
# 检查虚拟环境是否存在 # 检查主分支的requirements.txt是否有更新
if [ ! -d ".venv-prod" ]; then
echo "Creating new production virtual environment..."
python -m venv .venv-prod
source .venv-prod/bin/activate
pip install --upgrade pip
# 安装基础依赖
pip install sphinx sphinx-rtd-theme
else
echo "Reusing existing production virtual environment..."
source .venv-prod/bin/activate
fi
# 检查并更新依赖
if [ -f "requirements.txt" ]; then if [ -f "requirements.txt" ]; then
echo "Checking for dependency updates in production..."
REQ_MOD_TIME=$(stat -c %Y requirements.txt 2>/dev/null || echo 0) REQ_MOD_TIME=$(stat -c %Y requirements.txt 2>/dev/null || echo 0)
VENV_MOD_TIME=$(cat .venv-prod/last_update.txt 2>/dev/null || echo 0) VENV_MOD_TIME=$(cat .venv-shared/last_update.txt 2>/dev/null || echo 0)
if [ $REQ_MOD_TIME -gt $VENV_MOD_TIME ]; then if [ $REQ_MOD_TIME -gt $VENV_MOD_TIME ]; then
echo "Production requirements updated, installing new dependencies..." echo "Master branch requirements updated, installing new dependencies..."
pip install -r requirements.txt pip install -r requirements.txt
echo $REQ_MOD_TIME > .venv-prod/last_update.txt echo $REQ_MOD_TIME > .venv-shared/last_update.txt
else
echo "No changes in production requirements, skipping installation"
fi fi
fi fi
# 显示环境信息 # 第三步:从主工作树构建文档
echo "Production environment ready:"
pip list | grep sphinx
# 第三步:从master分支构建文档
- name: Build documentation from master - name: Build documentation from master
run: | run: |
echo "=== Building production documentation from master ===" echo "=== Building production documentation ==="
cd /home/ly0kos/work/test_env cd /home/ly0kos/work/test_env
source .venv-prod/bin/activate source .venv-shared/bin/activate
# 清理旧构建
rm -rf build/ rm -rf build/
# 构建文档
sphinx-build -b html source build -v -j 4 sphinx-build -b html source build -v -j 4
echo "✓ Production build completed" echo "✓ Production build completed"
# 第四步:部署到Web服务器 # 第四步:部署到Web服务器
- name: Deploy to web server - name: Deploy to web server
run: | run: |
echo "=== Deploying to production web server ===" echo "=== Deploying to production ==="
cd /home/ly0kos/work/test_env cd /home/ly0kos/work/test_env
echo "[INFO] Removing old files..." rm -rf /var/www/docs_dev/*
sudo rm -rf /var/www/docs_dev/* cp -r build/* /var/www/docs_dev/
echo "[INFO] Copying new files..." chown -R www-data:www-data /var/www/docs_dev/
sudo cp -r build/* /var/www/docs_dev/ chmod -R 755 /var/www/docs_dev/
# 设置正确的文件权限 echo "✓ Documentation deployed"
sudo chown -R www-data:www-data /var/www/docs_dev/
sudo chmod -R 755 /var/www/docs_dev/
echo "✓ Documentation deployed to /var/www/docs_dev/" # 第五步:清理PR工作树
- name: Cleanup PR worktree
# 第五步:清理PR预览文件
- name: Cleanup PR previews
run: | run: |
echo "Cleaning up PR preview files for branch: ${{ github.head_ref }}" echo "=== Cleaning up PR worktree ==="
cd /home/ly0kos/work/test_env
# 清理预览文件(保留虚拟环境) WORKTREE_DIR="/home/ly0kos/work/test_env/worktrees/${{ github.head_ref }}"
preview_dir="/home/ly0kos/work/test_env/pr-builds/${{ github.head_ref }}" if [ -d "$WORKTREE_DIR" ]; then
if [ -d "$preview_dir" ]; then git worktree remove "$WORKTREE_DIR" --force
rm -rf "$preview_dir" echo "✓ Removed worktree for ${{ github.head_ref }}"
echo "Removed preview for PR branch: ${{ github.head_ref }}" fi
# 清理预览文件
PREVIEW_DIR="/home/ly0kos/work/test_env/pr-builds/${{ github.head_ref }}"
if [ -d "$PREVIEW_DIR" ]; then
rm -rf "$PREVIEW_DIR"
echo "✓ Removed preview for ${{ github.head_ref }}"
fi fi
# 第六步:验证部署 # 第六步:验证部署
- name: Verify deployment - name: Verify deployment
run: | run: |
echo "Production deployment completed successfully!" echo "Production deployment completed!"
echo "Web server contents:"
ls -la /var/www/docs_dev/ | head -10 ls -la /var/www/docs_dev/ | head -10
+72 -72
View File
@@ -11,108 +11,108 @@ jobs:
runs-on: linux runs-on: linux
steps: steps:
# 第一步:获取PR分支最新代码 # 第一步:设置主工作树和虚拟环境
- name: Fetch latest PR branch code - name: Setup main worktree and virtual environment
run: | run: |
echo "=== Fetching latest code for PR branch: ${{ github.head_ref }} ===" echo "=== Setting up main worktree ==="
# 如果目录不存在,克隆仓库 # 如果目录不存在,克隆仓库
if [ ! -d "/home/ly0kos/work/test_env" ]; then if [ ! -d "/home/ly0kos/work/test_env" ]; then
echo "Cloning repository..." echo "Cloning repository to main worktree..."
git clone http://localhost:3000/yuysh/Manlink_Doc.git /home/ly0kos/work/test_env git clone http://localhost:3000/yuysh/Manlink_Doc.git /home/ly0kos/work/test_env
fi
# 进入目录并获取最新代码
cd /home/ly0kos/work/test_env cd /home/ly0kos/work/test_env
# 清理任何未提交的更改 # 创建共享虚拟环境
git reset --hard python -m venv .venv-shared
git clean -fd source .venv-shared/bin/activate
# 获取所有远程分支和更新
git fetch --all --prune
# 切换到PR分支并获取最新代码
git checkout ${{ github.head_ref }}
git pull origin ${{ github.head_ref }} --force
echo "✓ Latest code fetched for branch: ${{ github.head_ref }}"
echo "Current commit: $(git log --oneline -1)"
# 第二步:复用或创建Python虚拟环境
- name: Reuse or update Python virtual environment
run: |
echo "Setting up Python environment for PR branch: ${{ github.head_ref }}"
cd /home/ly0kos/work/test_env
# 检查虚拟环境是否存在
if [ ! -d ".venv-pr" ]; then
echo "Creating new virtual environment..."
python -m venv .venv-pr
source .venv-pr/bin/activate
pip install --upgrade pip pip install --upgrade pip
# 安装基础依赖
pip install sphinx sphinx-rtd-theme pip install sphinx sphinx-rtd-theme
# 记录初始依赖状态
if [ -f "requirements.txt" ]; then
pip install -r requirements.txt
stat -c %Y requirements.txt > .venv-shared/last_update.txt
fi
else else
echo "Reusing existing virtual environment..." cd /home/ly0kos/work/test_env
source .venv-pr/bin/activate git fetch --all --prune
git checkout master
git pull origin master
fi fi
# 检查requirements.txt是否更新 echo "✓ Main worktree ready"
if [ -f "requirements.txt" ]; then
echo "Checking for dependency updates..." # 第二步:为PR分支创建工作树
# 获取requirements.txt的修改时间 - name: Create worktree for PR branch
REQ_MOD_TIME=$(stat -c %Y requirements.txt 2>/dev/null || echo 0) run: |
# 获取虚拟环境中记录的最后更新时间 echo "=== Creating worktree for PR branch: ${{ github.head_ref }} ==="
VENV_MOD_TIME=$(cat .venv-pr/last_update.txt 2>/dev/null || echo 0) cd /home/ly0kos/work/test_env
# 清理可能存在的旧工作树
WORKTREE_DIR="/home/ly0kos/work/test_env/worktrees/${{ github.head_ref }}"
if [ -d "$WORKTREE_DIR" ]; then
echo "Removing existing worktree..."
git worktree remove "$WORKTREE_DIR" --force 2>/dev/null || true
rm -rf "$WORKTREE_DIR" 2>/dev/null || true
fi
# 创建新的工作树
mkdir -p "/home/ly0kos/work/test_env/worktrees"
git fetch origin ${{ github.head_ref }}:${{ github.head_ref }} --force
git worktree add "/home/ly0kos/work/test_env/worktrees/${{ github.head_ref }}" ${{ github.head_ref }} --force
echo "✓ Worktree created at: /home/ly0kos/work/test_env/worktrees/${{ github.head_ref }}"
# 第三步:复用共享虚拟环境并检查依赖更新
- name: Reuse shared virtual environment
run: |
echo "=== Reusing shared virtual environment ==="
cd /home/ly0kos/work/test_env
WORKTREE_DIR="/home/ly0kos/work/test_env/worktrees/${{ github.head_ref }}"
# 使用主工作树的共享虚拟环境
source .venv-shared/bin/activate
# 检查PR分支的requirements.txt是否有更新
if [ -f "$WORKTREE_DIR/requirements.txt" ]; then
echo "Checking for dependency updates in PR branch..."
REQ_MOD_TIME=$(stat -c %Y "$WORKTREE_DIR/requirements.txt" 2>/dev/null || echo 0)
VENV_MOD_TIME=$(cat .venv-shared/last_update.txt 2>/dev/null || echo 0)
if [ $REQ_MOD_TIME -gt $VENV_MOD_TIME ]; then if [ $REQ_MOD_TIME -gt $VENV_MOD_TIME ]; then
echo "Requirements updated, installing new dependencies..." echo "PR branch requirements updated, installing new dependencies..."
pip install -r requirements.txt pip install -r "$WORKTREE_DIR/requirements.txt"
# 记录更新时间 echo $REQ_MOD_TIME > .venv-shared/last_update.txt
echo $REQ_MOD_TIME > .venv-pr/last_update.txt echo "Dependencies updated from PR branch"
else else
echo "No changes in requirements, skipping dependency installation" echo "No changes in requirements, using existing packages"
fi fi
else
echo "No requirements.txt found, using existing packages"
fi fi
# 显示当前环境信息
echo "Python: $(python --version)" echo "Python: $(python --version)"
echo "Pip: $(pip --version)" echo "Sphinx: $(sphinx-build --version 2>/dev/null || echo 'Not installed')"
echo "Installed packages:"
pip list | grep sphinx
# 第步:构建文档(从PR分支) # 第步:在工作树中构建文档
- name: Build documentation from PR branch - name: Build documentation in worktree
run: | run: |
echo "=== Building documentation from PR branch: ${{ github.head_ref }} ===" echo "=== Building documentation in worktree ==="
cd /home/ly0kos/work/test_env cd /home/ly0kos/work/test_env
source .venv-pr/bin/activate WORKTREE_DIR="/home/ly0kos/work/test_env/worktrees/${{ github.head_ref }}"
source .venv-shared/bin/activate
# 确保源目录存在
if [ ! -d "source" ]; then
echo "Error: source directory not found!"
exit 1
fi
# 清理旧构建
rm -rf build/
# 构建文档 # 构建文档
sphinx-build -b html source build -v -j 4 cd "$WORKTREE_DIR"
sphinx-build -b html source "$WORKTREE_DIR/build" -v -j 4
# 将构建结果复制到预览位置 # 复制到预览位置
mkdir -p /home/ly0kos/work/test_env/pr-builds/ mkdir -p /home/ly0kos/work/test_env/pr-builds/
rm -rf /home/ly0kos/work/test_env/pr-builds/${{ github.head_ref }} rm -rf /home/ly0kos/work/test_env/pr-builds/${{ github.head_ref }}
cp -r build /home/ly0kos/work/test_env/pr-builds/${{ github.head_ref }} cp -r "$WORKTREE_DIR/build" /home/ly0kos/work/test_env/pr-builds/${{ github.head_ref }}
echo "✓ Build completed for PR branch: ${{ github.head_ref }}" echo "✓ Build completed for PR branch: ${{ github.head_ref }}"
# 第步:验证构建结果 # 第步:验证构建结果
- name: Verify build - name: Verify build
run: | run: |
echo "Build output for PR ${{ github.head_ref }}:" echo "Build output for PR ${{ github.head_ref }}:"
ls -la /home/ly0kos/work/test_env/pr-builds/${{ github.head_ref }}/ | head -10 ls -la /home/ly0kos/work/test_env/pr-builds/${{ github.head_ref }}/ | head -10
echo "Preview available at: /home/ly0kos/work/test_env/pr-builds/${{ github.head_ref }}/index.html"
+1 -1
View File
@@ -19,4 +19,4 @@
P/N:JC124M060 P/N:JC124M060
::: :::
[^1] Not Applicable for 1A Range, 1A Range Only have Postive and source [^1]: Not Applicable for 1A Range, 1A Range Only have Postive and source
+1 -1
View File
@@ -2,7 +2,7 @@
|Specification|Value|Condition| |Specification|Value|Condition|
|---|---|---| |---|---|---|
|Voltage Range|-8V to 13V|w/o Current Clamp [^1]| |Voltage Range|-8V to 13V|w/o Current Clamp|
|Current Clamp|±5uA,±20uA,±200uA,±2mA,±60mA,1A|| |Current Clamp|±5uA,±20uA,±200uA,±2mA,±60mA,1A||
|DC Accuracy|0.1%|After Calibration| |DC Accuracy|0.1%|After Calibration|
|Linearity Error|±0.0002V|| |Linearity Error|±0.0002V||
-35
View File
@@ -1,35 +0,0 @@
flowchart TD
n1["光耦"] --> n2["Pin5->Pin4存在二极管"]
n3["DPS小档位无法输出大电压"] --> n1 & n4["运放"]
n4 --> n6["In+/In-电压范围为Vdd~Vss,超出范围则会被内部二极管钳位"] & n12["Vout不超过Vdd"]
n6 --> n7@{ label: "<span style=\"background-color:\">In+通过1K电阻连至光耦1@Pin4</span>" }
n7 --> n8@{ label: "Force/MeasH-&gt;IN+<br style=\"--tw-scale-x:\">Pin5-&gt;Pin4" }
n10["Vout+串联肖特基二极管至光耦2@Pin4"] --> n9@{ label: "Force/MeasH-&gt;Vout<br style=\"--tw-scale-x:\">Pin5-&gt;Pin4" }
n2 --> n11@{ label: "<span style=\"background-color:\">如果Pin5电压&gt;Pin4电压</span>" }
n11 --> n5["二极管导通,存在电流通路"]
n12 --> n10
n8 --> n13["小档位Force 13V"]
n9 --> n13
n13 --> n14@{ label: "Force=13<br style=\"--tw-scale-x:\">Vout=9.6V" } & n15@{ label: "Force=13<br style=\"--tw-scale-x:\">IN+ = 9V<br>" }
n15 --> n11
n14 --> n11
n5 --> n18["ForceV ClampI"]
n18 --> n20["电流通过1K电阻"] & n21["肖特基二极管反向导通"]
n20 -- "<span style=background-color:>5uA/20uA/200uA Clamp</span>" --> n24["Force电压小于期望值"]
n21 -- "<span style=background-color: rgb(255, 255, 255);>2mA Clamp</span>" --> n24
n1@{ shape: rounded}
n3@{ shape: rounded}
n4@{ shape: rounded}
n6@{ shape: rect}
n12@{ shape: rect}
n7@{ shape: rect}
n8@{ shape: rect}
n10@{ shape: rect}
n9@{ shape: rect}
n11@{ shape: diam}
n5@{ shape: rounded}
n13@{ shape: rounded}
n14@{ shape: rect}
n15@{ shape: rect}
n20@{ shape: rounded}
n21@{ shape: rounded}