diff --git a/roles/deploy_ioc/vars/smaract.yml b/roles/deploy_ioc/vars/smaract.yml new file mode 100644 index 00000000..9908fb23 --- /dev/null +++ b/roles/deploy_ioc/vars/smaract.yml @@ -0,0 +1,21 @@ +--- +# Variables for the smaract role +deploy_ioc_template_root_path: "{{ deploy_ioc_required_module_path }}" +deploy_ioc_required_module: motorsmaract_ab4dfeb +deploy_ioc_use_common: false +deploy_ioc_executable: smarAct +deploy_ioc_req_file_list: + - name: auto_settings.req + macros: "" + - name: auto_positions.req + macros: "" + - name: info_settings.req + macros: "" + - name: info_positions.req + macros: "" +deploy_ioc_device_specific_env: + PORT: SMARACT + CONTROLLER_IP: 127.0.0.1 + MODEL: MCS2 + NUM_AXES: 3 + AXES_MASK: "0x7" diff --git a/roles/device_roles/smaract/README.md b/roles/device_roles/smaract/README.md new file mode 100644 index 00000000..8912e693 --- /dev/null +++ b/roles/device_roles/smaract/README.md @@ -0,0 +1,4 @@ +# SmarAct Role + +This role deploys EPICS IOCs for SmarAct MCS and MCS2 motor controllers, +providing support for precise piezo motor positioning systems. diff --git a/roles/device_roles/smaract/defaults/main.yml b/roles/device_roles/smaract/defaults/main.yml new file mode 100644 index 00000000..617bf888 --- /dev/null +++ b/roles/device_roles/smaract/defaults/main.yml @@ -0,0 +1,4 @@ +--- +device_roles_smaract_moving_poll_period: 0.05 +device_roles_smaract_idle_poll_period: 1 +device_roles_smaract_disable_speed: 0 diff --git a/roles/device_roles/smaract/example.yml b/roles/device_roles/smaract/example.yml new file mode 100644 index 00000000..8d5f12f3 --- /dev/null +++ b/roles/device_roles/smaract/example.yml @@ -0,0 +1,38 @@ +--- + +SmarAct: + type: "smaract" + model: "MCS2" + num_axes: 3 + environment: + PREFIX: "XF:31ID1-ES{SMARACT:Dev-1}" + ENGINEER: "C. Engineer" + CONTROLLER_IP: "192.168.1.100" + PORT: "SMARACT" + MODEL: "MCS2" + NUM_AXES: 3 + AXES_MASK: "0x7" + substitutions: + smaract: + templates: + - filepath: "$(MOTOR)/db/basic_asyn_motor.db" + pattern: ["P", "N", "M", "DTYP", "PORT", "ADDR", "DESC", + "EGU", "DIR", "VELO", "VBAS", "ACCL", "BDST", + "BVEL", "BACC", "MRES", "PREC", "DHLM", "DLLM", + "INIT"] + instances: + - ["$(PREFIX)", 1, "{MCS2-Ax:1}Mtr", "asynMotor", + "$(PORT)", 0, "mm", "Pos", 0, 0, 0, 0, 1, 0.2, + 0.000001, 6, 0, 0, "", ""] + - ["$(PREFIX)", 2, "{MCS2-Ax:2}Mtr", "asynMotor", + "$(PORT)", 1, "mm", "Pos", 0, 0, 0, 0, 1, 0.2, + 0.000001, 6, 0, 0, "", ""] + - ["$(PREFIX)", 3, "{MCS2-Ax:3}Mtr", "asynMotor", + "$(PORT)", 2, "mm", "Pos", 0, 0, 0, 0, 1, 0.2, + 0.000001, 6, 0, 0, "", ""] + - filepath: "$(SMARACT)/db/MCS2_Extra.db" + pattern: ["P", "N", "M", "PORT", "ADDR", "TIMEOUT"] + instances: + - ["$(PREFIX)", 1, "{MCS2-Ax:1}Mtr", "$(PORT)", 0, 1.0] + - ["$(PREFIX)", 2, "{MCS2-Ax:2}Mtr", "$(PORT)", 1, 1.0] + - ["$(PREFIX)", 3, "{MCS2-Ax:3}Mtr", "$(PORT)", 2, 1.0] diff --git a/roles/device_roles/smaract/schema.yml b/roles/device_roles/smaract/schema.yml new file mode 100644 index 00000000..10b08f47 --- /dev/null +++ b/roles/device_roles/smaract/schema.yml @@ -0,0 +1,29 @@ +--- + +type: enum("smaract") +model: enum("MCS", "MCS2") +num_axes: int(min=1, required=True) +environment: + PREFIX: str(required=True) + ENGINEER: str(required=False) + CONTROLLER_IP: any(ip(), hostname(), required=True) + PORT: str(required=True) + NUM_AXES: int(min=1, required=True) + MODEL: enum("MCS", "MCS2", required=True) + AXES_MASK: str(required=False) +substitutions: + smaract: + templates: + - filepath: enum("$(MOTOR)/db/basic_asyn_motor.db") + pattern: list(any(enum("P"), enum("N"), enum("M"), + enum("DTYP"), enum("PORT"), enum("ADDR"), + enum("DESC"), enum("EGU"), enum("DIR"), + enum("VELO"), enum("VBAS"), enum("ACCL"), + enum("BDST"), enum("BVEL"), enum("BACC"), + enum("MRES"), enum("PREC"), enum("DHLM"), + enum("DLLM"), enum("INIT"))) + instances: list(list(min=20, max=20)) + - filepath: enum("$(SMARACT)/db/MCS2_Extra.db") + pattern: list(any(enum("P"), enum("N"), enum("M"), + enum("PORT"), enum("ADDR"), enum("TIMEOUT"))) + instances: list(list(min=6, max=6)) diff --git a/roles/device_roles/smaract/tasks/main.yml b/roles/device_roles/smaract/tasks/main.yml new file mode 100644 index 00000000..1e6143bf --- /dev/null +++ b/roles/device_roles/smaract/tasks/main.yml @@ -0,0 +1,33 @@ +--- + +- name: Deploy base startup script + ansible.builtin.template: + src: base.cmd.j2 + dest: "{{ deploy_ioc_ioc_directory }}/iocBoot/base.cmd" + mode: "0664" + owner: "{{ host_config.softioc_user }}" + group: "{{ host_config.softioc_group }}" + +- name: Install autosave settings req file + ansible.builtin.template: + src: auto_settings.req.j2 + dest: "{{ deploy_ioc_as_directory }}/req/auto_settings.req" + mode: "0664" + owner: "{{ host_config.softioc_user }}" + group: "{{ host_config.softioc_group }}" + +- name: Install autosave positions req file + ansible.builtin.template: + src: auto_positions.req.j2 + dest: "{{ deploy_ioc_as_directory }}/req/auto_positions.req" + mode: "0664" + owner: "{{ host_config.softioc_user }}" + group: "{{ host_config.softioc_group }}" + +- name: Deploy postInit script + ansible.builtin.template: + src: postInit.cmd.j2 + dest: "{{ deploy_ioc_ioc_directory }}/iocBoot/postInit.cmd" + mode: "0664" + owner: "{{ host_config.softioc_user }}" + group: "{{ host_config.softioc_group }}" diff --git a/roles/device_roles/smaract/templates/auto_positions.req.j2 b/roles/device_roles/smaract/templates/auto_positions.req.j2 new file mode 100644 index 00000000..bc8ebdd3 --- /dev/null +++ b/roles/device_roles/smaract/templates/auto_positions.req.j2 @@ -0,0 +1,3 @@ +{% for axis in ioc.substitutions.smaract.templates[0].instances %} +file "asyn_motor_positions.req", P=$(PREFIX), M={{ axis[2] }} +{% endfor %} diff --git a/roles/device_roles/smaract/templates/auto_settings.req.j2 b/roles/device_roles/smaract/templates/auto_settings.req.j2 new file mode 100644 index 00000000..409ecdfa --- /dev/null +++ b/roles/device_roles/smaract/templates/auto_settings.req.j2 @@ -0,0 +1,3 @@ +{% for axis in ioc.substitutions.smaract.templates[0].instances %} +file "asyn_motor_settings.req", P=$(PREFIX), M={{ axis[2] }} +{% endfor %} diff --git a/roles/device_roles/smaract/templates/base.cmd.j2 b/roles/device_roles/smaract/templates/base.cmd.j2 new file mode 100644 index 00000000..4d99e2d3 --- /dev/null +++ b/roles/device_roles/smaract/templates/base.cmd.j2 @@ -0,0 +1,21 @@ +## Register all support components +dbLoadDatabase("{{ deploy_ioc_required_module_path }}/dbd/smarAct.dbd") +smarAct_registerRecordDeviceDriver(pdbbase) + +# Configure the low level communication port +{% if ioc.model == "MCS2" %} +drvAsynIPPortConfigure("$(PORT)_ETH", "$(CONTROLLER_IP):55551", 0, 0, 0) +MCS2CreateController("$(PORT)", "$(PORT)_ETH", "$(NUM_AXES)", + {{ device_roles_smaract_moving_poll_period * 1000 }}, + {{ device_roles_smaract_moving_poll_period * 1000 }}, + $(AXES_MASK)) +{% else %} +drvAsynIPPortConfigure("$(PORT)_ETH", "$(CONTROLLER_IP):55551", 0, 0, 0) +smarActMCSCreateController("$(PORT)", "$(PORT)_ETH", {{ ioc.num_axes }}, + {{ device_roles_smaract_moving_poll_period }}, + {{ device_roles_smaract_idle_poll_period }}, + {{ device_roles_smaract_disable_speed }}) +{% for i in range(ioc.num_axes) %} +smaraActMCSCreateAxis("$(PORT)", {{ i }}, {{ i }}) +{% endfor %} +{% endif %} diff --git a/roles/device_roles/smaract/templates/postInit.cmd.j2 b/roles/device_roles/smaract/templates/postInit.cmd.j2 new file mode 100644 index 00000000..a2fbcc55 --- /dev/null +++ b/roles/device_roles/smaract/templates/postInit.cmd.j2 @@ -0,0 +1,11 @@ +motorUtilInit("$(PREFIX)") + +makeAutosaveFileFromDbInfo("$(TOP)/as/req/info_settings.req", + "autosaveFields") +makeAutosaveFileFromDbInfo("$(TOP)/as/req/info_positions.req", + "autosaveFields_pass0") + +cd $(TOP) + +dbl > /tmp/{{ deploy_ioc_ioc_name }}-records.dbl +date diff --git a/roles/install_module/vars/motorsmaract_ab4dfeb.yml b/roles/install_module/vars/motorsmaract_ab4dfeb.yml new file mode 100644 index 00000000..e245a9bb --- /dev/null +++ b/roles/install_module/vars/motorsmaract_ab4dfeb.yml @@ -0,0 +1,6 @@ +--- +motorsmaract_ab4dfeb: + name: motorSmarAct + url: https://github.com/epics-motor/motorSmarAct + version: ab4dfeb + executable: smarAct