Commit bd7c532f authored by 徐生海's avatar 徐生海

Initial commit

parent 854d2864
...@@ -1043,39 +1043,44 @@ class AppBusinessController(AppBusinessInterface): ...@@ -1043,39 +1043,44 @@ class AppBusinessController(AppBusinessInterface):
logWARNING << message logWARNING << message
def waitForChamberAvailable(self, waittimes: int = 30000) -> bool: def waitForChamberAvailable(self, waittimes: int = 30000) -> bool:
isBuzzer : bool = self.isBuzzerAvailable() isChamberAvailable : bool = False
isChamberAvailable : bool
_waittimes : int = max(30000, waittimes) _waittimes : int = max(30000, waittimes)
isWarning : bool = False isWarning : bool = False
endtime : Qt.QDateTime = Qt.QDateTime.currentDateTime().addMSecs(_waittimes) endtime : Qt.QDateTime = Qt.QDateTime.currentDateTime().addMSecs(_waittimes)
warning_string: str = f'片仓没有安装到位 请检查安装好片仓' warning_string: str = f'片仓没有安装到位 请检查安装好片仓'
if self.system.isEnglishMode(): try:
warning_string = 'The slide cassette is not properly installed. Please verify the installation' if self.system.isEnglishMode():
while True: warning_string = 'The slide cassette is not properly installed. Please verify the installation'
isChamberAvailable = self.isChamberAvailable() while True:
isBuzzer = self.isBuzzerAvailable() isChamberAvailable = self.isChamberAvailable()
if isChamberAvailable: isBuzzer = self.isBuzzerAvailable()
if isBuzzer: if isChamberAvailable:
isBuzzer = False if isBuzzer:
self.setWarning(warning_string, isBuzzer) isBuzzer = False
break self.setWarning(warning_string, isBuzzer)
if not isBuzzer: break
if not isBuzzer: if not isBuzzer:
isBuzzer = True if not isBuzzer:
self.setWarning(warning_string, isBuzzer) isBuzzer = True
if Qt.QDateTime.currentDateTime() > endtime: self.setWarning(warning_string, isBuzzer)
break if Qt.QDateTime.currentDateTime() > endtime:
AppTimeLoop.processGlobalEvents(self.system.WarningWaitTimes()) break
AppTimeLoop.processGlobalEvents(self.system.WarningWaitTimes())
except Exception as e:
AppUtils.print_Exception(e)
return isChamberAvailable return isChamberAvailable
def isChamberAvailable(self) -> bool: def isChamberAvailable(self) -> bool:
isChamberAvailable: bool = False isChamberAvailable: bool = False
if self.hasDetection: try:
isChamberAvailable = self.detection.get_chamber_status() if self.hasDetection:
if isChamberAvailable != self.status.isChamberAvailable(): isChamberAvailable = self.detection.get_chamber_status()
self.status.setChamber(isChamberAvailable) if isChamberAvailable != self.status.isChamberAvailable():
self.status.setChamber(isChamberAvailable)
except Exception as e:
AppUtils.print_Exception(e)
return isChamberAvailable return isChamberAvailable
def isBuzzerAvailable(self) -> bool: def isBuzzerAvailable(self) -> bool:
...@@ -1806,14 +1811,14 @@ class AppBusinessController(AppBusinessInterface): ...@@ -1806,14 +1811,14 @@ class AppBusinessController(AppBusinessInterface):
listentime: Qt.QDateTime listentime: Qt.QDateTime
focusing_times: Qt.QDateTime focusing_times: Qt.QDateTime
isWrong: int = RECODE_FAILURE isWrong: int = RECODE_FAILURE
position_z: int = focusing_b_z # position_z: int = focusing_b_z
last_position_z: int = focusing_b_z # last_position_z: int = focusing_b_z
index: int = 1 index: int = 1
maxwaittimes: int = 2000 # maxwaittimes: int = 2000
max_focusing_times: int = 60000 max_focusing_times: int = 60000
"""开始Z轴定速定焦""" """开始Z轴定速定焦"""
listentime = Qt.QDateTime.currentDateTime() # listentime = Qt.QDateTime.currentDateTime()
begintimes = Qt.QDateTime.currentDateTime() # begintimes = Qt.QDateTime.currentDateTime()
logSCANNING << f"{AppConvert.QDateTimeToString(Qt.QDateTime.currentDateTime())}开始玻片定焦" logSCANNING << f"{AppConvert.QDateTimeToString(Qt.QDateTime.currentDateTime())}开始玻片定焦"
"""开始定焦""" """开始定焦"""
self.microscope.set_z_speed(focusing_z_speed) self.microscope.set_z_speed(focusing_z_speed)
...@@ -1837,7 +1842,7 @@ class AppBusinessController(AppBusinessInterface): ...@@ -1837,7 +1842,7 @@ class AppBusinessController(AppBusinessInterface):
item.Level = focusing_status item.Level = focusing_status
item.Index = index item.Index = index
index += 1 index += 1
listentime = Qt.QDateTime.currentDateTime() # listentime = Qt.QDateTime.currentDateTime()
if isGrabbing: if isGrabbing:
self.camera.GetFocusingData(item, classifier) self.camera.GetFocusingData(item, classifier)
else: else:
...@@ -1847,7 +1852,7 @@ class AppBusinessController(AppBusinessInterface): ...@@ -1847,7 +1852,7 @@ class AppBusinessController(AppBusinessInterface):
if RECODE_SUCCEED == isWrong: if RECODE_SUCCEED == isWrong:
item.Position_Z = position_z item.Position_Z = position_z
self.focusing_pool.SendEvent(item) self.focusing_pool.SendEvent(item)
print(f"一帧定焦数据:{index} {listentime.msecsTo(Qt.QDateTime.currentDateTime())}ms") # print(f"一帧定焦数据:{index} {listentime.msecsTo(Qt.QDateTime.currentDateTime())}ms")
if index % 5 == 0: if index % 5 == 0:
isWrong, Moving, Lower, Upper, Limit, Focus = self.microscope.ZDriverMoveStatus() isWrong, Moving, Lower, Upper, Limit, Focus = self.microscope.ZDriverMoveStatus()
if RECODE_SUCCEED == isWrong: if RECODE_SUCCEED == isWrong:
...@@ -1897,13 +1902,13 @@ class AppBusinessController(AppBusinessInterface): ...@@ -1897,13 +1902,13 @@ class AppBusinessController(AppBusinessInterface):
listentime: Qt.QDateTime listentime: Qt.QDateTime
focusing_times: Qt.QDateTime focusing_times: Qt.QDateTime
isWrong: int = RECODE_FAILURE isWrong: int = RECODE_FAILURE
position_z: int = focusing_b_z # position_z: int = focusing_b_z
last_position_z: int = focusing_b_z # last_position_z: int = focusing_b_z
index: int = 1 index: int = 1
maxwaittimes: int = 10000 maxwaittimes: int = 10000
max_focusing_times: int = 60000 # max_focusing_times: int = 60000
"""开始Z轴定速定焦""" """开始Z轴定速定焦"""
begintimes = Qt.QDateTime.currentDateTime() # begintimes = Qt.QDateTime.currentDateTime()
logSCANNING << f"{AppConvert.QDateTimeToString(Qt.QDateTime.currentDateTime())}开始玻片定焦" logSCANNING << f"{AppConvert.QDateTimeToString(Qt.QDateTime.currentDateTime())}开始玻片定焦"
"""开始定焦""" """开始定焦"""
...@@ -1912,7 +1917,7 @@ class AppBusinessController(AppBusinessInterface): ...@@ -1912,7 +1917,7 @@ class AppBusinessController(AppBusinessInterface):
self.microscope.set_z_range(min(focusing_b_z, focusing_e_z), max(focusing_b_z, focusing_e_z)) self.microscope.set_z_range(min(focusing_b_z, focusing_e_z), max(focusing_b_z, focusing_e_z))
self.microscope.POS_CONST_Z(focusing_z_speed) self.microscope.POS_CONST_Z(focusing_z_speed)
focusing_times = Qt.QDateTime.currentDateTime() focusing_times = Qt.QDateTime.currentDateTime()
endtime: Qt.QDateTime = Qt.QDateTime.currentDateTime().addMSecs(maxwaittimes) # endtime: Qt.QDateTime = Qt.QDateTime.currentDateTime().addMSecs(maxwaittimes)
while True: while True:
if isFilter: if isFilter:
if self.status.focusing_status == ScanStatusLevel.FocusingFinish_Status: if self.status.focusing_status == ScanStatusLevel.FocusingFinish_Status:
...@@ -1925,18 +1930,19 @@ class AppBusinessController(AppBusinessInterface): ...@@ -1925,18 +1930,19 @@ class AppBusinessController(AppBusinessInterface):
item.Level = focusing_status item.Level = focusing_status
item.Index = index item.Index = index
index += 1 index += 1
listentime = Qt.QDateTime.currentDateTime() # listentime = Qt.QDateTime.currentDateTime()
if isGrabbing:
self.camera.GetFocusingData(item, classifier)
else:
self.camera.GetRequestData(item, classifier)
# print(f"1一帧定焦数据:{index} {listentime.msecsTo(Qt.QDateTime.currentDateTime())}ms") # print(f"1一帧定焦数据:{index} {listentime.msecsTo(Qt.QDateTime.currentDateTime())}ms")
isWrong, position_z = self.motion.get_position_z() isWrong, position_z = self.motion.get_position_z()
"""获取Z轴位置错误 重新移动到目标位置""" """获取Z轴位置错误 重新移动到目标位置"""
if RECODE_SUCCEED == isWrong: if RECODE_SUCCEED == isWrong:
if isGrabbing:
self.camera.GetFocusingData(item, classifier)
else:
self.camera.GetRequestData(item, classifier)
item.Position_Z = position_z item.Position_Z = position_z
self.focusing_pool.SendEvent(item) self.focusing_pool.SendEvent(item)
print(f"2一帧定焦数据:{index} {listentime.msecsTo(Qt.QDateTime.currentDateTime())}ms") # print(f"2一帧定焦数据:{index} {listentime.msecsTo(Qt.QDateTime.currentDateTime())}ms")
if index % 5 == 0: if index % 5 == 0:
isWrong, Moving, Lower, Upper, Limit, Focus = self.microscope.ZDriverMoveStatus() isWrong, Moving, Lower, Upper, Limit, Focus = self.microscope.ZDriverMoveStatus()
if RECODE_SUCCEED == isWrong: if RECODE_SUCCEED == isWrong:
...@@ -2345,20 +2351,18 @@ class AppBusinessController(AppBusinessInterface): ...@@ -2345,20 +2351,18 @@ class AppBusinessController(AppBusinessInterface):
"""获取当前位置 如果当前机械臂位置大于安全位置 先回安全位置 再放片""" """获取当前位置 如果当前机械臂位置大于安全位置 先回安全位置 再放片"""
self.hitbot.flush_scara_param() self.hitbot.flush_scara_param()
self.hitbot.moveToSafePosition()
# SafeAction: HitBotSafeAction = HitBotSafeAction.getMinPrimaryItem()
# if not isinstance(SafeAction, HitBotModelInterface) or not isinstance(self.hitbot.yPosition, (int, float)):
# self.hitbot.moveToSafePosition()
# elif Float(self.hitbot.yPosition) < float(round(SafeAction.yPosition, 2)):
# self.hitbot.moveToSafePosition()
"""玻片取放片过程中不处理停止业务 只处理暂停业务""" """玻片取放片过程中不处理停止业务 只处理暂停业务"""
Action = Actions[0] Action = Actions[0]
if chamber_number == 4 or chamber_number == 9: if chamber_number == 4 or chamber_number == 9:
self.hitbot.moveToSafePosition(True)
Action.speed = self.system.HitBotSpeed4 Action.speed = self.system.HitBotSpeed4
elif chamber_number == 5 or chamber_number == 10: elif chamber_number == 5 or chamber_number == 10:
self.hitbot.moveToSafePosition(True)
Action.speed = self.system.HitBotSpeed5 Action.speed = self.system.HitBotSpeed5
else:
self.hitbot.moveToSafePosition()
isWrong = self.waitForSucceedMoving(Action) isWrong = self.waitForSucceedMoving(Action)
if RECODE_SUCCEED != isWrong: if RECODE_SUCCEED != isWrong:
Actions = HitBotChamberDropAction.getChamberDropActions(chamber_number, row_number) Actions = HitBotChamberDropAction.getChamberDropActions(chamber_number, row_number)
......
...@@ -154,8 +154,8 @@ class ChamberDropBusiness(Qt.QObject, AppBusinessController): ...@@ -154,8 +154,8 @@ class ChamberDropBusiness(Qt.QObject, AppBusinessController):
MinChamberNumber, MaxChamberNumber = self.system.getChamberRange () MinChamberNumber, MaxChamberNumber = self.system.getChamberRange ()
if MinChamberNumber <= chamber_number <= MaxChamberNumber and MinRowNumber <= row_number <= MaxRowNumber: if MinChamberNumber <= chamber_number <= MaxChamberNumber and MinRowNumber <= row_number <= MaxRowNumber:
"""如果当前玻片不能取 直接退出""" """如果当前玻片不能取 直接退出"""
if not ChamberStatusModel.IsPickAvailable(chamber_number, row_number): # if not ChamberStatusModel.IsPickAvailable(chamber_number, row_number):
return RECODE_FAILURE # return RECODE_FAILURE
if not self.isValid(): if not self.isValid():
return RECODE_FAILURE return RECODE_FAILURE
if not self.isAvailable: if not self.isAvailable:
......
...@@ -105,7 +105,12 @@ class ChamberPickBusiness(Qt.QObject, AppBusinessController): ...@@ -105,7 +105,12 @@ class ChamberPickBusiness(Qt.QObject, AppBusinessController):
if RECODE_SUCCEED != isWrong: if RECODE_SUCCEED != isWrong:
return isWrong return isWrong
if isSafe: if isSafe:
self.hitbot.moveToSafePosition() if chamber_number == 4 or chamber_number == 9:
self.hitbot.moveToSafePosition(True)
elif chamber_number == 5 or chamber_number == 10:
self.hitbot.moveToSafePosition(True)
else:
self.hitbot.moveToSafePosition()
"""处理片仓安装状态""" """处理片仓安装状态"""
while not self.waitForChamberAvailable(): while not self.waitForChamberAvailable():
AppTimeLoop.processEvents(self.system.WarningWaitTimes()) AppTimeLoop.processEvents(self.system.WarningWaitTimes())
...@@ -116,7 +121,12 @@ class ChamberPickBusiness(Qt.QObject, AppBusinessController): ...@@ -116,7 +121,12 @@ class ChamberPickBusiness(Qt.QObject, AppBusinessController):
AppTimeLoop.processEvents(self.system.WarningWaitTimes()) AppTimeLoop.processEvents(self.system.WarningWaitTimes())
if self.status.waitForExitRunning(): if self.status.waitForExitRunning():
if isSafe: if isSafe:
self.hitbot.moveToSafePosition() if chamber_number == 4 or chamber_number == 9:
self.hitbot.moveToSafePosition(True)
elif chamber_number == 5 or chamber_number == 10:
self.hitbot.moveToSafePosition(True)
else:
self.hitbot.moveToSafePosition()
return RECODE_SUCCEED return RECODE_SUCCEED
isWrong = self.waitForChamberPickSlide(chamber_number, row_number) isWrong = self.waitForChamberPickSlide(chamber_number, row_number)
...@@ -137,7 +147,12 @@ class ChamberPickBusiness(Qt.QObject, AppBusinessController): ...@@ -137,7 +147,12 @@ class ChamberPickBusiness(Qt.QObject, AppBusinessController):
isWrong = self.waitForPickWarning(chamber_number, row_number) isWrong = self.waitForPickWarning(chamber_number, row_number)
if isSafe and RECODE_SUCCEED == isWrong: if isSafe and RECODE_SUCCEED == isWrong:
self.hitbot.moveToSafePosition() if chamber_number == 4 or chamber_number == 9:
self.hitbot.moveToSafePosition(True)
elif chamber_number == 5 or chamber_number == 10:
self.hitbot.moveToSafePosition(True)
else:
self.hitbot.moveToSafePosition()
if isExit: if isExit:
"""处理暂停 退出""" """处理暂停 退出"""
......
...@@ -497,8 +497,8 @@ class SlideCellFocusingBusiness(Qt.QObject, AppBusinessController): ...@@ -497,8 +497,8 @@ class SlideCellFocusingBusiness(Qt.QObject, AppBusinessController):
focusing_z_speed = Focusing.FocusingSpeed focusing_z_speed = Focusing.FocusingSpeed
objective_focusing_positions = model.Position_Z # objective_focusing_positions = model.Position_Z #
objective_focusing_difference = abs(model.Position_Z) - FocalDistance objective_focusing_difference = abs(model.Position_Z) - FocalDistance
focusing_b_z = max(min(int(objective_focusing_positions - abs(FocalDistance) - abs(focusing_length)), Focus_Upper_Limit), Focus_Lower_Limit) focusing_b_z = max(min(int(objective_focusing_positions - abs(FocalDistance) ), Focus_Upper_Limit), Focus_Lower_Limit)
focusing_e_z = max(min(int(objective_focusing_positions + abs(FocalDistance) + abs(focusing_length)), Focus_Upper_Limit), Focus_Lower_Limit) focusing_e_z = max(min(int(objective_focusing_positions + abs(focusing_length) ), Focus_Upper_Limit), Focus_Lower_Limit)
item = model.copy() item = model.copy()
item.Index = index item.Index = index
item.Focusing = Focusing item.Focusing = Focusing
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#!D:/IDE/anaconda3/envs python
# -*- coding: UTF-8 -*-
"""
@Author: Administrator
@FileName:__init__.py.py\n
@DateTime: 2025/6/18 17:32\n
@Author :xsh
"""
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -88,6 +88,7 @@ class ModBusPool(Qt.QObject, ModBusPoolInterface, SingletonInterface): ...@@ -88,6 +88,7 @@ class ModBusPool(Qt.QObject, ModBusPoolInterface, SingletonInterface):
super(ModBusPool, self).deleValue() super(ModBusPool, self).deleValue()
self.deleManagers() self.deleManagers()
def IsOpen(self) -> bool: def IsOpen(self) -> bool:
handler: ModBusInterface = self.handle handler: ModBusInterface = self.handle
return isinstance(handler, ModBusInterface) and handler.IsOpen() return isinstance(handler, ModBusInterface) and handler.IsOpen()
......
...@@ -227,7 +227,7 @@ class HitBotReaderInterface(AppReaderInterface): ...@@ -227,7 +227,7 @@ class HitBotReaderInterface(AppReaderInterface):
pass pass
@abstractmethod @abstractmethod
def moveToSafePosition(self): def moveToSafePosition(self, isSlow: bool = False):
pass pass
@abstractmethod @abstractmethod
......
...@@ -31,17 +31,17 @@ if __name__ == "__main__": ...@@ -31,17 +31,17 @@ if __name__ == "__main__":
if AppUtils.IsServerAvailable(AppConfig.WebConfig.API): if AppUtils.IsServerAvailable(AppConfig.WebConfig.API):
from AppInterfaces.bases import * from AppInterfaces.bases import *
from AppUtils.DataBaseDeploy import DataBaseDeploy from AppUtils.DataBaseDeploy import DataBaseDeploy
from AppSettings.AppStatusSetting import AppStatus from AppSettings.AppGlobalStatus import AppStatus
from AppSettings.SystemSetting import SystemConfig from AppSettings.SystemSetting import SystemConfig
from AppSettings.HitBotSetting import HitBotSetting, HitBotConfig from AppSettings.HitBotSetting import HitBotSetting, HitBotConfig
from AppBackEnd.AppEventBusBusiness import * from AppBackEnd.AppEventBusBusiness import *
from AppCore.AppDBModels.DBModels import * from AppCore.AppDBModels.DBModels import *
DataBaseDeploy.init() DataBaseDeploy.init()
AppStatus.UpdateFromDBModel() AppStatus.UpdateMaxLocation()
HitBotConfig.UpdateFromDBModel() SystemConfig.UpdateMaxLocation()
SystemConfig.UpdateFromDBModel() HitBotConfig.UpdateMaxLocation()
TrayModel.UpdateModel() TrayModel.UpdateMaxLocation()
from AppCore.AppManagers.HardWareManager import HardWareManager from AppCore.AppManagers.HardWareManager import HardWareManager
from AppCore.Readers import ModBusPool from AppCore.Readers import ModBusPool
from AppBackEnd.AppScanningFlow import AppScanningFlow from AppBackEnd.AppScanningFlow import AppScanningFlow
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment