Skip to content

Commit

Permalink
Update example AS project
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewMusser committed Nov 22, 2023
1 parent 8ad7697 commit 25c4325
Show file tree
Hide file tree
Showing 115 changed files with 631 additions and 37 deletions.
2 changes: 1 addition & 1 deletion example/AsProject/AsProject.apj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<?AutomationStudio Version="4.12.2.93" WorkingVersion="4.12"?>
<?AutomationStudio Version="4.12.4.107 SP" WorkingVersion="4.12"?>
<Project Version="1.00.0" Edition="Standard" EditionComment="Standard" xmlns="http://br-automation.co.at/AS/Project">
<Communication />
<ANSIC DefaultIncludes="true" />
Expand Down
13 changes: 13 additions & 0 deletions example/AsProject/Logical/Diagnostics/Diagnostics.var
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(*
* File: Diagnostics.var
* Copyright (c) 2023 Loupe
* https://loupe.team
*
* This file is part of ErrorProg, licensed under the MIT License.
*)

VAR
gErrorCollector : ErrorCollector_typ := (0);
gErrorCollectorHMI : ErrorCollector_HMI_typ := (0);
END_VAR

11 changes: 11 additions & 0 deletions example/AsProject/Logical/Diagnostics/ErrorProg/ErrorProg.typ
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(*
* File: ErrorProg.typ
* Copyright (c) 2023 Loupe
* https://loupe.team
*
* This file is part of ErrorProg, licensed under the MIT License.
*)

TYPE

END_TYPE
8 changes: 8 additions & 0 deletions example/AsProject/Logical/Diagnostics/ErrorProg/ErrorProg.var
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(*
* File: ErrorProg.var
* Copyright (c) 2023 Loupe
* https://loupe.team
*
* This file is part of ErrorProg, licensed under the MIT License.
*)

16 changes: 16 additions & 0 deletions example/AsProject/Logical/Diagnostics/ErrorProg/ErrorProgCyclic.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(*
* File: ErrorProgCyclic.st
* Copyright (c) 2023 Loupe
* https://loupe.team
*
* This file is part of ErrorProg, licensed under the MIT License.
*)


PROGRAM _CYCLIC

ErrorCollectorFn_HMI_Cyclic( gErrorCollectorHMI, gErrorCollector );

ErrorCollectorFn_Cyclic( gErrorCollector );

END_PROGRAM
17 changes: 17 additions & 0 deletions example/AsProject/Logical/Diagnostics/ErrorProg/ErrorProgInit.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(*
* File: ErrorProgInit.st
* Copyright (c) 2023 Loupe
* https://loupe.team
*
* This file is part of ErrorProg, licensed under the MIT License.
*)

PROGRAM _INIT

(* gErrorCollector is initialized in FirstInitProg - Init only if it hasn't already been *)
IF NOT gErrorCollector.Internal.Initialized THEN
ErrorCollectorFn_Init(gErrorCollector);
END_IF
(* Sources are added to gErrorCollector in the source program. *)
END_PROGRAM
10 changes: 10 additions & 0 deletions example/AsProject/Logical/Diagnostics/ErrorProg/IEC.prg
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<?AutomationStudio FileVersion="4.9"?>
<Program SubType="IEC" xmlns="http://br-automation.co.at/AS/Program">
<Files>
<File Description="Initialization code">ErrorProgInit.st</File>
<File Description="Cyclic code">ErrorProgCyclic.st</File>
<File Description="Local data types" Private="true">ErrorProg.typ</File>
<File Description="Local variables" Private="true">ErrorProg.var</File>
</Files>
</Program>
7 changes: 7 additions & 0 deletions example/AsProject/Logical/Diagnostics/Package.pkg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<Package xmlns="http://br-automation.co.at/AS/Package">
<Objects>
<Object Type="File">Diagnostics.var</Object>
<Object Type="Program" Language="IEC">ErrorProg</Object>
</Objects>
</Package>
1 change: 1 addition & 0 deletions example/AsProject/Logical/Infrastructure/Package.pkg
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<Object Type="Program" Language="ANSIC">FirstInitProg</Object>
<Object Type="File">Infrastructure.typ</Object>
<Object Type="File">Infrastructure.var</Object>
<Object Type="Package">RevInfo</Object>
</Objects>
</Package>
8 changes: 8 additions & 0 deletions example/AsProject/Logical/Infrastructure/RevInfo/Package.pkg
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version='1.0' encoding='utf-8'?>
<Package xmlns="http://br-automation.co.at/AS/Package">
<Objects>
<Object Type="File">getRevInfo.sh</Object>
<Object Type="Program" Language="IEC">RevInfo</Object>
<Object Type="File">RevInfo.var</Object>
</Objects>
</Package>
18 changes: 18 additions & 0 deletions example/AsProject/Logical/Infrastructure/RevInfo/RevInfo.var
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
(*
* File: RevInfo.var
* Copyright (c) 2023 Loupe
* https://loupe.team
*
* This file is part of RevInfo, licensed under the MIT License.
*)

VAR
revision : STRING[80] := '';
revisionDate : STRING[80] := '';
revisionAuthor : STRING[80] := '';
branchName : STRING[80] := '';
uncommittedChanges : STRING[80] := '';
buildDate : STRING[80] := '';
buildConfiguration : STRING[80] := '';
builder : STRING[80] := '';
END_VAR
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<?AutomationStudio Version=4.5.5.113 SP?>
<Program SubType="IEC" xmlns="http://br-automation.co.at/AS/Program">
<Files>
<File Description="Implementation code">Main.st</File>
<File Private="true">Variables.var</File>
</Files>
</Program>
71 changes: 71 additions & 0 deletions example/AsProject/Logical/Infrastructure/RevInfo/RevInfo/Main.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
(*
* File: Main.st
* Copyright (c) 2023 Loupe
* https://loupe.team
*
* This file is part of RevInfo, licensed under the MIT License.
*)
PROGRAM _INIT

// Log revision information
//---------------------------------------------------------------

logInfo('App', 0, '************ RevInfo Start ************', 0);

// revision
brsmemset(ADR(tempString), 0, SIZEOF(tempString));
tempString := 'Revision: ';
brsstrcat(ADR(tempString), ADR(revision));
logInfo('App', 0, tempString, 0);

// revisionDate
brsmemset(ADR(tempString), 0, SIZEOF(tempString));
tempString := 'Commit Date: ';
brsstrcat(ADR(tempString), ADR(revisionDate));
logInfo('App', 0, tempString, 0);

// revisionAuthor
brsmemset(ADR(tempString), 0, SIZEOF(tempString));
tempString := 'Author: ';
brsstrcat(ADR(tempString), ADR(revisionAuthor));
logInfo('App', 0, tempString, 0);

// branchName
brsmemset(ADR(tempString), 0, SIZEOF(tempString));
tempString := 'Branch Name: ';
brsstrcat(ADR(tempString), ADR(branchName));
logInfo('App', 0, tempString, 0);

// uncommittedChanges
brsmemset(ADR(tempString), 0, SIZEOF(tempString));
tempString := 'Uncommitted Changes: ';
brsstrcat(ADR(tempString), ADR(uncommittedChanges));
logInfo('App', 0, tempString, 0);

// buildDate
brsmemset(ADR(tempString), 0, SIZEOF(tempString));
tempString := 'Build Date: ';
brsstrcat(ADR(tempString), ADR(buildDate));
logInfo('App', 0, tempString, 0);

// buildConfiguration
brsmemset(ADR(tempString), 0, SIZEOF(tempString));
tempString := 'Configuration: ';
brsstrcat(ADR(tempString), ADR(buildConfiguration));
logInfo('App', 0, tempString, 0);

// builder
brsmemset(ADR(tempString), 0, SIZEOF(tempString));
tempString := 'Builder: ';
brsstrcat(ADR(tempString), ADR(builder));
logInfo('App', 0, tempString, 0);

logInfo('App', 0, '************ RevInfo End ************', 0);

END_PROGRAM


PROGRAM _CYCLIC


END_PROGRAM
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
(*
* File: Variables.var
* Copyright (c) 2023 Loupe
* https://loupe.team
*
* This file is part of RevInfo, licensed under the MIT License.
*)
VAR
tempString : STRING[160];
END_VAR
142 changes: 142 additions & 0 deletions example/AsProject/Logical/Infrastructure/RevInfo/getRevInfo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
# File: getRevInfo.sh
# Copyright (c) 2023 Loupe
# https://loupe.team
#
# This file is part of RevInfo, licensed under the MIT License.
#
#!/bin/sh
# The following line should be put into the pre-build step of any configuration that should run this script
# "$(AS_PROJECT_PATH)\Logical\Documentation\getRevInfo.sh"
# This script will update the revision and build information

cd -- "$( dirname -- "${BASH_SOURCE[0]}" )"

cat > RevInfo.var << EOF
(* RevInfo.var 2.2.0 *)
VAR CONSTANT
revision : STRING[80] := '$(git describe --always --tags)';
revisionDate : STRING[80] := '$(git show -s --date=default --pretty=format:%ci)';
revisionAuthor : STRING[80] := '$(git show -s --pretty=format:%an)';
branchName : STRING[80] := '$(git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')';
uncommittedChanges : STRING[80] := '$(git diff --shortstat)';
buildDate : STRING[80] := '$(date +"%Y-%m-%d %H:%M:%S %z")';
buildConfiguration : STRING[80] := '${AS_CONFIGURATION}';
builder : STRING[80] := '${AS_USER_NAME}';
END_VAR
EOF

# Example implementation of RevInfo program:
#
# RevInfo/Variables.var:
#
# VAR RETAIN
# download : BOOL;
# END_VAR
# VAR
# dataOK : BOOL;
# reboot : BOOL;
# i : UINT := 0;
# tempString : STRING[160];
# END_VAR
#
# RevInfo/Main.st:
#
# PROGRAM _INIT
#
# // Log revision information
# //---------------------------------------------------------------
#
# logInfo('App', 0, '************ RevInfo Start ************', 0);
#
# // revision
# brsmemset(ADR(tempString), 0, SIZEOF(tempString));
# tempString := 'Revision: ';
# brsstrcat(ADR(tempString), ADR(revision));
# logInfo('App', 0, tempString, 0);
#
# // revisionDate
# brsmemset(ADR(tempString), 0, SIZEOF(tempString));
# tempString := 'Commit Date: ';
# brsstrcat(ADR(tempString), ADR(revisionDate));
# logInfo('App', 0, tempString, 0);
#
# // revisionAuthor
# brsmemset(ADR(tempString), 0, SIZEOF(tempString));
# tempString := 'Author: ';
# brsstrcat(ADR(tempString), ADR(revisionAuthor));
# logInfo('App', 0, tempString, 0);
#
# // branchName
# brsmemset(ADR(tempString), 0, SIZEOF(tempString));
# tempString := 'Branch Name: ';
# brsstrcat(ADR(tempString), ADR(branchName));
# logInfo('App', 0, tempString, 0);
#
# // uncommittedChanges
# brsmemset(ADR(tempString), 0, SIZEOF(tempString));
# tempString := 'Uncommitted Changes: ';
# brsstrcat(ADR(tempString), ADR(uncommittedChanges));
# logInfo('App', 0, tempString, 0);
#
# // buildDate
# brsmemset(ADR(tempString), 0, SIZEOF(tempString));
# tempString := 'Build Date: ';
# brsstrcat(ADR(tempString), ADR(buildDate));
# logInfo('App', 0, tempString, 0);
#
# // buildConfiguration
# brsmemset(ADR(tempString), 0, SIZEOF(tempString));
# tempString := 'Configuration: ';
# brsstrcat(ADR(tempString), ADR(buildConfiguration));
# logInfo('App', 0, tempString, 0);
#
# // builder
# brsmemset(ADR(tempString), 0, SIZEOF(tempString));
# tempString := 'Builder: ';
# brsstrcat(ADR(tempString), ADR(builder));
# logInfo('App', 0, tempString, 0);
#
# logInfo('App', 0, '************ RevInfo End ************', 0);
#
# END_PROGRAM
#
#
# PROGRAM _CYCLIC
#
# // Detect an AS transfer
# IF NOT download THEN
# download := TRUE;
# brsmemset(ADR(gDataValid), 0, SIZEOF(gDataValid));
# MessageBox_AddMsg(ADR('Download may have caused data loss. Please reboot to reload. If this was the first boot after a download, you may reset DataValid to maintain data.'), ADR('Reboot'), ADR(reboot), ADR('RESET DataValid'), ADR(dataOK));
# END_IF
#
# IF dataOK THEN
# dataOK := FALSE;
# FOR i := 0 TO SIZEOF(gDataValid)/SIZEOF(gDataValid[0]) - 1 BY 1 DO
# gDataValid[i] := 1;
# END_FOR
# END_IF
#
# IF reboot THEN
# SYSreset(1,1);
# END_IF
#
# END_PROGRAM


# Failed attempts to get the directory where the .sh file is stored
#
# echo "Script executed from: ${PWD}"
# BASEDIR=$(dirname $0)
# echo "Script location: ${BASEDIR}"
# DIR="$( cd "$( dirname "$0" )" && pwd )"
# echo "DIR = $DIR"
# DIR2="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# echo "DIR2 = $DIR2"
# DIR3=${0%\*}
# echo "DIR3 = $DIR3"
# echo "\$0 = $0"
# current_dir=$(pwd)
# script_dir=$(dirname $0)
# echo $current_dir
# echo $script_dir
Loading

0 comments on commit 25c4325

Please sign in to comment.