I have several identical subsystems that can have many different fault conditions. It would be extremely time-consuming and error-prone if I put separate alarm conditions for each subsystem in the alarm configuration:
Expression              Type   Class   MessagePLC_PRG.systems[0].material.consumed DIG=1  WARNING  Materialdepletedonsystem0PLC_PRG.systems[0].material.jammed  DIG=1  INTERLOCK Materialjammedonsystem0PLC_PRG.systems[0].sensor.blocked   DIG=1  INTERLOCK Sensorblockedonsystem0...PLC_PRG.systems[1].material.consumed DIG=1  WARNING  Materialdepletedonsystem1PLC_PRG.systems[1].material.jammed  DIG=1  INTERLOCK Materialjammedonsystem1PLC_PRG.systems[1].sensor.blocked   DIG=1  INTERLOCK Sensorblockedonsystem1...PLC_PRG.systems[2].......PLC_PRG.systems[3].......
Is there a way that I could use placeholders like this?
Wherei:=0TO5Expression               Type   Class   MessagePLC_PRG.systems[$i$].material.consumed DIG=1  WARNING  Materialdepletedonsystem$i$PLC_PRG.systems[$i$].material.jammed  DIG=1  INTERLOCK Materialjammedonsystem$i$PLC_PRG.systems[$i$].sensor.blocked   DIG=1  INTERLOCK Sensorblockedonsystem$i$...
I would be okay with using some function to manually add the alarm to the alarm table, too. Something like:
FORi :=0TO5DO
 IFsystems[i].material.consumedTHEN
  message :=CONCAT('Material depleted on system ', SINT_TO_STRING(i));
  NewAlarm(
   expr :='PLC_PRG.systems[i].material.consumed',
   type :=ALARMTYPE_DIG1,
   class :='WARNING',
   priority :=0,
   msg :=message
   );
 END_IF
 ...
END_FOR
As long as I don't have to change six pieces of code to fix one bug!
apart from the expr where you use [i] (which will not work) it is good.
you will have to keep in your own array the status as this is lost due to the loop.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
shooter hat geschrieben:
apart from the expr where you use [i] (which will not work) it is good.
you will have to keep in your own array the status as this is lost due to the loop.
The NewAlarm function doesn't really exist. I just put it there to show what kind of function I'm looking for. (In the real thing, I'm going to CONCAT the value of i into expr -- provided that something like NewAlarm really exists.) I am already storing the status in my own array; I am trying to cause an alarm whenever any subsystem faults. The difficult thing is, I want to:
1) Have the message show which of the many subsystems faulted, and
2) Not have to maintain six different copies of the alarm, the only difference being the i variable.
My question again: Is there a way to do this?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have several identical subsystems that can have many different fault conditions. It would be extremely time-consuming and error-prone if I put separate alarm conditions for each subsystem in the alarm configuration:
Is there a way that I could use placeholders like this?
I would be okay with using some function to manually add the alarm to the alarm table, too. Something like:
As long as I don't have to change six pieces of code to fix one bug!
Related
Talk.ru: 1
Talk.ru: 2
Talk.ru: 3
apart from the expr where you use [i] (which will not work) it is good.
you will have to keep in your own array the status as this is lost due to the loop.
The NewAlarm function doesn't really exist. I just put it there to show what kind of function I'm looking for. (In the real thing, I'm going to CONCAT the value of i into expr -- provided that something like NewAlarm really exists.) I am already storing the status in my own array; I am trying to cause an alarm whenever any subsystem faults. The difficult thing is, I want to:
1) Have the message show which of the many subsystems faulted, and
2) Not have to maintain six different copies of the alarm, the only difference being the i variable.
My question again: Is there a way to do this?