forked from modelica/ModelicaStandardLibrary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.mo
217 lines (201 loc) · 8.79 KB
/
package.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
within Modelica;
package Utilities "Library of utility functions dedicated to scripting (operating on files, streams, strings, system)"
extends Modelica.Icons.UtilitiesPackage;
package UsersGuide "User's Guide of Utilities Library"
extends Modelica.Icons.Information;
class ImplementationNotes "Implementation Notes"
extends Modelica.Icons.Information;
annotation (Documentation(info="<html>
<p>
Below the major design decisions of this library are summarized.
</p>
<ul>
<li> <strong>C-Function Interface</strong><br>
This library contains several interfaces to C-functions in order
to operate with the environment. As will become clear, it is usually
required that a Modelica tool vendor provides an implementation
of these C-functions that are suited for his environment.
In directory \"Modelica/Resources/C-Sources\" a reference implementation
is given for Microsoft Windows Systems and for POSIX environments.
The files \"ModelicaInternal.c\" and \"ModelicaStrings.c\" can be
used as a basis for the integration in the vendors environment.<br> </li>
<li> <strong>Character Encoding</strong><br>
The representation of characters is different in operating systems.
The more modern ones (e.g., Windows-NT) use an early variant of
Unicode (16 bit per character)
other (e.g., Windows-ME) use 8-bit encoding. Also 32 bit per character
and multi-byte representations are in use. This is important, since e.g.,
Japanese Modelica users need Unicode representation. The design in this
library is done in such a way that a basic set of calls to the operating
system hides the actual character representation. This means, that all
functions of this package can be used independent from the underlying
character representation.<br>
The C-interface of the Modelica language provides only an 8-bit
character encoding passing mechanism of strings. As a result, the
reference implementation in \"Modelica.Utilities\\C-Source\" needs to
be adapted to the character representation supported in the
Modelica vendor environment.<br> </li>
<li> <strong>Internal String Representation</strong><br>
The design of this package was made in order that string handling
is convenient. This is in contrast to, e.g., the C-language, where
string handling is inconvenient, cumbersome and error prone, but on the
other hand is in some sense \"efficient\".
The standard reference implementation in \"Modelica.Utilities\\C-Source\"
is based on the standard C definition of a string, i.e., a pointer to
a sequence of characters, ended with a null terminating character.
In order that the string handling in this package is convenient,
some assumptions have been made, especially, that the access to
a substring is efficient (O(1) access instead of O(n) as in standard C).
This allows to hide string pointer arithmetic from the user.
In such a case, a similar efficiency as in C can be expected for
most high level operations, such as find, sort, replace.
The \"efficient character access\" can be reached if, e.g.,
the number of characters
are stored in a string, and the length of a character is fixed,
say 16 or 32 bit (if all Unicode characters shall be represented).
A vendor should adapt the reference implementation in this
respect.<br> </li>
<li> <strong>String copy = pointer copy</strong><br>
The Modelica language has no mechanism to change a character
of a string. When a string has to be modified, the only way
to achieve this is to generate it newly. The advantage is that
a Modelica tool can treat a string as a constant entity and
can replace (expensive) string copy operations by pointer
copy operations. For example, when sorting a set of strings
the following type of operations occur:
<blockquote><pre>
String s[:], s_temp;
...
s_temp := s[i];
s[i] := s[j];
s[j] := s_temp;
</pre></blockquote>
Formally, three strings are copied. Due to the feature
sketched above, a Modelica tool can replace this
copy operation by pointer assignments, a very \"cheap\"
operation. The Modelica.Utilities functions will perform
efficiently, if such types of optimizations are supported
by the tool.</li>
</ul>
</html>"));
end ImplementationNotes;
class ReleaseNotes "Release notes"
extends Modelica.Icons.ReleaseNotes;
annotation (Documentation(info="<html>
<h4>Version 1.0, 2004-09-29</h4>
<p>
First version implemented.
</p>
</html>"));
end ReleaseNotes;
class Contact "Contact"
extends Modelica.Icons.Contact;
annotation (Documentation(info="<html>
<h4>Library officers</h4>
<p>
<a href=\"http://www.robotic.dlr.de/Martin.Otter/\"><strong>Martin Otter</strong></a><br>
Deutsches Zentrum für Luft- und Raumfahrt (DLR)<br>
Institut für Systemdynamik und Regelungstechnik (SR)<br>
Münchener Straße 20<br>
D-82234 Weßling<br>
Germany
</p>
<p>
<strong>Hans Olsson</strong><br>
Dassault Systèmes AB, Lund, Sweden
</p>
<h4>Main authors</h4>
<p>
<strong>Dag Brück</strong><br>
Dassault Systèmes AB, Lund, Sweden.<br>
email: <a href=\"mailto:Dag.Bruck@3ds.com\">Dag.Bruck@3ds.com</a>
</p>
<h4>Acknowledgements</h4>
<ul>
<li> This library has been designed by:<br>
<blockquote>
Dag Brück, Dassault Systèmes AB, Sweden<br>
Hilding Elmqvist, previously at Dassault Systèmes AB, Sweden<br>
Hans Olsson, Dassault Systèmes AB, Sweden<br>
Martin Otter, DLR Oberpfaffenhofen, Germany.
</blockquote></li>
<li> The library including the C reference implementation has
been implemented by Martin Otter and Dag Brück.</li>
<li> The Examples.calculator demonstration to implement a calculator
with this library is from Hilding Elmqvist.</li>
<li> Helpful comments from Kaj Nyström, PELAB, Linköping, Sweden,
are appreciated, as well as discussions at the 34th, 36th, and 40th
Modelica Design Meetings in Vienna, Linköping, and Dresden.</li>
</ul>
</html>"));
end Contact;
annotation (DocumentationClass=true, Documentation(info="<html>
<p>
Library <strong>Modelica.Utilities</strong> contains Modelica <strong>functions</strong> that are
especially suited for <strong>scripting</strong>. Currently, only a rudimentary
User's Guide is present. This will be improved in the next releases.
The User's Guide has currently the following chapters:
</p>
<ol>
<li>
<a href=\"modelica://Modelica.Utilities.UsersGuide.ReleaseNotes\">Release Notes</a>
summarizes the differences between different versions of this
library.
</li>
<li>
<a href=\"modelica://Modelica.Utilities.UsersGuide.ImplementationNotes\">ImplementationNotes</a>
describes design decisions for this library especially for
Modelica tool vendors.
</li>
<li>
<a href=\"modelica://Modelica.Utilities.UsersGuide.Contact\">Contact</a> provides
information about the authors of the library as well as acknowledgments.
</li>
</ol>
<p>
<strong>Error handling</strong><br>
In case of error, all functions in this library use a Modelica \"assert(..)\"
to provide an error message and to cancel all actions. This means that
functions do not return, if an error is triggered inside the function.
</p>
</html>"));
end UsersGuide;
annotation (
Documentation(info="<html>
<p>
This package contains Modelica <strong>functions</strong> that are
especially suited for <strong>scripting</strong>. The functions might
be used to work with strings, read data from file, write data
to file or copy, move and remove files.
</p>
<p>
For an introduction, have especially a look at:
</p>
<ul>
<li> <a href=\"modelica://Modelica.Utilities.UsersGuide\">Modelica.Utilities.User's Guide</a>
discusses the most important aspects of this library.</li>
<li> <a href=\"modelica://Modelica.Utilities.Examples\">Modelica.Utilities.Examples</a>
contains examples that demonstrate the usage of this library.</li>
</ul>
<p>
The following main sublibraries are available:
</p>
<ul>
<li> <a href=\"modelica://Modelica.Utilities.Files\">Files</a>
provides functions to operate on files and directories, e.g.,
to copy, move, remove files.</li>
<li> <a href=\"modelica://Modelica.Utilities.Streams\">Streams</a>
provides functions to read from files and write to files.</li>
<li> <a href=\"modelica://Modelica.Utilities.Strings\">Strings</a>
provides functions to operate on strings. E.g.
substring, find, replace, sort, scanToken.</li>
<li> <a href=\"modelica://Modelica.Utilities.System\">System</a>
provides functions to interact with the environment.
E.g., get or set the working directory or environment
variables and to send a command to the default shell.</li>
</ul>
<p>
Copyright © 1998-2024, Modelica Association and contributors
</p>
</html>"));
end Utilities;