EPICS Stream Device Support Kay Kasemir ORNLSNS kasemirkornl

  • Slides: 12
Download presentation
EPICS ’Stream’ Device Support Kay Kasemir ORNL/SNS kasemirk@ornl. gov Feb. 2013 Managed by UT-Battelle

EPICS ’Stream’ Device Support Kay Kasemir ORNL/SNS kasemirk@ornl. gov Feb. 2013 Managed by UT-Battelle for the Department of Energy

“Stream” Type Protocols Example Devices: – Temperature controllers: Lakeshore, Omega, … – Vacuum pumps:

“Stream” Type Protocols Example Devices: – Temperature controllers: Lakeshore, Omega, … – Vacuum pumps: Varian, … ·Serial (RS-232, RS 485), Networked (TCP), GPIB (IEEE-488) ·Text-based ·Command/Response What is the current temperature on channel A? “KRDG? An” “+077. 350 E+0n” It’s about 80 Kelvin! 2 Managed by UT-Battelle for the Department of Energy

Pro/Cons · Seems easy – Human-readable – Testable with Hyperterm, minicom, telnet – Create

Pro/Cons · Seems easy – Human-readable – Testable with Hyperterm, minicom, telnet – Create Visual Basic, Lab. VIEW, … demo in no time · But beware! – Speed and Terminators (CR, LF, CR/LF, …) can magically change · Was set to something, then device power-cycled … – Must handle timeouts · Don’t just hang! – Must handle errors · Don’t read “MODEL 340” as 340 Kelvin 3 Managed by UT-Battelle for the Department of Energy

The EPICS ‘Stream’ Device Idea Protocol File “demo. proto” Record Terminator = CR; record(ai,

The EPICS ‘Stream’ Device Idea Protocol File “demo. proto” Record Terminator = CR; record(ai, "Temp: B") { field(DTYP, "stream") field(INP, "@demo. proto get. Temp. A TC 1") field(SCAN, "5 second") } get. Temp. A { out "KRDG? A"; in "%f"; } IOC st. cmd drv. Asyn. IPPort. Configure ("TC 1", "192. 168. 164. 10: 23") 4 Managed by UT-Battelle for the Department of Energy

What ‘Stream Device’ does for you · Connect to device – Re-connect after disconnects

What ‘Stream Device’ does for you · Connect to device – Re-connect after disconnects · Allow many records to communicate via one connection – Threading, queuing, … · Handle timeouts, errors – Put records into ‘alarm’ state · Debug options – Log every byte sent/received 5 Managed by UT-Battelle for the Department of Energy

Net. Cat Example Using Net. Cat, we pretend to be a simple device. ·IOC

Net. Cat Example Using Net. Cat, we pretend to be a simple device. ·IOC with Stream Device will ask: “B? ” ·We reply either – with valid reply to request for B: “B 42. 13” – Invalid reply: “ 42. 13”, “get lost”, … – Not at all, which should be treated as timeout, – a shutdown of the network connection. 6 Managed by UT-Battelle for the Department of Energy

Full Example: Adding support to IOC · configure/RELEASE: SUPPORT=/home/controls/epics/R 3. 14. 12. 2/su pport

Full Example: Adding support to IOC · configure/RELEASE: SUPPORT=/home/controls/epics/R 3. 14. 12. 2/su pport ASYN=$(SUPPORT)/asyn STREAM=$(SUPPORT)/Stream. Device · demo. App/src/Makefile demo_DBD += stream. dbd demo_DBD += asyn. dbd demo_DBD += drv. Asyn. IPPort. dbd demo_LIBS += asyn demo_LIBS += stream 7 Managed by UT-Battelle for the Department of Energy

EPICS Database demo. App/Db/demo. db record(ai, "B") { field (DTYP, "stream") field (INP, "@demo.

EPICS Database demo. App/Db/demo. db record(ai, "B") { field (DTYP, "stream") field (INP, "@demo. proto get. B NC") field (SCAN, "5 second") } record(ai, "A") { field (DTYP, "stream") field (INP, "@demo. proto get. A NC") field (SCAN, "I/O Intr") } record(ao, "current") { field (DTYP, "stream") field (OUT, "@demo�. proto set. Current NC") field (EGU, "A") field (PREC, "2") field (DRVL, "0") field (DRVH, "60") field (LOPR, "0") field (HOPR, "60“ } 8 Managed by UT-Battelle for the Department of Energy

Protocol File ioc. Boot/iocdemo/demo. proto Terminator = CR LF; In. Terminator = LF; Reply.

Protocol File ioc. Boot/iocdemo/demo. proto Terminator = CR LF; In. Terminator = LF; Reply. Timeout = 10000; Read. Timeout = 10000; # Used with SCAN “… second”: # Prompts, then expects "B 5" get. B { out "B? "; in "B %f“; } 9 Managed by UT-Battelle for the Department of Energy # Example with initialization, # otherwise only writes when processed set. Current { out "CURRENT %. 2 f"; @init { out "CURRENT? "; in "CURRENT %f A"; } } # Used with SCAN, "I/O Intr": # Reacts to "A 5" at any time get. A { Poll. Period = 50; in "A %f"; }

IOC Startup File ioc. Book/iocdemo/st. cmd epics. Env. Set ("STREAM_PROTOCOL_PATH", ". ") drv. Asyn.

IOC Startup File ioc. Book/iocdemo/st. cmd epics. Env. Set ("STREAM_PROTOCOL_PATH", ". ") drv. Asyn. IPPort. Configure ("NC", "127. 0. 0. 1: 6543") # # # # # ASYN_TRACE_ERROR ASYN_TRACEIO_DEVICE ASYN_TRACEIO_FILTER ASYN_TRACEIO_DRIVER ASYN_TRACE_FLOW ASYN_TRACEIO_NODATA ASYN_TRACEIO_ASCII ASYN_TRACEIO_ESCAPE ASYN_TRACEIO_HEX 0 x 0001 0 x 0002 0 x 0004 0 x 0008 0 x 0010 0 x 0001 0 x 0002 0 x 0004 # Log some asyn info and in/out texts asyn. Set. Trace. Mask("NC", 0, 4) asyn. Set. Trace. IOMask("NC", 0, 6) db. Load. Records("db/stream. db", "user=fred") 10 Managed by UT-Battelle for the Department of Energy

Example Session · Net. Cat nc –l 127. 0. 0. 1 6543 B? B

Example Session · Net. Cat nc –l 127. 0. 0. 1 6543 B? B 17 B? B 18 B? B 3. 14 B? 34 B? · IOC …write 4 B? rn …read 5 B 17n … got "34" where "B " was expected … No reply from device within 10000 ms 11 Managed by UT-Battelle for the Department of Energy

Stream Device… · Allows you to concentrate on the protocol “demo. proto” · Handles

Stream Device… · Allows you to concentrate on the protocol “demo. proto” · Handles the rest – – Connection Threads Parse results Update record’s value and alarm state 12 Managed by UT-Battelle for the Department of Energy Terminator = CR; get. Temp. A { out "KRDG? A"; in "%f"; }