Skip to content

Commit

Permalink
Add max entries to parameter structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan committed Oct 30, 2020
1 parent 6da4a1d commit 2f27120
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 41 deletions.
27 changes: 14 additions & 13 deletions Logical/mappLogbook/LogTypes.typ
Original file line number Diff line number Diff line change
Expand Up @@ -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*)
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Logical/mappLogbook/LogVariables.var
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions Logical/mappLogbook/Logbook/LocalFunctions.st
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
16 changes: 9 additions & 7 deletions Logical/mappLogbook/Logbook/Main.st
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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}]}'));

Expand All @@ -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;
Expand Down Expand Up @@ -406,31 +408,31 @@ 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
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
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));
Expand Down
10 changes: 5 additions & 5 deletions Logical/mappLogbook/Logbook/Types.typ
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions Logical/mappLogbook/Logbook/Variables.var
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions Logical/mappLogbook/changelog.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
</Widgets>
</Widget>
<Widget xsi:type="widgets.brease.ToggleButton" id="btnRefresh" top="720" left="20" width="160" height="70" zIndex="0" mouseDownText="Abort" text="Refresh" cornerRadius="5px" fontSize="26px" />
<Widget xsi:type="widgets.brease.Button" id="btnResetError" top="720" left="655" width="160" height="70" zIndex="1" text="Reset Error" cornerRadius="5px" />
<Widget xsi:type="widgets.brease.NumericOutput" id="numStatus" top="770" left="700" width="115" height="20" zIndex="2" format="{'metric':{'decimalPlaces':0,'minimumIntegerDigits':1,'maximumIntegerDigits':10},'imperial':{'decimalPlaces':0,'minimumIntegerDigits':1,'maximumIntegerDigits':10},'imperial-us':{'decimalPlaces':0,'minimumIntegerDigits':1,'maximumIntegerDigits':10}}" borderWidth="1px" borderStyle="none" textAlign="left" padding="0px 0px 0px 0px" />
<Widget xsi:type="widgets.brease.Label" id="Label1" top="770" left="655" width="60" height="20" zIndex="3" text="Status" />
<Widget xsi:type="widgets.brease.Button" id="btnResetError" top="720" left="370" width="160" height="70" zIndex="1" text="Reset Error" cornerRadius="5px" fontSize="20px" />
<Widget xsi:type="widgets.brease.NumericOutput" id="numStatus" top="770" left="415" width="115" height="20" zIndex="2" format="{'metric':{'decimalPlaces':0,'minimumIntegerDigits':1,'maximumIntegerDigits':10},'imperial':{'decimalPlaces':0,'minimumIntegerDigits':1,'maximumIntegerDigits':10},'imperial-us':{'decimalPlaces':0,'minimumIntegerDigits':1,'maximumIntegerDigits':10}}" borderWidth="1px" borderStyle="none" textAlign="left" padding="0px 0px 0px 0px" />
<Widget xsi:type="widgets.brease.Label" id="Label1" top="770" left="370" width="60" height="20" zIndex="3" text="Status" />
<Widget xsi:type="widgets.brease.Label" id="Label4" top="20" left="9" width="81" height="20" zIndex="310" text="Error No" textAlign="right" bold="true" />
<Widget xsi:type="widgets.brease.NumericInput" id="numFilterErrorNo" top="15" left="95" width="131" zIndex="311" format="{'metric':{'decimalPlaces':0,'minimumIntegerDigits':1},'imperial':{'decimalPlaces':1,'minimumIntegerDigits':1},'imperial-us':{'decimalPlaces':1,'minimumIntegerDigits':1}}" maxValue="10000000000" useDigitGrouping="false" padding="0px 5px 0px 5px" />
<Widget xsi:type="widgets.brease.GroupBox" id="grpFacilities" top="40" left="630" width="565" height="140" zIndex="101">
Expand Down Expand Up @@ -118,5 +118,7 @@
<Widget xsi:type="widgets.brease.CheckBox" id="chkFilterSeverity" top="10" left="410" width="95" zIndex="313" boxSize="20" text="Severity" value="true" fontSize="14px" bold="true" />
<Widget xsi:type="widgets.brease.CheckBox" id="chkStopMaxEntries" top="725" left="840" width="320" height="25" zIndex="330" boxSize="20" text="Stop searching when max entries is reached" fontSize="14px" />
<Widget xsi:type="widgets.brease.Button" id="btnUpdate" top="720" left="195" width="160" height="70" zIndex="331" text="Update" cornerRadius="5px" fontSize="26px" />
<Widget xsi:type="widgets.brease.CheckBox" id="chkAutoUpdate" top="760" left="840" width="120" height="25" zIndex="332" boxSize="20" text="Auto Update" fontSize="14px" />
<Widget xsi:type="widgets.brease.NumericInput" id="numAutoUpdate" top="755" left="960" width="80" zIndex="333" format="{'metric':{'decimalPlaces':0,'minimumIntegerDigits':1},'imperial':{'decimalPlaces':1,'minimumIntegerDigits':1},'imperial-us':{'decimalPlaces':1,'minimumIntegerDigits':1}}" maxValue="10000000000" unit="{'metric':'SEC','imperial':'SEC','imperial-us':'SEC'}" unitAlign="right" useDigitGrouping="false" padding="0px 5px 0px 5px" />
</Widgets>
</Content>
1 change: 0 additions & 1 deletion Physical/PC/X20CP1583/Connectivity/OpcUA/OpcUaMap.uad
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
<Variable Name="FilterFacility" EnableArrayElements="True" />
</Variable>
</Variable>
<Variable Name="LOGBOOK_ENTRIES_TOTAL" />
<Variable Name="LOGBOOK_EXECUTIONS" />
<Variable Name="LOGBOOK_TEXT_LEN" />
</GlobalVariables>
Expand Down
19 changes: 14 additions & 5 deletions Physical/PC/X20CP1583/mappView/Logbook.binding
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@
<Source xsi:type="opcUa" refId="::AsGlobalPV:gLogbook.DAT.CntSeverity[3]" attribute="value" />
<Target xsi:type="brease" contentRefId="contentLogbook" widgetRefId="numCntError" attribute="value" />
</Binding>
<Binding mode="oneWay">
<Source xsi:type="opcUa" refId="::AsGlobalPV:LOGBOOK_ENTRIES_TOTAL" attribute="value" />
<Target xsi:type="brease" contentRefId="contentLogbook" widgetRefId="numEntriesTotalMax" attribute="value" />
</Binding>

<Binding mode="twoWay">
<Source xsi:type="opcUa" refId="::AsGlobalPV:gLogbook.PAR.FilterDateStart" attribute="value" />
<Target xsi:type="brease" contentRefId="contentLogbook" widgetRefId="dtDateStart" attribute="value" />
Expand Down Expand Up @@ -213,5 +210,17 @@
<Source xsi:type="opcUa" refId="::AsGlobalPV:gLogbook.PAR.FilterSeverity[0]" attribute="value" />
<Target xsi:type="brease" contentRefId="contentLogbook" widgetRefId="chkFilterNotification" attribute="value" />
</Binding>
</Bindings>
<Binding mode="oneWay">
<Source xsi:type="opcUa" refId="::AsGlobalPV:gLogbook.PAR.EntriesMax" attribute="value" />
<Target xsi:type="brease" contentRefId="contentLogbook" widgetRefId="numEntriesTotalMax" attribute="value" />
</Binding>
<Binding mode="twoWay">
<Source xsi:type="opcUa" refId="::AsGlobalPV:gLogbook.PAR.AutoUpdate" attribute="value" />
<Target xsi:type="brease" contentRefId="contentLogbook" widgetRefId="chkAutoUpdate" attribute="value" />
</Binding>
<Binding mode="twoWay">
<Source xsi:type="opcUa" refId="::AsGlobalPV:gLogbook.PAR.AutoUpdateInterval" attribute="value" />
<Target xsi:type="brease" contentRefId="contentLogbook" widgetRefId="numAutoUpdate" attribute="value" />
</Binding>
</Bindings>
</BindingsSet>
2 changes: 1 addition & 1 deletion Physical/PC/X20CP1583/mappView/Logbook.eventbinding
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<EventBinding id="EventBinding_1">
<Source xsi:type="opcUa.Event" refId="::AsGlobalPV:gLogbook.DAT.EntriesTotal" event="ValueChanged" />
<Operand datatype="ANY_INT" name="MAX_ENTRIES">
<ReadTarget xsi:type="opcUa.NodeAction.Read" refId="::AsGlobalPV:LOGBOOK_ENTRIES_TOTAL" serverAlias="">
<ReadTarget xsi:type="opcUa.NodeAction.Read" refId="::AsGlobalPV:gLogbook.PAR.EntriesMax" serverAlias="">
<Method xsi:type="opcUa.NodeAction.GetValue" />
</ReadTarget>
</Operand>
Expand Down

0 comments on commit 2f27120

Please sign in to comment.