-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_initial_connect.py
More file actions
92 lines (74 loc) · 3.08 KB
/
Copy pathtest_initial_connect.py
File metadata and controls
92 lines (74 loc) · 3.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
"""
接続テスト
デバイスに接続し、各種情報を表示する
"""
import sys
sys.stdout.reconfigure(encoding='utf-8') # Windowsでの文字化け対策
from dss300_hr import Dss300Hr
def main():
device = Dss300Hr()
print("=" * 60)
print("接続テスト")
print("=" * 60)
# デバイスリスト表示
devices = device.list_devices()
print(f"DSS300-HR (12CH AD) デバイス: {len(devices)}台")
for dev in devices:
print(f" [{dev['index']}] {dev['description']} (Serial: {dev['serial']})")
if not devices:
print("デバイスが見つかりません")
return
# 接続
if not device.connect():
print("デバイス接続失敗")
return
# デバイス情報表示
info = device.info
print("\n--- デバイス情報 ---")
print(f"シリアル: {info.serial}")
print(f"レビジョン: {info.revision}")
print(f"ファームウェアバージョン: {info.version}")
print(f"ID: {info.device_id}")
print(f"測定周波数: {info.frequency} Hz")
print(f"まとめ数: {info.matome}")
print(f"有効CH数: {device.ch_count}")
print(f"ステータス: {device.status.name}")
print("\n--- トリガ設定 ---")
print(f"外部トリガでの測定停止: {info.is_stop_trig_enable}")
print(f"プリトリガ: {info.is_pretrig_enable}")
print(f"TTL(無効時は接点): {info.is_ttl_enable}")
print(f"正論理(無効時は負論理): {info.is_active_high}")
print(f"TTL OUT(無効時はTTL IN): {info.is_ttl_out_enable}")
print("\n--- ハードウェア対応状況 ---")
print(f"20kHz 12CH: {info.is_12ch_20khz_available}")
print(f"有効CH数設定: {info.is_ch_count_available}")
print(f"マスタ/スレーブチェック: {info.is_master_check_available}")
print(f"レベルトリガ: {info.is_level_trig_available}")
if info.is_master_check_available:
print(f"\nマスタ/スレーブ: {'マスタ' if info.is_master_enable else 'スレーブ'}")
print(f"同期クロック出力: {info.is_conv_out_enable}")
if info.is_level_trig_available:
print("\n--- レベルトリガ設定 ---")
print(f"閾値: {info.level_threshold}")
print(f"スロープ: {info.level_slope.name}")
print(f"CH: {info.level_ch}")
print("\n--- 校正パラメータ ---")
cal = device.calibration
print(f"{'CH':>3} {'ゼロ点':>10} {'アンプ校正値':>12}")
for ch in range(device.CH_COUNT_MAX):
print(f"{ch:>3} {cal.zero_offset[ch]:>10.2f} {cal.amp_prf[ch]:>12.6f}")
# 現在値取得(マスタのみ)
if not info.is_master_check_available or info.is_master_enable:
print("\n--- 現在値 ---")
now = device.get_now()
if now is not None:
print(f"AD値: {now.tolist()}")
eng = device.ad_to_eng(now)
print(f"工学値: {[f'{v:.3f}' for v in eng]}")
else:
print("現在値取得失敗")
# 切断
device.disconnect()
print("\nテスト完了")
if __name__ == "__main__":
main()