中途改进
This commit is contained in:
29
reactor.py
29
reactor.py
@@ -2,20 +2,24 @@ import typing
|
||||
import particles as pt
|
||||
import pathlib
|
||||
import auxiliary as aux
|
||||
import compositions
|
||||
|
||||
class Apparatus():
|
||||
"""反应器对象, 处理一个原子的记忆工作, 并反馈到布局"""
|
||||
def __init__(self, atom):
|
||||
self.electron = atom[0]
|
||||
self.nucleon = atom[1]
|
||||
|
||||
def report(self):
|
||||
self.electron: pt.Electron = atom[0]
|
||||
self.nucleon: pt.Nucleon = atom[1]
|
||||
self.positron: dict = atom[2]
|
||||
self.testdata = self.positron["testdata"]
|
||||
|
||||
def iterator(self):
|
||||
pass
|
||||
|
||||
def assess(self):
|
||||
pass
|
||||
def composer(self):
|
||||
if self.positron["is_new_activation"] == 1:
|
||||
self.positron["is_new_activation"] = 0
|
||||
|
||||
def iterate(self):
|
||||
def updater(self):
|
||||
pass
|
||||
|
||||
|
||||
@@ -35,23 +39,26 @@ class Reactor():
|
||||
|
||||
def electron_dict_get_fallback(key) -> pt.Electron:
|
||||
value = self.electron_dict.get(key)
|
||||
|
||||
# 如果值不存在,则设置默认值
|
||||
if value is None:
|
||||
value = pt.Electron(key, {}) # 获取默认值
|
||||
self.electron_dict[key] = value # 将默认值存入字典
|
||||
electron_file.sync()
|
||||
|
||||
return value # 返回获取的值(可能是默认值)
|
||||
|
||||
for nucleon in nucleon_file.nucleons:
|
||||
atom = (electron_dict_get_fallback(nucleon.content), nucleon)
|
||||
# atom = (Electron, Nucleon, Positron) 即 (记忆元数据, 内容元数据, 运行时数据)
|
||||
atom = (electron_dict_get_fallback(nucleon.content), nucleon, {}) # 使用 "Positron" 代称 atom[2]
|
||||
atom[2]["testdata"] = nucleon_file.testdata
|
||||
atom[2]["keydata"] = nucleon_file.keydata
|
||||
if atom[0]["is_activated"] == 0:
|
||||
if counter > 0:
|
||||
atom[2]["is_new_activation"] = 1
|
||||
atom[0]["is_activated"] = 1
|
||||
self.atoms_new.append(atom)
|
||||
counter -= 1
|
||||
else:
|
||||
atom[2]["is_new_activation"] = 0
|
||||
if int(atom[0]["next_date"]) <= aux.get_daystamp():
|
||||
atom[0]["last_date"] = aux.get_daystamp()
|
||||
self.atoms_review.append(atom)
|
||||
@@ -61,7 +68,7 @@ class Reactor():
|
||||
self.failed: list
|
||||
self.round_title: str
|
||||
self.reported: set
|
||||
self.current_atom: typing.Tuple[pt.Electron, pt.Nucleon]
|
||||
self.current_atom: typing.Tuple[pt.Electron, pt.Nucleon, dict]
|
||||
self.round_set = 0
|
||||
self.current_atom = pt.Atom.placeholder()
|
||||
|
||||
|
Reference in New Issue
Block a user