Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions etc/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,24 @@ def __init__(self, name, P, R, BRICK, COMMAND, DESC):
)


class _PandAEncoderSync(AutoSubstitution):
TemplateFile = 'PandAEncoderSync.template'

class PandAEncoderSync(Device):
def __init__(self, MOTOR, PANDA, BLOCK):
_PandAEncoderSync(
MOTOR=MOTOR,
PANDA=PANDA,
BLOCK=BLOCK
)

ArgInfo = makeArgInfo(__init__,
MOTOR = Simple("PV prefix for the controller", str),
PANDA = Simple("PV prefix for the PandA", str),
BLOCK = Simple("Name of the block to link to", str)
)


# hiding templates which are just used in includes so as to not
# dirty the auto list of builder objects (is this the best way to do this?)
class _pmacDirectMotorTemplate(AutoSubstitution):
Expand Down
3 changes: 3 additions & 0 deletions pmacApp/Db/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ DB += zform.template
# The following templates are used for CSS screens
DB += pmacCSS.template

# The following templates are used for synchronizing the PMAC values to the PandA readback
DB += PandAEncoderSync.template

#----------------------------------------------------
# If <anyname>.db template is not named <anyname>*.template add
# <anyname>_template = <templatename>
Expand Down
56 changes: 56 additions & 0 deletions pmacApp/Db/PandAEncoderSync.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Macros
# % macro, MOTOR, PV Prefix for the motor to sync with
# % macro, PANDA, PV Prefix for the PandA
# % macro, BLOCK, Which block to link to

record(calcout, "$(MOTOR):SCALECALC") {
field(CALC, "(B=0?A:-A)*(C>0?C:1)")
field(INPA, "$(MOTOR).ERES CP")
field(INPB, "$(MOTOR).DIR CP")
field(INPC, "$(MOTOR):SCALE CP")
field(OUT, "$(PANDA):$(BLOCK):ValScale PP")
field(PREC, "4")
}

record(calcout, "$(MOTOR):OFFCALC") {
field(CALC, "A")
field(INPA, "$(MOTOR).OFF CP")
field(OUT, "$(PANDA):$(BLOCK):ValOffset PP")
field(PREC, "4")
}

record(stringout, "$(MOTOR):UNITSCALC") {
field(OUT, "$(PANDA):$(BLOCK):UNITS PP")
field(DOL, "$(MOTOR).EGU CP")
field(OMSL, "closed_loop")
}

record(calcout, "$(MOTOR):ONHOMED") {
field(DESC, "Trigger seq when motor has been homed")
field(CALC, "A=0")
field(INPA, "$(MOTOR):HOMING CP")
field(OOPT, "Transition To Non-zero")
field(OUT, "$(MOTOR):ONENABLE.PROC")
field(VAL, "1")
}

record(seq, "$(MOTOR):ONENABLE") {
field(DESC, "Process all the records that update the PandA")
field(DOL1, "1")
field(DLY1, 1)
field(LNK1, "$(MOTOR):SETPOSCALC.PROC PP")
field(DOL2, "1")
field(DLY2, 1)
field(LNK2, "$(MOTOR):SCALECALC.PROC PP")
field(DOL3, "1")
field(DLY3, 1)
field(LNK3, "$(MOTOR):OFFCALC.PROC PP")
}

# % archiver 10 Monitor
record(calcout, "$(MOTOR):SETPOSCALC") {
field(CALC, "A*(B>0?B:1)")
field(INPA, "$(MOTOR).REP") #WRITES TO THE MOTOR RECORD VAL IN COUNTS INSTEAD OF :RBV
field(INPB, "$(MOTOR):SCALE")
field(OUT, "$(PANDA):$(BLOCK):Setp PP")
}