Class: TE3270::Emulators::Extra
- Inherits:
-
Object
- Object
- TE3270::Emulators::Extra
- Defined in:
- lib/te3270/emulators/extra.rb
Overview
This class has the code necessary to communicate with the terminal emulator called EXTRA! X-treme. You can use this emulator by providing the :extra
parameter to the constructor of your screen object or by passing the same value to the emulator_for
method on the TE3270
module.
Instance Attribute Summary collapse
-
#max_wait_time ⇒ Object
writeonly
Sets the attribute max_wait_time.
-
#session_file ⇒ Object
writeonly
Sets the attribute session_file.
-
#visible ⇒ Object
writeonly
Sets the attribute visible.
-
#window_state ⇒ Object
writeonly
Sets the attribute window_state.
Instance Method Summary collapse
-
#connect {|_self| ... } ⇒ Object
Creates a method to connect to Extra System.
-
#disconnect ⇒ Object
Disconnects the Extra System connection.
-
#get_string(row, column, length) ⇒ String
Extracts text of specified length from a start point.
-
#initialize ⇒ Extra
constructor
A new instance of Extra.
-
#put_string(str, row, column) ⇒ Object
Puts string at the coordinates specified.
-
#recv_Host_File(filePath, fileHost, showHostDialog_Passed) ⇒ Object
Receive File Method: Support for Text TSO Downloads only.
-
#screenshot(filename) ⇒ Object
Creates a method to take screenshot of the active screen.
-
#send_Host_File(filePath, fileHost, showHostDialog_Passed) ⇒ Object
Send File Method: Support for Text TSO uploads only.
-
#send_keys(keys) ⇒ Object
Sends keystrokes to the host, including function keys.
-
#set_Show_Host_Dialog(showHostDialog_Received) ⇒ Object
Set Dialog True or False.
-
#text ⇒ String
Returns the text of the active screen.
-
#wait_for_host(seconds) ⇒ Object
Waits for the host to not send data for a specified number of seconds.
-
#wait_for_string(str, row, column) ⇒ Object
Wait for the string to appear at the specified location.
-
#wait_until_cursor_at(row, column) ⇒ Object
Waits until the cursor is at the specified location.
Constructor Details
#initialize ⇒ Extra
Returns a new instance of Extra.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/te3270/emulators/extra.rb', line 13 def initialize if jruby? require 'jruby-win32ole' require 'java' include_class 'java.awt.Dimension' include_class 'java.awt.Rectangle' include_class 'java.awt.Robot' include_class 'java.awt.Toolkit' include_class 'java.awt.event.InputEvent' include_class 'java.awt.image.BufferedImage' include_class 'javax.imageio.ImageIO' else require 'win32ole' require 'win32/screenshot' end end |
Instance Attribute Details
#max_wait_time=(value) ⇒ Object
Sets the attribute max_wait_time
10 11 12 |
# File 'lib/te3270/emulators/extra.rb', line 10 def max_wait_time=(value) @max_wait_time = value end |
#session_file=(value) ⇒ Object (writeonly)
Sets the attribute session_file
10 11 12 |
# File 'lib/te3270/emulators/extra.rb', line 10 def session_file=(value) @session_file = value end |
#visible=(value) ⇒ Object
Sets the attribute visible
10 11 12 |
# File 'lib/te3270/emulators/extra.rb', line 10 def visible=(value) @visible = value end |
#window_state=(value) ⇒ Object
Sets the attribute window_state
10 11 12 |
# File 'lib/te3270/emulators/extra.rb', line 10 def window_state=(value) @window_state = value end |
Instance Method Details
#connect {|_self| ... } ⇒ Object
Creates a method to connect to Extra System. This method expects a block in which certain platform specific values can be set. Extra can take the following parameters.
-
session_file - this value is required and should be the filename of the session.
-
visible - determines if the emulator is visible or not. If not set it will default to
true
. -
window_state - determines the state of the session window. Valid values are
:minimized
,:normal
, and:maximized
. If not set it will default to:normal
.
47 48 49 50 51 52 53 54 55 |
# File 'lib/te3270/emulators/extra.rb', line 47 def connect start_extra_system yield self if block_given? raise 'The session file must be set in a block when calling connect with the Extra emulator.' if @session_file.nil? open_session @screen = session.Screen @area = screen.SelectAll end |
#disconnect ⇒ Object
Disconnects the Extra System connection
60 61 62 |
# File 'lib/te3270/emulators/extra.rb', line 60 def disconnect session.Close end |
#get_string(row, column, length) ⇒ String
Extracts text of specified length from a start point.
72 73 74 |
# File 'lib/te3270/emulators/extra.rb', line 72 def get_string(row, column, length) screen.GetString(row, column, length) end |
#put_string(str, row, column) ⇒ Object
Puts string at the coordinates specified.
83 84 85 86 |
# File 'lib/te3270/emulators/extra.rb', line 83 def put_string(str, row, column) screen.PutString(str, row, column) quiet_period end |
#recv_Host_File(filePath, fileHost, showHostDialog_Passed) ⇒ Object
Receive File Method: Support for Text TSO Downloads only
170 171 172 173 174 175 176 |
# File 'lib/te3270/emulators/extra.rb', line 170 def recv_Host_File(filePath, fileHost, showHostDialog_Passed) create_Show_Dialog = set_Show_Host_Dialog(showHostDialog_Passed) session.FileTransferScheme = "Text Default" session.FileTransferHostOS = 1 # For TSO transfer Default session.ReceiveFile(filePath, fileHost, create_Show_Dialog) quiet_period end |
#screenshot(filename) ⇒ Object
Creates a method to take screenshot of the active screen. If you have set the :visible
property to false it will be made visible prior to taking the screenshot and then changed to invisible after.
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/te3270/emulators/extra.rb', line 186 def screenshot(filename) File.delete(filename) if File.exists?(filename) session.Visible = true unless visible if jruby? toolkit = Toolkit::getDefaultToolkit() screen_size = toolkit.getScreenSize() rect = Rectangle.new(screen_size) robot = Robot.new image = robot.createScreenCapture(rect) f = java::io::File.new(filename) ImageIO::write(image, "png", f) else hwnd = session.WindowHandle Win32::Screenshot::Take.of(:window, hwnd: hwnd).write(filename) end session.Visible = false unless visible end |
#send_Host_File(filePath, fileHost, showHostDialog_Passed) ⇒ Object
Send File Method: Support for Text TSO uploads only
155 156 157 158 159 160 161 |
# File 'lib/te3270/emulators/extra.rb', line 155 def send_Host_File(filePath, fileHost, showHostDialog_Passed) create_Show_Dialog = set_Show_Host_Dialog(showHostDialog_Passed) session.FileTransferScheme = "Text Default" session.FileTransferHostOS = 1 # For TSO transfer Default session.SendFile(filePath, fileHost, create_Show_Dialog) quiet_period end |
#send_keys(keys) ⇒ Object
Sends keystrokes to the host, including function keys.
93 94 95 96 |
# File 'lib/te3270/emulators/extra.rb', line 93 def send_keys(keys) screen.SendKeys(keys) quiet_period end |
#set_Show_Host_Dialog(showHostDialog_Received) ⇒ Object
Set Dialog True or False
138 139 140 141 142 143 144 145 146 147 |
# File 'lib/te3270/emulators/extra.rb', line 138 def set_Show_Host_Dialog(showHostDialog_Received) begin if showHostDialog_Received != true return false end return true rescue return false end end |
#text ⇒ String
Returns the text of the active screen
211 212 213 |
# File 'lib/te3270/emulators/extra.rb', line 211 def text area.Value end |
#wait_for_host(seconds) ⇒ Object
Waits for the host to not send data for a specified number of seconds
116 117 118 119 120 |
# File 'lib/te3270/emulators/extra.rb', line 116 def wait_for_host(seconds) wait_for(seconds) do screen.WaitHostQuiet end end |
#wait_for_string(str, row, column) ⇒ Object
Wait for the string to appear at the specified location
105 106 107 108 109 |
# File 'lib/te3270/emulators/extra.rb', line 105 def wait_for_string(str, row, column) wait_for do screen.WaitForString(str, row, column) end end |
#wait_until_cursor_at(row, column) ⇒ Object
Waits until the cursor is at the specified location.
128 129 130 131 132 |
# File 'lib/te3270/emulators/extra.rb', line 128 def wait_until_cursor_at(row, column) wait_for do screen.WaitForCursor(row, column) end end |