<%@ language="RPGLE" pgmtype="webservice" %>
<% 
/* ---------------------------------------------------------------------------------------- */
/* Copyright [2009] [System & Method Technologies]                                          */
/*                                                                                          */
/* Licensed under the Apache License, Version 2.0 (the "License");                          */
/* you may not use this file except in compliance with the License.                         */
/* You may obtain a copy of the License at                                                  */
/*                                                                                          */
/*     http://www.apache.org/licenses/LICENSE-2.0                                           */
/*                                                                                          */
/* Unless required by applicable law or agreed to in writing, software                      */
/* distributed under the License is distributed on an "AS IS" BASIS,                        */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.                 */
/* See the License for the specific language governing permissions and                      */
/* limitations under the License.                                                           */
/* ---------------------------------------------------------------------------------------- */
/*                                                                                          */
/* Project . . . : IceBreak                                                                 */
/* Design  . . . : Niels Liisberg                                                           */
/* Function  . . : Websservice using the Icecap Virtual Terminal                            */
/*                                                                                          */
/* By       Date       Task    Description                                                  */
/* -------- ---------- ------- ------------------------------------------------------------ */
/* NLI      11.01.2008 0000671 New program - Subproject IceCap                              */
/* ---------------------------------------------------------------------------------------- */
h nomain     
H bnddir('ICECAP')
/include qasphdr,iceCap
d pVts            s               *   inz(*null)
d vtSessoin       ds                  likeds(vtsDS) based(pVts)                                
d vtField         ds                  likeds(vtFieldDS)

//' ----------------------------------------------------------------------------------------
//' getSysSts - Get System Status webservice method
//' ----------------------------------------------------------------------------------------
p*name++++++++++..b...................keywords++++++++++++++++++++++++++comments++++++++++++ 
p getSysSts       B                   export 
 
d getSysSts       pi
d    cpuUsed                     5  2 output        
d    sysAspSize                  7  2 Output
d    sysAspUsed                  9  4 Output 
 
d panelFound      s               n
d decp            s              1    inz(',') 
//' ----------------------------------------------------------------------------------------
/free


  //' Open IceCap Virtual Terminal Session if not open yet. 
  if (pVts = *null); 
     pVts = vtOpen(); 
  endif;

  //' Locate the "Work with System Status" panel
  PanelFound = *OFF;
  dou (PanelFound); 
    select;
      //' logon if the signon is displayed
      when vtSaaTitleContains(pVts:'Sign On');  
        vtSetFieldNo(pVts: 1 : 'DEMO');    // First field is the userprofile
        vtSetFieldNo(pVts: 2 : 'DEMO');    // Second field is the password
        vtSetFieldNo(pVts: 3 : 'QCMD');    // Program to run - QCMD
        vtPressKey(pVts: vtENTER);
      
      when vtSaaTitleContains(pVts:'Display Program Messages');  
        vtPressKey(pVts: vtENTER);
      
      //' run wrksyssts if command entry is displayed        
      when vtSaaTitleContains(pVts:'Command Entry');  
        vtSetFieldNo(pVts: 1 : 'wrksyssts'); 
        vtPressKey(pVts: vtENTER);
        
      //' Refresh statistics in the system status is displayed
      when vtSaaTitleContains(pVts:'Work with System Status');
        vtPressKey(pVts: vtF10);
        PanelFound = *ON;

      other;
        // !! TODO - invalid screen
        return; 
    endsl;     
  enddo;

	
	
  //' Got the panel - peek the return fields for the webservice
  cpuUsed     =   num(vtGetScreen(pVts: 3: 29 : 10 ): decp); // session/line/column/len
  sysAspSize  =   num(vtGetScreen(pVts: 4: 70 :  8 ): decp); // session/line/column/len
  sysAspUsed  =   num(vtGetScreen(pVts: 5: 70 : 10 ): decp); // session/line/column/len
	
	return; 
  
/end-free   
p getSysSts       e
%>