Skip to content

Commit

Permalink
modified: README.md
Browse files Browse the repository at this point in the history
	modified:   src/system_cli.jl
	modified:   test/project_cli_test.jl
	modified:   test/system_cli_test.jl
  • Loading branch information
Pierre BLAUD committed Apr 16, 2023
1 parent 591ed8b commit 1c6e6af
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 22 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
[![License: MPL 2.0](https://img.shields.io/badge/License-MPL_2.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0)
![CI](https://github.com/AutomationLabs-sh/AutomationLabsDepot.jl/actions/workflows/ci.yml/badge.svg)
[![codecov](https://codecov.io/gh/AutomationLabs-sh/AutomationLabs.jl/branch/main/graph/badge.svg?token=JQZBIUJYP0)](https://codecov.io/gh/AutomationLabs-sh/AutomationLabs.jl)
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)
[![deps](https://juliahub.com/docs/AutomationLabs/deps.svg)](https://juliahub.com/ui/Packages/AutomationLabs/pZcfU?t=2)
[![Dev docs](https://img.shields.io/badge/docs-stable-blue.svg)](https://automationlabs-sh.github.io/AutomationLabs.jl/)

AutomationLabs is a package for dynamical system identification and Model Predictive Control. It is written in Julia and provides different algorithm approach for identification and tuning (black box, linear, mixed-integer or non-linear optimization).
Expand Down
50 changes: 30 additions & 20 deletions src/system_cli.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ function system(args; kws...)
return sys

elseif args == :stats
_system_stats(kws)
sys_stats = _system_stats(kws)
return sys_stats

else
# Wrong arguments
Expand Down Expand Up @@ -155,32 +156,41 @@ function _system_stats(kws_)
return nothing
end

# Get user selection for ploting cli
show_all = get(kws, :show_all, false)

stats_ls_system = AutomationLabsDepot.stats_system_local_folder_db(
string(project_name),
string(system_name),
)

print_table_ls = Array{Any}(undef, 1, 8)

print_table_ls[1, 1] = system_name
print_table_ls[1, 2] = stats_ls_system[1, 1]
print_table_ls[1, 3] = stats_ls_system[2, 1]
print_table_ls[1, 4] = stats_ls_system[3, 1]

PrettyTables.pretty_table(
print_table_ls;
header = [
"System",
"Type",
"Input constraint",
"State constraint",
],
alignment = :l,
border_crayon = PrettyTables.crayon"blue",
)
# Evaluate if print is requested
if show_all == true

return nothing
print_table_ls = Array{Any}(undef, 1, 4)

print_table_ls[1, 1] = system_name
print_table_ls[1, 2] = stats_ls_system[1, 1]
print_table_ls[1, 3] = stats_ls_system[2, 1]
print_table_ls[1, 4] = stats_ls_system[3, 1]

PrettyTables.pretty_table(
print_table_ls;
header = [
"System name",
"Type",
"State constraint",
"Input constraint",
],
alignment = :l,
border_crayon = PrettyTables.crayon"blue",
tf = PrettyTables.tf_matrix,
)

return nothing
end

return stats_ls_system
end

"""
Expand Down
28 changes: 28 additions & 0 deletions test/project_cli_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,32 @@ using AutomationLabs

end

@testset "Project error message test" begin

# Wrong args
project(:gt)

# Create a project with random name
rslt = project(:create)
@test rslt == true

# List project
pjt = project(:ls)
project(:ls, show_all = true)
@test size(pjt) == (1, 7)

# Remove project
rslt = project(:rm, name = "gt")
@test rslt == false

rslt = project(:rm, name = pjt[1])
@test rslt == true

# List project
pjt = project(:ls)
project(:ls, show_all = true)
@test size(pjt) == (0, 7)

end

end
82 changes: 82 additions & 0 deletions test/system_cli_test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,40 @@ using AutomationLabs
@test size(sys_3) == (3, 6)
@test sys_3[:, 3] == ["system_1"; "system_ucons"; "system_xcons_ucons"]

# Stats the systems
sys_stats_1 = system(:stats,
project_name = "qtp_test",
system_name = "system_1",
)
system(:stats,
project_name = "qtp_test",
system_name = "system_1",
show_all = true
)
@test size(sys_stats_1) == (3,)

sys_stats_ucons = system(:stats,
project_name = "qtp_test",
system_name = "system_ucons",
)
system(:stats,
project_name = "qtp_test",
system_name = "system_ucons",
show_all = true
)
@test size(sys_stats_ucons) == (3,)

sys_stats_xuconbs = system(:stats,
project_name = "qtp_test",
system_name = "system_xcons_ucons",

)
system(:stats,
project_name = "qtp_test",
system_name = "system_xcons_ucons",
show_all = true
)
@test size(sys_stats_xuconbs) == (3,)

### Linear system from identification

Expand Down Expand Up @@ -254,6 +288,19 @@ end
@test size(sys_6) == (1, 6)
@test sys_6[:, 3] == ["system_1"]

# Stats the system
sys_stats = system(:stats,
project_name = "qtp_test",
system_name = "system_1",
)
@test size(sys_stats) == (3,)

system(:stats,
project_name = "qtp_test",
system_name = "system_1",
show_all = true,
)

# Delete the system and the model
system(:rm, project_name = "qtp_test", system_name = "system_1",)
model(:rm, project_name = "qtp_test", model_name = "user_linear")
Expand All @@ -269,5 +316,40 @@ end

end

@testset "System error message test" begin

project(:create, name = "qtp_test")

project(:ls)

# Wrong arguments
system(:gt)

# Wrong ls
system(:ls, project_name = "qtp_test", show_all = true)
rslt = system(:ls, project_name = "gt")
@test size(rslt) == (0, 6)

# Wrong rm
rslt = system(:rm, project_name = "qtp_test")
@test rslt == nothing
rslt = system(:rm, system_name = "gt")
@test rslt == nothing

# Wrong stats
rslt = system(:stats, project_name = "qtp_test")
@test rslt == nothing
rslt = system(:stats, system_name = "gt")
@test rslt == nothing

# Wrong tune
rlst = system(:tune, project_name = "qtp_test")
@test rslt == nothing
rlst = system(:tune, model_name = "gt")
@test rslt == nothing

end



end

0 comments on commit 1c6e6af

Please sign in to comment.