Middle	
  Layer	
  Services	
  at	
  NSLS	
  II	
  	
  
for	
  Beam	  Commissioning	
  and	
  Opera;on	
  Guobao	  Shen	  Controls	  Group,	
  Photon	  Sciences	
  Brookhaven	
  Na;onal	
  Laboratory	
  Feb,	
  2014	
  	
  0

BROOKHAVEN SCIENCE ASSOCIATES

Content	  • NSLS	
  II	
  Overview	  • NSLS	
  II	
  Control	
  Brief	  • Virtual	  Accelerator	
  • EPICS	
  V4	
  based	
  Middle	  Layer	
  Service	  • RESTful	
  based	
  Middle	  Layer	
  Services	
  • Beam	  Commissioning	  • NSLS	
  II	
  Construc;on	  • Conclusion	  1

BROOKHAVEN SCIENCE ASSOCIATESNSLS	  II	  Overview	
  • Injec;on	
  system	  – Turn	
  key:	
  LINAC	
  &	
  Booster	
  Injec;on	
  Straight	
  Sec;on	  BST: 50nm-rad
0.1% energy spread
8nC/sec

3-GeV booster, C=158m
20 mA, 1 Hz, 40 nm⋅rad

LBT: 150nm-rad (4σxσx’)
0.5% energy spreadSingle bunch 0.5nC/sec
Multibunch (15nC/sec, 80~150)

2

200-MeV linac
15 nC/160-300 ns,
0.5% e.s., 50 µm⋅rad
BROOKHAVEN SCIENCE ASSOCIATESNSLS	  II	  Overview	
  • Storage	
  ring	  parameters	
  

Beam	
  Speciﬁca+ons	
  

– 30	
  Cell	
  DBA	
  ladce	  structure	
  Energy	
  
3.0	
  GeV
Circumference792	
  m
Number	  of	
  Periods
30	
  DBA
Straights
6.6/9.3	
  m
EmiXance	
  (h,v)<	
  1/0.008	
  nm
Momentum	
  Compac;on 0.00037
Dipole	  Bend	  Radius25	
  m
Energy	  Loss	  per	
  Turn<2	
  MeV
Energy	  Spread
0.09%
RF	
  Frequency
500	
  MHz
Harmonic	
  Number1320
RF	
  Bucket	
  Height>2.5%
RMS	
  Bunch	  Length15-­‐30	
  ps
Average	
  Current500	
  mA
Current	
  per	  Bunch0.5	
  mA
Charge	  per	  Bunch1.2	
  nC
Touschek	
  Life;me>	
  3hrsCourtesy	  of	
  Weiming	  Guo	  3

BROOKHAVEN SCIENCE ASSOCIATESNSLS	  II	  Controls	
  Brief	  • System	
  Architecture	
  Channel	  Arch	  Matlab	
  Apps	  Python	  Apps	
  
MMLT	
  
CAC	
   PVAC	   REST	
   CAC	   PVAC	   REST	
   CAC	   PVAC	   REST	
   CAC	   PVAC	   REST	
  CS-­‐Studio	  pvManager	  C A C 	   P V A C 	
   R E S T	
  Ethernet

EPICS	
  V4	
  
	
  

PVAS	
  
	
  

	
  

MASAR	
  

PVAS	
  
	
  

HTTP/REST	
  
	
  

	
  

HTTP/REST	
  
	
  

	
  

HTTP/REST	  	  MUNICONV	  Ladce/Model	  Channel	  Finder	  Python	  Python	
  

Java	
  

MySQL/IRMIS	  MySQL/IRMIS	  MySQL	  	
  Python	  SQLite/IRMIS	
  

PVAS	
  

	
  

	
  

Distributed Front-Ends

CAS	
  	
  	
  	
  PVAS	
  
Diag	
  db	
  
	
  

CAS	
  	
  	
  	
  PVAS	
  
PS	
  db	
  
	
  

CAS	
  	
  	
  	
  PVAS	
  
RF	
  db	
  
	
  

CAS	
  	
  	
  	
  PVAS	
  
VA	
  db	
  
	
  

CAS	
  
JMS	
  Service	
  Physical	
  Device	  Physical	
  Device	  Physical	
  Device	  Physical	
  Device	  Tracy-­‐III	
  Simula;on	
  

4

	
  

BROOKHAVEN SCIENCE ASSOCIATESNSLS	  II	  Controls	
  Brief	  • Control	
  room	  soiware	  	
  – Debian/Linux	
  7	
  consoles	
  • 4	
  for	
  general	
  operator	
  and	  1	  for	
  lead	  operator	  – Python	
  cothread	
  for	
  channel	
  access	  • Version	
  2.8/Python	
  2.7	  – Dedicated	
  matlab	
  server	
  	
  
• 3	
  for	
  physicist	  • 1	
  for	
  BPM	
  expert	
  • labCa	  3.4	
  support	
  – Elegant/SDDS	
  install	  • Limited	
  support	
  5

BROOKHAVEN SCIENCE ASSOCIATES

Virtual	  Accelerator	  Ethernet

Distributed Front-Ends

CAS	
  
JMS	
  Service	  	  Tracy-­‐III	
  Simula;on	  6

BROOKHAVEN SCIENCE ASSOCIATES

Virtual	  Accelerator	
  • An	
  integrated	
  accelerator	
  simula;on	
  code	  – Provide	  real	  ;me	
  accelerator	
  simula;on	
  results	  • A	
  standalone	  EPICS	
  V3	
  IOC	
  • Virtual	  accelerator	
  at	
  NSLS	  II	
  – Uses	  Tracy-­‐3	
  as	
  simula;on	
  backend	  – Provide	  realis;c	
  accelerator	
  beam	  behavior	  • Integrate	
  realis;c	
  ladce	  • Integrate	
  misalignment	  • Emulated	
  sedng	
  jiXer	  for	
  magnets	
  7

BROOKHAVEN SCIENCE ASSOCIATES

Virtual	  Accelerator	
  • Main	
  purpose	  – Support	
  high	  level	  applica;on	
  development	  • Especially	
  physics	
  applica;on	
  development	  • All	
  simula;on	
  results	
  available	
  via	  EPICS	
  V3	
  PVs	  – Middle	
  layer	  service	
  development	  • Channel	
  ﬁnder	  service	  • MASAR	  service	
  
• …	
  

– Other	
  tool	  need	  EPICS	
  V3	
  PVs	  8

BROOKHAVEN SCIENCE ASSOCIATES

Virtual	  Accelerator	  • What	  does	
  it	
  do?	  – All	
  data	  via	  EPICS	  PVs	  • Beam	  Op;cs	
  • Hardware	
  sedng	
  &	
  read	  back	  – Adjust	
  sedng	
  of	
  each	  device	
  individually	  • Magnets:	
  Bend,	  Quad,	  Sext,	
  Correctors,	
  …	
  
• RF	
  frequency	
  &	
  voltage	  • Inser;on	
  device	
  for	  synchrotron	
  machine	  – Dynamically	
  change	
  hardware	
  sedng	  – Real	  ;me	
  simula;on	  • Simula;on	
  performed	
  con;nuously	  9

BROOKHAVEN SCIENCE ASSOCIATES

Virtual	  Accelerator	  • What	  does	
  it	
  do?	  – Errors	
  source	  • Engineering	
  ripple	  – magnet	  sedng	  – BPM	
  read	  back	  • Misalignment	  – Read	  back	  beam	  behavior	  • Beam	  posi;on	
  at	
  each	  BPM	  • Beam	  closed	
  orbit	  • Beam	  op;cs	
  TWISS	  parameters	
  10

BROOKHAVEN SCIENCE ASSOCIATES

Virtual	  Accelerator	  • What	  does	
  it	
  not	  do	  or	
  need	  many	  eﬀort	  to	
  do?	  – Other	  accelerator	
  behavior	
  not	  available	
  via	  a	
  simula;on	
  code	  • Vacuum	
  reading	  • Mechanical	
  moving	  • Ground	  vibra;on	  – Mul;ple	  par;cle	
  tracking	  • Performance	
  issue	  – Synchrotron	
  photon	
  laser	  behavior	  11

BROOKHAVEN SCIENCE ASSOCIATES

Virtual	  Accelerator	  • Automa;c	
  generate	
  EPICS	
  database	  – Load	
  a	
  ladce	
  ﬁle	  in	
  – Apply	
  NSLS	
  II	
  naming	
  conversion	  – Generate	
  EPICS	
  .db	
  ﬁle	  
– Generate	
  cmd	
  ﬁle	  to	
  ini;alize	
  each	  sedng	
  point	
  PV	
  – Generate	
  a	
  table	  to	
  descript	
  the	
  property	  • for	
  physics	
  applica;on	  • For	
  channel	
  ﬁnder	  services	  12

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service	
  Ethernet

EPICS	
  V4	
  
	
  
	
  

MASAR	  	
  Python	  SQLite/IRMIS	  Distributed Front-Ends

CAS	
  	
  	
  	
  PVAS	
  
Diag	
  db	
  
	
  

CAS	
  	
  	
  	
  PVAS	
  
PS	
  db	
  
	
  

CAS	
  	
  	
  	
  PVAS	
  
RF	
  db	
  
	
  

CAS	
  	
  	
  	
  PVAS	
  
VA	
  db	
  
	
  

CAS	
  
JMS	
  Service	
  Physical	
  Device	  Physical	
  Device	  Physical	
  Device	  Physical	
  Device	  Tracy-­‐III	
  Simula;on	
  

13

	
  

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service	  • An	
  interna;onal	
  collabora;on	
  working	
  group	  – Collabora;ve	
  ins;tutes	
  • APS	
  
• BNL	  • COSYLAB	  • DLS	  
• PSI	  
• SLAC	  • ESS	  – Weekly	
  telecon	
  mee;ng	  – A	
  nominal	
  4	
  months	
  face-­‐face	
  mee;ng	  rota;ng	  between	  the	
  developer’s	
  sites.	
  14

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service	  • An	
  open	
  source	
  project	  for	
  experimental	
  facility	  – Extension	
  of	
  EPICS	
  version	
  3	
  • Complex	  data	  structure/data	
  types	  • New	
  communica;on	
  protocol	  – Expanded	
  to	
  ﬁdng	  the	
  requirement	  • Physics	
  middle	
  layer	  server	  • Data	  acquisi;on	  • Experimental	
  control	  • Other	  general	
  service	
  15

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service	  • V4	
  Modules	  – Core	  modules:	
  • pvData:	
  fundamental	
  data	  structure	  • pvAccess:	
  communica;on	
  protocol,	
  carry	
  data	  on	
  wire	  • pvCommon:	
  common	
  u;lity	  library	  – Extensions	  • pvaSrv:	
  EPICS	  Base	  IOC	
  plugin	
  interfacing	
  V3	
  data	  to	
  pvAccess	
  • Norma;ve	
  type:	
  collec;on	
  of	
  pvData	
  data	  types	
  that	  may	
  be	
  
used	
  for	
  general	
  purpose	  – Service	
  modules:	  • Developed	
  at	
  each	  diﬀerent	
  site	  for	
  its	
  own	
  purpose	  – Language	  support	  • C++	  &	
  Java	  mainly	
  • Python,	
  but	
  greatly	
  behind	
  because	
  of	
  short	  of	
  man-­‐power	
  16

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service	
  • Interopera;on	
  with	  V3	
  Client Apps

Client Apps

Client Apps

Channel Access Client

pvAccess

Channel Access

pvAccess	
  Channel	  Access	
  Channel Access

pvAccess Client

Channel Access

pvaSrv

V4 processing engine

EPICS Database
Device Support

Normative Type
pvDataDevice Driver

17

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service	
  • Communication Mechanisms– Get, Put, Monitor, Command/Response, Broadcast, Multicast• Normative types:– NT(DBRTypes), NTImage, NTTable, NTMultichannelArray,
NTNDArray, NTStatistics,• pvAccess– optimized to send large arrays and structured data.	
  • pvaSrv– reference implementations of middle layer services for relational
databases or continuous data sources– serves V3 channels from the EPICS process database as does
Channel Access.
18

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service	
  •pvAccess	
  and	
  Channel	
  Access	  compara;ve	
  performance	
  (Number	
  of	
  channel	
  value	
  get	
  opera;ons	
  per	
  second),	
  where	
  only	  one	
  channel's	
  value	
  is	
  got	
  in	
  
each	
  get	
  opera;on,	
  as	
  a	
  func;on	
  of	
  array	  size	  of	
  the	
  channel	
  Courtesy	
  of	
  Matej	  Sekoranja	  19

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service	
  
•
	
  

pvAccess	
  and	
  Channel	
  Access	  compara;ve	
  performance	
  (Number	
  of	
  channel	
  value	
  get	
  opera;ons	
  per	
  second),	
  where	
  1000	
  channels	
  values'	
  are	
  got	  in	
  each	  get	
  opera;on,	
  as	
  a	
  func;on	
  of	
  array	  size	  of	
  the	
  channel.	
  Courtesy	
  of	
  Matej	  Sekoranja	  20

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service• MASAR– Machine Snapshot, Archiving, and Retrieve– A general purpose tool to snapshot data from V3 PVs– Implemented in V4– Machine• A facility controlled by EPICS, accelerator for example– Snapshot• Data at specific time point– Value, time stamp, connection status, alarm status, alarm severity• Similar tools, but different purpose– IOC automatic save & restore• IOC bumpless rebooting– Channel Archiving• Archive pre-defined configuration periodically• All data saved time serially
21

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service• MASAR Architecture
Scrip;ng	
  
PyQt	
  

Scrip;ng	  High	
  Level	  Scrip;ng	
  API	  Low	
  Level	
  Python	
  Client	
  Library	  	
  pvAccess/channelRPC	
  Client	
  (C++)	
  CS-­‐Studio/
BOY	
  Others	  (Matlab)	
  pvAccess	
  Client	
  Library	
  (Java)	
  pvAccess

pvAccess/channelRPC	
  Service	  Engine	
  DSL-­‐PY	
  Module	  Gather/C++	
  PYMASAR	  	
  Channel Access(SQLite)	
  

IOC	
  
Finished	  User	
  Apps	  Planning	
  

22

IOC	
  

IOC	
  
Developing	
  BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service• Snapshot configuration– EPICS V3 PV orientated• Support all scalar and waveform PV types– Float, double, string, and enum

– PV group• Collection of PV names– Can be a mix of any of the types• One PV can be in many PV groups– Configuration• Collection of PV groups, therefore, collection of PV names• One PV group can be in many configurations• Snapshot– An event happened at a particular time
– Belongs to one configuration• One configuration can have many events– Each event is one data set• Header information + meta data (value, time stamp)

23

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service• Snapshot configuration
Snapshot	
  pv

pv group

configuration

event

event data

...

24

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service• UI PyQt4 based graphic user interface– Browse configuration– Browse event– Take snapshot– Retrieve data
– Compare data
– Restore machine– Export data toexternal file

25

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service• Event data browsing and comparing with live machine

26

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service• Multiple data sets comparisonØ Support up to 9 data sets

27

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service• Waveform data

28

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service• Deployed in control network from the first day (3/27/2012)• Configuration increasing over time (by Jan 15 2014 10:51 AM)

29

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service• Snapshots taken over time (by Jan 15 2014 10:51 AM)

30

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service• Snapshots taken with time
– Events (by Jan 15 2014 10:51 AM) total taken: 525, approved: 246– Regular snapshot per shiftDate	
  2012-­‐03-­‐21	
  9:28	  2012-­‐03-­‐29	
  10:32	  2012-­‐03-­‐30	
  18:01	
  2012-­‐04-­‐24	
  20:02	
  2012-­‐05-­‐11	
  10:27	  2012-­‐05-­‐24	
  14:25	  2012-­‐06-­‐07	
  18:28	  2012-­‐06-­‐14	
  16:13	  2013-­‐12-­‐17	
  7:34	  2013-­‐12-­‐20	
  16:01	
  2013-­‐12-­‐23	
  14:48	  2013-­‐12-­‐26	
  18:40	  2013-­‐12-­‐27	
  18:18	  2013-­‐12-­‐30	
  13:54	  2014-­‐01-­‐02	
  12:12	  2014-­‐01-­‐14	
  2:29	  2014-­‐01-­‐15	
  8:40	  Snapshots	
  taken	
   Snapshots	  Approved	
  
0	
  
30	
  
31	
  
144	
  
210	
  
279	
  
331	
  
338	
  
460	
  
488	
  
489	
  
493	
  
497	
  
498	
  
500	
  
519	
  
525	
  

31

0	
  
8	
  
9	
  
41	
  
63	
  
79	
  
96	
  
98	
  
186	
  
212	
  
213	
  
217	
  
221	
  
222	
  
224	
  
240	
  
246	
  

BROOKHAVEN SCIENCE ASSOCIATESEPICS	
  V4	
  based	
  Middle	  Layer	
  Service• Database size growing over time(by Jan 15 2014 10:51 AM)

32

BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services	  Ethernet

EPICS	
  V4	
  
	
  
	
  

MASAR	
  
	
  

PVAS	
  
	
  

	
  

HTTP/REST	
  
	
  

	
  

HTTP/REST	
  

	
  

HTTP/REST	
  HTTP/REST	
  Channel	  Finder	
  

Olog	
  

	
  

	
  

Ladce/Model	
  

	
  

PVAS	
  

PVAS	
  
	
  

MUNICONV	
  Python	  SQLite/IRMIS	
  

PVAS	
  

	
  

	
  

	
  

Python	  Python	
  

Java	
  

Java	
  

MySQL/IRMIS	  MySQL/IRMIS	  MySQL	  MySQL	
  Distributed Front-Ends

CAS	
  	
  	
  	
  PVAS	
  
Diag	
  db	
  
	
  

CAS	
  	
  	
  	
  PVAS	
  
PS	
  db	
  
	
  

CAS	
  	
  	
  	
  PVAS	
  
RF	
  db	
  
	
  

CAS	
  	
  	
  	
  PVAS	
  
VA	
  db	
  
	
  

CAS	
  
JMS	
  Service	
  Physical	
  Device	  Physical	
  Device	  Physical	
  Device	  Physical	
  Device	  Tracy-­‐III	
  Simula;on	
  

33

	
  

BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services	  • Channel	
  ﬁnder	  services	  – Originally	
  by	
  Ralph	  Lange	  – Channel	
  name	  look-­‐up	
  service	
  – Support	
  property	
  (name-­‐value	
  pair)	
  – Support	
  tags	  – Automatically load EPICS Channels at IOC initialization– Client support• Python library• CS-Studio– J2EE	  service	  – MySQL	
  as	
  RDB	
  backend	  34

BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services• Channel	
  ﬁnder	  update	  daemon	  /cf-­‐update	
  

NFS

IOCs	
  

Web	
  
proxy	
  Glassﬁsh	  Web	  service	
  dependency

Scripts	
  to	
  
-­‐	
  populate	
  proper;es	
  

CSS	
  

data flow

35

BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services• Virtual	  accelerator	
  property	
  into	  channel	
  ﬁnder	  Channel	  Name	  handle	  V2:SR:C02-­‐MG:G04A{HFCor:FM1}	
  V2:SR:C02-­‐MG:G04A{VFCor:FM1}	
  Fld-­‐I	
  Fld-­‐SP	
  Fld-­‐I	
  Fld-­‐SP	  READBACK	  SETPOINT	  READBACK	  SETPOINT	
  elemName	  FXM1G4C02A	  FYM1G4C02A	
  elemType	  HFCOR	  

VFCOR	  elemField	
  

x	
  

y	
  

devName	  FM1G4C02A	
  

sEnd	
  

65.5222	
  

cell	
  

C02	
  

girder	  G4	
  symmetry	
  

A	
  

length	  0.044	  ordinal	
  

263	
  
eget	
  

tags	
  

264	
  
eput	
  

eget	
  

x	
  

eput	
  
y	
  

36

sys.SR	  BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services	  • Olog	  – Collabora;on	
  by	
  NSLS	  II@BNL	
  &	
  FRIB@MSU	  – Log	  an	
  entry	  	
  • Time,	
  owner,	
  text,	
  aXachments,	
  logbooks,	
  tags,	  proper;es– J2EE	  service	  – MySQL	
  as	
  RDB	
  backend	  – Client support• Python library• CS-Studio• Web interface
37

BROOKHAVEN SCIENCE ASSOCIATES

IOC	
  

…	
  

IOC	
  

CA	
  client	
  (JCA/CAJ)	
  

Data	
  Sources	
  

CA	
  

…	
  

v4	
  

pvA	
  client	
  

Sim	
  

Test	
  

pvA	
  

Command/response	
  

v4	
  
Masar	
  
…	
  

Core	
  Client	  Technologies	
  AccelU;ls	  pvManager	
  Aggrega.on	  Data	
  Deﬁni.on	  vTypes	  Visualiza.on	  Graphene	  CSS	  Core	
  

IOC	
  

Publish/subscribe	
  

IOC	
  

v3	
  

ChannelFinder	  Integra;on	  Olog	
  Integra;on	  Log	
  Viewer	
  Java/Python	  Web	
  based	
  REST	
  services	
  

API	
  

ChannelFinder	
  

API	
  

Olog	
  

…	
  

...	
  

BEAST	
  BOY	
  DataBrowser	
  
…	
  

Courtesy	  of	
  Kunal	
  Shroﬀ	
  CS-­‐Studio	
  

38

Web	
  UI	
  and	
  other	  clients	  Scripts	
  and	
  u.li.es	
  Logbook	  pyOlog	
  

…	
  

…	
  
BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services• Olog web view

39

BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services• Olog CS-Studio view

40

BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services• Lattice and Model Service

Ladce	  Deck	
  Simula;on/	
  Measurement	
  Lattice

Beam	
  
Beam	
  
Beam	
  
Parameter	
  
Beam	
  
Parameter	
  Parameter	
  Parameter	
  

Model

(Geometric + Strength)(Simulation output)
41

BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services• Lattice Model Service Architecture
Scrip;ng	  Others	  (Matlab)	
  Java	
  Client	  RESTful	   	
   pvAccess	
  CSS/BOY	
  Python	  Client	  RESTful	   	
  pvAccess	
  Browsers	
  RESTfulpvAccess	
  V4	
  channelRPC	
  service	
  

HTML	
  

Django	  Data	
  Processing	  API	
  Python	  Data	  API	
  Simulation(Tracy-III & Elegant)Python-­‐MySQLdb	
  MySQL	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  

(Ladce:	  geo+strength,	  Model:	
  TWISS,	
  T-­‐Matrix,	
  Close	  Orbit,	  …)	
  Finished	  User	
  Apps	  42Planning	
  Developing	
  BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services• Service implemented under Django framework– Provide REST service interface• Currently, support RESTful GET & POST

– 3 lattice deck acceptable• Predefined tab-separated plain lattice• Tracy-3• Elegant– 2 simulation codes support by server• Tracy-3 & elegant– Client support• Python library• Web UI– MySQL as RDB backend– V4 implementation has been planned on top
43

BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services• Lattice view

44

44

BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services• Model view

45

45

BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services	  • MUNICONV Service– Multiple unit conversion• First implementation targeting on magnets• Convert value between different unit systems– i: power supply current– b: magnetic fields– k: value in model/lattice domain– RESTful service interface under Django• Currently, support GET method– MySQL as RDB backend– Client support• Python library• Web UI

– V4 implementation has been planned on top
46

BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services	  • MUNICONV Architecture
Scrip;ng	  Others	  (Matlab)	
  Java	
  Client	  RESTful	   	
   pvAccess	
  CSS/BOY	
  Python	  Client	  RESTful	   	
  pvAccess	
  Browsers	
  RESTfulpvAccess	
  V4	
  channelRPC	
  service	
  

HTML	
  

Django	  Conversion	
  func;ons	
  Python	  Data	  API	  V3 IOC
Conversion	
  func;ons	
  Python-­‐MySQLdb	
  MySQL	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  

(Ladce:	  geo+strength,	  Model:	
  TWISS,	
  T-­‐Matrix,	
  Close	  Orbit,	  …)	
  Finished	  User	
  Apps	  47Planning	
  Developing	
  BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services• MUNICONV Data stored in RDB– Capture interested raw data
• Measurement data, fitting parameters, fitting algorithm• Serial #, device name, installation info
• Component type– Measurement data
• For each individual magnet• For magnet type48

BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services• MUNICONV Capability– Convert value between predefine unit system– Unit is determined usually by magnet measurement– Conversion algorithm plugable• MUNICONV Support magnets– Standalone function magnet– Function combined magnet• A skew quadrupole with H&V correctors for example– Serial powered magnet chain

49

BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services• Pluggable and extendable conversion algorithm{'i2b': {'auxInfo': 1,'function': '','algorithmId': 1,'initialUnit': '','resultUnit': ''},
'b2i': {'auxInfo': 1,'function': '','algorithmId': 1,'initialUnit': '','resultUnit': ''},
'b2k': {'auxInfo': 2,'function': '','algorithmId': 0,'initialUnit': '','resultUnit': ''},…
}

# auxInfo: an additional information,# could be used for example the fitting order# of polynomial fitting,#
0: not use; 1: linear fit; 2: 2nd order poly
fit; ...
# or the order of fitting result, for example#
1: kick angle, rad/degree;#
2: K1, 1/m2;#
3: K2, 1/m3;#
4: K3, 1/m4; ...
# algorithmId: id to show which algorithm to use,
# 0: linear fitting with given function# 1: high order polynomial fitting with given function# 2: polynomial fitting using raw data
# 3: interpolating with raw magnetic data
# 4: …

50

BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services• MUNICONV WEB View

51

BROOKHAVEN SCIENCE ASSOCIATESRESTful	
  based	
  Middle	  Layer	
  Services	  • IDOD	  service	
  for	
  inser;on	
  device	  – Data	  service	
  to	
  store	  both	  online	
  data	  and	
  oﬄine	
  data	  – Same	  architecture	
  to	
  be	
  implemented	
  using	
  django	  – Under	
  ac;ve	
  development,	
  and	
  should	
  be	
  released	
  
soon	
  

• Data	  service	
  for	
  beam	  based	
  fast	  interlock	
  – Provide	  a	
  data	  warehouse	  	
  – Keep	  all	
  history	
  data	  – Under	  design	
  52

BROOKHAVEN SCIENCE ASSOCIATES

Middle	  Layer	
  Services	
  Integra;on	
  
IOCs	
  

Client	  App	
  

(PVs	
  in	
  Phyisics	
  Unit)	
  

IOC	
  

MASAR	
  Channel	  Finder	  Ladce/Model	  Other	
  Service	
  (IDOD)	
  

MUNICONV	  

53

BROOKHAVEN SCIENCE ASSOCIATESBeam	  Commissioning	  • High	  Level	
  Applica;ons	
  Channel	  Arch	  Matlab	
  Apps	  Python	  Apps	
  
MMLT	
  
CAC	
   PVAC	   REST	
   CAC	   PVAC	   REST	
   CAC	   PVAC	   REST	
   CAC	   PVAC	   REST	
  CS-­‐Studio	  pvManager	  C A C 	   P V A C 	
   R E S T	
  Ethernet

EPICS	
  V4	
  
	
  

PVAS	
  
	
  

	
  

MASAR	
  

PVAS	
  

HTTP/REST	  	  MUNICONV	
  

	
  

	
  

Python	
  

	
  

	
  

HTTP/REST	  	
  Ladce/Model	
  
	
  

PVAS	
  

PVAS	
  

PVAS	
  

	
  

	
  

HTTP/REST	
  HTTP/REST	
  Channel	  Finder	
  

Olog	
  

…	
  

HTTP/REST	
  
	
  

	
  

	
  

	
  

	
  

	
  

Python	  Python	
  

Java	
  

Java	
  

…	
  

MySQL/IRMIS	  MySQL/IRMIS	  MySQL	  MySQL	  MySQL	
  

CAS	
  	
  	
  	
  PVAS	
  
Diag	
  db	
  
	
  

CAS	
  	
  	
  	
  PVAS	
  
PS	
  db	
  
	
  

CAS	
  	
  	
  	
  PVAS	
  
RF	
  db	
  
	
  

CAS	
  	
  	
  	
  PVAS	
  
VA	
  db	
  
	
  

CAS	
  
JMS	
  Service	
  Physical	
  Device	  Physical	
  Device	  Physical	
  Device	  Physical	
  Device	  Tracy-­‐III	
  Simula;on	  SQLite/IRMIS	  Distributed Front-Ends

54

	
  

BROOKHAVEN SCIENCE ASSOCIATESBeam	  Commissioning	  • 2013-­‐11-­‐27:	
  restart	
  beam	  commissioning	  • 2013-­‐11-­‐29:	  	
  accelerate	
  to	
  200	
  MeV	  in	
  single	
  	
  

55

BROOKHAVEN SCIENCE ASSOCIATESBeam	  Commissioning	  • 2013-­‐11-­‐27:	
  restart	
  beam	  commissioning	  • 2013-­‐11-­‐29:	  	
  accelerate	
  to	
  200	
  MeV	  in	
  single	  • 2013-­‐12-­‐07:	
  injec;on	
  into	
  booster	  • 2013-­‐12-­‐10:	
  beam	  spinned	
  the	
  Booster	
  Ring	  56

BROOKHAVEN SCIENCE ASSOCIATESBeam	  Commissioning	  • 2013-­‐11-­‐27:	
  restart	
  beam	  commissioning	  • 2013-­‐11-­‐29:	  	
  accelerate	
  to	
  200	
  MeV	  in	
  single	  • 2013-­‐12-­‐07:	
  injec;on	
  into	
  booster	  • 2013-­‐12-­‐10:	
  beam	  spinned	
  the	
  Booster	
  Ring	  • 2013-­‐12-­‐16:	
  beam	  circulated	
  tens	  of	
  thousand	
  turns	  in	
  the	
  booster	
  ring	  	
  57

BROOKHAVEN SCIENCE ASSOCIATESBeam	  Commissioning	  • 2013-­‐11-­‐27:	
  restart	
  beam	  commissioning	  • 2013-­‐11-­‐29:	  	
  accelerate	
  to	
  200	
  MeV	  in	
  single	  • 2013-­‐12-­‐07:	
  injec;on	
  into	
  booster	  • 2013-­‐12-­‐10:	
  beam	  spinned	
  the	
  Booster	
  Ring	  • 2013-­‐12-­‐16:	
  beam	  circulated	
  tens	  of	
  thousand	
  turns	  in	
  the	
  booster	
  ring	  	
  • 2013-­‐12-­‐21:	
  beam	  captured	
  by	
  the	
  booster	
  RF	
  

58

BROOKHAVEN SCIENCE ASSOCIATESBeam	  Commissioning	  • 2013-­‐11-­‐27:	
  restart	
  beam	  commissioning	  • 2013-­‐11-­‐29:	  	
  accelerate	
  to	
  200	
  MeV	  in	
  single	  • 2013-­‐12-­‐07:	
  injec;on	
  into	
  booster	  • 2013-­‐12-­‐10:	
  beam	  spinned	
  the	
  Booster	
  Ring	  • 2013-­‐12-­‐16:	
  beam	  circulated	
  tens	  of	
  thousand	
  turns	
  in	
  the	
  booster	  ring	  	
  • 2013-­‐12-­‐21:	
  beam	  captured	
  by	
  the	
  booster	  RF	
  • 2013-­‐12-­‐31:	
  beam	  boosted	
  to	
  3	
  GeV	  (1.5	
  mA	
  out	
  3	
  mA	
  )	
  

59

BROOKHAVEN SCIENCE ASSOCIATESNSLS	  II	  Construc;on	  • Oct 200960

BROOKHAVEN SCIENCE ASSOCIATESNSLS	  II	  Construc;on	  • Oct 2010

61

BROOKHAVEN SCIENCE ASSOCIATESNSLS	  II	  Construc;on	  • Oct 201162

BROOKHAVEN SCIENCE ASSOCIATESNSLS	  II	  Construc;on	  • Jul 2013
Control RoomStorage Ring

Controls Group

Booster
Linac

63

BROOKHAVEN SCIENCE ASSOCIATESConclusion	  • Overviewed	
  NSLS	
  II	
  project	  • Virtual	  accelerator	
  provided	
  solid	
  support	
  • 2	
  technologies	
  for	
  middle	
  services	  – V4	
  service,	
  and	
  RESTful	
  web	  services	  – Sa;sfy	
  various	
  requirement	  – Play	  cri;cal	
  role	  during	
  commissioning	  • Support	
  beam	  commissioning	
  well	  – Beam	  to	
  3GeV	
  on	
  2013-­‐12-­‐31	
  

64

BROOKHAVEN SCIENCE ASSOCIATES