forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How do refresh a simplepot graph with new data?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
johannes



Joined: 21 Jan 2011
Posts: 65
Location: Leimen, Germany

PostPosted: Tue Aug 11, 2015 12:29 pm    Post subject: How do refresh a simplepot graph with new data? Reply with quote

Hi all,
consider we create a x-y line plot with %pl and regularily new x and y values were available. The graph should refresh itself and show the latest data set.

When I code like this (I am not using %gr)

Code:
Do
  sleep@ 5 ! wait for new data
  read ... x,y
  i=winio@(%pl ....)
enddo


I'm getting a new plot aside the old one and the graphics window gets bigger and bigger. For me it would be ok if a new graph is plotted, however it must remain at the initial position. Must I use %gr and if, how?
Back to top
View user's profile Send private message
Kenneth_Smith



Joined: 18 May 2012
Posts: 99
Location: Glasgow, Scotland.

PostPosted: Tue Aug 11, 2015 7:39 pm    Post subject: Reply with quote

This might help.

Code:

    program test
    integer n,winio@,i, j
    parameter(n=50)
    real x(n),y(n)
     
      do j = 1, 3, 1
       do i=1,n
         if (j .eq. 1) then
           x(i)=i-1
           y(i)=x(i)**2
         else if (j .eq. 2) then
           y(i) = sqrt(x(i))
         else
           y(i) = x(i)
         end if
       enddo
       call plot_poly (x,y,n)
     end do
     
     end program test
     
     subroutine plot_poly (x,y,n)
     implicit none
     real,    intent(in), dimension(1:n) :: x
     real,    intent(in), dimension(1:n) :: y
     integer, intent(in) :: n
     real*8,  allocatable::xr8(:)
     real*8,  allocatable::yr8(:)
     integer  i, winio@, alloc_stat

       allocate(xr8(n),stat=alloc_stat)
       if (alloc_stat.gt.0) stop 'failed to allocate xr8 in plot_poly'
       
       allocate(yr8(n),stat=alloc_stat)
       if (alloc_stat.gt.0) stop 'failed to allocate yr8 in plot_poly'

       xr8 = x
       yr8 = y
     
       i=winio@('%ca[simpleplot]%bg[grey]&')
       i=winio@('%pl[x_array,colour=blue,title="plot",x_axis=r,y_axis=x],&', 500,300,n,xr8,yr8)
       i=winio@('%ff%nl%cn%tt[ok]')

       deallocate(xr8,yr8)

     end subroutine plot_poly

Back to top
View user's profile Send private message Visit poster's website
johannes



Joined: 21 Jan 2011
Posts: 65
Location: Leimen, Germany

PostPosted: Fri Aug 14, 2015 10:13 am    Post subject: Reply with quote

Hi Kenneth,
thanks for the code, but it didn't hit my question exactly:
I do not want to press [ok] to see the next graphs. They should appear automatically as long there are new data.
regards,
johannes
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 1647
Location: Yateley, Hants, UK

PostPosted: Fri Aug 14, 2015 10:24 am    Post subject: Reply with quote

Hi Johannes,

Then set a flag to say if there is new data, and put a timer on the window with %dl, and if there is new data waiting to be plotted, (which the callback to the timer can find from the flag) then replot everything. Don't forget to unset the flag after plotting!

If you have a short enough interval, it will appear to be instant update.

Eddie
Back to top
View user's profile Send private message
johannes



Joined: 21 Jan 2011
Posts: 65
Location: Leimen, Germany

PostPosted: Fri Aug 14, 2015 4:04 pm    Post subject: Reply with quote

post deleted

Last edited by johannes on Fri Aug 14, 2015 7:15 pm; edited 1 time in total
Back to top
View user's profile Send private message
johannes



Joined: 21 Jan 2011
Posts: 65
Location: Leimen, Germany

PostPosted: Fri Aug 14, 2015 5:17 pm    Post subject: Reply with quote

This code is doing, but I don't know how to stop properly if finish==1
Code:
Module data
     integer,parameter :: n=10
     real*8 ::  x(n)=0., y(n)=0.
     integer :: i, winio@, newdataflag,icall,finish
end Module

program test
 USE data
 external lookup
 icall=1 ; finish=0
    i=winio@('%dl', 0.1d0, lookup)
    !HOW TO EXIT IF finish==1?
   !- call plot_poly () 
end program test
     
subroutine plot_poly ()
 USE data
 i=winio@('%pl[x_array,colour=blue,title="plot",x_axis=r,y_axis=x]', 500,300,n,x,y)
end subroutine plot_poly
     
integer function lookup()
 USE data    ! alternatively read data from file
 icall=icall+1
 finish=0
 do i=1,icall         
   if (icall>n) then
     finish=1
     RETURN
   endif   
   x(i)=i-1     
   y(i) = sqrt(x(i))
 enddo
  i=winio@('%pl[x_array,colour=blue,title="plot",x_axis=r,y_axis=x]', 500,300,n,x,y)

return
end
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 1647
Location: Yateley, Hants, UK

PostPosted: Fri Aug 14, 2015 6:09 pm    Post subject: Reply with quote

Johannes,

That depends what you mean by 'stop properly'. I've just upgraded this laptop to Windows 10 from 8.1, and your program gives me an odd message 'Simpleplot: incompatible device driver' so to have a proper look I'll have to wait until I'm in the office again.

It may mean that Windows 10 sounds the end of Simpleplot :(

Eddie
Back to top
View user's profile Send private message
johannes



Joined: 21 Jan 2011
Posts: 65
Location: Leimen, Germany

PostPosted: Fri Aug 14, 2015 7:31 pm    Post subject: Reply with quote

1. After I submitted the post I realized that I had to say what I mean by 'stop': at any time I want to be able to close the window and to abort the updating process.
I tried to add some more statements, which at the end shows a [Close] button very shortly, but no graphat all, unfortunately:
Code:
Module data
     integer,parameter :: n=10
     real*8 ::  x(n)=0., y(n)=0.
     integer :: i, winio@, newdataflag,icall,finish
end Module

program test
 USE data
 external lookup,abbruch
 icall=1 ; finish=0
    i=winio@('%dl&', 0.1d0, lookup)
    !HOW TO STOP IF finish=01?
       i=winio@('%^tt[Close]',abort)
end program test

     
integer function lookup()
 USE data    ! alternatively read data from file
 icall=icall+1
 finish=0
 do i=1,icall         
   if (icall>n) then
     finish=1
     RETURN
   endif   
   x(i)=i-1     
   y(i) = sqrt(x(i))
 enddo
  i=winio@('%pl[x_array,colour=blue,title="plot",x_axis=r,y_axis=x]&', 500,300,n,x,y)

return
end

integer function abort()
return
end[quote][/quote]

2. Another lack of my posted code from 5:17pm is, that it created 10 independent windows one over the other, which have to be closed one by one manually. That invalidates this solution.
3. Compatibility with Win10 is a good point. Is your Windows10 problem a Simpleplot problem or a general Clearwin problem? Is FTN prepared for Windows10?
johannes
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 1647
Location: Yateley, Hants, UK

PostPosted: Sat Aug 15, 2015 3:20 pm    Post subject: Reply with quote

Hi Johannes,

Couple of things. Firstly I think what you are looking for to get the plots redrawn in the same space is CALL SIMPLEPLOT_REDRAW@.

I'm getting in a tangle with simpleplot (which I don't use) but will post the demonstrator when I've done it.

As far as Win 10 is concerned, my small laptop came with Windows 8.1. I don't like all that much, so I thought that I'd let it update to Windows 10. It is certainly nastier in the visual department as Windows have no frames, there was that glitch with simpleplot, and Edge, the replacement for Internet Explorer is so different as to be (as yet) unusable by me. Caption bars are not differentiated from menu bars by colour or anything. I may scrub the lot and revert to my small Windows 7 laptop or install Windows 7 on the new one.

Eddie
Back to top
View user's profile Send private message
johannes



Joined: 21 Jan 2011
Posts: 65
Location: Leimen, Germany

PostPosted: Sat Aug 15, 2015 5:43 pm    Post subject: Reply with quote

Hi Eddie,
of course I don't know where to precisely place simpleplot_redraw@ but any compliation gives:

WARNING the following symbols are missing:
SIMPLEPLOT_REDRAW#

Did I forget to link a special library?

johannes
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 1647
Location: Yateley, Hants, UK

PostPosted: Sun Aug 16, 2015 10:36 am    Post subject: Reply with quote

Hi Johannes,

Simpleplot defeats me, and I gave up yesterday. I am an old dog and use Fortran 77 tricks, not all the new stuff, so I get access to Clearwin+ tricks with

Code:
INCLUDE <WINDOWS.INS>


This goes in every routine that uses any windows or clearwin subprograms. If you use USE then the modules are given in the include folder of Silverfrost/FTN95

The CALL SIMPLEPLOT_REDRAW@ goes immediately after you have changed x and y, and want to update the plot. It's a bit like perform_graphics_update@.

Eddie
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 1647
Location: Yateley, Hants, UK

PostPosted: Sun Aug 16, 2015 11:18 am    Post subject: Reply with quote

And then again, Johannes, maybe it doesn't! Apologies for this scruffy program, but it illustrates SIMPLEPLOT_REDRAW:
Code:

      WINAPP
      OPTIONS (INTL)

      program test
      IMPLICIT DOUBLE PRECISION(A-H, O-Z)
      INCLUDE <WINDOWS.INS>
      COMMON /VALUES/ X(10), Y(10)
      COMMON /COUNT/  N,     IA,    M
      COMMON /REPEAT/ Keep_code(3), New_data_ready
      INTEGER, EXTERNAL :: PLOT_FN, REDRAW_FN
      N = 10;   M = 1
      DO 10 I=1, 10
      x(i)=i-1     
      y(i)=x(i) ** 2 + M * x(I) - M
      write(*,*) x(i), y(i)
  10  CONTINUE
      I=WINIO@('%ca[Main window]%lw&', Keep_code(1))
      i=winio@('%dl&', 5.0d0, REDRAW_FN)
      I=WINIO@('%sc&', PLOT_FN)
      I=WINIO@('%fr', 600, 400) ! positioning
      end program test

       
      integer function PLOT_FN()
      IMPLICIT DOUBLE PRECISION(A-H, O-Z)
      INCLUDE <WINDOWS.INS>
      COMMON /VALUES/ X(10), Y(10)
      COMMON /COUNT/  N,     IA,    M
      COMMON /REPEAT/ Keep_code(3), New_data_ready

      IA=WINIO@('%aw&', Keep_code(1))
      iA=winio@('%pl[x_array,colour=blue,title="plot",
     &          x_axis=r,y_axis=x]', 500, 300, n, x, y)
      PLOT_FN = 1
      RETURN
      END


      INTEGER FUNCTION REDRAW_FN ()
      IMPLICIT DOUBLE PRECISION(A-H, O-Z)
      INCLUDE <WINDOWS.INS>
      COMMON /VALUES/ X(10), Y(10)
      COMMON /COUNT/  N,     IA,    M
      COMMON /REPEAT/ Keep_code(3), New_data_ready
      DO 10 I=1, 10
      x(i)=i-1     
      y(i)=x(i) ** 2 + M * x(I) - M
      write(*,*) x(i), y(i)
  10  CONTINUE
      M = M+1
      CALL SIMPLEPLOT_REDRAW@
      REDRAW_FN = 1
      IF (M .EQ. 11) REDRAW_FN = 0
      RETURN
      END


(I didn't use Keep_code 2 or 3, or New_data_ready). I put the plot in a child window, but the timer is in the main window.

Eddie
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 1522
Location: South Pole, Antarctica

PostPosted: Mon Aug 17, 2015 1:58 am    Post subject: Reply with quote

Eddie,
The Simpleplot Win10 incompatibility is a bad news, i was trying to update to Windows 10 too but some bug stopped me. I hope Silverfrost will fix that but may be we can temporally fix themselves too: can you make the EXE file compatible with Windows 8.1 changing its Properties ?

Right click on EXE file, chose Properties/Compatibility / select radiobutton "Run this program in compatibility mode" and chose older Windows version

As to autoupdate here is one more trick to consider. I use FILES@ for that which we discussed here last month in the thread in "General" called "Attributes of file". The code permanently scans for the data file (which contains your plotting data) attributes change with 0.1 second interval and as soon as it finds date/time stamps changed it reads this file and plots the data. Also John Campbell made the code (also in this thread) where all the DOS attributes are decrypted in human-readable format.
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 1647
Location: Yateley, Hants, UK

PostPosted: Mon Aug 17, 2015 9:28 am    Post subject: Reply with quote

Dan,

The next two days I got really big 'updates' and I haven't tried it since on this little laptop. I will when time permits. For example Cortana didn't run on day 1, but did on day 2, and better on day 3!

Meanwhile, I used my desktop computer (Win 7) to demo how SIMPLEPLOT_REDRAW@ works for Johannes. That idea of using the datestamp is great - I was thinking of a independently running plot program and another that creates the data. The date and time stamp is the flag that data has changed.
Back to top
View user's profile Send private message
LitusSaxonicum



Joined: 23 Aug 2005
Posts: 1647
Location: Yateley, Hants, UK

PostPosted: Mon Aug 17, 2015 10:35 am    Post subject: Reply with quote

Dan,

Good news so far: now my program above works on Win 10 without that 'device driver' bit. I was expecting some issues at first.

Eddie
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group