添加中枢延续

This commit is contained in:
jackyu66git
2026-04-05 17:55:09 +08:00
parent 6a6d24f601
commit 2bf9fe5825
6 changed files with 103 additions and 35 deletions
+64 -27
View File
@@ -923,12 +923,18 @@ class TF_DF():
"""
#self.cal_bi_zs(seg_list)
return seg_list
def get_zs_state(self, df):
bi_list = self.cal_bi_list(self.get_klc_list(self.get_kl_data(df)))
seg_list = self.get_seg_list(bi_list)
zs_list = self.calculate_zs(seg_list)
for zs in zs_list:
last_zs = zs
return zs_list
def cal_bi_list(self, klc_list):
bi_list = []
last_top = None
last_bottom = None
bi_klc_min = 7
bi_klc_min = 4
last_fx_klc = None
for klc in klc_list:
if last_fx_klc:
@@ -1784,26 +1790,44 @@ class TF_DF():
# 不重叠下移
zs_dir = Chan_ZS_DIR.DOWN
valid = (seg1.dir == Chan_SEG_DIR.UP and seg2.dir == Chan_SEG_DIR.DOWN and seg3.dir == Chan_SEG_DIR.UP)
create_new_zs = False
# 验证是否有效
if not valid:
start_idx += 1
continue
# 如果新中枢和前一个中枢的中枢区间有重叠,不行成新中枢需要合并两个中枢
is_in_last_zs = (zd > last_zs.zd and zd < last_zs.zg) or (zg < last_zs.zg and zg > last_zs.zd) or (zg > last_zs.zg and zd < last_zs.zd) or (zg < last_zs.zg and zd > last_zs.zd)
if is_in_last_zs:
#print(seg1.start_time, "New zs is in last zs, not valid")
last_zs.extend_zs(seg_list[last_zs.seg_list[-1].index:(seg3.index + 1)])
create_new_zs = False
else:
start_idx += 1
continue
else:
create_new_zs = True
if last_zs and create_new_zs:
last_seg = last_zs.seg_list[-1]
last_bi = last_seg.end_bi
if last_bi:
last_zs.is_sure = True
last_zs.set_end_klc(last_bi.end_klc, last_bi.sure_time, 0, last_seg)
last_zs.set_end_seg(last_seg)
zs = last_zs
if create_new_zs:
# 创建新中枢
gg = max(seg1.high, seg2.high, seg3.high)
dd = min(seg1.low, seg2.low, seg3.low)
# 创建新中枢
gg = max(seg1.high, seg2.high, seg3.high)
dd = min(seg1.low, seg2.low, seg3.low)
zs = ChanZS(seg1, len(zs_list), zs_dir)
zs.set_zg(zg)
zs.set_zd(zd)
zs.set_gg(gg)
zs.set_dd(dd)
zs.is_sure = False
zs.seg_list = [seg1, seg2, seg3]
zs = ChanZS(seg1, len(zs_list), zs_dir)
zs.set_zg(zg)
zs.set_zd(zd)
zs.set_gg(gg)
zs.set_dd(dd)
zs.is_sure = False
zs.seg_list = [seg1, seg2, seg3]
# 若第二线段与 [zd,zg] 重叠(如离开后回抽回到前中枢)则并入扩展
added_after_leave = []
leave_index = start_idx + 4
is_break = False
while leave_index < len(seg_list):
s = seg_list[leave_index]
if not s.is_sure:
@@ -1813,9 +1837,24 @@ class TF_DF():
if sh >= zs.zd and sl <= zs.zg:
added_after_leave.append(s.pre)
added_after_leave.append(s)
leave_index += 2
else:
next_seg = s.next
if next_seg and next_seg.is_sure:
if next_seg.dir == Chan_SEG_DIR.UP:
if next_seg.high <= zs.zg and next_seg.low >= zs.zd:
leave_index += 2
continue
else:
is_break = True
else:
if next_seg.low >= zs.zd and next_seg.low <= zs.zg:
leave_index += 2
continue
else:
is_break = True
if is_break:
break
leave_index += 2
if added_after_leave:
#print(len(added_after_leave))
segs_for_zs = list(zs.seg_list) + list(added_after_leave)
@@ -1825,16 +1864,12 @@ class TF_DF():
zs.set_dd(min(seg_lows))
zs.seg_list = segs_for_zs
seg = segs_for_zs[-1]
if seg.end_bi:
zs.set_end_klc(seg.end_bi.end_klc, seg.sure_time, 0, seg)
zs.set_end_seg(seg)
zs.is_sure = True
#if seg.end_bi:
#zs.set_end_klc(seg.end_bi.end_klc, seg.sure_time, 0, seg)
#zs.set_end_seg(seg)
#zs.is_sure = True
start_idx = start_idx + len(added_after_leave)
else:
zs.set_end_klc(seg3.end_bi.end_klc, seg3.sure_time, 0, seg3)
zs.set_end_seg(seg3)
zs.is_sure = True
if last_zs:
if last_zs and last_zs.index != zs.index:
last_zs.set_next(zs)
zs.set_pre(last_zs)
@@ -1845,6 +1880,7 @@ class TF_DF():
start_idx += 4
if last_zs:
last_zs.is_sure = seg_list[-1].is_sure
"""
# 处理最后一个未确认的中枢 - 不自动扩展,保持未完成状态
if last_zs and not last_zs.is_sure:
# 获取中枢最后一个线段的索引
@@ -1876,10 +1912,11 @@ class TF_DF():
else:
# 有离开,确认中枢
if last_seg_of_zs.end_bi:
#print(last_seg_of_zs.start_time, "last_seg_of_zs.end_time", last_seg_of_zs.end_time)
last_zs.set_end_klc(last_seg_of_zs.end_bi.end_klc, last_seg_of_zs.sure_time, 0, last_seg_of_zs)
last_zs.set_end_seg(last_seg_of_zs)
last_zs.is_sure = True
"""
return zs_list
def get_big_zs_list(self, zs_list):