Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register
  • Index
  • » Users
  • » jms1986
  • » Profile

Posts

Posts

Oct-04-11 19:45:26
How to create a function that instantiate several objects of a class?
Category: Programming

I’m a engineer of Porto University and I’m doing a computer network simulation in Open Modelica and I’m facing some hard issues.
When a create a function in order to assign class variables and return a object that I’ve created, the compiler says that the object is not declared and I’m sure that it is because I declare this output as follow: output class_name object_name;
Can I create functions to assign an object attributes or parameters? If yes how can I do it? (a simple example would be enough).
If I change the class_name by Real it works but I really want to return a specific class object.
The other issue that I’m facing is the encapsulation of a certain class or function in a package since as soon as I create a new class and add some code in it and save it, the class it’s removed out of the package in OM edit 3.1.
How can I aggregate several tasks in one function that creates instances and assigns the attributes or parameters?
Can anybody tell me how can I create functions to assign class attributes and instantiate class objects so the code can be easily used by another person?
I’ve already created my network nodes model and it works but now I’m trying to create functions to set all the class objects and assign the attributes values.
I’m looking forward to participate in Modelica community.

Many thanks in advance.




Kind regards,
João Santos

  • Index
  • » Users
  • » jms1986
  • » Profile
You are here: