half-sample 0.1.3__tar.gz → 0.1.4__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of half-sample might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: half-sample
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: sample data and analysis
5
5
  Home-page: https://github.com/KD-Group/Half.Sample
6
6
  Author: kunde
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: half-sample
3
- Version: 0.1.3
3
+ Version: 0.1.4
4
4
  Summary: sample data and analysis
5
5
  Home-page: https://github.com/KD-Group/Half.Sample
6
6
  Author: kunde
@@ -0,0 +1,120 @@
1
+ import math
2
+
3
+
4
+ class Result:
5
+ ErrorMessageMapper = {
6
+ # 基础状态
7
+ "success": "成功",
8
+
9
+ # 用户操作错误
10
+ "command_not_found": "命令不存在",
11
+ "sampler_not_found": "采样器不存在",
12
+ "now_in_measuring": "正在测量中",
13
+ "file_not_found": "文件未找到",
14
+
15
+ # 采样错误
16
+ "voltage_not_enough": "电压不足",
17
+ "wave_not_found": "未找到波形",
18
+ "appropriate_wave_not_found": "未找到合适波形",
19
+
20
+ # 警告类错误
21
+ "warning_intr_not_available": "中断资源不可用",
22
+ "warning_param_out_of_range": "参数超出范围",
23
+ "warning_prop_value_out_of_range": "属性值超出范围",
24
+ "warning_prop_value_not_spted": "属性值不支持",
25
+ "warning_prop_value_conflict": "属性值状态冲突",
26
+ "warning_vrg_of_group_not_same": "通道组量程不一致",
27
+
28
+ # 系统级错误
29
+ "error_handle_not_valid": "句柄无效",
30
+ "error_param_out_of_range": "参数超出范围",
31
+ "error_param_not_spted": "参数不支持",
32
+ "error_param_fmt_unexpted": "参数格式异常",
33
+ "error_memory_not_enough": "内存不足",
34
+ "error_buffer_is_null": "缓冲区为空",
35
+ "error_buffer_too_small": "缓冲区过小",
36
+ "error_data_len_exceed_limit": "数据长度超限",
37
+ "error_func_not_spted": "功能不支持",
38
+ "error_event_not_spted": "事件不支持",
39
+ "error_prop_not_spted": "属性不支持",
40
+ "error_prop_read_only": "属性只读",
41
+ "error_prop_value_conflict": "属性值冲突",
42
+ "error_prop_value_out_of_range": "属性值超限",
43
+ "error_prop_value_not_spted": "属性值不支持",
44
+ "error_privilege_not_held": "权限未持有",
45
+ "error_privilege_not_available": "权限不可用",
46
+ "error_driver_not_found": "驱动未找到",
47
+ "error_driver_ver_mismatch": "驱动版本不匹配",
48
+ "error_driver_count_exceed_limit": "驱动数量超限",
49
+ "error_device_not_opened": "设备未打开",
50
+ "error_device_not_exist": "设备不存在",
51
+ "error_device_unrecognized": "设备未识别",
52
+ "error_config_data_lost": "配置数据丢失",
53
+ "error_func_not_inited": "功能未初始化",
54
+ "error_func_busy": "功能忙",
55
+ "error_intr_not_available": "中断不可用",
56
+ "error_dma_not_available": "DMA通道不可用",
57
+ "error_device_io_time_out": "设备IO超时",
58
+ "error_signature_not_match": "签名不匹配",
59
+ "error_func_conflict_with_bfd_ai": "功能与缓冲AI冲突",
60
+ "error_vrg_not_available_in_se_mode": "单端模式量程不可用",
61
+ "error_undefined": "未定义错误"
62
+ }
63
+
64
+ def __init__(self):
65
+ self.error = False
66
+ self.message = ''
67
+
68
+ self.sampler_name = ''
69
+ self.measuring = False
70
+ self.success = False
71
+ self.with_magnetic = False
72
+
73
+ self.sampling_interval = 0.0 # us
74
+ self.wave_interval = 0.0 # us
75
+ self.waveforms_per_sample = 0.0 # 采集卡每次采样时能得到的最大波形数量,可能采集到部分波形,因此为double类型,例如0.5
76
+ self.sampling_time = 1 # 采样次数,当要求的波形数量大于采集卡单次最大采样点数的时,进行多次采样直到能采集到要求的波形
77
+ self.sampling_length_per_sample = 0 # 采集卡单次采样点数
78
+ self.waveform_length = 0 # 一个完整波形的点数(包括上升沿和下降沿)
79
+ self.valid_length = 0 # 有效的波形点数(仅包含上升沿部分)
80
+ self.number_of_waveforms = 0 # 波形平均次数
81
+ self.wave = []
82
+ self.time_line = []
83
+ self.estimate = []
84
+
85
+ self.tau = 0.0
86
+ self.tau_b = 0.0
87
+ self.w = 0.0
88
+ self.b = 0.0
89
+ self.loss = 0.0
90
+
91
+ self.v0 = 0.0
92
+ self.v_inf = 0.0
93
+
94
+ self.mock_tau = 0.0
95
+ self.mock_v0 = 0.0
96
+ self.mock_v_inf = 0.0
97
+ self.mock_noise = 0.0
98
+
99
+ self.rho = 0.0
100
+ self.miu = 0.0
101
+ self.carrier = 0.0
102
+ self.corrected_rho = 0.0
103
+ self.corrected_miu = 0.0
104
+ self.corrected_carrier = 0.0
105
+
106
+ def process(self):
107
+ self.time_line = [self.wave_interval * i for i in range(len(self.wave))]
108
+
109
+ if self.success:
110
+ tau, w, b = self.tau, self.w, self.b
111
+ self.estimate = [w * math.exp(t / -tau) + b for t in self.time_line]
112
+
113
+ self.v0, self.v_inf = b + w, b
114
+
115
+ @property
116
+ def chinese_message(self) -> str:
117
+ try:
118
+ return self.ErrorMessageMapper[self.message]
119
+ except Exception as e:
120
+ return self.message
@@ -39,13 +39,17 @@ class Sampler:
39
39
  return p
40
40
 
41
41
  def communicate(self, command: str, executor: st.Process = None) -> Result:
42
- executor = executor or self.p
43
-
44
- executor.write_line(command)
45
- lines = executor.read_until('EOF')
46
-
47
42
  result = Result()
48
- exec(lines, result.__dict__)
43
+ try:
44
+ executor = executor or self.p
45
+ executor.write_line(command)
46
+ lines = executor.read_until('EOF')
47
+ if lines:
48
+ exec(lines, result.__dict__)
49
+ except Exception as e:
50
+ result.error = True
51
+ result.message = str(e)
52
+ raise self.Error("{}: {}".format(result.message, result.chinese_message))
49
53
 
50
54
  if result.error:
51
55
  raise self.Error("{}: {}".format(result.message, result.chinese_message))
@@ -2,7 +2,7 @@ import setuptools
2
2
 
3
3
  setuptools.setup(
4
4
  name="half-sample",
5
- version="0.1.3",
5
+ version="0.1.4",
6
6
  author="kunde",
7
7
  author_email="gzkunde@163.com",
8
8
  description="sample data and analysis",
Binary file
@@ -1,62 +0,0 @@
1
- import math
2
-
3
-
4
- class Result:
5
- ErrorMessageMapper = {
6
- "success": "成功",
7
- "command_not_found": "命令不存在",
8
- "sampler_not_found": "采样器不存在",
9
- "now_in_measuring": "正在测量中",
10
- "voltage_not_enough": "电压不足",
11
- "real_sampler_error": "采样器出错",
12
- "wave_not_found": "未找到波形",
13
- "appropriate_wave_not_found": "未找到合适波形"
14
- }
15
-
16
- def __init__(self):
17
- self.error = False
18
- self.message = ''
19
-
20
- self.sampler_name = ''
21
- self.measuring = False
22
- self.success = False
23
-
24
- self.sampling_interval = 0.0 # us
25
- self.wave_interval = 0.0 # us
26
- self.wave = []
27
- self.time_line = []
28
- self.estimate = []
29
-
30
- self.tau = 0.0
31
- self.tau_b = 0.0
32
- self.w = 0.0
33
- self.b = 0.0
34
- self.loss = 0.0
35
-
36
- self.v0 = 0.0
37
- self.v_inf = 0.0
38
-
39
- self.mock_tau = 0.0
40
- self.mock_v0 = 0.0
41
- self.mock_v_inf = 0.0
42
- self.mock_noise = 0.0
43
-
44
- self.rho = 0.0
45
- self.miu = 0.0
46
- self.carrier = 0.0
47
- self.corrected_rho = 0.0
48
- self.corrected_miu = 0.0
49
- self.corrected_carrier = 0.0
50
-
51
- def process(self):
52
- self.time_line = [self.wave_interval * i for i in range(len(self.wave))]
53
-
54
- if self.success:
55
- tau, w, b = self.tau, self.w, self.b
56
- self.estimate = [w * math.exp(t / -tau) + b for t in self.time_line]
57
-
58
- self.v0, self.v_inf = b + w, b
59
-
60
- @property
61
- def chinese_message(self) -> str:
62
- return self.ErrorMessageMapper[self.message]
File without changes
File without changes