Informative Screen

Informative Screen

Postby Adolfo » Mon Jan 14, 2019 2:17 pm

Hi Fivewinners.

Need some help with something I need to do.

Years ago I made a kind of informative screen on what was going on in certains parts of an industry. There were only 5 items to show.
So I made a Xbrowse, with the name of the process, numeric data and a color button. I refresh them every 2 minutes. The input was made by some employees who modified some data on a DBF, I read the dbf and refresh the data shown. So far, so good.

But now, I was asked to do something similar, some Changes needed. Is MYSQL the DB used (no problem at all), but I dont know the numer of items to show, perhaps more than the ones that can fit in 1 xbrowse screen, so if that is the case I will need to automatically scroll it. There's no user input in this Pc, just the xbrowse showing the data.
Any idea will be appreciated.

From Chile.
Adolfo
;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
User avatar
Adolfo
 
Posts: 860
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile

Re: Informative Screen

Postby nageswaragunupudi » Tue Jan 15, 2019 9:35 am

Do you mean something like this?

If your xbrowse displays N rows at a time on the screen, you make some changes to a row > N and you want to scroll and bring new row into view.

If that is what you want then
Code: Select all  Expand view  RUN

oBrw:BookMark := <nNewRowNum>
oBrw:Refresh()
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10662
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Informative Screen

Postby James Bott » Wed Jan 16, 2019 12:42 am

Adolfo,

You could add a TIME field and index on it, so that the newest record would also be displayed at the top. You can refresh the screen each time a new update is made and it will appear to scroll down.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Informative Screen

Postby Adolfo » Thu Jan 17, 2019 8:01 pm

Hi..

Sorry I was out of office some days.

Nages, James.
The idea is. I have some information that I retrieve from a Sql Table. This table is modified by others, they include information of some industry processes, line state and numbers of pieces.
I dont know how many of them will be in the data, the minimum is 5, the max is 99.
So, I show them in a big screen, I run a query and get the ones within the range I need to show. I run this query to update a xbrowse every 2 minutes, within this time, anything could happen, some process can dissapear, some will be added, and number of pieces change.

I have no problem updating the query, but I need to show them in the xbrowse, If the xb have 10 lines, and I have 21 process data then I need to scroll it down or up until next time query in a continium loop. If I get only 8 data lines, then theres no need to scroll it.

Thtas the idea. Working with timers I can update the query, but no idea on how to do or not the scroll

Thanks in advance.

PD : This info is shown to others mebers of the crew, is like a informative screen, like those in the airports, theres no human interaction in this pc. I'm supposed to turn the pc on, and this is shown automatically.
;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
User avatar
Adolfo
 
Posts: 860
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile

Re: Informative Screen

Postby James Bott » Thu Jan 17, 2019 8:58 pm

Adolfo,

Since you are using SQL presumably you have an autoincremented ID field. You can use that to sort the data however you wish, newest (largest ID) at the top is what I would use.

In the browse just skip one record at a time using a timer. Then when the timer expires, refresh the browse. When you get to the end go back to the top and start over.
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Informative Screen

Postby nageswaragunupudi » Fri Jan 18, 2019 4:23 am

Mr. Adolfo

Are you looking for something like this?

Image

In the animated gif above, the scrolling appears a bit jerky, but when you run the actual sample below, you find the scrolling to be very smooth.

This is the sample program. This uses data on FWH free mysql server. If you have FWH version 16.12 or later you can copy this program to \fwh\samples folder, build and run with buildh.bat or buildx.bat.
Code: Select all  Expand view  RUN
#include "fivewin.ch"

#define MIN_ITEMS           8 //   5
#define MAX_ITEMS          20 //  99
#define REFRESH_SECS       30 // 120

//----------------------------------------------------------------------------//

function Main()

   XbrAutoScroll():New()

return nil

//----------------------------------------------------------------------------//

function db()

   static oCn

   if oCn == nil
      oCn   := FW_DEMODB()
      if oCn == nil
         QUIT
      endif
   endif

return oCn

//----------------------------------------------------------------------------//

CLASS XBRAUTOSCROLL

   DATA oRs, oWnd, oFont, oBrw
   DATA nRecCount
   DATA nRec      INIT 0
   DATA nPixel    INIT 0

   DATA oTimer
   DATA nReadSec, nScrollSec

   METHOD New() CONSTRUCTOR
   METHOD ReadData()
   METHOD SetupBrowse()
   METHOD TimerAction()
   //
   METHOD RsGoTo( nGoTo )
   METHOD BrwSkipper( n )
   METHOD BrwScrollDown()

ENDCLASS

//----------------------------------------------------------------------------//

METHOD New() CLASS XbrAutoScroll

   ::ReadData()
   ::SetupBrowse()

   ACTIVATE WINDOW ::oWnd CENTERED

   RELEASE TIMER ::oTimer
   RELEASE FONT ::oFont
   db():Close()

return Self

//----------------------------------------------------------------------------//

METHOD ReadData() CLASS XbrAutoScroll

   local nRecs    := HB_RandomInt( MIN_ITEMS,  MAX_ITEMS )
   local nStart   := HB_RandomInt( 1, 400 )
   local nUpto    := nStart + nRecs - 1
   local cSql     := "SELECT FIRST,CITY FROM customer WHERE ID BETWEEN ? AND ?"

   if ::oRs == nil
      ::oRs   := db():RowSet( cSql, { nStart, nUpto } )
   else
      ::oRs:Requery( { nStart, nUpto } )
   endif

   ::nRecCount    := ::oRs:RecCount()
   ::nRec         := 0
   ::nPixel       := 0

   if ::oBrw != nil
      ::oBrw:GoTop()
      ::oBrw:nDataRows  := ::oBrw:RowCount()
      ::oBrw:BookMark   := ;
      ::oBrw:nRowSel    := ::oBrw:nDataRows
      ::oBrw:Refresh()
   endif
   ::nReadSec     := ;
   ::nScrollSec   := SECONDS()

return nil

//----------------------------------------------------------------------------//

METHOD SetupBrowse() CLASS XbrAutoScroll

   DEFINE FONT ::oFont NAME "VERDANA" SIZE 0,-30
   DEFINE WINDOW ::oWnd
   ::oWnd:SetFont( ::oFont )
   @ 20,20 XBROWSE ::oBrw SIZE -20,-20 PIXEL OF ::oWnd DATASOURCE ::oRs ;
   COLUMNS { || ::oRs:RecNo }, "FIRST", "CITY" ;
   HEADERS "SlNo" ;
   COLSIZES 100,200,200 ;
   NOBORDER FOOTERS

   WITH OBJECT ::oBrw
      :nMarqueeStyle    := MARQSTYLE_NOMARQUEE
      :lHScroll         := .f.
      :lVScroll         := .f.
      :aCols[ 1 ]:bFooter  := { || ::nRecCount }
      :nStretchCol      := 3
      :lFitGridHeight   := .t.
      :lRecordSelector  := .f.
      :lDrawBorder      := .t.

      :bSkip            := { |n| ::BrwSkipper( n ) }
      :bBookMark        := { |u| If( u == nil, ::nRec + 1, ::RsGoTo( u ) ) }
      :bKeyNo           := :bBookMark

      :CreateFromCode()
   END

   ::oWnd:nHeight      := 600
   ::oWnd:nWidth       := 700

   DEFINE TIMER ::oTimer INTERVAL 10 ACTION ::TimerAction() OF ::oWnd

   ::oWnd:bInit   := <||
      ::oBrw:BookMark := ::oBrw:nRowSel := ::oBrw:RowCount()
      ACTIVATE TIMER ::oTimer
      return nil
      >

return nil

//----------------------------------------------------------------------------//

METHOD TimerAction() CLASS XbrAutoScroll

   local nLapsed

   nLapsed  := SECONDS() - ::nReadSec
   if nLapsed >= REFRESH_SECS
      ::ReadData()
      return nil
   endif

   if ::nRecCount > ::oBrw:nDataRows
      ::BrwScrollDown()
   endif

return nil

//----------------------------------------------------------------------------//

METHOD RsGoTo( nGoTo ) CLASS XbrAutoScroll

   ::nRec   := Max( nGoTo - 1, 0 )

   if ::nRecCount <= ::oBrw:nDataRows
      ::nRec   := Min( ::nRec, ::nRecCount - 1 )
   endif

   ::oRs:GoTo( ( ::nRec % ::nRecCount ) + 1 )

return ::nRec + 1

//----------------------------------------------------------------------------//

METHOD BrwSkipper( nSkip )

   local nOldPos  := ::nRec

   DEFAULT nSkip := 1

   ::nRec      += nSkip
   ::nRec      := Max( 0, ::nRec )

   if ::nRecCount <= ::oBrw:nDataRows
      ::nRec   := Min( ::nRec, ::nRecCount - 1 )
   endif

   ::oRs:GoTo( ( ::nRec % ::nRecCount ) + 1 )

return ::nRec - nOldPos

//----------------------------------------------------------------------------//

METHOD BrwScrollDown() CLASS XbrAutoScroll

   if ::nPixel < ::oBrw:nRowHeight
      XBrwScrollRow( ::oBrw:hWnd, 1, ::oBrw:FirstRow(), ::oBrw:nDataRows * ::oBrw:nRowHeight )
      ::nPixel++
   else
      ::nPixel    := 0
      ::oBrw:Skip( 1 )
      ::oBrw:DrawLine( .t. )
   endif

return nil
//----------------------------------------------------------------------------//
 


This sample implements two features that are normally not possible with xbrowse:
1) Smooth scrolling.
2) Scrolling the data in a continuous loop instead of scrolling up and down.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10662
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Informative Screen

Postby Silvio.Falconi » Fri Jan 18, 2019 9:15 am

Rao,
it's possible withour Mysql but with dbf ) ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7076
Joined: Thu Oct 18, 2012 7:17 pm

Re: Informative Screen

Postby nageswaragunupudi » Fri Jan 18, 2019 9:39 am

Silvio.Falconi wrote:Rao,
it's possible withour Mysql but with dbf ) ?

Yes.
I showed the way.
It is now for you to adapt.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10662
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Informative Screen

Postby Adolfo » Fri Jan 18, 2019 2:25 pm

Nages...

Thanks a lot... you are a genius... jaajajajaa

Gonna try it rigth now,

From Chile Adolfo
;-) Ji,ji,ji... buena la cosa... "all you need is code"

http://www.xdata.cl - Desarrollo Inteligente
----------
Asus TUF F15, 32GB Ram, 2 * 1 TB NVME M.2, GTX 1650
User avatar
Adolfo
 
Posts: 860
Joined: Tue Oct 11, 2005 11:57 am
Location: Chile


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 70 guests