.
18 |
19 | Main Author 2010-2013, Christoph Höger
20 | */
21 |
22 | #include "osgviewerGTK.hpp"
23 |
24 | int main(int argc, char** argv) {
25 | return run_viewer(proc3d::AnimationContext());
26 | }
27 |
--------------------------------------------------------------------------------
/common/cmake/FindDBUS.cmake:
--------------------------------------------------------------------------------
1 | FIND_PATH( DBUS_INCLUDE_DIR dbus/dbus.h PATH_SUFFIXES /include/dbus-1.0)
2 | FIND_PATH( DBUS_INCLUDE_LIB_DIR dbus/dbus-arch-deps.h PATH_SUFFIXES /lib/dbus-1.0/include /lib64/dbus-1.0/include /lib/x86_64-linux-gnu/dbus-1.0/include/ /lib/i386-linux-gnu/dbus-1.0/include/)
3 |
4 | FIND_LIBRARY(DBUS_LIBRARY NAME dbus-1 PATHS /lib)
5 |
6 | IF( DBUS_INCLUDE_DIR AND DBUS_INCLUDE_LIB_DIR AND DBUS_LIBRARY )
7 | SET( DBUS_FOUND TRUE )
8 | ENDIF( DBUS_INCLUDE_DIR AND DBUS_INCLUDE_LIB_DIR AND DBUS_LIBRARY )
9 |
10 | IF( DBUS_INCLUDE_DIR AND DBUS_INCLUDE_LIB_DIR )
11 | SET( DBUS_INCLUDES ${DBUS_INCLUDE_DIR} ${DBUS_INCLUDE_LIB_DIR} )
12 | ENDIF( DBUS_INCLUDE_DIR AND DBUS_INCLUDE_LIB_DIR )
13 |
14 | IF( DBUS_FOUND )
15 | MESSAGE( STATUS "Found dbus: ${DBUS_LIBRARY}" )
16 | ELSE( DBUS_FOUND )
17 | IF( DBUS_FIND_REQUIRED )
18 | MESSAGE( FATAL_ERROR "Could not find dbus ${DBUS_INCLUDE_LIB_DIR}" )
19 | ENDIF( DBUS_FIND_REQUIRED )
20 | ENDIF( DBUS_FOUND )
21 |
22 |
23 |
--------------------------------------------------------------------------------
/common/cmake/FindGLFW.cmake:
--------------------------------------------------------------------------------
1 | # - Try to find libglfw
2 | # Once done this will define
3 | # LIBGLFW_FOUND - System has LibXml2
4 | # LIBGLFW_INCLUDE_DIRS - The LibXml2 include directories
5 | # LIBGLFW_LIBRARIES - The libraries needed to use LibXml2
6 |
7 | find_path(LIBGLFW_INCLUDE_DIR GL/glfw.h)
8 |
9 | find_library(LIBGLFW_LIBRARY NAMES glfw libglfw)
10 |
11 | set(LIBGLFW_LIBRARIES ${LIBGLFW_LIBRARY} )
12 | set(LIBGLFW_INCLUDE_DIRS ${LIBGLFW_INCLUDE_DIR} )
13 |
14 | include(FindPackageHandleStandardArgs)
15 | # handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE
16 | # if all listed variables are TRUE
17 | find_package_handle_standard_args(libglfw DEFAULT_MSG
18 | LIBGLFW_LIBRARY LIBGLFW_INCLUDE_DIR)
19 |
20 | mark_as_advanced(LIBGLFW_INCLUDE_DIR LIBGLFW_LIBRARY)
--------------------------------------------------------------------------------
/common/cmake/FindGtkGl.cmake:
--------------------------------------------------------------------------------
1 | #use pkg-config to find various modues
2 | INCLUDE(FindPkgConfig OPTIONAL)
3 |
4 | IF(PKG_CONFIG_FOUND)
5 |
6 | INCLUDE(FindPkgConfig)
7 |
8 | PKG_CHECK_MODULES(GTK gtk+-2.0)
9 |
10 | IF(WIN32)
11 | PKG_CHECK_MODULES(GTKGL gtkglext-win32-1.0)
12 | ELSE()
13 | PKG_CHECK_MODULES(GTKGL gtkglext-1.0)
14 | ENDIF()
15 |
16 | ENDIF()
17 |
--------------------------------------------------------------------------------
/common/cmake/FindOMC.cmake:
--------------------------------------------------------------------------------
1 | # Tries to detect omc modelica-library and include dirs, does not search for binary yet
2 |
3 | # This will also search ${CMAKE_PREFIX_PATH}/include automagically
4 | find_path(OMC_INCLUDE_DIR openmodelica.h PATH_SUFFIXES omc/c)
5 |
6 | find_program(OMC_COMPILER NAMES omc)
7 |
8 | # This will _not_ search ${CMAKE_PREFIX_PATH}/lib automagically, we need to give a search hint
9 | find_path(OMC_MOD_LIB_DIR "ModelicaReference/package.mo"
10 | PATHS "${CMAKE_LIBRARY_PATH}/omlibrary"
11 | "${CMAKE_PREFIX_PATH}/lib/omlibrary" /usr/lib/omlibrary)
12 |
13 | # This will also search ${CMAKE_PREFIX_PATH}/lib automagically
14 | find_library(OMC_RUNTIME omcruntime PATH_SUFFIXES omc)
15 |
16 | if ( OMC_INCLUDE_DIR AND OMC_MOD_LIB_DIR AND OMC_RUNTIME AND OMC_COMPILER)
17 | set( OMC_FOUND TRUE )
18 | endif()
19 |
20 | if( OMC_INCLUDE_DIR)
21 | set( OMC_INCLUDES "${OMC_INCLUDE_DIR}")
22 | endif ( OMC_INCLUDE_DIR )
23 |
24 | if( OMC_RUNTIME)
25 | get_filename_component(OMC_LIBRARY_DIR ${OMC_RUNTIME} PATH)
26 | endif( OMC_RUNTIME)
27 |
28 | if( OMC_FOUND )
29 | message( STATUS "Found omc runtime : ${OMC_RUNTIME}" )
30 | message( STATUS "Found omc compiler : ${OMC_COMPILER}" )
31 | else( OMC_FOUND )
32 | if( OMC_FIND_REQUIRED )
33 | message( FATAL_ERROR "Could not find the openmodelica installation" )
34 | endif( OMC_FIND_REQUIRED )
35 | endif( OMC_FOUND )
36 |
37 | # vi:ts=4:sw=4:expandtab
38 |
--------------------------------------------------------------------------------
/examples/multibody/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # Modelica library to install
2 | set(multibody_src "${CMAKE_SOURCE_DIR}/examples/multibody/src/modelica/")
3 |
4 | install(FILES
5 | "${multibody_src}/Internal.mo"
6 | "${multibody_src}/Pendulum.mo"
7 | "${multibody_src}/DoublePendulum.mo"
8 | "${multibody_src}/Engine1b.mo"
9 | DESTINATION "lib/omlibrary-modelica3d")
10 |
--------------------------------------------------------------------------------
/examples/multibody/src/modelica/DoublePendulum.mo:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2012 Christoph Höger, All Rights Reserved
3 |
4 | This file is part of modelica3d
5 | (https://mlcontrol.uebb.tu-berlin.de/redmine/projects/modelica3d-public).
6 |
7 | Licensed under the Modelica License 2
8 | */
9 |
10 | within Modelica.Mechanics.MultiBody.Examples.Elementary;
11 | model DoublePendulum
12 | "Simple double pendulum with two revolute joints and two bodies"
13 |
14 | extends Modelica.Icons.Example;
15 |
16 | /* enable M3D Visualization */
17 | import M3D=ModelicaServices.Modelica3D;
18 |
19 | inner M3D.Controller m3d_control;
20 |
21 | inner Modelica.Mechanics.MultiBody.World world annotation (Placement(
22 | transformation(extent={{-88,0},{-68,20}}, rotation=0)));
23 | Modelica.Mechanics.MultiBody.Joints.Revolute revolute1(useAxisFlange=true,phi(fixed=true),
24 | w(fixed=true)) annotation (Placement(transformation(extent={{-48,0},
25 | {-28,20}}, rotation=0)));
26 | Modelica.Mechanics.Rotational.Components.Damper damper(
27 | d=0.1)
28 | annotation (Placement(transformation(extent={{-48,40},{-28,60}}, rotation=0)));
29 | Modelica.Mechanics.MultiBody.Parts.BodyBox boxBody1(r={0.5,0,0}, width=0.06)
30 | annotation (Placement(transformation(extent={{-10,0},{10,20}}, rotation=0)));
31 | Modelica.Mechanics.MultiBody.Joints.Revolute revolute2(phi(fixed=true), w(
32 | fixed=true)) annotation (Placement(transformation(extent={{32,0},{
33 | 52,20}}, rotation=0)));
34 | Modelica.Mechanics.MultiBody.Parts.BodyBox boxBody2(r={0.5,0,0}, width=0.06)
35 | annotation (Placement(transformation(extent={{74,0},{94,20}}, rotation=0)));
36 | equation
37 |
38 | connect(damper.flange_b, revolute1.axis) annotation (Line(points={{-28,50},{
39 | -24,50},{-24,28},{-38,28},{-38,20}}, color={0,0,0}));
40 | connect(revolute1.support, damper.flange_a) annotation (Line(points={{-44,20},
41 | {-44,28},{-58,28},{-58,50},{-48,50}}, color={0,0,0}));
42 | connect(revolute1.frame_b, boxBody1.frame_a)
43 | annotation (Line(
44 | points={{-28,10},{-10,10}},
45 | color={95,95,95},
46 | thickness=0.5));
47 | connect(revolute2.frame_b, boxBody2.frame_a)
48 | annotation (Line(
49 | points={{52,10},{74,10}},
50 | color={95,95,95},
51 | thickness=0.5));
52 | connect(boxBody1.frame_b, revolute2.frame_a)
53 | annotation (Line(
54 | points={{10,10},{32,10}},
55 | color={95,95,95},
56 | thickness=0.5));
57 | connect(world.frame_b, revolute1.frame_a)
58 | annotation (Line(
59 | points={{-68,10},{-48,10}},
60 | color={95,95,95},
61 | thickness=0.5));
62 | annotation (
63 | experiment(StopTime=3),
64 | Diagram(coordinateSystem(
65 | preserveAspectRatio=true,
66 | extent={{-100,-100},{100,100}},
67 | grid={2,2}), graphics),
68 | Documentation(info="
69 |
70 | This example demonstrates that by using joint and body
71 | elements animation is automatically available. Also the revolute
72 | joints are animated. Note, that animation of every component
73 | can be switched of by setting the first parameter animation
74 | to false or by setting enableAnimation in the world
75 | object to false to switch off animation of all components.
76 |
77 |
78 |
79 |
81 | |
82 |
83 | "));
84 | end DoublePendulum;
85 |
--------------------------------------------------------------------------------
/examples/multibody/src/modelica/Engine1b.mo:
--------------------------------------------------------------------------------
1 | within Modelica.Mechanics.MultiBody.Examples.Loops;
2 | model Engine1b
3 | "Model of one cylinder engine with gas force and preparation for assembly joint JointRRP"
4 | import SI = Modelica.SIunits;
5 | extends Modelica.Icons.Example;
6 |
7 | extends Utilities.Engine1bBase;
8 |
9 | /* enable M3D Visualization */
10 | import M3D=ModelicaServices.Modelica3D;
11 | inner M3D.Controller m3d_control;
12 |
13 | Joints.RevolutePlanarLoopConstraint B2(
14 | n={1,0,0},
15 | cylinderLength=0.02,
16 | cylinderDiameter=0.05) annotation (Placement(transformation(extent={{40,20},
17 | {60,40}}, rotation=0)));
18 | Modelica.Mechanics.MultiBody.Joints.Revolute B1(
19 | n={1,0,0},
20 | cylinderLength=0.02,
21 | cylinderDiameter=0.05)
22 | annotation (Placement(transformation(extent={{40,-20},
23 | {60,0}}, rotation=0)));
24 | Modelica.Mechanics.MultiBody.Joints.Prismatic Cylinder(useAxisFlange=true,
25 | boxWidth=0.02, n={0,-1,0})
26 | annotation (Placement(transformation(
27 | origin={50,97},
28 | extent={{-10,-10},{10,10}},
29 | rotation=270)));
30 | Parts.FixedTranslation Rod1(r={0,0.2,0}, animation=false)
31 | annotation (Placement(transformation(
32 | origin={70,10},
33 | extent={{-10,-10},{10,10}},
34 | rotation=90)));
35 | Parts.FixedTranslation Rod3(r={0,-0.1,0}, animation=false)
36 | annotation (Placement(transformation(
37 | origin={50,58},
38 | extent={{10,-10},{-10,10}},
39 | rotation=90)));
40 | equation
41 | connect(B1.frame_b, Rod1.frame_a) annotation (Line(
42 | points={{60,-10},{70,-10},{70,0}},
43 | color={95,95,95},
44 | thickness=0.5));
45 | connect(Rod1.frame_b, B2.frame_b) annotation (Line(
46 | points={{70,20},{70,30},{60,30}},
47 | color={95,95,95},
48 | thickness=0.5));
49 | connect(Cylinder.frame_b, Rod3.frame_a) annotation (Line(
50 | points={{50,87},{50,68}},
51 | color={95,95,95},
52 | thickness=0.5));
53 | connect(B2.frame_a, Rod3.frame_b) annotation (Line(
54 | points={{40,30},{30,30},{30,44},{50,44},{50,48}},
55 | color={95,95,95},
56 | thickness=0.5));
57 | connect(cylPosition.frame_b, Cylinder.frame_a) annotation (Line(
58 | points={{-20.5,110},{50,110},{50,107}},
59 | color={95,95,95},
60 | thickness=0.5));
61 | connect(gasForce.flange_a, Cylinder.support) annotation (Line(points={{119,
62 | 107},{119,112},{70,112},{70,101},{56,101}}, color={0,127,0}));
63 | connect(Cylinder.axis, gasForce.flange_b) annotation (Line(points={{56,89},{
64 | 71,89},{71,80},{119,80},{119,87}}, color={0,127,0}));
65 | connect(Piston.frame_a, Rod3.frame_a) annotation (Line(
66 | points={{120,63},{120,75},{50,75},{50,68}},
67 | color={95,95,95},
68 | thickness=0.5));
69 | connect(B1.frame_b, Rod2.frame_a) annotation (Line(
70 | points={{60,-10},{120,-10},{120,0}},
71 | color={95,95,95},
72 | thickness=0.5));
73 | connect(Mid.frame_b, B1.frame_a) annotation (Line(
74 | points={{50,-43},{57,-43},{57,-28},{30,-28},{30,-10},{40,-10}},
75 | color={95,95,95},
76 | thickness=0.5));
77 | annotation (
78 | experiment(StopTime=0.5),
79 | Diagram(coordinateSystem(
80 | preserveAspectRatio=true,
81 | extent={{-100,-120},{150,120}},
82 | grid={1,1}), graphics={
83 | Rectangle(
84 | extent={{3,117},{88,-23}},
85 | lineColor={255,0,0},
86 | lineThickness=0.5),
87 | Text(
88 | extent={{65,-30},{145,-39}},
89 | lineColor={255,0,0},
90 | lineThickness=0.5,
91 | textString="jointRRP in model"),
92 | Text(
93 | extent={{66,-34},{141,-52}},
94 | lineColor={255,0,0},
95 | lineThickness=0.5,
96 | textString="Loops.Engine1b_analytic")}),
97 | Documentation(info="
98 |
99 | This is a model of the mechanical part of one cylinder of an engine.
100 | It is similiar to
101 | Loops.Engine1a.
102 | The difference is that a simple
103 | model for the gas force in the cylinder is added and that the
104 | model is restructured in such a way, that the central part of
105 | the planar kinematic loop can be easily replaced by the
106 | assembly joint \"Modelica.Mechanics.MultiBody.Joints.Assemblies.JointRRP\".
107 | This exchange of the kinematic loop is shown in
108 | Loops.Engine1b_analytic.
109 | The advantage of using JointRRP is, that the
110 | non-linear algebraic equation of this loop is solved analytically, and
111 | not numerically as in this model (Engine1b).
112 |
113 |
114 | An animation of this example is shown in the figure below.
115 |
116 |
117 |
118 |
119 | "));
120 | end Engine1b;
121 |
--------------------------------------------------------------------------------
/examples/multibody/src/modelica/Internal.mo:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2012 Christoph Höger, All Rights Reserved
3 |
4 | This file is part of modelica3d
5 | (https://mlcontrol.uebb.tu-berlin.de/redmine/projects/modelica3d-public).
6 |
7 | Licensed under the Modelica License 2
8 | */
9 |
10 | within Modelica.Utilities;
11 | package Internal
12 | "Internal components that a user should usually not directly utilize"
13 | partial package PartialModelicaServices
14 | "Interfaces of components requiring a tool specific implementation"
15 | package Animation "Models and functions for 3-dim. animation"
16 |
17 | partial model PartialShape
18 | "Different visual shapes with variable size; all data have to be set as modifiers"
19 |
20 | import SI = Modelica.SIunits;
21 | import Modelica.Mechanics.MultiBody.Frames;
22 | import Modelica.Mechanics.MultiBody.Types;
23 |
24 | parameter Types.ShapeType shapeType="box"
25 | "Type of shape (box, sphere, cylinder, pipecylinder, cone, pipe, beam, gearwheel, spring)";
26 | input Frames.Orientation R=Frames.nullRotation()
27 | "Orientation object to rotate the world frame into the object frame"
28 | annotation(Dialog);
29 | input SI.Position r[3]={0,0,0}
30 | "Position vector from origin of world frame to origin of object frame, resolved in world frame"
31 | annotation(Dialog);
32 | input SI.Position r_shape[3]={0,0,0}
33 | "Position vector from origin of object frame to shape origin, resolved in object frame"
34 | annotation(Dialog);
35 | input Real lengthDirection[3](each final unit="1")={1,0,0}
36 | "Vector in length direction, resolved in object frame"
37 | annotation(Dialog);
38 | input Real widthDirection[3](each final unit="1")={0,1,0}
39 | "Vector in width direction, resolved in object frame"
40 | annotation(Dialog);
41 | input SI.Length length=0 "Length of visual object" annotation(Dialog);
42 | input SI.Length width=0 "Width of visual object" annotation(Dialog);
43 | input SI.Length height=0 "Height of visual object" annotation(Dialog);
44 | input Types.ShapeExtra extra=0.0
45 | "Additional size data for some of the shape types" annotation(Dialog);
46 | input Real color[3]={255,0,0} "Color of shape" annotation(Dialog);
47 | input Types.SpecularCoefficient specularCoefficient = 0.7
48 | "Reflection of ambient light (= 0: light is completely absorbed)"
49 | annotation(Dialog);
50 | // Real rxry[3, 2];
51 | annotation (
52 | Icon(coordinateSystem(
53 | preserveAspectRatio=true,
54 | extent={{-100,-100},{100,100}},
55 | grid={2,2}), graphics={
56 | Rectangle(
57 | extent={{-100,-100},{80,60}},
58 | lineColor={0,0,255},
59 | fillColor={255,255,255},
60 | fillPattern=FillPattern.Solid),
61 | Polygon(
62 | points={{-100,60},{-80,100},{100,100},{80,60},{-100,60}},
63 | lineColor={0,0,255},
64 | fillColor={192,192,192},
65 | fillPattern=FillPattern.Solid),
66 | Polygon(
67 | points={{100,100},{100,-60},{80,-100},{80,60},{100,100}},
68 | lineColor={0,0,255},
69 | fillColor={160,160,164},
70 | fillPattern=FillPattern.Solid),
71 | Text(
72 | extent={{-100,-100},{80,60}},
73 | lineColor={0,0,0},
74 | textString="%shapeType"),
75 | Text(
76 | extent={{-132,160},{128,100}},
77 | textString="%name",
78 | lineColor={0,0,255})}),
79 | Documentation(info="
80 |
81 |
82 | This model is documented at
83 | Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
84 |
85 |
86 |
87 | "));
88 |
89 | import Bus=ModelicaServices.modbus;
90 | import ModelicaServices.modcount;
91 |
92 | import Id=ModelicaServices.modcount.HeapString;
93 | import M3D=ModelicaServices.Modelica3D;
94 | import Modelica.Math.Vectors.isEqual;
95 |
96 | function shapeDescrTo3D
97 | input M3D.State state;
98 | input String descr;
99 | input Real length, width, height;
100 | input Real[3] at;
101 | output Id id;
102 | protected
103 |
104 | algorithm
105 | if (descr == "box") then
106 | id := M3D.createBoxAt(state, width, height, length, at[1], at[2], at[3]);
107 | elseif (descr == "cone") then
108 | id := M3D.createConeAt(state, length, width, at[1], at[2], at[3] );
109 | elseif (descr == "sphere") then
110 | id := M3D.createSphere(state, length);
111 | elseif (descr == "cylinder") then
112 | id := M3D.createCylinderAt(state, length, width, at[1], at[2], at[3]);
113 | elseif (descr == "pipecylinder") then
114 | // not yet supported
115 | Modelica.Utilities.Streams.print("Error: Visualization of pipecylinders has not been implemented yet!");
116 | id := Id("UNKNOWN");
117 | elseif (descr == "pipe") then
118 | // not yet supported
119 | Modelica.Utilities.Streams.print("Error: Visualization of pipes has not been implemented yet!");
120 | id := Id("UNKNOWN");
121 | elseif (descr == "beam") then
122 | // not yet supported
123 | Modelica.Utilities.Streams.print("Error: Visualization of beams has not been implemented yet!");
124 | id := Id("UNKNOWN");
125 | elseif (descr == "gearwheel") then
126 | // not yet supported
127 | Modelica.Utilities.Streams.print("Error: Visualization of gearwheels has not been implemented yet!");
128 | id := Id("UNKNOWN");
129 | elseif (descr == "spring") then
130 | // not yet supported
131 | Modelica.Utilities.Streams.print("Error: Visualization of springs has not been implemented yet!");
132 | id := Id("UNKNOWN");
133 | else
134 | // assume it is a filename
135 | id := M3D.loadFromFile(state, Modelica.Utilities.Files.fullPathName(descr), at[1], at[2], at[3]);
136 | end if;
137 |
138 | end shapeDescrTo3D;
139 |
140 | outer M3D.Controller m3d_control;
141 |
142 | Id id;
143 | Id mat;
144 | modcount.Context initContext = modcount.Context();
145 | String res;
146 |
147 | discrete Real[3] pos;
148 | discrete Real[3,3] oldT;
149 | discrete Boolean moved;
150 | discrete Boolean rotated;
151 | // disable initial equation for now, since there is some bug in initial residuals
152 | //initial equation
153 | // pre(oldT) = R.T;
154 | // pre(pos) = r + Frames.resolve1(R, r_shape);
155 | initial algorithm
156 | if modcount.get(initContext) <> 1 then
157 | id := shapeDescrTo3D(m3d_control.state, shapeType, length, width, height, lengthDirection);
158 | mat := M3D.createMaterial(m3d_control.state);
159 | M3D.setAmbientColor(m3d_control.state, mat, color[1] / 255, color[2] / 255, color[3] / 255, 1.0, time);
160 | M3D.setSpecularColor(m3d_control.state, mat, specularCoefficient * (color[1] / 255),
161 | specularCoefficient * color[2] / 255, specularCoefficient * color[3] / 255, 1.0, time);
162 |
163 | M3D.applyMaterial(m3d_control.state, id, mat);
164 | modcount.set(initContext, 1);
165 | end if;
166 | algorithm
167 | when m3d_control.send and modcount.get(initContext) == 1 then
168 |
169 | // check for rotation
170 | rotated := not Modelica.Math.Matrices.isEqual(R.T, oldT);
171 | if noEvent(rotated) then
172 | res := M3D.rotate(m3d_control.state, id, R.T, time);
173 | end if;
174 | oldT := R.T;
175 |
176 | // check for translation
177 | pos := r + Frames.resolve1(R, r_shape);
178 | moved := not Modelica.Math.Vectors.isEqual(pos, pre(pos));
179 | if noEvent(moved) then
180 | res := M3D.moveTo(m3d_control.state, id, pos, time);
181 | end if;
182 |
183 | end when;
184 | end PartialShape;
185 | end Animation;
186 |
187 | annotation (Documentation(info="
188 |
189 |
190 | This package contains interfaces of a set of functions and models used in the
191 | Modelica Standard Library that requires a tool specific implementation.
192 | There is an associated package called ModelicaServices. A tool vendor
193 | should provide a proper implementation of this library for the corresponding
194 | tool. The default implementation is \"do nothing\".
195 | In the Modelica Standard Library, the models and functions of ModelicaServices
196 | are used.
197 |
198 |
199 | "));
200 | end PartialModelicaServices;
201 |
202 | protected
203 | package FileSystem
204 | "Internal package with external functions as interface to the file system"
205 | extends Modelica.Icons.Library;
206 |
207 | function mkdir "Make directory (POSIX: 'mkdir')"
208 | extends Modelica.Icons.Function;
209 | input String directoryName "Make a new directory";
210 | external "C" ModelicaInternal_mkdir(directoryName);
211 |
212 | annotation(Library="ModelicaExternalC");
213 | end mkdir;
214 |
215 | function rmdir "Remove empty directory (POSIX function 'rmdir')"
216 | extends Modelica.Icons.Function;
217 | input String directoryName "Empty directory to be removed";
218 | external "C" ModelicaInternal_rmdir(directoryName);
219 |
220 | annotation(Library="ModelicaExternalC");
221 | end rmdir;
222 |
223 | function stat "Inquire file information (POSIX function 'stat')"
224 | extends Modelica.Icons.Function;
225 | input String name "Name of file, directory, pipe etc.";
226 | output Types.FileType fileType "Type of file";
227 | external "C" fileType= ModelicaInternal_stat(name);
228 |
229 | annotation(Library="ModelicaExternalC");
230 | end stat;
231 |
232 | function rename "Rename existing file or directory (C function 'rename')"
233 | extends Modelica.Icons.Function;
234 | input String oldName "Current name";
235 | input String newName "New name";
236 | external "C" ModelicaInternal_rename(oldName, newName);
237 |
238 | annotation(Library="ModelicaExternalC");
239 | end rename;
240 |
241 | function removeFile "Remove existing file (C function 'remove')"
242 | extends Modelica.Icons.Function;
243 | input String fileName "File to be removed";
244 | external "C" ModelicaInternal_removeFile(fileName);
245 |
246 | annotation(Library="ModelicaExternalC");
247 | end removeFile;
248 |
249 | function copyFile
250 | "Copy existing file (C functions 'fopen', 'getc', 'putc', 'fclose')"
251 | extends Modelica.Icons.Function;
252 | input String fromName "Name of file to be copied";
253 | input String toName "Name of copy of file";
254 | external "C" ModelicaInternal_copyFile(fromName, toName);
255 |
256 | annotation(Library="ModelicaExternalC");
257 | end copyFile;
258 |
259 | function readDirectory
260 | "Read names of a directory (POSIX functions opendir, readdir, closedir)"
261 | extends Modelica.Icons.Function;
262 | input String directory
263 | "Name of the directory from which information is desired";
264 | input Integer nNames
265 | "Number of names that are returned (inquire with getNumberOfFiles)";
266 | output String names[nNames]
267 | "All file and directory names in any order from the desired directory";
268 | external "C" ModelicaInternal_readDirectory(directory,nNames,names);
269 |
270 | annotation(Library="ModelicaExternalC");
271 | end readDirectory;
272 |
273 | function getNumberOfFiles
274 | "Get number of files and directories in a directory (POSIX functions opendir, readdir, closedir)"
275 | extends Modelica.Icons.Function;
276 | input String directory "Directory name";
277 | output Integer result
278 | "Number of files and directories present in 'directory'";
279 | external "C" result = ModelicaInternal_getNumberOfFiles(directory);
280 |
281 | annotation(Library="ModelicaExternalC");
282 | end getNumberOfFiles;
283 |
284 | annotation (
285 | Documentation(info="
286 |
287 | Package Internal.FileSystem is an internal package that contains
288 | low level functions as interface to the file system.
289 | These functions should not be called directly in a scripting
290 | environment since more convenient functions are provided
291 | in packages Files and Systems.
292 |
293 |
294 | Note, the functions in this package are direct interfaces to
295 | functions of POSIX and of the standard C library. Errors
296 | occuring in these functions are treated by triggering
297 | a Modelica assert. Therefore, the functions in this package
298 | return only for a successful operation. Furthermore, the
299 | representation of a string is hidden by this interface,
300 | especially if the operating system supports Unicode characters.
301 |
302 | "));
303 | end FileSystem;
304 | end Internal;
305 |
--------------------------------------------------------------------------------
/examples/multibody/src/modelica/Pendulum.mo:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2012 Christoph Höger, All Rights Reserved
3 |
4 | This file is part of modelica3d
5 | (https://mlcontrol.uebb.tu-berlin.de/redmine/projects/modelica3d-public).
6 |
7 | Licensed under the Modelica License 2
8 | */
9 |
10 | within Modelica.Mechanics.MultiBody.Examples.Elementary;
11 | model Pendulum "Simple pendulum with one revolute joint and one body"
12 |
13 | extends Modelica.Icons.Example;
14 |
15 | /* enable M3D Visualization */
16 | import M3D=ModelicaServices.Modelica3D;
17 |
18 | inner M3D.Controller m3d_control;
19 |
20 | inner Modelica.Mechanics.MultiBody.World world(gravityType=Modelica.Mechanics.MultiBody.Types.GravityTypes.
21 | UniformGravity) annotation (Placement(transformation(extent={{-60,0},{
22 | -40,20}}, rotation=0)));
23 | Modelica.Mechanics.MultiBody.Joints.Revolute rev(n={0,0,1},useAxisFlange=true,
24 | phi(fixed=true),
25 | w(fixed=true)) annotation (Placement(transformation(extent={{
26 | -20,0},{0,20}}, rotation=0)));
27 | Modelica.Mechanics.Rotational.Components.Damper damper(
28 | d=0.1)
29 | annotation (Placement(transformation(extent={{-20,40},{0,60}}, rotation=0)));
30 | Modelica.Mechanics.MultiBody.Parts.Body body(m=1.0, r_CM={0.5,0,0})
31 | annotation (Placement(transformation(extent={{20,0},{40,20}}, rotation=0)));
32 | equation
33 | connect(world.frame_b, rev.frame_a)
34 | annotation (Line(
35 | points={{-40,10},{-20,10}},
36 | color={95,95,95},
37 | thickness=0.5));
38 | connect(damper.flange_b, rev.axis) annotation (Line(points={{0,50},{4,50},{4,
39 | 26},{-10,26},{-10,20}}, color={0,0,0}));
40 | connect(rev.support, damper.flange_a) annotation (Line(points={{-16,20},{-16,
41 | 26},{-28,26},{-28,50},{-20,50}}, color={0,0,0}));
42 | connect(body.frame_a, rev.frame_b) annotation (Line(
43 | points={{20,10},{0,10}},
44 | color={95,95,95},
45 | thickness=0.5));
46 | annotation (
47 | experiment(StopTime=5),
48 | Diagram(coordinateSystem(
49 | preserveAspectRatio=true,
50 | extent={{-100,-100},{100,100}},
51 | grid={2,2}), graphics),
52 | Documentation(info="
53 |
54 | This simple model demonstrates that by just dragging components
55 | default animation is defined that shows the structure of the
56 | assembled system.
57 |
58 |
60 |
61 | "));
62 | end Pendulum;
63 |
--------------------------------------------------------------------------------
/lib/mod3d/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(mod3d_src "${CMAKE_SOURCE_DIR}/lib/mod3d/src/")
2 |
3 | if(USE_OMC)
4 | # Modelica library to install
5 | install(FILES "${mod3d_src}/modelica/Modelica3D\ 3.2.1/package.mo"
6 | DESTINATION "${OMC_MOD_LIB_DIR}/${MODELICA_SERVICES_LIBRARY}/Modelica3D")
7 | install(FILES "${mod3d_src}/modelica/package.mo"
8 | DESTINATION "${OMC_MOD_LIB_DIR}/${MODELICA_SERVICES_LIBRARY}")
9 | endif(USE_OMC)
10 |
--------------------------------------------------------------------------------
/lib/mod3d/src/modelica/Modelica3D 3.2.1/package.mo:
--------------------------------------------------------------------------------
1 | within ModelicaServices;
2 | package Modelica3D
3 | extends Modelica.Icons.Package;
4 |
5 | import Id = ModelicaServices.modcount.HeapString;
6 | import ModelicaServices.modcount.{Context,HeapString,getString,setString};
7 |
8 | import ModelicaServices.modbus.{Connection,Message,sendMessage,addInteger,addReal,addString};
9 |
10 | constant String TARGET = "de.tuberlin.uebb.modelica3d.server";
11 | constant String OBJECT = "/de/tuberlin/uebb/modelica3d/server";
12 | constant String INTERFACE = "de.tuberlin.uebb.modelica3d.api";
13 |
14 | class Controller
15 | discrete Connection conn = Connection("de.tuberlin.uebb.modelica3d.client");
16 | discrete Context context = Context();
17 |
18 | parameter Integer framerate = 30;
19 | parameter Modelica.SIunits.Time updateInterval = 1 / framerate;
20 | parameter Boolean autostop = true;
21 |
22 | output Boolean send;
23 |
24 | equation
25 | send = sample(1e-08, updateInterval);
26 |
27 | algorithm
28 | when terminal() then
29 | if autostop then stop(conn, context); end if;
30 | end when;
31 | annotation (
32 | defaultComponentName="m3d_control",
33 | defaultComponentPrefixes="inner",
34 | missingInnerMessage="No \"m3d_control\" component is defined.");
35 | end Controller;
36 |
37 | function objectId
38 | input String s;
39 | output Id id = HeapString(s);
40 | end objectId;
41 |
42 |
43 | function createMaterial
44 | input Connection conn;
45 | input Context context;
46 | input Id id;
47 | protected
48 | Message msg = Message(TARGET, OBJECT, INTERFACE, "make_material");
49 | algorithm
50 | setString(id,"material_" + String(modcount.increase_get(context)));
51 | addString(msg, "reference", getString(id));
52 | sendMessage(conn, msg);
53 | end createMaterial;
54 |
55 |
56 | function applyMaterial
57 | input Connection conn;
58 | input Context context;
59 | input Id obj;
60 | input Id mat;
61 | output String res;
62 | protected
63 | Message msg = Message(TARGET, OBJECT, INTERFACE, "apply_material");
64 | algorithm
65 | addString(msg, "reference", getString(obj));
66 | addString(msg, "material", getString(mat));
67 | res := sendMessage(conn, msg);
68 | end applyMaterial;
69 |
70 |
71 | function createBox
72 | input Connection conn;
73 | input Context context;
74 | input Real length, width, height;
75 | input Id id;
76 | protected
77 | Message msg = Message(TARGET, OBJECT, INTERFACE, "make_box");
78 | algorithm
79 | setString(id,HeapString("box_" + String(modcount.increase_get(context))));
80 | addString(msg, "reference", getString(id));
81 | addReal(msg, "length", length);
82 | addReal(msg, "width", width);
83 | addReal(msg, "height", height);
84 | sendMessage(conn, msg);
85 | end createBox;
86 |
87 |
88 | function createBoxAt
89 | input Connection conn;
90 | input Context context;
91 | input Real length, width, height;
92 | input Real tx,ty,tz;
93 | input Id id;
94 | protected
95 | Message msg = Message(TARGET, OBJECT, INTERFACE, "make_box");
96 | algorithm
97 | setString(id,"box_" + String(modcount.increase_get(context)));
98 | addString(msg, "reference", getString(id));
99 | addReal(msg, "length", length);
100 | addReal(msg, "width", width);
101 | addReal(msg, "height", height);
102 | addReal(msg, "tx", tx);
103 | addReal(msg, "ty", ty);
104 | addReal(msg, "tz", tz);
105 | sendMessage(conn, msg);
106 | end createBoxAt;
107 |
108 | function loadFromFile
109 | input Connection conn;
110 | input Context context;
111 | input String fileName;
112 | input Real tx,ty,tz;
113 | input Id id;
114 | protected
115 | Message msg = Message(TARGET, OBJECT, INTERFACE, "loadFromFile");
116 | algorithm
117 | setString(id,"file_" + String(modcount.increase_get(context)));
118 | addString(msg, "reference", getString(id));
119 | addString(msg, "fileName", fileName);
120 | addReal(msg, "tx", tx);
121 | addReal(msg, "ty", ty);
122 | addReal(msg, "tz", tz);
123 | sendMessage(conn, msg);
124 | end loadFromFile;
125 |
126 |
127 | function createSphere
128 | input Connection conn;
129 | input Context context;
130 | input Real size;
131 | input Id id;
132 | protected
133 | Message msg = Message(TARGET, OBJECT, INTERFACE, "make_sphere");
134 | algorithm
135 | setString(id,"sphere_" + String(modcount.increase_get(context)));
136 | addString(msg, "reference", getString(id));
137 | addReal(msg, "size", size);
138 | sendMessage(conn, msg);
139 | end createSphere;
140 |
141 |
142 | function createCylinder
143 | input Connection conn;
144 | input Context context;
145 | input Real height;
146 | input Real diameter;
147 | input Id id;
148 | protected
149 | Message msg = Message(TARGET, OBJECT, INTERFACE, "make_cylinder");
150 | algorithm
151 | setString(id,"cylinder_" + String(modcount.increase_get(context)));
152 | addString(msg, "reference", getString(id));
153 | addReal(msg, "height", height);
154 | addReal(msg, "diameter", diameter);
155 | sendMessage(conn, msg);
156 | end createCylinder;
157 |
158 |
159 | function createCylinderAt
160 | input Connection conn;
161 | input Context context;
162 | input Real height;
163 | input Real diameter;
164 | input Real x,y,z;
165 | input Id id;
166 | protected
167 | Message msg = Message(TARGET, OBJECT, INTERFACE, "make_cylinder");
168 | algorithm
169 | setString(id,"cylinder_" + String(modcount.increase_get(context)));
170 | addString(msg, "reference", getString(id));
171 | addReal(msg, "height", height);
172 | addReal(msg, "diameter", diameter);
173 | addReal(msg, "x", x);
174 | addReal(msg, "y", y);
175 | addReal(msg, "z", z);
176 | sendMessage(conn, msg);
177 | end createCylinderAt;
178 |
179 |
180 | function createCone
181 | input Connection conn;
182 | input Context context;
183 | input Real height;
184 | input Real diameter;
185 | input Id id;
186 | protected
187 | Message msg = Message(TARGET, OBJECT, INTERFACE, "make_cone");
188 | algorithm
189 | setString(id,"cone_" + String(modcount.increase_get(context)));
190 | addString(msg, "reference", getString(id));
191 | addReal(msg, "height", height);
192 | addReal(msg, "diameter", diameter);
193 | sendMessage(conn, msg);
194 | end createCone;
195 |
196 |
197 | function createConeAt
198 | input Connection conn;
199 | input Context context;
200 | input Real height;
201 | input Real diameter;
202 | input Real x,y,z;
203 | input Id id;
204 | protected
205 | Message msg = Message(TARGET, OBJECT, INTERFACE, "make_cone");
206 | algorithm
207 | setString(id,"cone_" + String(modcount.increase_get(context)));
208 | addString(msg, "reference", getString(id));
209 | addReal(msg, "height", height);
210 | addReal(msg, "diameter", diameter);
211 | addReal(msg, "x", x);
212 | addReal(msg, "y", y);
213 | addReal(msg, "z", z);
214 | sendMessage(conn, msg);
215 | end createConeAt;
216 |
217 |
218 | function moveTo
219 | input Connection conn;
220 | input Context context;
221 | input Id id;
222 | input Real p[3];
223 | input Real t;
224 | output String r;
225 | protected
226 | Message msg = Message(TARGET, OBJECT, INTERFACE, "move_to");
227 | algorithm
228 | addString(msg, "reference", getString(id));
229 | addReal(msg, "x", p[1]);
230 | addReal(msg, "y", p[2]);
231 | addReal(msg, "z", p[3]);
232 | addReal(msg, "t", t);
233 | r := sendMessage(conn, msg);
234 | end moveTo;
235 |
236 |
237 | function moveZ
238 | input Connection conn;
239 | input Context context;
240 | input Id id;
241 | input Real z;
242 | input Real t;
243 | output String r;
244 | protected
245 | Message msg = Message(TARGET, OBJECT, INTERFACE, "move_to");
246 | algorithm
247 | addString(msg, "reference", getString(id));
248 | addReal(msg, "z", z);
249 | addReal(msg, "t", t);
250 | r := sendMessage(conn, msg);
251 | end moveZ;
252 |
253 |
254 | function scale
255 | input Connection conn;
256 | input Context context;
257 | input Id id;
258 | input Real x,y,z;
259 | input Real t;
260 | output String r;
261 | protected
262 | Message msg = Message(TARGET, OBJECT, INTERFACE, "scale");
263 | algorithm
264 | addString(msg, "reference", getString(id));
265 | addReal(msg, "x", x);
266 | addReal(msg, "y", y);
267 | addReal(msg, "z", z);
268 | addReal(msg, "t", t);
269 | r := sendMessage(conn, msg);
270 | end scale;
271 |
272 |
273 | function scaleZ
274 | input Connection conn;
275 | input Context context;
276 | input Id id;
277 | input Real z;
278 | input Real t;
279 | output String r;
280 | protected
281 | Message msg = Message(TARGET, OBJECT, INTERFACE, "scale");
282 | algorithm
283 | addString(msg, "reference", getString(id));
284 | addReal(msg, "z", z);
285 | addReal(msg, "t", t);
286 | r := sendMessage(conn, msg);
287 | end scaleZ;
288 |
289 |
290 | function setAmbientColor
291 | input Connection conn;
292 | input Context context;
293 | input Id id;
294 | input Real r,g,b,a;
295 | input Real t;
296 | output String res;
297 | protected
298 | Message msg = Message(TARGET, OBJECT, INTERFACE, "set_ambient_color");
299 | algorithm
300 | addString(msg, "reference", getString(id));
301 | addReal(msg, "r", r);
302 | addReal(msg, "g", g);
303 | addReal(msg, "b", b);
304 | addReal(msg, "a", a);
305 | addReal(msg, "t", t);
306 | res := sendMessage(conn, msg);
307 | end setAmbientColor;
308 |
309 |
310 | function setDiffuseColor
311 | input Connection conn;
312 | input Context context;
313 | input Id id;
314 | input Real r,g,b,a;
315 | input Real t;
316 | output String res;
317 | protected
318 | Message msg = Message(TARGET, OBJECT, INTERFACE, "set_diffuse_color");
319 | algorithm
320 | addString(msg, "reference", getString(id));
321 | addReal(msg, "r", r);
322 | addReal(msg, "g", g);
323 | addReal(msg, "b", b);
324 | addReal(msg, "a", a);
325 | addReal(msg, "t", t);
326 | res := sendMessage(conn, msg);
327 | end setDiffuseColor;
328 |
329 |
330 | function setSpecularColor
331 | input Connection conn;
332 | input Context context;
333 | input Id id;
334 | input Real r,g,b,a;
335 | input Real t;
336 | output String res;
337 | protected
338 | Message msg = Message(TARGET, OBJECT, INTERFACE, "set_specular_color");
339 | algorithm
340 | addString(msg, "reference", getString(id));
341 | addReal(msg, "r", r);
342 | addReal(msg, "g", g);
343 | addReal(msg, "b", b);
344 | addReal(msg, "a", a);
345 | addReal(msg, "t", t);
346 | res := sendMessage(conn, msg);
347 | end setSpecularColor;
348 |
349 |
350 | function setMatProperty
351 | input Connection conn;
352 | input Context context;
353 | input Id id;
354 | input String property;
355 | input Real value;
356 | input Real t;
357 | output String res;
358 | protected
359 | Message msg = Message(TARGET, OBJECT, INTERFACE, "set_material_property");
360 | algorithm
361 | addString(msg, "reference", getString(id));
362 | addString(msg, "prop", property);
363 | addReal(msg, "value", value);
364 | addReal(msg, "t", t);
365 | res := sendMessage(conn, msg);
366 | end setMatProperty;
367 |
368 |
369 | function loadSceneFromFile
370 | input Connection conn;
371 | input Context context;
372 | input String fileName;
373 | output String res;
374 | protected
375 | Message msg = Message(TARGET, OBJECT, INTERFACE, "load_scene");
376 | algorithm
377 | addString(msg, "filepath", fileName);
378 | res := sendMessage(conn, msg);
379 | end loadSceneFromFile;
380 |
381 |
382 | function rotate
383 | input Connection conn;
384 | input Context context;
385 | input Id id;
386 | input Real[3,3] R;
387 | input Real t;
388 | output String r;
389 | protected
390 | Message msg = Message(TARGET, OBJECT, INTERFACE, "rotate");
391 | algorithm
392 | addString(msg, "reference", getString(id));
393 |
394 | /* arrays not yet supported by dbus layer */
395 | for i in 1:3 loop
396 | for j in 1:3 loop
397 | addReal(msg, "R_" + String(i) + "_" + String(j), R[i,j]);
398 | end for;
399 | end for;
400 |
401 | addReal(msg, "t", t);
402 | r := sendMessage(conn, msg);
403 | end rotate;
404 |
405 |
406 | function stop
407 | input Connection conn;
408 | input Context context;
409 | output String r;
410 | protected
411 | Message msg = Message(TARGET, OBJECT, INTERFACE, "stop");
412 | algorithm
413 | r := sendMessage(conn, msg);
414 | end stop;
415 |
416 |
417 | partial model PartialShape
418 | "Different visual shapes with variable size; all data have to be set as modifiers"
419 | extends
420 | Modelica.Utilities.Internal.PartialModelicaServices.Animation.PartialShape;
421 |
422 | import Bus = ModelicaServices.modbus;
423 | import ModelicaServices.modcount;
424 | import Id = ModelicaServices.modcount.HeapString;
425 | import Modelica.Mechanics.MultiBody.Frames;
426 |
427 | function shapeDescrTo3D
428 | input Connection conn;
429 | input Context context;
430 | input String descr;
431 | input Real length, width, height;
432 | input Real[3] at;
433 | input Real extra;
434 | input Id id;
435 | algorithm
436 |
437 | if (descr == "box") then
438 | createBoxAt(conn, context, width, height, length, at[1], at[2], at[3], id);
439 | elseif (descr == "cone") then
440 | createConeAt(conn, context, length, width, at[1], at[2], at[3], id);
441 | elseif (descr == "sphere") then
442 | createSphere(conn, context, length, id);
443 | elseif (descr == "cylinder") then
444 | createCylinderAt(conn, context, length, width, at[1], at[2], at[3], id);
445 | elseif (descr == "pipecylinder") then
446 | if (Modelica.Math.isEqual(extra, 0.0)) then
447 | createCylinderAt(conn, context, length, width, at[1], at[2], at[3], id);
448 | else
449 | // not yet supported
450 | Modelica.Utilities.Streams.print("Error: Visualization of pipecylinders has not been implemented yet!");
451 | setString(id,"UNKNOWN");
452 | end if;
453 | elseif (descr == "pipe") then
454 | if (Modelica.Math.isEqual(extra, 0.0)) then
455 | createCylinderAt(conn, context, length, width, at[1], at[2], at[3], id);
456 | else
457 | // not yet supported
458 | Modelica.Utilities.Streams.print("Error: Visualization of pipes has not been implemented yet!");
459 | setString(id,"UNKNOWN");
460 | end if;
461 | elseif (descr == "beam") then
462 | // not yet supported
463 | Modelica.Utilities.Streams.print("Error: Visualization of beams has not been implemented yet!");
464 | setString(id,"UNKNOWN");
465 | elseif (descr == "gearwheel") then
466 | // not yet supported
467 | Modelica.Utilities.Streams.print("Error: Visualization of gearwheels has not been implemented yet!");
468 | setString(id,"UNKNOWN");
469 | elseif (descr == "spring") then
470 | // not yet supported
471 | Modelica.Utilities.Streams.print("Error: Visualization of springs has not been implemented yet!");
472 | setString(id,"UNKNOWN");
473 | else
474 | // assume it is a filename
475 | loadFromFile(conn, context, Modelica.Utilities.Files.fullPathName(ModelicaServices.ExternalReferences.loadResource(descr)), at[1], at[2], at[3], id);
476 | end if;
477 |
478 | end shapeDescrTo3D;
479 |
480 | outer Controller m3d_control;
481 |
482 | Id id = Id("");
483 | Id mat = Id("");
484 | modcount.Context initContext = modcount.Context();
485 | String res;
486 |
487 | discrete Real[3] pos;
488 | discrete Real[3,3] oldT;
489 | discrete Boolean moved;
490 | discrete Boolean rotated;
491 | // disable initial equation for now, since there is some bug in initial residuals
492 | //initial equation
493 | // pre(oldT) = R.T;
494 | // pre(pos) = r + Frames.resolve1(R, r_shape);
495 | algorithm
496 | when m3d_control.send and modcount.get(initContext) == 1 then
497 | // check for rotation
498 | rotated := not Modelica.Math.Matrices.isEqual(R.T, oldT);
499 | if noEvent(rotated) then
500 | res := rotate(m3d_control.conn, m3d_control.context, id, R.T, time);
501 | end if;
502 | oldT := R.T;
503 |
504 | // check for translation
505 | pos := r + Frames.resolve1(R, r_shape);
506 | moved := not Modelica.Math.Vectors.isEqual(pos, pre(pos));
507 | if noEvent(moved) then
508 | res := moveTo(m3d_control.conn, m3d_control.context, id, pos, time);
509 | end if;
510 |
511 | end when;
512 |
513 | if modcount.get(initContext) <> 1 then
514 |
515 | Modelica.Utilities.Streams.print( "SHAPE " + getString(id) + " " + shapeType);
516 | Modelica.Utilities.Streams.print( "length = " + String(length));
517 | Modelica.Utilities.Streams.print( "width = " + String(width));
518 | Modelica.Utilities.Streams.print( "height = " + String(height));
519 |
520 |
521 | shapeDescrTo3D(m3d_control.conn, m3d_control.context, shapeType, length, width, height, lengthDirection, extra, id);
522 | createMaterial(m3d_control.conn, m3d_control.context, mat);
523 | setAmbientColor(m3d_control.conn, m3d_control.context, mat, color[1] / 255, color[2] / 255, color[3] / 255, 1.0, time);
524 | setSpecularColor(m3d_control.conn, m3d_control.context, mat, specularCoefficient * (color[1] / 255),
525 | specularCoefficient * color[2] / 255, specularCoefficient * color[3] / 255, 1.0, time);
526 |
527 | applyMaterial(m3d_control.conn, m3d_control.context, id, mat);
528 | modcount.set(initContext, 1);
529 | end if;
530 |
531 |
532 |
533 |
534 | annotation (
535 | Icon(coordinateSystem(
536 | preserveAspectRatio=true,
537 | extent={{-100,-100},{100,100}},
538 | grid={2,2}), graphics={
539 | Rectangle(
540 | extent={{-100,-100},{80,60}},
541 | lineColor={0,0,255},
542 | fillColor={255,255,255},
543 | fillPattern=FillPattern.Solid),
544 | Polygon(
545 | points={{-100,60},{-80,100},{100,100},{80,60},{-100,60}},
546 | lineColor={0,0,255},
547 | fillColor={192,192,192},
548 | fillPattern=FillPattern.Solid),
549 | Polygon(
550 | points={{100,100},{100,-60},{80,-100},{80,60},{100,100}},
551 | lineColor={0,0,255},
552 | fillColor={160,160,164},
553 | fillPattern=FillPattern.Solid),
554 | Text(
555 | extent={{-100,-100},{80,60}},
556 | lineColor={0,0,0},
557 | textString="%shapeType"),
558 | Text(
559 | extent={{-132,160},{128,100}},
560 | textString="%name",
561 | lineColor={0,0,255})}),
562 | Documentation(info="
563 |
564 |
565 | This model is documented at
566 | Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
567 |
568 |
569 |
570 | "));
571 | end PartialShape;
572 | end Modelica3D;
573 |
--------------------------------------------------------------------------------
/lib/mod3d/src/modelica/Modelica3D 3.2.1/required changes.txt:
--------------------------------------------------------------------------------
1 | To use Modelica3D with Modelica 3.2.1, copy this package.mo to ModelicaServices/Modelica3D/package.mo along with modbus and modcount (as in the old version)
2 |
3 | Additionally, the model Shape
4 |
5 | {{{
6 | package Animation "Models and functions for 3-dim. animation"
7 | extends Modelica.Icons.Package;
8 | model Shape
9 | "Different visual shapes with variable size; all data have to be set as modifiers (see info layer)"
10 | extends
11 | Modelica.Utilities.Internal.PartialModelicaServices.Animation.PartialShape;
12 | }}}
13 |
14 | has to be extended from Modelica3D.PartialShape, i.e. it becomes
15 |
16 | {{{
17 | package Animation "Models and functions for 3-dim. animation"
18 | extends Modelica.Icons.Package;
19 | model Shape
20 | "Different visual shapes with variable size; all data have to be set as modifiers (see info layer)"
21 | extends
22 | Modelica.Utilities.Internal.PartialModelicaServices.Animation.PartialShape;
23 | extends
24 | ModelicaServices.Modelica3D.PartialShape;
25 | }}}
26 |
--------------------------------------------------------------------------------
/lib/mod3d/src/modelica/package.mo:
--------------------------------------------------------------------------------
1 | within ;
2 | package ModelicaServices "ModelicaServices (OpenModelica implementation + Modelica3D hooks) - Models and functions used in the Modelica Standard Library requiring a tool specific implementation"
3 | extends Modelica.Icons.Package;
4 | constant String target="OpenModelica"
5 | "Target of this ModelicaServices implementation";
6 |
7 |
8 | package UsersGuide "User's Guide"
9 | extends Modelica.Icons.Information;
10 | class ModelicaLicense2 "Modelica License 2"
11 | extends Modelica.Icons.Information;
12 | annotation (Documentation(info="
13 |
14 | The Modelica License 2
15 |
26 |
27 |
28 | All files in this directory (Modelica) and in all
29 | subdirectories are licensed by the Modelica Association under the
30 | Modelica License 2.
31 |
32 | Licensor:
33 | Modelica Association
34 | (Ideella Föreningar 822003-8858 in Linköping)
35 | c/o PELAB, IDA, Linköpings Universitet
36 | S-58183 Linköping
37 | Sweden
38 | email: Board@Modelica.org
39 | web: https://www.Modelica.org
40 |
41 | Copyright notices of the files:
42 | Copyright © 1998-2013, DLR, Dassault Systèmes AB.
43 |
44 |
45 |
46 | The Modelica License 2
47 | Frequently Asked Questions
48 |
49 |
50 |
51 |
52 | The Modelica License 2
53 |
54 |
55 | Preamble. The goal of this license is that Modelica related
56 | model libraries, software, images, documents, data files etc. can be
57 | used freely in the original or a modified form, in open source and in
58 | commercial environments (as long as the license conditions below are
59 | fulfilled, in particular sections 2c) and 2d). The Original Work is
60 | provided free of charge and the use is completely at your own risk.
61 | Developers of free Modelica packages are encouraged to utilize this
62 | license for their work.
63 |
64 |
65 | The Modelica License applies to any Original Work that contains the
66 | following licensing notice adjacent to the copyright notice(s) for
67 | this Original Work:
68 |
69 | Licensed by the Modelica Association under the Modelica License 2
70 |
71 | 1. Definitions.
72 |
73 | - “License” is this Modelica License.
74 |
75 | - “Original Work” is any work of authorship, including
76 | software, images, documents, data files, that contains the above
77 | licensing notice or that is packed together with a licensing notice
78 | referencing it.
79 |
80 | - “Licensor” is the provider of the Original Work who has
81 | placed this licensing notice adjacent to the copyright notice(s) for
82 | the Original Work. The Original Work is either directly provided by
83 | the owner of the Original Work, or by a licensee of the owner.
84 |
85 | - “Derivative Work” is any modification of the Original
86 | Work which represents, as a whole, an original work of authorship.
87 | For the matter of clarity and as examples:
88 |
89 |
90 | - Derivative Work shall not include work that remains separable from
91 | the Original Work, as well as merely extracting a part of the
92 | Original Work without modifying it.
93 |
94 | - Derivative Work shall not include (a) fixing of errors and/or (b)
95 | adding vendor specific Modelica annotations and/or (c) using a
96 | subset of the classes of a Modelica package, and/or (d) using a
97 | different representation, e.g., a binary representation.
98 |
99 | - Derivative Work shall include classes that are copied from the
100 | Original Work where declarations, equations or the documentation
101 | are modified.
102 |
103 | - Derivative Work shall include executables to simulate the models
104 | that are generated by a Modelica translator based on the Original
105 | Work (of a Modelica package).
106 |
107 |
108 | - “Modified Work” is any modification of the Original Work
109 | with the following exceptions: (a) fixing of errors and/or (b)
110 | adding vendor specific Modelica annotations and/or (c) using a
111 | subset of the classes of a Modelica package, and/or (d) using a
112 | different representation, e.g., a binary representation.
113 |
114 | - "Source Code" means the preferred form of the Original
115 | Work for making modifications to it and all available documentation
116 | describing how to modify the Original Work.
117 |
118 | - “You” means an individual or a legal entity exercising
119 | rights under, and complying with all of the terms of, this License.
120 |
121 | - “Modelica package” means any Modelica library that is
122 | defined with the “
package <Name> ... end <Name>;
” Modelica language element.
123 |
124 |
125 |
126 |
127 | 2. Grant of Copyright License. Licensor grants You a
128 | worldwide, royalty-free, non-exclusive, sublicensable license, for
129 | the duration of the copyright, to do the following:
130 |
131 |
132 |
133 | To reproduce the Original Work in copies, either alone or as part of
134 | a collection.
135 |
136 | To create Derivative Works according to Section 1d) of this License.
137 |
138 | To distribute or communicate to the public copies of the Original
139 | Work or a Derivative Work under this License. No
140 | fee, neither as a copyright-license fee, nor as a selling fee for
141 | the copy as such may be charged under this License. Furthermore, a
142 | verbatim copy of this License must be included in any copy of the
143 | Original Work or a Derivative Work under this License.
144 | For the matter of clarity, it is permitted A) to distribute or
145 | communicate such copies as part of a (possible commercial)
146 | collection where other parts are provided under different licenses
147 | and a license fee is charged for the other parts only and B) to
148 | charge for mere printing and shipping costs.
149 |
150 | To distribute or communicate to the public copies of a Derivative
151 | Work, alternatively to Section 2c), under any other license
152 | of your choice, especially also under a license for
153 | commercial/proprietary software, as long as You comply with Sections
154 | 3, 4 and 8 below.
For the matter of clarity, no
155 | restrictions regarding fees, either as to a copyright-license fee or
156 | as to a selling fee for the copy as such apply.
157 |
158 | To perform the Original Work publicly.
159 |
160 | To display the Original Work publicly.
161 |
162 |
163 |
164 | 3. Acceptance. Any use of the Original Work or a
165 | Derivative Work, or any action according to either Section 2a) to 2f)
166 | above constitutes Your acceptance of this License.
167 |
168 |
169 | 4. Designation of Derivative Works and of Modified Works.
170 | The identifying designation of Derivative Work and of Modified
171 | Work must be different to the corresponding identifying designation
172 | of the Original Work. This means especially that the (root-level)
173 | name of a Modelica package under this license must be changed if the
174 | package is modified (besides fixing of errors, adding vendor specific
175 | Modelica annotations, using a subset of the classes of a Modelica
176 | package, or using another representation, e.g. a binary
177 | representation).
178 |
179 |
180 | 5. Grant of Patent License.
181 | Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license,
182 | under patent claims owned by the Licensor or licensed to the Licensor by
183 | the owners of the Original Work that are embodied in the Original Work
184 | as furnished by the Licensor, for the duration of the patents,
185 | to make, use, sell, offer for sale, have made, and import the Original Work
186 | and Derivative Works under the conditions as given in Section 2.
187 | For the matter of clarity, the license regarding Derivative Works covers
188 | patent claims to the extent as they are embodied in the Original Work only.
189 |
190 |
191 | 6. Provision of Source Code. Licensor agrees to provide
192 | You with a copy of the Source Code of the Original Work but reserves
193 | the right to decide freely on the manner of how the Original Work is
194 | provided.
195 | For the matter of clarity, Licensor might provide only a binary
196 | representation of the Original Work. In that case, You may (a) either
197 | reproduce the Source Code from the binary representation if this is
198 | possible (e.g., by performing a copy of an encrypted Modelica
199 | package, if encryption allows the copy operation) or (b) request the
200 | Source Code from the Licensor who will provide it to You.
201 |
202 |
203 | 7. Exclusions from License Grant. Neither the names of
204 | Licensor, nor the names of any contributors to the Original Work, nor
205 | any of their trademarks or service marks, may be used to endorse or
206 | promote products derived from this Original Work without express
207 | prior permission of the Licensor. Except as otherwise expressly
208 | stated in this License and in particular in Sections 2 and 5, nothing
209 | in this License grants any license to Licensor’s trademarks,
210 | copyrights, patents, trade secrets or any other intellectual
211 | property, and no patent license is granted to make, use, sell, offer
212 | for sale, have made, or import embodiments of any patent claims.
213 | No license is granted to the trademarks of
214 | Licensor even if such trademarks are included in the Original Work,
215 | except as expressly stated in this License. Nothing in this License
216 | shall be interpreted to prohibit Licensor from licensing under terms
217 | different from this License any Original Work that Licensor otherwise
218 | would have a right to license.
219 |
220 |
221 | 8. Attribution Rights. You must retain in the Source
222 | Code of the Original Work and of any Derivative Works that You
223 | create, all author, copyright, patent, or trademark notices, as well
224 | as any descriptive text identified therein as an "Attribution
225 | Notice". The same applies to the licensing notice of this
226 | License in the Original Work. For the matter of clarity, “author
227 | notice” means the notice that identifies the original
228 | author(s).
229 | You must cause the Source Code for any Derivative
230 | Works that You create to carry a prominent Attribution Notice
231 | reasonably calculated to inform recipients that You have modified the
232 | Original Work.
233 | In case the Original Work or Derivative Work is not provided in
234 | Source Code, the Attribution Notices shall be appropriately
235 | displayed, e.g., in the documentation of the Derivative Work.
236 |
237 | 9. Disclaimer
238 | of Warranty.
The Original Work is provided under this
239 | License on an "as is" basis and without warranty, either
240 | express or implied, including, without limitation, the warranties of
241 | non-infringement, merchantability or fitness for a particular
242 | purpose. The entire risk as to the quality of the Original Work is
243 | with You. This disclaimer of warranty constitutes an
244 | essential part of this License. No license to the Original Work is
245 | granted by this License except under this disclaimer.
246 |
247 |
248 | 10. Limitation of Liability. Under no circumstances and
249 | under no legal theory, whether in tort (including negligence),
250 | contract, or otherwise, shall the Licensor, the owner or a licensee
251 | of the Original Work be liable to anyone for any direct, indirect,
252 | general, special, incidental, or consequential damages of any
253 | character arising as a result of this License or the use of the
254 | Original Work including, without limitation, damages for loss of
255 | goodwill, work stoppage, computer failure or malfunction, or any and
256 | all other commercial damages or losses. This limitation of liability
257 | shall not apply to the extent applicable law prohibits such
258 | limitation.
259 |
260 |
261 | 11. Termination. This License conditions your rights to
262 | undertake the activities listed in Section 2 and 5, including your
263 | right to create Derivative Works based upon the Original Work, and
264 | doing so without observing these terms and conditions is prohibited
265 | by copyright law and international treaty. Nothing in this License is
266 | intended to affect copyright exceptions and limitations. This License
267 | shall terminate immediately and You may no longer exercise any of the
268 | rights granted to You by this License upon your failure to observe
269 | the conditions of this license.
270 |
271 |
272 | 12. Termination for Patent Action. This License shall
273 | terminate automatically and You may no longer exercise any of the
274 | rights granted to You by this License as of the date You commence an
275 | action, including a cross-claim or counterclaim, against Licensor,
276 | any owners of the Original Work or any licensee alleging that the
277 | Original Work infringes a patent. This termination provision shall
278 | not apply for an action alleging patent infringement through
279 | combinations of the Original Work under combination with other
280 | software or hardware.
281 |
282 |
283 | 13. Jurisdiction. Any action or suit relating to this
284 | License may be brought only in the courts of a jurisdiction wherein
285 | the Licensor resides and under the laws of that jurisdiction
286 | excluding its conflict-of-law provisions. The application of the
287 | United Nations Convention on Contracts for the International Sale of
288 | Goods is expressly excluded. Any use of the Original Work outside the
289 | scope of this License or after its termination shall be subject to
290 | the requirements and penalties of copyright or patent law in the
291 | appropriate jurisdiction. This section shall survive the termination
292 | of this License.
293 |
294 |
295 | 14. Attorneys’ Fees. In any action to enforce the
296 | terms of this License or seeking damages relating thereto, the
297 | prevailing party shall be entitled to recover its costs and expenses,
298 | including, without limitation, reasonable attorneys' fees and costs
299 | incurred in connection with such action, including any appeal of such
300 | action. This section shall survive the termination of this License.
301 |
302 |
303 | 15. Miscellaneous.
304 |
305 |
306 | - If any
307 | provision of this License is held to be unenforceable, such
308 | provision shall be reformed only to the extent necessary to make it
309 | enforceable.
310 |
311 | - No verbal
312 | ancillary agreements have been made. Changes and additions to this
313 | License must appear in writing to be valid. This also applies to
314 | changing the clause pertaining to written form.
315 |
316 | - You may use the
317 | Original Work in all ways not otherwise restricted or conditioned by
318 | this License or by law, and Licensor promises not to interfere with
319 | or be responsible for such uses by You.
320 |
321 |
322 |
323 |
324 |
325 | Frequently Asked Questions
326 | This
327 | section contains questions/answer to users and/or distributors of
328 | Modelica packages and/or documents under Modelica License 2. Note,
329 | the answers to the questions below are not a legal interpretation of
330 | the Modelica License 2. In case of a conflict, the language of the
331 | license shall prevail.
332 |
333 | Using or Distributing a Modelica Package under the Modelica License 2
334 |
335 | What are the main
336 | differences to the previous version of the Modelica License?
337 |
338 |
339 | Modelica License 1 is unclear whether the licensed Modelica package
340 | can be distributed under a different license. Version 2 explicitly
341 | allows that “Derivative Work” can be distributed under
342 | any license of Your choice, see examples in Section 1d) as to what
343 | qualifies as Derivative Work (so, version 2 is clearer).
344 |
345 | If You modify a Modelica package under Modelica License 2 (besides
346 | fixing of errors, adding vendor specific Modelica annotations, using
347 | a subset of the classes of a Modelica package, or using another
348 | representation, e.g., a binary representation), you must rename the
349 | root-level name of the package for your distribution. In version 1
350 | you could keep the name (so, version 2 is more restrictive). The
351 | reason of this restriction is to reduce the risk that Modelica
352 | packages are available that have identical names, but different
353 | functionality.
354 |
355 | Modelica License 1 states that “It is not allowed to charge a
356 | fee for the original version or a modified version of the software,
357 | besides a reasonable fee for distribution and support”.
358 | Version 2 has a similar intention for all Original Work under
359 | Modelica License 2 (to remain free of charge and open source)
360 | but states this more clearly as “No fee, neither as a
361 | copyright-license fee, nor as a selling fee for the copy as such may
362 | be charged”. Contrary to version 1, Modelica License 2 has no
363 | restrictions on fees for Derivative Work that is provided under a
364 | different license (so, version 2 is clearer and has fewer
365 | restrictions).
366 |
367 | Modelica License 2 introduces several useful provisions for the
368 | licensee (articles 5, 6, 12), and for the licensor (articles 7, 12,
369 | 13, 14) that have no counter part in version 1.
370 |
371 | Modelica License 2 can be applied to all type of work, including
372 | documents, images and data files, contrary to version 1 that was
373 | dedicated for software only (so, version 2 is more general).
374 |
375 |
376 | Can I distribute a
377 | Modelica package (under Modelica License 2) as part of my commercial
378 | Modelica modeling and simulation environment?
379 | Yes,
380 | according to Section 2c). However, you are not allowed to charge a
381 | fee for this part of your environment. Of course, you can charge for
382 | your part of the environment.
383 |
384 |
385 | Can I distribute a
386 | Modelica package (under Modelica License 2) under a different
387 | license?
388 | No.
389 | The license of an unmodified Modelica package cannot be changed
390 | according to Sections 2c) and 2d). This means that you cannot sell
391 | copies of it, any distribution has to be free of charge.
392 |
393 | Can I distribute a
394 | Modelica package (under Modelica License 2) under a different license
395 | when I first encrypt the package?
396 | No.
397 | Merely encrypting a package does not qualify for Derivative Work and
398 | therefore the encrypted package has to stay under Modelica License 2.
399 |
400 | Can I distribute a
401 | Modelica package (under Modelica License 2) under a different license
402 | when I first add classes to the package?
403 | No.
404 | The package itself remains unmodified, i.e., it is Original Work, and
405 | therefore the license for this part must remain under Modelica
406 | License 2. The newly added classes can be, however, under a different
407 | license.
408 |
409 |
410 | Can
411 | I copy a class out of a Modelica package (under Modelica License 2)
412 | and include it unmodified in a Modelica package
413 | under a commercial/proprietary license?
414 | No,
415 | according to article 2c). However, you can include model, block,
416 | function, package, record and connector classes in your Modelica
417 | package under Modelica License 2. This means that your
418 | Modelica package could be under a commercial/proprietary license, but
419 | one or more classes of it are under Modelica License 2.
Note, a
420 | “type” class (e.g., type Angle = Real(unit=”rad”))
421 | can be copied and included unmodified under a commercial/proprietary
422 | license (for details, see the next question).
423 |
424 | Can
425 | I copy a type class or part of a model, block,
426 | function, record, connector class, out of a Modelica package (under
427 | Modelica License 2) and include it modified or unmodified in a
428 | Modelica package under a commercial/proprietary
429 | license
430 | Yes,
431 | according to article 2d), since this will in the end usually qualify
432 | as Derivative Work. The reasoning is the following: A type class or
433 | part of another class (e.g., an equation, a declaration, part of a
434 | class description) cannot be utilized “by its own”. In
435 | order to make this “usable”, you have to add additional
436 | code in order that the class can be utilized. This is therefore
437 | usually Derivative Work and Derivative Work can be provided under a
438 | different license. Note, this only holds, if the additional code
439 | introduced is sufficient to qualify for Derivative Work. Merely, just
440 | copying a class and changing, say, one character in the documentation
441 | of this class would be no Derivative Work and therefore the copied
442 | code would have to stay under Modelica License 2.
443 |
444 | Can
445 | I copy a class out of a Modelica package (under Modelica License 2)
446 | and include it in modified form in a
447 | commercial/proprietary Modelica package?
448 | Yes.
449 | If the modification can be seen as a “Derivative Work”,
450 | you can place it under your commercial/proprietary license. If the
451 | modification does not qualify as “Derivative Work” (e.g.,
452 | bug fixes, vendor specific annotations), it must remain under
453 | Modelica License 2. This means that your Modelica package could be
454 | under a commercial/proprietary license, but one or more parts of it
455 | are under Modelica License 2.
456 |
457 | Can I distribute a
458 | “save total model” under my commercial/proprietary
459 | license, even if classes under Modelica License 2 are included?
460 | Your
461 | classes of the “save total model” can be distributed
462 | under your commercial/proprietary license, but the classes under
463 | Modelica License 2 must remain under Modelica License 2. This means
464 | you can distribute a “save total model”, but some parts
465 | might be under Modelica License 2.
466 |
467 | Can I distribute a
468 | Modelica package (under Modelica License 2) in encrypted form?
469 | Yes.
470 | Note, if the encryption does not allow “copying” of
471 | classes (in to unencrypted Modelica source code), you have to send
472 | the Modelica source code of this package to your customer, if he/she
473 | wishes it, according to article 6.
474 |
475 | Can I distribute an
476 | executable under my commercial/proprietary license, if the model from
477 | which the executable is generated uses models from a Modelica package
478 | under Modelica License 2?
479 | Yes,
480 | according to article 2d), since this is seen as Derivative Work. The
481 | reasoning is the following: An executable allows the simulation of a
482 | concrete model, whereas models from a Modelica package (without
483 | pre-processing, translation, tool run-time library) are not able to
484 | be simulated without tool support. By the processing of the tool and
485 | by its run-time libraries, significant new functionality is added (a
486 | model can be simulated whereas previously it could not be simulated)
487 | and functionality available in the package is removed (e.g., to build
488 | up a new model by dragging components of the package is no longer
489 | possible with the executable).
490 |
491 | Is my modification to
492 | a Modelica package (under Modelica License 2) a Derivative Work?
493 | It
494 | is not possible to give a general answer to it. To be regarded as "an
495 | original work of authorship", a derivative work must be
496 | different enough from the original or must contain a substantial
497 | amount of new material. Making minor changes or additions of little
498 | substance to a preexisting work will not qualify the work as a new
499 | version for such purposes.
500 |
501 |
502 | Using or Distributing a Modelica Document under the Modelica License 2
503 |
504 | This
505 | section is devoted especially for the following applications:
506 |
507 |
508 | A Modelica tool extracts information out of a Modelica package and
509 | presents the result in form of a “manual” for this
510 | package in, e.g., html, doc, or pdf format.
511 |
512 | The Modelica language specification is a document defining the
513 | Modelica language. It will be licensed under Modelica License 2.
514 |
515 | Someone writes a book about the Modelica language and/or Modelica
516 | packages and uses information which is available in the Modelica
517 | language specification and/or the corresponding Modelica package.
518 |
519 |
520 | Can I sell a manual
521 | that was basically derived by extracting information automatically
522 | from a Modelica package under Modelica License 2 (e.g., a “reference
523 | guide” of the Modelica Standard Library):
524 | Yes.
525 | Extracting information from a Modelica package, and providing it in a
526 | human readable, suitable format, like html, doc or pdf format, where
527 | the content is significantly modified (e.g. tables with interface
528 | information are constructed from the declarations of the public
529 | variables) qualifies as Derivative Work and there are no restrictions
530 | to charge a fee for Derivative Work under alternative 2d).
531 |
532 | Can
533 | I copy a text passage out of a Modelica document (under Modelica
534 | License 2) and use it unmodified in my document
535 | (e.g. the Modelica syntax description in the Modelica Specification)?
536 | Yes.
537 | In case you distribute your document, the copied parts are still
538 | under Modelica License 2 and you are not allowed to charge a license
539 | fee for this part. You can, of course, charge a fee for the rest of
540 | your document.
541 |
542 | Can
543 | I copy a text passage out of a Modelica document (under Modelica
544 | License 2) and use it in modified form in my
545 | document?
546 | Yes,
547 | the creation of Derivative Works is allowed. In case the content is
548 | significantly modified this qualifies as Derivative Work and there
549 | are no restrictions to charge a fee for Derivative Work under
550 | alternative 2d).
551 |
552 | Can I sell a printed
553 | version of a Modelica document (under Modelica License 2), e.g., the
554 | Modelica Language Specification?
555 | No,
556 | if you are not the copyright-holder, since article 2c) does not allow
557 | a selling fee for a (in this case physical) copy. However, mere
558 | printing and shipping costs may be recovered.
559 | "));
560 | end ModelicaLicense2;
561 |
562 | class ReleaseNotes "Release notes"
563 | extends Modelica.Icons.ReleaseNotes;
564 | annotation (Documentation(info="
565 | Version 3.2.1, 2012-12-05
566 |
567 |
568 | - Version numbering adapted to the corresponding version number of
569 | package Modelica (= Modelica Standard Library).
570 | - New function
571 | loadResource
572 | to determine the absolute, local file name from an URI path name.
573 |
574 | - New String type with tool dependent choices
575 | SolverMethod
576 | to define the integration method to solve differential equations in a
577 | clocked discretized continuous-time partition.
578 |
579 | - New package
580 | Machine
581 | to define the processor dependent constants as used in
582 | Modelica.Constants.
583 |
584 |
585 |
586 |
587 | Version 1.1, 2010-07-30
588 |
589 |
590 | - New model Surface
591 | to describe movable, parameterized surfaces.
592 | - New string constant ModelicaServices.target to define the
593 | target of the corresponding ModelicaServices implementation
594 | - Package icons adapted to the icons of package Modelica, version 3.2.
595 | - ModelicaServices library on the Modelica subversion server provided in three versions:
596 |
597 | - Default/ModelicaServices
598 | (for tools that do not support 3-dim. visualization).
599 |
600 | - Dymola/ModelicaServices
601 | (a Dymola-specific implementation).
602 |
603 | - DymolaAndDLRVisualization/ModelicaServices
604 | (an implementation that uses the DLR Visualization library
605 | in combination with Dymola).
606 |
607 |
608 |
609 |
610 | Version 1.0, 2009-06-21
611 |
612 |
613 | First version of the ModelicaServices library.
614 |
615 | "));
616 | end ReleaseNotes;
617 |
618 | class Contact "Contact"
619 | extends Modelica.Icons.Contact;
620 | annotation (Documentation(info="
621 | Main Author:
622 |
623 |
624 |
625 |
626 | Martin Otter
627 | Deutsches Zentrum für Luft und Raumfahrt e.V. (DLR)
628 | Robotik und Mechatronik Zentrum (RMC)
629 | Institut für Systemdynamik und Regelungstechnik (SR)
630 | Postfach 1116
631 | D-82230 Wessling
632 | Germany
633 | email: Martin.Otter@dlr.de |
634 |
635 |
636 |
637 | Acknowledgements:
638 |
639 |
640 | The design of the Animation.Shape component is from Hilding Elmqvist, Dassault Systèmes AB.
641 |
642 | "));
643 |
644 | end Contact;
645 | annotation (__Dymola_DocumentationClass=true);
646 | end UsersGuide;
647 |
648 |
649 | package Animation "Models and functions for 3-dim. animation"
650 | extends Modelica.Icons.Package;
651 | model Shape
652 | "Different visual shapes with variable size; all data have to be set as modifiers (see info layer)"
653 | extends Modelica.Utilities.Internal.PartialModelicaServices.Animation.PartialShape;
654 | extends ModelicaServices.Modelica3D.PartialShape;
655 |
656 | annotation (Icon(coordinateSystem(
657 | preserveAspectRatio=true,
658 | extent={{-100,-100},{100,100}},
659 | grid={2,2}), graphics={Text(
660 | extent={{-150,-110},{150,-140}},
661 | lineColor={0,0,0},
662 | textString="default")}), Documentation(info="
663 |
664 | The interface of this model is documented at
665 | Modelica.Mechanics.MultiBody.Visualizers.Advanced.Shape.
666 |
667 |
668 | "));
669 |
670 | end Shape;
671 |
672 | model Surface
673 | "Animation of a moveable, parameterized surface; the surface characteristic is provided by a function"
674 |
675 | annotation (Documentation(info="
676 |
677 | The interface of this model is documented at
678 | Modelica.Mechanics.MultiBody.Visualizers.Advanced.Surface.
679 | The interface of this model is defined at
680 | Modelica.Utilities.Internal.PartialModelicaServices.Animation.PartialSurface.
681 |
682 |
683 | "));
684 | end Surface;
685 | end Animation;
686 |
687 |
688 | package ExternalReferences "Library of functions to access external resources"
689 | extends Modelica.Icons.Package;
690 | function loadResource
691 | "Return the absolute path name of a URI or local file name (in this default implementation URIs are not supported, but only local file names)"
692 | extends
693 | Modelica.Utilities.Internal.PartialModelicaServices.ExternalReferences.PartialLoadResource;
694 | algorithm
695 | fileReference:=OpenModelica.Scripting.uriToFilename(uri);
696 |
697 | annotation (Documentation(info="
698 |
699 | The interface of this model is documented at
700 | Modelica.Utilities.Files.loadResource.
701 |
702 | "));
703 | end loadResource;
704 | end ExternalReferences;
705 |
706 |
707 | package Machine
708 | // Machine dependent constants
709 | extends Modelica.Icons.Package;
710 | final constant Real eps=1.e-15 "Biggest number such that 1.0 + eps = 1.0";
711 | final constant Real small=1.e-60
712 | "Smallest number such that small and -small are representable on the machine";
713 | final constant Real inf=1.e+60
714 | "Biggest Real number such that inf and -inf are representable on the machine";
715 | final constant Integer Integer_inf=OpenModelica.Internal.Architecture.integerMax()
716 | "Biggest Integer number such that Integer_inf and -Integer_inf are representable on the machine";
717 | annotation (Documentation(info="
718 |
719 | Package in which processor specific constants are defined that are needed
720 | by numerical algorithms. Typically these constants are not directly used,
721 | but indirectly via the alias definition in
722 | Modelica.Constants.
723 |
724 | "));
725 | end Machine;
726 |
727 |
728 | package Types "Library of types with vendor specific choices"
729 | extends Modelica.Icons.Package;
730 | type SolverMethod = String
731 | "String defining the integration method to solve differential equations in a clocked discretized continuous-time partition"
732 | annotation (choices(
733 | choice="External" "Solver specified externally",
734 | choice="ExplicitEuler" "Explicit Euler method (order 1)",
735 | choice="ExplicitMidPoint2" "Explicit mid point rule (order 2)",
736 | choice="ExplicitRungeKutta4" "Explicit Runge-Kutta method (order 4)",
737 | choice="ImplicitEuler" "Implicit Euler method (order 1)",
738 | choice="ImplicitTrapezoid" "Implicit trapezoid rule (order 2)"),
739 | Documentation(info="
740 |
741 | Type SolverMethod is a String type with menu choices to select the
742 | integration method to solve differential equations in a clocked discretized
743 | continuous-time partition. The choices are tool dependent.
744 | For details, see chapter 16.8.2 \"Solver Method\" in the Modelica Language
745 | Specification (version ≥ 3.3).
746 |
747 | "));
748 | end Types;
749 |
750 |
751 | annotation (
752 | Protection(access=Access.hide),
753 | preferredView="info",
754 | version="3.2.1 modelica3d",
755 | versionDate="2012-12-05",
756 | versionBuild=0,
757 | revisionId="$Id:: package.mo 6169 2013-03-30 17:25:09Z #$",
758 | uses(Modelica(version="3.2.1")),
759 | conversion(
760 | noneFromVersion="1.0",
761 | noneFromVersion="1.1",
762 | noneFromVersion="1.2"),
763 | Documentation(info="
764 |
765 | This package contains a set of functions and models to be used in the
766 | Modelica Standard Library that requires a tool specific implementation.
767 | These are:
768 |
769 |
770 |
798 |
799 |
800 | This is the default implementation, if no tool-specific implementation is available.
801 | This ModelicaServices package provides only \"dummy\" models that do nothing.
802 |
803 |
804 |
805 | Licensed by DLR and Dassault Systèmes AB under the Modelica License 2
806 | Copyright © 2009-2013, DLR and Dassault Systèmes AB.
807 |
808 |
809 |
810 | This Modelica package is free software and the use is completely at your own risk; it can be redistributed and/or modified under the terms of the Modelica License 2. For license conditions (including the disclaimer of warranty) see Modelica.UsersGuide.ModelicaLicense2 or visit https://www.modelica.org/licenses/ModelicaLicense2.
811 |
812 |
813 | "));
814 | end ModelicaServices;
815 |
--------------------------------------------------------------------------------
/lib/modbus/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | find_package(DBUS REQUIRED)
2 |
3 | include_directories(${DBUS_INCLUDES} ${OMC_INCLUDES})
4 | set(modbus_src "${CMAKE_SOURCE_DIR}/lib/modbus/src/")
5 |
6 | add_library(modbus "${modbus_src}/c/modbus.c")
7 |
8 | if(MSVC)
9 | set_source_files_properties("${modbus_src}/c/modbus.c" PROPERTIES LANGUAGE CXX)
10 | endif(MSVC)
11 |
12 | if (USE_OMC)
13 | # Modelica library to install
14 | install(DIRECTORY "${modbus_src}/modelica/modbus"
15 | DESTINATION "${OMC_MOD_LIB_DIR}/${MODELICA_SERVICES_LIBRARY}")
16 |
17 | # Install library header
18 | install(FILES "${modbus_src}/c/modbus.h" DESTINATION ${OMC_INCLUDE_DIR})
19 |
20 | install(TARGETS modbus
21 | LIBRARY DESTINATION ${OMC_LIBRARY_DIR}
22 | ARCHIVE DESTINATION ${OMC_LIBRARY_DIR}
23 | )
24 | endif(USE_OMC)
25 |
--------------------------------------------------------------------------------
/lib/modbus/src/c/modbus.c:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the Modelica3D package.
3 |
4 | Copyright (C) 2012-current year Christoph Höger and Technical University of Berlin
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU Lesser General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public License
17 | along with this program. If not, see .
18 |
19 | Main Author 2010-2013, Christoph Höger
20 | */
21 |
22 | #define DBUS_STATIC_BUILD /* In order to link against dbus static lib. */
23 | #include
24 | #include
25 | #include
26 |
27 | #include "modbus.h"
28 |
29 | #ifdef __cplusplus
30 | extern "C"
31 | {
32 | #endif
33 |
34 | DBusError err;
35 |
36 | typedef struct modbus_message {
37 | DBusMessage* msg;
38 | DBusMessageIter args;
39 | DBusMessageIter dict;
40 | } ModbusMessage;
41 |
42 | void* modbus_acquire_session_bus(const char * client_name) {
43 | dbus_error_init(&err);
44 |
45 | /* taken from http://www.matthew.ath.cx/misc/dbus */
46 | DBusConnection* conn = dbus_bus_get(DBUS_BUS_SESSION, &err);
47 |
48 | if (dbus_error_is_set(&err)) {
49 | fprintf(stderr, "Connection Error (%s)\n", err.message);
50 | dbus_error_free(&err);
51 | }
52 |
53 | if (NULL == conn) {
54 | exit(1);
55 | }
56 |
57 | // request a name on the bus
58 | int ret = dbus_bus_request_name(conn, client_name,
59 | DBUS_NAME_FLAG_REPLACE_EXISTING
60 | , &err);
61 |
62 | if (dbus_error_is_set(&err)) {
63 | fprintf(stderr, "Name Error (%s)\n", err.message);
64 | dbus_error_free(&err);
65 | }
66 |
67 | if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) {
68 | exit(1);
69 | }
70 |
71 | return (void*)conn;
72 | }
73 |
74 | void modbus_release_bus(void* vconn) {
75 | DBusConnection* conn = (DBusConnection*)vconn;
76 | dbus_connection_unref(conn);
77 | }
78 |
79 | void* modbus_msg_alloc(const char *target, const char* object, const char *interface, const char* method) {
80 | ModbusMessage* message = (ModbusMessage*)malloc(sizeof(ModbusMessage));
81 |
82 | message->msg = dbus_message_new_method_call(target, object, interface, method);
83 | if (NULL == message->msg) {
84 | fprintf(stderr, "Message Null\n");
85 | exit(1);
86 | }
87 |
88 | dbus_message_iter_init_append(message->msg, &(message->args));
89 | dbus_message_iter_open_container(&(message->args), DBUS_TYPE_ARRAY,
90 | DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
91 | DBUS_TYPE_STRING_AS_STRING
92 | DBUS_TYPE_VARIANT_AS_STRING
93 | DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
94 | &(message->dict));
95 |
96 | return message;
97 | }
98 |
99 | void modbus_msg_release(void* vmessage) {
100 | ModbusMessage* message = (ModbusMessage*)vmessage;
101 | // free message
102 | dbus_message_unref(message->msg);
103 | free(message);
104 | }
105 |
106 | const char* modbus_connection_send_msg(void* vconn, void* vmessage) {
107 | DBusConnection* conn = (DBusConnection*)vconn;
108 | ModbusMessage* message = (ModbusMessage*)vmessage;
109 | DBusMessage* reply;
110 | DBusMessageIter rargs;
111 | DBusPendingCall* pending;
112 | char* stat;
113 |
114 | dbus_message_iter_close_container(&(message->args), &(message->dict));
115 |
116 | // send message and get a handle for a reply
117 | if (!dbus_connection_send_with_reply (conn, message->msg, &pending, -1)) { // -1 is default timeout
118 | fprintf(stderr, "Out Of Memory!\n");
119 | exit(1);
120 | }
121 | if (NULL == pending) {
122 | fprintf(stderr, "Pending Call Null\n");
123 | exit(1);
124 | }
125 | dbus_connection_flush(conn);
126 |
127 | // block until we receive a reply
128 | dbus_pending_call_block(pending);
129 |
130 | // get the reply message
131 | reply = dbus_pending_call_steal_reply(pending);
132 | if (NULL == reply) {
133 | fprintf(stderr, "Reply Null\n");
134 | exit(1);
135 | }
136 |
137 | // free the pending message handle
138 | dbus_pending_call_unref(pending);
139 |
140 | // read the parameters
141 | if (!dbus_message_iter_init(reply, &rargs))
142 | fprintf(stderr, "Message has no arguments!\n");
143 | else if (DBUS_TYPE_STRING == dbus_message_iter_get_arg_type(&rargs))
144 | dbus_message_iter_get_basic(&rargs, &stat);
145 |
146 |
147 | stat = strdup(stat);
148 | // free reply and close connection
149 | dbus_message_unref(reply);
150 |
151 | // printf("Returning: %s\n", stat);
152 | return stat;
153 | }
154 |
155 | void msg_add_entry(const void* vmessage, const char* name, const void* val,
156 | const int type, const char* sig) {
157 |
158 | ModbusMessage* message = (ModbusMessage*)vmessage;
159 |
160 | /* prepare dictionary entry */
161 | DBusMessageIter entry;
162 | dbus_message_iter_open_container(&(message->dict), DBUS_TYPE_DICT_ENTRY, 0, &entry);
163 | dbus_message_iter_append_basic(&entry, DBUS_TYPE_STRING, &name);
164 |
165 | /* stuff value into variant */
166 | DBusMessageIter var;
167 | dbus_message_iter_open_container(&entry, DBUS_TYPE_VARIANT, sig, &var);
168 | dbus_message_iter_append_basic(&var, type, val);
169 | dbus_message_iter_close_container(&entry, &var);
170 |
171 | /* close dictionary entry */
172 | dbus_message_iter_close_container(&(message->dict), &entry);
173 |
174 | }
175 |
176 | void modbus_msg_add_double(void* message, const char* name, double value) {
177 | return msg_add_entry(message, name, &value, DBUS_TYPE_DOUBLE, DBUS_TYPE_DOUBLE_AS_STRING);
178 | }
179 |
180 | void modbus_msg_add_int(void* message, const char* name, int value) {
181 | return msg_add_entry(message, name, &value, DBUS_TYPE_INT32, DBUS_TYPE_INT32_AS_STRING);
182 | }
183 |
184 | void modbus_msg_add_string(void* message, const char* name, const char* value) {
185 | return msg_add_entry(message, name, &value, DBUS_TYPE_STRING, DBUS_TYPE_STRING_AS_STRING);
186 | }
187 |
188 | #ifdef __cplusplus
189 | }
190 | #endif
191 |
--------------------------------------------------------------------------------
/lib/modbus/src/c/modbus.h:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the Modelica3D package.
3 |
4 | Copyright (C) 2012-current year Christoph Höger and Technical University of Berlin
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU Lesser General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public License
17 | along with this program. If not, see .
18 |
19 | Main Author 2010-2013, Christoph Höger
20 | */
21 |
22 | #include
23 | #include
24 |
25 | #ifdef __cplusplus
26 | extern "C"
27 | {
28 | #endif
29 |
30 | void* modbus_acquire_session_bus(const char * client_name);
31 |
32 | void modbus_release_bus(void* conn);
33 |
34 | void* modbus_msg_alloc(const char *target, const char* object, const char *interface, const char* method);
35 |
36 | void modbus_msg_release(void* msg);
37 |
38 | void modbus_msg_add_double(void* msg, const char* name, double value);
39 |
40 | void modbus_msg_add_int(void* msg, const char* name, int value);
41 |
42 | void modbus_msg_add_string(void* msg, const char* name, const char* value);
43 |
44 | const char* modbus_connection_send_msg(void* vconn, void* vmessage);
45 |
46 | #ifdef __cplusplus
47 | }
48 | #endif
49 |
--------------------------------------------------------------------------------
/lib/modbus/src/modelica/modbus/package.mo:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the Modelica3D package.
3 |
4 | Copyright (C) 2012-current year Christoph Höger and Technical University of Berlin
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU Lesser General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public License
17 | along with this program. If not, see .
18 |
19 | Main Author 2010-2013, Christoph Höger
20 | */
21 |
22 | within ModelicaServices;
23 |
24 | package modbus
25 |
26 | model Foo
27 | Connection c = Connection("myName");
28 | end Foo;
29 |
30 | class Connection
31 | extends ExternalObject;
32 |
33 | function constructor
34 | annotation(Include = "#include ", Library = {"modbus", "dbus-1"});
35 | input String clientName;
36 | output Connection conn;
37 | external "C" conn = modbus_acquire_session_bus(clientName);
38 | end constructor;
39 |
40 | function destructor
41 | annotation(Include = "#include ", Library = {"modbus", "dbus-1"});
42 | input Connection conn;
43 | external "C" modbus_release_bus(conn);
44 | end destructor;
45 |
46 | end Connection;
47 |
48 | class Message
49 | extends ExternalObject;
50 |
51 | function constructor
52 | annotation(Include = "#include ", Library = {"modbus", "dbus-1"});
53 | input String target;
54 | input String object;
55 | input String interface;
56 | input String method;
57 |
58 | output Message msg;
59 | external "C" msg = modbus_msg_alloc(target, object, interface, method);
60 | end constructor;
61 |
62 | function destructor
63 | annotation(Include = "#include ", Library = {"modbus", "dbus-1"});
64 | input Message msg;
65 | external "C" modbus_msg_release(msg);
66 | end destructor;
67 |
68 | end Message;
69 |
70 | function sendMessage
71 | input Connection conn;
72 | input Message msg;
73 | output String result;
74 | external "C" result = modbus_connection_send_msg(conn, msg);
75 | end sendMessage;
76 |
77 | function addReal
78 | input Message msg;
79 | input String name;
80 | input Real val;
81 | external "C" modbus_msg_add_double(msg, name, val);
82 | end addReal;
83 |
84 | function addInteger
85 | input Message msg;
86 | input String name;
87 | input Integer val;
88 | external "C" modbus_msg_add_int(msg, name, val);
89 | end addInteger;
90 |
91 | function addString
92 | input Message msg;
93 | input String name;
94 | input String val;
95 | external "C" modbus_msg_add_string(msg, name, val);
96 | end addString;
97 |
98 | end modbus;
99 |
--------------------------------------------------------------------------------
/lib/modcount/CMakeLists.txt:
--------------------------------------------------------------------------------
1 |
2 | set(modcount_src "${CMAKE_SOURCE_DIR}/lib/modcount/src/")
3 |
4 | # modcount c-library
5 | add_library(modcount "${modcount_src}/c/modcount.c")
6 |
7 | add_definitions(-fPIC)
8 |
9 | if(USE_OMC)
10 | # Modelica library to install
11 | install(DIRECTORY "${modcount_src}/modelica/modcount"
12 | DESTINATION "${OMC_MOD_LIB_DIR}/${MODELICA_SERVICES_LIBRARY}")
13 |
14 | # Install library header
15 | install(FILES "${modcount_src}/c/modcount.h" DESTINATION ${OMC_INCLUDE_DIR})
16 |
17 | install(TARGETS modcount
18 | LIBRARY DESTINATION ${OMC_LIBRARY_DIR}
19 | ARCHIVE DESTINATION ${OMC_LIBRARY_DIR}
20 | )
21 | endif(USE_OMC)
22 |
--------------------------------------------------------------------------------
/lib/modcount/src/c/modcount.c:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 |
6 | #include "modcount.h"
7 |
8 | /**
9 | * This is both a very simple example of an external Modelica library
10 | * and a very useful tool. If you ever find yourself in need for a mutable
11 | * counter in Modelica, use this pattern.
12 | */
13 |
14 | typedef struct _Context {
15 | int counter;
16 | } Context;
17 |
18 | void* modcount_acquire_context() {
19 | Context* ctxt = (Context*)malloc(sizeof(Context));
20 | ctxt -> counter = 0;
21 | return ctxt;
22 | }
23 |
24 | int modcount_get(void* vctxt) {
25 | Context* ctxt = (Context*)vctxt;
26 | return ctxt -> counter;
27 | }
28 |
29 | int modcount_set(void* vctxt, int val) {
30 | Context* ctxt = (Context*)vctxt;
31 | ctxt -> counter = val;
32 | return ctxt -> counter;
33 | }
34 |
35 | void modcount_release_context(void* vctxt) {
36 | free(vctxt);
37 | }
38 |
39 | /**
40 | * Modelica tools will free strings passed to external functions,
41 | * so we need to hide our string objects on the heap...
42 | */
43 | void* modcount_acquire_string(const char *content) {
44 | /* we do not know modelica's string length
45 | Instead of char*, we could also use C++ std::string here ...
46 | */
47 | char **res = (char**) malloc(sizeof(char*));
48 | const size_t len = strlen(content);
49 | char* buf = (char*)calloc(len+1, sizeof(char)); // +1 since it is 0-terminated
50 | strcpy(buf, content);
51 | *res = buf;
52 | return (void*) res;
53 | }
54 |
55 | void modcount_release_string(void *obj) {
56 | char **str = (char**) obj;
57 | free(*str);
58 | free(str);
59 | }
60 |
61 | const char* modcount_get_string(void *str) {
62 | /* copy, so omc does _not_ free */
63 | const char** content = (const char**) str;
64 | const size_t len = strlen(*content);
65 | char* buf = (char*)calloc(len+1,sizeof(char)); // +1 since it is 0-terminated
66 | strncpy(buf, *content, len+1);
67 | return buf;
68 | }
69 |
70 | void modcount_set_string(void *obj, const char *content) {
71 | const size_t len = strlen(content);
72 | char **res = (char**) obj;
73 | *res = realloc(*res, sizeof(char)*(len+1));
74 | strncpy(*res, content, len+1);
75 | }
76 |
--------------------------------------------------------------------------------
/lib/modcount/src/c/modcount.h:
--------------------------------------------------------------------------------
1 | void* modcount_acquire_context();
2 |
3 | void modcount_release_context(void* vctxt);
4 |
5 | int modcount_get(void* vctxt);
6 |
7 | int modcount_set(void* vctxt, int val);
8 |
9 | void* modcount_acquire_string(const char* content);
10 |
11 | void modcount_release_string(void* str);
12 |
13 | const char* modcount_get_string(void* str);
14 |
--------------------------------------------------------------------------------
/lib/modcount/src/modelica/Test.mo:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the Modelica3D package.
3 |
4 | Copyright (C) 2012-current year Christoph Höger and Technical University of Berlin
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU Lesser General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public License
17 | along with this program. If not, see .
18 |
19 | Main Author 2010-2013, Christoph Höger
20 | */
21 |
22 | model Test
23 | import ModelicaServices.modcount;
24 |
25 | /* whenever this function is evaluated, increase the counter */
26 | function f
27 | input modcount.Context context;
28 | input Real x;
29 | output Real y;
30 |
31 | algorithm
32 | modcount.increase_get(context);
33 | y := x;
34 | end f;
35 |
36 | Real x;
37 | Integer i;
38 | modcount.Context context = modcount.Context();
39 |
40 | equation
41 | when sample(1,1) then
42 | /* read the counter */
43 | i = modcount.get(context);
44 | end when;
45 |
46 | der(x) = f(context, time);
47 |
48 | end Test;
49 |
--------------------------------------------------------------------------------
/lib/modcount/src/modelica/modcount/package.mo:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the Modelica3D package.
3 |
4 | Copyright (C) 2012-current year Christoph Höger and Technical University of Berlin
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU Lesser General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public License
17 | along with this program. If not, see .
18 |
19 | Main Author 2010-2013, Christoph Höger
20 | */
21 |
22 | within ModelicaServices;
23 |
24 | package modcount
25 |
26 | class Context
27 | extends ExternalObject;
28 |
29 | function constructor
30 | annotation(Include = "#include ", Library = {"modcount"});
31 | output Context context;
32 | external "C" context = modcount_acquire_context();
33 | end constructor;
34 |
35 | function destructor
36 | annotation(Include = "#include ", Library = {"modcount"});
37 | input Context context;
38 | external "C" modcount_release_context(context);
39 | end destructor;
40 | end Context;
41 |
42 | function set
43 | annotation(Include = "#include ", Library = {"modcount"});
44 | input Context c;
45 | input Integer i;
46 | output Integer out;
47 | external "C" out = modcount_set(c, i);
48 | end set;
49 |
50 | function get
51 | annotation(Include = "#include ", Library = {"modcount"});
52 | input Context c;
53 | output Integer i;
54 | external "C" i = modcount_get(c);
55 | end get;
56 |
57 | function increase_get
58 | input Context c;
59 | output Integer i;
60 | algorithm
61 | i := get(c);
62 | i := set(c, i + 1);
63 | end increase_get;
64 |
65 | class HeapString
66 | extends ExternalObject;
67 |
68 | function constructor
69 | annotation(Include = "#include ", Library = {"modcount"});
70 | input String content;
71 | output HeapString str;
72 | external "C" str = modcount_acquire_string(content);
73 | end constructor;
74 |
75 | function destructor
76 | annotation(Include = "#include ", Library = {"modcount"});
77 | input HeapString str;
78 | external "C" modcount_release_string(str);
79 | end destructor;
80 | end HeapString;
81 |
82 | function setString
83 | input HeapString str;
84 | input String val;
85 | annotation(Include = "#include ", Library = {"modcount"});
86 | external "C" modcount_set_string(str,val);
87 | end setString;
88 |
89 | function getString
90 | input HeapString str;
91 | output String val;
92 | annotation(Include = "#include ", Library = {"modcount"});
93 | external "C" val = modcount_get_string(str);
94 | end getString;
95 |
96 | end modcount;
97 |
--------------------------------------------------------------------------------
/lib/proc3d/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | find_package(Boost REQUIRED)
2 |
3 | if(MINGW)
4 | add_definitions(-std=c++0x -fPIC -U__STRICT_ANSI__)
5 | else(MINGW)
6 | add_definitions(-std=c++0x -fPIC)
7 | endif(MINGW)
8 |
9 | include_directories(${Boost_INCLUDE_DIR})
10 | set(proc3d_src "${CMAKE_SOURCE_DIR}/lib/proc3d/src/")
11 |
12 | add_library(proc3d SHARED "${proc3d_src}/proc3d.cpp")
13 |
14 | install(TARGETS proc3d
15 | RUNTIME DESTINATION bin
16 | LIBRARY DESTINATION lib
17 | ARCHIVE DESTINATION lib
18 | )
19 |
--------------------------------------------------------------------------------
/lib/proc3d/src/animationContext.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the Modelica3D package.
3 |
4 | Copyright (C) 2012-current year Christoph Höger and Technical University of Berlin
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU Lesser General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public License
17 | along with this program. If not, see .
18 |
19 | Main Author 2010-2013, Christoph Höger
20 | */
21 |
22 | #include
23 | #include
24 |
25 | #include "operations.hpp"
26 |
27 | namespace proc3d {
28 |
29 | struct get_time : boost::static_visitor {
30 | template
31 | double operator()(const T& op) const {
32 | return op.time;
33 | }
34 | };
35 |
36 | static inline double time_of(const AnimOperation& op) {
37 | return boost::apply_visitor( get_time(), op );
38 | }
39 |
40 | struct compare_frames : boost::static_visitor {
41 | template
42 | bool operator()(const T1& op1, const T2& op2) const {
43 | return op1.time > op2.time;
44 | }
45 | };
46 |
47 | struct AnimationComparator {
48 | bool operator()(const AnimOperation& op1, const AnimOperation& op2) const {
49 | return boost::apply_visitor( compare_frames(), op1, op2 );
50 | }
51 | };
52 |
53 | typedef std::priority_queue, AnimationComparator> animation_queue;
54 | class AnimationContext {
55 | public:
56 | std::queue setupOps;
57 | animation_queue deltaOps;
58 |
59 | virtual void handleSignal(const int signal) {
60 | };
61 | };
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/lib/proc3d/src/operations.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the Modelica3D package.
3 |
4 | Copyright (C) 2012-current year Christoph Höger and Technical University of Berlin
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU Lesser General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public License
17 | along with this program. If not, see .
18 |
19 | Main Author 2010-2013, Christoph Höger
20 | */
21 |
22 | #pragma once
23 |
24 | #include
25 | #include
26 | #include
27 |
28 | namespace proc3d {
29 |
30 | using namespace boost; //array, variant
31 | using namespace boost::numeric::ublas; //bounded_matrix
32 |
33 | struct ObjectOperation {
34 | ObjectOperation(const std::string& name) : name(name) {}
35 | std::string name;
36 | };
37 |
38 | struct CreateGroup : ObjectOperation {
39 | CreateGroup(const std::string& name) : ObjectOperation(name) {}
40 | };
41 |
42 | struct LoadObject : ObjectOperation {
43 | LoadObject(const std::string& name, const std::string& f, const array& a) : ObjectOperation(name), fileName(f), at(a) {}
44 | std::string fileName;
45 | array at;
46 | };
47 |
48 | struct ObjectLinkOperation : ObjectOperation {
49 | ObjectLinkOperation(const std::string& name, const std::string& target) : ObjectOperation(name), target(target) {}
50 | std::string target;
51 | };
52 |
53 | struct AddToGroup : ObjectLinkOperation {
54 | AddToGroup(const std::string& name, const std::string& target) : ObjectLinkOperation(name, target) {}
55 | };
56 |
57 | struct CreateMaterial : ObjectOperation {
58 | CreateMaterial(const std::string& name) : ObjectOperation(name) {}
59 | };
60 |
61 | struct ApplyMaterial : ObjectLinkOperation {
62 | ApplyMaterial(const std::string& name, const std::string& target) : ObjectLinkOperation(name, target) {}
63 | };
64 |
65 | struct CreateSphere : ObjectOperation {
66 | CreateSphere(const std::string& name, const double r) : ObjectOperation(name), radius(r) {}
67 | double radius;
68 | };
69 |
70 | struct CreateBox : ObjectOperation {
71 | CreateBox(const std::string& name, const double w, const double l, const double h, const array& a) : ObjectOperation(name), width(w), length(l), height(h), at(a) {}
72 | double width, length, height;
73 | array at;
74 | };
75 |
76 | struct CreateCylinder : ObjectOperation {
77 | CreateCylinder(const std::string& name, const double r, const double h, const array& a) : ObjectOperation(name), radius(r), height(h), at(a) {}
78 | double radius;
79 | double height;
80 | array at;
81 | };
82 |
83 | struct CreateCone : ObjectOperation {
84 | CreateCone(const std::string& name, const double r, const double h, const array& a) : ObjectOperation(name), radius(r), height(h), at(a) {}
85 | double radius;
86 | double height;
87 | array at;
88 | };
89 |
90 | struct CreatePlane : ObjectOperation {
91 | CreatePlane(const std::string& name, const double l, const double w) : ObjectOperation(name), length(l), width(w) {}
92 | double length;
93 | double width;
94 | };
95 |
96 | struct DeltaOperation : ObjectOperation {
97 | DeltaOperation(const std::string& name, const double t) : ObjectOperation(name), time(t) {}
98 | double time;
99 | };
100 |
101 | struct Move : DeltaOperation {
102 | Move(const std::string& name, const double t, const double x, const double y, const double z) : DeltaOperation(name, t), x(x), y(y), z(z) {}
103 | double x,y,z;
104 | };
105 |
106 | struct Scale : DeltaOperation {
107 | Scale(const std::string& name, const double t, const double x, const double y, const double z) : DeltaOperation(name, t), x(x), y(y), z(z) {}
108 | double x,y,z;
109 | };
110 |
111 | struct RotateEuler : DeltaOperation {
112 | RotateEuler(const std::string& name, const double t, const double x, const double y, const double z) : DeltaOperation(name, t), x(x), y(y), z(z) {}
113 | double x,y,z;
114 | };
115 |
116 | struct RotateMatrix : DeltaOperation {
117 | RotateMatrix(const std::string& name, const double t, const bounded_matrix& m) : DeltaOperation(name, t), m(m) {}
118 | bounded_matrix m;
119 | };
120 |
121 | struct SetMaterialProperty : DeltaOperation {
122 | SetMaterialProperty(const std::string& name, const double t, const std::string& p, const double v) : DeltaOperation(name, t), property(p), value(v) {}
123 | std::string property;
124 | double value;
125 | };
126 |
127 | struct SetAmbientColor : DeltaOperation {
128 | SetAmbientColor(const std::string& name, const double t,
129 | const double r, const double g, const double b, const double a) :
130 | DeltaOperation(name, t) {color[0] = r;color[1] = g;color[2] = b;color[3] = a;}
131 | array color;
132 | };
133 |
134 | struct SetDiffuseColor : DeltaOperation {
135 | SetDiffuseColor(const std::string& name, const double t,
136 | const double r, const double g, const double b, const double a) :
137 | DeltaOperation(name, t){color[0] = r;color[1] = g;color[2] = b;color[3] = a;}
138 | array color;
139 | };
140 |
141 | struct SetSpecularColor : DeltaOperation {
142 | SetSpecularColor(const std::string& name, const double t,
143 | const double r, const double g, const double b, const double a) :
144 | DeltaOperation(name, t){color[0] = r;color[1] = g;color[2] = b;color[3] = a;}
145 | array color;
146 | };
147 |
148 | typedef variant SetupOperation;
151 |
152 | typedef variant AnimOperation;
154 |
155 | }
156 |
157 |
158 |
--------------------------------------------------------------------------------
/lib/proc3d/src/proc3d.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the Modelica3D package.
3 |
4 | Copyright (C) 2012-current year Christoph Höger and Technical University of Berlin
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU Lesser General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public License
17 | along with this program. If not, see .
18 |
19 | Main Author 2010-2013, Christoph Höger
20 | */
21 |
22 | #include "proc3d.hpp"
23 | #include "operations.hpp"
24 | #include "animationContext.hpp"
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | using namespace boost::assign;
31 |
32 | namespace proc3d {
33 |
34 | static inline AnimationContext* getContext(void* ptr) {
35 | return (AnimationContext*) ptr;
36 | }
37 |
38 | extern "C" {
39 |
40 | /* memory management */
41 |
42 | void* proc3d_animation_context_new() {
43 | return new AnimationContext();
44 | }
45 |
46 | void proc3d_animation_context_free(void* context) {
47 | delete getContext(context);
48 | }
49 |
50 | /* setup ops */
51 |
52 | void proc3d_load_object(void* context, const char* name, const char* filename, const double x, const double y, const double z) {
53 | boost::array arr = {x,y,z};
54 | getContext(context)->setupOps.push(LoadObject(name, filename, arr));
55 | }
56 |
57 | void proc3d_create_group(void* context, const char* name) {
58 | getContext(context)->setupOps.push(CreateGroup(name));
59 | }
60 |
61 | void proc3d_create_material(void* context, const char* name, const double r, const double g, const double b, const double a) {
62 | getContext(context)->setupOps.push(CreateMaterial(name));
63 | }
64 |
65 | void proc3d_create_sphere(void* context, const char* name, const double radius) {
66 | getContext(context)->setupOps.push(CreateSphere(name, radius));
67 | }
68 |
69 | void proc3d_create_box(void* context, const char* name,
70 | const double x, const double y, const double z,
71 | const double width, const double length, const double height) {
72 | boost::array arr = {x,y,z};
73 | getContext(context)->setupOps.push(CreateBox(name, width, length, height, arr));
74 | }
75 |
76 | void proc3d_create_plane(void* context, const char* name, const double width, const double length) {
77 | getContext(context)->setupOps.push(CreatePlane(name, width, length));
78 | }
79 |
80 | void proc3d_create_cylinder(void* context, const char* name, const double x, const double y, const double z, const double height, const double radius) {
81 | boost::array arr = {x,y,z};
82 | CreateCylinder cylinder = CreateCylinder(name, radius, height, arr);
83 | getContext(context)->setupOps.push(cylinder);
84 | }
85 |
86 | void proc3d_create_cone(void* context, const char* name, const double x, const double y, const double z, const double height, const double radius) {
87 | boost::array arr = {x,y,z};
88 | getContext(context)->setupOps.push(CreateCone(name, radius, height, arr));
89 | }
90 |
91 | void proc3d_add_to_group(void* context, const char* name, const char* target) {
92 | getContext(context)->setupOps.push(AddToGroup(name, target));
93 | }
94 |
95 | void proc3d_apply_material(void* context, const char* name, const char* target) {
96 | getContext(context)->setupOps.push(ApplyMaterial(name, target));
97 | }
98 |
99 | /* delta ops */
100 |
101 | void proc3d_set_rotation_euler(void* context, const char* name, const double x, const double y, const double z, const double time) {
102 | getContext(context)->deltaOps.push(RotateEuler(name, time, x, y, z));
103 | }
104 |
105 | void proc3d_set_rotation_matrix(void* context, const char* name,
106 | const double r11, const double r12, const double r13,
107 | const double r21, const double r22, const double r23,
108 | const double r31, const double r32, const double r33,
109 | const double time) {
110 | boost::numeric::ublas::bounded_matrix m;
111 | //TODO: This can probably be rewritten with some fancy boost function, I just can't figure out which one ...
112 | m(0,0) = r11; m(0,1) = r12; m(0,2) = r13;
113 | m(1,0) = r21; m(1,1) = r22; m(1,2) = r23;
114 | m(2,0) = r31; m(2,1) = r32; m(2,2) = r33;
115 |
116 | getContext(context)->deltaOps.push(RotateMatrix(name, time, m));
117 | }
118 |
119 | void proc3d_set_translation(void* context, const char* name, const double x, const double y, const double z, const double time) {
120 | getContext(context)->deltaOps.push(Move(name, time,x,y,z));
121 | }
122 |
123 | void proc3d_set_scale(void* context, const char* name, const double x, const double y, const double z, const double time) {
124 | getContext(context)->deltaOps.push(Scale(name, time,x,y,z));
125 | }
126 |
127 | void proc3d_set_material_property(void* context, const char* name, const char* property, const double value, const double time) {
128 | getContext(context)->deltaOps.push(SetMaterialProperty(name, time, property, value));
129 | }
130 |
131 | void proc3d_set_ambient_color(void* context, const char* name, const double r, const double g, const double b, const double a, const double time) {
132 | getContext(context)->deltaOps.push(SetAmbientColor(name, time, r, g, b, a));
133 | }
134 |
135 | void proc3d_set_specular_color(void* context, const char* name, const double r, const double g, const double b, const double a, const double time) {
136 | getContext(context)->deltaOps.push(SetSpecularColor(name, time, r, g, b, a));
137 | }
138 |
139 | void proc3d_set_diffuse_color(void* context, const char* name, const double r, const double g, const double b, const double a, const double time) {
140 | getContext(context)->deltaOps.push(SetDiffuseColor(name, time, r, g, b, a));
141 | }
142 |
143 | /* signals */
144 |
145 | void proc3d_send_signal(void* context, const int signal) {
146 | getContext(context)->handleSignal(signal);
147 | }
148 |
149 | }
150 | }
151 |
--------------------------------------------------------------------------------
/lib/proc3d/src/proc3d.hpp:
--------------------------------------------------------------------------------
1 | /*
2 | This file is part of the Modelica3D package.
3 |
4 | Copyright (C) 2012-current year Christoph Höger and Technical University of Berlin
5 |
6 | This program is free software: you can redistribute it and/or modify
7 | it under the terms of the GNU Lesser General Public License as published by
8 | the Free Software Foundation, either version 3 of the License, or
9 | (at your option) any later version.
10 |
11 | This program is distributed in the hope that it will be useful,
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | GNU General Public License for more details.
15 |
16 | You should have received a copy of the GNU Lesser General Public License
17 | along with this program. If not, see .
18 |
19 | Main Author 2010-2013, Christoph Höger
20 | */
21 |
22 | #pragma once
23 |
24 | #include
25 |
26 | #include "operations.hpp"
27 |
28 | extern "C" {
29 |
30 | /* memory management */
31 |
32 | void* proc3d_animation_context_new();
33 |
34 | void proc3d_animation_context_free(void* pAnimationContext);
35 |
36 | /* setup ops */
37 |
38 | void proc3d_load_object(void* context, const char* name, const char* filename, const double x, const double y, const double z);
39 |
40 | void proc3d_create_group(void* context, const char* name);
41 |
42 | void proc3d_create_material(void* context, const char* name, const double r, const double g, const double b, const double a);
43 |
44 | void proc3d_create_sphere(void* context, const char* name, const double radius);
45 |
46 | void proc3d_create_box(void* context, const char* name,
47 | const double tx, const double ty, const double tz,
48 | const double width, const double length, const double height);
49 |
50 | void proc3d_create_plane(void* context, const char* name, const double width, const double length);
51 |
52 | void proc3d_create_cylinder(void* context, const char* name,
53 | const double tx, const double ty, const double tz,
54 | const double height, const double radius);
55 |
56 | void proc3d_create_cone(void* context, const char* name,
57 | const double tx, const double ty, const double tz,
58 | const double height, const double radius);
59 |
60 | void proc3d_add_to_group(void* context, const char* name, const char* target);
61 |
62 | void proc3d_apply_material(void* context, const char* name, const char* target);
63 |
64 | /* delta ops */
65 |
66 | void proc3d_set_rotation_euler(void* context, const char* name, const double x, const double y, const double z, const double time);
67 |
68 | void proc3d_set_rotation_matrix(void* context, const char* name,
69 | const double r11, const double r12, const double r13,
70 | const double r21, const double r22, const double r23,
71 | const double r31, const double r32, const double r33,
72 | const double time);
73 |
74 | void proc3d_set_translation(void* context, const char* name, const double x, const double y, const double z, const double time);
75 |
76 | void proc3d_set_scale(void* context, const char* name, const double x, const double y, const double z, const double time);
77 |
78 | void proc3d_set_material_property(void* context, const char* name, const char* property, const double value, const double time);
79 |
80 | /* coloring */
81 | void proc3d_set_ambient_color(void* context, const char* name, const double r, const double g, const double b, const double a, const double time);
82 |
83 | void proc3d_set_specular_color(void* context, const char* name, const double r, const double g, const double b, const double a, const double time);
84 |
85 | void proc3d_set_diffuse_color(void* context, const char* name, const double r, const double g, const double b, const double a, const double time);
86 |
87 | /* signals */
88 |
89 | void proc3d_send_signal(void* context, const int signal);
90 |
91 | }
92 |
93 |
94 |
95 |
96 |
97 |
98 |
--------------------------------------------------------------------------------
/test/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | add_test(NAME "pendulum"
2 | COMMAND ${OMC_COMPILER} "${CMAKE_SOURCE_DIR}/test/test.mos")
3 |
--------------------------------------------------------------------------------
/test/test.mos:
--------------------------------------------------------------------------------
1 | loadModelica3D();getErrorString();
2 | loadString("model DoublePendulum
3 | extends Modelica.Mechanics.MultiBody.Examples.Elementary.DoublePendulum;
4 | inner ModelicaServices.Modelica3D.Controller m3d_control;
5 | end DoublePendulum;");getErrorString();
6 | system("python " + getInstallationDirectoryPath() + "/lib/omlibrary-modelica3d/osg-gtk/dbus-server.py &");getErrorString();
7 | res:=simulate(DoublePendulum);getErrorString();
8 | exit(if res.resultFile <> "" then 0 else 1);
9 |
--------------------------------------------------------------------------------