Solved

OnWork event for idTHCPClient

Posted on 2006-07-06
3
218 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

696 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