Click here to Skip to main content
15,888,908 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
Hi, so I made a program in a windows form application for a MEWS System which displays patients vital signs for a hospital. I used timers to display coloured bars to show the vital sign levels. what I want to know is how can i use arrays to store the timer number results each time I run the program, so i can have the results stored in a collection component.
Posted
Updated 9-Dec-10 6:27am
v5
Comments
Toli Cuturicu 9-Dec-10 12:18pm    
You should not do such an absurd thing.
programmer1234 9-Dec-10 12:19pm    
Do what?
Henry Minute 9-Dec-10 12:23pm    
I think that you will need to explain in more detail what it is that you are trying to do. At the moment it is not entirely clear.
LloydA111 9-Dec-10 13:03pm    
From what I understand of your question, you would not need to use timers, you would have an array called something like "ResultArray" and then in each cell put the returned data.
programmer1234 9-Dec-10 15:21pm    
Something like this Lloyd?

int[] ResultArray = { 1, 0, 1, 1, 2, 1 };

for (int i = 0; i < 5; i++)
{
Console.WriteLine(ResultArray[i]);
}

Not sure I understand your question, but I think you're asking how to use timers to store the data values they are retrieving from the sensors?

To begin, timers are arbitrary time keeping devices without any provisions for data storage. You need to implement that layer yourself.

Next you need to determine how long you need to store the data for. If you need this data to persist longer than an application restart then you'll need to store the data in a file or in a database. If you only need to store the data temporarily, you could consider using a Stack<t> or one of the List<t> variants.

After you determine your persistence medium (SQL Server, XML file, Memory, etc) you'll need to figure out a model to use to store the data as it is read from the input device. I would suggest storing the sensorID, timestamp, sensorvalue within a table or class object but you're the only one who can answer that question.

You may consider building your app so that you have separate mechanisms: one system for reading the data, one system for persisting it, one system for displaying it and one system for controlling the application.

Hope that helps you.
 
Share this answer
 
Comments
E.F. Nijboer 9-Dec-10 12:35pm    
My vote of 5: Some good arguments and tips.
fjdiewornncalwe 9-Dec-10 14:50pm    
A good understanding of the question and a good answer...
Why use an array of timers? It would be better to create classes for different processing and let those decide if work must be done.

on timer event (based on the shortest time span, for example 100 ms.):
vital1.execute;
vital2.execute;
vital3.execute;


or better yet:
foreach(vital in vitals)
{
  vital.execute;
}


For example: vital 1 needs to be executed every 200ms, vital 2 every 100ms and vital 3 every 400ms.

In the execute you check if the time has expired, do some processing and set the value (for checking if the time has expired) to the current time incremented with the interval (for example 200 ms.)

You can use DateTime.Now + TimeSpan.FromMilliseconds(100); to calculate the next time to check if 100 ms have elapsed.

Using this scheme you only need a single timer to schedule processing of each vital. Be aware that total processing must nut exceed the timer interval because it would otherwise mean that processing will get behind (because processing is started while previous processing did not even end completely).

Good luck!
 
Share this answer
 

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