-
Notifications
You must be signed in to change notification settings - Fork 85
/
generate_figures.ps1
113 lines (101 loc) · 3.58 KB
/
generate_figures.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
param([switch] $verbose)
$pngOutDir = Resolve-Path (Join-Path $PSScriptRoot "\docs\images\schema")
$generatorDir = Join-Path $PSScriptRoot "xsddiagram"
$generator = Join-Path $generatorDir "XSDDiagramConsole.exe"
function Clear-Gen() {
# Get-ChildItem $pngOutDir\*
if (Test-Path $generatorDir){
Remove-Item -Recurse $generatorDir
}
Remove-Item $pngOutDir\*
}
function Get-XSDDiagram() {
if (-Not (Test-Path $generator))
{
$uri = "https://github.com/clagms/xsddiagram/releases/download/XSDDiagram_1.3_FMI/XSDDiagram_1.3_FMI.zip"
$zipFile = "XSDDiagram-Binary.zip"
Invoke-WebRequest -Uri $uri -OutFile $zipFile
Expand-Archive -Path $zipFile -DestinationPath $generatorDir -Force
Remove-Item -Path $zipFile
}
}
function Check-Existing() {
Param(
$file
)
If (Test-Path $file -PathType Leaf) {
Write-Output "Error: File already exists."
Exit 1
}
}
function Export-Schema() {
Param(
$element,
$expand,
$schema = "fmi3ModelDescription.xsd",
$outName = $element + ".png",
[switch] $preview = $false
)
Write-Output "Generating schema for $element..."
$out = Join-Path $pngOutDir $outName
Check-Existing $out
$schema = (Resolve-Path (Join-Path $PSScriptRoot "\schema\$schema"))
if ($verbose) {
Write-Output "Generator command parameters:"
Write-Output " exe: $generator"
Write-Output " out: $out"
Write-Output " element: $element"
Write-Output " expand: $expand"
Write-Output " schema: $schema"
}
& $generator -o $out -r $element -e $expand -d -c -z 300 -a -no-gui -y $schema
If ((Get-Item $out).length -eq 0kb) {
Write-Output "Error generating file $out"
exit 1
}
if ($preview) {
Start-Process $out
}
}
Clear-Gen
Get-XSDDiagram
Export-Schema fmiModelDescription 1
Export-Schema UnitDefinitions 3
Export-Schema BaseUnit 2
Export-Schema DisplayUnit 2
Export-Schema TypeDefinitions 2
Export-Schema Float64Type 3 -schema fmi3Type.xsd
Export-Schema Int32Type 3 -schema fmi3Type.xsd
Export-Schema BooleanType 3 -schema fmi3Type.xsd
Export-Schema BinaryType 3 -schema fmi3Type.xsd
Export-Schema EnumerationType 3 -schema fmi3Type.xsd
Export-Schema ClockType 3 -schema fmi3Type.xsd
Export-Schema LogCategories 3
Export-Schema DefaultExperiment 1
Export-Schema fmiTerminalsAndIcons 1 -schema fmi3TerminalsAndIcons.xsd
Export-Schema Terminals 2 -schema fmi3TerminalsAndIcons.xsd
Export-Schema TerminalMemberVariable 1 -schema fmi3TerminalsAndIcons.xsd
Export-Schema TerminalStreamMemberVariable 1 -schema fmi3TerminalsAndIcons.xsd
Export-Schema GraphicalRepresentation 2 -schema fmi3TerminalsAndIcons.xsd
Export-Schema CoordinateSystem 2 -schema fmi3TerminalsAndIcons.xsd
Export-Schema Icon 2 -schema fmi3TerminalsAndIcons.xsd
Export-Schema TerminalGraphicalRepresentation 2 -schema fmi3Terminal.xsd
Export-Schema ModelVariables 2
Export-Schema fmi3ArrayableVariable 1
Export-Schema Float64 1 -schema fmi3Variable.xsd
Export-Schema Int32 1 -schema fmi3Variable.xsd
Export-Schema Boolean 1 -schema fmi3Variable.xsd
Export-Schema Binary 1 -schema fmi3Variable.xsd
Export-Schema Enumeration 1 -schema fmi3Variable.xsd
Export-Schema Clock 1 -schema fmi3Variable.xsd
Export-Schema Annotations 2
Export-Schema ModelStructure 2
Export-Schema ModelExchange 2
Export-Schema CoSimulation 2
Export-Schema ScheduledExecution 2
Export-Schema fmiBuildDescription 2 -schema fmi3BuildDescription.xsd
Export-Schema SourceFileSet 1 -schema fmi3BuildDescription.xsd
Export-Schema SourceFile 1 -schema fmi3BuildDescription.xsd
Export-Schema PreprocessorDefinition 1 -schema fmi3BuildDescription.xsd
Export-Schema IncludeDirectory 1 -schema fmi3BuildDescription.xsd
Export-Schema Library 1 -schema fmi3BuildDescription.xsd