12-19-2017 06:00 AM
Hello everybody,
I would like to initilize sensors on a track with a drag and drop method (see the attached screenshot). Unfortunatly, my code does not put the sensors at the right postions.
Here is my code, which I got from the book from Steffen Bangsow:
(obj:string) is posi:real; station:object; found:boolean; sensorID:integer; do --create reference station:=str_to_obj(obj); -- calculate x position posi:=(station.xPos-self.~.segmentsTable[1,1])* self.~.location.scalingFactor; -- look in the sensorList self.~.sensorlist.setCursor(1,1); found:=self.~.sensorlist.find(station); -- found, move sensor if found then self.~.sensorID(self.~.sensorList[1, self.~.sensorlist.zeigerY]).position:=posi; else -- create new Sensor sensorId:=self.~.createSensor(posi,"Länge","sensorControl"); -- create entry self.~.sensorlist.writeRow(1,self.~.sensorList.yDim+ 1,sensorID,station); end; end;
I know that my definition of the y-Position is wrong, but I am not sure how to change it. I appreciate every suggestion or hint!
Thank you very much in advance!
Solved! Go to Solution.
12-19-2017 06:10 AM
you need to change it for tracks in y direction:
posi:=(self.~.segmentsTable[2,1]-station.YPos)* self.~.location.scalingFactor;
Steffen Bangsow freelance simulation specialist web: www.bangsow.eu mail: steffen@bangsow.net | ![]() |
12-19-2017 07:47 AM