module KrakenMobile::Protocol::FileProtocol
Public Instance Methods
build_scenario_id(scenario)
click to toggle source
helpers
# File lib/kraken-mobile/protocols/file_protocol.rb, line 87 def build_scenario_id scenario location = scenario.location.to_s index_of_line_number_start = location.index(":") real_location = location[0..index_of_line_number_start-1] Digest::SHA256.hexdigest(real_location) end
devices_ready_start(devices_manager, scenario_id)
click to toggle source
# File lib/kraken-mobile/protocols/file_protocol.rb, line 117 def devices_ready_start devices_manager, scenario_id devices_manager.connected_devices.select { |device| devices_manager.device_helper.read_file_content(KrakenMobile::Constants::KRAKEN_CONFIGURATION_FILE_NAME, device.id) == "ready_#{scenario_id}" } end
devices_ready_to_finish(devices_manager, scenario_id)
click to toggle source
# File lib/kraken-mobile/protocols/file_protocol.rb, line 121 def devices_ready_to_finish devices_manager, scenario_id devices_manager.connected_devices.select { |device| devices_manager.device_helper.read_file_content(KrakenMobile::Constants::KRAKEN_CONFIGURATION_FILE_NAME, device.id) == "end_#{scenario_id}" } end
end_setup(channel, scenario)
click to toggle source
# File lib/kraken-mobile/protocols/file_protocol.rb, line 73 def end_setup channel, scenario devices_manager = DevicesHelper::Manager.new({runner: ENV["RUNNER"], config_path: ENV["CONFIG_PATH"]}) device_id = channel_to_device_id(channel) scenario_id = build_scenario_id(scenario) devices_manager.device_helper.write_content_to_file "end_#{scenario_id}", KrakenMobile::Constants::KRAKEN_CONFIGURATION_FILE_NAME, device_id ordered_tags = ordered_feature_tags scenario while true compare_criteria = devices_manager.connected_devices.count >= ordered_tags.count ? ordered_tags.count : devices_manager.connected_devices.count break if devices_ready_to_finish(devices_manager, scenario_id).count >= compare_criteria sleep(1) end end
readAnySignal(channel, timeout)
click to toggle source
# File lib/kraken-mobile/protocols/file_protocol.rb, line 23 def readAnySignal(channel, timeout) devices_helper = DevicesHelper::Manager.new({runner: ENV["RUNNER"], config_path: ENV["CONFIG_PATH"]}).device_helper device_id = channel_to_device_id(channel) Timeout::timeout(timeout, RuntimeError) do sleep(1) until devices_helper.read_file_content(KrakenMobile::Constants::DEVICE_INBOX_NAME, device_id) != "" end end
readLastSignal(channel)
click to toggle source
# File lib/kraken-mobile/protocols/file_protocol.rb, line 17 def readLastSignal(channel) devices_helper = DevicesHelper::Manager.new({runner: ENV["RUNNER"], config_path: ENV["CONFIG_PATH"]}).device_helper device_id = channel_to_device_id(channel) devices_helper.read_file_content(KrakenMobile::Constants::DEVICE_INBOX_NAME, device_id) end
readSignal(channel, content, timeout)
click to toggle source
# File lib/kraken-mobile/protocols/file_protocol.rb, line 9 def readSignal(channel, content, timeout) devices_helper = DevicesHelper::Manager.new({runner: ENV["RUNNER"], config_path: ENV["CONFIG_PATH"]}).device_helper device_id = channel_to_device_id(channel) Timeout::timeout(timeout, RuntimeError) do sleep(1) until devices_helper.read_file_content(KrakenMobile::Constants::DEVICE_INBOX_NAME, device_id) == content end end
readSignalWithKeyworkd(channel, keyword, timeout)
click to toggle source
# File lib/kraken-mobile/protocols/file_protocol.rb, line 31 def readSignalWithKeyworkd(channel, keyword, timeout) devices_helper = DevicesHelper::Manager.new({runner: ENV["RUNNER"], config_path: ENV["CONFIG_PATH"]}).device_helper device_id = channel_to_device_id(channel) Timeout::timeout(timeout, RuntimeError) do sleep(1) until devices_helper.read_file_content(KrakenMobile::Constants::DEVICE_INBOX_NAME, device_id).include?(keyword) return devices_helper.read_file_content(KrakenMobile::Constants::DEVICE_INBOX_NAME, device_id) end end
start_setup(channel, scenario)
click to toggle source
# File lib/kraken-mobile/protocols/file_protocol.rb, line 60 def start_setup channel, scenario devices_manager = DevicesHelper::Manager.new({runner: ENV["RUNNER"], config_path: ENV["CONFIG_PATH"]}) device_id = channel_to_device_id(channel) scenario_id = build_scenario_id(scenario) devices_manager.device_helper.write_content_to_file "ready_#{scenario_id}", KrakenMobile::Constants::KRAKEN_CONFIGURATION_FILE_NAME, device_id ordered_tags = ordered_feature_tags scenario while true compare_criteria = devices_manager.connected_devices.count >= ordered_tags.count ? ordered_tags.count : devices_manager.connected_devices.count break if devices_ready_start(devices_manager, scenario_id).count >= compare_criteria sleep(1) end end
writeSignal(channel, content)
click to toggle source
# File lib/kraken-mobile/protocols/file_protocol.rb, line 40 def writeSignal(channel, content) devices_helper = DevicesHelper::Manager.new({runner: ENV["RUNNER"], config_path: ENV["CONFIG_PATH"]}).device_helper device_id = channel_to_device_id(channel) devices_helper.write_content_to_file(content, KrakenMobile::Constants::DEVICE_INBOX_NAME, device_id) end
writeSignalToAll(content)
click to toggle source
# File lib/kraken-mobile/protocols/file_protocol.rb, line 46 def writeSignalToAll(content) devices_manager = DevicesHelper::Manager.new({runner: ENV["RUNNER"], config_path: ENV["CONFIG_PATH"]}) devices_manager.connected_devices.each do |device| devices_manager.device_helper.write_content_to_file(content, KrakenMobile::Constants::DEVICE_INBOX_NAME, device.id) end end
writeSignalToAnyDevice(content)
click to toggle source
# File lib/kraken-mobile/protocols/file_protocol.rb, line 53 def writeSignalToAnyDevice(content) devices_manager = DevicesHelper::Manager.new({runner: ENV["RUNNER"], config_path: ENV["CONFIG_PATH"]}) device = devices_manager.connected_devices.sample devices_manager.device_helper.write_content_to_file(content, KrakenMobile::Constants::DEVICE_INBOX_NAME, device.id) device end