Instantiation of equation - modelica

I am trying to model a pump system. The system consists of a controller, two ON/OFF valves, and a swept volume acting as a chamber. The controller is responsible for the state of the valves as well as filling the volume and pumping it.
When connecting all the components together, i started getting errors saying " Failed to instantiate equation between components ", for example between the swept volume and the first valve. I tried to delete the valves from the whole system and connect the piston directly to the source, but i then got an error saying "Failed to instantiate equation .." between the piston displacment and its input.
I couldn't understand where is my problem to be exact. Is it with the model themselves that they cannot be connected together or am i missing something else?
I am not an expert in modelica obviously, but i got the basics of course.
To make things clearer, here's the link to my model:
https://www.dropbox.com/s/g9dr40jame3lk2n/pumpsystem.zip?dl=0
Any help would be appreciated.

OpenModelica complains about obsolete connections. You have many connections in your model between components which don't exist anymore.
For example:
connect(ChamberController.PistonDisplacment, sweptVolume1.flange) annotation(...);
connect(close.on, ChamberController.deflate) annotation(...);
To remove these connections, simply click the link in the Messages Browser, which will bring you directly to the correct position in the code.

Related

Transport gets stuck

I'm implementing a model in which many transport (Transport fleet, Material Handling library) move in the same network.
I've got some limited access paths ( limited to 1 transport).
The intersection between two or more path are nodes; in this way if a path is already occupied it will stay in the node until the path is free again.
The model seems to run until some transport get stuck (see screenshot).
At the moment Transport are able to resolve collision, but if the Resolve collision parameter is false then when transports get stuck a collision is detected.
I think transport cannot choose who can be the first to can cross the path (my thought, any suggestion is appreciated).
It is not a constant problem, it can happen at different times of the one year simulation or not happen at all.
What's the problem? How can I solve it?
Thanks
Transport stuck image
The problem is that the underlying algorithms cannot possibly work for any situation or foresee any eventuality.
Either you use the build-in resolution or you have to apply custom intelligence, route-finding and decision-making, which is possible but not trivial :)

Which file to extend for customized messages in veins? What is the purpose of AirFrame11p.msg?

I'm new to SUMO, Veins, OMNET++ and simulations with a bit background of networks. I have successfully setup environment and run veins 4.6 demo application. On google found that unlike RSU, Car modules are added on the fly.
In demo example car nodes send Airframe11p message, i'm not getting where this message is being populated because in TraCIDemo11p.cc methods (onWSA, onWSM, handleSelfMsg, handlePositionUpdate) we are dealing with WSM message types and BaseWaveApplLayer::checkAndTrackPacket methods ensures that message being sent is either BSM, WSM or WSA.
In veins\src\veins\modules\messages AirFrame11p.msg file exists but on finding references of "AirFrame11p" in project, matches are found in AirFrame11p_m.h and AirFrame11p_m.cc only. If demo is not using these files then for what purpose these files are added? and from where simulation gets the annotation of AirFrame11p.
I'm trying to simulate a car accident scenario without RSU using V2V communication, have replaced demo map with mine, generated random routes, now trying to remove RSU from demo application and exploring to send customized messages (including geo location, speed, direction, time etc) to nearby vehicles in specified range e.g. 100 meters using WiFi direct.
If i'm confusing something then please guide me. Thanks.
The short answer: The AirFrame11p message is a lower level message that encapsulates the upper layer messages. Just use the application message type that is appropriate for your application. If you want to replace the physical layer with WiFi direct instead of 11p, and you're starting from scratch, you're probably in for quite a bit of work, since the VEINS PHY implementation is very intricate. If you have an existing implementation of WiFi direct, it may be worth investigating the integration of VEINS' TraCI implementation with that code.
Encapsulation in VEINS
You are correct that the message types at the application layer are more diverse -- these message types (BSM and WSM) are used to encapsulate "application" behavior; it's just not very well visualized in the simulation execution. You can pause the simulation and look (for example) under scheduled events, where the queued packets can be examined visually.
Unlike regular networks, where such messages would be packaged in IP, MAC and PHY encapsulations, VEINS uses the following encapsulation process: BSMs are packaged in MAC frames (80211Pkt), which in turn are encapsulated by AirFrame11p signals. So basically, you should choose the correct message type for your application.
Footnote regarding application behavior:
Technically speaking, these messages would be more correctly placed at the Facilities layer (see e.g. ETSI's spec), since the periodic exchange of messages provides data stored in the facilities layer, which is then used by cITS/VANET applications that run on top. If you need this, look at Artery (as Ventu suggested in the comments).

Simulink: List programmatically the connections between subsystems

I have a Simulink model that includes a lot of inter-connected subsystems. A lot of these subsystems are connected to the other with "goto" objects. For verification and documentation purpose, I need to get the complete list of inputs/outputs of each sub-system, and check that the subsystem are connected between them as expected. Checking manually each connection is really time consuming and I often make mistakes doing it. Is there a way (function/script/command) to obtain the list automatically? Thank you very much if you can help me.
Firstly, have you considered using the Simulink Model Advisor to do this? You can create your own custom checks.
Secondly, it is possible to determine which blocks a sub-system (or any other block is connected to)
Selecting a block manually in the model and then running the following, will give you a cell array of all the blocks that the current block is connected to.
connected_to = get_param(gcb,'PortConnectivity')
If the block has 4 inputs, then the connected_to variable will contain 4 items. You can get the Source Block name by doing
srcBlockName = connected_to(1).SrcBlock;
Typically you would work from the outports back through the model to the inports or other source blocks checking what is connected to each.

My simple Stateflow model shows error

I'm almost new to Simulink and Stateflow. I am trying to model some simple state machines. But when trying to run the model, it shows errors (on the main Matlab screen).
Warning: Input port 1 of 'sample/If' is not connected.
Warning: Output port 1 of 'sample/If' is not connected.
Parsing failed for machine: "sample"(#90)
1) Is there anything wrong with this?
2) One more question: How can I add a timer on S2? e.g. we can not stay more than 2 minutes on S2. So as soon as we enter S2, a timer starts, and when it reaches 2 minutes, then should transition to S3.
P.S. For some reasons, the stateflow thumbnail on simulink scheme is not showing the updated model; there is no condition and if_outfput variables anymore!
Well, the error message is pretty self-explanatory: you haven't connected the input Condition of your Stateflow chart to anything, hence the error. Connect it to a signal in your Simulink (whatever represents your condition signal). Likewise, you haven't connected the output of the chart to anything either. You say these variables aren't there anymore, but Stateflow doesn't seem to think so. Have you deleted them from the Model Explorer? If not, Stateflow will still think they're part of the chart. See Use the Model Explorer with Stateflow Objects in the documentation for more details.
For the timer, yes it's possible. At the moment, you exit S2 to S3 when input ==1. You can change the transition to be [input == 1] || after(2000,sec) (I think). You may need to enable support for absolute time in the model configuration parameters. See Control Chart Execution Using Temporal Logic in the documentation for more details.

gtk signal for moving a scale(slider)?

Simple question:
I've added some scales (sliders) to my window, and I want to call a method when you move the scale.
What is the signal name that I use for gtk_signal_connect?
ie I should be able to write something like:
gtk_signal_connect(GTK_OBJECT(my_scale), "scale_moved", (GtkSignalFunc)my_event, data);
or am I missing something here?
And more importantly - how do I find out in the future what the signal names are? for example - I googled 'gtk_signal_connect' but I didn't find a big list of different signals.
Similarly, I didn't find details about related signals in the GtkScale documentation. (Well, in this page, there is a single signal detail, but it relates to changing the displayed value format).
GtkScale inherits from GtkRange, and signals are inherited in GTK+. Therefore, you can connect to the value-changed signal exposed by GtkRange.
You're on the right track to find the signals exposed by a given GTK+ widget: besides the source code itself, the documentation is indeed the canonical resource, but you should also take the base classes into account in your search.