Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

OnWork event for idTHCPClient

Posted on 2006-07-06
3
Medium Priority
?
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 750 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

609 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