Skip to content

Commit 06972a2

Browse files
committed
Refactoring
1 parent 9303312 commit 06972a2

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

test/test_forcespeedcontroller1.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ BENCHMARK = false
3030
include("test_utilities.jl")
3131

3232
STARTUP = get_startup(wcs, SAMPLES)
33-
V_WIND = STARTUP .* get_triangle_wind(wcs)
33+
V_WIND = STARTUP .* get_triangle_wind(wcs, V_WIND_MIN, V_WIND_MAX, FREQ_WIND, SAMPLES)
3434
V_RO, V_SET_OUT, V_SET_OUT_B, FORCE, F_ERR = zeros(SAMPLES), zeros(SAMPLES), zeros(SAMPLES), zeros(SAMPLES), zeros(SAMPLES)
3535
ACC, ACC_SET, V_ERR = zeros(SAMPLES), zeros(SAMPLES), zeros(SAMPLES)
3636
STATE = zeros(Int64, SAMPLES)

test/test_forcespeedcontroller2.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ BENCHMARK = false
3434
include("test_utilities.jl")
3535

3636
STARTUP = get_startup(wcs, SAMPLES)
37-
V_WIND = STARTUP .* get_triangle_wind(wcs)
37+
V_WIND = STARTUP .* get_triangle_wind(wcs, V_WIND_MIN, V_WIND_MAX, FREQ_WIND, SAMPLES)
3838
V_RO, V_SET_OUT, FORCE, F_ERR = zeros(SAMPLES), zeros(SAMPLES), zeros(SAMPLES), zeros(SAMPLES)
3939
ACC, ACC_SET, V_ERR = zeros(SAMPLES), zeros(SAMPLES), zeros(SAMPLES)
4040
STATE = zeros(Int64, SAMPLES)

test/test_speedcontroller1.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ BENCHMARK = false
2424
include("test_utilities.jl")
2525

2626
STARTUP = get_startup(wcs, SAMPLES)
27-
V_WIND = STARTUP .* get_triangle_wind(wcs)
27+
V_WIND = STARTUP .* get_triangle_wind(wcs, V_WIND_MIN, V_WIND_MAX, FREQ_WIND, SAMPLES)
2828
V_RO = zeros(SAMPLES)
2929
V_SET_OUT = zeros(SAMPLES)
3030
FORCE = zeros(SAMPLES)

test/test_speedcontroller2.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ BENCHMARK = false
2525
include("test_utilities.jl")
2626

2727
STARTUP = get_startup(wcs, SAMPLES)
28-
V_WIND = STARTUP .* get_triangle_wind(wcs)
28+
V_WIND = STARTUP .* get_triangle_wind(wcs, V_WIND_MIN, V_WIND_MAX, FREQ_WIND, SAMPLES)
2929
V_RO = zeros(SAMPLES)
3030
V_SET_OUT = zeros(SAMPLES)
3131
FORCE = zeros(SAMPLES)

test/test_utilities.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
# Create a wind signal in triangle form, using the constants V_WIND_MIN and V_WIND_MAX with
22
# the frequency FREQ_WIND.
3-
function get_triangle_wind(wcs::WCSettings)
3+
function get_triangle_wind(wcs::WCSettings, min, max, freq, samples)
44
result = zeros(SAMPLES)
55
v_wind = 0.0
66
rising = true
7-
delta = FREQ_WIND * 2.0 * (V_WIND_MAX - V_WIND_MIN) * wcs.dt
8-
for i in 1:SAMPLES
7+
delta = freq * 2.0 * (max - min) * wcs.dt
8+
for i in 1:samples
99
result[i] = v_wind
1010
if rising
1111
v_wind += delta
1212
end
13-
if v_wind >= V_WIND_MAX
14-
v_wind = V_WIND_MAX
13+
if v_wind >= max
14+
v_wind = max
1515
rising = false
1616
end
1717
if ! rising
1818
v_wind -= delta
1919
end
20-
if v_wind <= V_WIND_MIN
21-
v_wind = V_WIND_MIN + delta
20+
if v_wind <= min
21+
v_wind = min + delta
2222
rising = true
2323
end
2424
end

test/test_winchcontroller.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ FREQ_WIND = 0.25 # frequency of the triangle wind speed signal
3030
include("test_utilities.jl")
3131

3232
STARTUP = get_startup(wcs, SAMPLES)
33-
V_WIND = STARTUP .* get_triangle_wind(wcs)
33+
V_WIND = STARTUP .* get_triangle_wind(wcs, V_WIND_MIN, V_WIND_MAX, FREQ_WIND, SAMPLES)
3434
V_RO, V_SET_OUT, FORCE, F_ERR = zeros(SAMPLES), zeros(SAMPLES), zeros(SAMPLES), zeros(SAMPLES)
3535
ACC, ACC_SET, V_ERR = zeros(SAMPLES), zeros(SAMPLES), zeros(SAMPLES)
3636
RESET, ACTIVE, F_SET = zeros(SAMPLES), zeros(SAMPLES), zeros(SAMPLES)

0 commit comments

Comments
 (0)