Précédent   Forum des professionnels en informatique > Systèmes > Autres systèmes > AS/400
AS/400 Le Forum d'entraide sur IBM AS/400 - iSeries. RPG.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 18/04/2011, 10h59   #1
Nouveau Membre du Club
 
Homme Thomas
Architecte technique
Inscription : septembre 2010
Messages : 39
Détails du profil
Informations personnelles :
Nom : Homme Thomas
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Architecte technique

Informations forums :
Inscription : septembre 2010
Messages : 39
Points : 39
Points : 39
Par défaut [V6R1] - IHM en auto rafraichissement

Bonjour.

Quelqu'un connait-il une façon de faire un programme affichant un écran qui soit en rafraichissement automatique (jusque là, c'est pas trop compliqué, encore qu'il faille un jour l'arrêter), mais qui reste réceptif aux actions du clavier pendant ce temps-là ?

Pour simplifier, c'est le comportement du WRKSYSACT en mode "Automatic Refresh" (F19) que je souhaite reproduire : toutes les x secondes, l'écran se rafraichit, mais pendant cet interval de temps, le clavier n'est pas verrouillé (pas de symbole X d'occupation système) et on peut intervenir pour effectuer une opération, par exemple un F10...

Merci de vos conseils.
pwrdwnsys est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/04/2011, 11h28   #2
Membre éclairé
 
Homme
Inscription : septembre 2008
Messages : 251
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations forums :
Inscription : septembre 2008
Messages : 251
Points : 309
Points : 309
Il suffit de compiler l'écran avec WAITRCD(1).

Dans le programme, tu fais un exfmt normalement.
Tu peux tester dans les infos de l'écran si l'écran est en erreur de timewait ou non. Si oui, tu raffraichis. Si non, l'utilisateur a utilisé la touche Entrée ou une touche de fonction.
FORMULARY est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/04/2011, 19h22   #3
Membre Expert
 
Patrick
Inscription : mai 2008
Messages : 821
Détails du profil
Informations personnelles :
Nom : Patrick
Âge : 42
Localisation : France, Hérault (Languedoc Roussillon)

Informations forums :
Inscription : mai 2008
Messages : 821
Points : 1 041
Points : 1 041
Personnellement j'opterai pour une DTAQ attachée au DSPF.
Exemple glané sur le net :

Code :
1
2
CRTDTAQ DTAQ(SIMPLETEST) MAXLEN(80)
Le DSPF


Code :
1
2
3
                                             CA03(03)    
                 R RECORD                    INVITE      
                                         2 20 TIME
On compile le DSPF avec la DTAQ attachée :

Code :
CRTDSPF FILE(*CURLIB/SIMPLEDSPF) SRCFILE(QDDSSRC) DFRWRT(*NO) DTAQ(*CURLIB/SIMPLETEST)
Le RPG qui lit la DTAQ :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

 fSimpleDSPFcf   e             workstn                                
                                                                      
 dRcvDtaQ          pr                  extpgm('QRCVDTAQ')             
 d DtaQName                      10    const                          
 d DtaQLib                       10    const                          
 d ReceiverLenRtn                 5  0                                
 d Receiver                       1    options(*varsize)              
 d WaitTime                       5  0 const                          
                                                                      
 dMsgSize          s              5  0                                
 dMsg              s             80                                   
 dTimeToWait       s              5  0 inz(10)                        
                                                                      
  /free                                                               
   // Do whatever processing is needed by application for dspf output 
   dow not *in03;                                                     
       write Record;                                                  
       RcvDtaQ('SIMPLETEST' :'VINING' :MsgSize :Msg :TimeToWait);     
       select;                                                        
          when MsgSize = 0;                   // Time out             
               // Do whatever processing is needed by application     
          when %subst(Msg :1 :10) = '*DSPF';  // Input from device    
               read Record;                                           
               // Do whatever processing is needed by application     
          other;                                                      
               // Unexpected input -- and error condition             
       endsl;                                                         
   enddo;                                                             
   *inlr = *on;                                                       
   return;                                                            
  /end-free
K2R400 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/04/2011, 17h52   #4
Nouveau Membre du Club
 
Homme Thomas
Architecte technique
Inscription : septembre 2010
Messages : 39
Détails du profil
Informations personnelles :
Nom : Homme Thomas
Localisation : France, Rhône (Rhône Alpes)

Informations professionnelles :
Activité : Architecte technique

Informations forums :
Inscription : septembre 2010
Messages : 39
Points : 39
Points : 39
Merci pour vos solutions.

J'ai tout testé, et tout fonctionne à merveille. La solution de Patrick à base de *DTAQ est très intéressante, mais il faut absolument qu'une seule instance du programme soit exécutée (et oui, deux programmes écoutant la même *DTAQ, c'est pas terrible...), donc ça ne peut pas être pour un programme utilisé par plusieurs utilisateurs simultanément.

Du coup, pour en faire profiter tout le monde, voici les sources de mes tests.

Ecran simple :

Source du DSPF TBDSPF01D. A compiler en WAITRCD(5) DFRWRT(*NO)
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
     A                                      DSPSIZ(24 80 *DS3)
     A                                      CA03(03)
     A                                      CA05(05)
     A          R FMT1
     A                                      INVITE
     A                                  1 26'Ecran en auto-rafraîchissement'
     A                                      DSPATR(HI)
     A                                  2 34'Format simple'
     A                                      DSPATR(HI)
     A                                  4  2'Cet écran est rafraîchi automatiqu-
     A                                      ement toutes les 5 secondes.'
     A                                      COLOR(BLU)
     A                                  5  2'Il reste cependant sensible aux to-
     A                                      uches de fonction.'
     A                                      COLOR(BLU)
     A                                  7  2'Heure . . . . . . . . . . . . . . -
     A                                      . . . . . . :'
     A                                  7 52TIME
     A                                      DSPATR(HI)
     A                                  8  2'Nombre de raffraîchissements autom-
     A                                      atiques . . :'
     A            COUNT          5Y 0O  8 52DSPATR(HI)
     A                                      EDTCDE(1)
     A                                 23  2'F3=Sortie'
     A                                      COLOR(BLU)
     A                                 23 14'F5=Réafficher'
     A                                      COLOR(BLU)
Source du RPG TBDSPF01R.
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
     ftbdspf01d cf   e             workstn maxdev(*file)

      /free

       // Compteur de raffraîchissements
       count = 0 ;

       // Boucler jusqu'à F3
       dow not *in03 ;

          write(e) fmt1;
          read(e) tbdspf01d ;

          // Déclenchement du rafraîchissement automatique : timeout
          if %status = 1331 ;
             count += 1 ;
          endif;

          // F05 : ré-initialisation du compteur de raffraîchissements
          if *in05 ;
             *in05 = *off ;
             count = 0 ;
          endif ;

       enddo;

       *inlr = *on;
       return ;

      /end-free

Sous-fichier :


Source du DSPF TBDSPF02D. A compiler en WAITRCD(5) DFRWRT(*NO)

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
     A                                      DSPSIZ(24 80 *DS3)
     A                                      INDARA
     A                                      CA03(03)
     A                                      CA05(05)
     A*=========================================================================
     A          R SF01                      SFL
     A                                 11  2'Ligne de sous-fichier numéro'
     A            NBLIG          2Y 0O 11 31EDTCDE(1)
     A*=========================================================================
     A          R CT01                      SFLCTL(SF01)
     A N15                                  PAGEDOWN
     A  11                                  INVITE
     A                                      OVERLAY
     A  13                                  SFLDSP
     A  14                                  SFLDSPCTL
     A  12                                  SFLCLR
     A  15                                  SFLEND(*MORE)
     A                                      SFLSIZ(0012)
     A                                      SFLPAG(0011)
     A            HSFLRCDNBR     4S 0H      SFLRCDNBR(CURSOR)
     A                                  1 26'Ecran en auto-rafraîchissement'
     A                                      DSPATR(HI)
     A                                  2 35'Sous-fichier'
     A                                      DSPATR(HI)
     A                                  4  2'Cet écran est rafraîchi automatiqu-
     A                                      ement toutes les 5 secondes.'
     A                                      COLOR(BLU)
     A                                  5  2'Il reste cependant sensible aux to-
     A                                      uches de fonction.'
     A                                      COLOR(BLU)
     A                                  7  2'Heure . . . . . . . . . . . . . . -
     A                                      . . . . . . :'
     A                                  7 52TIME
     A                                      DSPATR(HI)
     A                                  8  2'Nombre de raffraîchissements autom-
     A                                      atiques . . :'
     A            COUNT          5Y 0O  8 52DSPATR(HI)
     A                                      EDTCDE(1)
     A                                 10  2'Détail'
     A                                      DSPATR(HI)
      *=========================================================================
     A          R BP01
     A                                 23  2'F3=Sortie'
     A                                      COLOR(BLU)
     A                                 23 14'F5=Réafficher'
     A                                      COLOR(BLU)
Source du RPG TBDSPF02R.
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
     ftbdspf02d cf   e             workstn sfile( sf01 : HSFLRCDNBR )
     f                                     indds( Ind )
     f                                     maxdev(*file)

     d TBDSPF02R...
     d                 pr

       // Indicateurs
     d Ind             ds                  qualified
     d  IsF3                           n   overlay( Ind : 3 ) inz( *off )
     d  IsF5                           n   overlay( Ind : 5 ) inz( *off )
     d  invite                         n   overlay( Ind : 11 ) inz( *off )
     d  SflClr                         n   overlay( Ind : 12 ) inz( *off )
     d  SflDsp                         n   overlay( Ind : 13 ) inz( *off )
     d  SflDspCtl                      n   overlay( Ind : 14 ) inz( *off )
     d  SflEnd                         n   overlay( Ind : 15 ) inz( *off )

       //=======================================================================
       // Gestion du sous-fichier
       //=======================================================================

     d TBDSPF02R...
     d                 pi

     d i               s              5u 0 inz( 0 )

      /free

       // Compteur de raffraîchissements
       count = 0 ;
       Ind.IsF5 = *on ;

       // Boucler jusqu'à F3
       dow not Ind.IsF3 ;

          // Initialisation du sous-fichier
          if Ind.IsF5 ;
             Ind.IsF5 = *off ;

             // Vider le sous-fichier
             Ind.Invite = *off ;
             Ind.SflClr = *on ;
             Ind.SflDsp = *off ;
             Ind.SflDspCtl = *off ;
             Ind.SflEnd = *off ;
             HSFLRCDNBR = 0 ;
             write ct01 ;
             Ind.SflClr = *off ;

             // Charger la page de sous-fichier
             for i = 1 to 11 by 1 ;
                clear sf01 ;
                NBLIG = i ;
                HSFLRCDNBR += 1 ;
                write sf01 ;
                Ind.SflDsp = *on ;
             endfor ;
             Ind.SflEnd = *on ;

          endif ;

          // Afficher le sous-fichier
          write bp01 ;
          Ind.Invite = *on ;
          Ind.SflDspCtl = *on ;
          write(e) ct01;
          read(e) tbdspf02d ;

          // Déclenchement du rafraîchissement automatique : timeout
          if %status = 1331 ;
             count += 1 ;
          endif;

          // F05 : ré-initialisation du compteur de raffraîchissements
          if Ind.IsF5 ;
             Ind.IsF5 = *off ;
             count = 0 ;
          endif ;

       enddo;

       *inlr = *on;
Ecran simple avec écoute d'une DTAQ :

Création de la DTAQ TBDSPF03.
Code :
CRTDTAQ DTAQ(*LIBL/TBDSPF03) MAXLEN(80)
Source du DSPF TBDSPF03D. A compiler en DFRWRT(*NO) DTAQ(*LIBL/TBDSPF03)
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
     A                                      DSPSIZ(24 80 *DS3)
     A                                      CA03(03)
     A                                      CA05(05)
     A          R FMT1
     A                                      INVITE
     A                                  1 26'Ecran en auto-rafraîchissement'
     A                                      DSPATR(HI)
     A                                  2 31'Format simple + DTAQ'
     A                                      DSPATR(HI)
     A                                  4  2'Cet écran est rafraîchi automatiqu-
     A                                      ement toutes les 5 secondes ou lors-
     A                                      qu''un'
     A                                      COLOR(BLU)
     A                                  5  2'message arrive dans la DTAQ associ-
     A                                      ée.'
     A                                      COLOR(BLU)
     A                                  6  2'Il reste cependant sensible aux to-
     A                                      uches de fonction.'
     A                                      COLOR(BLU)
     A                                  8  2'Heure . . . . . . . . . . . . . . -
     A                                      . . . . . . :'
     A                                  8 52TIME
     A                                      DSPATR(HI)
     A                                  9  2'Nombre de raffraîchissements autom-
     A                                      atiques . . :'
     A            COUNT          5Y 0O  9 52DSPATR(HI)
     A                                      EDTCDE(1)
     A                                 10  2'Message reçu dans la DTAQ . . . . -
     A                                      . . . . . . :'
     A            MSG           80   B 10 52DSPATR(PR)
     A                                      CNTFLD(028)
     A  99                                  DSPATR(UL)
     A                                      DSPATR(HI)
     A                                 23  2'F3=Sortie'
     A                                      COLOR(BLU)
     A                                 23 14'F5=Réafficher'
     A                                      COLOR(BLU)
Source du RPG TBDSPF03R.
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
     ftbdspf03d cf   e             workstn

     dRcvDtaQ          pr                  extpgm('QRCVDTAQ')
     d DtaQName                      10    const
     d DtaQLib                       10    const
     d ReceiverLenRtn                 5  0
     d Receiver                       1    options(*varsize)
     d WaitTime                       5  0 const

     dMsgSize          s              5  0
     dTimeToWait       s              5  0 inz(5)

      /free

       // Compteur de raffraîchissements
       count = 0 ;

       // Boucler jusqu'à F3
       dow not *in03 ;

          write fmt1 ;
          RcvDtaQ( 'TBDSPF03' : '*LIBL' : MsgSize : Msg : TimeToWait ) ;

          select ;

             // Déclenchement du rafraîchissement automatique : timeout sur l'écoute de la DTAQ
             when MsgSize = 0 ; // Time out
                count += 1 ;

             // Action sur l'écran : envoie un message dans la DTAQ
             when %subst( Msg : 1 : 10) = '*DSPF' ;
                read fmt1 ;

                // F05 : ré-initialisation du compteur de raffraîchissements
                if *in05 ;
                   *in05 = *off ;
                   count = 0 ;
                   msg = ' ' ;
                endif ;

             // Erreur...
             other ;

          endsl ;

       enddo;

       *inlr = *on;
       return ;

      /end-free
Source du RPG TBDSPF04R pour écrire dans la DTAQ.
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
     dSndDtaQ          pr                  extpgm('QSNDDTAQ')
     d DtaQName                      10    const
     d DtaQLib                       10    const
     d DataLen                        5  0
     d Data                          80

     dMsgSize          s              5  0 inz( 80 )
     dMsg              s             80

      /free

       Msg = 'Message envoyé dans la DTAQ à ' + %char( %time( ) ) ;
       SndDtaQ('TBDSPF03' : '*LIBL' : MsgSize : Msg);
       *inlr = *on;
       return ;

      /end-free
Merci encore.
pwrdwnsys est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/04/2011, 18h02   #5
Membre Expert
 
Patrick
Inscription : mai 2008
Messages : 821
Détails du profil
Informations personnelles :
Nom : Patrick
Âge : 42
Localisation : France, Hérault (Languedoc Roussillon)

Informations forums :
Inscription : mai 2008
Messages : 821
Points : 1 041
Points : 1 041
Il est vrai que si deux instances s’exécutent en simultané, l'un sera rafraîchi par la DTAQ pas l'autre (l'entrée étant aspirée). Mais cette technique peut être intéressante dans certains cas.

Pour pousser à l'extrême, il est aussi possible de mettre ta DTAQ dans QTEMP. Quel intérêt ? car aucun autre job ne pourra toucher à la QTEMP d'un autre job. C'est pourtant possible avec STRWCH démarré à l'initialisation des différents jobs en question. Cet outil permet d'appeler un programme à l'entrée d'un message dans une MSGQ (une sorte de trigger).
Ainsi un autre job envoie un message dans une MSGQ, les différents Watch se déclenchent dans l'ensemble des jobs initialisés avec STRWCH (ceux des utilisateurs), les programmes sont appelés dans l'environnement de l'utilisateur. Il peuvent ainsi mettre à jour la QTEMP/DTAQ, ainsi tous les écrans se rafraîchissent en même temps à l'arrivée d'un message dans une MSGQ.


Pour le reste, Excellent travail, merci d'en faire profiter la communauté.
Bravo !!
K2R400 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 04h58.


 
 
 
 
Partenaires

Hébergement Web