Skip to content

Commit

Permalink
Introduce REG_NAME macro in iosh and templates
Browse files Browse the repository at this point in the history
Add one more macro to allow to use a $(P)$(R)-style loading of templates
However, here we use $(SYSPFX) and $(AXIS_NAME) and now $(REG_NAME)
do assemble the complete record name.

THis change should not affect existing start scripts.
Changes to be committed:
    modified:   docs/PTP-Records-Alarms.txt
    modified:   ethercatmcApp/Db/ethercatmcEL1252-OneChannel.template
    modified:   ethercatmcApp/Db/ethercatmcEL6688-EL1252-PTP-POS-NEG.template
    modified:   ethercatmcApp/Db/ethercatmcEL6688-EL1252-PTP.template
    modified:   ethercatmcApp/Db/ethercatmcEL6688-PTP-twincat-ads.template
    modified:   ethercatmcApp/Db/ethercatmcEL6688-PTP.template
    modified:   ethercatmcApp/Db/ethercatmcPlcName.template
    modified:   iocsh/ethercatmcEL1252-OneChannel.iocsh
    modified:   iocsh/ethercatmcEL6688-EL1252-PTP-POS-NEG.iocsh
    modified:   iocsh/ethercatmcEL6688-EL1252-PTP.iocsh
    modified:   iocsh/ethercatmcEL6688-PTP-twincat-ads.iocsh
    modified:   iocsh/ethercatmcEL6688-PTP.iocsh
  • Loading branch information
tboegi committed Feb 29, 2024
1 parent a154de5 commit 54eb6a4
Show file tree
Hide file tree
Showing 12 changed files with 86 additions and 86 deletions.
16 changes: 8 additions & 8 deletions docs/PTP-Records-Alarms.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Note that all records should have 2 generic alarm:
DEVICE STATE is the alarm state "state": The device is not usable:
broken, not configured in the MCU. Some action is needed.

$(SYSPFX)PTPState
$(SYSPFX)$(REG_NAME)PTPState
Reflects the PTP state inside the EL6688 terminal.
The "good" value is "PTP:SLAVE"
A really problematic state is "PTP:NO_CABLE":
Expand All @@ -28,13 +28,13 @@ $(SYSPFX)PTPState
MAJOR STATE "PTP:NO_CABLE"
MINOR STATE all other states (e.g. PTP:LISTENING)

$(SYSPFX)PTPOffset
$(SYSPFX)$(REG_NAME)PTPOffset
Alarms:
INVALID DEVICE STATE (PTPState has an alarm)
MINOR DEVICE HIGH (PTPOffset is > +5000nsec. The MCU decides this!)
MINOR DEVICE LOW (PTPOffset is < -5000nsec. The MCU decides this!)

$(SYSPFX)PTPErrorStatus
$(SYSPFX)$(REG_NAME)PTPErrorStatus
Mainly used to collect the bits around the "EL6688 diag" structure.
None of the bits should be true under "all good" conditions.
Note: Once the the "NotSynchronized" bit becomes false,
Expand All @@ -47,7 +47,7 @@ $(SYSPFX)PTPErrorStatus
Alarms:
MINOR DEVICE HIGH (one of the bits is set)

$(SYSPFX)PTPdiffTimeIOC_MCU
$(SYSPFX)$(REG_NAME)PTPdiffTimeIOC_MCU
Shows the difference between the UTC time inside the IOC,
which is typically synchronized via NTP,
and the "UTC time" inside the MCU based on PTP.
Expand All @@ -65,19 +65,19 @@ $(SYSPFX)PTPdiffTimeIOC_MCU
MINOR DEVICE LOW
MINOR DEVICE HIGH

$(SYSPFX)PTPallGood
$(SYSPFX)$(REG_NAME)PTPallGood
My favorite record.
With help of $(SYSPFX)PTPAlarmSevrCalc an "overall good state"
With help of $(SYSPFX)$(REG_NAME)PTPAlarmSevrCalc an "overall good state"
is calculated, summarizing all PTP records from above.
Note that $(SYSPFX)PTPAlarmSevrCalc has it's own timer,
Note that $(SYSPFX)$(REG_NAME)PTPAlarmSevrCalc has it's own timer,
so that the PTPallGood will become Yes some seconds after
all alarms have disappeared.
The record itself has the value "Yes" or "No", and beside this,
we may find:
Alarms:
MINOR RECORD LINK

$(SYSPFX)TS_NS
$(SYSPFX)$(REG_NAME)TS_NS
The nano-second fraction of the 1Hz pulse.
The 1Hz pulse is created inside the timing system ("EVR") and
feed into an EL1252-0050 (the 5 volt version) to verify e.g.
Expand Down
8 changes: 4 additions & 4 deletions ethercatmcApp/Db/ethercatmcEL1252-OneChannel.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
record(int64in, "$(SYSPFX)UTCEL1252P$(CHNO)")
record(int64in, "$(SYSPFX)$(REG_NAME)UTCEL1252P$(CHNO)")
{
field(DTYP, "asynInt64")
field(DESC, "UTC of raising edge")
Expand All @@ -8,7 +8,7 @@ record(int64in, "$(SYSPFX)UTCEL1252P$(CHNO)")
#field(TSE, -2)
}

record(int64in, "$(SYSPFX)UTCEL1252N$(CHNO)")
record(int64in, "$(SYSPFX)$(REG_NAME)UTCEL1252N$(CHNO)")
{
field(DTYP, "asynInt64")
field(DESC, "UTC of falling edge")
Expand All @@ -18,9 +18,9 @@ record(int64in, "$(SYSPFX)UTCEL1252N$(CHNO)")
#field(TSE, -2)
}

#record(stringin, "$(SYSPFX)DClockEL1252ASC") {
#record(stringin, "$(SYSPFX)$(REG_NAME)DClockEL1252ASC") {
# field(DTYP, "Soft Timestamp")
# field(TSEL, "$(SYSPFX)DClockEL1252 CP")
# field(TSEL, "$(SYSPFX)$(REG_NAME)DClockEL1252 CP")
# field(INP, "@%Y/%m/%d %H:%M:%S.%06f")
#}

4 changes: 2 additions & 2 deletions ethercatmcApp/Db/ethercatmcEL6688-EL1252-PTP-POS-NEG.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
record(longin, "$(SYSPFX)TS_NS_POS")
record(longin, "$(SYSPFX)$(REG_NAME)TS_NS_POS")
{
field(DTYP, "asynInt32")
field(DESC, "TS_NS_POS fraction")
Expand All @@ -7,7 +7,7 @@ record(longin, "$(SYSPFX)TS_NS_POS")
field(SCAN, "1 second")
}

record(longin, "$(SYSPFX)TS_NS_NEG")
record(longin, "$(SYSPFX)$(REG_NAME)TS_NS_NEG")
{
field(DTYP, "asynInt32")
field(DESC, "TS_NS_NEG fraction")
Expand Down
2 changes: 1 addition & 1 deletion ethercatmcApp/Db/ethercatmcEL6688-EL1252-PTP.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
record(longin, "$(SYSPFX)TS_NS")
record(longin, "$(SYSPFX)$(REG_NAME)TS_NS")
{
field(DTYP, "asynInt32")
field(DESC, "TS_NS fraction")
Expand Down
32 changes: 16 additions & 16 deletions ethercatmcApp/Db/ethercatmcEL6688-PTP-twincat-ads.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
record(mbbi, "$(SYSPFX)PTPState") {
record(mbbi, "$(SYSPFX)$(REG_NAME)PTPState") {
field(DESC, "PTP state EtherCAT bus")
field(DTYP, "asynInt32")
field(INP, "@asyn($(ASYN_PORT),0,1)ADSPORT=852/EL6688_PTP.nPTPState?")
Expand Down Expand Up @@ -41,7 +41,7 @@ record(mbbi, "$(SYSPFX)PTPState") {
field(FFSV, "2")
}

record(longin, "$(SYSPFX)PTPOffset")
record(longin, "$(SYSPFX)$(REG_NAME)PTPOffset")
{
field(DTYP, "asynInt32")
field(DESC, "PTPOffset")
Expand All @@ -50,7 +50,7 @@ record(longin, "$(SYSPFX)PTPOffset")
field(SCAN, "1 second")
}

record(longin, "$(SYSPFX)PTPSyncSeqNum")
record(longin, "$(SYSPFX)$(REG_NAME)PTPSyncSeqNum")
{
field(DTYP, "asynInt32")
field(DESC, "PTPSyncSeqNum")
Expand All @@ -59,7 +59,7 @@ record(longin, "$(SYSPFX)PTPSyncSeqNum")
field(SCAN, "1 second")
}

record(int64in, "$(SYSPFX)DcToExtTimeOffset")
record(int64in, "$(SYSPFX)$(REG_NAME)DcToExtTimeOffset")
{
field(DTYP, "asynInt64")
field(DESC, "DcToExtTimeOffsetSystem")
Expand All @@ -68,7 +68,7 @@ record(int64in, "$(SYSPFX)DcToExtTimeOffset")
field(SCAN, "1 second")
}

record(int64in, "$(SYSPFX)SystemUTCtime")
record(int64in, "$(SYSPFX)$(REG_NAME)SystemUTCtime")
{
field(DTYP, "asynInt64")
field(DESC, "SystemUTCtime")
Expand All @@ -77,7 +77,7 @@ record(int64in, "$(SYSPFX)SystemUTCtime")
field(SCAN, "1 second")
}

record(int64in, "$(SYSPFX)SystemUTCtime-TSE")
record(int64in, "$(SYSPFX)$(REG_NAME)SystemUTCtime-TSE")
{
field(DTYP, "asynInt64")
field(DESC, "SystemUTCtime")
Expand All @@ -87,7 +87,7 @@ record(int64in, "$(SYSPFX)SystemUTCtime-TSE")
field(TSE, -2)
}

record(longin, "$(SYSPFX)PTPErrorStatus")
record(longin, "$(SYSPFX)$(REG_NAME)PTPErrorStatus")
{
field(DTYP, "asynInt32")
field(DESC, "PTPErrorStatus")
Expand All @@ -104,7 +104,7 @@ record(longin, "$(SYSPFX)PTPErrorStatus")
# Typically the MCU has an EL6688 with PTP
# Since the PLC cycle time is 10msec,
# we allow 10msec larger values for HIGH/HIHI
record(ai, "$(SYSPFX)PTPdiffTimeIOC_MCU")
record(ai, "$(SYSPFX)$(REG_NAME)PTPdiffTimeIOC_MCU")
{
field(DTYP, "asynFloat64")
field(DESC, "Diff between IOC time and MCU time")
Expand All @@ -121,29 +121,29 @@ record(ai, "$(SYSPFX)PTPdiffTimeIOC_MCU")
# Calculate the severity
# When the severity from all input links gets 0,
# start a countdown
record(transform, "$(SYSPFX)PTPAlarmSevrCalc") {
record(transform, "$(SYSPFX)$(REG_NAME)PTPAlarmSevrCalc") {
field(DESC, "Alarm Severity of PTP")
field(SCAN, "1 second")
field(COPT, "Always")
# Counter before allGood gets true
field(INPA, "11")
field(INPB, "$(SYSPFX)PTPState.SEVR CP MS")
field(INPC, "$(SYSPFX)PTPOffset.SEVR CP MS")
field(INPD, "$(SYSPFX)PTPErrorStatus.SEVR CP MS")
field(INPE, "$(SYSPFX)PTPdiffTimeIOC_MCU.SEVR CP MS")
field(INPB, "$(SYSPFX)$(REG_NAME)PTPState.SEVR CP MS")
field(INPC, "$(SYSPFX)$(REG_NAME)PTPOffset.SEVR CP MS")
field(INPD, "$(SYSPFX)$(REG_NAME)PTPErrorStatus.SEVR CP MS")
field(INPE, "$(SYSPFX)$(REG_NAME)PTPdiffTimeIOC_MCU.SEVR CP MS")
field(CLCN, "b || c || d || e")
# O is LED visible
field(CLCO, "N ? A : (O > 0 ? O - 1 : O)")
# P is all good
field(CLCP, "O > 0 ? 0 : 1")
field(FLNK, "$(SYSPFX)PTPallGood")
field(FLNK, "$(SYSPFX)$(REG_NAME)PTPallGood")

}

record(bo, "$(SYSPFX)PTPallGood") {
record(bo, "$(SYSPFX)$(REG_NAME)PTPallGood") {
field(DESC, "PTP is all good")
field(DTYP, "asynInt32")
field(DOL, "$(SYSPFX)PTPAlarmSevrCalc.P CP MS")
field(DOL, "$(SYSPFX)$(REG_NAME)PTPAlarmSevrCalc.P CP MS")
field(OMSL, "closed_loop")
#field(OUT, "@asyn($(MOTOR_PORT),0,1)ADSPORT=852/PTPallGood")
field(ZNAM, "No")
Expand Down
Loading

0 comments on commit 54eb6a4

Please sign in to comment.