32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
# 移相器类定义
|
|
|
|
import heurams.kernel.particles as pt
|
|
from .states import PhaserState, ProcessionState
|
|
from .procession import Procession
|
|
|
|
class Phaser():
|
|
"""移相器: 全局调度阶段管理器"""
|
|
def __init__(self, atoms: list[pt.Atom]) -> None:
|
|
new_atoms = list()
|
|
old_atoms = list()
|
|
self.state = PhaserState.UNSURE
|
|
for i in atoms:
|
|
if not i.registry["electron"].is_activated():
|
|
new_atoms.append(i)
|
|
else:
|
|
old_atoms.append(i)
|
|
self.processions = list()
|
|
if len(old_atoms):
|
|
self.processions.append(Procession(old_atoms, PhaserState.QUICK_REVIEW, "初始复习"))
|
|
if len(new_atoms):
|
|
self.processions.append(Procession(new_atoms,PhaserState.RECOGNITION, "新记忆"))
|
|
self.processions.append(Procession(atoms,PhaserState.FINAL_REVIEW, "总体复习"))
|
|
|
|
def current_procession(self):
|
|
for i in self.processions:
|
|
i: Procession
|
|
if not i.state == ProcessionState.FINISHED:
|
|
self.state = i.phase
|
|
return i
|
|
self.state = PhaserState.FINISHED
|
|
return 0 |