From 2f27120170d48759327c5b5f7b514685e96fa816 Mon Sep 17 00:00:00 2001 From: Stephan Date: Fri, 30 Oct 2020 18:13:57 +0100 Subject: [PATCH] Add max entries to parameter structure --- Logical/mappLogbook/LogTypes.typ | 27 ++++++++++--------- Logical/mappLogbook/LogVariables.var | 4 +-- Logical/mappLogbook/Logbook/LocalFunctions.st | 4 +-- Logical/mappLogbook/Logbook/Main.st | 16 ++++++----- Logical/mappLogbook/Logbook/Types.typ | 10 +++---- Logical/mappLogbook/Logbook/Variables.var | 4 +-- Logical/mappLogbook/changelog.txt | 4 +++ .../Pages/LogbookPage/Content.content | 8 +++--- .../X20CP1583/Connectivity/OpcUA/OpcUaMap.uad | 1 - .../PC/X20CP1583/mappView/Logbook.binding | 19 +++++++++---- .../X20CP1583/mappView/Logbook.eventbinding | 2 +- 11 files changed, 58 insertions(+), 41 deletions(-) diff --git a/Logical/mappLogbook/LogTypes.typ b/Logical/mappLogbook/LogTypes.typ index 95cabd5..54dd576 100644 --- a/Logical/mappLogbook/LogTypes.typ +++ b/Logical/mappLogbook/LogTypes.typ @@ -51,16 +51,17 @@ TYPE logbookPAR : STRUCT (*Parameter structure*) DateNow : DATE_AND_TIME; (*Current date and time*) TableConfig : STRING[100]; (*Hide unused rows*) + EntriesMax : UINT; (*Maximum number of entries, shadow of LOGBOOK_ENTRIES_MAX*) FilterErrorNo : UDINT; (*Filter by error number*) FilterErrorText : STRING[100]; (*Filter by error text*) FilterSeverity : ARRAY[0..3]OF BOOL := [4(TRUE)]; (*Filter by severity*) - FilterFacility : ARRAY[0..LOGBOOK_FACILITIES_TOTAL]OF BOOL := [14(TRUE)]; (*Filter by facility*) + FilterFacility : ARRAY[0..LOGBOOK_FACILITIES_MAX]OF BOOL := [14(TRUE)]; (*Filter by facility*) FilterDateStart : DATE; (*Filter by date*) FilterDateEnd : DATE; Sorting : enumSorting := sortingDESC; (*Sort date asc or desc*) AbortOnEntriesLimit : BOOL; (*Stop looking for additional entries when limit is reached*) AutoUpdate : BOOL; (*Automatically update data*) - AutoUpdateInterval : UINT := 10; (*Interval for auto refresh in s*) + AutoUpdateInterval : UINT := 10; (*Interval for auto update in s*) END_STRUCT; logbookERR : STRUCT (*Error structure*) State : enumLogbook; (*State where the error occured*) @@ -69,20 +70,20 @@ TYPE Entries : logbookENTRIES; EntriesTotal : UINT; (*Total number of entries*) CntSeverity : ARRAY[0..3]OF UINT; (*Counts by severity*) - CntFacility : ARRAY[0..LOGBOOK_FACILITIES_TOTAL]OF UINT; (*Counts by facility*) + CntFacility : ARRAY[0..LOGBOOK_FACILITIES_MAX]OF UINT; (*Counts by facility*) LastUpdate : STRING[25]; (*Last refresh run*) END_STRUCT; logbookENTRIES : STRUCT (*Entries structure*) - EventID : ARRAY[1..LOGBOOK_ENTRIES_TOTAL]OF DINT; (*Event ID*) - Timestamp : ARRAY[1..LOGBOOK_ENTRIES_TOTAL]OF STRING[25]; (*Date and time*) - DTsec : ARRAY[1..LOGBOOK_ENTRIES_TOTAL]OF UDINT; (*Date and time in sec*) - DTmsec : ARRAY[1..LOGBOOK_ENTRIES_TOTAL]OF UDINT; (*Additional milliseconds*) - Severity : ARRAY[1..LOGBOOK_ENTRIES_TOTAL]OF USINT; (*Severity*) - Code : ARRAY[1..LOGBOOK_ENTRIES_TOTAL]OF UINT; (*Code*) - FacilityCode : ARRAY[1..LOGBOOK_ENTRIES_TOTAL]OF UINT; (*Facility code*) - FacilityText : ARRAY[1..LOGBOOK_ENTRIES_TOTAL]OF STRING[30]; (*Facility text*) - ErrorNo : ARRAY[1..LOGBOOK_ENTRIES_TOTAL]OF DINT; (*Error number*) - ErrorText : ARRAY[1..LOGBOOK_ENTRIES_TOTAL]OF STRING[LOGBOOK_TEXT_LEN]; (*Error text*) + EventID : ARRAY[1..LOGBOOK_ENTRIES_MAX]OF DINT; (*Event ID*) + Timestamp : ARRAY[1..LOGBOOK_ENTRIES_MAX]OF STRING[25]; (*Date and time*) + DTsec : ARRAY[1..LOGBOOK_ENTRIES_MAX]OF UDINT; (*Date and time in sec*) + DTmsec : ARRAY[1..LOGBOOK_ENTRIES_MAX]OF UDINT; (*Additional milliseconds*) + Severity : ARRAY[1..LOGBOOK_ENTRIES_MAX]OF USINT; (*Severity*) + Code : ARRAY[1..LOGBOOK_ENTRIES_MAX]OF UINT; (*Code*) + FacilityCode : ARRAY[1..LOGBOOK_ENTRIES_MAX]OF UINT; (*Facility code*) + FacilityText : ARRAY[1..LOGBOOK_ENTRIES_MAX]OF STRING[30]; (*Facility text*) + ErrorNo : ARRAY[1..LOGBOOK_ENTRIES_MAX]OF DINT; (*Error number*) + ErrorText : ARRAY[1..LOGBOOK_ENTRIES_MAX]OF STRING[LOGBOOK_TEXT_LEN]; (*Error text*) END_STRUCT; logbookMAIN : STRUCT (*Main structure*) CMD : logbookCMD; diff --git a/Logical/mappLogbook/LogVariables.var b/Logical/mappLogbook/LogVariables.var index 0d312dd..ab7b2d3 100644 --- a/Logical/mappLogbook/LogVariables.var +++ b/Logical/mappLogbook/LogVariables.var @@ -3,7 +3,7 @@ VAR END_VAR VAR CONSTANT LOGBOOK_EXECUTIONS : USINT := 10; (*Executions per cycle*) - LOGBOOK_ENTRIES_TOTAL : UINT := 100; (*Total number of entries*) - LOGBOOK_FACILITIES_TOTAL : USINT := 13; (*Total number of facilities*) + LOGBOOK_ENTRIES_MAX : UINT := 100; (*Total number of entries*) + LOGBOOK_FACILITIES_MAX : USINT := 13; (*Total number of facilities*) LOGBOOK_TEXT_LEN : UINT := 200; (*Error text length*) END_VAR diff --git a/Logical/mappLogbook/Logbook/LocalFunctions.st b/Logical/mappLogbook/Logbook/LocalFunctions.st index 5785352..54047c2 100644 --- a/Logical/mappLogbook/Logbook/LocalFunctions.st +++ b/Logical/mappLogbook/Logbook/LocalFunctions.st @@ -56,7 +56,7 @@ FUNCTION InsertEntry END_FOR; // Add data as long as buffer is not full - IF DAT.EntriesTotal < LOGBOOK_ENTRIES_TOTAL THEN + IF DAT.EntriesTotal < LOGBOOK_ENTRIES_MAX THEN IF DAT.EntriesTotal = 1 AND idx = 1 THEN idy := 1; ELSIF DAT.EntriesTotal > idx THEN @@ -66,7 +66,7 @@ FUNCTION InsertEntry // If buffer is full check where entry fits ELSE // Entry is beyond scope of buffer - IF idx >= LOGBOOK_ENTRIES_TOTAL THEN + IF idx >= LOGBOOK_ENTRIES_MAX THEN InsertEntry := NO_SPACE; RETURN; ELSE diff --git a/Logical/mappLogbook/Logbook/Main.st b/Logical/mappLogbook/Logbook/Main.st index d94421d..957d9a9 100644 --- a/Logical/mappLogbook/Logbook/Main.st +++ b/Logical/mappLogbook/Logbook/Main.st @@ -36,6 +36,7 @@ PROGRAM _CYCLIC DTGetTime_0.enable := TRUE; DTGetTime_0(); gLogbook.PAR.DateNow := DTGetTime_0.DT1; + gLogbook.PAR.EntriesMax := LOGBOOK_ENTRIES_MAX; // -------------------------------------------------------------------------------------------------------------------- // Refresh all logbook data @@ -54,6 +55,7 @@ PROGRAM _CYCLIC AutoRefresh.PT := gLogbook.PAR.AutoUpdateInterval*100; AutoRefresh(); IF AutoRefresh.Q THEN + AutoRefresh(IN:= FALSE); gLogbook.CMD.Update := TRUE; state := enumNext; END_IF @@ -88,7 +90,7 @@ PROGRAM _CYCLIC gLogbook.PAR.TableConfig := '{"specRows":[{"from":'; brsstrcat(ADR(gLogbook.PAR.TableConfig), ADR(tmpSTR)); brsstrcat(ADR(gLogbook.PAR.TableConfig), ADR(', "to":')); - brsitoa(LOGBOOK_ENTRIES_TOTAL, ADR(tmpSTR)); + brsitoa(LOGBOOK_ENTRIES_MAX, ADR(tmpSTR)); brsstrcat(ADR(gLogbook.PAR.TableConfig), ADR(tmpSTR)); brsstrcat(ADR(gLogbook.PAR.TableConfig), ADR(', "visible":false}]}')); @@ -103,7 +105,7 @@ PROGRAM _CYCLIC // -------------------------------------------------------------------------------------------------------------------- enumOpen: // Last facility reached - IF Facility.CntFacility > LOGBOOK_FACILITIES_TOTAL THEN + IF Facility.CntFacility > LOGBOOK_FACILITIES_MAX THEN Facility.CntFacility := 0; state := enumLatest; EXIT; @@ -406,17 +408,17 @@ PROGRAM _CYCLIC // Find next facility from here to the end REPEAT Facility.CntFacility := Facility.CntFacility + 1; - IF Facility.CntFacility <= LOGBOOK_FACILITIES_TOTAL THEN + IF Facility.CntFacility <= LOGBOOK_FACILITIES_MAX THEN IF (Facility.Ident[Facility.CntFacility] <> 0 AND NOT Facility.RecordIDIsLast[Facility.CntFacility]) OR (Facility.Ident[Facility.CntFacility] <> 0 AND Facility.RecordID[Facility.CntFacility] = 0) THEN EXIT; END_IF END_IF - UNTIL Facility.CntFacility > LOGBOOK_FACILITIES_TOTAL + UNTIL Facility.CntFacility > LOGBOOK_FACILITIES_MAX END_REPEAT; // -------------------------------------------------------------------------------------------------------------------- // No facility found, start at the beginning - IF Facility.CntFacility > LOGBOOK_FACILITIES_TOTAL THEN + IF Facility.CntFacility > LOGBOOK_FACILITIES_MAX THEN Facility.CntFacility := 0; // Find next facility from start to the end REPEAT @@ -424,13 +426,13 @@ PROGRAM _CYCLIC EXIT; END_IF Facility.CntFacility := Facility.CntFacility + 1; - UNTIL Facility.CntFacility > LOGBOOK_FACILITIES_TOTAL + UNTIL Facility.CntFacility > LOGBOOK_FACILITIES_MAX END_REPEAT; END_IF // -------------------------------------------------------------------------------------------------------------------- // Finish when no facility found or max entries is reached - IF Facility.CntFacility > LOGBOOK_FACILITIES_TOTAL OR (gLogbook.PAR.AbortOnEntriesLimit AND gLogbook.DAT.EntriesTotal = LOGBOOK_ENTRIES_TOTAL) THEN + IF Facility.CntFacility > LOGBOOK_FACILITIES_MAX OR (gLogbook.PAR.AbortOnEntriesLimit AND gLogbook.DAT.EntriesTotal = LOGBOOK_ENTRIES_MAX) THEN // Add last update DT_TO_DTStructure(gLogbook.PAR.DateNow, ADR(tmpDTstruct)); brsmemset(ADR(gLogbook.DAT.LastUpdate), 0, SIZEOF(gLogbook.DAT.LastUpdate)); diff --git a/Logical/mappLogbook/Logbook/Types.typ b/Logical/mappLogbook/Logbook/Types.typ index 4787f3d..fa41905 100644 --- a/Logical/mappLogbook/Logbook/Types.typ +++ b/Logical/mappLogbook/Logbook/Types.typ @@ -1,11 +1,11 @@ TYPE typFacility : STRUCT - Ident : ARRAY[0..LOGBOOK_FACILITIES_TOTAL]OF UDINT; - RecordIDLatest : ARRAY[0..LOGBOOK_FACILITIES_TOTAL]OF UDINT; - RecordIDOld : ARRAY[0..LOGBOOK_FACILITIES_TOTAL]OF UDINT; - RecordIDIsLast : ARRAY[0..LOGBOOK_FACILITIES_TOTAL]OF BOOL; - RecordID : ARRAY[0..LOGBOOK_FACILITIES_TOTAL]OF UDINT; + Ident : ARRAY[0..LOGBOOK_FACILITIES_MAX]OF UDINT; + RecordIDLatest : ARRAY[0..LOGBOOK_FACILITIES_MAX]OF UDINT; + RecordIDOld : ARRAY[0..LOGBOOK_FACILITIES_MAX]OF UDINT; + RecordIDIsLast : ARRAY[0..LOGBOOK_FACILITIES_MAX]OF BOOL; + RecordID : ARRAY[0..LOGBOOK_FACILITIES_MAX]OF UDINT; CntFacility : USINT; END_STRUCT; END_TYPE diff --git a/Logical/mappLogbook/Logbook/Variables.var b/Logical/mappLogbook/Logbook/Variables.var index b239d43..f446b9b 100644 --- a/Logical/mappLogbook/Logbook/Variables.var +++ b/Logical/mappLogbook/Logbook/Variables.var @@ -38,7 +38,7 @@ END_VAR (*---------------------------------------------------------------------------------------------------------------------------------*) (*Local constants*) VAR CONSTANT - FACILITY_NAMES : ARRAY[0..LOGBOOK_FACILITIES_TOTAL] OF STRING[50] := ['$$accsec','$$diag','$$arlogconn','$$fieldbus','$$firewall','$$mapp','$$motion','$$safety','$$arlogsys','$$textsys','$$unitsys','$$arlogusr','$$vision','$$visu']; - FACILITY_TEXT : ARRAY[0..LOGBOOK_FACILITIES_TOTAL] OF STRING[50] := ['Access','Commissioning','Connectivity','Fieldbus','Firewall','Mapp','Motion','Safety','System','Text System','Unit System','User','Vision','Visualization']; + FACILITY_NAMES : ARRAY[0..LOGBOOK_FACILITIES_MAX] OF STRING[50] := ['$$accsec','$$diag','$$arlogconn','$$fieldbus','$$firewall','$$mapp','$$motion','$$safety','$$arlogsys','$$textsys','$$unitsys','$$arlogusr','$$vision','$$visu']; + FACILITY_TEXT : ARRAY[0..LOGBOOK_FACILITIES_MAX] OF STRING[50] := ['Access','Commissioning','Connectivity','Fieldbus','Firewall','Mapp','Motion','Safety','System','Text System','Unit System','User','Vision','Visualization']; NO_SPACE : UINT := 0; END_VAR diff --git a/Logical/mappLogbook/changelog.txt b/Logical/mappLogbook/changelog.txt index 0106444..0685792 100644 --- a/Logical/mappLogbook/changelog.txt +++ b/Logical/mappLogbook/changelog.txt @@ -1,3 +1,7 @@ +Next version +- New update table command +- Add max entries to parameter structure + Version 0.2 - Fixed special characters not showing up correct - Fixed filter checkboxes dont remember state diff --git a/Logical/mappView/Visualization/Pages/LogbookPage/Content.content b/Logical/mappView/Visualization/Pages/LogbookPage/Content.content index 2248eb7..6b2296d 100644 --- a/Logical/mappView/Visualization/Pages/LogbookPage/Content.content +++ b/Logical/mappView/Visualization/Pages/LogbookPage/Content.content @@ -11,9 +11,9 @@ - - - + + + @@ -118,5 +118,7 @@ + + \ No newline at end of file diff --git a/Physical/PC/X20CP1583/Connectivity/OpcUA/OpcUaMap.uad b/Physical/PC/X20CP1583/Connectivity/OpcUA/OpcUaMap.uad index a03396c..7e1025b 100644 --- a/Physical/PC/X20CP1583/Connectivity/OpcUA/OpcUaMap.uad +++ b/Physical/PC/X20CP1583/Connectivity/OpcUA/OpcUaMap.uad @@ -38,7 +38,6 @@ - diff --git a/Physical/PC/X20CP1583/mappView/Logbook.binding b/Physical/PC/X20CP1583/mappView/Logbook.binding index d127e8c..c75c00e 100644 --- a/Physical/PC/X20CP1583/mappView/Logbook.binding +++ b/Physical/PC/X20CP1583/mappView/Logbook.binding @@ -45,10 +45,7 @@ - - - - + @@ -213,5 +210,17 @@ - + + + + + + + + + + + + + diff --git a/Physical/PC/X20CP1583/mappView/Logbook.eventbinding b/Physical/PC/X20CP1583/mappView/Logbook.eventbinding index 0eec3da..9cb7f8f 100644 --- a/Physical/PC/X20CP1583/mappView/Logbook.eventbinding +++ b/Physical/PC/X20CP1583/mappView/Logbook.eventbinding @@ -46,7 +46,7 @@ - +