Real-time simulation problem

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2005
Posts: 62
Reputation: freemind is an unknown quantity at this point 
Solved Threads: 1
freemind's Avatar
freemind freemind is offline Offline
Junior Poster in Training

Real-time simulation problem

 
0
  #1
Jun 15th, 2006
Hi everybody! I recently wrote a little simulation program, that simulates a real-time elevator system with 3 elevators. Since the code is around 530 lines I presume it is not a good idea to paste it here. There is some number of minor flaws of logical type and I would be very thankful on any ideas or corrections.

Since I don't posses any web space and I believe that corrections will be (probably) move obvious on a personal machine I can send the code to the email of anybody who's interested. I guarantee that no harmful programs will come with the email, in case somebody may think so.

If somebody is interested please answer to this post or send me a personal message with your email. If you have a better proposition than the email option that I can think of at the moment - please, of course, share it with me

Thanks to all in advance!
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Real-time simulation problem

 
0
  #2
Jun 15th, 2006
Your program is divided into functions right?

Post the functions where you think the flaws are?
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 62
Reputation: freemind is an unknown quantity at this point 
Solved Threads: 1
freemind's Avatar
freemind freemind is offline Offline
Junior Poster in Training

Re: Real-time simulation problem

 
0
  #3
Jun 15th, 2006
They will make no sense without the other code. Besides the program is divided into files, besides the function and namespace division..
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Real-time simulation problem

 
0
  #4
Jun 15th, 2006
Just post the all the code then?
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 62
Reputation: freemind is an unknown quantity at this point 
Solved Threads: 1
freemind's Avatar
freemind freemind is offline Offline
Junior Poster in Training

Re: Real-time simulation problem

 
0
  #5
Jun 15th, 2006
I found a plase to paste it: http://rafb.net/paste/results/Jqrme337.html
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Real-time simulation problem

 
0
  #6
Jun 15th, 2006
Any hints as to where the flaws are?
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 62
Reputation: freemind is an unknown quantity at this point 
Solved Threads: 1
freemind's Avatar
freemind freemind is offline Offline
Junior Poster in Training

Re: Real-time simulation problem

 
0
  #7
Jun 15th, 2006
liblifts.h is the dirty worker in this case so this is the place. I presume that the Elevator class is the primary and probably almost only source of errors. The open_doors() function and the move() function are probably most critical. If I must be sincere - I don't have an exact idea what's wrong .. if I did have one I would try to correct the code myself.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 377
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: Real-time simulation problem

 
0
  #8
Jun 15th, 2006
I bet you know what I'm gonna say don't you.

Let me guess, you wrote the whole program in one go, and then hit compile and execute and expected it to work?

My advice would be to test each function or in your case, each method, separately and make sure it's doing what it is supposed to. Once you've gone through each method systematically you should be able to find out what's going wrong and where.


It's the only way.

Another thing, I noticed, it appears you're not freeing up your memory.

Where's your use of delete[].

And you really need to work on your indentation. It's horrendous. I also hate the use of try catch statements in c++, but that's just me.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 62
Reputation: freemind is an unknown quantity at this point 
Solved Threads: 1
freemind's Avatar
freemind freemind is offline Offline
Junior Poster in Training

Re: Real-time simulation problem

 
0
  #9
Jun 15th, 2006
Generally you're right about the testing. I can't think of a way, though, to check every function, especially when one function often uses the other from the same class and executable code is produced only when all the used functions are written down. Once the whole picture is clear I can start tracking down the problems.

As for delete[] - this belongs to the last actions I have to do. My primary concern at the moment is that the code starts running as it is supposed to do :-) Optimization belongs to the last stage before giving up the ready code and will be done, I can assure you.
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,342
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 237
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: Real-time simulation problem

 
0
  #10
Jun 15th, 2006
freemind: You know that you're not supposed to put function bodies or variable definitions in a header, right? (Well, now you do.)

I may actually help more later on, but there are many things that make this code difficult to look at and understand. So I'm taking my time.
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC