91 lines
3.1 KiB
Python
91 lines
3.1 KiB
Python
from typing import Dict, Optional
|
|
|
|
import ChanKLC, ChanSEG
|
|
import ChanCTime
|
|
from ChanEnum import Chan_ZS_DIR
|
|
# 中枢
|
|
class ChanZS():
|
|
def __init__(self, start_seg: ChanSEG, index, ddir: Chan_ZS_DIR):
|
|
self.start_klc = start_seg.start_bi.start_klc
|
|
self.start_time = self.start_klc.start_time
|
|
self.end_time = None
|
|
self.index = index
|
|
self.next = None
|
|
self.pre = None
|
|
self.start_seg = start_seg
|
|
self.seg_list = []
|
|
self.seg_list.append(start_seg)
|
|
self.end_seg = None
|
|
self.last_bi_in = None
|
|
self.bi_out = None
|
|
self.is_sure = False
|
|
self.zg = 0
|
|
self.zd = 0
|
|
self.gg = 0
|
|
self.dd = 0
|
|
self.dir = ddir
|
|
self.sure_time = None
|
|
self.end_klc = None
|
|
self.bi_out_count = 0
|
|
self.bi_out_list = []
|
|
self.bi_out_seg_list = []
|
|
self.bi_out_seg = None
|
|
def set_last_bi_in(self, last_bi_in):
|
|
self.last_bi_in = last_bi_in
|
|
def set_bi_out(self, bi_out, bi_out_seg):
|
|
if bi_out:
|
|
#print(bi_out.start_klc.start_time, bi_out.sure_time, bi_out.dir, bi_out_seg.dir, len(self.bi_out_list))
|
|
if len(self.bi_out_list) > 0:
|
|
last_bi = self.bi_out_list[-1]
|
|
if last_bi.index != bi_out.index:
|
|
self.bi_out_list.append(bi_out)
|
|
self.bi_out_seg_list.append(bi_out_seg)
|
|
else:
|
|
self.bi_out_list.append(bi_out)
|
|
self.bi_out_seg_list.append(bi_out_seg)
|
|
self.bi_out = bi_out
|
|
self.bi_out_seg = bi_out_seg
|
|
def set_end_klc(self, end_klc, sure_time, bi_out_count, seg):
|
|
self.end_klc = end_klc
|
|
self.set_end_time(end_klc.end_time)
|
|
self.is_sure = True
|
|
self.sure_time = sure_time
|
|
self.bi_out_count = bi_out_count
|
|
self.end_seg = seg
|
|
def set_end_seg(self, end_seg):
|
|
self.end_seg = end_seg
|
|
def set_pre(self, pre):
|
|
self.pre = pre
|
|
def set_next(self, next):
|
|
self.next = next
|
|
def set_end_time(self, end_time):
|
|
self.end_time = end_time
|
|
def add_klc(self, klc):
|
|
self.klc_list.append(klc)
|
|
def set_zg(self, zg):
|
|
self.zg = zg
|
|
def set_zd(self, zd):
|
|
self.zd = zd
|
|
def set_gg(self, gg):
|
|
self.gg = gg
|
|
def set_dd(self, dd):
|
|
self.dd = dd
|
|
|
|
|
|
# 大级别中枢:由多个区间重叠(扩张)的笔/线段中枢合并而成,用于显示更大级别的震荡区间
|
|
class ChanZS_Big():
|
|
def __init__(self, zs_list):
|
|
assert len(zs_list) >= 1
|
|
self.zs_list = list(zs_list)
|
|
first = self.zs_list[0]
|
|
last = self.zs_list[-1]
|
|
self.start_time = first.start_time
|
|
self.end_time = last.end_time if last.end_time else None
|
|
self.start_klc = first.start_klc
|
|
self.end_klc = last.end_klc
|
|
# 大级别区间取并集:包住所有子中枢
|
|
self.zd = min(zs.zd for zs in self.zs_list)
|
|
self.zg = max(zs.zg for zs in self.zs_list)
|
|
self.dd = min(zs.dd for zs in self.zs_list)
|
|
self.gg = max(zs.gg for zs in self.zs_list)
|
|
self.index = 0 # 由外部设置 |