|
Pete O'Hanlon wrote: Each class there is in a separate namespace.
Okay, so, the fact that all the files have the same line in them, near the top, i.e., this one...
namespace SerialPortPractice_03
namespace SerialPortPractice_03
...does not mean that they can see each other.
In other words, there is no "linker" (such as I am accustomed to having) which combines all the labels in different files into the same area in memory (even with the namespace line at the start) to allow one guy to call the other guy whenever he wants.
Am I close ?
|
|
|
|
|
C-P-User-3 wrote: Am I close ?
No. In the example you listed above, there were three separate namespaces. If your classes are in the same namespace, they can see each other.
|
|
|
|
|
Pete O'Hanlon wrote: No. In the example you listed above, there were three separate namespaces.
I'm going to double check that right now.
I was certain; like extremely certain; and made a deliberate effort; to make sure that every file had the same namespace.
Let me check that
Okay, the protocol file starts with these two lines...
using System;
namespace SerialPortPractice_03
The Form1.cs file starts off with these 9 (or 10 if you count the blank) lines...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
namespace SerialPortPractice_03
Do I have the correct idea about the keyword namespace in my mind ?
|
|
|
|
|
Yes. They are in the same namespace.
|
|
|
|
|
Still trying to figure out what's going on.
I see the phrase, "SerialPortListener", by itself, and in another place with a dot and "Serial" after it, like this: SerialPortListener.Serial;.
I'm looking at this section, several times over...
Pete O'Hanlon wrote: using SerialPortListener.Serial;
namespace SerialPortListener
{
public class MainForm : Form
{
private SerialPortManager portManager = new SerialPortManager();
....
}
}
I see the "using" line with the name, and a dot, and the word "Serial" on one line, then in another line, I see the exact same word used with the namespace directive, then again with the private descriptor (sorry for my vocabulary) then in the same line, with the new keyword; but this time with empty parentheses appended.
It would help me greatly if I could get some sort of idea as to what bytes are being placed where, when these words are used.
By the way, thanks for all this time and direction. Hope I'm not annoying you or the gang here. One of these days I would like to help others like you guys have been helping me.
|
|
|
|
|
What's probably confusing you is that the namespaces and class names are all very close. Let's simplify this with an easy example. Suppose we have a very simple vehicle creating system. I'm going to arbitrarily break this up like this:
namespace WeMakeVehiclesForOthers
{
public class BaseVehicle
{
protected void Buy() {}
}
} Now, in a namespace that we are going to call Cars, we are going to add a specific manufacturer:
using WeMakeVehiclesForOthers;
namespace Cars
{
public class Ford : BaseVehicle
{
public void BuyCar()
{
Buy();
}
}
} Now finally, we have a set of car dealerships that want to sell custom Fords. They might look like this:
using Cars;
namespace Dealers
{
public class PetesDealers
{
private Ford ford = new Ford();
public void BuyFord()
{
ford.BuyCar();
}
}
} As you can see, you have full access to Ford and all the methods it has available. I hope this makes sense
|
|
|
|
|
Pete, Dave, anybody else, thank you.
King of the clueless, reigns supreme again.
Just learned something: in order for one method in one file to see another thing (anything) in another file, in C#, you can't just open a file and type in the same namespace.
No, you must put the cursor over the name of your project, then right click, then choose "Add", then choose "Class", then go through a drop-down menu and choose "Class" again, then give that class a name, then click something else (my brain isn't good enough to catalog the full procedure, but you get the idea) and then some more stuff, and when you follow that procedure, C# does ninety seven magic tricks and the names in one file are visible to the other files.
I am sorry, sorry, sorry for creating such needless useless questions and draining your time in such an absurdly obtuse manner.
Honest, I saw the other files, and thought I could just say "File", "New", "File", and start typing.
Be respectful; you are in the presence of the King Of The Clueless.
|
|
|
|
|
C-P-User-3 wrote: I have seen other apps run 921600 on this very machine right in front of my
eyes.
That baud rate has to be user defined. It's not going to be in the base Windows API or the .NET Framework. It's extremely rare to find any use for a RS232 port faster than 115200.
Frankly, with a baud rate like that, the cable would have to be sheilded in lead and a max of 3 feet long for it to work with any reliability.
|
|
|
|
|
Clarification: I'm using BlueTooth across a USB (i.e., Fake-out) UART.
This is the hardware which I've seen do 921600 Bits Per Second, with "Terminal by Br@y" and 230400 with "TERMite" and maybe Hyperterminal as well.
(Hyperterminal hates my guts; he's really got it in for me; don't know why.)
|
|
|
|
|
Total time waste. Sorry for the trail of the red herring.
I discovered the big liar in all this.
Well, not sure exactly who is lying, but I have at least dissected the lie from the truth.
The lie: the limit is 115200
The truth: If you open that port at a speed of 115200, he can, and will, and does, deliver a speed of 921600. It also works at even lower speeds.
To really grasp the magnitude of this, check out these results...
-- I opened the port at 1200 bps.
-- The other side was doing 921600.
-- It worked.
|
|
|
|
|
How can I dispatch 30 threads to do 30 things ?
How do those threads inform each other of what they are doing ?
I looked up the word "Semaphore" on the MSDN site, and here as well. Apparently, C# and embedded systems have markedly different definitions of that term.
Still newbee noclue.
I'm watching some YouTube videos on the topic, still learning, really interesting, I think that threading will do what I want it to do.
Input is welcome.
|
|
|
|
|
|
Thank you. This stuff is relevant to my interests !
|
|
|
|
|
I have found the paper very helpful. It has been updated a few time, especially with TPL. Sort of got back to it after reading up on TPL in Task Parallel Library: 1 of n[^]
|
|
|
|
|
hi ,
I got an object which is a generic, at runtime i pass the type for T and create the proper object. the generic object as follows
class parent <T>
{
string name;
T childObject;
}
I create the parent<x> in runtime using the reflection , for e.g.
Type type = x;
Dynamic response = Activator.CreateInstance(typeof(parent<>).MakeGenericType(type));
it works fine , but the problem is when I try to assign an object to response.childObject it gives me an exception saying that i'm missing cast and it cannot implicitly cast the object.
the object try to assign is also created using reflection,
ADDED LATER: I'm not sure this part will be important for this issue , but anyway , the object i'm trying to assign to response.childObject is also an object created by deserialization , means
for in order to deserialize this object i have to give the type , so that type also crated using reflection in a similar way described above.
i would really appreciate your help on this.
thanks in advance.
modified 31-Oct-12 12:43pm.
|
|
|
|
|
I dont know how it actual works if I am honest (as I found the question interesting) but my modifying your code to this
Type t = typeof(Parent<>);
int y = 1234;
Type type = y.GetType();
dynamic response = Activator.CreateInstance(t.MakeGenericType(type));
response.MyValue = 123;
public class Parent<T>
{
public string name = string.Empty;
public T MyValue;
}
I was able to assign a value to the property MyValue.
*Edit* Not sure if it helps but I've just read through this MSDN article on Type.MakeGenericType[^], I found this an interesting Question
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
thanks , I also tried the value types and it works , but the problem came when i'm trying to assign reference type.
|
|
|
|
|
Type t = typeof(Parent<>);
Type type = typeof(Data);
dynamic response = Activator.CreateInstance(t.MakeGenericType(type));
Data es = new Data() { Name = "Fred", value = 213 };
response.value = es;
public class Parent<T>
{
public string name = string.Empty;
public T value;
}
public class Data
{
public string Name = string.Empty;
public int value = 0;
}
I have also tried it with the following and it still works can you expand your problem with some sample code? or a snippet?
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
Thanks again , ok then I think I have to focus on the deserialzed object , unfortunately i haven't got the code snippet right now , but I will definitely post that code snippet soon.
thanks .
|
|
|
|
|
Your welcome
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
hi ,
this is how i'm doing the deserialization
Type genericSyncObj = typeof(SyncObject<>);
Type syncObj = genericSyncObj.MakeGenericType(type);
IList customObjectList = (IList)Activator.CreateInstance((typeof(List<>).MakeGenericType(type)));
foreach (string value in pullRequest.Knowledge)
{
dynamic syncObject = JasonSerializer.Deserialize(value, syncObj, null);
customObjectList.Add(syncObject.Object);
}
and i'm getting the exception at here
dynamic responseSync = Activator.CreateInstance(typeof(SyncObject<>).MakeGenericType(type));
responseSync.Object = customObjectList[y] ;
thanks .
|
|
|
|
|
The problem is that customObject[y] is returned as an object which is why it fails.
if you then hard code a cast such as for example.
responseSync.Object = (SomeTestClass)customObject[y];
it works as you need it to do, but how to create this as a generic routine I'm not sure at the moment as (typeof(SomeTestClass))customObject[y] or even (typeof(SomeTestClass))CustomObject[y] is rejected by the compiler.
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
thanks , yes this is the place where i'm stuck , need to cast in runtime , if you find a way please share it .
|
|
|
|
|
IList datalist = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(typeof(Data)));
datalist.Add(new Data {Name = "SIMON", value = 1});
datalist.Add(new Data {Name = "SIMON", value = 2});
datalist.Add(new Data {Name = "SIMON", value = 3});
Type t = typeof(Parent<>);
Type type = typeof(Data);
dynamic response = Activator.CreateInstance(t.MakeGenericType(type));
Type SingleRecordType = datalist[0].GetType();
dynamic Destination = Activator.CreateInstance(SingleRecordType);
Desintation = datalist[0];
response.value = Desintation;
have a look at this. it is a bit of a work around converting the list item from object to a specific type at runtime.
Thanks
Simon
**edit** missed a GetType()
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
modified 1-Nov-12 11:24am.
|
|
|
|
|
hi
thanks it seems to be working, though it is a workaround . thanks for the clue .
** yes i noticed that and i fixed it by calling the GetType()
thanks.
|
|
|
|
|