From 0a7e9dc896cf86962fbbe34c99f51b2e70cb213c Mon Sep 17 00:00:00 2001 From: YuWuKunCheng Date: Sat, 6 Jun 2026 22:02:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=82=E5=AF=9F=E8=80=85=20=E7=BA=BF?= =?UTF-8?q?=E6=AE=B5=E5=88=86=E6=9E=90/=E6=89=A9=E5=B1=95=E5=88=86?= =?UTF-8?q?=E6=9E=90=20=E6=94=AF=E6=8C=81=E6=97=A0=E9=99=90=E9=80=92?= =?UTF-8?q?=E5=BD=92=EF=BC=8C=E4=BF=9D=E7=95=99=E4=B9=8B=E5=89=8D=E5=BA=8F?= =?UTF-8?q?=E5=88=97=E4=B8=BA@property=20=E5=BD=A2=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chanlun-py/chanlun/__init__.pyi | 32 ++++++++++++++++++++++++--- chanlun-py/src/structure_py.rs | 8 ++++++- chanlun/src/structure/segment_feat.rs | 15 ++++++++----- 3 files changed, 46 insertions(+), 9 deletions(-) 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() {