-
Notifications
You must be signed in to change notification settings - Fork 164
/
Internal.mo
243 lines (216 loc) · 11.6 KB
/
Internal.mo
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
within Modelica.Utilities;
package Internal
"Internal components that a user should usually not directly utilize"
extends Modelica.Icons.InternalPackage;
partial package PartialModelicaServices
"Interfaces of components requiring a tool specific implementation"
extends Modelica.Icons.InternalPackage;
package Animation "Models and functions for 3-dim. animation"
extends Modelica.Icons.Package;
partial model PartialShape "Interface for 3D animation of elementary shapes"
import SI = Modelica.SIunits;
import Modelica.Mechanics.MultiBody.Frames;
import Modelica.Mechanics.MultiBody.Types;
parameter Types.ShapeType shapeType="box"
"Type of shape (box, sphere, cylinder, pipecylinder, cone, pipe, beam, gearwheel, spring, <external shape>)";
input Frames.Orientation R=Frames.nullRotation()
"Orientation object to rotate the world frame into the object frame" annotation(Dialog);
input SI.Position r[3]={0,0,0}
"Position vector from origin of world frame to origin of object frame, resolved in world frame" annotation(Dialog);
input SI.Position r_shape[3]={0,0,0}
"Position vector from origin of object frame to shape origin, resolved in object frame" annotation(Dialog);
input Real lengthDirection[3](each final unit="1")={1,0,0}
"Vector in length direction, resolved in object frame" annotation(Dialog);
input Real widthDirection[3](each final unit="1")={0,1,0}
"Vector in width direction, resolved in object frame" annotation(Dialog);
input SI.Length length=0 "Length of visual object" annotation(Dialog);
input SI.Length width=0 "Width of visual object" annotation(Dialog);
input SI.Length height=0 "Height of visual object" annotation(Dialog);
input Types.ShapeExtra extra=0.0
"Additional size data for some of the shape types" annotation(Dialog);
input Real color[3]={255,0,0} "Color of shape" annotation(Dialog(colorSelector=true));
input Types.SpecularCoefficient specularCoefficient = 0.7
"Reflection of ambient light (= 0: light is completely absorbed)" annotation(Dialog);
annotation (
Documentation(info="<html>
<p>
This model is documented at
<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape\">Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape</a>.
</p>
</html>"));
end PartialShape;
model PartialVector "Interface for 3D animation of a vector quantity (force, torque etc)"
import Modelica.Mechanics.MultiBody.Types;
import Modelica.Mechanics.MultiBody.Frames;
input Frames.Orientation R=Frames.nullRotation()
"Orientation object to rotate the world frame into the vector frame" annotation(Dialog);
input Modelica.SIunits.Position r[3]={0,0,0}
"Position vector from origin of world frame to origin of vector frame, resolved in world frame" annotation(Dialog);
input Real coordinates[3]={0,0,0}
"Coordinates of the vector resolved in vector frame" annotation(Dialog);
input Types.Color color=Types.Defaults.ArrowColor
"Color of vector" annotation(Dialog(colorSelector=true));
input Types.SpecularCoefficient specularCoefficient = 0.7
"Material property describing the reflecting of ambient light (= 0 means, that light is completely absorbed)" annotation(Dialog);
input Types.VectorQuantity quantity = Types.VectorQuantity.Force "The quantity of the coordinates" annotation(Dialog);
input Boolean headAtOrigin=false "= true, if the vector is pointing towards the origin of vector frame" annotation(Dialog);
input Boolean twoHeadedArrow=false "= true, if the arrow has two heads after each other (pointing in the same direction)" annotation(Dialog);
annotation (
Documentation(info="<html>
<p>
This model is documented at
<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Advanced.Vector\">Modelica.Mechanics.MultiBody.Visualizers.Advanced.Vector</a>.
</p>
</html>"));
end PartialVector;
model PartialSurface "Interface for 3D animation of surfaces"
import Modelica.Mechanics.MultiBody.Frames;
import Modelica.Mechanics.MultiBody.Types;
input Frames.Orientation R=Frames.nullRotation()
"Orientation object to rotate the world frame into the surface frame"
annotation(Dialog(group="Surface frame"));
input Modelica.SIunits.Position r_0[3]={0,0,0}
"Position vector from origin of world frame to origin of surface frame, resolved in world frame"
annotation(Dialog(group="Surface frame"));
parameter Integer nu=2 "Number of points in u-Dimension" annotation(Dialog(group="Surface properties"));
parameter Integer nv=2 "Number of points in v-Dimension" annotation(Dialog(group="Surface properties"));
replaceable function surfaceCharacteristic =
Modelica.Mechanics.MultiBody.Interfaces.partialSurfaceCharacteristic
"Function defining the surface characteristic"
annotation(choicesAllMatching=true,Dialog(group="Surface properties"));
parameter Boolean wireframe=false "= true: 3D model will be displayed without faces"
annotation (Dialog(group="Material properties"),choices(checkBox=true));
parameter Boolean multiColoredSurface=false "= true: Color is defined for each surface point"
annotation(Dialog(group="Material properties"),choices(checkBox=true));
input Real color[3]={255,0,0} "Color of surface" annotation(Dialog(colorSelector=true,group="Material properties", enable=not multiColoredSurface));
input Types.SpecularCoefficient specularCoefficient = 0.7
"Reflection of ambient light (= 0: light is completely absorbed)"
annotation(Dialog(group="Material properties"));
input Real transparency=0 "Transparency of shape: 0 (= opaque) ... 1 (= fully transparent)"
annotation(Dialog(group="Material properties"));
annotation (Documentation(info="<html>
<p>
This model is documented at
<a href=\"modelica://Modelica.Mechanics.MultiBody.Visualizers.Advanced.Surface\">Modelica.Mechanics.MultiBody.Visualizers.Advanced.Surface</a>.
</p>
</html>"));
end PartialSurface;
end Animation;
package ExternalReferences "Functions to access external resources"
extends Modelica.Icons.InternalPackage;
partial function PartialLoadResource
"Interface for tool specific function to return the absolute path name of a URI or local file name"
extends Modelica.Icons.Function;
input String uri "URI or local file name";
output String fileReference "Absolute path name of file";
annotation (Documentation(info="<html>
<p>
This partial function defines the function interface of a tool-specific implementation
in package ModelicaServices. The interface is documented at
<a href=\"modelica://Modelica.Utilities.Files.loadResource\">Modelica.Utilities.Internal.FileSystem.loadResource</a>.
</p>
</html>"));
end PartialLoadResource;
end ExternalReferences;
package System "System dependent functions"
extends Modelica.Icons.InternalPackage;
partial function exitBase "Interface for tool specific function to terminate the execution of the Modelica environment"
extends Modelica.Icons.Function;
input Integer status=0 "Result to be returned by environment (0 means success)";
annotation (Documentation(info="<html>
<p>
This partial function defines the function interface of a tool-specific implementation
in package ModelicaServices.
</p>
</html>"));
end exitBase;
end System;
annotation (Documentation(info="<html>
<p>
This package contains interfaces of a set of functions and models used in the
Modelica Standard Library that requires a <strong>tool specific implementation</strong>.
There is an associated package called <strong>ModelicaServices</strong>. A tool vendor
should provide a proper implementation of this library for the corresponding
tool. The default implementation is \"do nothing\".
In the Modelica Standard Library, the models and functions of ModelicaServices
are used.
</p>
</html>"));
end PartialModelicaServices;
package FileSystem
"Internal package with external functions as interface to the file system"
extends Modelica.Icons.InternalPackage;
impure function mkdir "Make directory (POSIX: 'mkdir')"
extends Modelica.Icons.Function;
input String directoryName "Make a new directory";
external "C" ModelicaInternal_mkdir(directoryName) annotation(Library="ModelicaExternalC");
end mkdir;
impure function rmdir "Remove empty directory (POSIX function 'rmdir')"
extends Modelica.Icons.Function;
input String directoryName "Empty directory to be removed";
external "C" ModelicaInternal_rmdir(directoryName) annotation(Library="ModelicaExternalC");
end rmdir;
impure function stat "Inquire file information (POSIX function 'stat')"
extends Modelica.Icons.Function;
input String name "Name of file, directory, pipe etc.";
output Types.FileType fileType "Type of file";
external "C" fileType = ModelicaInternal_stat(name) annotation(Library="ModelicaExternalC");
end stat;
impure function rename "Rename existing file or directory (C function 'rename')"
extends Modelica.Icons.Function;
input String oldName "Current name";
input String newName "New name";
external "C" ModelicaInternal_rename(oldName, newName) annotation(Library="ModelicaExternalC");
end rename;
impure function removeFile "Remove existing file (C function 'remove')"
extends Modelica.Icons.Function;
input String fileName "File to be removed";
external "C" ModelicaInternal_removeFile(fileName) annotation(Library="ModelicaExternalC");
end removeFile;
impure function copyFile
"Copy existing file (C functions 'fopen', 'fread', 'fwrite', 'fclose')"
extends Modelica.Icons.Function;
input String fromName "Name of file to be copied";
input String toName "Name of copy of file";
external "C" ModelicaInternal_copyFile(fromName, toName) annotation(Library="ModelicaExternalC");
end copyFile;
impure function readDirectory
"Read names of a directory (POSIX functions opendir, readdir, closedir)"
extends Modelica.Icons.Function;
input String directory
"Name of the directory from which information is desired";
input Integer nNames
"Number of names that are returned (inquire with getNumberOfFiles)";
output String names[nNames]
"All file and directory names in any order from the desired directory";
external "C" ModelicaInternal_readDirectory(directory,nNames,names) annotation(Library="ModelicaExternalC");
end readDirectory;
impure function getNumberOfFiles
"Get number of files and directories in a directory (POSIX functions opendir, readdir, closedir)"
extends Modelica.Icons.Function;
input String directory "Directory name";
output Integer result
"Number of files and directories present in 'directory'";
external "C" result = ModelicaInternal_getNumberOfFiles(directory) annotation(Library="ModelicaExternalC");
end getNumberOfFiles;
annotation (
Documentation(info="<html>
<p>
Package <strong>Internal.FileSystem</strong> is an internal package that contains
low level functions as interface to the file system.
These functions should not be called directly in a scripting
environment since more convenient functions are provided
in packages Files and Systems.
</p>
<p>
Note, the functions in this package are direct interfaces to
functions of POSIX and of the standard C library. Errors
occurring in these functions are treated by triggering
a Modelica assert. Therefore, the functions in this package
return only for a successful operation. Furthermore, the
representation of a string is hidden by this interface,
especially if the operating system supports Unicode characters.
</p>
</html>"));
end FileSystem;
end Internal;