Create an alarm list without use of Alarm config

2013-12-12
2024-06-06
  • techkarlsson - 2013-12-12

    I'm programming a WAGO 750-881 and almost finished with the main program. Next thing on the list would be alarm handling and displaying this both visual with lamps, and in the VISU. Except just showing red/green in the VISU I would also like to add a list of strings, representing each fault.
    When I scanned through the oscat.lib I found the FB's LIST_ADD etc and figured that could be worth a shot.

    With help of those functions I've managed to create a list with strings (using & as string separator) but now to the trouble to display this in the VISU. Does anyone know how I can split the string up and show them as a proper 1 column list instead of one single row? This is how the list now looks like ->
    "&Fault on refillvalve 1&Fault on levelsensor 5&Fault on external input 1"

    Thanks in advance.

     
  • hki75 - 2013-12-13

    Hi techkarlsson, I think you need to FIND the string position for each "&" character and REPLACE it with the LF+CR (Line feed =ASCII code 10, Carriage return=ASCII code 13). In this way I think you're able to have a text file where every row is one alarm

     
  • hki75 - 2013-12-13

    the best should be directly create string by string each one with its relevant LF+CR character.
    like this

    AlarmString : string;
    StringLen:INT; ( string length )
    StringPointer: POINTER TO ARRAY[0...max String Length ] of byte; ( need to define the max length of your alarm string)
    OpenFile: DWORD;
    WriteFile: DWORD;
    CloseFile:DWORD;
    FileName:STRING:='Alarms.csv'; ( file name..ex Alarms.csv )

    ( then with your application you wrote into the "AlarmString " and..)
    StringLen:=LEN(AlarmString );
    StringPointer:=ADR(AlarmString);
    StringPointer^[StringLen+1]:=10; ( LF )
    StringPointer^[StringLen+2]:=13; ( CR )

    ( and then append every new alarms string in your alarm File... ex Alarms.csv, return to next row for future alarms )

    OpenFile:=SysFileOpen(FileName, a); ( open Alarms.csv and append )
    WriteFile:=SysFileWrite(FileName, ADR(AlarmString ), StringLen+2);
    CloseFile:=SysFileClose(FileName);

    I used something like this in a log-report application..

     
  • techkarlsson - 2013-12-13

    First of all, thanks for you replies hki75!

    Unfortunately I think my level of programming is way lower than yours and I don't fully understand your code.
    As I understand it your example is to create an .csv file with the one alarm per row?

    I was hoping there was a simple way in the visualization "table" function in which I could split my long string up to induvidual rows instead of one single row.

    Your example is still interesting in case I want to add a logging function in the future but at the moment that is more than my head can handle!

     
  • shooter - 2013-12-15

    make alarmlinearray [0..100]:string (30);

    fill it with texts in a function block
    like
    alarmline[1]:='001 it is too cold outhere';
    alarmline[2]:='002 the winter is coming';
    etc

    a activealarmarray[0..10]:bool;
    a dataealarmarray[0..10]:date;
    a textalarmarray[0..10]:int;

    on screen
    if activealarmarray= true;
    show the date and the text by alarmline[(textalarmarray[linenumber])];
    repeat this 10 times.

    there are complex ways to do this just start with this simple one so you get familiar with it.
    oscat is using a lot of pointers etc it is working but very difficult to understand

     

    Related

    Talk.ru: 1
    Talk.ru: 2

  • techkarlsson - 2013-12-15

    Thanks for your reply shooter!

    I will try this out asap.

    Cheers.

     
  • techkarlsson - 2013-12-15

    Ok, tried it but I can't get it to work. I don't think I've understood you fully. Maybe I should stick with CFC and ladder...

    VAR_GLOBAL
    Β  Β ALARMLINE : ARRAY[1..100] OF STRING(30);
    Β  Β SHOW_VISU: STRING;
    END_VAR
    _____________________________________________________________________
    FUNCTION_BLOCK TEST_OF_LIST_2
    VAR
    Β  Β ACTIVEALARM : ARRAY[0..10] OF BOOL;
    Β  Β DATEALARM : ARRAY[0..10] OF DATE;
    Β  Β TEXTALARM : ARRAY[0..10] OF INT;
    END_VAR
    ALARMLINE[1]:='001 TEST1';
    ALARMLINE[2]:='002 TEST2';
    ALARMLINE[3]:='003 TEST3';
    ALARMLINE[4]:='004 TEST4';
    ALARMLINE[5]:='005 TEST5';
    ALARMLINE[6]:='006 TEST6';
    ALARMLINE[7]:='007 TEST7';
    ALARMLINE[8]:='008 TEST8';
    ALARMLINE[9]:='009 TEST9';
    ALARMLINE[10]:='010 TEST10';
    IF ACTIVEALARM THEN
    Β  Β SHOW_VISU := ALARMLINE[(TEXTALARM[i])];
    END_IF
    __________________________________________________________________________
    

    Finally I'm watching the SHOW_VISU variable in the VISU-table.

    Am I far off?

     
  • shooter - 2013-12-16

    no this is nice start
    now in the visualisation make a line with:
    datealarm[1] and textalarm[1] followed by alarmline[(textalarm[1])
    make this ten lines (1..10) for example
    now play a little with numbers by changing the number in textalarm, you will get all the different messages.

    if an alarm is not active anymore change the bool to false. (this can be used to change visibility.
    but better is to shift other lines one up.

    if your show_visu is on the screen you will see one alarm. good for beginning.

     

    Related

    Talk.ru: 1

  • techkarlsson - 2013-12-17

    Thanks for you effort but I give up now shooter.
    I've tried to get that IF statement to work but just errors about that cannot convert array to bool or whatever. Then tried a FOR statement but my knowledge level is simply too low. I will do this in some other way. Guess I need to take some classes in ST before I try it again.

    Cheers.

     
  • shooter - 2013-12-17

    i never give up.

    IF should be

    IF activealarm[1]=TRUE THEN
    etc
    at the end END_IF
    this is because activealarm is not in the varlist but activealarmarray is.
    it is a simple error everybody makes.

     

    Related

    Talk.ru: 1

  • talhaali - 2024-06-06

    Hi, I am trying to access active alarms in code(As alarm count variable updates only when we go to to alarm table frame in visualization). I wrote following code but it is not working:

    VAR
    iCountActiveAlarms : INT;
    parritfActiveAlarms : POINTER TO ARRAY[0..0] OF IAlarm;
    itfAlarmManagerClientAll : IAlarmManagerClient;
    END_VAR

    AlarmManager.g_AlarmHandler.GetActiveAlarms(
    itfAlarmManagerClient :=itfAlarmManagerClientAll,
    iCountActiveAlarms => iCountActiveAlarms,
    parritfActiveAlarms => parritfActiveAlarms);

    The Value is always 0.
    Please help.

     
  • talhaali - 2024-06-06

    Hi, I am trying to access active alarms in code(As alarm count variable updates only when we go to to alarm table frame in visualization). I wrote following code but it is not working:

    VAR
    iCountActiveAlarms : INT;
    parritfActiveAlarms : POINTER TO ARRAY[0..0] OF IAlarm;
    itfAlarmManagerClientAll : IAlarmManagerClient;
    END_VAR

    AlarmManager.g_AlarmHandler.GetActiveAlarms(
    itfAlarmManagerClient :=itfAlarmManagerClientAll,
    iCountActiveAlarms => iCountActiveAlarms,
    parritfActiveAlarms => parritfActiveAlarms);

    The Value is always 0.
    Please help.

     

Log in to post a comment.