Solved

OnWork event for idTHCPClient

Posted on 2006-07-06
3
213 Views
Last Modified: 2010-04-05
Hi!

I am writing a TCP client application and i am using indy9.
The server works as following:
When the connection established the server starts sending data messages. A message could look something like this:
<start>STX</start>
<configuration>.......</configuration>
<record>
          <paramcode>1</paramcode>
          <time>12:00</time>
         <mesurevalue>10</mesurevalue>
</record>
<record>
          <paramcode>12</paramcode>
          <time>12:00</time>
         <mesurevalue>10</mesurevalue>
</record>
The message is not really in xml.


number of record is changing. If a record has the right paramcode i should plot it on a graph. I have managed to do this by reading the hole message and then go through the records and plot it.
My question is is it possible to use onwork and check the records as they arrive on by one?
I would like to have my graph as a advanced progressbar so that u can watch the graph in realtime and se the values beeing ploted when they arrive.

Thanks
0
Comment
Question by:mikrodidakt
3 Comments
 
LVL 10

Expert Comment

by:atul_parmar
ID: 17048838
Can you tell me how you are reading the message.

If you are reading it in full, then change it so that it reads specified number of chars e.g. read one record at time. or character by character.
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 17049047
add
<rec_count>140</rec_count>

then you know that you are expecting 140 records and you can make a progress bar for example.
0
 
LVL 17

Accepted Solution

by:
TheRealLoki earned 250 total points
ID: 17052780
if you are using WriteStream (or Write(Stream) ) then yes, you will need to look in your stream during the OnWork() event and get the data to plot it
eg. use the stream's position, and work out where the last <mesurevalue> would be in it. make sure you have not already plotted this one (ie. buffer has increased to include the next measure, and plot it

If however, you are just using

WriteLn('<record>');
WriteLn('          <paramcode>1</paramcode>');
WriteLn('          <time>12:00</time>');
WriteLn('         <mesurevalue>10</mesurevalue>');
WriteLn('</record>');

then there is no need for the OnWork event.
As you receive each line, chek it and plot the data
eg.
S := TCPCLient1.IOHandler.ReadLN;
i := pos('<mesurevalue>', s);
if i > 0 then
begin // plot it
  delete(s, 1, i _ length('<mesurevalue');
  s := copy(s, 1, pos('</mesurevalue>', s)-1);
  PlotValue(IntToStr(s));
end;
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now