diff --git a/chanlun-py/chanlun/__init__.pyi b/chanlun-py/chanlun/__init__.pyi index 3ea5b94..7e7e0b1 100644 --- a/chanlun-py/chanlun/__init__.pyi +++ b/chanlun-py/chanlun/__init__.pyi @@ -435,9 +435,9 @@ class 虚线: @property def 模式(self) -> str: ... @property - def 特征序列_显示(self) -> bool: ... - @特征序列_显示.setter - def 特征序列_显示(self, value: bool) -> None: ... + def _特征序列_显示(self) -> bool: ... + @_特征序列_显示.setter + def _特征序列_显示(self, value: bool) -> None: ... @property def 特征序列(self) -> List[Optional[线段特征]]: ... @property @@ -523,6 +523,8 @@ class 虚线: class 线段特征: @property def 序号(self) -> int: ... + @序号.setter + def 序号(self, value: int) -> None: ... @property def 标识(self) -> str: ... @标识.setter @@ -790,6 +792,30 @@ class 观察者: def 扩展线段序列_扩展线段(self) -> List[虚线]: ... @property def 扩展中枢序列_扩展线段(self) -> List[中枢]: ... + @property + def 线段分析层次(self) -> int: ... + @线段分析层次.setter + def 线段分析层次(self, value: int) -> None: ... + @property + def 扩展线段分析层次(self) -> int: ... + @扩展线段分析层次.setter + def 扩展线段分析层次(self, value: int) -> None: ... + @property + def 混合扩展线段分析层次(self) -> int: ... + @混合扩展线段分析层次.setter + def 混合扩展线段分析层次(self, value: int) -> None: ... + @property + def 线段序列组(self) -> List[List[虚线]]: ... + @property + def 中枢序列组(self) -> List[List[中枢]]: ... + @property + def 扩展线段序列组(self) -> List[List[虚线]]: ... + @property + def 扩展中枢序列组(self) -> List[List[中枢]]: ... + @property + def 混合扩展线段序列组(self) -> List[List[虚线]]: ... + @property + def 混合扩展中枢序列组(self) -> List[List[中枢]]: ... def 重置基础序列(self) -> None: ... def 增加原始K线(self, 普K: K线) -> None: ... def 投喂原始数据(self, 时间戳: int, 开: float, 高: float, 低: float, 收: float, 量: float) -> None: ... diff --git a/chanlun-py/src/structure_py.rs b/chanlun-py/src/structure_py.rs index 01d665a..eec6cd7 100644 --- a/chanlun-py/src/structure_py.rs +++ b/chanlun-py/src/structure_py.rs @@ -994,7 +994,13 @@ pub struct 线段特征Py { impl 线段特征Py { #[getter] fn 序号(&self) -> i64 { - self.inner.序号 + self.inner.序号.load(Ordering::Relaxed) + } + + #[setter] + #[pyo3(name = "序号")] + fn set_序号(&self, value: i64) { + self.inner.序号.store(value, Ordering::Relaxed); } #[getter] diff --git a/chanlun/src/structure/segment_feat.rs b/chanlun/src/structure/segment_feat.rs index 3009607..ba1edf0 100644 --- a/chanlun/src/structure/segment_feat.rs +++ b/chanlun/src/structure/segment_feat.rs @@ -26,6 +26,7 @@ use crate::structure::dash_line::虚线; use crate::structure::feat_fractal::特征分型; use crate::structure::fractal_obj::分型; use crate::types::{分型结构, 相对方向}; +use std::sync::atomic::AtomicI64; use std::sync::atomic::Ordering; use std::sync::{Arc, RwLock}; @@ -48,7 +49,7 @@ use std::sync::{Arc, RwLock}; #[derive(Debug)] pub struct 线段特征 { /// 特征序列元素编号 - pub 序号: i64, + pub 序号: AtomicI64, /// 标识字符串(如 "特征<虚线>") pub 标识: RwLock, /// 所属线段的方向 @@ -60,7 +61,7 @@ pub struct 线段特征 { impl Clone for 线段特征 { fn clone(&self) -> Self { Self { - 序号: self.序号, + 序号: AtomicI64::new(self.序号.load(Ordering::Relaxed)), 标识: RwLock::new(self.标识.read().unwrap().clone()), 线段方向: self.线段方向, 基础序列: self.基础序列.clone(), @@ -72,7 +73,7 @@ impl 线段特征 { /// 新建线段特征(给定标识、基础序列和线段方向) pub fn new(标识: String, 基础序列: Vec>, 线段方向: 相对方向) -> Self { Self { - 序号: 0, + 序号: AtomicI64::new(0), 标识: RwLock::new(标识), 线段方向, 基础序列, @@ -319,10 +320,14 @@ impl 线段特征 { /// 结构化相等校验 — 逐项递归校验基础序列中的虚线,返回 (是否相等, 差异描述) pub fn 相等(&self, other: &Self, 浮点容差: f64) -> (bool, String) { - if self.序号 != other.序号 { + if self.序号.load(Ordering::Relaxed) != other.序号.load(Ordering::Relaxed) { return ( false, - format!("线段特征: [序号] 不等 A={},B={}", self.序号, other.序号), + format!( + "线段特征: [序号] 不等 A={},B={}", + self.序号.load(Ordering::Relaxed), + other.序号.load(Ordering::Relaxed) + ), ); } if *self.标识.read().unwrap() != *other.标识.read().unwrap() {