-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement just enough of the orocos'rb Async interface for the …
…task inspector This is only the API surface. Data is currently still not transferred.
- Loading branch information
Showing
10 changed files
with
249 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Syskit | ||
module Telemetry | ||
module Async | ||
# Async interface compatible with the orocos.rb's API | ||
class InputPort < ReadableInterfaceObject | ||
def output? | ||
false | ||
end | ||
|
||
def input? | ||
true | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Syskit | ||
module Telemetry | ||
module Async | ||
# Async interface compatible with the orocos.rb's API | ||
class OutputPort < ReadableInterfaceObject | ||
def output? | ||
true | ||
end | ||
|
||
def input? | ||
false | ||
end | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
# frozen_string_literal: true | ||
|
||
module Syskit | ||
module Telemetry | ||
module Async | ||
# Definition of hooks related to reading data | ||
class ReadableInterfaceObjectHooks < InterfaceObject | ||
define_hooks :on_data | ||
define_hooks :on_raw_data | ||
end | ||
|
||
# Base class for interface objects that allow to read data | ||
class ReadableInterfaceObject < ReadableInterfaceObjectHooks | ||
# Callback management object with the same API than orocos.rb's | ||
class Listener | ||
def initialize(object, event, block) | ||
@object = object | ||
@event = event | ||
@block = block | ||
end | ||
|
||
def start | ||
return if @disposable | ||
|
||
@disposable = @object.send(@event, &@block) | ||
end | ||
|
||
def stop | ||
@disposable&.dispose | ||
@disposable = nil | ||
end | ||
|
||
def dispose | ||
stop | ||
end | ||
end | ||
|
||
alias __on_raw_data on_raw_data | ||
def on_raw_data(&block) | ||
listener = Listener.new(self, :__on_raw_data, block) | ||
listener.start | ||
listener | ||
end | ||
|
||
alias __on_data on_data | ||
def on_data(&block) | ||
listener = Listener.new(self, :__on_data, block) | ||
listener.start | ||
listener | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.