Here's a my question.
I want to express the followings,
1. The cars(transporters) should reduce their speed from 1m/s to 0.5m/s when they enter the track(rotary or roundabout) that i apply to sensor as a enterance.
2. The cars from "source" should go to "Line2" and "drain1"
The cars from "source1" should go to "Line1" and "drain"
The cars from "source2" should go to "Line4" and "drain3"
The cars from "source3" should go to "Line3" and "drain2"
( It means that every cars should go the opposite straight way.)
Please help me..i want to know...
After looking at your model, I can say that the sensors need to be adjusted to use your method. If you change them to be just the lane leading to the roundabout then you don't need to check what the destination is of the part to change it to always run.
To set where it is going, there is a 'Destination' attribute for the transporters which will make it automatically make its way to that object. All you need to do in the method is check where the transporter currently is and based from that set its destination to where you want it to go.
The speed can be changed by the 'Speed' attribute and can be changed to 0.5 when you enter the roundabout within the same method on that sensor, if you want it to be set back to 1 after then create another sensor on the other track using another method and get that other method to set it to 1.
Well, as said for each of your sensors on the tracks, you can se them to be at the end of your line where they currently are, where it sais 'Lanes' you can select the correct lane for which one feeds the roundabout as shown in the 2D icon (either Lane A or Lane B). You will want Frount to be checked and will want 'Activate' to be set to Always. Then for the 'Control' you will want that to point to your method.
In doing so it will change your method to accept 2 parameters, one is SensorID and is the ID of the sensor the triggered it and the other is Front which will say if the front of the MU (in this case the transporter) triggered it or the back. Both of these are not needed as they are not relevent to what you are trying to do but has to be there for it to work.
@ will point to the MU that triggered the event, so when you use the @ symbole it will point to the transporter.
@.~ will tell you where it currently is (at the time the event is triggered it will be on your two lane tracks).
@.Destination can be set to tell the transporter where to travel to.
Through checking where it is against the known locations of where it can be, you can set it to where you want it to end up.
@.Speed will set the speed of the transporter, so if you include this then you can get the speed of the transporter to change when it triggers the sensor.
As this sounds like the outline of a project you are doing as part of training (based of your previous traffic light system) I am reluctant to give you the answer. The method itself is simple and is not many lines of code and through using a different sensor method per sensor can be made even more simple (no need to check the current location that way).
I am not to sure how much more simple I can explain it without telling you what to type.
As your advice,
I tried to make it the destination first.
Here's my method below,
(senserID : integer)
-- To Control the destination using sensor---
if ?=Line1 and sensorID=1 then
if @.name="T1" then
else if ?=Line2 and sensorID=1 then
if @.name="T3" then
else if ?=Line3 and sensorID=1 then
if @.name="T2" then
else if ?=Line4 and sensorID=1 then
if @.name="T4" then
However, they are still going every where..
Few things, first of you have used 'else if' while it should be 'elseif' (1 word, no space between them) and also you are missing an 'end;' at the end of your code. If you reformat your code so every new if statment is indented so you step into them and step out when you put an end you will see the 'end' is missing of your 'is do end'.
For sensors, they take in 2 parameters, they are the sensorID (integer) and Front (Boolean), remember to check these spellings line up with else where in your code as in the model you provided it does not.
As stated before with the sensors on the 2 way tracks, they need to be set up correctly for the method to be triggered by the transporter. Attached is a screenshoot of how I would configure each of the sensors, changing the length and 'Lane A' as required to ensure that it is always on the side that feeds the roundabout.
As for the method itself and what you have done, it is along the right lines but I do not see why you check the name of the transporter. Remove that if statment and leave in place setting the destination and see what happens. At the same time you can remove the 'and sensorID=1' if you wish as for now all sensors have an ID of 1 as each track only has 1 sensor.
First of all,
Great honors to give me the big advices,
From your advice,
I made some corrections,
(senserID : integer; Front : Boolean)
-- To Control the destination using sensor---
if ?=Line1 then
--if @.name="T1" then
elseif ?=Line2 then
--if @.name="T3" then
elseif ?=Line3 then
--if @.name="T2" then
elseif ?=Line4 then
--if @.name="T4" then
As you mentioned, I input the "front : Boolean",
and, rearrange "elseif", and remove trasnpoters ID"T1~T4"
and, also remove "SensorID=1"
Finally it works,
Here's my further question for method,
You said that i need to use sensors as a trigger before, i understood that "trigger" need some special order in method.
So i made each name of transproters' names as a trigger,
"if ?=Line1 and SenserID=1 then" means that the SensorID=1 on the Line1.
"if @.name="T1" then" means, i believed that the name of T1 could be the trigger of method.
After that the destination line which was "@.destination:Line2;"
!!!for speed control!!!
i will do my best for this one.
I am attaching SPP file for "Roundabout"
Anyway I still need further study for Plant simulation.
Looking good, setting up the different transports with colours does help a lot to see what is going on.
By trigger I more mean trigger the method itself. The method will sit there doing nothing until it has been triggered and is set to run, within Plant Sim there is different methods of triggering a method, these are:
Well arguably, the top one does not trigger your method as that is you yourself doing it and not your model, but you get the idea. Also just to point out, this is just the termonogy that I would use, others may use different words to mean the same time.
Then yes, depending on what triggers it and how many things could trigger it you need to then use logic statments inside the method to ensure it performs as expected and in this case, filter out what triggered it so we know where to sent it.
If you look back, you will see I have tried to explain the speed to you before, this should help you a lot, it should only be a line or so of code that needs to be added as every transporter is being changed to the same speed reguardless of where it currently is.