Package SpecClient :: Module SpecConnection :: Class SpecConnectionDispatcher
[hide private]
[frames] | no frames]

Class SpecConnectionDispatcher

source code

asyncore.dispatcher --+
                      |
                     SpecConnectionDispatcher

SpecConnection class

Signals: connected() -- emitted when the required Spec version gets connected disconnected() -- emitted when the required Spec version gets disconnected replyFromSpec(reply id, SpecReply object) -- emitted when a reply comes from the remote Spec error(error code) -- emitted when an error event is received from the remote Spec

Instance Methods [hide private]
 
__init__(self, specVersion)
Constructor
source code
 
__str__(self) source code
 
set_socket(self, s) source code
 
makeConnection(self)
Establish a connection to Spec
source code
 
registerChannel(self, chanName, receiverSlot, registrationFlag=0, dispatchMode=1)
Register a channel
source code
 
unregisterChannel(self, chanName)
Unregister a channel
source code
 
getChannel(self, chanName)
Return a channel object
source code
 
error(self, error)
Emit the 'error' signal when the remote Spec version signals an error.
source code
 
simulationStatusChanged(self, simulationMode) source code
 
isSpecConnected(self)
Return True if the remote Spec version is connected.
source code
 
specConnected(self)
Emit the 'connected' signal when the remote Spec version is connected.
source code
 
specDisconnected(self)
Emit the 'disconnected' signal when the remote Spec version is disconnected.
source code
 
handle_close(self)
Handle 'close' event on socket.
source code
 
disconnect(self)
Disconnect from the remote Spec version.
source code
 
handle_error(self)
Handle an uncaught error.
source code
 
handle_read(self)
Handle 'read' events on socket
source code
 
checkourversion(self, name)
Check remote Spec version
source code
 
readable(self) source code
 
writable(self)
Return True if socket should be written.
source code
 
handle_connect(self)
Handle 'connect' event on socket
source code
 
handle_write(self)
Handle 'write' events on socket
source code
 
send_msg_cmd_with_return(self, cmd)
Send a command message to the remote Spec server, and return the reply id.
source code
 
send_msg_func_with_return(self, cmd)
Send a command message to the remote Spec server using the new 'func' feature, and return the reply id.
source code
 
send_msg_cmd(self, cmd)
Send a command message to the remote Spec server.
source code
 
send_msg_func(self, cmd)
Send a command message to the remote Spec server using the new 'func' feature
source code
 
send_msg_chan_read(self, chanName)
Send a channel read message, and return the reply id.
source code
 
send_msg_chan_send(self, chanName, value)
Send a channel write message.
source code
 
send_msg_register(self, chanName)
Send a channel register message.
source code
 
send_msg_unregister(self, chanName)
Send a channel unregister message.
source code
 
send_msg_close(self)
Send a close message.
source code
 
send_msg_abort(self)
Send an abort message.
source code
 
send_msg_hello(self)
Send a hello message.
source code
 
__send_msg_with_reply(self, reply, message, replyReceiverObject=None)
Send a message to the remote Spec, and return the reply id.
source code
 
__send_msg_no_reply(self, message)
Send a message to the remote Spec.
source code

Inherited from asyncore.dispatcher: __getattr__, __repr__, accept, add_channel, bind, close, connect, create_socket, del_channel, handle_accept, handle_connect_event, handle_expt, handle_expt_event, handle_read_event, handle_write_event, listen, log, log_info, recv, send, set_reuse_addr

Class Variables [hide private]

Inherited from asyncore.dispatcher: ac_in_buffer_size, accepting, addr, closing, connected, connecting, debug, ignore_log_types

Method Details [hide private]

__init__(self, specVersion)
(Constructor)

source code 

Constructor

Arguments: specVersion -- a 'host:port' string

Overrides: asyncore.dispatcher.__init__

__str__(self)
(Informal representation operator)

source code 
Overrides: asyncore.dispatcher.__repr__

set_socket(self, s)

source code 
Overrides: asyncore.dispatcher.set_socket

makeConnection(self)

source code 

Establish a connection to Spec

If the connection is already established, do nothing. Otherwise, create a socket object and try to connect. If we are in port scanning mode, try to connect using a port defined in the range from MIN_PORT to MAX_PORT

registerChannel(self, chanName, receiverSlot, registrationFlag=0, dispatchMode=1)

source code 

Register a channel

Tell the remote Spec we are interested in receiving channel update events. If the channel is not already registered, create a new SpecChannel object, and connect the channel 'valueChanged' signal to the receiver slot. If the channel is already registered, simply add a connection to the receiver slot.

Arguments: chanName -- a string representing the channel name, i.e. 'var/toto' receiverSlot -- any callable object in Python

Keywords arguments: registrationFlag -- internal flag dispatchMode -- can be SpecEventsDispatcher.UPDATEVALUE (default) or SpecEventsDispatcher.FIREEVENT, depending on how the receiver slot will be called. UPDATEVALUE means we don't mind skipping some channel update events as long as we got the last one (for example, a motor position). FIREEVENT means we want to call the receiver slot for every event.

unregisterChannel(self, chanName)

source code 

Unregister a channel

Arguments: chanName -- a string representing the channel to unregister, i.e. 'var/toto'

getChannel(self, chanName)

source code 

Return a channel object

If the required channel is already registered, return it. Otherwise, return a new 'temporary' unregistered SpecChannel object ; reference should be kept in the caller or the object will get dereferenced.

Arguments: chanName -- a string representing the channel name, i.e. 'var/toto'

handle_close(self)

source code 

Handle 'close' event on socket.

Overrides: asyncore.dispatcher.handle_close

handle_error(self)

source code 

Handle an uncaught error.

Overrides: asyncore.dispatcher.handle_error

handle_read(self)

source code 

Handle 'read' events on socket

Messages are built from the read calls on the socket.

Overrides: asyncore.dispatcher.handle_read

checkourversion(self, name)

source code 

Check remote Spec version

If we are in port scanning mode, check if the name from Spec corresponds to our required Spec version.

readable(self)

source code 
Overrides: asyncore.dispatcher.readable

writable(self)

source code 

Return True if socket should be written.

Overrides: asyncore.dispatcher.writable

handle_connect(self)

source code 

Handle 'connect' event on socket

Send a HELLO message.

Overrides: asyncore.dispatcher.handle_connect

handle_write(self)

source code 

Handle 'write' events on socket

Send all the messages from the queue.

Overrides: asyncore.dispatcher.handle_write

send_msg_cmd_with_return(self, cmd)

source code 

Send a command message to the remote Spec server, and return the reply id.

Arguments: cmd -- command string, i.e. '1+1'

send_msg_func_with_return(self, cmd)

source code 

Send a command message to the remote Spec server using the new 'func' feature, and return the reply id.

Arguments: cmd -- command string

send_msg_cmd(self, cmd)

source code 

Send a command message to the remote Spec server.

Arguments: cmd -- command string, i.e. 'mv psvo 1.2'

send_msg_func(self, cmd)

source code 

Send a command message to the remote Spec server using the new 'func' feature

Arguments: cmd -- command string

send_msg_chan_read(self, chanName)

source code 

Send a channel read message, and return the reply id.

Arguments: chanName -- a string representing the channel name, i.e. 'var/toto'

send_msg_chan_send(self, chanName, value)

source code 

Send a channel write message.

Arguments: chanName -- a string representing the channel name, i.e. 'var/toto' value -- channel value

send_msg_register(self, chanName)

source code 

Send a channel register message.

Arguments: chanName -- a string representing the channel name, i.e. 'var/toto'

send_msg_unregister(self, chanName)

source code 

Send a channel unregister message.

Arguments: chanName -- a string representing the channel name, i.e. 'var/toto'

__send_msg_with_reply(self, reply, message, replyReceiverObject=None)

source code 

Send a message to the remote Spec, and return the reply id.

The reply object is added to the registeredReplies dictionary, with its reply id as the key. The reply id permits then to register for the reply using the 'registerReply' method.

Arguments: reply -- SpecReply object which will receive the reply message -- SpecMessage object defining the message to send

__send_msg_no_reply(self, message)

source code 

Send a message to the remote Spec.

If a reply is sent depends only on the message, and not on the method to send the message. Using this method, any reply is lost.