1.原先程序启动后会先下发关闭位置,再开始闭环,现在启动后直接从当前阀门开度(默认全开)开始闭环。删除了safe_close相关的代码
2.新增open_loop.py进行开环控制,记录控流阀前后流量和压力数据,方便后面辨识拟合,以及观察动态特性。 3.新增README.md
This commit is contained in:
+2
-40
@@ -166,12 +166,9 @@ class FlowControlLoop:
|
||||
self.faulted = False
|
||||
self.running = True
|
||||
|
||||
def stop(self, close_valve=True):
|
||||
"""停止 PID;默认同时安全关阀。"""
|
||||
def stop(self):
|
||||
"""停止 PID;阀门保持当前开度(默认全开)。"""
|
||||
self.running = False
|
||||
self.pid.reset(initial_output=0.0)
|
||||
if close_valve:
|
||||
return self.safe_close("STOP_REQUESTED")
|
||||
return True
|
||||
|
||||
def step(self, now=None):
|
||||
@@ -290,39 +287,6 @@ class FlowControlLoop:
|
||||
actual_dt_s=actual_dt,
|
||||
)
|
||||
|
||||
def safe_close(self, reason="UNSPECIFIED"):
|
||||
"""尝试把阀门置于关闭端;失败时返回 False 并详细记录。"""
|
||||
try:
|
||||
success = bool(
|
||||
self.hardware.set_motor_position(
|
||||
self.motor_closed_position,
|
||||
channel=self.motor_channel,
|
||||
)
|
||||
)
|
||||
except Exception as exc:
|
||||
self._log(
|
||||
"critical",
|
||||
"SAFE_CLOSE_FAILED reason=%s exception=%s context=%s",
|
||||
reason,
|
||||
repr(exc),
|
||||
self._context(),
|
||||
)
|
||||
return False
|
||||
|
||||
if success:
|
||||
self.last_opening_pct = 0.0
|
||||
self.last_motor_position = self.motor_closed_position
|
||||
self._log("warning", "阀门已安全关闭,原因=%s", reason)
|
||||
return True
|
||||
|
||||
self._log(
|
||||
"critical",
|
||||
"SAFE_CLOSE_FAILED reason=%s hardware_return=False context=%s",
|
||||
reason,
|
||||
self._context(),
|
||||
)
|
||||
return False
|
||||
|
||||
def _read_flow(self):
|
||||
try:
|
||||
value = self.hardware.get_flow(self.flow_channel)
|
||||
@@ -409,8 +373,6 @@ class FlowControlLoop:
|
||||
context.update(extra_context or {})
|
||||
self.faulted = True
|
||||
self.running = False
|
||||
close_ok = self.safe_close(code)
|
||||
context["safe_close_success"] = close_ok
|
||||
fault = FlowControlFault(code, stage, message, context)
|
||||
self._log("critical", "%s", fault)
|
||||
raise fault
|
||||
|
||||
Reference in New Issue
Block a user