Files
PBSwissMX/src/triggerSync/UnusedSeqDiag.md

6.7 KiB

Detailed Python sequence

sequenceDiagram
  participant ts as TimingSystem
  participant py as Python
  participant pb as PowerBrick

  activate py
  Note over py: .setup_sync()<br/>prepare code snipplets
  py -)+ pb: sftp / ssh
  Note over pb: sftp triggerSync<br/>run triggerSync
  pb --)- py: done
  Note over py: .setup_coord_trf()
  py -)+ pb: download code
  Note over pb: setup coordinate transformation
  pb --)- py: done
  Note over py: .setup_motion()
  py -)+ pb: generate code<br/>download code
  Note over pb: setup motion program
  pb --)- py: done
  Note over py: .setup_gather()
  py -)+ pb: download code
  Note over pb: set addresses to gather<br/>Gather.Enable=1
  pb --)- py: done
  Note over py: .homing()
  py -)+ pb: download code
  Note over pb: runs homing PLC [if needed]<br/>enable plc 1
  pb --) py: done
  Note over py: wait(Motor[1].HomeComplete)
  deactivate py
  pb ->>- py: HomeComplete
  activate py
  Note over py: .run()
  py -)+ pb: .run()
  Note over pb: runs motion program 2 in coordSystem 1<br/>&1br2
  pb --) py: done
  Note over py: .wait_armed()<br/>wait(Q[0]==-2)  # wait until motors are at first position
  deactivate py
  Note over pb: move to first point<br/>DesTimeBase=0 (wait motion)<br/>Q[0]=-2 (motion armed)
  pb ->>- py: Q[0]=-2 done
  activate py
  Note over py: .trigger() #send a start trigger (if needed) after given time
  Note over pb: wait for the start trigger
  alt simulated trigger
    Note over py:Q[10]=1
    py-)+pb: start trigger
    Note over pb: DesTimeBase=Sys.ServoPeriod
  else real trigger
    ts-)pb: start trigger<br/>triggerSync:DesTimeBase=Sys.ServoPeriod
  end
  Note over pb: pvt10abs<br/>move to all points
  Note over py: while .progress()<br/>wait(Gather.Enable==0)
  deactivate py
    loop 10 ms
      Note over pb: move to next point
    end
  Note over pb: Gather.Enable=0
  pb ->>- py: Gather.Enable=0
  activate py
  Note over py: .gather_upload()
  deactivate py

more detailed sequence trial 1

sequenceDiagram
  participant py as Python
  participant pb as PowerBrick

  Note over py: .setup_sync()
  create participant ts as TriggerSync
  py -)+ ts: .setup_sync()
  create participant tsync as triggersync_func()
  ts -) tsync: start thread
  create participant tsim as trig_sim_func()
  ts -) tsim: ? if sync_mode&2 then start thread
  deactivate ts

  Note over py: .setup_coord_trf()<br/>shapepath.py
  py -)+ pb: download code
  pb --)- py: done
  Note over py: .setup_motion()<br/>shapepath.py
  py -)+ pb: generate code<br/>download code
  pb --)- py: done
  Note over py: .setup_gather()
  Note over py, pb: calls set_address(*address)<br/>that sets also Gather.Enable=1.
  py -)+ pb: download code
  Note over pb: Gather.Enable=1
  pb --)- py: done
  Note over py: .homing()
  py -)+ pb: download code
  pb --) py: done
  Note over pb: runs homing PLC if needed<br/>enable plc 1
  Note over py: wait(Motor[1].HomeComplete)
  pb ->>- py: HomeComplete
  Note over py: .run()
  py -)+ pb: .run()
  pb --)- py: done
  Note over pb: runs motion program 2 in coordSystem 1<br/>&1br2<br/>move to first point<br/>DesTimeBase=0 (wait motion)
  Note over tsync: wait(Q[0]==-3)
  pb -)+ tsync: Q[0]=-3
  Note over py: MXMotion.py:.wait_armed()<br/>wait(Q[0]==-2)
  tsync -)+ py: Q[0]=-2
  Note over py: MXMotion.py:.trigger()<br/>if sync_mode&1 then Q[10]=1
  deactivate py

  tsync -)+ pb: DesTimeBase=ServoPerion
  loop aaa
    tsync ->> tsync:adjust DesTimeBase<br/>while Gather.Enable!=0
  end
  activate tsim
  loop bbb
    tsim ->> tsim:simulate start and frame triggers
  end
  deactivate tsim 

  Note over pb: pvt10abs<br/>move to all points
  Note over pb: Gather.Enable=0
  Note over py: while .progress()<br/>wait(Gather.Enable==0)
  pb -)+ py: Gather.Enable=0
  pb -)- tsync: Gather.Enable=0
  
  Note over py: shapepath.py:.gather_upload()
  Note over ts: wait threds finished
  activate ts

  deactivate tsync 
  destroy tsync
  tsync -x ts: thread finished
  destroy tsim
  tsim -x ts: thread finished
  deactivate ts
  deactivate py

  box rgba(196,196,224,.3) TriggerSync executable
  participant ts
  participant tsim
  participant tsync
  end

more detailed sequence simulated trigger and speed adjustment

sequenceDiagram
  participant py as Python
  participant pb as PowerBrick
  participant ts as TimingSystem

  activate py
  Note over py: .setup_sync()<br/>prepare code snipplets
  py -)+ pb: sftp / ssh
  Note over pb: sftp triggerSync<br/>run triggerSync
  pb --)- py: done
  Note over py: .setup_sync()
  create participant tgss as TriggerSync
  py -)+ tgss: .setup_sync()
  create participant tsync as triggersync_func()
  tgss ->> tsync: start thread
  opt if sync_mode&2
    create participant tsim as trig_sim_func()
    tgss ->>- tsim: start thread
  end
#  deactivate tgss



  Note over py: .setup_coord_trf()
  py -)+ pb: download code
  Note over pb: setup coordinate transformation
  pb --)- py: done
  Note over py: .setup_motion()
  py -)+ pb: generate code<br/>download code
  Note over pb: setup motion program
  pb --)- py: done
  Note over py: .setup_gather()
  py -)+ pb: download code
  Note over pb: set addresses to gather<br/>Gather.Enable=1
  pb --)- py: done
  Note over py: .homing()
  py -)+ pb: download code
  Note over pb: runs homing PLC [if needed]<br/>enable plc 1
  pb --) py: done
  Note over py: wait(Motor[1].HomeComplete)
  deactivate py
  pb -)- py: HomeComplete
  activate py
  Note over py: .run()
  py -)+ pb: .run()
  Note over pb: runs motion program 2 in coordSystem 1<br/>&1br2
  pb --) py: done
  Note over py: .wait_armed()<br/>wait(Q[0]==-2)  # wait until motors are at first position
  deactivate py
  Note over pb: move to first point<br/>DesTimeBase=0 (wait motion)<br/>Q[0]=-3 (motion program waiting at start position)

  pb -) tsync: Q[0]=-3 (motion program waiting at start position)

  pb -)- py: Q[0]=-2 done
  activate py
  Note over py: .trigger() #send a start trigger (if needed) after given time
  Note over pb: wait for the start trigger
    Note over py:Q[10]=1
    py-)+pb: start trigger
    Note over pb: DesTimeBase=Sys.ServoPeriod
  Note over pb: pvt10abs<br/>move to all points
  Note over py: while .progress()<br/>wait(Gather.Enable==0)
  deactivate py
  loop 10 ms
    Note over pb: move to next point
  end
  #activate tsync
  #activate tsim
  tgss->>tsync: Wait for tsync to Finish
  tgss->>tsim: Wait for tsim to Finish

  Note over pb: Gather.Enable=0
  pb -) py: Gather.Enable=0
  pb -) tsync: Gather.Enable=0
  pb -)- tsim: Gather.Enable=0

  destroy tsync
  tsync-->>tgss: exit triggersync_func() thread
  destroy tsim
  tsim-->>tgss: exit triggersync_func() thread
  destroy tgss
  tsync-->tgss: Exit Main Thread
  
  activate py
  Note over py: .gather_upload()
  deactivate py