#!/bin/bash
for xmlfile in *.xml; do
base="${xmlfile%.*}"
outfile="${base}.rc"
id=1
> "$outfile" # 清空输出文件
# 处理 <setIntlkAlarm> 内容
awk -v id=1 '
BEGIN { FS="<setIntlkAlarm[^>]*>|</setIntlkAlarm>"; OFS="" }
/<setIntlkAlarm/ {
for (i = 2; i < NF; i += 2) {
split($i, arr, ",")
str1 = gensub(/^ +| +$/, "", "g", arr[1])
str2 = gensub(/^ +| +$/, "", "g", arr[2])
str3 = gensub(/^ +| +$/, "", "g", arr[3])
printf("KEY:%s\n", str1)
printf("MSG:%s\n", str3)
printf("DES:%s\n", str3)
printf("LEVEL:%s\n", str2)
printf("ID:%d\n", id)
printf("\n")
id++
}
}
' "$xmlfile" >> "$outfile"
echo "生成: $outfile"
done <VInterlocks>
<!--efem_rorze_3lp_beg-->
<!--
<IceTimeout class="STDTMVInterlock" type="instance" alias="">
<setTrigger type="method">(/IO/SysExports/CallbackErrDisp != NoError)</setTrigger>
<setIntlkAlarm type="method">Alarm,FATAL,GUI and MEC communication time out occurs.</setIntlkAlarm>
<acceptUnknown type="method">TriggerUnknown,FATAL,Interlock trigger state is unknown.</acceptUnknown>
<addIntDescriptorActionNoAlarm type="method">/IO/Platform/TowerLight/Red,ON</addIntDescriptorActionNoAlarm>
<addIntDescriptorActionNoAlarm type="method">/IO/Platform/TowerLight/Buzzer,ON</addIntDescriptorActionNoAlarm>
</IceTimeout>
-->
<EFEMDoor class="STDTMVInterlock" type="instance">
<setTrigger type="method">(/IO/Platform/EFEM/DoorOpenDI == Open)</setTrigger>
<setIntlkAlarm type="method">Alarm,NOTICE,EFEM Door is not closed.</setIntlkAlarm>
&SimulatedFlag_Ch1;
<acceptUnknown type="method">TriggerUnknown,FATAL,Interlock trigger state is unknown. (Hardware IO may be unavailable)</acceptUnknown>
</EFEMDoor>
<PressureStatus type="data" dataType="I" accessMode="RW" alias="/IO/FFUExports/PressureStatus">
<Bd></Bd>
<Ch></Ch>
<Min>0</Min>
<Max>1</Max>
<DescriptorList>Abnormal:0,Normal:1</DescriptorList>
</PressureStatus>
<FFUPressureNormal type="instance" class="STDTMVInterlock" alias="">
<setTriggerInterval type="method">2000</setTriggerInterval>
<setTrigger type="method">(/IO/Platform/EFEM/PressureAI >= /SETUP/Control/EFEM/FFUPressure)</setTrigger>
<addIntDescriptorActionNoAlarm type="method">/Control/ATR/VInterlocks/PressureStatus,Normal</addIntDescriptorActionNoAlarm>
</FFUPressureNormal>
<FFUPressureAbnormal type="instance" class="STDTMVInterlock" alias="">
<setTriggerInterval type="method">2000</setTriggerInterval>
<setTrigger type="method">(/IO/Platform/EFEM/PressureAI < /SETUP/Control/EFEM/FFUPressure)</setTrigger>
<addIntDescriptorActionNoAlarm type="method">/Control/ATR/VInterlocks/PressureStatus,Abnormal</addIntDescriptorActionNoAlarm>
</FFUPressureAbnormal>
<FFUPressureAlarm type="instance" class="STDTMVInterlock" alias="">
<setDurationTrigger type="method">(/Control/ATR/VInterlocks/PressureStatus == Abnormal),10000</setDurationTrigger>
<setIntlkAlarm type="method">Alarm,ERROR,EFEM Pressure is too Low!</setIntlkAlarm>
<acceptUnknown type="method">TriggerUnknown,FATAL,Interlock trigger state is unknown. (Hardware IO may be unavailable)</acceptUnknown>
</FFUPressureAlarm>
<FFU1SpeedStatus type="data" dataType="I" accessMode="RW" alias="/IO/FFUExports/FFU1SpeedStatus">
<Bd></Bd>
<Ch></Ch>
<Min>0</Min>
<Max>1</Max>
<DescriptorList>Abnormal:0,Normal:1</DescriptorList>
</FFU1SpeedStatus>
<FFU1SpeedNormal type="instance" class="STDTMVInterlock" alias="">
<setTriggerInterval type="method">2000</setTriggerInterval>
<setTrigger type="method">(/IO/Platform/EFEM/FFU1SpeedAI >= /SETUP/Control/EFEM/FFUSpeed)</setTrigger>
<addIntDescriptorActionNoAlarm type="method">/Control/ATR/VInterlocks/FFU1SpeedStatus,Normal</addIntDescriptorActionNoAlarm>
</FFU1SpeedNormal>
<FFU1SpeedAbnormal type="instance" class="STDTMVInterlock" alias="">
<setTriggerInterval type="method">2000</setTriggerInterval>
<setTrigger type="method">(/IO/Platform/EFEM/FFU1SpeedAI < /SETUP/Control/EFEM/FFUSpeed)</setTrigger>
<addIntDescriptorActionNoAlarm type="method">/Control/ATR/VInterlocks/FFU1SpeedStatus,Abnormal</addIntDescriptorActionNoAlarm>
</FFU1SpeedAbnormal>
<FFU1SpeedAlarm type="instance" class="STDTMVInterlock" alias="">
<setDurationTrigger type="method">(/Control/ATR/VInterlocks/FFU1SpeedStatus == Abnormal),10000</setDurationTrigger>
<setIntlkAlarm type="method">Alarm,ERROR,EFEM fan1 Rotating speed is too low!</setIntlkAlarm>
<acceptUnknown type="method">TriggerUnknown,FATAL,Interlock trigger state is unknown. (Hardware IO may be unavailable)</acceptUnknown>
</FFU1SpeedAlarm>
<FFU2SpeedStatus type="data" dataType="I" accessMode="RW" alias="/IO/FFUExports/FFU2SpeedStatus">
<Bd></Bd>
<Ch></Ch>
<Min>0</Min>
<Max>1</Max>
<DescriptorList>Abnormal:0,Normal:1</DescriptorList>
</FFU2SpeedStatus>
<FFU2SpeedNormal type="instance" class="STDTMVInterlock" alias="">
<setTriggerInterval type="method">2000</setTriggerInterval>
<setTrigger type="method">(/IO/Platform/EFEM/FFU2SpeedAI >= /SETUP/Control/EFEM/FFUSpeed)</setTrigger>
<addIntDescriptorActionNoAlarm type="method">/Control/ATR/VInterlocks/FFU2SpeedStatus,Normal</addIntDescriptorActionNoAlarm>
</FFU2SpeedNormal>
<FFU2SpeedAbnormal type="instance" class="STDTMVInterlock" alias="">
<setTriggerInterval type="method">2000</setTriggerInterval>
<setTrigger type="method">(/IO/Platform/EFEM/FFU2SpeedAI < /SETUP/Control/EFEM/FFUSpeed)</setTrigger>
<addIntDescriptorActionNoAlarm type="method">/Control/ATR/VInterlocks/FFU2SpeedStatus,Abnormal</addIntDescriptorActionNoAlarm>
</FFU2SpeedAbnormal>
<FFU2SpeedAlarm type="instance" class="STDTMVInterlock" alias="">
<setDurationTrigger type="method">(/Control/ATR/VInterlocks/FFU2SpeedStatus == Abnormal),10000</setDurationTrigger>
<setIntlkAlarm type="method">Alarm,ERROR,EFEM fan2 Rotating speed is too low!</setIntlkAlarm>
<acceptUnknown type="method">TriggerUnknown,FATAL,Interlock trigger state is unknown. (Hardware IO may be unavailable)</acceptUnknown>
</FFU2SpeedAlarm>
<FFU3SpeedStatus type="data" dataType="I" accessMode="RW" alias="/IO/FFUExports/FFU3SpeedStatus">
<Bd></Bd>
<Ch></Ch>
<Min>0</Min>
<Max>1</Max>
<DescriptorList>Abnormal:0,Normal:1</DescriptorList>
</FFU3SpeedStatus>
<FFU3SpeedNormal type="instance" class="STDTMVInterlock" alias="">
<setTriggerInterval type="method">2000</setTriggerInterval>
<setTrigger type="method">(/IO/Platform/EFEM/FFU3SpeedAI >= /SETUP/Control/EFEM/FFUSpeed)</setTrigger>
<addIntDescriptorActionNoAlarm type="method">/Control/ATR/VInterlocks/FFU3SpeedStatus,Normal</addIntDescriptorActionNoAlarm>
</FFU3SpeedNormal>
<FFU3SpeedAbnormal type="instance" class="STDTMVInterlock" alias="">
<setTriggerInterval type="method">2000</setTriggerInterval>
<setTrigger type="method">(/IO/Platform/EFEM/FFU3SpeedAI < /SETUP/Control/EFEM/FFUSpeed)</setTrigger>
<addIntDescriptorActionNoAlarm type="method">/Control/ATR/VInterlocks/FFU3SpeedStatus,Abnormal</addIntDescriptorActionNoAlarm>
</FFU3SpeedAbnormal>
<FFU3SpeedAlarm type="instance" class="STDTMVInterlock" alias="">
<setDurationTrigger type="method">(/Control/ATR/VInterlocks/FFU3SpeedStatus == Abnormal),10000</setDurationTrigger>
<setIntlkAlarm type="method">Alarm,ERROR,EFEM fan3 Rotating speed is too low!</setIntlkAlarm>
<acceptUnknown type="method">TriggerUnknown,FATAL,Interlock trigger state is unknown. (Hardware IO may be unavailable)</acceptUnknown>
</FFU3SpeedAlarm>
<!--efem_rorze_3lp_end-->
</VInterlocks>
在上面的脚本基础上,获取找到的模式所在上一级的名称