Skip to content

Commit 92fb147

Browse files
committed
restructure all files
1 parent 3461638 commit 92fb147

File tree

11 files changed

+125
-2272
lines changed

11 files changed

+125
-2272
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
**/*.jar
2+
test.html

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"java.project.referencedLibraries": [
3+
"lib\\**\\*.jar"
4+
]
5+
}

DEPENDENCIES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
file:tomcat-embed-core:webserver\lib
2+
url:CommissioningScripts-0.1.1.jar:https://github.com/automatic-controls/commissioning-scripts/releases/download/v0.1.1-beta/CommissioningScripts-0.1.1.jar
3+
url:CommissioningScripts-0.1.1-sources.jar:https://github.com/automatic-controls/commissioning-scripts/releases/download/v0.1.1-beta/CommissioningScripts-0.1.1-sources.jar

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,12 @@ The remaining three error messages are thrown during the data analysis phase. Wh
9898

9999
### Sample Output
100100

101-
![](./report1.png)
102-
![](./report2.png)
101+
![](./resources/report1.png)
102+
![](./resources/report2.png)
103103

104104
## Mappings
105105

106-
Control programs with dampers should be grouped by air source. By limiting the percentage of active tests per group, we can avoid tripping the high static safety alarm on the RTU air source (for a worst case scenario, imagine all VAV dampers locked to 0% while the RTU supply fan is still pumping air into the system). If there are hot water valves, you should also consider grouping by water source. See the following table for a list of mapping tags for this script. Also see [./tags.json](./tags.json) for the tag mappings I used while testing this script.
106+
Control programs with dampers should be grouped by air source. By limiting the percentage of active tests per group, we can avoid tripping the high static safety alarm on the RTU air source (for a worst case scenario, imagine all VAV dampers locked to 0% while the RTU supply fan is still pumping air into the system). If there are hot water valves, you should also consider grouping by water source. See the following table for a list of mapping tags for this script. Also see [./resources/tags.json](./resources/tags.json) for the tag mappings I used while testing this script.
107107

108108
| Semantic Tag | Sample Expression | Description |
109109
| - | - | - |

TerminalUnitTest.jar

-24.3 KB
Binary file not shown.

build.bat

Lines changed: 85 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,106 @@
11
@echo off
2+
setlocal EnableDelayedExpansion
23
echo.
3-
set "jdk=C:\Program Files\Java\jdk-17.0.2\bin"
4-
set "classes=%~dp0classes"
4+
5+
:: Modify these parameters when necessary
6+
set "WebCTRL=C:\WebCTRL8.0"
57
set "mainClass=TerminalUnitTest"
8+
set "package="
9+
set "jdk=%JAVA_HOME%\bin"
10+
set "release=8"
11+
12+
if not exist "%~dp0lib" mkdir "%~dp0lib" >nul 2>nul
13+
call :collect "%~dp0DEPENDENCIES" "%~dp0lib"
14+
if %ERRORLEVEL% NEQ 0 (
15+
echo Failed to collect necessary dependencies.
16+
echo Press any key to exit.
17+
pause >nul
18+
exit
19+
)
20+
set "classes=%~dp0classes"
621
if exist "%classes%" rmdir /S /Q "%classes%" >nul
722
if exist "%~dp0%mainClass%.jar" del /F "%~dp0%mainClass%.jar" >nul
823
mkdir "%classes%" >nul
9-
"%jdk%\javac.exe" --release 8 -d "%classes%" --class-path "%~dp0src;C:\Users\cvogt\Desktop\Repositories\commissioning-scripts\CommissioningScripts.jar;C:\Users\cvogt\Desktop\Repositories\addon-dev-script\lib\*;C:\Users\cvogt\Desktop\Repositories\commissioning-scripts\lib\*" "%~dp0src\%mainClass%.java"
24+
echo Compiling...
25+
"%jdk%\javac.exe" --release %release% -d "%classes%" --class-path "%~dp0src;%~dp0lib\*" "%~dp0src\%package%%mainClass%.java"
1026
if %ERRORLEVEL% NEQ 0 (
1127
rmdir /S /Q "%classes%" >nul
1228
echo.
29+
echo Compilation failed.
1330
echo Press any key to exit.
1431
pause >nul
1532
exit
1633
)
17-
"%jdk%\jar.exe" --create --verbose --file "%~dp0%mainClass%.jar" --main-class "%mainClass%" -C "%classes%" . >nul
34+
echo Packing...
35+
robocopy /E "%~dp0src" "%classes%" /XF "*.java" >nul 2>nul
36+
if exist "%~dp0%mainClass%.jar" del /F "%~dp0%mainClass%.jar" >nul 2>nul
37+
"%jdk%\jar.exe" --create --verbose --file "%~dp0%mainClass%.jar" --main-class "%package%%mainClass%" -C "%classes%" . >nul
1838
if %ERRORLEVEL% NEQ 0 (
1939
rmdir /S /Q "%classes%" >nul
2040
echo.
41+
echo Jar creation failed.
2142
echo Press any key to exit.
2243
pause >nul
2344
exit
2445
)
2546
rmdir /S /Q "%classes%" >nul
26-
exit
47+
echo Build successful.
48+
echo Press any key to exit.
49+
pause >nul
50+
exit
51+
52+
53+
:: Collect dependencies from the WebCTRL installation or from external websites
54+
:: Parameters: <dependency-file> <output-folder>
55+
:collect
56+
setlocal
57+
set "tmp1=%~dp0tmp1"
58+
set "tmp2=%~dp0tmp2"
59+
set "err=0"
60+
set "msg=0"
61+
dir "%~f2\*.jar" /B /A-D 2>nul >"%tmp1%"
62+
for /F "usebackq tokens=1,2,* delims=:" %%i in ("%~f1") do (
63+
set "findString=%%j"
64+
if "!findString:~-4!" NEQ ".jar" set "findString=%%j-[0-9].*"
65+
set "exists=0"
66+
for /F %%a in ('findstr /R /X "!findString!" "%tmp1%"') do (
67+
set "exists=1"
68+
)
69+
if "!exists!" EQU "0" (
70+
set "msg=1"
71+
if /I "%%i" EQU "url" (
72+
curl --location --fail --silent --output-dir "%~f2" --remote-name %%k
73+
if !ErrorLevel! EQU 0 (
74+
echo Collected: %%j
75+
) else (
76+
set "err=1"
77+
echo Failed to collect: %%j
78+
)
79+
) else if /I "%%i" EQU "file" (
80+
set "file="
81+
dir "%WebCTRL%\%%k\*.jar" /B /A-D 2>nul >"%tmp2%"
82+
for /F %%a in ('findstr /R /X "!findString!" "%tmp2%"') do (
83+
set "file=%%a"
84+
)
85+
if "!file!" EQU "" (
86+
set "err=1"
87+
echo Failed to collect: %%j
88+
) else (
89+
copy /Y "%WebCTRL%\%%k\!file!" "%~f2\!file!" >nul
90+
if !ErrorLevel!==0 (
91+
echo Collected: %%j
92+
) else (
93+
set "err=1"
94+
echo Failed to collect: %%j
95+
)
96+
)
97+
) else (
98+
set "err=1"
99+
echo Failed to collect: %%j
100+
)
101+
)
102+
)
103+
if "%msg%" EQU "1" echo.
104+
if exist "%tmp1%" del /F "%tmp1%" >nul 2>nul
105+
if exist "%tmp2%" del /F "%tmp2%" >nul 2>nul
106+
endlocal & exit /b %err%
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/TerminalUnitTest.java

Lines changed: 27 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public class TerminalUnitTest extends Script {
2424
@Override public void init(){
2525
data = new Data[this.testsTotal];
2626
Arrays.fill(data,null);
27-
testDampers = (Boolean)this.params.getOrDefault("Dampers",false);
28-
testFans = (Boolean)this.params.getOrDefault("Fans",false);
29-
testHeating = (Boolean)this.params.getOrDefault("Heating",false);
27+
testDampers = this.params.getOrDefault("Dampers",false);
28+
testFans = this.params.getOrDefault("Fans",false);
29+
testHeating = this.params.getOrDefault("Heating",false);
3030
initialized = true;
3131
}
3232
@Override public void exec(ResolvedTestingUnit x) throws Throwable {
@@ -615,7 +615,7 @@ private void printData(final StringBuilder sb, final boolean JSON){
615615
}else{
616616
sb.append("\n]\n},\n");
617617
}
618-
sb.append(Utility.format("{\n\"name\":\"$0\",\n\"equipment\":[\n", escape(JSON,(String)this.mapping.groupNames.getOrDefault(group,"(Deleted Group)"))));
618+
sb.append(Utility.format("{\n\"name\":\"$0\",\n\"equipment\":[\n", escape(JSON,this.mapping.groupNames.getOrDefault(group,"(Deleted Group)"))));
619619
}
620620
d.print(sb,JSON);
621621
}
@@ -625,7 +625,8 @@ private void printData(final StringBuilder sb, final boolean JSON){
625625
private static String escape(boolean JSON, String s){
626626
return JSON?Utility.escapeJSON(s):Utility.escapeJS(s);
627627
}
628-
class Data implements Comparable<Object> {
628+
public final static int[] airflowX = new int[]{0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100};
629+
class Data implements Comparable<Data> {
629630
private final static String tagAirflow = "airflow";
630631
private final static String tagAirflowMaxHeat = "airflow_max_heat";
631632
private final static String tagAirflowMaxCool = "airflow_max_cool";
@@ -665,7 +666,6 @@ class Data implements Comparable<Object> {
665666
public volatile boolean fanStartTest = false;
666667
public volatile boolean damperError = false;
667668
public volatile boolean damperResponse = true;
668-
public final int[] airflowX = new int[]{0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100};
669669
public volatile Stats[] airflowY;
670670
private final static int airflowSamples = 5;
671671
public volatile double airflowMaxCoolValue = 0;
@@ -723,8 +723,8 @@ public Data(ResolvedTestingUnit x) throws Throwable {
723723
Thread.sleep(30000);
724724
}
725725
if (hasPump){
726-
waitFor(180000, 3000, tagPumpStatus, new Predicate<Object>(){
727-
public boolean test(Object s){
726+
waitFor(180000, 3000, tagPumpStatus, new Predicate<String>(){
727+
public boolean test(String s){
728728
return s.equals("0");
729729
}
730730
});
@@ -735,8 +735,8 @@ public boolean test(Object s){
735735
if (!x.setValueAutoMark(tagSFSSLockValue, 0) || !x.setValueAutoMark(tagSFSSLockFlag, true)){
736736
fanError = true; break fanTest;
737737
}
738-
b = waitFor(180000, 3000, tagSFST, new Predicate<Object>(){
739-
public boolean test(Object s){
738+
b = waitFor(180000, 3000, tagSFST, new Predicate<String>(){
739+
public boolean test(String s){
740740
return s.equals("0");
741741
}
742742
});
@@ -747,8 +747,8 @@ public boolean test(Object s){
747747
if (!x.setValueAutoMark(tagSFSSLockValue, 1)){
748748
fanError = true; break fanTest;
749749
}
750-
b = waitFor(180000, 3000, tagSFST, new Predicate<Object>(){
751-
public boolean test(Object s){
750+
b = waitFor(180000, 3000, tagSFST, new Predicate<String>(){
751+
public boolean test(String s){
752752
return s.equals("1");
753753
}
754754
});
@@ -759,8 +759,8 @@ public boolean test(Object s){
759759
} else if (hasFan && (hasDamper && testDampers || hasHeatAO && testHeating || hasPump && testHeating)){
760760
// If we're going to test dampers or heating/cooling elements, then we lock the fan on
761761
if (x.setValueAutoMark(tagSFSSLockValue, 1) && x.setValueAutoMark(tagSFSSLockFlag, true)){
762-
b = waitFor(180000, 3000, tagSFST, new Predicate<Object>(){
763-
public boolean test(Object s){
762+
b = waitFor(180000, 3000, tagSFST, new Predicate<String>(){
763+
public boolean test(String s){
764764
return s.equals("1");
765765
}
766766
});
@@ -788,9 +788,9 @@ public boolean test(Object s){
788788
damperError = true; break damperTest;
789789
}
790790
}
791-
b = waitFor(240000, 3000, tagDamperPosition, new Predicate<Object>(){
792-
public boolean test(Object s){
793-
return Math.abs(Double.parseDouble(s.toString())-pos)<1;
791+
b = waitFor(240000, 3000, tagDamperPosition, new Predicate<String>(){
792+
public boolean test(String s){
793+
return Math.abs(Double.parseDouble(s)-pos)<1;
794794
}
795795
});
796796
if (b==null){
@@ -834,9 +834,9 @@ public boolean test(Object s){
834834
if (!x.setValueAutoMark(tagAirflowLockValue, airflowMaxHeatValue) || !x.setValueAutoMark(tagDamperLockFlag, false) || !x.setValueAutoMark(tagAirflowLockFlag, true)){
835835
heatingError = true; break heatTest;
836836
}
837-
waitFor(240000, 3000, tagAirflow, new Predicate<Object>(){
838-
public boolean test(Object s){
839-
return Math.abs(Double.parseDouble(s.toString())-airflowMaxHeatValue)<50;
837+
waitFor(240000, 3000, tagAirflow, new Predicate<String>(){
838+
public boolean test(String s){
839+
return Math.abs(Double.parseDouble(s)-airflowMaxHeatValue)<50;
840840
}
841841
});
842842
final long dif = lim-System.currentTimeMillis();
@@ -915,8 +915,8 @@ public boolean test(Object s){
915915
if (!x.setValueAutoMark(tagPumpRevLockValue,0) || !x.setValueAutoMark(tagPumpRevLockFlag,true) || !x.setValueAutoMark(tagPumpCmdLockValue,0) || !x.setValueAutoMark(tagPumpCmdLockFlag,true)){
916916
heatingError = true; break heatTest;
917917
}
918-
b = waitFor(180000, 3000, tagPumpStatus, new Predicate<Object>(){
919-
public boolean test(Object s){
918+
b = waitFor(180000, 3000, tagPumpStatus, new Predicate<String>(){
919+
public boolean test(String s){
920920
return s.equals("0");
921921
}
922922
});
@@ -1073,7 +1073,7 @@ private Boolean checkAirflow() throws Throwable {
10731073
}
10741074
return false;
10751075
}
1076-
private Boolean waitFor(long timeout, long interval, String tag, Predicate<Object> test) throws Throwable {
1076+
private Boolean waitFor(long timeout, long interval, String tag, Predicate<String> test) throws Throwable {
10771077
final long lim = System.currentTimeMillis()+timeout;
10781078
String s;
10791079
do {
@@ -1209,16 +1209,11 @@ public void print(final StringBuilder sb, final boolean JSON){
12091209
}
12101210
sb.append("\n}");
12111211
}
1212-
@Override public int compareTo(Object obj){
1213-
if (obj instanceof Data){
1214-
Data t = (Data)obj;
1215-
if (group==t.group){
1216-
return path.compareTo(t.path);
1217-
}else{
1218-
return group-t.group;
1219-
}
1212+
@Override public int compareTo(Data d){
1213+
if (group==d.group){
1214+
return path.compareTo(d.path);
12201215
}else{
1221-
return -1;
1216+
return group-d.group;
12221217
}
12231218
}
12241219
}

0 commit comments

Comments
 (0)