MasterScan  Lab_Matlab_control Master Branch
List of all members | Properties and Events | Protected Properties | Methods | Protected Methods | Static Methods
dotsEnsembleServer Class Reference

Overview

Mirrors dotsClientEnsemble objects from another instance of Matlab.

dotsEnsembleServer opens a socket and checks for messages sent from dotsClientEnsemble objects created in another Matlab instance. It creates topsEnsemble objects on the server which mirror the client ensembles. It can call methods on server objects and return results to the client objects.

Client-server interactions must be initiated on the client side. For basic method calls, the client is expected to wait until dotsEnsembleServer reports that it's finished with each action and returns any results.

dotsEnsembleServer also continuously invokes runBriefly() on those ensemble objects that have isRunning set to true. This allows client and server ensembles to run concurrent behaviors across Matlab instances. Invoking run() or start(), and finish(), on a client ensembl controls isRunning for the mirrored server ensemble.

The runBriefly() behavior of each server ensemble depends on which of its calls are active. Invoking setActiveByName() or callByName(), with the isActive flag, from the client side controls the behavior of the mirrored server ensemble.

Inheritance diagram for dotsEnsembleServer:
Inheritance graph
[legend]

Properties and Events

Property timeout = 1.0
 seconds to allow for network communications
 
Property waitTime = 0.0001
 seconds to yield periodically to the operating system
 
Property clockFunction
 function that returns the current time as a number
 

Protected Properties

Property clientIP
 IP address of the Snow Dots client.
 
Property clientPort
 network port of the Snow Dots client
 
Property serverIP
 IP address of this dotsEnsembleServer.
 
Property serverPort
 network port of this dotsEnsembleServer
 
Property socket
 socket identifier for communictions
 
Property ensembles
 server side ensemble instances
 
Property ensembleCell
 cache ensembles in a cell array for faster access
 

Methods

self dotsEnsembleServer (clientIP, clientPort, serverIP, serverPort)
 Create an ensemble server with optional network addresses. More...
 
 setAddresses (self, clientIP, clientPort, serverIP, serverPort)
 Use the given network addresses for messages. More...
 
 run (self, duration)
 Run the server with optional duration. More...
 
 reset (self)
 Return to a like-new state. More...
 

Protected Methods

 openSocket (self)
 Get a socket for messages.
 
status doNextTransaction (self)
 Do a transaction on self, or delegate a named ensemble. More...
 
 runEnsemblesBriefly (self)
 Let each ensemble that isRunning runBriefly().
 

Static Methods

static runNewServer (duration, clientIP, clientPort, serverIP, serverPort)
 Create an ensemble server and start it running. More...
 

Constructor

◆ dotsEnsembleServer()

Create an ensemble server with optional network addresses.

Parameters
clientIPstring IP address of the Snow Dots client
clientPortnetwork port number of the Snow Dots client
serverIPstring IP address of the ensemble server
serverPortnetowrk port number of the ensemble server

If clientIP, clientPort, serverIP, and serverPort are provided, attempts to connect to a client using the given addresses. Otherwise, uses default provided by dotsTheMessenger.

Methods

◆ setAddresses()

setAddresses ( self  ,
clientIP  ,
clientPort  ,
serverIP  ,
serverPort   
)

Use the given network addresses for messages.

Parameters
clientIPstring IP address of the Snow Dots client
clientPortnetwork port number of the Snow Dots client
serverIPstring IP address of the ensemble server
serverPortnetowrk port number of the ensemble server

If clientIP, clientPort, serverIP, and serverPort are provided, attempts to connect to a client using the given addresses. Otherwise, uses default provided by dotsTheMessenger.

◆ run()

run ( self  ,
duration   
)

Run the server with optional duration.

Parameters
durationhow long to keep running

Starts the server running, responding to messages from the client side and invoking runBriefly() on server-side ensembles that have isRunning set to true.

If @duration is provided, runs for that long, in units of clockFunction, then returns. By default, runs forever.

◆ reset()

reset ( self  )

Return to a like-new state.

Removes all ensembles, and with them all server-side objects. Also re-opens network sockets. Reset may be invoked directly on the server side, or remotely from the client side, via the appropriate transaction. Note that the server will reply to the "reset" transaction just before resetting itself. The server may be unresponsive for a short time after it reposnds.

◆ doNextTransaction()

status doNextTransaction ( self  )
protected

Do a transaction on self, or delegate a named ensemble.

This most important method for dotsEnsembleServer. It checks for a client message, and if there is a message, it carries out the indicated transaction. The transaction may be one of a few types, related to the server itself, or the ensembles it contains.

After carrying out a transaction, the server sends a reply to the client (which the client should be waiting for). The reply contains the original transaction data, plus any data requested in the transaction, plus timing data about the server's behavior.

Returns the message status from dotsTheMessenger, which is positive there was a transaction to carry out.

◆ runNewServer()

static runNewServer ( duration  ,
clientIP  ,
clientPort  ,
serverIP  ,
serverPort   
)
static

Create an ensemble server and start it running.

Parameters
durationtime in seconds to keep running
clientIPstring IP address of the Snow Dots client
clientPortnetwork port number of the Snow Dots client
serverIPstring IP address of the ensemble server
serverPortnetowrk port number of the ensemble server

Creates an instance of dotsEnsembleServer and lets it run. If duration is provided, runs for that many seconds, otherwise runs forever.

If clientIP, clientPort, serverIP, and serverPort are provided, attempts to connect to a client using the given addresses. Otherwise, uses default addresses provided by dotsTheMessenger. @deatils runNewServer() will block, busying its Matlab instance, until the server is done running, if ever.


The documentation for this class was generated from the following file: