Click here to Skip to main content
16,016,894 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am trying to write a program which generates different outputs depending on the inputs (A, B, C & D) and previous inputs, this is fairly straightforward although my program has to work within a time frame interval (one unit arrives at the station every time unit) with this parameters:

Machine 1 must take 1 time unit to generate an output unit V.

Machine 2 takes 1 unit to generate an output W if the input was B. If the input was BC, it takes 2 time units and produces an output X.

Machine 3 takes 3 time units if the input was a D and generates an output Y, but 7 if it was DBC and it produces an output Z.

Machine 4 takes 5 time units and generates an output T.

This outputs will be queued and then selected so that the machine delivers a single stream of units.

This outputs unit must be generated every time unit after the program has started.

I am not quite sure how to approach this type of procedure, should I slow down the process so it meets the criteria or how could I affect time with C?

Thank you

[mail address removed]
Posted
Updated 21-Aug-11 22:25pm
v3

Is this a theoretical (college) problem or one from the real world? Is you system based on a PC or an embedded processor? Are you using C or C++?

Since it sounds fairly complicated, if I was tackling it, I would work out what I wanted to do with a flow chart. If you need to perform events at particular times there are timer functions available in C++ for the PC, but real time events are tricky on a PC which is a multi tasking system. If you are using an embedded system this may not be the right forum for you as it is largely PC based, but if I wanted to control an Industrial process with critical timing I would not use a PC, I would choose a microprocessor. I hope this helps a little.

Best of Luck :)
 
Share this answer
 
Comments
mariormp 22-Aug-11 5:08am    
Yes, it is a PC based tutorial problem from my C programming unit, I don't want to do separate events, i would like to put inputs, say A, B, C or D, in between a time frame and receive the corresponding outputs but I must receive at least one output unit, say W, X, Z or T.

thank you for your help
mariormp wrote:
I am not quite sure how to approach this type of procedure, should I slow down the process so it meets the criteria or how could I affect time with C?

It looks you just have to define properly such states machines: the output flow will be a mere consequence (and no, you cannot 'affect time with C' -if I got you-).
 
Share this answer
 
v2
Comments
mariormp 22-Aug-11 4:58am    
what you say is... i have to add a time variant to each case that develops with the previous and present inputs, that sounds plausible, again how could do that? I'm not very literate with C
mariormp 22-Aug-11 5:08am    
where are my manners... thank you for your help

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900