スレッド内からvwaitを終了するように変数を設定できる必要があります。これは、通常はインターペレーターをロックするループがあり、それが完了するまで実行中のGUIがあるためです。
私はそれが次のようなsleepコマンドのように機能することを望んでいます:
global EndSleep
after ${SleepTime_ms} set EndSleep 1
vwait EndSleep
デバイスを照会しているwhileループが終了するときに、vwait変数を設定する必要があるのは私だけです。
現在の私のコードは次のとおりです。
proc ::VISA::Wait {VisaAlias} {
# Link global variable
global EndWait
# Execute commands in a thread so the GUI is not locked while executing
set Thread [thread::create]
thread::send ${Thread} [list set VisaAlias ${VisaAlias}]
thread::send ${Thread} {
source MolexVisa.tcl
# Temporarily make new connection with device
VISA::Connect ${VisaAlias}
# Query operation complete bit
VISA::Query ${VisaAlias} "*OPC?"
# Continue to attempt to read OPC bit until any response is given; typically 1
while {[string equal [VISA::Read ${VisaAlias}] ""]} {}
# Destroy temporary connection
VISA::Disconnect ${VisaAlias}
# Set vwait variable
set EndWait 1
}
# Wait for thread to end
vwait EndWait
# Mark thread for termination
thread::release ${Thread}
}
現在、スレッドはまだGUIをフリーズしています。また、スレッド内の変数と私が期待している変数は同じではないので、明らかにそれは永遠に待つだけです。
アドバイスや助けをいただければ幸いです。タスクを達成するための他のより実用的な方法をすべて使い果たしたと思いますが、もう少し洞察を歓迎します。