-
Notifications
You must be signed in to change notification settings - Fork 8
/
st.cmd.template
144 lines (116 loc) · 5.94 KB
/
st.cmd.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!{{hashbang}}
< envPaths
epicsEnvSet("ADS_IOC_TOP", "$(TOP)" )
epicsEnvSet("IOCNAME", "{{name}}" )
epicsEnvSet("ENGINEER", "{{user}}" )
epicsEnvSet("LOCATION", "{{prefix}}" )
epicsEnvSet("IOCSH_PS1", "$(IOCNAME)> " )
# Run common startup commands for linux soft IOC's
< /reg/d/iocCommon/All/pre_linux.cmd
# Register all support components
dbLoadDatabase("$(ADS_IOC_TOP)/dbd/adsIoc.dbd")
adsIoc_registerRecordDeviceDriver(pdbbase)
epicsEnvSet("ASYN_PORT", "{{asyn_port}}")
epicsEnvSet("IPADDR", "{{plc_ip}}")
epicsEnvSet("AMSID", "{{plc_ams_id}}")
epicsEnvSet("AMS_PORT", "{{plc_ads_port}}")
epicsEnvSet("ADS_MAX_PARAMS", "10000")
epicsEnvSet("ADS_SAMPLE_MS", "50")
epicsEnvSet("ADS_MAX_DELAY_MS", "100")
epicsEnvSet("ADS_TIMEOUT_MS", "1000")
epicsEnvSet("ADS_TIME_SOURCE", "0")
# adsAsynPortDriverConfigure(portName, ipaddr, amsaddr, amsport,
# asynParamTableSize, priority, noAutoConnect, defaultSampleTimeMS,
# maxDelayTimeMS, adsTimeoutMS, defaultTimeSource)
# portName Asyn port name
# ipAddr IP address of PLC
# amsaddr AMS Address of PLC
# amsport Default AMS port in PLC (851 for first PLC)
# paramTableSize Maximum parameter/variable count. (1000)
# priority Asyn priority (0)
# noAutoConnect Enable auto connect (0=enabled)
# defaultSampleTimeMS Default sample of variable (PLC ams router
# checks if variable changed, if changed then add to send buffer) (50ms)
# maxDelayTimeMS Maximum delay before variable that has changed is sent to client
# (Linux). The variable can also be sent sooner if the ams router
# send buffer is filled (100ms)
# adsTimeoutMS Timeout for adslib commands (1000ms)
# defaultTimeSource Default time stamp source of changed variable (PLC=0):
# PLC=0: The PLC time stamp from when the value was
# changed is used and set as timestamp in the EPICS record
# (if record TSE field is set to -2=enable asyn timestamp).
# This is the preferred setting.
# EPICS=1: The time stamp will be made when the updated data
# arrives in the EPICS client.
adsAsynPortDriverConfigure("$(ASYN_PORT)", "$(IPADDR)", "$(AMSID)", "$(AMS_PORT)", "$(ADS_MAX_PARAMS)", 0, 0, "$(ADS_SAMPLE_MS)", "$(ADS_MAX_DELAY_MS)", "$(ADS_TIMEOUT_MS)", "$(ADS_TIME_SOURCE)")
cd "$(ADS_IOC_TOP)/db"
{% if motors %}
epicsEnvSet("MOTOR_PORT", "{{motor_port}}")
epicsEnvSet("PREFIX", "{{prefix}}{{delim}}")
epicsEnvSet("NUMAXES", "{{nc.axis_by_id|max}}")
epicsEnvSet("MOVE_POLL_RATE", "200")
epicsEnvSet("IDLE_POLL_RATE", "1000")
EthercatMCCreateController("$(MOTOR_PORT)", "$(ASYN_PORT)", "$(NUMAXES)", "$(MOVE_POLL_RATE)", "$(IDLE_POLL_RATE)")
#define ASYN_TRACE_ERROR 0x0001
#define ASYN_TRACEIO_DEVICE 0x0002
#define ASYN_TRACEIO_FILTER 0x0004
#define ASYN_TRACEIO_DRIVER 0x0008
#define ASYN_TRACE_FLOW 0x0010
#define ASYN_TRACE_WARNING 0x0020
#define ASYN_TRACE_INFO 0x0040
asynSetTraceMask("$(ASYN_PORT)", -1, 0x41)
#define ASYN_TRACEIO_NODATA 0x0000
#define ASYN_TRACEIO_ASCII 0x0001
#define ASYN_TRACEIO_ESCAPE 0x0002
#define ASYN_TRACEIO_HEX 0x0004
asynSetTraceIOMask("$(ASYN_PORT)", -1, 2)
#define ASYN_TRACEINFO_TIME 0x0001
#define ASYN_TRACEINFO_PORT 0x0002
#define ASYN_TRACEINFO_SOURCE 0x0004
#define ASYN_TRACEINFO_THREAD 0x0008
asynSetTraceInfoMask("$(ASYN_PORT)", -1, 5)
#define AMPLIFIER_ON_FLAG_CREATE_AXIS 1
#define AMPLIFIER_ON_FLAG_WHEN_HOMING 2
#define AMPLIFIER_ON_FLAG_USING_CNEN 4
{% for motor in motors | sort(attribute='nc_axis.axis_number') %}
epicsEnvSet("AXIS_NO", "{{motor.nc_axis.axis_number}}")
epicsEnvSet("MOTOR_PREFIX", "{{motor|epics_prefix}}")
epicsEnvSet("MOTOR_NAME", "{{motor|epics_suffix}}")
epicsEnvSet("DESC", "{{motor.name}} / {{motor.nc_axis.name}}")
epicsEnvSet("EGU", "{{motor.nc_axis.units}}")
epicsEnvSet("PREC", "{{motor|pragma('precision', 3) }}")
epicsEnvSet("AXISCONFIG", "{{motor|pragma('axisconfig', '')}}")
epicsEnvSet("ECAXISFIELDINIT", "{{motor|pragma('additional_fields', '') }}")
epicsEnvSet("AMPLIFIER_FLAGS", "{{motor|pragma('amplifier_flags', '') }}")
EthercatMCCreateAxis("$(MOTOR_PORT)", "$(AXIS_NO)", "$(AMPLIFIER_FLAGS)", "$(AXISCONFIG)")
dbLoadRecords("EthercatMC.template", "PREFIX=$(MOTOR_PREFIX), MOTOR_NAME=$(MOTOR_NAME), R=$(MOTOR_NAME)-, MOTOR_PORT=$(MOTOR_PORT), ASYN_PORT=$(ASYN_PORT), AXIS_NO=$(AXIS_NO), DESC=$(DESC), PREC=$(PREC) $(ECAXISFIELDINIT)")
dbLoadRecords("EthercatMCreadback.template", "PREFIX=$(MOTOR_PREFIX), MOTOR_NAME=$(MOTOR_NAME), R=$(MOTOR_NAME)-, MOTOR_PORT=$(MOTOR_PORT), ASYN_PORT=$(ASYN_PORT), AXIS_NO=$(AXIS_NO), DESC=$(DESC), PREC=$(PREC) ")
dbLoadRecords("EthercatMCdebug.template", "PREFIX=$(MOTOR_PREFIX), MOTOR_NAME=$(MOTOR_NAME), MOTOR_PORT=$(MOTOR_PORT), AXIS_NO=$(AXIS_NO), PREC=3")
{% endfor %}
{% endif %}
dbLoadRecords("iocSoft.db", "IOC={{prefix}}")
dbLoadRecords("save_restoreStatus.db", "P={{prefix}}{{delim}}")
cd "$(IOC_TOP)"
{% if additional_db_files %}
{% for db in additional_db_files %}
dbLoadRecords("{{ db.file }}", "PORT={{ asyn_port }},PREFIX={{prefix}}{{delim}},IOCNAME=$(IOCNAME),{{ db.macros }}")
{% endfor %}
{% endif %}
# Setup autosave
set_savefile_path( "$(IOC_DATA)/$(IOC)/autosave" )
set_requestfile_path( "$(IOC_TOP)/autosave" )
save_restoreSet_status_prefix( "{{prefix}}{{delim}}" )
save_restoreSet_IncompleteSetsOk( 1 )
save_restoreSet_DatedBackupFiles( 1 )
set_pass0_restoreFile( "info_positions.sav" )
set_pass1_restoreFile( "info_settings.sav" )
cd "$(IOC_TOP)/autosave"
makeAutosaveFiles()
cd "$(IOC_TOP)"
# Initialize the IOC and start processing records
iocInit()
# Start autosave backups
create_monitor_set( "info_positions.req", 10, "" )
create_monitor_set( "info_settings.req", 60, "" )
# All IOCs should dump some common info after initial startup.
< /reg/d/iocCommon/All/post_linux.cmd