Changes between Version 1 and Version 2 of epics/streamdevice/tips_and_tricks


Ignore:
Timestamp:
09/04/14 10:22:24 (11 years ago)
Author:
Tetsuya Michikawa
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • epics/streamdevice/tips_and_tricks

    v1 v2  
    1616 * db file
    1717 {{{
    18 field (OUT, "@motor.proto moveaxis(X) motor1")
     18reocrd(ao, "$(RECORD):ex01") {
     19  field (OUT, "@motor.proto moveaxis(X) motor1")
     20  field (DTYP, "stream")
     21}
    1922 }}}
    2023
     
    4043 * db file
    4144 {{{
    42 field (INP, "@vacuumgauge.proto readpressure(0x84) gauge3")
     45reocrd(ao, "$(RECORD):ex02") {
     46    field (INP, "@vacuumgauge.proto readpressure(0x84) gauge3")
     47    field (DTYP, "stream")
     48}
    4349 }}}
    4450
     
    6874 * db file
    6975 {{{
    70 record (ai, "$(RECORD)") {
     76record (ai, "$(RECORD):ex03") {
    7177  field (DTYP, "stream")
    7278  field (INP, "@$(DEVICETYPE).proto read $(BUS)")
     
    8288 }}}
    8389
    84  この場合、空白も含めてまったく同じ文字列じゃないと処理ないので注意。
     90 この場合、空白も含めてまったく同じ文字列じゃないと処理されないので注意。
    8591
    8692
     
    8894
    8995 例として、こんな文字列を送ってくるデバイスだとする。
    90 
    9196 {{{
    9297Here is the value:
     
    95100
    96101 その場合、'''{{{in}}}'''を複数記述すればいい。
     102
     103 * db file
     104 {{{
     105record (ai, "$(RECORD):ex04") {
     106  field (DTYP, "stream")
     107  field (INP, "@$(DEVICETYPE).proto read_value $(BUS)")
     108  field (SCAN, "I/O Intr")
     109}
     110 }}}
    97111
    98112 * protocol file
     
    103117}
    104118 }}}
     119
     120== 一つのメッセージで複数のデータを扱う必要がある ==
     121
     122 この問題には色々なアプローチで、複数の解決策がある。
     123
     124 === 全部同じ型で、同じ文字で区切られているデータを出力 ===
     125
     126 waveform,aaoレコードを使って処理が可能。
     127
     128 * db file
     129 {{{
     130record(waveform, "$(RECORD):ex05") {
     131    field(OUT, "@$(DEVICETYPE).proto array_out $(BUS)")
     132    field(DTYP, "stream")
     133}
     134 }}}
     135
     136 * protocol file
     137 {{{
     138array_out {
     139    separator=", ";
     140    out "an array: (%.2f)";
     141}
     142 }}}
     143
     144 '''{{{%.2f}}}'''のフォーマット文字列が配列数分、'''{{{", "}}}'''で連結されて、こんな文字列が作成される。
     145 {{{
     146an array: (1.23, 2.34, 3.45, 4.56)
     147 }}}
     148
     149
     150