Class: Orocos::RemoteProcesses::Process

Inherits:
ProcessBase show all
Defined in:
lib/orocos/remote_processes/process.rb

Overview

Representation of a remote process started with ProcessClient#start

Instance Attribute Summary collapse

Attributes inherited from ProcessBase

#default_logger, #logged_ports, #model, #name, #name_mappings, #tasks

Instance Method Summary collapse

Methods inherited from ProcessBase

#default_log_file_name, #default_logger_name, #each_task, #get_mapped_name, #log_all_ports, #map_name, #orogen, #register_task, resolve_prefix, #setup_default_logger, #task_names

Constructor Details

#initialize(name, deployment_model, process_client, pid) ⇒ Process

Returns a new instance of Process



17
18
19
20
21
22
# File 'lib/orocos/remote_processes/process.rb', line 17

def initialize(name, deployment_model, process_client, pid)
    @process_client = process_client
    @pid = pid
    @alive = true
    super(name, deployment_model)
end

Instance Attribute Details

#pidObject (readonly)

The process ID of this process on the machine of the process server



15
16
17
# File 'lib/orocos/remote_processes/process.rb', line 15

def pid
  @pid
end

#process_clientObject (readonly)

The ProcessClient instance that gives us access to the remote process server



7
8
9
# File 'lib/orocos/remote_processes/process.rb', line 7

def process_client
  @process_client
end

Instance Method Details

#alive?Boolean

True if the process is running. This is an alias for running?

Returns:

  • (Boolean)


51
# File 'lib/orocos/remote_processes/process.rb', line 51

def alive?; @alive end

#dead!Object

Called to announce that this process has quit



30
31
32
# File 'lib/orocos/remote_processes/process.rb', line 30

def dead!
    @alive = false
end

#host_idObject

A string describing the host. It can be used to check if two processes are running on the same host



10
# File 'lib/orocos/remote_processes/process.rb', line 10

def host_id; process_client.host_id end

#joinObject

Wait for the



46
47
48
# File 'lib/orocos/remote_processes/process.rb', line 46

def join
    process_client.join(name)
end

#kill(wait = true) ⇒ Object

Stops the process



41
42
43
# File 'lib/orocos/remote_processes/process.rb', line 41

def kill(wait = true)
    process_client.stop(name, wait)
end

#on_localhost?Boolean

True if this process is located on the same machine than the ruby interpreter

Returns:

  • (Boolean)


13
# File 'lib/orocos/remote_processes/process.rb', line 13

def on_localhost?; process_client.host == 'localhost' end

#processObject

Retunging the Process name of the remote process



25
26
27
# File 'lib/orocos/remote_processes/process.rb', line 25

def process
    self
end

#resolve_all_tasks(cache = Hash.new) ⇒ Object

Resolve all tasks within the deployment

A deployment is usually considered ready when all its tasks can be resolved successfully



59
60
61
62
63
# File 'lib/orocos/remote_processes/process.rb', line 59

def resolve_all_tasks(cache = Hash.new)
    Orocos::Process.resolve_all_tasks(self, cache) do |task_name|
        task(task_name)
    end
end

#running?Boolean

True if the process is running. This is an alias for alive?

Returns:

  • (Boolean)


53
# File 'lib/orocos/remote_processes/process.rb', line 53

def running?; @alive end

#task(task_name) ⇒ Object

Returns the task context object for the process' task that has this name



36
37
38
# File 'lib/orocos/remote_processes/process.rb', line 36

def task(task_name)
    process_client.name_service.get(task_name, process: self)
end

#wait_running(timeout = nil) ⇒ Object

Waits for the deployment to be ready. timeout is the number of milliseconds we should wait. If it is nil, will wait indefinitely



67
68
69
# File 'lib/orocos/remote_processes/process.rb', line 67

def wait_running(timeout = nil)
           Orocos::Process.wait_running(self, timeout)
end