Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Syntax changed from "class Voltage" to "type Voltage".
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk/OMNotebook/DrModelica@7404 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
Mohsen Torabzadeh-Tari
committed
Dec 15, 2010
1 parent
317dfdf
commit 8c750a6
Showing
1 changed file
with
97 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,103 @@ | ||
<!DOCTYPE OMNotebook> | ||
<Notebook> | ||
<GroupCell closed="false" > | ||
<GroupCell closed="false" > | ||
<TextCell style="Title" > | ||
<Text><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Arial; font-size:38pt; font-weight:600; color:#000000;">Short Class Definition</p></body></html></Text> | ||
</TextCell> | ||
<TextCell style="Text" > | ||
<Text><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;"><br />There is a short syntax for defining classes, commonly used to introduce more informative type names for existing classes.</p></body></html></Text> | ||
</TextCell> | ||
<InputCell style="Input" closed="true" > | ||
<Input>class Voltage = Real(Unit = "V");</Input> | ||
<Output></Output> | ||
</InputCell> | ||
<TextCell style="Text" > | ||
<Text><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;"><br />The same thing can be written using the keyword <span style=" font-family:Courier New;">type</span> instead:</p></body></html></Text> | ||
</TextCell> | ||
<InputCell style="Input" closed="true" > | ||
<Input>type Voltage = Real;</Input> | ||
<Output></Output> | ||
</InputCell> | ||
<TextCell style="Text" > | ||
<Text><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;"><br />The short class definition is the only way to introduce a "class" name for an array type:</p></body></html></Text> | ||
</TextCell> | ||
<InputCell style="Input" closed="true" > | ||
<Input>type Matrix10 = Real [10, 10];</Input> | ||
<Output></Output> | ||
</InputCell> | ||
<TextCell style="Text" > | ||
<Text><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;"><br />A short class definition is in most cases just a shorter syntax for defining a class that could just as well be defined using the standard inheritance syntax:</p></body></html></Text> | ||
</TextCell> | ||
<InputCell style="Input" closed="true" > | ||
<Input>type Voltage | ||
<GroupCell closed="false"> | ||
<GroupCell closed="false"> | ||
<TextCell style="Title"> | ||
<Text><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> | ||
<html><head><meta name="qrichtext" content="1" /><style type="text/css"> | ||
p, li { white-space: pre-wrap; } | ||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> | ||
<table border="0" style="-qt-table-type: root; margin-top:10px; margin-bottom:10px; margin-left:10px; margin-right:10px;"> | ||
<tr> | ||
<td style="border: none;"> | ||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Arial'; font-size:38pt; font-weight:600; color:#000000;">Short Class Definition</span></p></td></tr></table></body></html></Text> | ||
</TextCell> | ||
<TextCell style="Text"> | ||
<Text><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> | ||
<html><head><meta name="qrichtext" content="1" /><style type="text/css"> | ||
p, li { white-space: pre-wrap; } | ||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> | ||
<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> | ||
<tr> | ||
<td style="border: none;"> | ||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />There is a short syntax for defining classes, commonly used to introduce more informative type names for existing classes.</span></p></td></tr></table></body></html></Text> | ||
</TextCell> | ||
<GraphCell AutoX="true" AutoY="true" style="Graph" MinorX="0.1" Antialiasing="false" MinorY="0.1" Title="Plot by OpenModelica" LogX="false" LogY="false" MajorX="1" MajorY="1" closed="false" YLabel="" Area="wEgAAAAAAADAMAAAAAAAAEBZAAAAAAAAQD4AAAAAAAA=" ShowGraph="false" Grid="true" XLabel="" Legend="false"> | ||
<Input>type Voltage = Real(Unit = "V");</Input> | ||
<Output>{Voltage}</Output> | ||
</GraphCell> | ||
<TextCell style="Text"> | ||
<Text><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> | ||
<html><head><meta name="qrichtext" content="1" /><style type="text/css"> | ||
p, li { white-space: pre-wrap; } | ||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> | ||
<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> | ||
<tr> | ||
<td style="border: none;"> | ||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The same thing can be written using the keyword </span><span style=" font-family:'Courier New'; font-size:12pt; color:#000000;">type</span><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"> instead:</span></p></td></tr></table></body></html></Text> | ||
</TextCell> | ||
<GraphCell AutoX="true" AutoY="true" style="Graph" MinorX="0.1" Antialiasing="false" MinorY="0.1" Title="Plot by OpenModelica" LogX="false" LogY="false" MajorX="1" MajorY="1" closed="false" YLabel="" Area="wEgAAAAAAADAMAAAAAAAAEBZAAAAAAAAQD4AAAAAAAA=" ShowGraph="false" Grid="true" XLabel="" Legend="false"> | ||
<Input>type Voltage = Real;</Input> | ||
<Output>{Voltage}</Output> | ||
</GraphCell> | ||
<TextCell style="Text"> | ||
<Text><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> | ||
<html><head><meta name="qrichtext" content="1" /><style type="text/css"> | ||
p, li { white-space: pre-wrap; } | ||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> | ||
<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> | ||
<tr> | ||
<td style="border: none;"> | ||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />The short class definition is the only way to introduce a &quot;class&quot; name for an array type:</span></p></td></tr></table></body></html></Text> | ||
</TextCell> | ||
<GraphCell AutoX="true" AutoY="true" style="Graph" MinorX="0.1" Antialiasing="false" MinorY="0.1" Title="Plot by OpenModelica" LogX="false" LogY="false" MajorX="1" MajorY="1" closed="false" YLabel="" Area="wEgAAAAAAADAMAAAAAAAAEBZAAAAAAAAQD4AAAAAAAA=" ShowGraph="false" Grid="true" XLabel="" Legend="false"> | ||
<Input>type Matrix10 = Real [10, 10];</Input> | ||
<Output>{Matrix10}</Output> | ||
</GraphCell> | ||
<TextCell style="Text"> | ||
<Text><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> | ||
<html><head><meta name="qrichtext" content="1" /><style type="text/css"> | ||
p, li { white-space: pre-wrap; } | ||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> | ||
<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> | ||
<tr> | ||
<td style="border: none;"> | ||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />A short class definition is in most cases just a shorter syntax for defining a class that could just as well be defined using the standard inheritance syntax:</span></p></td></tr></table></body></html></Text> | ||
</TextCell> | ||
<GraphCell AutoX="true" AutoY="true" style="Graph" MinorX="0.1" Antialiasing="false" MinorY="0.1" Title="Plot by OpenModelica" LogX="false" LogY="false" MajorX="1" MajorY="1" closed="false" YLabel="" Area="wEgAAAAAAADAMAAAAAAAAEBZAAAAAAAAQD4AAAAAAAA=" ShowGraph="false" Grid="true" XLabel="" Legend="false"> | ||
<Input>type Voltage | ||
extends Real(unit = "V", min = -220.0, max = 220.0); | ||
end Voltage;</Input> | ||
<Output></Output> | ||
</InputCell> | ||
<TextCell style="Text" > | ||
<Text><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;"><br />Which is just the same as this:</p></body></html></Text> | ||
</TextCell> | ||
<InputCell style="Input" closed="true" > | ||
<Input>type Voltage = Real(unit = "V", min = -220.0, max = 220.0);</Input> | ||
<Output></Output> | ||
</InputCell> | ||
<TextCell style="Text" > | ||
<Text><html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-size:8.25pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:Times New Roman; font-size:12pt; color:#000000;"><br />Writing array types is done this short way:</p></body></html></Text> | ||
</TextCell> | ||
<InputCell style="Input" closed="true" > | ||
<Input>type Force3 = Real[3](unit={"N","N","N"});</Input> | ||
<Output></Output> | ||
</InputCell> | ||
<Output>{Voltage}</Output> | ||
</GraphCell> | ||
<TextCell style="Text"> | ||
<Text><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> | ||
<html><head><meta name="qrichtext" content="1" /><style type="text/css"> | ||
p, li { white-space: pre-wrap; } | ||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> | ||
<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> | ||
<tr> | ||
<td style="border: none;"> | ||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Which is just the same as this:</span></p></td></tr></table></body></html></Text> | ||
</TextCell> | ||
<GraphCell AutoX="true" AutoY="true" style="Graph" MinorX="0.1" Antialiasing="false" MinorY="0.1" Title="Plot by OpenModelica" LogX="false" LogY="false" MajorX="1" MajorY="1" closed="false" YLabel="" Area="wEgAAAAAAADAMAAAAAAAAEBZAAAAAAAAQD4AAAAAAAA=" ShowGraph="false" Grid="true" XLabel="" Legend="false"> | ||
<Input>type Voltage = Real(unit = "V", min = -220.0, max = 220.0);</Input> | ||
<Output>{Voltage}</Output> | ||
</GraphCell> | ||
<TextCell style="Text"> | ||
<Text><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> | ||
<html><head><meta name="qrichtext" content="1" /><style type="text/css"> | ||
p, li { white-space: pre-wrap; } | ||
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> | ||
<table border="0" style="-qt-table-type: root; margin-top:5px; margin-bottom:5px; margin-left:5px; margin-right:5px;"> | ||
<tr> | ||
<td style="border: none;"> | ||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Times New Roman'; font-size:12pt; color:#000000;"><br />Writing array types is done this short way:</span></p></td></tr></table></body></html></Text> | ||
</TextCell> | ||
<GraphCell AutoX="true" AutoY="true" style="Graph" MinorX="0.1" Antialiasing="false" MinorY="0.1" Title="Plot by OpenModelica" LogX="false" LogY="false" MajorX="1" MajorY="1" closed="false" YLabel="" Area="wEgAAAAAAADAMAAAAAAAAEBZAAAAAAAAQD4AAAAAAAA=" ShowGraph="false" Grid="true" XLabel="" Legend="false"> | ||
<Input>type Force3 = Real[3](unit={"N","N","N"});</Input> | ||
<Output>{Force3}</Output> | ||
</GraphCell> | ||
</GroupCell> | ||
</GroupCell> | ||
</GroupCell> | ||
</Notebook> |