|
stephen.darling wrote: (Gosh! its even complecated to simply exaplin ha)
Ain't that the truth!
Without actually seeing it, from your description it sounds ok. Not sure you need the simulation object to be static, but if there is only ever going to one of it, then fine. If you ever need to expand this to two patients it could be a problem though.
Otherwise, looks OK to me
Good luck!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
I have a class,
public class Collection<T>
and I was wondering if there was a way to determine if the data type used implements an interface.
I have used this code.
if (typeof(T) == typeof(ICollectable))
variance = 1.2;
but it never gets into this if block, regardless if the class I use implements ICollectable.
Any ideas?
|
|
|
|
|
I've come up with this, which will work for now. I am unsure of it's efficency though, I assume it uses Reflection
if (typeof(T).GetInterface("ICollectable") != null)
|
|
|
|
|
Sure... When you call typeof(T) , it returns a Type object, which has plenty of useful methods like GetInterface(), FindInterface(), etc.
Just don't use IsSubclassOf(), as that won't work for interfaces.
|
|
|
|
|
Reflection is probably the best way to go, but here is another technique which may be faster, though is not as flexible (i.e., you must know in advance if the type is a class or a struct, and it requires the class have a default constructor):
public bool IsClassAnimal<T>()
where T:new()
{
T t = new T();
return t is IAnimal;
}
public bool IsStructAnimal<T>()
{
T t = default(T);
if (t == null)
{
throw new InvalidOperationException("The type was a class.");
}
else
{
return t is IAnimal;
}
}
Sample interface/struct/class:
public interface IAnimal
{
}
public class Dog : IAnimal
{
}
struct Cat : IAnimal
{
}
Sample usage:
if (IsClassAnimal<Dog>())
{
MessageBox.Show("A dog is an animal!");
}
if (IsStructAnimal<Cat>())
{
MessageBox.Show("A cat is an animal!");
}
You could simplify that by just passing an instance of the class/struct, but that doesn't seem like what you're after. Also, if your class/struct is large (e.g., with lots of member variables), this could be a very expensive operation; not to mention it could have some weird side-effects. But, hey, thought I'd throw the technique out there anyway in case somebody can make use of it.
|
|
|
|
|
What about :
T myObj;
if (myObj is ICollectable)
variance = 1.2;
?
|
|
|
|
|
Hi,
I am currently doing my school project , which is about robot fish.
So the robot fish is used to detect the temperature inside the water.
2 types of devices I am using :
- Access device : this is usb-based, to connect to the pc, and also measure the temperature around it
- end device : this will measure the temperature somewhere else and transmit the wireless data to access device.
Both devices has been downloaded with some programs inside.
I have successfully displayed the data to the pc, using the software called sensor monitor visualizer( texas instrument ).
The problem is that I have to display the data using C# code programming , instead of that software from texas.
So I may need to find out the code to access or display or read the data from the usb device, and display the data again to the pc using some circles or whatever.
The detail is in http://focus.ti.com/lit/ug/slau227e/slau227e.pdf , including the screenshot of the display.
Please help me if you have any idea about this, as I am very poor in programming languages.
Thank you all.
|
|
|
|
|
depressedguy wrote: as I am very poor in programming languages.
I'll write something for you for $50 per hour.
|
|
|
|
|
As you know I am still a student, so I dont have so much money to pay
|
|
|
|
|
Hi,
For a project I am using System.IO.Ports.SerialPort for serial port communication. The serialport class can detect the status of DSR (serialPort.DsrHolding), CTS (serialPort.CtsHolding) and CD (serialPort.CDHolding), but it isn't possible to determine the status of the ring indicator (only RI change can be detected).
I made a work around, so you can still keep using the normal SerialPort functions, but you can also detect the RI status. I have only tested it on Vista x86 and VS2010.
Kind regards,
Mark
using System.Runtime.InteropServices;
using Microsoft.Win32.SafeHandles;
using System.Reflection;
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern Boolean GetCommModemStatus(SafeFileHandle hFile, ref UInt32 Status);
const UInt32 MS_CTS_ON = 0x0010;
const UInt32 MS_DSR_ON = 0x0020;
const UInt32 MS_RING_ON = 0x0040;
const UInt32 MS_RLSD_ON = 0x0080;
private void ShowPinStates(System.IO.Ports.SerialPort serialPort)
{
UInt32 Status = 0;
Boolean CTS = false;
Boolean DSR = false;
Boolean DCD = false;
Boolean RI = false;
if (serialPort == null) return;
if (serialPort.IsOpen)
{
object baseStream = serialPort.BaseStream;
Type baseStreamType = baseStream.GetType();
SafeFileHandle portFileHandle = (SafeFileHandle)baseStreamType.GetField("_handle", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(baseStream);
if (GetCommModemStatus(portFileHandle, ref Status))
{
CTS = ((Status & MS_CTS_ON) == MS_CTS_ON);
DSR = ((Status & MS_DSR_ON) == MS_DSR_ON));
DCD = ((Status & MS_RLSD_ON) == MS_RLSD_ON));
RI = ((Status & MS_RING_ON) == MS_RING_ON));
}
}
}
|
|
|
|
|
Hi,
if you don't have a question, and just want to share your solution to compensate for the absence of a SerialPort.RingIndicator property, maybe you should post your approach as a tip. See here[^].
|
|
|
|
|
Hello,
I'm developing a application which sends and receives tons of data over UDP. I know the problem of UDP to loss udp-datagrams between sending and receiving. So i created a stack and a timer, where the datagrams to send are stored and sended. (All datagrams get a counting ID, so i'm able to recognize if something is missing)
With the interval of the timer i'm able to control the transfer-rate. My problem is now, how to calculate the correct interval of the transfer? Is there any logic to do this? I would work with the messages i get from the connection-partner how many datagrams are lost, but what is the best way to calculate this?
|
|
|
|
|
If delivery is important, why are you even using UDP?
UDP does not guarantee delivery, and considerbly less known, does not guarantee that the packets will arrive in the correct order.
This sounds very kludgy because you cannot guarantee that the interval will be constant, depending on network traffic and load on the client end, the server end, and everything in between. Remember, it's not just your app putting data on the wire and it's a shared medium being used by machines that have nothing to do with your app.
softwarejaeger wrote: My problem is now, how to calculate the correct interval of the transfer?
What defines what the correct interval should be? Just because a packet was lost is not a valid indicator that the transfer should slow down. The NIC will only send out packets when it can, not at the rate your app can send them.
|
|
|
|
|
Hi, Everybody
i am writing ANN code with c#
i wrote a class which has folowing structure;
<br />
<br />
class neuron<br />
{<br />
public double [] dentw = new double[nron];<br />
public double bias,hata,delta ;<br />
<br />
public double[] input = new double[nron ];<br />
public double output ;<br />
public int[] sbaglanti = new int[nron];<br />
public int[] sbagk = new int[nron];<br />
public int[] obaglanti = new int[nron];<br />
public int numara;<br />
public int dents;
public int oid,sid;<br />
<br />
~neuron() { }<br />
<br />
}<br />
class layer {<br />
public neuron[] noron = new neuron[nron];<br />
<br />
public layer()<br />
{<br />
for (int index = 0; index < noron.Length; index++)<br />
{<br />
noron[index] = new neuron();<br />
}<br />
<br />
}<br />
<br />
~layer(){}<br />
<br />
}<br />
class net {<br />
<br />
public int ban, hen;<br />
public layer[] layers = new layer[lay];<br />
public net()<br />
{<br />
for (int index = 0; index < layers.Length; index++)<br />
{<br />
layers[index] = new layer();<br />
<br />
}<br />
<br />
}<br />
<br />
~net(){}<br />
<br />
}<br />
<br />
net networks;<br />
<br />
in here, i want to change neuron count of layers and so how can i do it ?
can you help me ?
thanks
|
|
|
|
|
Just change the value of nron.
|
|
|
|
|
i want to difference neuron in diffrence layers it means firs layer which has 4 neurons and second layer 7 neurons ...
|
|
|
|
|
Make a Layer constructor with an int parameter giving the Layer's length. Then in class net, pass the length you want when you make a new Layer.
Take the initialization of noron out of class Layer, and allocate this array in the Layer constructor with the proper length.
|
|
|
|
|
You also need to make some changes to class neuron so that the arrays of weights to the previous and following layers have matching lengths.
|
|
|
|
|
Firstly I hope that your knowledge of Neural Networks is greater than your knowledge of programming, otherwise I fear that this particular project is going to be beyond your capabilities.
Still, let's get on with a little help:
The first thing that I would do is to change your net class, something like this
class net {
public int ban, hen;
public layer[] layers;
public net()
{
layers = new layer[lay];
for (int index = 0; index < layers.Length; index++)
{
layers[index] = new layer();
}
}
public net(int lays)
{
layers = new layer[lays];
for (int index = 0; index < layers.Length; index++)
{
layers[index] = new layer();
}
}
~net(){}
}
You will see that I suggest moving the instantiation of your layer[] to within the constructor. I have also added a constructor that takes an int as a parameter. With the class defined in this way:
net networks = new net(); gets you a network with the standard number of layers (whatever you have set your lay member to)
net networks = new net(25); gets you a network with 25 layers.
For your actual question I would suggest that one method would be to add yet another constructor to the net class and one in the layer class.
Firstly, layer gets the same treatment as above, for the same reason.
public neuron[] noron;
public layer()
{
noron = new neuron[nron];
for (int index = 0; index < noron.Length; index++)
{
noron[index] = new neuron();
}
}
public layer(int neurons)
{
noron = new neuron[neurons];
for (int index = 0; index < noron.Length; index++)
{
noron[index] = new neuron();
}
}
I have just listed the new constructors.
In the net class the new constructor would look something like:
public net(int lays, int[] neuronMap)
{
if (neurons.Length != lays)
{
throw new ArgumentException("neurons");
}
layers = new layer[lays];
for (int index = 0; index < layers.Length; index++)
{
layers[index] = new layer(neuronMap[index]);
}
}
~net(){}
}
Using the suggestions above you could then do something like:
int[] neuronMap = new int[] { 6, 7, 8, 9, 10 };
net networks = new net(5, neuronMap);
This creates a net with 5 layers . The first layer will have 6 neurons, the second 7 and so on.
I hope this helps.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Why do you have a destructor? An empty one even. It doesn't even do anything, except slow you down.
Empty destructors should not be used. When a class contains a destructor, an entry is created in the Finalize queue. When the destructor is called, the garbage collector is invoked to process the queue. If the destructor is empty, this just causes a needless loss of performance.
|
|
|
|
|
hi all
i want to Extend a Property for a class
is there some thing like Extension Methods for properties?
|
|
|
|
|
Extension methods only work at the class level.
Depending on what you want to do, you may have a couple of options. You'll either have to inherit from the class and override the property or add another property and call the base class property from it.
|
|
|
|
|
i know bun unfortunately i can`t derive from desired class because it force me to change all of the project .
in addition i am looking for a better solution
|
|
|
|
|
reza assar wrote: i know bun unfortunately i can`t derive from desired class because it force me to change all of the project
Sounds like the requirements and specs changed after development started. You really have to plan ahread for these things.
reza assar wrote: in addition i am looking for a better solution
You don't have one. Extension methods cannot be attached to a property of a type, only to the type itself.
|
|
|
|
|
hi!
I have a listview , which contains some records with checkbox.
I have also a linkbutton for select all, delete and so on.
my query is, when i click on select all(link button) all checkbox has select.
please help me.
i use this code, but not work :
protected void lnkSelect_Click(object sender, EventArgs e)
{
foreach (ListViewDataItem lvItem in lstView.Items)
{
CheckBox check = (CheckBox)lvItem.FindControl("chksel");
if (check != null && check.Checked)
{
check.Checked = true;
}
}
}
thanx & regards
|
|
|
|