|
Hi,
I would suggest that you embed the resources to your application. Have a look at this article:
http://support.microsoft.com/?scid=kb%3Ben-us%3B319292&x=10&y=10[^]
You can then load your data using a StreamReader. Save the name of the file and sounds within your Patient-class, since each patient I think has a different picture and sound.
Hope this helps a bit.
Regards
Sebastian
|
|
|
|
|
I would have to disagree with SeMartins.
If the picture is of the patient, then it should be stored with other patient information. Otherwise, when you add a new patient, how do you include a picture? Embedding them in your resources is a bad move as you would have to define them at build time, or play silly buggers.
Either: store the file path with the patient data and load the image when you need it, or include the picture in a database with your other patient information - the latter means there is only one place to go for all relevant info - again, you do not have to load the image until you need it for display.
Again with sounds, these should be stored either as a file reference or database field (depending on the size) and loaded only when you need them.
The general rule is: If it is part of the object info, let the object deal with it. Your main form is concerned with user interaction - displaying patient and EGC info to the user, and relating user generated changes to that info back to the object, not with how the object is stored.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Thank you for the positive feed back, it is well appreciated.
Thank you
Steve
|
|
|
|
|
You're totally right. Due to my missing morning coffee I assumed that your patient data is fixed (since it is just a demo, isn't it). If the data itself is not fixed, store it within a file or (better) database as already suggested by OriginalGriff.
You could also place the picture and sounds into the patient data file by embedding the data as base64 strings... So you got everything in one place.
Regards
Sebastian
|
|
|
|
|
|
Ok, If I have learned correctly, one should limit an app to maybe 1 or 2 timers.
I have a timer object set to triger every second, but I need a number of different events to happen at different times.
For example,
every 1 second...timer triggers
every 3 seconds, run function A
every 10 seconds, run function B
etc
Now, I cant figure out how to do this properly. I know I need variables to keep tabs on elapsed times, but would some kind coder please give me an example of how I may do this please?
Thank you
Steve
|
|
|
|
|
Hi,
1.
you can have several timers, however I would avoid having dozens of them.
2.
you can easily combine two or more periodic timer requirements and serve them by a single timer, basically it works like this (code looks like C#, has not been tested):
public class MultiTimerDemo {
private int timerCounter17=0;
private int timerCounter5=0;
public MultiTimerDemo() {
Windows.Forms.Timer timer=new Windows.Forms.Timer();
timer.Interval=1000;
timer.Tick+=ticker;
timer.Start();
}
private void ticker(object sender, EventArgs e) {
if (--timerCounter5<=0) {
timerCounter5=5;
.. now do whatever needs to be done every 5 seconds
}
if (--timerCounter17<=0) {
timerCounter17=17;
.. now do whatever needs to be done every 17 seconds
}
}
}
The above illustrates how one actual timer can be turned into two or more virtual timers.
You can easily add virtual timers. And of course you could make things more dynamic (provide code to add and remove all kinds of virtual timers) by using lists and delegates.
|
|
|
|
|
Thanx alot Luc, just what I needed!
Steve
|
|
|
|
|
One timer. One second interval. Keep a DateTime of when each task last ran. When the timer elapses, iterate the tasks to see which are due.
That's basically what I do, but with the tasks configured in a database.
|
|
|
|
|
Hi again coders.
I am writing my first, simple patient simulator.
I need to play a sound file on repeat, while the simulator is running.
It is a beep beep kind of file for the ECG machine (EKG in america, I am in UK)
I have a time object in my c# app, set to triger every second so I can track each second of the currently running simulation.
I tried to add my playsound() function here, but it is being reset every second (I understand why, but I cannot figure out what to do)
The whole sound file lasts approx 12 seconds, and needs to repeat straignt after it ends, for as long as the sim is running)
Sorry if it a basic question, but what functions do I need, and where would I put them to allow me to do this?
Thank you
Steve
|
|
|
|
|
stephen.darling wrote: I have a time object in my c# app, set to triger every second
Perhaps you could have this trigger every 12 seconds? Or if it needs to be every second, have a variable track how many times it has triggered and every 12 times, you can play the sound (the other 11 times you'd skip the sound playing since it's already playing and you'd do whatever you do on that trigger).
stephen.darling wrote: I tried to add my playsound() function here
Speaking of adding your playsound function here, you should post some code here so we know the actual functions you are using to play the sound and which objects you are using for your timer.
|
|
|
|
|
Hello and thank you.
Here is my code, but it is rough as i have not yet created the classes etc, it is all happening within the form function
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Threading;
using System.IO;
using System.Text;
using System.Runtime.InteropServices;
namespace SimMed
{
public partial class simmedForm : Form
{
[DllImport("winmm.dll")]
private static extern bool PlaySound(string lpszName, int hModule, int dwFlags);
#region Variables
private int nTime;
private int patientHeartRate;
private int patientBloodPressure;
private int patientTemp;
private int patientBreathRate;
private int patientConciousLevel;
#endregion
public simmedForm()
{
InitializeComponent();
HeartBpmLed.Text = ("72");
patientHeartRate = 72;
startNewSimulation(false);
}
private void startNewSimulation(bool restart)
{
if (timer1.Enabled) timer1.Stop();
if (!timer1.Enabled) InitTimer();
}
private void InitTimer()
{
timer1.Interval = 1000;
timer1.Enabled = true;
}
private void PlayWav(int play)
{
string myFile = ".\\Sounds\\default.wav";
switch (play)
{
case 1:
myFile = ".\\Sounds\\ecg.wav";
break;
case 2:
myFile = ".\\Sounds\\ecg.wav";
break;
case 3:
myFile = ".\\Sounds\\ecg.wav";
break;
case 4:
myFile = ".\\Sounds\\ECG Alarm.wav";
break;
case 5:
myFile = ".\\Sounds\\Flatline.wav";
break;
case 6:
myFile = ".\\Sounds\\Medicalventilator.wav";
break;
case 7:
myFile = ".\\Sounds\\PulseOximeter.wav";
break;
case 8:
myFile = ".\\Sounds\\Heartbeat.wav";
break;
case 9:
myFile = ".\\Sounds\\Won.wav";
break;
case 10:
myFile = ".\\Sounds\\illegal.wav";
break;
default:
break;
}
PlaySound(myFile, 0, 0x0003);
}
private void simmedForm_Load(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
Random r1 = new Random(unchecked((int)DateTime.Now.Ticks));
nTime++;
patientHeartRate = 72 + r1.Next(0, 5);
HeartBpmLed.Text = patientHeartRate.ToString();
PlayWav(1);
}
}
}
Thank you
|
|
|
|
|
|
Ah, OK.
I will look into this function.
Thank you
|
|
|
|
|
|
Thank you for that really useful information <Sarcasm mode="off" />
Did you mean to post it somewhere else, or are you just not big on reading?
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
So write an article then.
|
|
|
|
|
How does it differ from storing my stored procedures as plain text files and pulling them from harddisk as needed?
I are Troll
|
|
|
|
|
How are you able to control objects in your project with stored procedures? Not objects in database.
Without hard-coding it into your code.
|
|
|
|
|
hove82 wrote: Not objects in database.
Without hard-coding it into your code.
You're sounding like a salesman. Don't do that if you want a decent opinion.
I put objects in my database by serializing them. I put assemblies in my database as blobs, based on the source-code that's stored in a NVARCHAR. Updating the text in the NVARCHAR gives a new build-number, and there's a certain amount of builds in a release
What's the motivation behind the original question? Do you plan on using their software and looking for people with previous experience, are you evaluating idea's, or what? Without a decent list of features, it's hard to say whether or not it would fit a specific task.
Yes, it's definitely handy for those people who don't want to spend the time on building that part of the infrastructure themselves. There's room for logging-frameworks, for exception-handling frameworks, should be room for a macro/configurationmanager framework.
Is it Open Source? If yes, then why not write an article on it's use, and how it could save people time?
I are Troll
|
|
|
|
|
Now I want to know what he was talking about...
|
|
|
|
|
I am not a salesman.
I has been moved to an article ObjectPolicy.
This project is about not including certain things into project (hard-coding), but to be able to control it from a volatile source.
modified on Tuesday, September 14, 2010 2:04 AM
|
|
|
|
|
hove82 wrote: I am not a salesman.
I has been moved to an article ObjectPolicy.
My apologies, but for a split second you sounded like one. Looking back, it sounds logical that you'd be excited and enthusiastic. Good to hear that there's an article upcoming
hove82 wrote: This project is about not including certain things into project (hard-coding), but to be able to control it from a volatile source.
That's a portable, cross-platform source? You mentioned XML as a source, which could mean that it might run on Mono without any modifications. Might even work from a memory-stick.
Some people will be interested in the product, others more in how you created it, but most in both
I are Troll
|
|
|
|
|
Just to be clear, ObjectPolicy reads, interprets and executes commands written in xml, it's not standalone solution, you need to implement it in your application. It's all about mapping objects in xml with objects in your application, and issuing command against them, that's what ObjectPolicy does.
My article was deleted because I refuse to post a source code. You can download dll, or test app from here.
|
|
|
|
|
hove82 wrote: Just to be clear, ObjectPolicy reads, interprets and executes commands written in xml
It's not clear; I had to look at the XML to see what you actually meant by that.
hove82 wrote: You can downloaded it from here.
Thanks for the link, downloaded it. Looks like 's easy to use, and has a small footprint. Looks portable.
I'm not running Windows, and Linux doesn't like the precompiled version since that targets .NET 4.0. Do you need the stuff from the 4.0 framework, or does it also build under 2.0?
hove82 wrote: My article was deleted because I refuse to post a source code.
Posting an article to promote closed-source ("commercial") software would be seen as an attempt to post an advertisement without paying. If the software was open-source then you could reach a nice audience here.
Yes, there's quite some criticism at the start, and it's impossible to please everyone. And yes, I'm interested, but as a programmer - not as a customer.
I are Troll
|
|
|
|
|