【发布时间】:2013-01-09 20:26:12
【问题描述】:
好的,所以我在高层次上做的是扫描系统以查找连接到它的所有 VISA 设备并让它们识别自己。
问题在于,并非所有 VISA 设备都支持识别自己的功能,而我知道的唯一方法是告诉设备这样做。这迫使那些无法识别自己的人依赖至少 1 秒的超时。在等待超时时,我的 TCL 脚本和 Wish 应用程序冻结,直到超时完成。对于多台设备,这让我的等待时间很尴尬,可能长达几秒钟,我无法向用户更新正在发生的事情。
这是我的代码:
proc ::VISA::Scan {} {
# Open a temporary resource manager
set TemporaryResourceManagerId [::visa::open-default-rm]
# Get addresses for all devices on system
foreach address [::visa::find $TemporaryResourceManagerId "?*"] {
# Create temporary VISA channel
set TemporaryChannel [visa::open $TemporaryResourceManagerId $address]
# Have device identify itself while suppressing errors
if {![catch {puts $TemporaryChannel "*IDN?"}]} {
if {![catch {gets $TemporaryChannel} result]} {
if {![string is space $result]} {
puts $address
puts "$result \n"
}
# Clear any potential errors
puts $TemporaryChannel "*CLS"
}
}
# Destroy temporary channel
close $TemporaryChannel
unset TemporaryChannel
}
# Destroy temporary resource manager
close $TemporaryResourceManagerId
unset TemporaryResourceManagerId
}
我想知道是否有办法在 TCL 方面防止这种情况发生,因为我无法知道我将查询哪些类型的设备。我尝试在脚本的几个不同位置使用“update”和“update idletasks”,但它只是让我在冻结之间有一点时间。
任何帮助将不胜感激。提前致谢!
【问题讨论】: