|
What is happening is info from one child form is being received or listen to by the wrong child form.
The situ is one parent form and any number of child forms. Specifically this is a truck control system, all the the truck/child forms are the same. But the monitoring and controls for each are to be independent of the other's actions. Example one truck could be in neutral with a rpm speed of 800, while another truck is in 3rd gear with rpm of 1000. So the situation has to be contained within the logical confines of the individual childform/truck.
I've tried using access modifiers to there extent. Making things 'private' as much as possible, getting rid of as much 'static' as possible.
What is first sent is the info packet. Defined as: !!!780;125;1400;0;5000&&&
The truck sends back a string of data for processing, and as confirmation of what's wanted by the operator. The string looks like this:
I5000R0780G02O099C060V23.3W2440F099L4S01400P00000X126Y057B27.08H65253E01T01D0000_99!
Within the program I'm using a ID_Parser to strip/read out the identifier at the beginning of the string to make sure it gets sent to the right form. Actually creating a instance of the truck/chilform that the info belongs to. I had to do this because sometimes the sending form would receive info string from another truck. This routine does put the port_in into the proper truck and its accompanying array:
public static string[] Trux_Info = new string[20];
The letters designate different pieces of information 'I ' designates id of the truck in this case truck5000, the 'R' is rpm, 780, followed by gear and so on.
The transmission is by RS-232, on the parent form, constantly open. Each truck sends/ reads through this, and the buffers, in and output, is flushed after each use. I've tried individual comports per childform, but had unaccessible issues.
As I have ran out of ideas and test methods I asking if anyone sees what I'm missing.
Further definitions, test methods, and results are provided as an attachment.
Is there way to attach attachments, I have them already zipped.?
Thanks
|
|
|
|
|
None of this makes much sense. I can't work out how your long info string has anything to do with the title.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I've read that about 5 times and I'm still not sure!
So you have several external devices connected to the same comport (?) represented in your software as 'child forms', and all the control is done through one 'parent form' that holds the comport connection?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
In effect yes, each truck is to be timesliced, a chance to send and recieve data by itself.
The maincontroller, parent form, contains the comport feature. The parent form also creates an instance of each truck when its time for that particular truck.
I hope that clarifies. I have a zip file of a more defined situ. Unfortunatley I haven't found a place to apply an attachment.
Thanks for reply
L.
|
|
|
|
|
Hi,
Lecutus1 wrote: I had to do this because sometimes the sending form would receive info string from another truck.
That is the sentence I noticed in your post because unexpected data read from the serial port is indicative of a fault. The question is why is bad data being received? Where to route the response is relevant only when the data is good.
From your description each request that is sent is tagged with a truck ID. I assume that all trucks attached to the serial port will receive the request but only one will recognise the ID and respond using that same ID. Is that correct and can you verify that all the trucks operate correctly?
Clearly only one truck should be allowed to respond at a time as overlapping responses at the serial port would cause all sorts of trouble. Problems of this nature can be avoided by ensuring that a response is received for each request before a further request is issued. If this send-receive protocol is strictly obeyed then routing the response to the correct form is straightforward as the expected response ID is always known. If a situation ever arises where response ID != request ID then something has gone very wrong and the status of the truck is unknown.
Do you wait for the response to each request and check that a full response has been read before parsing it?
That is just a few things for you to think about. Let us know how you get on.
Alan.
|
|
|
|
|
Thanks Alan
As to the first question, I'm not recieving bad data, I've got a filter for that, I'm recieving data from another truck. Your absolutely right as far as write and wait for a response before moving to the next truck.
I'm still trying to get used to the timing of this RS232 and its behaviour.
Once again this was a case of overcooking the goose, in other words I did too much, too quickly when a a little less could have been used.
Thanks once again
|
|
|
|
|
I am doing a windows based project in which i come across a situation where i need to update the values in the database with the values edited in the datagridview control. I need the code for doing this.
|
|
|
|
|
praveenkumar_vittaboina wrote: I need the code for doing this.
Well, this is no code shop where you get the ready code.
What have done so far?
Break down your problem into small units, try to look in Google for the examples and still if you have difficult than pin point your problem so that some one can help you.
This will eventually make you a better developer too.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
|
Hello,
I have a problem with the accuracy of double.
If i have a lot of formula that look somthing like this :
double a = Somthing1();
double b = Something2();
double c = something3();
double Ans = a+b-c
And in one of the calc the answer for :
a = 2e-35
b=1
c=1
then the formula need to be :
Ans =2e-35+1-1=2e-35+0=2e-35
but becaue a will be very small number and c and b will be big number (1)
then Ans will be 0 because it will do this:
(2e-35)+1-1 = ~0+1-1=1-1=0
so if
ans = a+b-c != b-c+a
What can i do to solve this problem ?
|
|
|
|
|
Use a float.
On a more serious note, all programmers should know that:
double a = 1.5;
double b = 1.5;
bool result = a == b
When doing double math determine the acceptable margin of error and use that in your calculations to evaluate equality. Usually margin of error is one order of magnitude below significant results. The other option is to magnify your numbers by a factor before performing your results and then divide when finished. Double will eventually run out of precision.
|
|
|
|
|
Multiply c by -1 and then apply Kahan summation. You can't really do anything better than that unless you know something about a b and c in advance.
|
|
|
|
|
Hi,
when you are accumulating numeric values, you have to take care of the order you apply; the right order could be:
- small to large if you don't expect values to cancel out (say you have to add a million times 1 and one billion; doing the ones first will yield one million, which is visible when added to one billion. The other way around each individual one would be lost against the billion.
- large to small if you have large values that cancel each other out.
As you can see, it isn't straightforward. There is a difference between computer hardware+software and algebraic equations.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Excel.Application ExcelApp = new Excel.ApplicationClass();
ExcelApp.Visible = false;
String WorkbookPath = filename;
Excel.Workbook ExcelWorkbook = ExcelApp.Workbooks.Open(WorkbookPath, 0, false, 5, "", "", false, Excel.XlPlatform.xlWindows, "", true, false, 0, true, false, false);
Excel.Worksheet Sheet = (Excel.Worksheet)ExcelWorkbook.Sheets[1];
DataTable newTable = new DataTable();
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + filename + ";Extended Properties= Excel 8.0";
OleDbConnection conn = new OleDbConnection(strConn);
conn.Open();
OleDbCommand cmd = new OleDbCommand("SELECT * FROM [" + Sheet + "$]", conn);
cmd.CommandType = CommandType.Text;
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
da.Fill(newTable);
dataGridView1.DataSource = newTable;
I am using this code to read an excel file and save the data in a datatable ....
I am getting this error "System.__ComObject$' is not a valid name. Make sure that it does not include invalid characters or punctuation and that it is not too long." and the error pointer comes on the second last line of the code ... can neone help
|
|
|
|
|
You are building your SQL string by concatenating the object Sheet. This object is of type Excel.Worksheet - which is not a string. Thus, as with all objects, it is calling it's ToString() method to obtain a string value it can concatenate with the rest of the SQL string. Since Excel.Worksheet is a COM Object, it's ToString is returning "System.__ComObject". You'll need to obtain the actual text name of the worksheet and use that to build the SQL string.
|
|
|
|
|
Thankyou very much ... the answer was not only precise but was very well explained
|
|
|
|
|
You may also want to take a look at OleDbConnection.GetSchema (Google it to find the MSDN documentation link). This will allow you to directly obtain schema information for the Excel file. The schema is returned as a DataSet containing DataTables for a variety of entities. One of these DataTables will contain a list of table names (which are the Excel worksheet names you'll use in your queries). This will allow you to avoid using COM automation entirely (ie. Excel Object library) to obtain the list of Worksheets. The benefit: no dependency on Excel object library DLLs, registration, versioning, etc... all the headaches that come with COM automation.
|
|
|
|
|
Hi all,
if someone forgets there password for login to a website, i would like to send them an email with there username and password by quering the database.
Can any one advice me on the C# code that is used for sending email to a user?
Thank you in advance.
|
|
|
|
|
If you search this site for an article called 'how to use google', you'll find that I both answer your question, and the underlying question that caused you to need to ask this.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi Christain,
Thank you for your response.
Can you at least learn to be polite?
Any ways I have the Answer :
System.Net.NetworkCredential SMTPUserInfo = new System.Net.NetworkCredential(sSMTPUser, sSMTPPass);
SmtpClient emailClient = new SmtpClient("smtp.gmail.com",587);
The 587 works with some mail Client but not with others like Gmail, etc...
|
|
|
|
|
He is being polite, and you're being lazy. You can find out what port Google expects by Googling for "SMTP port gmail".
Good luck
I are troll
|
|
|
|
|
kibromg wrote: Can you at least learn to be polite?
Watch your tone there, Christian Graus has been a member at codeproject for years, with over 50,000 posts and 30 articles, his Fixture/Legend status has been earned.
You are a firstly and obviously a beginner and new to programming, you're putting in NO effort to make your system functional other then expecting your work handed to you.
I'll be less polite then others, get the f*** off your ass and go learn to use Google, and if you can't find your answer there then guess what, it's time to find a different f***ing profession, one that is more suited to your (lack of) intelligence.
How's that for polite, buddy?
|
|
|
|
|
EliottA wrote: How's that for polite, buddy?
Not much, I'm afraid.
However it is pretty clear, except for some asterisks.
Do you really need 27 letters in your alphabet?
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I could have circumvented then filter, but I didn't feel it appropriate.
Those responses truly get to me, especially when geared towards people with high post/article counts who have contributed more then enough for others. I knew zilch about programming before I stumbled my butt onto this site, and learned from various tutorials and posts before I began to post myself.
So retorts like that, insulting from people from whom I've directly (or indirectly) learned off of comes as a direct insult to me.
|
|
|
|
|
Yes, you and I both don't like what was said.
However, if I would want to call someone impolite, I would still try and do so in a polite way if such is possible at all.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|