Switch to desktop version  
Assign alarms to booleans - Printable Version

+- Ewon Technical Forum (https://techforum.ewon.biz)
+-- Forum: Development (https://techforum.ewon.biz/forum-50.html)
+--- Forum: BASIC Script (https://techforum.ewon.biz/forum-52.html)
+--- Thread: Assign alarms to booleans (/thread-165.html)



Assign alarms to booleans - Francesco - 03-11-2016

Hi,
how could I split into different booleans (internal MEM tags) the alarms of an analog tag?
I would use internal Alarm setup: the activation or return of every alarm (Low, LowLow, High, HighHigh) must set or reset 4 different booleans.


And how can assign the value of an internal MEM tag to a setpoint (or activation delay, or deadband) in Alarm setup of a tag?

Thank you in advance for your help.


RE: Assign alarms to booleans - simon - 03-11-2016

Hi Francesco,

For this, you need to use the BASIC Scripting.

1.  To extract bits from an analog Tag, you have to use the # function.


Code:
REM : Extract bit 1 (starts at 0)
MEMbit@ = MEMAna@#1

See Basic Scripting manual on https://developer.ewon.biz/content/basic-1

2.  To change the configuration of a Tag through script. You must use the functions GETSYS and SETSYS.
Here is an example for changing the Alarm level of a Tag using another Tag value (to paste in the init section) :

Code:
ONCHANGE "AlarmLowLevel_PLC","GOTO AlarmLowLevel_PLC_Change"
ONCHANGE "AlarmHighLevel_PLC","GOTO AlarmHighLevel_PLC_Change"
REM : AlarmLowLevel_PLC tag is defined as an IOserver tag in order to read Alarm Low level tag value from PLC
REM : AlarmHighLevel_PLC tag is defined as an IOserver tag in order to read Alarm High level tag value from PLC

END

AlarmLowLevel_PLC_Change:

 SETSYS TAG, "LOAD", "MyProcessTag"
 SETSYS TAG, "AlLow", AlarmLowLevel_PLC@
 SETSYS TAG, "SAVE"
 
END

AlarmHighLevel_PLC_Change:

 SETSYS TAG, "LOAD", "MyProcessTag"
 SETSYS TAG, "AlHigh", AlarmHighLevel_PLC@
 SETSYS TAG, "SAVE"
 
END

The different field name of the Tag ( SETSYS TAG, "AlLow", AlarmLowLevel_PLC@) are defined at the page 120-121-122 of the RG-006 Document


RE: Assign alarms to booleans - Francesco - 03-11-2016

Thank you very much for your answer!
But about the first question: I would like to assign the 4 alarms of a tag to 4 different booleans tags, not to spilt the tag value.
Is there a way to do that?


RE: Assign alarms to booleans - simon - 03-11-2016

You can get the Alarm type by using the Script code :
Code:
SETSYS TAG, "LOAD", "MyTag"
AlarmType$ = GETSYS TAG, "AlType"

IF AlarmType$ = "1" THEN
   BoolTagOHi@ = 1
ELSE
   BoolTagOHi@ = 0
ENDIF
...

  1. "MyTag" is the TagName
  2. The value is returned as a string (AlarmType$ is a string variable)
  3. Here are the different values that you can get :
               0 : Ok
               1 : High
               2 : Low
               3 : Level
               4 : LowLow
               5 : HighHigh


RE: Assign alarms to booleans - Francesco - 03-11-2016

Very good! Thank you again!


RE: Assign alarms to booleans - simon - 03-11-2016

You are welcome.

Just one more thing I did not mention -> You can easily get a script executed when an alarm occurs in the eWON using the event "ONALARM".
Check the BASIC doc for more details.