Silverfrost Forums

Welcome to our forums

Ideas for \"Work in Progress\" indicator ?

5 Nov 2014 3:49 #14984

Any suggestions for good looking, small and simple indicator of 'Run in Progress' ('Load in Progress' etc) ? If amount of runs/tries/lines is known i usually use slider %sl but if the volume of work/load is unknown then this is not good method. Something periodically blinking, moving, rotating...

5 Nov 2014 7:36 #14985

Have you looked at %br?

5 Nov 2014 4:07 (Edited: 6 Nov 2014 3:14) #14988

Oops, i meant i used not %sl but %br. But it looks not exactly how i'd want the sign telling that the program is running/loading has to be displayed. It has to be something like this

http://s25.postimg.org/q34y4bpjj/Loading.png

or something blinking on/off

BTW, i have a freeze after few seconds with this program when use CALL SLEEP1@. If i do not use it or use SLEEP@ (which unfortunately grabs 100% CPU time when sleeps) the program works fine

INCLUDE <windows.ins>
real*8 fill

ii=winio@('%ww%5br&', fill, RGB@(200,50,0))
!ii=winio@('%ww%5br[bottom_top]&', fill, RGB@(200,50,0))
ii=winio@('%ac[esc]&', '+', 'set', istop, 1, 'exit')
ii=winio@('%lw', ilw)

istop = 0
do i=1,2000000
if(istop.eq.1) exit 
call sleep1@(0.1)
fill = abs(sin(i/5.))
call window_update@(fill)
enddo
end
5 Nov 2014 6:51 #14991

Quoted from DanRRight

BTW, i have program freeze after few seconds with this program when use CALL SLEEP1@. If i do not use it or use SLEEP@ (which unfortunately grabs 100% CPU time when sleeps) the program works fine

I would use separate threads to do the actual work and to update the progress. Using a thread pool it's really easy. Below is an example using my thread pool wrapper functions. You can get the project files from here. Package includes a simple total cpu usage monitor.

module Test
  implicit none
  include <windows.ins>

  ! Thread pool wrapper functions in tp.dll
  STDCALL TPEnvNew 'TPEnvNew' ():INTEGER*4
  STDCALL TPEnvDelete 'TPEnvDelete' (VAL)
  STDCALL TPCreate 'TPCreate' ():INTEGER*4
  STDCALL TPSet 'TPSet' (VAL, VAL)
  STDCALL TPClose 'TPClose' (VAL)
  STDCALL TPCreateWork 'TPCreateWork' (VAL, REF, VAL):INTEGER*4
  STDCALL TPCloseWork 'TPCloseWork' (VAL)
  STDCALL TPSubmitwork 'TPSubmitwork' (VAL)
  STDCALL TPCreateCleanupGroup 'TPCreateCleanupGroup' ():INTEGER*4
  STDCALL TPCloseCleanupGroup 'TPCloseCleanupGroup' (VAL)
  STDCALL TPSetCleanupGroup 'TPSetCleanupGroup' (VAL, VAL, VAL)
  STDCALL TPCloseCleanupGroupMembers 'TPCloseCleanupGroupMembers' (VAL, VAL, VAL)
  STDCALL TPWaitForWorkCallbacks 'TPWaitForWorkCallbacks' (VAL, VAL)
  STDCALL TPSetThreadMax 'TPSetThreadMax' (VAL, VAL)
  STDCALL TPSetThreadMin 'TPSetThreadMin' (VAL, VAL)

  integer :: work
  logical :: done = .FALSE.

   real*8 :: fill 


  contains

    subroutine updating(instance, context, work)
      integer :: instance, context, work
      
      integer :: i

      i = 1
      do while(.NOT. done)
        fill = abs(sin(i/5.)) 
        call window_update@(fill)
        i = i + 1
        if (i > 200) i = 1
        call sleep(500)  
      end do 

    end subroutine updating
                 

    integer function cc_func()
      done = .TRUE.
      call TPWaitForWorkCallbacks(work, 0)
      call TPCloseWork(work)
      cc_func=0
    end function cc_func


end module Test


winapp
  use Test
  implicit none

  integer :: ii, ilw

  ii=winio@('%ww%5br&', fill, RGB@(200,50,0))
  ii=winio@('%`cc&',cc_func) 
  ii=winio@('%lw', ilw)
  
  work = TPCreateWork(updating, 0, 0)
  call TPSubmitwork(work)
end
6 Nov 2014 3:20 #14993

Does my code also freezes in your computer/OS/environment?

I have very little time right now for any experimenting, while your approach is huge jump aside...Let it lies in backbrain, may be some time we will return to it. You too think where it will shine the most. I'd probably only spend some time on parallelization on multi-core CPUs including massive parallel coprocessors, parallelization on GPUs, 64bit compilers and as a little hobby gaming on OpenGL+Fortran. That is our future, so many are probably interested too. Could be potentially interesting some latest advanced SDK allowing mouse click-based GUI programming for cellphones and tablets ideally also with some Fortran adopted for that. Anything else has to wait for better times...

6 Nov 2014 8:01 #14994

Dan, for your 'animated wait' first find an animated GIF (or create one by ourself). Let's say we call this test_1.gif. This must be in a ressource script:

test_1  GIF  test_1.gif

Then you can do something like this:

      WINAPP 'test_1'
      PROGRAM TEST_1

      integer*4      play,ctrl,j
      common   /my_gif/   ctrl

      j = play()
      do j = 1,2500
        print*,j,sqrt(dble(j))
      end do
      ctrl = 0
      call window_update@(ctrl)
      end

      integer function play()

      integer*4      ctrl
      common   /my_gif/   ctrl

      play = winio@('%ww[naked,topmost]%lw%gi[test_1]',ctrl)
      end

With play() you start your animation, with ctrl=0 and window_update@(ctrl) you stop it.

Good luck - Wilfried

7 Nov 2014 4:21 #14996

Good idea, thanks, Wilfried

But is it possible to make some on/off animation tricks with existing images in the RESOURCES like graying and ungraying them? Or similar things with standard CWP graphics resources like %si!, %si# etc ?

Please login to reply.