Module: ButlerMainframe::GenericFunctions
- Included in:
- HostBase
- Defined in:
- lib/mainframe/customization/generic_functions.rb
Instance Method Summary collapse
-
#abend? ⇒ Boolean
Check if there was a malfunction on the mainframe.
-
#catch_abend ⇒ Object
Get the abend message.
-
#catch_message(options = {}) ⇒ Object
Get the message line usually in the bottom of the screen You can define which rows provide the message: :first_row => 22, :last_row => 23.
-
#catch_title(options = {}) ⇒ Object
Get the title usually the first row You can change default option :rows to get more lines starting from the first.
-
#cics? ⇒ Boolean
Check if we are the first blank cics screen.
-
#cics_selection(ar_cics) ⇒ Object
On this map, we have to select the cics environment param1 cics(array) [text, y, x].
-
#cics_selection? ⇒ Boolean
Check the label to know when we are on the cics selection map.
-
#company_menu(ar_menu) ⇒ Object
On this map, we have to select the cics environment param1 cics usually is a number.
-
#company_menu? ⇒ Boolean
Check the label to know when we are on the cics selection map.
-
#destination_list ⇒ Object
If you add your static screen you must add it in the navigation method to define how to manage it.
- #do_confirm ⇒ Object
- #do_enter ⇒ Object
- #do_erase ⇒ Object
- #do_quit ⇒ Object
- #execute_cics(name) ⇒ Object
- #go_back ⇒ Object
-
#navigate(destination, options = {}) ⇒ Object
Use navigation method to move through the static screens Options: :cics => ButlerMainframe::Settings.cics, :user => ButlerMainframe::Settings.user, :password => ButlerMainframe::Settings.password, :raise_on_abend => false raise an exception if an abend is occured.
- #screen_title(options = {}) ⇒ Object
-
#session_login(ar_user, ar_password) ⇒ Object
Login to mainframe param1 user(array) [text, y, x] param2 password(array) [text, y, x].
-
#session_login? ⇒ Boolean
Check if we are on the login mainframe screen.
Instance Method Details
#abend? ⇒ Boolean
Check if there was a malfunction on the mainframe
211 212 213 |
# File 'lib/mainframe/customization/generic_functions.rb', line 211 def abend? /DFHA/i === catch_abend end |
#catch_abend ⇒ Object
Get the abend message
206 207 208 |
# File 'lib/mainframe/customization/generic_functions.rb', line 206 def catch_abend scan(:y1 => 23, :x1 => 1, :y2 => 23, :x2 => 80) end |
#catch_message(options = {}) ⇒ Object
Get the message line usually in the bottom of the screen You can define which rows provide the message:
:first_row => 22,
:last_row => 23
197 198 199 200 201 202 203 |
# File 'lib/mainframe/customization/generic_functions.rb', line 197 def ={} = { :first_row => 22, :last_row => 23 }.merge() scan(:y1 => [:first_row], :x1 => 1, :y2 => [:last_row], :x2 => 80).gsub(/\s+/, " ").strip end |
#catch_title(options = {}) ⇒ Object
Get the title usually the first row You can change default option :rows to get more lines starting from the first
217 218 219 220 221 222 |
# File 'lib/mainframe/customization/generic_functions.rb', line 217 def catch_title ={} = { :rows => 1 }.merge() scan(:y1 => 1, :x1 => 1, :y2 => [:rows], :x2 => 80) end |
#cics? ⇒ Boolean
Check if we are the first blank cics screen
129 130 131 |
# File 'lib/mainframe/customization/generic_functions.rb', line 129 def cics? scan(:y1 => 1, :x1 => 1, :y2 => 22, :x2 => 80).strip.empty? end |
#cics_selection(ar_cics) ⇒ Object
On this map, we have to select the cics environment param1 cics(array) [text, y, x]
163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/mainframe/customization/generic_functions.rb', line 163 def cics_selection ar_cics puts "Starting selezione_cics..." if @debug cics, y_cics, x_cics = ar_cics raise "Check cics configuration! #{cics} #{y_cics} #{x_cics}" unless cics && y_cics && x_cics wait_session raise "It was waiting cics selezion map instead of: #{catch_title}, message: #{}" unless cics_selection? write cics, :y => y_cics, :x => x_cics do_enter wait_session 1 end |
#cics_selection? ⇒ Boolean
Check the label to know when we are on the cics selection map
157 158 159 |
# File 'lib/mainframe/customization/generic_functions.rb', line 157 def cics_selection? /#{ButlerMainframe::Settings.cics_selection_tag}/i === catch_title end |
#company_menu(ar_menu) ⇒ Object
On this map, we have to select the cics environment param1 cics usually is a number
182 183 184 185 186 187 188 189 190 191 |
# File 'lib/mainframe/customization/generic_functions.rb', line 182 def puts "Starting company menu..." if @debug , , = raise "Check company menu configuration! #{} #{} #{}" unless && && wait_session raise "It was waiting company menu map instead of: #{catch_title}, message: #{}" unless write , :y => , :x => do_enter end |
#company_menu? ⇒ Boolean
Check the label to know when we are on the cics selection map
176 177 178 |
# File 'lib/mainframe/customization/generic_functions.rb', line 176 def /#{ButlerMainframe::Settings.}/i === catch_title end |
#destination_list ⇒ Object
If you add your static screen you must add it in the navigation method to define how to manage it
6 7 8 9 10 11 12 |
# File 'lib/mainframe/customization/generic_functions.rb', line 6 def destination_list [:company_menu, :cics_selection, :session_login, :next, :back] end |
#do_confirm ⇒ Object
237 |
# File 'lib/mainframe/customization/generic_functions.rb', line 237 def do_confirm; exec_command "PF3" end |
#do_enter ⇒ Object
233 |
# File 'lib/mainframe/customization/generic_functions.rb', line 233 def do_enter; exec_command "ENTER" end |
#do_erase ⇒ Object
241 |
# File 'lib/mainframe/customization/generic_functions.rb', line 241 def do_erase; exec_command "ERASE EOF" end |
#do_quit ⇒ Object
239 |
# File 'lib/mainframe/customization/generic_functions.rb', line 239 def do_quit; exec_command "CLEAR" end |
#execute_cics(name) ⇒ Object
228 229 230 231 |
# File 'lib/mainframe/customization/generic_functions.rb', line 228 def execute_cics name write name, :y => 1, :x => 2 do_enter end |
#go_back ⇒ Object
235 |
# File 'lib/mainframe/customization/generic_functions.rb', line 235 def go_back; exec_command "PA2" end |
#navigate(destination, options = {}) ⇒ Object
Use navigation method to move through the static screens Options: :cics => ButlerMainframe::Settings.cics, :user => ButlerMainframe::Settings.user, :password => ButlerMainframe::Settings.password, :raise_on_abend => false raise an exception if an abend is occured
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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/mainframe/customization/generic_functions.rb', line 20 def navigate destination, ={} = { :session_user => ButlerMainframe::Settings.session_user, :session_password => ButlerMainframe::Settings.session_password, :cics => ButlerMainframe::Settings.cics, :company_menu => ButlerMainframe::Settings., :raise_on_abend => false }.merge() max_attempts_number = ButlerMainframe::Settings.max_attempts_number transactions_cics = ButlerMainframe::Settings.transactions_cics raise "Destination #{destination} not valid, please use: #{destination_list.join(', ')}" unless destination_list.include? destination puts "Navigating to #{destination}" if @debug destination_found = nil attempt_number = 0 while !destination_found do attempt_number += 1 if abend? puts "Navigate: abend" if @debug [:raise_on_abend] ? raise(catch_abend) : do_quit elsif puts "Navigating to #{destination} from company menu" if @debug case destination when :cics_selection, :session_login then do_quit when :back then do_quit destination_found = true when :next then [:company_menu] destination_found = true when :company_menu then destination_found = true else # Every other destination is forward [:company_menu] end elsif cics? puts "Navigating to #{destination} from cics" if @debug case destination when :cics_selection, :session_login then execute_cics ButlerMainframe::Settings.logoff_cics when :back then execute_cics ButlerMainframe::Settings.logoff_cics destination_found = true when :next then execute_cics transactions_cics[:main_application] destination_found = true when :company_menu then execute_cics transactions_cics[:company_menu] else #If we are in CICS with blank screen start the first transaction execute_cics transactions_cics[:main_application] end elsif cics_selection? puts "Navigating to #{destination} from cics selection" if @debug case destination when :cics_selection then destination_found = true when :session_login then exec_command("PF3") when :next then cics_selection [:cics] if [:cics] destination_found = true when :back then exec_command("PF3") destination_found = true else cics_selection [:cics] if [:cics] end elsif session_login? puts "Navigating to #{destination} from session login" if @debug case destination when :session_login, :back then destination_found = true when :next then session_login [:session_user], [:session_password] destination_found = true else session_login [:session_user], [:session_password] end else puts "Navigating to #{destination} from unknown screen" if @debug # If we do not know where we are... case destination when :session_login then # ...to come back to the first screen we surely have to go back go_back when :back then # ...we can try to go back (not all the screen may go back in the same way) go_back destination_found = true when :next then # ...but we dont know how to move forward raise "Define how to go forward in the navigation method on generic function module" else # We unlock the position with both commands to be sure that they are managed by all maps cics raise "Destination #{destination} not defined in the current screen" end end break if attempt_number > max_attempts_number wait_session end raise "It was waiting #{destination} map instead of: #{catch_title(:rows => 2).strip}" unless destination_found end |
#screen_title(options = {}) ⇒ Object
223 224 225 226 |
# File 'lib/mainframe/customization/generic_functions.rb', line 223 def screen_title ={} show_deprecated_method 'catch_title' catch_title end |
#session_login(ar_user, ar_password) ⇒ Object
Login to mainframe param1 user(array) [text, y, x] param2 password(array) [text, y, x]
141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/mainframe/customization/generic_functions.rb', line 141 def session_login ar_user, ar_password puts "Starting session login..." if @debug user, y_user, x_user = ar_user raise "Check session user configuration! #{user} #{y_user} #{x_user}" unless user && y_user && x_user password, y_password, x_password = ar_password raise "Check session password configuration! #{password} #{y_password} #{x_password}" unless password && y_password && x_password wait_session #inizializza_sessione raise "It was waiting session login map instead of: #{catch_title}" unless session_login? write user, :y => y_user, :x => x_user write password, :y => y_password, :x => x_password, :sensible_data => true do_enter end |
#session_login? ⇒ Boolean
Check if we are on the login mainframe screen
134 135 136 |
# File 'lib/mainframe/customization/generic_functions.rb', line 134 def session_login? /#{ButlerMainframe::Settings.session_login_tag}/i === catch_title end |