locked
Display Rows continuously from start to bottom RRS feed

  • Question

  • Hello All;

    What i need to do is to display 1000 logs coming from the server into 20 rows continuously.Does anyone have any idea??
    I am storing the data strings coming from the server into the vector container. And that i have to display continuously from 0th Row row to 19th row i.e total 20 rows continuously, till the 1000 logs are complete.

    I have 20 rows and i need to display the data in format like, deleting or storing the data from the first row into the vector and then move it continuously from the bottom to top ie if 1st row has 999th log then after 1st fill 19th row has 980th log now after that we have to store 999th data in vector and decrement log count from bottom row i.e 19th row like 979,978,977 and so on.

    Please help if anyone has some idea.

    Wednesday, January 7, 2015 11:35 AM

All replies

  • How about a console app where the console is 20 lines high?

    How do you want to display this? Do you have a visual mock-up you can share?  What part is giving you trouble?  Is this purely a design question?  It sounds sort of like maybe you're wondering if there's a control that will suit your needs.

    Or maybe you're wondering about how to implement a circular buffer.  Which is basically just an array of 20 items and then the index of the first and last items.

    Wednesday, January 7, 2015 12:21 PM
  • We don't want to do it by using circular buffer but using vectors only maybe by using function with 2 arguments as startrow and endrow. 

    I am able to display the logs once from 999th log to 980th log but now i want to display the remaining logs . How to display that ?? We don't have any button as it is not event driven programming but we have just simple 20 Rows of string field and we want to display logs continuously upto 1000. 

    void XYZ::fnDisplayData(int rowstart, int rowend)
    {
    		
    	int size = udp.size();
    	int n = size;
    
    
    	CString text;
    
    	
    		
    		   
    			
    				   while(rowstart <= rowend)
    				   {
    						 if(rowstart == 0)
    						 {	
    						    GetField(e_Logs + rowstart)->SetValueString(udp[n-1]);
    						    text.Format(udp[n-1]);
    							//rowstart++;
    						 }			
    						 
    							n--;
    							GetField(e_Logs + rowstart)->SetValueString(udp[n-1]);
    							text.Format(udp[n-1]);
    							rowstart++;
    						 
    						 
    					
    						 while(rowstart == rowend)
    						 {
    							 
    							n--;
    							GetField(e_Logs + rowend)->SetValueString(udp[n]);
    							text.Format(udp[n]);
    						//	rowstart--;
    
    						 }
    						// if(rowstart == 20)
    						//	 break;
    				   }
    						
    
    				  
    				
    
    }

    Here udp is our vector object, and i am using fndisplaydata function to display data with 2 arguments as rowstart and rowend.

    Please help.

    Thanks.


    • Edited by tndesai Wednesday, January 7, 2015 12:39 PM
    Wednesday, January 7, 2015 12:28 PM
  • We don't want to do it by using circular buffer but using vectors only maybe by using function with 2 arguments as startrow and endrow.

    I am able to display the logs once from 999th log to 980th log but now i want to display the remaining logs . How to display that ?? We don't have any button as it is not event driven programming but we have just simple 20 Rows of string field and we want to display logs continuously upto 1000.

    If you want to update the display continuously then use a timer. Maybe I have not understood your requirement, but don't you just want to display the last 20 messages (or all of them if there are less than 20). Surely this is very simple.


    David Wilkinson | Visual C++ MVP

    Wednesday, January 7, 2015 1:06 PM
  • David Sir,

    I want to display all logs starting from last index that is 999 to 0 logs continuously on 20 rows one by one.

    Do you know sir what to do with it and how to display continuously.

    Thanks.

    • Proposed as answer by Pintu Shukla Monday, January 19, 2015 9:26 PM
    • Unproposed as answer by Pintu Shukla Tuesday, January 20, 2015 2:22 PM
    Wednesday, January 7, 2015 1:28 PM
  • David Sir,

    I want to display all logs starting from last index that is 999 to 0 logs continuously on 20 rows one by one.

    Do you know sir what to do with it and how to display continuously.

    Thanks.

    Here's what I find frustrating about your question.

    I don't know if you're designing a Win32 desktop application, Console application, Web page, or what.  This GREATLY affects what it means to "display" something.  So I'm left to assume that you are writing a native Win32 windows desktop application using MFC (I deduce this solely on the appearance of CString in your code.)

    A log is typically a collection of log entries.  1000 logs to me suggests 1000 different collections of log messages, each with multiple rows.  But I have to assume that what you are calling a "log" is what I would call a "log entry" or "log message".  (One record in a table of log messages.)  This affects in what manner they would be displayed such as in one column vs multiple columns.

    When you say rows, it typically suggests data tables and database operations.  You haven't said if anything database related is going on.  And although "GetField" looks vaguely ADO-like, I'm going to assume that it is not.  But it does suggest to me that your log message is divided into fields, and that you probably want to display columnar data.  The only thing that contradicts that is that I had to look at some of your past posts to figure out that you are writing in native C++ and that you are (likely) trying to manage a std::vector of strings.  So that suggests to me that each log message is just a simple string.  This means that you probably don't need a table view.

    You haven't really given me a good sense of what you mean by continuously.  You may mean that it updates periodically, or that rows appear one after the other, or that it scrolls with smooth animation.

    What you've said is that you have "20 rows of string field".  I'm not sure if you mean that you have 20 static label controls ... it kind of sounds like that may be what you mean.  But regardless, it sounds like you have "room" to display 20 items and you want to display 1000 in that space.  This is where it breaks down for me.  What do you want to have happen?  I'm afraid I just don't get it from your explanation yet.

    You said you were able to display 20 of the 1000 messages but you "don't have any button".  You also said that it is not event driven programming", (which is contrary to my assumption that you are creating a Win32 windows desktop application")  So I'm not sure what constraint this has placed on you.

    It sounds like you may need to periodically update the screen with either an automatic "next page" feature, or that you want text to scroll by in an animation.

    You'll have to clarify these things if you want help.

    What you DID show me was an incomplete snippet of code with the following features:

    • An unused, no-purpose text string variable.
    • An undescribed  GetField function and an undescribed SetValueString method of some unknown class.

    I'm trying very hard to help you, but you haven't described this in enough detail for me to do so.

    What aspect of this do you need help with?  What did you try?  And why didn't it work?

    Wednesday, January 7, 2015 2:16 PM
  • Correct me if i am wrong . You are getting 1000 logs from server in 20 rows.

    Q:- How do you know that those are 1000 logs first . Might be they are 20 log message only ?

    If you are sure that you are getting 20 Rows only in that case you can have a map on where key is the row no and value will be your vector<> or struct which will store all the log in a partucular row . Now you can display it from map and can add and delete row on the map as per your requirement and can update your row.

    Thanks


    Rupesh Shukla

    Wednesday, January 7, 2015 2:49 PM
  • What we are doing is We have have my company's workstation in which we are creating GUI type application calling it as Image development.

    In this regard we are having 20 String fields and we are listening from the server and specifying the limit of logs to be 1000 i.e we need to process 1000 logs. We are storing the logs coming from the UDP server in a vector container and thus displaying the logs stored in vector in a string field as a Image.

    The GetField Function however used in our workstation to get the value of String field, here e_Logs is the enum variable with some specific id,.

    What i am able to display is the logs 999 to 980 in 20 Rows now , but my problem is now how can i display the remaining logs upto 0th log in 20 rows ?? 

    We have the idea like when first time the logs are filled from 999 to 980 then next time 999th log will be stored in the vector from the top row and subsequently decrement the log count by one so in next sequence we have logs from 998 to 979 to be displayed in 20 rows and this goes on continuously upto all the logs upto 0 will be displayed accordingly. 

    How to print or to display this type of sequence??? Please, tell me about it.

    Thanks,

    Hope it is clear now.


    • Edited by tndesai Thursday, January 8, 2015 8:49 AM
    Thursday, January 8, 2015 7:16 AM
  • What we are doing is We have have my company's workstation in which we are creating GUI type application calling it as Image development.

    In this regard we are having 20 String fields and we are listening from the server and specifying the limit of logs to be 1000 i.e we need to process 1000 logs. We are storing the logs coming from the UDP server in a vector container and thus displaying the logs stored in vector in a string field as a Image.

    The GetField Function however used in our workstation to get the value of String field, here e_Logs is the enum variable with some specific id,.

    What i am able to display is the logs 999 to 980 in 20 Rows now , but my problem is now how can i display the remaining logs upto 0th log in 20 rows ?? 

    We have the idea like when first time the logs are filled from 999 to 980 then next time 999th log will be stored in the vector from the top row and subsequently decrement the log count by one so in next sequence we have logs from 998 to 979 to be displayed in 20 rows and this goes on continuously upto all the logs upto 0 will be displayed accordingly. 

    How to print or to display this type of sequence??? Please, tell me about it.

    Thanks,

    Hope it is clear now.


    • Edited by tndesai Thursday, January 8, 2015 8:49 AM
    Thursday, January 8, 2015 7:16 AM
  • Hi,

    My understanding is, you will be receiving 1000 log entries from server and you are storing them in a vector of string [Not sure if you receive them all at once or randomly].

    You want to display the latest 20 entries in a table like control.

    What do you mean by "in next sequence"? When is this sequence triggered, on pressing any button or on receiving log from server or something else?

    Are you looking for suggestions for implementation logic or suggestions for controls/containers to use in your program.

    Please correct if the understanding is wrong.

    Regards,

    Suman



    • Edited by rp_suman Thursday, January 8, 2015 1:02 PM
    Thursday, January 8, 2015 1:01 PM
  • I'm having a very difficult time understanding you.  Perhaps I'll go in the direction that I think you need me to go, and if you need to correct me, then please do so.

    Since you haven't said how to read a log entry or how to "display" one, I'm going to assume three things:

    1. That you can provide a function to get the log entry at index i.  Assuming it's a std::vector called "logs", I'll use the code:  logs[i]
    2. That you can get the number of log entries (in case it isn't 1000).  Assuming it's a vector again, I'll use the code: logs.size()
    3. That you can provide a function to "display" a log entry as a row.  I'll use the code:  Display( log )

    If not, then you should first refactor your code to have this structure, (or explain to me why it can't be done.)

    You let me know if I do something that doesn't match your expectations.  OK?

    Given those assumptions, then to display the first log entry:

    Display( logs[0] );


    To display the first two log entries:

    Display( logs[0] );
    Display( logs[1] );


    To display the first n log entries:

    for( int i = 0; i < n; ++i ) {
       Display( logs[i] );
    }


    To display the first n log entries in reverse order:

    for( int i = 0; i < n; ++i ) {
       Display( logs[n-1-i] );
    }


    To display the last log entry:

    Display( logs[logs.size()-1] );


    To display the last two log entries:

    Display( logs[logs.size()-2] );
    Display( logs[logs.size()-1] );


    To display the last n log entries:

    for( int i = 0; i < n; ++i ) {
       Display( logs[logs.size() - n + i] );
    }


    To display the last n log entries in reverse order:

    for( int i = 0; i < n; ++i ) {
       Display( logs[logs.size() - 1 - i)] );
    }


    To display n log entries starting at index k

    for( int i = 0; i < n; ++i )
    {
       Display( logs[ k + i ] );
    }


    To display n log entries starting at index k in reverse order

    for( int i = 0; i < n; ++i )
    {
       Display( logs[ k + n - 1 - i ] );
    }

    To display n log entries in groups of 20.

    To do something special every 20 items, such as handling pagination with BeginPage and EngPage functions (that you provide).

    for( int i = 0; i < n; ++i )
    {
       if( i % 20 == 0 ) BeginPage();
       Display( logs[i] );
    }
    EndPage();


    Does any of this help?


    Thursday, January 8, 2015 2:19 PM
  • What i am able to display is the logs 999 to 980 in 20 Rows now , but my problem is now how can i display the remaining logs upto 0th log in 20 rows ?? 


    So what is the problem, When you are able to display from 999 to 980 same thing you have to do for other element as well . In this case fetch next 20 prior from vector and display them . Actually where are you displaying these row in any control or console etc. Looks like your problem is not about reading log from vector it's about displaying them on console or in control. See as you mentioned Button on your app so i am assuming it is some kind of GUI application in that scenario you can have a RichEditControl and display your data inside it .And show a scrollbar on your control when user click on scroll then read next or priv record from vector and show in the control depend on the direction of scroll.

    Thanks


    Rupesh Shukla

    Thursday, January 8, 2015 2:50 PM
  • Thanks, Wyck Sir for your help . I am getting logs from the server when the bytes received  is greater then zero.  What i did is took the infinite loop and as long as bytes received is greater then zero from the udp server i got the logs instead of displaying particular amount of logs, i made the code generic.

    Now my Problem is:-  I am able to display logs in 20 rows but it is not refreshing once the 20 rows are filled.

    I need to refresh it with new logs when the 20 rows are filled at first, with the next 20 logs and so on it goes on in infinite loop till we get the bytes received equal to zero.

    Please help.

    Thanks.

    Monday, January 12, 2015 10:54 AM
  • Can we break the problem up into two pieces, please?

    I'd like to know if this is:

    A) a display problem, hinging on either the manipulation of data structures or user interface display issues. 
    or B), a data collection problem related to networking or populating the data structures in the first place.

    To figure this out:

    1)  Use dummy data, not originating from your UDP server and see if your display updates the way you intended.  If so, then this is probably a data collection problem.  You should be able to "pretend" that your messages are simply the numbers from 1 to 1000, for example, by replacing the function that gets the log messages with a mock.

    2) Just use fprintf debugging and write your logs to a dummy file on disk and see if the data you collected matches what you see over the udp connection.  You say that data comes "from the UDP server", which I can only assume means that your application is a UDP client and requests log message data from the server via UDP.  In this case, you have to describe to me what your application protocol is so that I am convinced that you are not suffering from dropped/duplicated or out-of-order UDP traffic.

    In case you don't know what I mean by fprintf debugging.  I mean that should open a file using fopen and then fprintf into that file a simple text representation of the data you collected.

    I have a suspicion that this is a networking problem.


    • Proposed as answer by rp_suman Wednesday, January 14, 2015 1:56 PM
    Monday, January 12, 2015 8:46 PM
  • Hi,

    While looking at your code quickly, I thought there is a chance for infinite loop / run time error at the inner while loop:

    while(rowstart == rowend)

    I am not sure, but another possible problem why the controls are not updated with other set of 20 logs is, you are not removing the entry from the vector/array "udp".

    Is "udp" a "copy" of the logs received from the communication port or it is used directly to receive the logs? In that case, it's size will change while your function fnDisplayData() is being running and you may need some locking mechanism.

    Could you please tell when exactly(timing) you want to put the 2nd set of 20 logs in text fields:

    1. On receiving new logs from server

    2. In regular time intervals(say every second once or every 100ms once)

    3. On any user action like scroll or something

    4. Until reaching start of vector without any delay. There is no use in this case, as user cannot see the values changing until last 20 logs updated as the update would be very fast.

    5. Anything else?

    Whatever details you have provided is not sufficient enough to understand your program flow or the issue and my suggestions are based on assumption only.


    Thanks & Regards

    Wednesday, January 14, 2015 1:54 PM
  • Hello rp_suman;

    What we need to do is once the 20 rows are are filled we need to erase or update the previously printed logs with new logs starting from the first row to the 20th  row.  The logs are coming from the UDP server when we listen to the server.

    Also, when the bytes received is greater then zero then only we need to print the logs into the 20 rows created as an image or GUI in my Company's workstation. I am attaching the snapshot for much clear view to understand what i need to do. Attached herewith the sample GUI what we need to do is display logs from row 1 to row 20 and after filling it once we need to update this rows with new logs from 1 to 20. Please tell me how to do it ???????  I am getting the logs running  in the background but it is now displaying in this 20 rows continuously, as you can see also there is no button in the GUI created so we want to do it without using any button or clicking any button.

    Thanks in advance.


    Tanmay

    Friday, January 16, 2015 12:29 PM
  • Hello rp_suman;

    What we need to do is once the 20 rows are are filled we need to erase or update the previously printed logs with new logs starting from the first row to the 20th  row.  The logs are coming from the UDP server when we listen to the server.

    Also, when the bytes received is greater then zero then only we need to print the logs into the 20 rows created as an image or GUI in my Company's workstation. I am attaching the snapshot for much clear view to understand what i need to do. Attached herewith the sample GUI what we need to do is display logs from row 1 to row 20 and after filling it once we need to update this rows with new logs from 1 to 20. Please tell me how to do it ???????  I am getting the logs running  in the background but it is now displaying in this 20 rows continuously, as you can see also there is no button in the GUI created so we want to do it without using any button or clicking any button.

    Thanks in advance.


    Tanmay

    Friday, January 16, 2015 12:30 PM
  • Hello Wyck Sir;

    What we need to do is once the 20 rows are are filled we need to erase or update the previously printed logs with new logs starting from the first row to the 20th  row.  The logs are coming from the UDP server when we listen to the server.

    Also, when the bytes received is greater then zero then only we need to print the logs into the 20 rows created as an image or GUI in my Company's workstation. I am attaching the snapshot for much clear view to understand what i need to do. Attached herewith the sample GUI what we need to do is display logs from row 1 to row 20 and after filling it once we need to update this rows with new logs from 1 to 20. Please tell me how to do it ???????  I am getting the logs running  in the background but it is now displaying in this 20 rows continuously, as you can see also there is no button in the GUI created so we want to do it without using any button or clicking any button.

    Thanks in advance.


    Tanmay

    Friday, January 16, 2015 12:30 PM
  • (I know what 20 rows look like.  Sadly, your picture provides no additional value.)

    But, sure.  I can help you with that.  Please tell me what is the current API to drive the GUI Display mechanism?  What kinds of functions do you have now?

    Friday, January 16, 2015 4:08 PM
  • Hello Tanmay, Even after so many post still I am not sure whether i understand your problem  fully or not.

    Break your problem in three section.

    1) What you have

    2) What you have to do

    3) How

    Now go step by step I am assuming that you are using some ListBox to show your log.See your logic will be same control can be differ.Apart from this you have a vector witch contain information about all the logs from xyz server.

    Now you want to display this log inside your list box and you need to update your list Box as well based on your data.

    First Step:- You already aware that how to show log inside your control . Here you should debug your code to understand how things are taking place if you are not aware about it.

    Second Step :-As you mentioned that " when the bytes received is greater then zero then only we need to print the logs into the 20 rows created as an image or GUI in my Company's workstation" . I think that is the time when you are filling your vector .So here is What you have to do .Create an event inside your app and whenever you fill new data to vector fire that even to your control . So that it can update itself with respect to new data. You don't have to click any button for this.

    Just do some try run and you will be fine but if still you have some issue . Post here ,people are here to help you.

    Thanks 

                         


    Rupesh Shukla


    Friday, January 16, 2015 4:46 PM
  • Now go step by step I am assuming that you are using some ListBox to show your log.See your logic will be same control can be differ.Apart from this you have a vector witch contain information about all the logs from xyz server.

    FYI: I didn't get that.  In fact, tndesai has claimed most recently that the rows are created "as an image or GUI in my Company's workstation", and also that they are using the approach of "displaying the logs stored in vector in a string field as a Image."  That doesn't suggest "ListBox" to me at all.

    ----

    And all I can think of is that the GUI needs to display logs 1-20 for a few seconds, then display 21-40 for a few seconds, then display 41-60 for a few seconds, etc. And then possibly roll over after displaying lines 981-1000 so that it displays 1-20 for a few seconds, and then repeat endlessly, or until new data comes along.

    Is that what you are trying to do?  Is that what you mean by "continuously"?

    Friday, January 16, 2015 7:19 PM

  • FYI: I didn't get that.  In fact, tndesai has claimed most recently that the rows are created "as an image or GUI in my Company's workstation", and also that they are using the approach of "displaying the logs stored in vector in a string field as a Image."  That doesn't suggest "ListBox" to me at all.

    That's why i mentioned that i am assuming. As he mentioned or there and same time in first step i had asked him to debug his code ,to know how they are displaying data in the row that will let him know whether they are using some control or drawing inside the paint() or draw() function.Just provided him the basic idea. But as per first line of my post was that " Even after so many post still I am not sure whether i understand your problem  fully or not. "

    So i just tried to explain him what he can do. Now it's up to him.

    Thanks


    Rupesh Shukla


    Friday, January 16, 2015 7:40 PM