Changes between Version 8 and Version 9 of epics/streamdevice/tips_and_tricks


Ignore:
Timestamp:
09/04/14 16:18:02 (11 years ago)
Author:
Tetsuya Michikawa
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • epics/streamdevice/tips_and_tricks

    v8 v9  
    301301== 数字と文字列の混合データを処理する必要がある ==
    302302
    303 
    304 
    305 
    306 
     303 {{{@mismatch}}}例外ハンドラとレコードのリダイレクトで、プロトコルファイルの引数に設定したレコードにエラーメッセージを設定。
     304
     305
     306=== 例 ===
     307
     308 {{{"CURRENT?"}}}を出力すると、正常な場合には{{{"CURRENT 3.24 A"}}}、異常な場合には{{{"device switched off"}}}と応答するデバイス
     309
     310 * db file
     311 {{{
     312record (ai, "$(DEVICE):readcurrent") {
     313  field (DTYP, "stream")
     314  field (INP, "@$(DEVICETYPE).proto read_current($(DEVICE):message) $(BUS)")
     315}
     316record (stringin, "$(DEVICE):message") {
     317}
     318 }}}
     319
     320 * protocol file
     321 {{{
     322read_current {
     323    out "CURRENT?";
     324    in "CURRENT %f A";
     325    @mismatch {
     326        in "%(\$1)39c";
     327    }
     328}
     329 }}}
     330
     331 {{{in}}} に設定した文字列と違うデータが来た場合、{{{@mismatch}}}の中の処理が実行される。ただし、ここでもエラーになった場合には処理は中断されて、コンソールにエラーが出力される。[[br]]
     332 エラー出力が全く必要なければ、{{{extrainput=ignore}}}を設定してもいい。
     333
     334
     335
     336