Class: Baykit::BayServer::WaterCraft::Ship
- Inherits:
-
Object
- Object
- Baykit::BayServer::WaterCraft::Ship
- Includes:
- Util, Util::Reusable
- Defined in:
- lib/baykit/bayserver/watercraft/ship.rb
Direct Known Subclasses
Constant Summary collapse
- SHIP_ID_NOCHECK =
-1
- INVALID_SHIP_ID =
0
Class Attribute Summary collapse
-
.oid_counter ⇒ Object
readonly
Returns the value of attribute oid_counter.
-
.ship_id_counter ⇒ Object
readonly
Returns the value of attribute ship_id_counter.
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#initialized ⇒ Object
readonly
Returns the value of attribute initialized.
-
#keeping ⇒ Object
Returns the value of attribute keeping.
-
#object_id ⇒ Object
readonly
Returns the value of attribute object_id.
-
#postman ⇒ Object
readonly
Returns the value of attribute postman.
-
#protocol_handler ⇒ Object
Returns the value of attribute protocol_handler.
-
#ship_id ⇒ Object
readonly
Returns the value of attribute ship_id.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Instance Method Summary collapse
- #check_ship_id(check_id) ⇒ Object
- #id ⇒ Object
-
#init(skt, agt, postman) ⇒ Object
Other methods.
-
#initialize ⇒ Ship
constructor
A new instance of Ship.
- #protocol ⇒ Object
-
#reset ⇒ Object
implements Reusable.
- #resume(check_id) ⇒ Object
- #set_protocol_handler(proto_hnd) ⇒ Object
Constructor Details
#initialize ⇒ Ship
Returns a new instance of Ship.
33 34 35 36 |
# File 'lib/baykit/bayserver/watercraft/ship.rb', line 33 def initialize() @object_id = Ship.oid_counter.next @ship_id = INVALID_SHIP_ID end |
Class Attribute Details
.oid_counter ⇒ Object (readonly)
Returns the value of attribute oid_counter.
14 15 16 |
# File 'lib/baykit/bayserver/watercraft/ship.rb', line 14 def oid_counter @oid_counter end |
.ship_id_counter ⇒ Object (readonly)
Returns the value of attribute ship_id_counter.
15 16 17 |
# File 'lib/baykit/bayserver/watercraft/ship.rb', line 15 def ship_id_counter @ship_id_counter end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
26 27 28 |
# File 'lib/baykit/bayserver/watercraft/ship.rb', line 26 def agent @agent end |
#initialized ⇒ Object (readonly)
Returns the value of attribute initialized.
29 30 31 |
# File 'lib/baykit/bayserver/watercraft/ship.rb', line 29 def initialized @initialized end |
#keeping ⇒ Object
Returns the value of attribute keeping.
31 32 33 |
# File 'lib/baykit/bayserver/watercraft/ship.rb', line 31 def keeping @keeping end |
#object_id ⇒ Object (readonly)
Returns the value of attribute object_id.
24 25 26 |
# File 'lib/baykit/bayserver/watercraft/ship.rb', line 24 def object_id @object_id end |
#postman ⇒ Object (readonly)
Returns the value of attribute postman.
27 28 29 |
# File 'lib/baykit/bayserver/watercraft/ship.rb', line 27 def postman @postman end |
#protocol_handler ⇒ Object
Returns the value of attribute protocol_handler.
30 31 32 |
# File 'lib/baykit/bayserver/watercraft/ship.rb', line 30 def protocol_handler @protocol_handler end |
#ship_id ⇒ Object (readonly)
Returns the value of attribute ship_id.
25 26 27 |
# File 'lib/baykit/bayserver/watercraft/ship.rb', line 25 def ship_id @ship_id end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
28 29 30 |
# File 'lib/baykit/bayserver/watercraft/ship.rb', line 28 def socket @socket end |
Instance Method Details
#check_ship_id(check_id) ⇒ Object
92 93 94 95 96 97 98 99 |
# File 'lib/baykit/bayserver/watercraft/ship.rb', line 92 def check_ship_id(check_id) if !@initialized raise Sink.new("#{self} ship not initialized (might be returned ship): #{check_id}") end if check_id != SHIP_ID_NOCHECK && check_id != @ship_id raise Sink.new("#{self} Invalid ship id (might be returned ship): #{check_id}") end end |
#id ⇒ Object
77 78 79 |
# File 'lib/baykit/bayserver/watercraft/ship.rb', line 77 def id() @ship_id end |
#init(skt, agt, postman) ⇒ Object
Other methods
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/baykit/bayserver/watercraft/ship.rb', line 59 def init(skt, agt, postman) if @initialized raise Sink.new("Ship already initialized") end @ship_id = Ship.ship_id_counter.next @agent = agt @postman = postman @socket = skt @initialized = true BayLog.debug("%s initialized", self) end |
#protocol ⇒ Object
81 82 83 |
# File 'lib/baykit/bayserver/watercraft/ship.rb', line 81 def protocol() return @protocol_handler == nil ? "unknown" : @protocol_handler.protocol end |
#reset ⇒ Object
implements Reusable
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/baykit/bayserver/watercraft/ship.rb', line 41 def reset() BayLog.debug("%s reset", self) @initialized = false @postman.reset() @postman = nil # for reloading certification @agent = nil @ship_id = INVALID_SHIP_ID @socket = nil @protocol_handler = nil @keeping = false end |
#resume(check_id) ⇒ Object
87 88 89 90 |
# File 'lib/baykit/bayserver/watercraft/ship.rb', line 87 def resume(check_id) check_ship_id(check_id); @postman.open_valve(); end |
#set_protocol_handler(proto_hnd) ⇒ Object
71 72 73 74 75 |
# File 'lib/baykit/bayserver/watercraft/ship.rb', line 71 def set_protocol_handler(proto_hnd) @protocol_handler = proto_hnd proto_hnd.ship = self #BayLog.debug("%s protocol handler is set", self) end |