Skip to content

Commit

Permalink
update print functions
Browse files Browse the repository at this point in the history
  • Loading branch information
mcosovic committed Jul 23, 2024
1 parent 2bbdb0f commit b8b1e2e
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 31 deletions.
30 changes: 23 additions & 7 deletions src/print/measurement.jl
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,6 @@ function formatDevice(meter::GaussMeter, analysisArray::Array{Float64,1}, style:
return fmt, width, show, minval, maxval
end


function headerDevice(io::IO, width::Dict{String, Int64}, show::Dict{String, Bool}, delimiter::String, unitLive::String)
fmtMes, fmtEst, fmtSta = printHeader1(io, width, show, delimiter)
printHeader2(io, width, show, fmtMes, fmtEst, fmtSta, delimiter)
Expand All @@ -872,10 +871,16 @@ end

function headerDevice(io::IO, show::Dict{String, Bool}, delimiter::String, unitLive::String, device::String)
print(io, format(Format("%s"), "$device Label"))
printf(io, show, delimiter, "Measurement Mean", "Measurement Mean [$unitLive]", "Measurement Variance", "Measurement Variance [$unitLive]")
printf(io, show, delimiter, "State Estimation Estimate", "State Estimation Estimate [$unitLive]", "State Estimation Residual", "State Estimation Residual [$unitLive]")
printf(io, show, delimiter, "Measurement Mean", "Measurement Mean", "Measurement Variance", "Measurement Variance")
printf(io, show, delimiter, "State Estimation Estimate", "State Estimation Estimate", "State Estimation Residual", "State Estimation Residual")
printf(io, show, delimiter, "Status", "Status")
@printf io "\n"

print(io, format(Format("%s"), ""))
printf(io, show, delimiter, "Measurement Mean", "[$unitLive]", "Measurement Variance", "[$unitLive]")
printf(io, show, delimiter, "State Estimation Estimate", "[$unitLive]", "State Estimation Residual", "[$unitLive]")
printf(io, show, delimiter, "Status", "")
@printf io "\n"
end

function headerDevice(io::IO, width1::Dict{String, Int64}, width2::Dict{String, Int64}, show1::Dict{String, Bool}, show2::Dict{String, Bool},
Expand Down Expand Up @@ -915,15 +920,26 @@ function headerDevice(io::IO, show1::Dict{String, Bool}, show2::Dict{String, Boo
hasMore::Bool, device::String)

print(io, format(Format("%s"), "$device Label"))
printf(io, show1, delimiter, "Measurement Mean", "Magnitude Measurement Mean [$unitLive1]", "Measurement Variance", "Magnitude Measurement Variance [$unitLive1]")
printf(io, show1, delimiter, "State Estimation Estimate", "Magnitude State Estimation Estimate [$unitLive1]", "State Estimation Residual", "Magnitude State Estimation Residual [$unitLive1]")
printf(io, show1, delimiter, "Measurement Mean", "Magnitude Measurement Mean", "Measurement Variance", "Magnitude Measurement Variance")
printf(io, show1, delimiter, "State Estimation Estimate", "Magnitude State Estimation Estimate", "State Estimation Residual", "Magnitude State Estimation Residual")
printf(io, show1, delimiter, "Status", "Magnitude Status")
if hasMore
printf(io, show2, delimiter, "Measurement Mean", "Angle Measurement Mean [$unitLive2]", "Measurement Variance", "Angle Measurement Variance [$unitLive2]")
printf(io, show2, delimiter, "State Estimation Estimate", "Angle State Estimation Estimate [$unitLive2]", "State Estimation Residual", "Angle State Estimation Residual [$unitLive2]")
printf(io, show2, delimiter, "Measurement Mean", "Angle Measurement Mean", "Measurement Variance", "Angle Measurement Variance")
printf(io, show2, delimiter, "State Estimation Estimate", "Angle State Estimation Estimate", "State Estimation Residual", "Angle State Estimation Residual")
printf(io, show2, delimiter, "Status", "Angle Status")
end
@printf io "\n"

print(io, format(Format("%s"), ""))
printf(io, show1, delimiter, "Measurement Mean", "[$unitLive1]", "Measurement Variance", "[$unitLive1]")
printf(io, show1, delimiter, "State Estimation Estimate", "[$unitLive1]", "State Estimation Residual", "[$unitLive1]")
printf(io, show1, delimiter, "Status", "")
if hasMore
printf(io, show2, delimiter, "Measurement Mean", "[$unitLive2]", "Measurement Variance", "[$unitLive2]")
printf(io, show2, delimiter, "State Estimation Estimate", "[$unitLive2]", "State Estimation Residual", "[$unitLive2]")
printf(io, show2, delimiter, "Status", "")
end
@printf io "\n"
end

function printHeader1(io::IO, width::Dict{String, Int64}, show::Dict{String, Bool}, delimiter::String; label::Bool = true, newLine::Bool = true)
Expand Down
89 changes: 66 additions & 23 deletions src/print/powerSystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,21 @@ function printBusData(system::PowerSystem, analysis::AC, io::IO = stdout; label:
printf(io, fmtCur[3], width, show, "Current Injection Magnitude", "-"^width["Current Injection Magnitude"], "Current Injection Angle", "-"^width["Current Injection Angle"])
else
print(io, format(Format("%s"), "Bus Label"))
printf(io, show, delimiter, "Voltage Magnitude", "Voltage Magnitude $(unitData["V"])", "Voltage Angle", "Voltage Angle $(unitData["θ"])")
printf(io, show, delimiter, "Power Generation Active", "Active Power Generation $(unitData["P"])", "Power Generation Reactive", "Reactive Power Generation $(unitData["Q"])")
printf(io, show, delimiter, "Power Demand Active", "Active Power Demand $(unitData["P"])", "Power Demand Reactive", "Reactive Power Demand $(unitData["Q"])")
printf(io, show, delimiter, "Power Injection Active", "Active Power Injection $(unitData["P"])", "Power Injection Reactive", "Reactive Power Injection $(unitData["Q"])")
printf(io, show, delimiter, "Shunt Power Active", "Active Shunt Power $(unitData["P"])", "Shunt Power Reactive", "Reactive Shunt Power $(unitData["Q"])")
printf(io, show, delimiter, "Current Injection Magnitude", "Current Injection Magnitude $(unitData["I"])", "Current Injection Angle", "Current Injection Angle $(unitData["ψ"])")
printf(io, show, delimiter, "Voltage Magnitude", "Voltage Magnitude", "Voltage Angle", "Voltage Angle")
printf(io, show, delimiter, "Power Generation Active", "Active Power Generation", "Power Generation Reactive", "Reactive Power Generation")
printf(io, show, delimiter, "Power Demand Active", "Active Power Demand", "Power Demand Reactive", "Reactive Power Demand")
printf(io, show, delimiter, "Power Injection Active", "Active Power Injection", "Power Injection Reactive", "Reactive Power Injection")
printf(io, show, delimiter, "Shunt Power Active", "Shunt Active Power", "Shunt Power Reactive", "Shunt Reactive Power")
printf(io, show, delimiter, "Current Injection Magnitude", "Current Injection Magnitude", "Current Injection Angle", "Current Injection Angle")
@printf io "\n"

print(io, format(Format("%s"), ""))
printf(io, show, delimiter, "Voltage Magnitude", unitData["V"], "Voltage Angle", unitData["θ"])
printf(io, show, delimiter, "Power Generation Active", unitData["P"], "Power Generation Reactive", unitData["Q"])
printf(io, show, delimiter, "Power Demand Active", unitData["P"], "Power Demand Reactive", unitData["Q"])
printf(io, show, delimiter, "Power Injection Active", unitData["P"], "Power Injection Reactive", unitData["Q"])
printf(io, show, delimiter, "Shunt Power Active", unitData["P"], "Shunt Power Reactive", unitData["Q"])
printf(io, show, delimiter, "Current Injection Magnitude", unitData["I"], "Current Injection Angle", unitData["ψ"])
end
@printf io "\n"
end
Expand Down Expand Up @@ -322,10 +331,17 @@ function printBusData(system::PowerSystem, analysis::DC, io::IO = stdout; label:
printf(io, fmtInj[3], width, show, "Power Injection Active", "-"^width["Power Injection Active"])
else
print(io, format(Format("%s"), "Bus Label"))
printf(io, show, delimiter, "Voltage Angle", "Voltage Angle $(unitData["θ"])")
printf(io, show, delimiter, "Power Generation Active", "Active Power Generation $(unitData["P"])")
printf(io, show, delimiter, "Power Demand Active", "Active Power Demand $(unitData["P"])")
printf(io, show, delimiter, "Power Injection Active", "Active Power Injection $(unitData["P"])")
printf(io, show, delimiter, "Voltage Angle", "Voltage Angle")
printf(io, show, delimiter, "Power Generation Active", "Active Power Generation")
printf(io, show, delimiter, "Power Demand Active", "Active Power Demand")
printf(io, show, delimiter, "Power Injection Active", "Active Power Injection")
@printf io "\n"

print(io, format(Format("%s"), ""))
printf(io, show, delimiter, "Voltage Angle", unitData["θ"])
printf(io, show, delimiter, "Power Generation Active", unitData["P"])
printf(io, show, delimiter, "Power Demand Active", unitData["P"])
printf(io, show, delimiter, "Power Injection Active", unitData["P"])
end
@printf io "\n"
end
Expand Down Expand Up @@ -529,14 +545,25 @@ function printBranchData(system::PowerSystem, analysis::AC, io::IO = stdout; lab
printf(io, fmtStatus[3], width, show, "Status", "-"^width["Status"])
else
print(io, format(Format("%s"), "Branch Label"))
printf(io, show, delimiter, "From-Bus Power Active", "Active Power From-Bus $(unitData["P"])", "From-Bus Power Reactive", "Reactive Power From-Bus $(unitData["Q"])")
printf(io, show, delimiter, "To-Bus Power Active", "Active Power To-Bus $(unitData["P"])", "To-Bus Power Reactive", "Reactive Power To-Bus $(unitData["Q"])")
printf(io, show, delimiter, "Shunt Power Active", "Active Shunt Power $(unitData["P"])", "Shunt Power Reactive", "Reactive Shunt Power $(unitData["Q"])")
printf(io, show, delimiter, "Series Power Active", "Active Series Power $(unitData["P"])", "Series Power Reactive", "Reactive Series Power $(unitData["Q"])")
printf(io, show, delimiter, "From-Bus Current Magnitude", "From-Bus Current Magnitude $(unitData["I"])", "From-Bus Current Angle", "From-Bus Current Angle $(unitData["ψ"])")
printf(io, show, delimiter, "To-Bus Current Magnitude", "To-Bus Current Magnitude $(unitData["I"])", "To-Bus Current Angle", "To-Bus Current Angle $(unitData["ψ"])")
printf(io, show, delimiter, "Series Current Magnitude", "Series Current Magnitude $(unitData["I"])", "Series Current Angle", "Series Current Angle $(unitData["ψ"])")
printf(io, show, delimiter, "From-Bus Power Active", "From-Bus Active Power", "From-Bus Power Reactive", "From-Bus Reactive Power")
printf(io, show, delimiter, "To-Bus Power Active", "To-Bus Active Power", "To-Bus Power Reactive", "To-Bus Reactive Power")
printf(io, show, delimiter, "Shunt Power Active", "Shunt Active Power", "Shunt Power Reactive", "Shunt Reactive Power")
printf(io, show, delimiter, "Series Power Active", "Series Active Power", "Series Power Reactive", "Series Reactive Power")
printf(io, show, delimiter, "From-Bus Current Magnitude", "From-Bus Current Magnitude", "From-Bus Current Angle", "From-Bus Current Angle")
printf(io, show, delimiter, "To-Bus Current Magnitude", "To-Bus Current Magnitude", "To-Bus Current Angle", "To-Bus Current Angle")
printf(io, show, delimiter, "Series Current Magnitude", "Series Current Magnitude", "Series Current Angle", "Series Current Angle")
printf(io, show, delimiter, "Status", "Status")
@printf io "\n"

print(io, format(Format("%s"), ""))
printf(io, show, delimiter, "From-Bus Power Active", unitData["P"], "From-Bus Power Reactive", unitData["Q"])
printf(io, show, delimiter, "To-Bus Power Active", unitData["P"], "To-Bus Power Reactive", unitData["Q"])
printf(io, show, delimiter, "Shunt Power Active", unitData["P"], "Shunt Power Reactive", unitData["Q"])
printf(io, show, delimiter, "Series Power Active", unitData["P"], "Series Power Reactive", unitData["Q"])
printf(io, show, delimiter, "From-Bus Current Magnitude", unitData["I"], "From-Bus Current Angle", unitData["ψ"])
printf(io, show, delimiter, "To-Bus Current Magnitude", unitData["I"], "To-Bus Current Angle", unitData["ψ"])
printf(io, show, delimiter, "Series Current Magnitude", unitData["I"], "Series Current Angle", unitData["ψ"])
printf(io, show, delimiter, "Status", "")
end
@printf io "\n"
end
Expand Down Expand Up @@ -754,9 +781,15 @@ function printBranchData(system::PowerSystem, analysis::DC, io::IO = stdout; lab
printf(io, fmtSt[3], width, show, "Status", "-"^width["Status"])
else
print(io, format(Format("%s"), "Branch Label"))
printf(io, show, delimiter, "From-Bus Power Active", "Active Power From-Bus $(unitData["P"])")
printf(io, show, delimiter, "To-Bus Power Active", "Active Power To-Bus $(unitData["P"])")
printf(io, show, delimiter, "From-Bus Power Active", "From-Bus Active Power")
printf(io, show, delimiter, "To-Bus Power Active", "To-Bus Active Power")
printf(io, show, delimiter, "Status", "Status")
@printf io "\n"

print(io, format(Format("%s"), ""))
printf(io, show, delimiter, "From-Bus Power Active", unitData["P"])
printf(io, show, delimiter, "To-Bus Power Active", unitData["P"])
printf(io, show, delimiter, "Status", "")
end
@printf io "\n"
end
Expand Down Expand Up @@ -890,7 +923,7 @@ function printGeneratorData(system::PowerSystem, analysis::AC, io::IO = stdout;
printTitle(io, maxLine, delimiter, "Generator Data")

print(io, format(Format("$delimiter %*s%s%*s $delimiter"), floor(Int, (width["Label"] - 5) / 2), "", "Label", ceil(Int, (width["Label"] - 5) / 2) , ""))
fmtOut = printf(io, width, show, delimiter, "Output Power Active", "Output Power Reactive", "Output Power")
fmtOut = printf(io, width, show, delimiter, "Output Power Active", "Output Power Reactive", "Power Output")
fmtSta = printf(io, width, show, delimiter, "Status", "Status")
@printf io "\n"

Expand All @@ -914,8 +947,13 @@ function printGeneratorData(system::PowerSystem, analysis::AC, io::IO = stdout;
printf(io, fmtSta[3], width, show, "Status", "-"^width["Status"])
else
print(io, format(Format("%s"), "Generator Label"))
printf(io, show, delimiter, "Output Power Active", "Active Output Power $(unitData["P"])", "Output Power Reactive", "Reactive Output Power $(unitData["Q"])")
printf(io, show, delimiter, "Output Power Active", "Active Power Output", "Output Power Reactive", "Reactive Power Output")
printf(io, show, delimiter, "Status", "Status")
@printf io "\n"

print(io, format(Format("%s"), ""))
printf(io, show, delimiter, "Output Power Active", unitData["P"], "Output Power Reactive", unitData["Q"])
printf(io, show, delimiter, "Status", "")
end
@printf io "\n"
end
Expand Down Expand Up @@ -1000,7 +1038,7 @@ function printGeneratorData(system::PowerSystem, analysis::DC, io::IO = stdout;
printTitle(io, maxLine, delimiter, "Generator Data")

print(io, format(Format("$delimiter %*s%s%*s $delimiter"), floor(Int, (width["Label"] - 5) / 2), "", "Label", ceil(Int, (width["Label"] - 5) / 2) , ""))
fmtOut = printf(io, width, show, delimiter, "Output Power Active", "Output Power")
fmtOut = printf(io, width, show, delimiter, "Output Power Active", "Power Output")
fmtSta = printf(io, width, show, delimiter, "Status", "Status")
@printf io "\n"

Expand All @@ -1024,8 +1062,13 @@ function printGeneratorData(system::PowerSystem, analysis::DC, io::IO = stdout;
printf(io, fmtSta[3], width, show, "Status", "-"^width["Status"])
else
print(io, format(Format("%s"), "Generator Label"))
printf(io, show, delimiter, "Output Power Active", "Active Output Power $(unitData["P"])")
printf(io, show, delimiter, "Output Power Active", "Active Power Output")
printf(io, show, delimiter, "Status", "Status")
@printf io "\n"

print(io, format(Format("%s"), ""))
printf(io, show, delimiter, "Output Power Active", unitData["P"])
printf(io, show, delimiter, "Status", "")
end
@printf io "\n"
end
Expand Down
2 changes: 1 addition & 1 deletion src/print/routine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function summaryBlock(io::IO, data1::SummaryData, unitLive::String, span::Array{
end

function printTitle(io::IO, maxLine::Int64, delimiter::String, title::String)
print(io, format(Format("\n$delimiter%s$delimiter\n"), "-"^maxLine))
print(io, format(Format("$delimiter%s$delimiter\n"), "-"^maxLine))
print(io, format(Format("$delimiter %s%*s$delimiter\n"), title, maxLine - textwidth(title) - 1, ""))
print(io, format(Format("$delimiter%s$delimiter\n"), "-"^maxLine))
end
Expand Down

0 comments on commit b8b1e2e

Please sign in to comment.