Compare commits
13 Commits
v1.0
...
feature/we
| Author | SHA1 | Date | |
|---|---|---|---|
| 537cbaab9d | |||
| c8286b7c4c | |||
| afd85e56eb | |||
| 71360a47e4 | |||
| d82402924e | |||
| de7fd17f76 | |||
| 7a71284199 | |||
| 5a9722a92b | |||
| 6927594f0f | |||
| bda47e10e9 | |||
| bd781a19ce | |||
| adea31758d | |||
| e764586cc7 |
314
.gitignore
vendored
314
.gitignore
vendored
@ -1,64 +1,276 @@
|
||||
# Python
|
||||
**/__pycache__/
|
||||
# ---> Qt
|
||||
# C++ objects and libs
|
||||
*.slo
|
||||
*.lo
|
||||
*.o
|
||||
*.a
|
||||
*.la
|
||||
*.lai
|
||||
*.so
|
||||
*.so.*
|
||||
*.dll
|
||||
*.dylib
|
||||
|
||||
# Qt-es
|
||||
object_script.*.Release
|
||||
object_script.*.Debug
|
||||
*_plugin_import.cpp
|
||||
/.qmake.cache
|
||||
/.qmake.stash
|
||||
*.pro.user
|
||||
*.pro.user.*
|
||||
*.qbs.user
|
||||
*.qbs.user.*
|
||||
*.moc
|
||||
moc_*.cpp
|
||||
moc_*.h
|
||||
qrc_*.cpp
|
||||
ui_*.h
|
||||
*.qmlc
|
||||
*.jsc
|
||||
Makefile*
|
||||
*build-*
|
||||
*.qm
|
||||
*.prl
|
||||
|
||||
# Qt unit tests
|
||||
target_wrapper.*
|
||||
|
||||
# QtCreator
|
||||
*.autosave
|
||||
|
||||
# QtCreator Qml
|
||||
*.qmlproject.user
|
||||
*.qmlproject.user.*
|
||||
|
||||
# QtCreator CMake
|
||||
CMakeLists.txt.user*
|
||||
|
||||
# QtCreator 4.8< compilation database
|
||||
compile_commands.json
|
||||
|
||||
# QtCreator local machine specific files for imported projects
|
||||
*creator.user*
|
||||
|
||||
*_qmlcache.qrc
|
||||
|
||||
# ---> Python
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# IDEs and editors
|
||||
.idea/
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
cover/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
.pybuilder/
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
# For a library or package, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# .python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# UV
|
||||
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
#uv.lock
|
||||
|
||||
# poetry
|
||||
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
||||
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
||||
# commonly ignored for libraries.
|
||||
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
||||
#poetry.lock
|
||||
|
||||
# pdm
|
||||
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
||||
#pdm.lock
|
||||
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
||||
# in version control.
|
||||
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
||||
.pdm.toml
|
||||
.pdm-python
|
||||
.pdm-build/
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
||||
|
||||
# pytype static type analyzer
|
||||
.pytype/
|
||||
|
||||
# Cython debug symbols
|
||||
cython_debug/
|
||||
|
||||
# PyCharm
|
||||
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
||||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
|
||||
# Ruff stuff:
|
||||
.ruff_cache/
|
||||
|
||||
# PyPI configuration file
|
||||
.pypirc
|
||||
|
||||
# 忽略.vscode文件夹
|
||||
.vscode/
|
||||
*.suo
|
||||
# *.ntvs*
|
||||
# *.njsproj
|
||||
# # *.sln
|
||||
# *.sw?
|
||||
.VSCodeCounter
|
||||
|
||||
# OS generated files
|
||||
# .DS_Store
|
||||
# .DS_Store?
|
||||
# ._*
|
||||
# .Spotlight-V100
|
||||
# .Trashes
|
||||
# ehthumbs.db
|
||||
# Thumbs.db
|
||||
# 忽略工作区文件
|
||||
*.code-workspace
|
||||
.DS_Store
|
||||
|
||||
# Logs
|
||||
# 忽略 .idea
|
||||
.idea/
|
||||
|
||||
# 忽略python缓存文件
|
||||
*/__pycache__
|
||||
*.py[cod]
|
||||
|
||||
# 忽略日志文件
|
||||
log/
|
||||
*.log
|
||||
*.log.*
|
||||
|
||||
# 忽略测试文件
|
||||
test.py
|
||||
|
||||
# Temporary files
|
||||
# *.tmp
|
||||
# *.temp
|
||||
# .cache/
|
||||
# 忽略配置文件
|
||||
config.json
|
||||
|
||||
# Test coverage
|
||||
# .coverage
|
||||
# .coverage.*
|
||||
# coverage.xml
|
||||
# 忽略下载文件夹
|
||||
download/
|
||||
|
||||
# Debug
|
||||
# *.pyc
|
||||
# *.pyd
|
||||
# *.so
|
||||
# *.dll
|
||||
# *.exe
|
||||
|
||||
# Runtime data
|
||||
# pids
|
||||
# *.pid
|
||||
# *.seed
|
||||
# *.pid.lock
|
||||
|
||||
# Project specific
|
||||
# test.py
|
||||
# test2.py
|
||||
# test3.py
|
||||
# test6.py
|
||||
# TEST3.py
|
||||
# workflow_test.py
|
||||
# MvFGSdkLog/
|
||||
# MvSDKLog/
|
||||
# Trace/com_pose.txt
|
||||
# Trace/com_pose2.txt
|
||||
# 忽略构建文件夹
|
||||
build/
|
||||
dist/
|
||||
PyQt_Fluent_Widgets.egg-info/
|
||||
PySide6_Fluent_Widgets.egg-info/
|
||||
PyQt6_Fluent_Widgets.egg-info/
|
||||
PySide2_Fluent_Widgets.egg-info/
|
||||
/COM/__pycache__
|
||||
/__pycache__
|
||||
/CU/__pycache__
|
||||
/EMV/__pycache__
|
||||
/Model/__pycache__
|
||||
/Trace/__pycache__
|
||||
/Util/__pycache__
|
||||
/view/__pycache__
|
||||
/log/log.log
|
||||
|
||||
3
.idea/.gitignore
generated
vendored
3
.idea/.gitignore
generated
vendored
@ -1,3 +0,0 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
12
.idea/ailai.iml
generated
12
.idea/ailai.iml
generated
@ -1,12 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
<component name="PyDocumentationSettings">
|
||||
<option name="format" value="PLAIN" />
|
||||
<option name="myDocStringFormat" value="Plain" />
|
||||
</component>
|
||||
</module>
|
||||
6
.idea/inspectionProfiles/profiles_settings.xml
generated
6
.idea/inspectionProfiles/profiles_settings.xml
generated
@ -1,6 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
||||
4
.idea/misc.xml
generated
4
.idea/misc.xml
generated
@ -1,4 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="ailai" project-jdk-type="Python SDK" />
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
8
.idea/modules.xml
generated
@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/ailai.iml" filepath="$PROJECT_DIR$/.idea/ailai.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
Binary file not shown.
Binary file not shown.
@ -268,7 +268,7 @@ class Feeding(QObject):
|
||||
|
||||
# --- 新增: 用于码垛模式的投料点索引 ---
|
||||
self.current_drop_index = 0
|
||||
self.drop_manager = DropPositionManager()
|
||||
# self.drop_manager = DropPositionManager()
|
||||
pass
|
||||
|
||||
def close_feed(self):
|
||||
|
||||
@ -75,7 +75,7 @@ class FeedPosition:
|
||||
self.position = position
|
||||
|
||||
class FeedLine:
|
||||
def __init__(self, id, name, feed_positions:list,remain_count:int):
|
||||
def __init__(self, id, name, feed_positions:list,remain_count:int,drop_manage:DropPositionManager):
|
||||
self.feed_positions = copy.deepcopy(feed_positions)
|
||||
|
||||
self.feeding2end_pos_index = 0
|
||||
@ -83,7 +83,7 @@ class FeedLine:
|
||||
self.start2take_pos_index = 0
|
||||
self.name = name
|
||||
self.id = id
|
||||
self.drop_manager = DropPositionManager()
|
||||
self.drop_manager = drop_manage
|
||||
# 初始化各个阶段的位置列表
|
||||
self.feeding_to_end = []
|
||||
|
||||
@ -479,7 +479,7 @@ class Feeding(QObject):
|
||||
self.next_position()
|
||||
return
|
||||
#初始点无论如何先打开夹爪
|
||||
self.relay_controller.close(clamp=True)
|
||||
if self.relay_controller.close(clamp=True):
|
||||
#重新抓去信号料带
|
||||
self.take_sensor_signal=False
|
||||
self.relay_controller.sensor2_ready=True
|
||||
@ -507,6 +507,9 @@ class Feeding(QObject):
|
||||
# self.take_photo_sigal.emit()
|
||||
self.next_position()
|
||||
self.log_signal.emit(logging.INFO, Constant.str_sys_runing2)
|
||||
else:
|
||||
self.log_signal.emit(logging.ERROR, Constant.str_clamp_open_error)
|
||||
time.sleep(2)
|
||||
# self.feedStatus = FeedStatus.FTake
|
||||
|
||||
elif self.feedStatus == FeedStatus.FTake:
|
||||
@ -534,8 +537,11 @@ class Feeding(QObject):
|
||||
# 移动到下一个抓取点
|
||||
# 更新丢包点: 如果需要根据放置情况调整下次抓取
|
||||
|
||||
self.relay_controller.open(clamp=True)
|
||||
if self.relay_controller.open(clamp=True):
|
||||
self.next_position(self.is_reverse)
|
||||
else:
|
||||
self.log_signal.emit(logging.ERROR, Constant.str_clamp_close_error)
|
||||
time.sleep(2)
|
||||
|
||||
#self.feedConfig.feedLine.set_drop_position(real_position)#我想在这里读取我的一个ini文件值里面有很多个drop点,每一次索引递增的点
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
64
CU/drop.py
64
CU/drop.py
@ -8,7 +8,7 @@ import Constant
|
||||
|
||||
|
||||
class DropPositionManager:
|
||||
def __init__(self, config_path=Constant.dropLine_set_file):
|
||||
def __init__(self, config_path):
|
||||
self.config_path = config_path
|
||||
self.config = configparser.ConfigParser()
|
||||
self._load_config()
|
||||
@ -167,10 +167,13 @@ class DropPositionManager:
|
||||
return None
|
||||
|
||||
|
||||
|
||||
#region 前端UI编辑码垛点位调用方法
|
||||
def load_path_points(self,lineid: int) ->Optional[LineModel]:
|
||||
"""根据lineid加载所有码垛的路径信息"""
|
||||
#默认码垛的lineid从10开始
|
||||
if self.config_path==Constant.dropLine_set_file_35:
|
||||
_lineid=lineid+11
|
||||
else:
|
||||
_lineid=lineid+10
|
||||
line_model = LineModel(_lineid)
|
||||
line_model.line_category = 2
|
||||
@ -255,10 +258,13 @@ class DropPositionManager:
|
||||
def save_path_points(self, line_model: LineModel):
|
||||
"""根据lineid保存所有码垛的路径信息"""
|
||||
#默认码垛的lineid从10开始,保存的时候减一
|
||||
if self.config_path==Constant.dropLine_set_file_35:
|
||||
_lineid=line_model.id-11
|
||||
else:
|
||||
_lineid=line_model.id-10
|
||||
if _lineid<=0:
|
||||
return
|
||||
self.config.read(Constant.dropLine_set_file, encoding='utf-8')
|
||||
self.config.read(self.config_path, encoding='utf-8')
|
||||
# 查找主表 DropLineX
|
||||
main_section = f"{Constant.dropLine_set_section}{_lineid}"
|
||||
if not self.config.has_section(main_section):
|
||||
@ -267,7 +273,7 @@ class DropPositionManager:
|
||||
self.config.set(main_section, "id", str(_lineid))
|
||||
_current_reset_index=1
|
||||
_current_mid_index=1
|
||||
_current_drop_section_val=self._current_drop_section[main_section]
|
||||
_current_drop_section_val=self._get_max_drop_section()
|
||||
# 保存每个DropPoints
|
||||
for i, pos in enumerate(line_model.positions):
|
||||
if pos.lineId == _lineid or pos.lineId == line_model.id:
|
||||
@ -300,49 +306,25 @@ class DropPositionManager:
|
||||
#保存数据
|
||||
pos.save_position_model(self.config)
|
||||
|
||||
with open(Constant.dropLine_set_file, 'w', encoding='utf-8') as f:
|
||||
with open(self.config_path, 'w', encoding='utf-8') as f:
|
||||
self.config.write(f)
|
||||
|
||||
def del_drop_point(self,section):
|
||||
self.config.read(Constant.dropLine_set_file, encoding = 'utf-8')
|
||||
self.config.read(self.config_path, encoding = 'utf-8')
|
||||
self.config.remove_section(section)
|
||||
with open(Constant.dropLine_set_file, 'w', encoding='utf-8') as f:
|
||||
with open(self.config_path, 'w', encoding='utf-8') as f:
|
||||
self.config.write(f)
|
||||
|
||||
def _get_point_debug_info(manager, pos, model):
|
||||
config = manager.config
|
||||
for sec in config.sections():
|
||||
if sec.startswith("DropPoints"):
|
||||
try:
|
||||
x, y, z = config.getfloat(sec, "x"), config.getfloat(sec, "y"), config.getfloat(sec, "z")
|
||||
if abs(x - pos.X) < 0.001 and abs(y - pos.Y) < 0.001 and abs(z - pos.Z) < 0.001:
|
||||
point_id = config.getint(sec, "id")
|
||||
return f"📌 DropPoints{point_id} | id={point_id}"
|
||||
except: pass
|
||||
|
||||
elif sec.startswith("DropMidPoint"):
|
||||
try:
|
||||
parts = sec.split('-')
|
||||
if len(parts) != 2: continue
|
||||
point_id = int(''.join(filter(str.isdigit, parts[0])))
|
||||
level = int(parts[1])
|
||||
x, y, z = config.getfloat(sec, "x"), config.getfloat(sec, "y"), config.getfloat(sec, "z")
|
||||
if abs(x - pos.X) < 0.001 and abs(y - pos.Y) < 0.001 and abs(z - pos.Z) < 0.001:
|
||||
return f"📍 DropMidPoint{point_id}-{level} | id={point_id}, level={level}"
|
||||
except: pass
|
||||
|
||||
elif sec.startswith("ResetPoint"):
|
||||
try:
|
||||
parts = sec.split('-')
|
||||
if len(parts) != 2: continue
|
||||
point_id = int(''.join(filter(str.isdigit, parts[0])))
|
||||
level = int(parts[1])
|
||||
x, y, z = config.getfloat(sec, "x"), config.getfloat(sec, "y"), config.getfloat(sec, "z")
|
||||
if abs(x - pos.X) < 0.001 and abs(y - pos.Y) < 0.001 and abs(z - pos.Z) < 0.001:
|
||||
return f"🔙 ResetPoint{point_id}-{level} | id={point_id}, level={level}"
|
||||
except: pass
|
||||
return "❓ 未知点位"
|
||||
|
||||
def _get_max_drop_section(self):
|
||||
"""获取最大的DropPoints序号"""
|
||||
max_section = 1
|
||||
for section in self.config.sections():
|
||||
if section.startswith("DropPoints"):
|
||||
num_part = int(section.replace("DropPoints", "0"))
|
||||
if num_part > max_section:
|
||||
max_section = num_part
|
||||
return max_section
|
||||
#endregion
|
||||
# 测试
|
||||
if __name__ == "__main__":
|
||||
# manager = DropPositionManager("drop.ini")
|
||||
|
||||
Binary file not shown.
@ -3,7 +3,7 @@ import os
|
||||
# 调试变量
|
||||
Debug = False # 控制不加图像的Fphoto False是不加
|
||||
Debug1 = False # 打印很多日志节点
|
||||
DebugPosition = False # 调试位置,关闭机器人和传感器及判断
|
||||
DebugPosition = True # 调试位置,关闭机器人和传感器及判断
|
||||
# Debug2 = False
|
||||
feedStatus = True #feedStatus的状态打印
|
||||
|
||||
@ -22,6 +22,7 @@ dropLine_set_section = 'DropLine'
|
||||
position_set_section = 'Position'
|
||||
feedLine_set_file = f'.{os.sep}Config{os.sep}FeedLine.ini'
|
||||
dropLine_set_file = f'.{os.sep}Config{os.sep}drop.ini'
|
||||
dropLine_set_file_35 = f'.{os.sep}Config{os.sep}drop-35.ini'
|
||||
MAX_Position_num = 40
|
||||
MAX_Line_num = 10
|
||||
set_ini = 'Seting.ini'
|
||||
@ -104,7 +105,8 @@ str_tcp_connect_no_reply = '无回复'
|
||||
str_tcp_connect_error = 'tcp连接错误'
|
||||
str_tcp_reconnect = '重连中'
|
||||
str_sys_json_error = 'json解析错误'
|
||||
|
||||
str_clamp_open_error = '夹爪打开失败'
|
||||
str_clamp_close_error = '夹爪关闭失败'
|
||||
|
||||
str_sys_runing = '运行到这里了!'
|
||||
str_sys_runing1 = '运行到这里2! '
|
||||
|
||||
328
EMV/EMV.py
328
EMV/EMV.py
@ -36,6 +36,7 @@ class RelayController(QObject):
|
||||
self.sensor_stable_duration = 1.0 # 传感器状态稳定检测时间(秒)
|
||||
self.sensor_max_attempts = 3 # 连续检测次数达到此值判定有效
|
||||
self.sensor1_debounce_time = 1.0 # 传感器1防抖时间(秒)
|
||||
self.sensor2_debounce_time = 3.0 # 袋尾检测3秒有效信号
|
||||
|
||||
# ===================== 网络与设备映射 =====================
|
||||
self.host = host
|
||||
@ -113,6 +114,7 @@ class RelayController(QObject):
|
||||
|
||||
self.sensor2_ready = False #默认不打开
|
||||
self.motor_stopped_by_sensor2 = True
|
||||
self.is_drop_35=False #是否是35码
|
||||
|
||||
# ===================== 基础通信方法 =====================
|
||||
def send_command(self, command_hex, retry_count=2, source='unknown'):
|
||||
@ -127,7 +129,7 @@ class RelayController(QObject):
|
||||
sock.connect((self.host, self.port))
|
||||
sock.send(byte_data)
|
||||
response = sock.recv(1024)
|
||||
hex_response = binascii.hexlify(response).decode('utf-8')
|
||||
# hex_response = binascii.hexlify(response).decode('utf-8')
|
||||
#if source == 'sensor':
|
||||
#print(f"[传感器响应] {hex_response}")
|
||||
#elif source == 'device':
|
||||
@ -136,13 +138,14 @@ class RelayController(QObject):
|
||||
#print(f"[通信响应] {hex_response}")
|
||||
return response
|
||||
except Exception as e:
|
||||
print(f"网络继电器通信错误 ({source}): {e}, 尝试重连... ({attempt + 1}/{retry_count})")
|
||||
# print(f"网络继电器通信错误 ({source}): {e}, 尝试重连... ({attempt + 1}/{retry_count})")
|
||||
self.log_signal.emit(logging.INFO,f"网络继电器通信错误 ({source}): {e}, 尝试重连... ({attempt + 1}/{retry_count})")
|
||||
time.sleep(5)
|
||||
self.trigger_alarm()
|
||||
return None
|
||||
|
||||
def trigger_alarm(self):
|
||||
print("警告:网络继电器连续多次通信失败,请检查设备连接!")
|
||||
self.log_signal.emit(logging.ERROR,"警告:网络继电器连续多次通信失败,请检查设备连接!")
|
||||
|
||||
# ===================== 状态读取方法 =====================
|
||||
def get_all_device_status(self, command_type='devices'):
|
||||
@ -186,6 +189,7 @@ class RelayController(QObject):
|
||||
|
||||
if response and len(response) >= 10:
|
||||
hex_response = binascii.hexlify(response).decode('utf-8')
|
||||
|
||||
# print(f"[原始响应][{command_type}] {hex_response}")
|
||||
|
||||
# 假设传感器数据从第 9 字节开始,长度为 2 字节
|
||||
@ -247,7 +251,63 @@ class RelayController(QObject):
|
||||
time.sleep(self.sensor2_loop_delay)
|
||||
return False
|
||||
|
||||
def is_valid_sensor(self,sensor_name):
|
||||
"""
|
||||
检查传感器状态是否有效
|
||||
参数:
|
||||
sensor_name: 传感器名称
|
||||
返回:
|
||||
True: 传感器状态有效
|
||||
False: 传感器状态无效
|
||||
"""
|
||||
responses = self.get_all_sensor_responses('sensors')
|
||||
response = responses.get(sensor_name)
|
||||
|
||||
if not response:
|
||||
print(f"[警告] 无法获取 {sensor_name} 的响应,尝试重试...")
|
||||
return False
|
||||
else:
|
||||
temp_status_code = self.parse_status_code(response)
|
||||
if temp_status_code in self.required_codes_1:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def is_valid_sensor_signal_stable(self, sensor_name, detection_duration=3.0, stability_duration=2.5, check_interval=0.1):
|
||||
"""
|
||||
检测在指定时间窗口内是否存在持续稳定的有效信号
|
||||
参数:
|
||||
sensor_name: 传感器名称
|
||||
detection_duration: 总检测时间窗口(秒),默认为3秒
|
||||
stability_duration: 信号需要持续稳定的时间(秒),默认为2.5秒
|
||||
check_interval: 检测间隔(秒),默认为0.1秒
|
||||
|
||||
返回:
|
||||
True: 在时间窗口内检测到持续稳定的有效信号
|
||||
False: 未检测到持续稳定的有效信号
|
||||
"""
|
||||
stable_start_time = None # 记录首次检测到有效信号的时间
|
||||
start_time = time.time()
|
||||
if not self.is_valid_sensor(sensor_name):
|
||||
return False # 传感器状态无效,返回
|
||||
else:
|
||||
stable_start_time = time.time() # 首次检测到有效信号
|
||||
time.sleep(check_interval)
|
||||
|
||||
while time.time() - start_time < detection_duration:
|
||||
temp_is_valid = self.is_valid_sensor(sensor_name)
|
||||
if temp_is_valid:
|
||||
if time.time() - stable_start_time >= stability_duration:
|
||||
return True # 信号持续稳定达到要求时间
|
||||
else:
|
||||
stable_start_time = None # 信号不稳定,重置计时
|
||||
time.sleep(check_interval)
|
||||
return False
|
||||
|
||||
def is_valid_sensor2_status_lost(self, sensor_name):
|
||||
"""
|
||||
检查传感器2是否丢失信号
|
||||
"""
|
||||
stable_count = 0
|
||||
_try_nums=5 # 尝试次数
|
||||
for _ in range(_try_nums):
|
||||
@ -269,49 +329,104 @@ class RelayController(QObject):
|
||||
return False
|
||||
|
||||
# ===================== 动作控制方法 =====================
|
||||
def open(self, conveyor1=False, pusher=False, conveyor2=False, clamp=False, pusher1=False, conveyor2_reverse=False):
|
||||
if Constant.DebugPosition:
|
||||
return
|
||||
def open(self, conveyor1=False, pusher=False, conveyor2=False, clamp=False, pusher1=False, conveyor2_reverse=False)->bool:
|
||||
"""将if改成elif,一次只能打开一个设备,否则会造成延时sleep时间不一致问题。并返回成功核验"""
|
||||
loc_ret=False
|
||||
loc_reponse=None
|
||||
loc_send_command=None
|
||||
status = self.get_all_device_status()
|
||||
if conveyor1 and not status.get(self.CONVEYOR1, False):
|
||||
self.send_command(self.valve_commands[self.CONVEYOR1]['open'])
|
||||
time.sleep(self.delay_conveyor)
|
||||
if pusher and not status.get(self.PUSHER, False):
|
||||
self.send_command(self.valve_commands[self.PUSHER]['open'])
|
||||
time.sleep(self.delay_pusher)
|
||||
if conveyor2 and not status.get(self.CONVEYOR2, False):
|
||||
self.send_command(self.valve_commands[self.CONVEYOR2]['open'])
|
||||
time.sleep(self.delay_conveyor)
|
||||
if clamp and not status.get(self.CLAMP, False):
|
||||
self.send_command(self.valve_commands[self.CLAMP]['open'])
|
||||
time.sleep(self.delay_clamp)
|
||||
if pusher1 and not status.get(self.PUSHER1, False):
|
||||
self.send_command(self.valve_commands[self.PUSHER1]['open'])
|
||||
time.sleep(self.delay_pusher)
|
||||
if conveyor2_reverse:
|
||||
self.send_command(self.valve_commands[self.CONVEYOR2_REVERSE]['open'])
|
||||
time.sleep(self.delay_conveyor)
|
||||
|
||||
def close(self, conveyor1=False, pusher=False, conveyor2=False, clamp=False, pusher1=False, conveyor2_reverse=False):
|
||||
if conveyor1:
|
||||
self.send_command(self.valve_commands[self.CONVEYOR1]['close'])
|
||||
if not status.get(self.CONVEYOR1, False):
|
||||
loc_send_command=self.valve_commands[self.CONVEYOR1]['open']
|
||||
loc_reponse=self.send_command(loc_send_command)
|
||||
time.sleep(self.delay_conveyor)
|
||||
else:
|
||||
loc_ret=True
|
||||
elif pusher:
|
||||
if not status.get(self.PUSHER, False):
|
||||
loc_send_command=self.valve_commands[self.PUSHER]['open']
|
||||
loc_reponse=self.send_command(loc_send_command)
|
||||
time.sleep(self.delay_pusher)
|
||||
else:
|
||||
loc_ret=True
|
||||
elif conveyor2:
|
||||
if not status.get(self.CONVEYOR2, False):
|
||||
loc_send_command=self.valve_commands[self.CONVEYOR2]['open']
|
||||
loc_reponse=self.send_command(loc_send_command)
|
||||
time.sleep(self.delay_conveyor)
|
||||
else:
|
||||
loc_ret=True
|
||||
elif clamp:
|
||||
if not status.get(self.CLAMP, False):
|
||||
loc_send_command=self.valve_commands[self.CLAMP]['open']
|
||||
loc_reponse=self.send_command(loc_send_command)
|
||||
time.sleep(self.delay_clamp)
|
||||
else:
|
||||
loc_ret=True
|
||||
elif pusher1:
|
||||
if not status.get(self.PUSHER1, False):
|
||||
loc_send_command=self.valve_commands[self.PUSHER1]['open']
|
||||
loc_reponse=self.send_command(loc_send_command)
|
||||
time.sleep(self.delay_pusher)
|
||||
else:
|
||||
loc_ret=True
|
||||
elif conveyor2_reverse:
|
||||
if not status.get(self.CONVEYOR2_REVERSE, False):
|
||||
loc_send_command=self.valve_commands[self.CONVEYOR2_REVERSE]['open']
|
||||
loc_reponse=self.send_command(loc_send_command)
|
||||
time.sleep(self.delay_conveyor)
|
||||
else:
|
||||
loc_ret=True
|
||||
|
||||
|
||||
if loc_reponse and len(loc_reponse) >= 10:
|
||||
lol_hex_response = binascii.hexlify(response).decode('utf-8')
|
||||
if lol_hex_response == loc_send_command:
|
||||
loc_ret=True
|
||||
|
||||
if Constant.DebugPosition:
|
||||
loc_ret=True
|
||||
return loc_ret
|
||||
|
||||
|
||||
def close(self, conveyor1=False, pusher=False, conveyor2=False, clamp=False, pusher1=False, conveyor2_reverse=False)->bool:
|
||||
loc_ret=False
|
||||
loc_reponse=None
|
||||
loc_send_command=None
|
||||
if conveyor1:
|
||||
loc_send_command=self.valve_commands[self.CONVEYOR1]['close']
|
||||
loc_reponse=self.send_command(loc_send_command)
|
||||
time.sleep(self.delay_conveyor)
|
||||
if pusher:
|
||||
self.send_command(self.valve_commands[self.PUSHER]['close'])
|
||||
loc_send_command=self.valve_commands[self.PUSHER]['close']
|
||||
loc_reponse=self.send_command(loc_send_command)
|
||||
time.sleep(self.delay_pusher)
|
||||
if conveyor2:
|
||||
self.send_command(self.valve_commands[self.CONVEYOR2]['close'])
|
||||
loc_send_command=self.valve_commands[self.CONVEYOR2]['close']
|
||||
loc_reponse=self.send_command(loc_send_command)
|
||||
time.sleep(self.delay_conveyor)
|
||||
if clamp:
|
||||
self.send_command(self.valve_commands[self.CLAMP]['close'])
|
||||
loc_send_command=self.valve_commands[self.CLAMP]['close']
|
||||
loc_reponse=self.send_command(loc_send_command)
|
||||
time.sleep(self.delay_clamp)
|
||||
if pusher1:
|
||||
self.send_command(self.valve_commands[self.PUSHER1]['close'])
|
||||
loc_send_command=self.valve_commands[self.PUSHER1]['close']
|
||||
loc_reponse=self.send_command(loc_send_command)
|
||||
time.sleep(self.delay_pusher)
|
||||
if conveyor2_reverse:
|
||||
self.send_command(self.valve_commands[self.CONVEYOR2_REVERSE]['close'])
|
||||
loc_send_command=self.valve_commands[self.CONVEYOR2_REVERSE]['close']
|
||||
loc_reponse=self.send_command(loc_send_command)
|
||||
time.sleep(self.delay_conveyor)
|
||||
|
||||
if loc_reponse and len(loc_reponse) >= 10:
|
||||
lol_hex_response = binascii.hexlify(response).decode('utf-8')
|
||||
if lol_hex_response == loc_send_command:
|
||||
loc_ret=True
|
||||
if Constant.DebugPosition:
|
||||
loc_ret=True
|
||||
return loc_ret
|
||||
|
||||
|
||||
# ===================== 传感器处理线程 =====================
|
||||
def handle_sensor1(self):
|
||||
while self._running:
|
||||
@ -356,6 +471,7 @@ class RelayController(QObject):
|
||||
time.sleep(self.sensor1_loop_delay)
|
||||
except Exception as e:
|
||||
print(f"SENSOR1 处理错误: {e}")
|
||||
self.log_signal.emit(logging.ERROR,f"SENSOR1 处理错误: {e}")
|
||||
self.sensor1_triggered = False
|
||||
time.sleep(self.sensor1_error_delay)
|
||||
|
||||
@ -363,6 +479,14 @@ class RelayController(QObject):
|
||||
_is_pause_close=True
|
||||
#是否料袋尾部(有信号--》无信号)
|
||||
_is_signal=False
|
||||
|
||||
#正发转用
|
||||
_is_reverse_2=False
|
||||
#是否反转后正转信号消息
|
||||
_is_signal_2=False
|
||||
#是否首次正转信号
|
||||
_is_first_signal_2=False
|
||||
|
||||
while self._running:
|
||||
if self._ispause:
|
||||
#暂停
|
||||
@ -376,9 +500,66 @@ class RelayController(QObject):
|
||||
continue
|
||||
#开启线程
|
||||
_is_pause_close=True
|
||||
|
||||
if self.is_drop_35:
|
||||
#region 35kg 正反转打平
|
||||
try:
|
||||
if _is_signal or self.is_valid_sensor_status_1(self.SENSOR2):
|
||||
if _is_signal_2 or self.is_valid_sensor_status_1(self.SENSOR2):
|
||||
#反转要加个防抖动时间
|
||||
if _is_reverse_2:
|
||||
print('回退后检查到sensor2 35KG信号,正转')
|
||||
self.open(conveyor2=True)
|
||||
_is_reverse_2=False
|
||||
_is_signal_2=True
|
||||
elif _is_signal_2 and self.is_valid_sensor2_status_lost(self.SENSOR2):
|
||||
print('检查到sensor2正转35KG信号消失')
|
||||
self.close(conveyor2=True)
|
||||
#滚筒关闭标志
|
||||
self.motor_stopped_by_sensor2 = True
|
||||
# 发送信号通知机器人取走物品
|
||||
self.take_robot_signal.emit()
|
||||
_is_signal_2=False
|
||||
#停止后即使有信号了,也不能转,直到self.sensor2_ready=True
|
||||
# _is_first_signal=False
|
||||
self.sensor2_ready=False #打开滚洞标识
|
||||
elif not _is_first_signal_2:
|
||||
print('检查到正转sensor2 35KG信号')
|
||||
#检测到信号,5秒
|
||||
time.sleep(6)
|
||||
self.open(conveyor2_reverse=True)
|
||||
_is_reverse_2=True
|
||||
_is_first_signal_2=True
|
||||
time.sleep(0.1)
|
||||
continue
|
||||
elif self.sensor2_ready:
|
||||
#sensor2_ready:通过Feeding:FPhoto处控制是否启动
|
||||
if self.motor_stopped_by_sensor2:
|
||||
print('开滚筒')
|
||||
self.open(conveyor2=True)
|
||||
self.motor_stopped_by_sensor2 = False
|
||||
_is_first_signal=False
|
||||
# _is_reverse=False
|
||||
# _is_first_signal=False
|
||||
# _is_signal=False
|
||||
|
||||
if _is_reverse_2:
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
time.sleep(2)
|
||||
except Exception as e:
|
||||
print(f"SENSOR3 处理错误: {e}")
|
||||
self.log_signal.emit(logging.ERROR,f"SENSOR3 处理错误: {e}")
|
||||
time.sleep(self.sensor2_error_delay)
|
||||
#endregion
|
||||
else:
|
||||
try:
|
||||
|
||||
if self.sensor2_ready:
|
||||
#sensor2_ready:通过Feeding:FPhoto处控制是否启动,到了,先启动
|
||||
if self.motor_stopped_by_sensor2:
|
||||
print('开滚筒')
|
||||
self.open(conveyor2=True)
|
||||
self.motor_stopped_by_sensor2 = False
|
||||
elif _is_signal or self.is_valid_sensor_signal_stable(self.SENSOR2,detection_duration=3,stability_duration=2.5,check_interval=0.5):
|
||||
#检测到信号,如果之前是没有信号,关闭滚筒
|
||||
print('检查到sensor2信号')
|
||||
if _is_signal and self.is_valid_sensor2_status_lost(self.SENSOR2):
|
||||
@ -394,16 +575,85 @@ class RelayController(QObject):
|
||||
_is_signal=True
|
||||
# time.sleep(0.1)
|
||||
continue
|
||||
|
||||
time.sleep(2)
|
||||
except Exception as e:
|
||||
print(f"SENSOR2 处理错误: {e}")
|
||||
self.log_signal.emit(logging.ERROR,f"SENSOR2 处理错误: {e}")
|
||||
time.sleep(self.sensor2_error_delay)
|
||||
|
||||
def handle_sensor3(self):
|
||||
"""
|
||||
正转--》反转--》正转
|
||||
"""
|
||||
_is_pause_close=True
|
||||
#是否反转
|
||||
_is_reverse=False
|
||||
#是否反转后正转信号消息
|
||||
_is_signal=False
|
||||
#是否首次正转信号
|
||||
_is_first_signal=False
|
||||
#是否料袋尾部(有信号--》无信号)
|
||||
while self._running:
|
||||
if self._ispause:
|
||||
#暂停
|
||||
if _is_pause_close:
|
||||
self.close(conveyor2=True)
|
||||
self.motor_stopped_by_sensor2 = True
|
||||
# self.sensor2_ready = True #初始值
|
||||
_is_pause_close=False
|
||||
|
||||
time.sleep(self.sensor2_error_delay)
|
||||
continue
|
||||
#开启线程
|
||||
_is_pause_close=True
|
||||
#滚动次数
|
||||
try:
|
||||
if _is_signal or self.is_valid_sensor_status_1(self.SENSOR2):
|
||||
#反转要加个防抖动时间
|
||||
if _is_reverse:
|
||||
print('回退后检查到sensor2信号,正转')
|
||||
self.open(conveyor2=True)
|
||||
_is_reverse=False
|
||||
_is_signal=True
|
||||
elif _is_signal and self.is_valid_sensor2_status_lost(self.SENSOR2):
|
||||
print('检查到sensor2正转信号消失')
|
||||
self.close(conveyor2=True)
|
||||
#滚筒关闭标志
|
||||
self.motor_stopped_by_sensor2 = True
|
||||
# 发送信号通知机器人取走物品
|
||||
self.take_robot_signal.emit()
|
||||
_is_signal=False
|
||||
#停止后即使有信号了,也不能转,直到self.sensor2_ready=True
|
||||
# _is_first_signal=False
|
||||
self.sensor2_ready=False #打开滚洞标识
|
||||
elif not _is_first_signal:
|
||||
print('检查到正转sensor2信号')
|
||||
#检测到信号,5秒
|
||||
time.sleep(6)
|
||||
self.open(conveyor2_reverse=True)
|
||||
_is_reverse=True
|
||||
_is_first_signal=True
|
||||
time.sleep(0.1)
|
||||
continue
|
||||
elif self.sensor2_ready:
|
||||
#sensor2_ready:通过Feeding:FPhoto处控制是否启动
|
||||
if self.motor_stopped_by_sensor2:
|
||||
print('开滚筒')
|
||||
self.open(conveyor2=True)
|
||||
self.motor_stopped_by_sensor2 = False
|
||||
_is_first_signal=False
|
||||
# _is_reverse=False
|
||||
# _is_first_signal=False
|
||||
# _is_signal=False
|
||||
|
||||
if _is_reverse:
|
||||
time.sleep(0.1)
|
||||
else:
|
||||
time.sleep(2)
|
||||
except Exception as e:
|
||||
print(f"SENSOR2 处理错误: {e}")
|
||||
print(f"SENSOR3 处理错误: {e}")
|
||||
self.log_signal.emit(logging.ERROR,f"SENSOR3 处理错误: {e}")
|
||||
time.sleep(self.sensor2_error_delay)
|
||||
|
||||
def pause_start_sensor(self,is_pause):
|
||||
@ -413,6 +663,14 @@ class RelayController(QObject):
|
||||
"""
|
||||
self._ispause = is_pause
|
||||
|
||||
def set_drop_35(self,is_drop_35):
|
||||
"""
|
||||
设置是否是35码
|
||||
is_drop_35:True是,False否
|
||||
"""
|
||||
self.is_drop_35=is_drop_35
|
||||
|
||||
|
||||
def stop_sensor(self,sensor1_thread,sensor2_thread):
|
||||
if not self._running:
|
||||
print("线程未在运行")
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
13
Seting.ini
13
Seting.ini
@ -21,12 +21,12 @@ photo_z1 = 1.0
|
||||
photo_u1 = 12.0
|
||||
photo_v1 = 0.0
|
||||
photo_w1 = 1.0
|
||||
photo_x2 = 7.0
|
||||
photo_y2 = 50.0
|
||||
photo_z2 = 1.0
|
||||
photo_u2 = 12.0
|
||||
photo_x2 = 0.0
|
||||
photo_y2 = 0.0
|
||||
photo_z2 = 0.0
|
||||
photo_u2 = 0.0
|
||||
photo_v2 = 0.0
|
||||
photo_w2 = 1.0
|
||||
photo_w2 = 0.0
|
||||
photo_x3 = 7.0
|
||||
photo_y3 = 50.0
|
||||
photo_z3 = 1.0
|
||||
@ -47,7 +47,8 @@ photo_v5 = 0.0
|
||||
photo_w5 = 1.0
|
||||
linecount = 2
|
||||
remain_linename = 1
|
||||
remain_count = 10
|
||||
remain_dropweight_kg = 50
|
||||
remain_count = 18
|
||||
maduo_count = 30
|
||||
io_take_addr = 8
|
||||
io_zip_addr = 11
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -51,9 +51,18 @@ class Logger(QObject):
|
||||
|
||||
handler = TimedRotatingFileHandler(file_path, when='D', interval=1, backupCount=30,encoding='utf-8')
|
||||
handler.suffix = "%Y-%m-%d"
|
||||
formatter = logging.Formatter('%(asctime)s - %(levelname)s - %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
|
||||
formatter = logging.Formatter('%(asctime)s - %(levelname)s- %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
|
||||
handler.setFormatter(formatter)
|
||||
self.logger_file_info.addHandler(handler)
|
||||
# 添加错误专用日志文件
|
||||
error_handler = TimedRotatingFileHandler(
|
||||
file_path.replace('.log', '_error.log'),
|
||||
when='D', interval=1, backupCount=30, encoding='utf-8')
|
||||
error_handler.suffix = "%Y-%m-%d"
|
||||
error_handler.setLevel(logging.ERROR) # 只处理错误级别
|
||||
error_handler.setFormatter(formatter)
|
||||
self.logger_file_info.addHandler(error_handler)
|
||||
|
||||
|
||||
def _process_logs(self):
|
||||
while True:
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
17229
log/log.log
17229
log/log.log
File diff suppressed because it is too large
Load Diff
458
main.py
458
main.py
@ -48,6 +48,7 @@ from ui_MainWin import Ui_MainWindow
|
||||
from view.ResetView import StopDialog
|
||||
from EMV.EMV import RelayController
|
||||
from CU.drop import DropPositionManager
|
||||
import re
|
||||
|
||||
|
||||
class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
@ -58,7 +59,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.setupUi(self)
|
||||
#传感器继电器加入变量
|
||||
self.relay_controller = RelayController()
|
||||
self.drop_position_manager = DropPositionManager()
|
||||
self.drop_position_manager = DropPositionManager(Constant.dropLine_set_file)
|
||||
self.sensor_thread = None
|
||||
self.sensor2_thread = None
|
||||
self.last_status_printed = None
|
||||
@ -241,7 +242,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
line_model.save_line_model(config_reader)
|
||||
config_reader.write(open(Constant.feedLine_set_file, 'w', encoding='utf-8'))
|
||||
elif section.startswith(Constant.dropLine_set_section):
|
||||
self.drop_position_manager.save_path_points(line_model)
|
||||
loc_dropline_file=Constant.dropLine_set_file
|
||||
if section.endswith('-35'):
|
||||
loc_dropline_file=Constant.dropLine_set_file_35
|
||||
DropPositionManager(loc_dropline_file).save_path_points(line_model)
|
||||
self.init_FeedLine()
|
||||
break
|
||||
self.init_table_lines_data()
|
||||
@ -334,7 +338,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
def show_lines_pos_data(self,line_index):
|
||||
if self.selected_line_section!='' and self.selected_line_section != self.tableWidget_lines.item(line_index,0).text():
|
||||
if self.table_position_changed or self.table_line_changed:
|
||||
msgBox = QMessageBox()
|
||||
msgBox = QMessageBox(self)
|
||||
msgBox.setText("已修改的数据,是否保存?")
|
||||
msgBox.setStandardButtons(QMessageBox.Yes | QMessageBox.No)
|
||||
result = msgBox.exec()
|
||||
@ -407,7 +411,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.tableWidget_line_positions.removeRow(self.tableWidget_line_positions.currentRow())
|
||||
|
||||
if self.selected_line_section.startswith(Constant.dropLine_set_section):
|
||||
self.drop_position_manager.del_drop_point(section)
|
||||
loc_dropline_file=Constant.dropLine_set_file
|
||||
if self.selected_line_section.endswith('-35'):
|
||||
loc_dropline_file=Constant.dropLine_set_file_35
|
||||
DropPositionManager(loc_dropline_file).del_drop_point(section)
|
||||
else:
|
||||
config_writer = configparser.ConfigParser()
|
||||
config_writer.read(Constant.feedLine_set_file, encoding = 'utf-8')
|
||||
@ -447,7 +454,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.set_positionModel_to_tabel(row_i+1,position_model)
|
||||
self.table_line_changed = True
|
||||
|
||||
|
||||
def tabel_move_position(self,row_i):
|
||||
if self.tableWidget_line_positions.currentRow()==-1:
|
||||
QMessageBox.information(self, "提示", Constant.str_sys_set_position_error)
|
||||
@ -565,11 +571,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
pass
|
||||
|
||||
def init_log(self):
|
||||
"""初始化日志显示到界面上"""
|
||||
log.log_info_signal.connect(self.log_info_message)
|
||||
log.log_error_signal.connect(self.log_error_message)
|
||||
log.log_warning_signal.connect(self.log_warning_message)
|
||||
log.init_log(self.textEdit_log_info, self.textEdit_log_error, Constant.log_file_path)
|
||||
log.log_message(logging.INFO, Constant.str_sys_start)
|
||||
|
||||
def log_info_message(self,message):
|
||||
now = datetime.now()
|
||||
formatted_time = now.strftime("%Y-%m-%d %H:%M:%S")
|
||||
@ -751,11 +759,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
# self.camera_img.update_camera_image.connect(self.updateUI_label_detection)
|
||||
self.feeding.log_signal.connect(self.log_message)
|
||||
self.feeding.stack_finish_signal.connect(self.stack_finish)
|
||||
self.relay_controller.log_signal.connect(self.log_message)
|
||||
# self.camera_img=CameraImg(self.feeding)
|
||||
# self.camera_img.update_camera_image.connect(self.updateUI_label_detection)
|
||||
|
||||
self.last_time = time.time()
|
||||
self.remain_lineName = self.configReader.get('Robot_Feed', 'remain_lineName')
|
||||
self.remain_drop_weight = self.configReader.get("Robot_Feed", "remain_dropweight_kg") # 9/29 投料重量, 单位kg
|
||||
self.remain_Count = int(self.configReader.get('Robot_Feed', 'remain_Count'))
|
||||
self.maduo_Count = int(self.configReader.get('Robot_Feed', 'maduo_Count'))
|
||||
self.label_remain_num.setText(str(self.remain_Count))
|
||||
@ -776,112 +786,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
else:
|
||||
return Error_Code.SYS_NETERROR
|
||||
|
||||
def init_seting_frame(self):
|
||||
|
||||
rows = len(self.feedLine_dict.keys()) + 1
|
||||
self.tableWidget_feedSeting.setRowCount(rows)
|
||||
self.tableWidget_feedSeting.setColumnCount(20+2*6)
|
||||
# 设置第一重表头的合并 (三列一组)
|
||||
self.tableWidget_feedSeting_addtional_col_num = 2
|
||||
|
||||
self.tableWidget_feedSeting.setSpan(0, 0 + self.tableWidget_feedSeting_addtional_col_num, 1, 6) # 合并前3列
|
||||
self.tableWidget_feedSeting.setSpan(0, 6 + self.tableWidget_feedSeting_addtional_col_num, 1, 6) # 合并后3列
|
||||
self.tableWidget_feedSeting.setSpan(0, 12 + self.tableWidget_feedSeting_addtional_col_num, 1, 6) # 合并后3列
|
||||
self.tableWidget_feedSeting.setSpan(0, 18 + self.tableWidget_feedSeting_addtional_col_num, 1, 6) # 合并后3列
|
||||
self.tableWidget_feedSeting.setSpan(0, 24 + self.tableWidget_feedSeting_addtional_col_num, 1, 6) # 合并后3列
|
||||
|
||||
|
||||
self.tableWidget_feedSeting.itemChanged.connect(self.send_tabelFeedSet_itemChanged)
|
||||
|
||||
btn_safe = QPushButton("获取安全位置")
|
||||
widget_safe = QWidget()
|
||||
layout_safe = QHBoxLayout()
|
||||
layout_safe.addWidget(btn_safe)
|
||||
# 调整布局的间距,使之更紧凑
|
||||
layout_safe.setContentsMargins(0, 0, 0, 0)
|
||||
# 将布局设置到 QWidget 容器中
|
||||
widget_safe.setLayout(layout_safe)
|
||||
|
||||
|
||||
btn_bk1 = QPushButton("获取破袋位置1")
|
||||
widget_bk1 = QWidget()
|
||||
layout_bk1 = QHBoxLayout()
|
||||
layout_bk1.addWidget(btn_bk1)
|
||||
# 调整布局的间距,使之更紧凑
|
||||
layout_bk1.setContentsMargins(0, 0, 0, 0)
|
||||
# 将布局设置到 QWidget 容器中
|
||||
widget_bk1.setLayout(layout_bk1)
|
||||
|
||||
btn_bk2 = QPushButton("获取破袋位置2")
|
||||
widget_bk2 = QWidget()
|
||||
layout_bk2 = QHBoxLayout()
|
||||
layout_bk2.addWidget(btn_bk2)
|
||||
# 调整布局的间距,使之更紧凑
|
||||
layout_bk2.setContentsMargins(0, 0, 0, 0)
|
||||
# 将布局设置到 QWidget 容器中
|
||||
widget_bk2.setLayout(layout_bk2)
|
||||
|
||||
btn_shake = QPushButton("获取摇晃位置")
|
||||
widget_shake = QWidget()
|
||||
layout_shake = QHBoxLayout()
|
||||
layout_shake.addWidget(btn_shake)
|
||||
layout_shake.setContentsMargins(0, 0, 0, 0)
|
||||
widget_shake.setLayout(layout_shake)
|
||||
|
||||
|
||||
btn_dropbag = QPushButton("获取丢袋位置")
|
||||
widget_dropbag = QWidget()
|
||||
layout_dropbag = QHBoxLayout()
|
||||
layout_dropbag.addWidget(btn_dropbag)
|
||||
# 调整布局的间距,使之更紧凑
|
||||
layout_dropbag.setContentsMargins(0, 0, 0, 0)
|
||||
# 将布局设置到 QWidget 容器中
|
||||
widget_dropbag.setLayout(layout_dropbag)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
btn_safe.clicked.connect(self.send_get_safe_position_button_click)
|
||||
btn_bk1.clicked.connect(self.send_get_broken1_position_button_click)
|
||||
btn_bk2.clicked.connect(self.send_get_broken2_position_button_click)
|
||||
btn_shake.clicked.connect(self.send_get_shake_position_button_click)
|
||||
btn_dropbag.clicked.connect(self.send_get_dropbag_position_button_click)
|
||||
|
||||
# 添加第一重表头项
|
||||
|
||||
self.tableWidget_feedSeting.setCellWidget(0, 0 + self.tableWidget_feedSeting_addtional_col_num, widget_safe)
|
||||
self.tableWidget_feedSeting.setCellWidget(0, 6 + self.tableWidget_feedSeting_addtional_col_num, widget_bk1)
|
||||
self.tableWidget_feedSeting.setCellWidget(0, 12 + self.tableWidget_feedSeting_addtional_col_num, widget_bk2)
|
||||
self.tableWidget_feedSeting.setCellWidget(0, 18 + self.tableWidget_feedSeting_addtional_col_num, widget_shake)
|
||||
self.tableWidget_feedSeting.setCellWidget(0, 24 + self.tableWidget_feedSeting_addtional_col_num, widget_dropbag)
|
||||
|
||||
|
||||
self.tableWidget_feedSeting.setSelectionBehavior(QTableWidget.SelectRows)
|
||||
self.tableWidget_feedSeting.setAutoScroll(True)
|
||||
# 添加第二重表头
|
||||
self.tableWidget_feedSeting.setHorizontalHeaderLabels(
|
||||
['header', '线名', 'X1', 'Y1', 'Z1', 'U1', 'V1', 'W1', 'X2', 'Y2', 'Z2', 'U2', 'V2', 'W2', 'X3', 'Y3', 'Z3',
|
||||
'U3', 'V3', 'W3', 'X4', 'Y4', 'Z4', 'U4', 'V4', 'W4', 'X5', 'Y5', 'Z5', 'U5', 'V5', 'W5'])
|
||||
|
||||
self.tableWidget_feedSeting.hideColumn(0)
|
||||
# 填充数据行
|
||||
for row, (feed_line_key, feed_line) in enumerate(self.feedLine_dict.items()):
|
||||
self.tableWidget_feedSeting.setItem(row + 1, 0, QTableWidgetItem(feed_line_key))
|
||||
self.tableWidget_feedSeting.setItem(row + 1, 1, QTableWidgetItem(feed_line.name))
|
||||
self.set_position_to_tabel(row + 1, 0, feed_line.safe_position)
|
||||
self.set_position_to_tabel(row + 1, 1, feed_line.broken1_position)
|
||||
self.set_position_to_tabel(row + 1, 2, feed_line.broken2_position)
|
||||
self.set_position_to_tabel(row + 1, 3, feed_line.broken2_position)
|
||||
self.set_position_to_tabel(row + 1, 4, feed_line.drop_bag_position)
|
||||
|
||||
|
||||
# 禁用自动表头
|
||||
self.tableWidget_feedSeting.verticalHeader().setVisible(True)
|
||||
self.pushButton_tableFeedSet_addRow.clicked.connect(self.send_tabelFeedSet_addRow)
|
||||
self.pushButton_tableFeedSet_deleRow.clicked.connect(self.send_tabelFeedSet_delRow)
|
||||
self.pushButton_tableFeedSet_save.clicked.connect(self.send_tabelFeedSet_save)
|
||||
|
||||
def init_FeedLine(self):
|
||||
# line_count = self.configReader.get('Robot_Feed', 'LineCount', fallback=0)
|
||||
configReader = configparser.ConfigParser()
|
||||
@ -893,13 +797,18 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
feed_line.read_line_model(config_reader=configReader,index=i)
|
||||
self.feedLine_dict[f'{Constant.feedLine_set_section}{i}'] = feed_line
|
||||
#加载所有码垛的路径信息
|
||||
for i in range(1,Constant.MAX_Line_num):
|
||||
line_model = self.drop_position_manager.load_path_points(i)
|
||||
# for i in range(1,Constant.MAX_Line_num):
|
||||
line_model = DropPositionManager(Constant.dropLine_set_file).load_path_points(1)
|
||||
if line_model:
|
||||
self.feedLine_dict[f'{Constant.dropLine_set_section}{i}'] = line_model
|
||||
self.feedLine_dict[f'{Constant.dropLine_set_section}-50'] = line_model
|
||||
line_model = DropPositionManager(Constant.dropLine_set_file_35).load_path_points(1)
|
||||
if line_model:
|
||||
self.feedLine_dict[f'{Constant.dropLine_set_section}-35'] = line_model
|
||||
|
||||
self.updateUI_Select_Line()
|
||||
pass
|
||||
# self.updateUI_Select_Line()
|
||||
# 9/29 初始化线名选择框 和 重量选择框
|
||||
self.updateui_select_line_by_feedLine_ini()
|
||||
self.updateui_select_dropweight_by_drop_ini()
|
||||
|
||||
def init_robot_info(self):
|
||||
j1_min = int(self.configReader.get('Robot_Feed', 'j1_min'))
|
||||
@ -973,15 +882,13 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
||||
def check_continue(self):
|
||||
if self.remain_Count!=0:
|
||||
for key in self.feedLine_dict.keys():
|
||||
feed_line = self.feedLine_dict[key]
|
||||
if f'FeedLine{self.remain_lineName}' == key:
|
||||
#提示
|
||||
remain_messageBox = QMessageBox()
|
||||
remain_messageBox = QMessageBox(self)
|
||||
remain_messageBox.setIcon(QMessageBox.Icon.Warning)
|
||||
remain_messageBox.setText(f'还有{self.remain_Count}袋未投料,是否继续?') # 这里返回多少袋没有投料
|
||||
# remain_messageBox.setStandardButtons(QMessageBox.StandardButton.Ok | QMessageBox.StandardButton.Cancel)
|
||||
@ -1015,7 +922,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.send_start_tool_command()
|
||||
log.log_message(logging.INFO, Constant.str_sys_start_tool)
|
||||
|
||||
msg_box_person = QMessageBox()
|
||||
msg_box_person = QMessageBox(self)
|
||||
msg_box_person.setIcon(QMessageBox.Icon.Information)
|
||||
msg_box_person.setText("是否确认生产区域安全继续生产?")
|
||||
msg_box_person.setWindowTitle("提示")
|
||||
@ -1054,8 +961,24 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
return
|
||||
|
||||
self.label_button_status.setText("运行中...")
|
||||
self.drop_position_manager=DropPositionManager(Constant.dropLine_set_file_35)
|
||||
self.relay_controller.set_drop_35(True)
|
||||
#注意码垛数和码垛总数
|
||||
# num=25 #先默认30包码垛
|
||||
self.command_quene.put(FeedCommand(FeedingConfig(num, FeedLine(self.feedLine_dict[line_head].id,self.feedLine_dict[line_head].name,self.feedLine_dict[line_head].positions,self.remain_Count), self.feeding.robotClient.photo_locs[:],self.remain_Count)))
|
||||
self.command_quene.put(
|
||||
FeedCommand(
|
||||
FeedingConfig(num,
|
||||
FeedLine(
|
||||
self.feedLine_dict[line_head].id,
|
||||
self.feedLine_dict[line_head].name,
|
||||
self.feedLine_dict[line_head].positions,
|
||||
self.remain_Count,
|
||||
self.drop_position_manager
|
||||
)
|
||||
, self.feeding.robotClient.photo_locs[:],self.remain_Count
|
||||
)
|
||||
)
|
||||
)
|
||||
# self.stackedWidget_num.setCurrentIndex(1)
|
||||
self.set_run_status_button(True)
|
||||
self.feeding.pause = False
|
||||
@ -1264,97 +1187,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
log.log_message(logging.INFO, Constant.str_sys_setSpeed + str(self.robotClient.debug_speed)+'|'+str(self.robotClient.feed_speed))
|
||||
pass
|
||||
|
||||
def send_get_safe_position_button_click(self):
|
||||
real_position = self.robotClient.status_model.getRealPosition()
|
||||
row_i = self.tableWidget_feedSeting.currentRow()
|
||||
head = self.tableWidget_feedSeting.item(row_i, 0).text()
|
||||
self.feedLine_dict[head].safe_position.init_position(real_position.X, real_position.Y, real_position.Z,
|
||||
real_position.U, real_position.V, real_position.W)
|
||||
self.set_position_to_tabel(row_i, 0, real_position)
|
||||
|
||||
|
||||
def send_get_broken1_position_button_click(self):
|
||||
real_position = self.robotClient.status_model.getRealPosition()
|
||||
row_i = self.tableWidget_feedSeting.currentRow()
|
||||
head = self.tableWidget_feedSeting.item(row_i, 0).text()
|
||||
self.feedLine_dict[head].broken1_position.init_position(real_position.X, real_position.Y, real_position.Z,
|
||||
real_position.U, real_position.V, real_position.W)
|
||||
self.set_position_to_tabel(row_i, 1, real_position)
|
||||
|
||||
def send_get_broken2_position_button_click(self):
|
||||
real_position = self.robotClient.status_model.getRealPosition()
|
||||
row_i = self.tableWidget_feedSeting.currentRow()
|
||||
head = self.tableWidget_feedSeting.item(row_i, 0).text()
|
||||
self.feedLine_dict[head].broken2_position.init_position(real_position.X, real_position.Y, real_position.Z,
|
||||
real_position.U, real_position.V, real_position.W)
|
||||
self.set_position_to_tabel(row_i, 2, real_position)
|
||||
|
||||
def send_get_shake_position_button_click(self):
|
||||
real_position = self.robotClient.status_model.getRealPosition()
|
||||
row_i = self.tableWidget_feedSeting.currentRow()
|
||||
head = self.tableWidget_feedSeting.item(row_i, 0).text()
|
||||
self.feedLine_dict[head].shake_position.init_position(real_position.X, real_position.Y, real_position.Z,
|
||||
real_position.U, real_position.V, real_position.W)
|
||||
self.set_position_to_tabel(row_i, 3, real_position)
|
||||
|
||||
def send_get_dropbag_position_button_click(self):
|
||||
real_position = self.robotClient.status_model.getRealPosition()
|
||||
row_i = self.tableWidget_feedSeting.currentRow()
|
||||
head = self.tableWidget_feedSeting.item(row_i, 0).text()
|
||||
self.feedLine_dict[head].drop_bag_position.init_position(real_position.X, real_position.Y, real_position.Z,
|
||||
real_position.U, real_position.V, real_position.W)
|
||||
self.set_position_to_tabel(row_i, 4, real_position)
|
||||
|
||||
def send_get_zipbag_position_button_click(self):
|
||||
real_position = self.robotClient.status_model.getRealPosition()
|
||||
row_i = self.tableWidget_feedSeting.currentRow()
|
||||
head = self.tableWidget_feedSeting.item(row_i, 0).text()
|
||||
self.feedLine_dict[head].zip_bag_position.init_position(real_position.X, real_position.Y, real_position.Z,
|
||||
real_position.U, real_position.V, real_position.W)
|
||||
self.set_position_to_tabel(row_i, 6, real_position)
|
||||
|
||||
def send_tabelFeedSet_addRow(self):
|
||||
for i in range(1, 20):
|
||||
head = f'{Constant.feedLine_set_section}{i}'
|
||||
if head not in self.feedLine_dict:
|
||||
row_position = self.tableWidget_feedSeting.rowCount() # 当前行数
|
||||
self.tableWidget_feedSeting.insertRow(row_position)
|
||||
safe_position = Real_Position()
|
||||
break_1_position = Real_Position()
|
||||
break_2_position = Real_Position()
|
||||
shake_position = Real_Position()
|
||||
drop_bag_position = Real_Position()
|
||||
|
||||
self.feedLine_dict[head] = FeedLine('新建', safe_position, break_1_position, break_2_position,shake_position,drop_bag_position)
|
||||
self.tableWidget_feedSeting.setItem(self.tableWidget_feedSeting.rowCount() - 1, 0,
|
||||
QTableWidgetItem(head))
|
||||
self.tableWidget_feedSeting.setItem(self.tableWidget_feedSeting.rowCount() - 1, 1,
|
||||
QTableWidgetItem('新建'))
|
||||
self.set_position_to_tabel(self.tableWidget_feedSeting.rowCount() - 1, 0, safe_position)
|
||||
self.set_position_to_tabel(self.tableWidget_feedSeting.rowCount() - 1, 1, break_1_position)
|
||||
self.set_position_to_tabel(self.tableWidget_feedSeting.rowCount() - 1, 2, break_2_position)
|
||||
self.set_position_to_tabel(self.tableWidget_feedSeting.rowCount() - 1, 3, shake_position)
|
||||
self.set_position_to_tabel(self.tableWidget_feedSeting.rowCount() - 1, 4, drop_bag_position)
|
||||
break
|
||||
|
||||
def send_tabelFeedSet_delRow(self):
|
||||
selectRow = self.tableWidget_feedSeting.currentRow()
|
||||
if selectRow >= 0:
|
||||
for feed_line_key, feed_line in self.feedLine_dict.items():
|
||||
if feed_line_key == self.tableWidget_feedSeting.item(selectRow, 0).text():
|
||||
self.feedLine_dict.pop(feed_line_key)
|
||||
self.tableWidget_feedSeting.removeRow(selectRow)
|
||||
break
|
||||
else:
|
||||
QMessageBox.information(self, "提示", "请选择要删除的行")
|
||||
|
||||
def send_tabelFeedSet_save(self):
|
||||
count = len(self.feedLine_dict.keys())
|
||||
self.configReader.read(Constant.set_ini)
|
||||
self.configReader.set('Robot_Feed', 'LineCount', str(count))
|
||||
writeFeedLine_to_ini(self.feedLine_dict, Constant.feedLine_set_file)
|
||||
pass
|
||||
|
||||
def send_stopFeed_button_click(self):
|
||||
# 清空状态
|
||||
self.feeding.feedStatus = FeedStatus.FNone
|
||||
@ -1383,7 +1215,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
|
||||
def send_emergency_alarm_command(self):
|
||||
"""停止当前工作,需要启动"""
|
||||
msg_box_person = QMessageBox()
|
||||
msg_box_person = QMessageBox(self)
|
||||
msg_box_person.setIcon(QMessageBox.Icon.Question)
|
||||
msg_box_person.setText("您确定要停止当前工作吗?")
|
||||
msg_box_person.setWindowTitle("提示")
|
||||
@ -1464,9 +1296,15 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
position_origin.status = 1
|
||||
return_positions.insert(0,position_origin)
|
||||
if self.feedLine_dict.keys().__contains__(line_head):
|
||||
self.feeding.feedConfig= FeedingConfig(0, FeedLine(self.feedLine_dict[line_head].id, self.feedLine_dict[line_head].name,
|
||||
return_positions,self.remain_Count),
|
||||
self.feeding.robotClient.photo_locs[:],self.remain_Count)
|
||||
self.feeding.feedConfig= FeedingConfig(
|
||||
0,
|
||||
FeedLine(
|
||||
self.feedLine_dict[line_head].id,
|
||||
self.feedLine_dict[line_head].name,
|
||||
return_positions,
|
||||
self.remain_Count
|
||||
)
|
||||
,self.feeding.robotClient.photo_locs[:],self.remain_Count,None)
|
||||
else:
|
||||
log.log_message(logging.ERROR, Constant.str_feed_reset_no_line_error)
|
||||
return
|
||||
@ -1484,78 +1322,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.send_clear_auto_command()
|
||||
self.send_emergency_alarm_command()
|
||||
|
||||
def send_tabelFeedSet_itemChanged(self, item):
|
||||
row = item.row()
|
||||
column = item.column()
|
||||
value = item.text()
|
||||
head = self.tableWidget_feedSeting.item(row, 0).text()
|
||||
if column == 1:
|
||||
self.feedLine_dict[head].name = value
|
||||
elif column == (0 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].safe_position.X = float(value)
|
||||
elif column == (1 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].safe_position.Y = float(value)
|
||||
elif column == (2 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].safe_position.Z = float(value)
|
||||
elif column == (3 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].safe_position.U = float(value)
|
||||
elif column == (4 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].safe_position.V = float(value)
|
||||
elif column == (5 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].safe_position.W = float(value)
|
||||
# elif column == 7:
|
||||
elif column == (6 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].broken1_position.X = float(value)
|
||||
elif column == (7 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].broken1_position.Y = float(value)
|
||||
elif column == (8 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].broken1_position.Z = float(value)
|
||||
elif column == (9 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].broken1_position.U = float(value)
|
||||
elif column == (10 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].broken1_position.V = float(value)
|
||||
elif column == (11 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].broken1_position.W = float(value)
|
||||
|
||||
elif column == (12 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].broken2_position.X = float(value)
|
||||
elif column == (13 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].broken2_position.Y = float(value)
|
||||
elif column == (14 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].broken2_position.Z = float(value)
|
||||
elif column == (15 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].broken2_position.U = float(value)
|
||||
elif column == (16 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].broken2_position.V = float(value)
|
||||
elif column == (17 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].broken2_position.W = float(value)
|
||||
|
||||
elif column == (18 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].shake_position.X = float(value)
|
||||
elif column == (19 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].shake_position.Y = float(value)
|
||||
elif column == (20 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].shake_position.Z = float(value)
|
||||
elif column == (21 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].shake_position.U = float(value)
|
||||
elif column == (22 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].shake_position.V = float(value)
|
||||
elif column == (23 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].shake_position.W = float(value)
|
||||
|
||||
elif column == (24 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].drop_bag_position.X = float(value)
|
||||
elif column == (25 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].drop_bag_position.Y = float(value)
|
||||
elif column == (26 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].drop_bag_position.Z = float(value)
|
||||
elif column == (27 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].drop_bag_position.U = float(value)
|
||||
elif column == (28 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].drop_bag_position.V = float(value)
|
||||
elif column == (29 + self.tableWidget_feedSeting_addtional_col_num):
|
||||
self.feedLine_dict[head].drop_bag_position.W = float(value)
|
||||
|
||||
def run(self):
|
||||
# 主线程的逻辑就是 feeding.run() 接口和错误状态处理
|
||||
while self.thread_signal:
|
||||
@ -1577,7 +1343,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.feeding.feedConfig = command.feed_config
|
||||
# 开启传感器线程检测相关
|
||||
self.relay_controller.pause_start_sensor(False)
|
||||
self.feeding.feedStatus = FeedStatus.FStart # ✅ 投料开始,会触发传感器线程启动
|
||||
self.feeding.feedStatus = FeedStatus.FStart
|
||||
command.status = Status.Runing
|
||||
self.record_remain_num()
|
||||
|
||||
@ -1673,7 +1439,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
# self.send_pause_command(True)
|
||||
# self.feeding.pause = True
|
||||
# self.relay_controller.pause_start_sensor(True)
|
||||
msg_box_finish = QMessageBox()
|
||||
msg_box_finish = QMessageBox(self)
|
||||
msg_box_finish.setIcon(QMessageBox.Icon.Warning)
|
||||
msg_box_finish.setText("码垛完成,请移走拖板")
|
||||
msg_box_finish.setWindowTitle("提示")
|
||||
@ -1729,6 +1495,90 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.comboBox_lineIndex.clear()
|
||||
for key, value in self.feedLine_dict.items():
|
||||
self.comboBox_lineIndex.addItem(value.name, key)
|
||||
|
||||
# 9/29: 只需要加载FeedLine.ini中的name 作为comboBox_lineIndex的选项
|
||||
def updateui_select_line_by_feedLine_ini(self):
|
||||
self.comboBox_lineIndex.clear()
|
||||
configReader = configparser.ConfigParser()
|
||||
configReader.read(Constant.feedLine_set_file, encoding="utf-8")
|
||||
for index in range(1, Constant.MAX_Line_num):
|
||||
section = f"{Constant.feedLine_set_section}{index}"
|
||||
if configReader.has_section(section):
|
||||
line_name = configReader.get(section, "name")
|
||||
self.comboBox_lineIndex.addItem(line_name, section)
|
||||
|
||||
# 设置初始化选中,初始选中 f'{Constant.feedLine_set_section}{self.remain_linename}'
|
||||
if self.remain_lineName:
|
||||
selected_value = f"{Constant.feedLine_set_section}{self.remain_lineName}"
|
||||
selected_index = self.comboBox_lineIndex.findData(selected_value)
|
||||
if selected_index >= 0:
|
||||
self.comboBox_lineIndex.setCurrentIndex(selected_index)
|
||||
|
||||
# 9/29 初始化加载 drop.ini 中的name,获取预先设置的重量
|
||||
def updateui_select_dropweight_by_drop_ini(self):
|
||||
self.comboBox_dropWeight.clear()
|
||||
configReader = configparser.ConfigParser()
|
||||
# 读取重量路径配置文件 drop.ini
|
||||
configReader.read(Constant.dropLine_set_file, encoding="utf-8")
|
||||
|
||||
# drop_name匹配xxxkg获取重量
|
||||
weight_pattern = re.compile(r'(\d+kg)')
|
||||
|
||||
for index in range(1, Constant.MAX_Line_num):
|
||||
section = f"{Constant.dropLine_set_section}{index}"
|
||||
if configReader.has_section(section):
|
||||
drop_name = configReader.get(section, "name")
|
||||
match = weight_pattern.search(drop_name)
|
||||
if match:
|
||||
# 提取匹配到的内容(如"50kg")
|
||||
weight_text = match.group(1)
|
||||
else:
|
||||
# 无法匹配xxxkg, 则使用"未知重量"
|
||||
weight_text = "未知重量"
|
||||
# userData: 如 DropLine50kg
|
||||
userData = f"{Constant.dropLine_set_section}{weight_text}"
|
||||
self.comboBox_dropWeight.addItem(weight_text, userData)
|
||||
|
||||
# 连接槽函数
|
||||
self.comboBox_dropWeight.currentIndexChanged.connect(self.on_drop_weight_changed)
|
||||
|
||||
# 设置初始化选中的重量
|
||||
if self.remain_drop_weight:
|
||||
# selected_value: 如 DropLine50kg
|
||||
selected_value = f"{Constant.dropLine_set_section}{self.remain_drop_weight}kg"
|
||||
selected_index = self.comboBox_dropWeight.findData(selected_value)
|
||||
if selected_index >= 0:
|
||||
self.comboBox_dropWeight.setCurrentIndex(selected_index)
|
||||
# 初始化重量提示标签
|
||||
self.weight_label_info.setText(f"Tips: 当前选择的码垛重量为 {self.remain_drop_weight}kg")
|
||||
|
||||
|
||||
"""9/29 重量下拉框选中项变化时, 更新self.remain_drop_weight"""
|
||||
def on_drop_weight_changed(self, index):
|
||||
# 默认的重量为 50 kg
|
||||
default_weight = 50
|
||||
|
||||
if index < 0: # 没有选中项时(如下拉框为空)
|
||||
self.remain_drop_weight = default_weight
|
||||
return
|
||||
|
||||
# 获取当前选中项的显示文本(如"50kg")
|
||||
selected_text = self.comboBox_dropWeight.currentText()
|
||||
|
||||
# 提取重量数值(从"50kg"中提取"50")
|
||||
weight_pattern = re.compile(r'(\d+)kg')
|
||||
match = weight_pattern.search(selected_text)
|
||||
if match:
|
||||
# 提取数字部分(如"50")
|
||||
self.remain_drop_weight = match.group(1)
|
||||
else:
|
||||
# 若为"未知重量",remain_drop_weight 也为 default_weight
|
||||
self.remain_drop_weight = default_weight
|
||||
|
||||
# 更新上方的码垛重量提示Tips:
|
||||
self.weight_label_info.setText(f"Tips: 当前选择的码垛重量为 {selected_text}")
|
||||
|
||||
|
||||
def updateUI_label_status(self):
|
||||
if self.robotClient.status_model.isMoving==1:
|
||||
self.label_move_sign.show()
|
||||
@ -1751,8 +1601,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.label_status_toolIndex.setText(str(self.robotClient.status_model.toolCoord))
|
||||
self.label_status_speed.setText(str(self.robotClient.status_model.curSpeed_n))
|
||||
|
||||
|
||||
|
||||
def updateUI_Position(self):
|
||||
self.horizontalSlider_J1.setValue(self.status_address.axis_0)
|
||||
self.horizontalSlider_J2.setValue(self.status_address.axis_1)
|
||||
@ -1774,19 +1622,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.horizontalSlider_J5.setValue(self.status_address.axis_4)
|
||||
self.horizontalSlider_J6.setValue(self.status_address.axis_5)
|
||||
|
||||
def set_position_to_tabel(self, row_i, position_j, real_Position: Real_Position):
|
||||
self.tableWidget_feedSeting.setItem(row_i, position_j * 6 + self.tableWidget_feedSeting_addtional_col_num,
|
||||
QTableWidgetItem(str(real_Position.X)))
|
||||
self.tableWidget_feedSeting.setItem(row_i, position_j * 6 + 1 + self.tableWidget_feedSeting_addtional_col_num,
|
||||
QTableWidgetItem(str(real_Position.Y)))
|
||||
self.tableWidget_feedSeting.setItem(row_i, position_j * 6 + 2 + self.tableWidget_feedSeting_addtional_col_num,
|
||||
QTableWidgetItem(str(real_Position.Z)))
|
||||
self.tableWidget_feedSeting.setItem(row_i, position_j * 6 + 3 + self.tableWidget_feedSeting_addtional_col_num,
|
||||
QTableWidgetItem(str(real_Position.U)))
|
||||
self.tableWidget_feedSeting.setItem(row_i, position_j * 6 + 4 + self.tableWidget_feedSeting_addtional_col_num,
|
||||
QTableWidgetItem(str(real_Position.V)))
|
||||
self.tableWidget_feedSeting.setItem(row_i, position_j * 6 + 5 + self.tableWidget_feedSeting_addtional_col_num,
|
||||
QTableWidgetItem(str(real_Position.W)))
|
||||
def updateUI_frame_sign(self,sign:FeedStatus):
|
||||
# print("start")
|
||||
if sign == FeedStatus.FNone:
|
||||
@ -1853,8 +1688,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
|
||||
|
||||
def set_run_status_button(self, isRuning: bool):
|
||||
self.pushButton_pauseFeed.setText("暂停")
|
||||
##self.pushButton_startFeed.setEnabled(False)
|
||||
@ -2119,6 +1952,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
log.log_message(logging.INFO, f'设置拍照点5:{x5},{y5},{z5}')
|
||||
except:
|
||||
self.show_infomessage_box("设置拍照点5失败")
|
||||
|
||||
def set_origin_button_click(self):
|
||||
try:
|
||||
x = float(self.lineEdit_origin_x.text())
|
||||
@ -2143,8 +1977,6 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
log.log_message(logging.ERROR, f'设置原点失败')
|
||||
self.show_infomessage_box("设置原点失败")
|
||||
|
||||
|
||||
|
||||
def updateUI_Photo_Set(self):
|
||||
self.lineEdit_x1.setText(str(self.robotClient.photo_locs[0][0]))
|
||||
self.lineEdit_y1.setText(str(self.robotClient.photo_locs[0][1]))
|
||||
@ -2201,7 +2033,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
def send_click_change_stackView(self,index):
|
||||
self.stackedWidget_view.setCurrentIndex(index)
|
||||
if index == 0:
|
||||
self.updateUI_Select_Line()
|
||||
# 9/29: 切换界面,不刷新 线名选择框 comboBox_lineIndex
|
||||
# self.updateUI_Select_Line()
|
||||
pass
|
||||
if index == 2:
|
||||
self.updateRobotSeting()
|
||||
self.updateUI_Photo_Set()
|
||||
@ -2272,6 +2106,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.configReader.set('Robot_Feed', 'remain_count', str(self.feeding.feedConfig.remain_count))
|
||||
if self.cur_pushbutton_num:
|
||||
self.configReader.set('Robot_Feed', 'maduo_count', self.cur_pushbutton_num.text())
|
||||
|
||||
# 9/29 保存 remain_dropweight_kg 投料的重量,35、50 (单位kg)
|
||||
self.configReader.set("Robot_Feed", "remain_dropweight_kg", str(self.remain_drop_weight))
|
||||
|
||||
self.configReader.write(open(Constant.set_ini, 'w', encoding='utf-8'))
|
||||
except:
|
||||
log.log_message(logging.ERROR, Constant.str_sys_log_feedNum)
|
||||
|
||||
4064
ui_MainWin - 副本 (3).py
Normal file
4064
ui_MainWin - 副本 (3).py
Normal file
File diff suppressed because it is too large
Load Diff
@ -628,7 +628,36 @@ class Ui_MainWindow(object):
|
||||
"border-image: None;")
|
||||
self.frame_sign_2.setFrameShape(QFrame.Shape.StyledPanel)
|
||||
self.frame_sign_2.setFrameShadow(QFrame.Shadow.Raised)
|
||||
self.gridLayout_4 = QGridLayout(self.frame_sign_2)
|
||||
|
||||
|
||||
# 9/30 新增显示 投料的重量的信息
|
||||
self.verticalLayout_sign = QVBoxLayout(self.frame_sign_2)
|
||||
self.verticalLayout_sign.setObjectName(u"verticalLayout_sign")
|
||||
self.verticalLayout_sign.setContentsMargins(0, 0, 0, 0) # 清除边距
|
||||
self.verticalLayout_sign.setSpacing(5) # 新标签与下方网格布局的间距
|
||||
|
||||
# 1. 添加新的信息标签(放在上方)
|
||||
self.weight_label_info = QLabel(self.frame_sign_2)
|
||||
self.weight_label_info.setObjectName(u"label_info")
|
||||
# 设置标签样式 background-color: #2c2c2c;
|
||||
self.weight_label_info.setStyleSheet(u"""
|
||||
QLabel {
|
||||
background-color: rgba(255, 255, 255, 0);
|
||||
color: red;
|
||||
font: 11pt "Microsoft YaHei UI";
|
||||
padding: 5px;
|
||||
border-radius: 3px;
|
||||
}
|
||||
""")
|
||||
self.weight_label_info.setText("显示当前的重量") # 初始信息
|
||||
# self.weight_label_info.setAlignment(Qt.AlignmentFlag.AlignLeft | Qt.AlignmentFlag.AlignVCenter)
|
||||
self.weight_label_info.setAlignment(Qt.AlignmentFlag.AlignCenter) # 居中
|
||||
self.verticalLayout_sign.addWidget(self.weight_label_info)
|
||||
|
||||
|
||||
# 9/10
|
||||
# self.gridLayout_4 = QGridLayout(self.frame_sign_2)
|
||||
self.gridLayout_4 = QGridLayout()
|
||||
self.gridLayout_4.setObjectName(u"gridLayout_4")
|
||||
self.pushButton_sign_go = QPushButton(self.frame_sign_2)
|
||||
self.pushButton_sign_go.setObjectName(u"pushButton_sign_go")
|
||||
@ -786,6 +815,9 @@ class Ui_MainWindow(object):
|
||||
|
||||
self.gridLayout_4.addWidget(self.label_sign_feed, 0, 7, 1, 1)
|
||||
|
||||
# 9/10 添加 取料中、拍照中等布局
|
||||
self.verticalLayout_sign.addLayout(self.gridLayout_4)
|
||||
|
||||
|
||||
self.verticalLayout_14.addWidget(self.frame_sign_2)
|
||||
|
||||
@ -3310,6 +3342,47 @@ class Ui_MainWindow(object):
|
||||
|
||||
self.verticalLayout_11.addWidget(self.comboBox_lineIndex)
|
||||
|
||||
# 9/29 新增重量选择框 和 选择投料重量提示
|
||||
weight_h_layout = QHBoxLayout()
|
||||
# weight_h_layout.setSpacing(10)
|
||||
self.weight_label = QLabel(self.frame_20)
|
||||
self.weight_label.setText("选择码垛重量:")
|
||||
self.weight_label.setStyleSheet("color: white;")
|
||||
weight_h_layout.addWidget(self.weight_label)
|
||||
|
||||
self.comboBox_dropWeight = QComboBox(self.frame_20)
|
||||
self.comboBox_dropWeight.setObjectName(u"comboBox_dropWeight")
|
||||
self.comboBox_dropWeight.setStyleSheet(u"QComboBox {\n"
|
||||
" border-radius: 10px;\n"
|
||||
" padding: 5px 5px 5px 5px;\n"
|
||||
" background-color: #2c2c2c;\n"
|
||||
" color: white;\n"
|
||||
" border: 1px solid #474747;\n"
|
||||
" min-width: 80px;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"\n"
|
||||
"QComboBox::drop-down {\n"
|
||||
" width: 0px;\n"
|
||||
" border: none;\n"
|
||||
"\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"QComboBox::down-arrow {\n"
|
||||
" image: none;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"QComboBox QAbstractItemView {\n"
|
||||
" border-bottom-right-radius: 10px;\n"
|
||||
" border-bottom-left-radius: 10px;\n"
|
||||
" background-color: #D3D3D3;\n"
|
||||
" border: 1px solid gray;\n"
|
||||
" padding: 4px 4px 4px 4px;\n"
|
||||
" outline: none;\n"
|
||||
"}")
|
||||
weight_h_layout.addWidget(self.comboBox_dropWeight)
|
||||
self.verticalLayout_11.addLayout(weight_h_layout)
|
||||
|
||||
self.stackedWidget_num = QStackedWidget(self.frame_20)
|
||||
self.stackedWidget_num.setObjectName(u"stackedWidget_num")
|
||||
self.stackedWidget_num.setStyleSheet(u"border:none;")
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user