Skip to content

Commit 32cb936

Browse files
committed
fix (hook-create-chronics) include integration test for hook create-chronics, fix issue raised during cppcheck
Signed-off-by: Ritesh.K <riteshkarki6@gmail.com>
1 parent a07f059 commit 32cb936

File tree

2 files changed

+131
-1
lines changed

2 files changed

+131
-1
lines changed

lib/hooks/create_chronics.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static double round_dec(double value, unsigned decimals) {
5353

5454
static void parse_table(const nlohmann::json &table_df,
5555
std::unordered_map<int, int> &target,
56-
const std::string col) {
56+
const std::string &col) {
5757
const nlohmann::json &load = table_df.at("_object").at(col);
5858
std::string s = table_df["_object"][col]["_object"].get<std::string>();
5959

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Integration test for hook create-chronics.
4+
#
5+
# Author: Ritesh Karki <ritesh.karki@rwth-aachen.de>
6+
# SPDX-FileCopyrightText: 2014-2026 Institute for Automation of Complex Power Systems, RWTH Aachen University
7+
# SPDX-License-Identifier: Apache-2.0
8+
9+
echo "Test not ready"
10+
exit 99
11+
12+
13+
DIR=$(mktemp -d)
14+
pushd ${DIR}
15+
16+
function finish {
17+
popd
18+
rm -rf ${DIR}
19+
}
20+
21+
trap finish EXIT
22+
23+
cat > config.conf << EOF
24+
nodes = {
25+
26+
file_node = {
27+
type = "file"
28+
format = {
29+
type = "csv"
30+
separator = ","
31+
delimiter = "\n"
32+
skip_first_line = false
33+
header = true
34+
}
35+
uris = ("./Load1.csv", "./SGen.csv")
36+
uri = "test_uri"
37+
in = {
38+
read_mode = "all"
39+
}
40+
41+
hooks = (
42+
{
43+
type = "create_chronics"
44+
loads_dir = "./"
45+
sgens_dir = "./"
46+
grid = "./grid_file.json"
47+
output = "./test_output"
48+
round_decimals = 3
49+
compress = true
50+
}
51+
)
52+
},
53+
dummy_node = {
54+
type = "file"
55+
format = "csv"
56+
uri = "dummy"
57+
out = {
58+
59+
}
60+
}
61+
}
62+
63+
paths = (
64+
{
65+
in = "file_node",
66+
out = "dummy_node"
67+
}
68+
)
69+
EOF
70+
71+
cat > Load1.csv << EOF
72+
secs,nsecs,offset,sequence,P_norm,Q_norm
73+
0,83333333,0.0,0,0.016932429412331206,0.009857843460539759
74+
0,166666666,0.0,1,0.016932429412331206,0.009282331392780813
75+
0,250000000,0.0,2,0.016932429412331206,0.008983608863673546
76+
0,333333333,0.0,3,0.016932429412331206,0.008961675873217962
77+
0,416666666,0.0,4,0.016932429412331206,0.0092165235308626
78+
0,500000000,0.0,5,0.016932429412331206,0.009670519541245412
79+
0,583333333,0.0,6,0.016932429412331206,0.009857843460539759
80+
0,666666666,0.0,7,0.01693242416294213,0.009700854102832137
81+
0,750000000,0.0,8,0.01693241891355305,0.009267075206472835
82+
0,833333333,0.0,9,0.016932429412331206,0.008961675873217962
83+
0,916666666,0.0,10,0.01693245040988752,0.008852188731969274
84+
1,0,0.0,11,0.016932476656832916,0.008909808395991422
85+
1,83333333,0.0,12,0.016932429412331206,0.008961675873217962
86+
1,166666666,0.0,13,0.016932303426993315,0.008978976886362093
87+
1,250000000,0.0,14,0.01693216169348819,0.008967472512770878
88+
1,333333333,0.0,15,0.016932429412331206,0.008961675873217962
89+
1,416666666,0.0,16,0.016933174825580388,0.008967330263947493
90+
1,500000000,0.0,17,0.016933993730276667,0.008978745732024092
91+
1,583333333,0.0,18,0.016932429412331206,0.008961675873217962
92+
1,666666666,0.0,19,0.016928077668784944,0.008910430734593728
93+
1,750000000,0.0,20,0.016923321722279623,0.008853477861931195
94+
1,833333333,0.0,21,0.016932429412331206,0.008961675873217962
95+
1,916666666,0.0,22,0.016957783961581444,0.00926349231423384
96+
2,0,0.0,23,0.01698551648408434,0.009693368258501533
97+
EOF
98+
99+
cat > SGen1.csv << EOF
100+
secs,nsecs,offset,sequence,P_norm,Q_norm
101+
0,83333333,0.0,0,0.0,0.0
102+
0,166666666,0.0,1,0.0,0.0
103+
0,250000000,0.0,2,0.0,0.0
104+
0,333333333,0.0,3,0.0,0.0
105+
0,416666666,0.0,4,0.0,0.0
106+
0,500000000,0.0,5,0.0,0.0
107+
0,583333333,0.0,6,0.0,0.0
108+
0,666666666,0.0,7,0.0,0.0
109+
0,750000000,0.0,8,0.0,0.0
110+
0,833333333,0.0,9,0.0,0.0
111+
0,916666666,0.0,10,0.0,0.0
112+
1,0,0.0,11,0.0,0.0
113+
1,83333333,0.0,12,0.0,0.0
114+
1,166666666,0.0,13,0.0,0.0
115+
1,250000000,0.0,14,0.0,0.0
116+
1,333333333,0.0,15,0.0,0.0
117+
1,416666666,0.0,16,0.0,0.0
118+
1,500000000,0.0,17,0.0,0.0
119+
1,583333333,0.0,18,0.0,0.0
120+
1,666666666,0.0,19,0.0,0.0
121+
1,750000000,0.0,20,0.0,0.0
122+
1,833333333,0.0,21,0.0,0.0
123+
1,916666666,0.0,22,0.0,0.0
124+
EOF
125+
126+
# TODO: Add an example grid net file
127+
128+
villas node confif.conf
129+
130+
# TODO: Compare with pre-generated csv files

0 commit comments

Comments
 (0)