diff --git a/etc/builder.py b/etc/builder.py index 71eadfdc..6b77bf46 100644 --- a/etc/builder.py +++ b/etc/builder.py @@ -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): diff --git a/pmacApp/Db/Makefile b/pmacApp/Db/Makefile index 62a2ca00..511ef957 100644 --- a/pmacApp/Db/Makefile +++ b/pmacApp/Db/Makefile @@ -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 .db template is not named *.template add # _template = diff --git a/pmacApp/Db/PandAEncoderSync.template b/pmacApp/Db/PandAEncoderSync.template new file mode 100644 index 00000000..34beae3d --- /dev/null +++ b/pmacApp/Db/PandAEncoderSync.template @@ -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") +} \ No newline at end of file