gestalt package

Submodules

gestalt.core module

class gestalt.core.actionObject(serviceRoutine)

Bases: object

channelAccess()

The user method that gets called when the actionObject has been granted access to the channel.

commit()

Commits this actionObject to its interface’s priority queue

commitAndRelease()

Commits this actionObject to its interface’s priority queue and releases for channel access.

getPacket()

Returns a packet waiting in the packet holder.

grantAccess()

This method gets called by the interface when this actionObject has been granted access to the channel.

init()

This method gets called when the action object is instantiated.

It should be overridden by the user.

isReleased()
new(*args, **kwargs)

Will create a new instance of self, duplicating references created on instantiation.

release()
setPacket(packet, mode='unicast')
transmit()

Sends a packet over the interface to the matching physical node. Note that this method will only be called within the interface channelAccess thread, which guarantees that the channel is avaliable.

transmitPersistent(tries=10, timeout=0.2)

Transmit a packet until a response is received.

waitForChannelAccess(timeout=None)

Can be called by the user init function if it needs to return a response.

waitForResponse(timeout=None)
class gestalt.core.actionSequence(actionObjects=None, parent=None)

Bases: object

Stores a series of action objects which should get executed sequentially.

commit()

Commits all member actionObjects to their interface’s priority queue.

release()
class gestalt.core.actionSet(actionObjects)

Bases: object

Stores a set of actionObjects which should be executed simultaneously.

commit()
isReleased()
release()
gestalt.core.distributeFunctionCall(*args, **kwargs)

Distributes a function call to _attribute_ amongst the provided actionObjects.

Any arg or kwarg provided as a tuple is distributed uniquely to the actionObjects. Otherwise the parameter is copied to all actionObjects.

gestalt.core.functionCall(callObject, attribute, args, kwargs)

Calls callObject.attribute(*args, **kwargs)

class gestalt.core.syncToken

Bases: object

Contains tokens used by nodes to synchronize with each other.

pull(tokenName)
push(tokenName, tokenValue)

gestalt.functions module

class gestalt.functions.jog(move, defaultJogSpeed=20)

Bases: object

class gestalt.functions.move(virtualMachine=None, virtualNode=None, axes=None, kinematics=None, machinePosition=None, defaultAcceleration=2000.0, pullInSpeed=4000, planner=None)

Bases: object

class motionPlanner(move, queueSize=50, queueTimeout=0.1)

Bases: threading.Thread

addMove(newMoveObject)

Adds a new move to the motion planner queue.

static distanceFromVelocities(finalVelocity, initialVelocity, acceleration)
flushPlanner()
forwardPass()
generateJunctionVelocity(entryMoveObject, exitMoveObject)

Calculates the maximum junction velocity based on the pull in velocity limit and the directions of the entry and exit vectors.

getMoveObject()

Will attempt to retrieve a new move object from the planner queue.

static intersectionPoint(initialVelocity, finalVelocity, acceleration, seperationDistance)

This calculates the intersection point of two acceleration curves. The first starts at initial velocity and increases with acceleration, and the second starts at final velocity and increases with acceleration. The starting points are seperated by seperationDistance, and the return value is the distance of the intersection point from the final velocity position.

normalizeVector(inputVector)
processMoves(newMoveObject)

Performs multi-block look-ahead algorithm.

release(segment)
resetMachineState(velocity=0.0, acceleration=0.0)
reversePass()
run()
updateAndRelease(segment)
static velocityFromDistance(distance, initialVelocity, acceleration)
class move.nullMotionPlanner(move, queueSize=50, queueTimeout=0.1)

Bases: threading.Thread

addMove(newMoveObject)

Adds a new move to the motion planner queue.

flushPlanner()
getMoveObject()

Will attempt to retrieve a new move object from the planner queue.

processMoves(newMoveObject)
release(segment)
resetMachineState(velocity=0.0, acceleration=0.0)
run()
class gestalt.functions.moveObject(move, position=None, velocity=None, acceleration=None)

Bases: object

commit()

Adds this move to the motion planner.

release()

Releases all constituent spin objects to the real machine, making them no longer modifiable.

update()

Updates all action objects with new parameters.

class gestalt.functions.serviceRoutine(virtualNode=None, packetSet=None, responseFlag=None, packetHolder=None)

Bases: object

A function which spawns an action item that will eventually be executed on the network.

The expected pattern is as follows: 1) A call to serviceRoutine causes an actionObject to be created. 2) This actionObject eventually gets access to the network. 3) actionObject transmits a packet to its physical counterpart. 4) When a response arrives, it is routed by the virtual node to the response serviceRoutine. 5) Response service routine calls its receive method. 6) Receive method might update machine state, etc. 7) Receive method sets the responseFlag, signaling to the actionObject that a response has arrived. 8) actionObject reacts to message, either by returning something to the calling method, transmitting another packet, etc...

Note that because only action object has access to the network at a time, it will block in the channelAccessQueue until a response is received. However because serviceRoutine is running in the interface receiver routing queue, it can asynchronously update the machine state.

receive(packet)
receiver(packet)

gestalt.interfaces module

class gestalt.interfaces.CRC

Generates CRC bytes and checks CRC validated packets.

calculateByteCRC(byteValue)

Calculates Bytes in the CRC Table.

crcTableGen()

Generates a CRC table to make CRC generation faster.

validate(packet)

Checks CRC byte against packet.

class gestalt.interfaces.baseInterface

Bases: object

This base class could eventually provide a common foundation for all interfaces

initAfterSet()

This method gets called when an interface is set into an interface shell.

class gestalt.interfaces.devInterface

Bases: gestalt.interfaces.baseInterface

Base class for interfaces mounted in the /dev/ folder.

deviceScan(searchTerm)

returns available ports that match the search term

getSearchTerms(interfaceType)

returns the likely prefix for a serial port based on the operating system and device type

waitForNewPort(searchTerms='', timeout=10)

Scans for a new port to appear in /dev/ and returns the name of the port.

Search terms is a list that can contain several terms. For now only implemented for one term.

class gestalt.interfaces.gestaltInterface(name=None, interface=None, owner=None)

Bases: gestalt.interfaces.baseInterface

Interface to Gestalt nodes based on the Gestalt protocol.

assignNode(node, address)

Assigns a given node to the interface on a particular address.

class channelAccessThread(interface)

Bases: threading.Thread

Controls when action objects have access to the interface.

channelAccessQueue contains a serialized list of actionObjects which have been cleared for transmission and are waiting for access to the channel.

getActionObject()
putActionObject(actionObject)
run()
class gestaltInterface.channelPriorityThread(interface)

Bases: threading.Thread

Releases actionObjects to the channelAccessQueue, and when necessary first serializes actionSets into a series of action objects.

getActionObject()
putActionObject(actionObject)
run()
serialize(actionObject)

serializes actionSets into actionObjects.

gestaltInterface.commit(actionObject)

Puts actionObjects or actionSets into the channelPriority queue.

class gestaltInterface.nodeManager

Bases: object

Manages all nodes under the control of this interface.

getIP(node)

Returns IP address for a given node.

getNode(IP)
updateNodesAddresses(node, address)
class gestaltInterface.packetRouterThread(interface)

Bases: threading.Thread

Routes packets to their matching service routines, and executes the service routine within this thread.

getRouterPacket()
run()
class gestaltInterface.receiveThread(interface)

Bases: threading.Thread

Gets packets from the network interface, interpreting them, and pushing them to the router queue.

run()
gestaltInterface.startInterfaceThreads()

Initiates the receiver thread.

gestaltInterface.transmit(virtualNode, port, packetSet, mode)

Transmits a packet set over the interface immediately.

gestaltInterface.validateIP(IP)

Makes sure that an IP address isn’t already in use on the interface.

class gestalt.interfaces.interfaceShell(Interface=None, owner=None)

Bases: object

Allows both the node and shell node to access the interface by acting as an intermediary.

set(Interface, owner=None)

Updates the interface contained by the shell

setOwner(owner)

Updates the owner of the interface contained by the shell

class gestalt.interfaces.serialInterface(baudRate, portName=None, interfaceType=None, owner=None, timeOut=0.2, flowControl=None)

Bases: gestalt.interfaces.devInterface

Provides an interface to nodes connected thru a serial port on the host machine.

acquirePort(interfaceType=None)

Discovers and connects to a port by waiting for a new device to be plugged in.

connect(portName=None)

Locates port for interface on host machine.

connectToPort(portName)

Actually connects the interface to the port

disconnect()

Disconnects from serial port.

flushInput()

Flushes the input buffer.

getAvailablePorts(ports)

tests all provided ports and returns a subset of ports that are available

initAfterSet()
receive()

Grabs one byte from the serial port.

setDTR()

Used to reset the Arduino hardware.

setTimeout(timeout)

Sets timeout for receiving on port.

startTransmitter()

Starts the transmit thread.

transmit(data)

Sends request for data to be transmitted over the serial port. Format is as a list.

class transmitThread(transmitQueue, port)

Bases: threading.Thread

Handles transmitting data over the serial port.

getTransmitPacket()

Tries to fetch a packet from the transmit queue.

run()

Code run by the transmit thread.

gestalt.interfaces.serialize(packet)

Converts packet into a string for transmission over a serial port.

class gestalt.interfaces.socketInterface(IPAddress='', IPPort=27272)

Bases: gestalt.interfaces.baseInterface

class gestalt.interfaces.socketUDPServer(IPAddress='', IPPort=27272)

Bases: gestalt.interfaces.socketInterface

initAfterSet()
receive()
transmit(remoteIPAddress, remoteIPPort, data)

gestalt.machines module

class gestalt.machines.coordinates

Components pertinent to storing and manipulating position information.

class baseCoordinate(inputList)

Bases: object

A set of ordinates which can be used to define positions of various machine elements.

get()
set(valueArray)
class coordinates.uFloat(value, units=None)

Bases: float

A floating-point number which also has units.

convertUnits(targetUnits)
coordinates.uFloatSubtract(term1, term2)

Returns a list containing term1 - term2 with units.

class gestalt.machines.elements
class element

Bases: object

Base class for mechanical elements. In essence, elements scale and/or convert between units.

classmethod forward(thisClass, inputParameter)
init(inputUnits=None, outputUnits=None, transformation=None)
classmethod reverse(thisClass, inputParameter)
transformForward(value)
transformReverse(value)
class elements.elementChain(elements)

Bases: gestalt.machines.element

class elements.invert(invert=False)

Bases: gestalt.machines.element

class elements.leadscrew(lead)

Bases: gestalt.machines.element

class elements.microstep(microstepCount)

Bases: gestalt.machines.element

class elements.pulley(pitchDiameter)

Bases: gestalt.machines.element

class elements.stepper(stepAngle)

Bases: gestalt.machines.element

class gestalt.machines.kinematics
class chain(forwardChain)

Bases: gestalt.machines.transform

Allows a series of kinematics to be chained together.

forward(inputVector)
reverse(inputVector)
class kinematics.compound(inputTransforms)

Bases: gestalt.machines.transform

class kinematics.compoundMatrix(inputMatrices)

Bases: gestalt.machines.matrix

A matrix which is composed of several matrices arranged along the diagonal.

transform(inputVector)
class kinematics.direct(order)

Bases: gestalt.machines.transform

class kinematics.hbot(invertX=False, invertY=False)

Bases: gestalt.machines.transform

class kinematics.identityMatrix(order)

Bases: gestalt.machines.matrix

A square matrix of size = order with 1’s on the diagonal and zeros elsewhere.

class kinematics.matrix(array)

Bases: object

A base class for defining transformation matrices.

dot(array1, array2)
transform(inputVector)
class kinematics.route(routingList)

Bases: gestalt.machines.transform

class kinematics.routeForwardMatrix(routingList)

Bases: gestalt.machines.matrix

A square matrix which routes according to the provided routing list.

class kinematics.routeReverseMatrix(routingList)

Bases: gestalt.machines.matrix

A square matrix which routes according to the inverse of the provided routing list.

class kinematics.transform(forwardMatrix, reverseMatrix)

Bases: object

Contains methods for transforming in the forwards and reverse directions.

forward(inputVector)
reverse(inputVector)
class gestalt.machines.state

Elements which help keep track of machine state.

class coordinate(inputList)

Bases: object

A collection of coordinates which stores both actual (real-time) and future (buffered) machine positions.

commit(inputList)

Updates most recent change to machine position used for calculating future moves.

update(inputList)

Updates last known real-time coordinate of machine.

class gestalt.machines.virtualMachine(*args, **kwargs)

Bases: object

The base class for all virtual machines.

While many machines won’t need the pre-built initializers which get called, they are provided to introduce some structure to the format of user virtual machines.

disablePublishing()
enablePublishing()
init(*args, **kwargs)
initController()
initCoordinates()
initFunctions()
initInterfaces()
initKinematics()
initLast()
initPublish()
publish()

gestalt.nodes module

class gestalt.nodes.baseGestaltNode(**kwargs)

Bases: gestalt.nodes.baseVirtualNode

base class for all gestalt nodes

class bindPort(virtualNode)
baseGestaltNode.initFunctions()
baseGestaltNode.initLast()
baseGestaltNode.initPackets()
baseGestaltNode.initParameters()
baseGestaltNode.initPorts()
baseGestaltNode.route(port, packet=None)
baseGestaltNode.transmit(nodeSet, mode='unicast')
class gestalt.nodes.baseNodeShell

Bases: object

The basic container for all nodes.

Like a room in a hotel, that has different occupants and offers certain amenities to its guests. baseNodeShell gets subclassed by more specific shells for one of the four types of gestalt nodes: ->Solo/Independent: arbitrary interface/ arbitrary protocol ->Solo/Gestalt: arbitrary interface/ gestalt protocol ->Networked/Gestalt: networked gestalt interface/ gestalt protocol ->Managed/Gestalt: hardware synchronized gestalt network/ gestalt protocol

acquire()

gets the identifier for either the interface or the node

hasNode()

Checks if shell contains a node.

loadNodeFromFile(filename, **kwargs)

Loads a node into the node shell from a provided filename.

Assumes that this is called from a node shell that has defined self.name

loadNodeFromModule(module, **kwargs)

Loads a node into the node shell from the provided class.

Note that class itself should be provided, NOT a class instance.

loadNodeFromURL(URL, **kwargs)

Loads a node into the node shell from a provided URL.

Assumes that this is called form a node shell that has defined self.name

setNode(node)

sets the node

class gestalt.nodes.baseSoloIndependentNode(**kwargs)

Bases: gestalt.nodes.baseVirtualNode

base class for solo/independent virtual nodes

class gestalt.nodes.baseStandardGestaltNode(**kwargs)

Bases: gestalt.nodes.baseGestaltNode

class bootCommandRequest(virtualNode=None, packetSet=None, responseFlag=None, packetHolder=None)

Bases: gestalt.functions.serviceRoutine

class actionObject(serviceRoutine)

Bases: gestalt.core.actionObject

init(command)
class baseStandardGestaltNode.bootReadRequest(virtualNode=None, packetSet=None, responseFlag=None, packetHolder=None)

Bases: gestalt.functions.serviceRoutine

class actionObject(serviceRoutine)

Bases: gestalt.core.actionObject

init(pageNumber)
class baseStandardGestaltNode.bootWriteRequest(virtualNode=None, packetSet=None, responseFlag=None, packetHolder=None)

Bases: gestalt.functions.serviceRoutine

class actionObject(serviceRoutine)

Bases: gestalt.core.actionObject

init(pageNumber, data)
class baseStandardGestaltNode.identifyRequest(virtualNode=None, packetSet=None, responseFlag=None, packetHolder=None)

Bases: gestalt.functions.serviceRoutine

class actionObject(serviceRoutine)

Bases: gestalt.core.actionObject

init()
baseStandardGestaltNode.initBootload()
baseStandardGestaltNode.loadProgram(filename)

Loads a program into a Gestalt Node via the built-in Gestalt bootloader.

class baseStandardGestaltNode.resetRequest(virtualNode=None, packetSet=None, responseFlag=None, packetHolder=None)

Bases: gestalt.functions.serviceRoutine

class actionObject(serviceRoutine)

Bases: gestalt.core.actionObject

init()
baseStandardGestaltNode.runApplication()
class baseStandardGestaltNode.setIPRequest(virtualNode=None, packetSet=None, responseFlag=None, packetHolder=None)

Bases: gestalt.functions.serviceRoutine

class actionObject(serviceRoutine)

Bases: gestalt.core.actionObject

init(IP)
class baseStandardGestaltNode.statusRequest(virtualNode=None, packetSet=None, responseFlag=None, packetHolder=None)

Bases: gestalt.functions.serviceRoutine

class actionObject(serviceRoutine)

Bases: gestalt.core.actionObject

init()
class baseStandardGestaltNode.urlRequest(virtualNode=None, packetSet=None, responseFlag=None, packetHolder=None)

Bases: gestalt.functions.serviceRoutine

class actionObject(serviceRoutine)

Bases: gestalt.core.actionObject

init()
class gestalt.nodes.baseVirtualNode(**kwargs)

Bases: object

base class for creating virtual nodes

init(**kwargs)

Dummy initializer for terminal child class.

class gestalt.nodes.compoundNode(*nodes)

Bases: object

A compound node helps distribute and synchronize function calls across multiple nodes.

class distributor(compoundNode, attribute)

Bases: object

The distributor is responsible for forwarding function calls made on the compound node to its constituents.

Arguments provided as tuples will be distributed individually. Non-tuple arguments will be duplicated to all nodes.

nodeFunctionCall(node, attribute, args, kwargs)
class gestalt.nodes.gestaltNodeShell(name=None, interface=None, filename=None, URL=None, module=None, persistence=<function <lambda>>, **kwargs)

Bases: gestalt.nodes.baseNodeShell

Base class for all nodes which communicate using the gestalt protocol.

generateIPAddress()

Generates a random IP address.

class gestalt.nodes.networkedGestaltNode(name=None, interface=None, filename=None, URL=None, module=None, persistence=<function <lambda>>, **kwargs)

Bases: gestalt.nodes.gestaltNodeShell

A container shell for Networked/Gestalt nodes.

Networked/Gestalt nodes are networked and use the gestalt communications protocol. Both the older Fabnet hardware as well as boards based on Units of Fab are supported.

class gestalt.nodes.soloGestaltNode(name=None, interface=None, filename=None, URL=None, module=None, persistence=<function <lambda>>, **kwargs)

Bases: gestalt.nodes.gestaltNodeShell

A container shell for Solo/Gestalt nodes.

Solo/Gestalt nodes are non-networked and use the gestalt communications protocol. For example they might make use of the gsArduino library.

class gestalt.nodes.soloIndependentNode(name=None, interface=None, filename=None, URL=None, module=None, **kwargs)

Bases: gestalt.nodes.baseNodeShell

A container shell for Solo/Independent nodes.

Solo/Independent nodes are non-networked and may use an arbitrary communications protocol. For example, they could be a third-party device with a python plug-in, etc...

gestalt.packets module

class gestalt.packets.pInteger(keyName, numBytes)

Bases: gestalt.packets.packetToken

decode(inputPacket)
encode(inputDict)
class gestalt.packets.pLength

Bases: gestalt.packets.packetToken

decode(inputPacket)
encode(inputDict)
class gestalt.packets.pList(keyName, numBytes=False)

Bases: gestalt.packets.packetToken

decode(inputPacket)
encode(inputDict)
class gestalt.packets.pString(keyName, numBytes=False)

Bases: gestalt.packets.packetToken

decode(inputPacket)
encode(inputDict)
class gestalt.packets.packet(template, value=None)

Bases: list

decode(decodeList=None)
spawn(outputList)
class gestalt.packets.packetHolder

Bases: object

get()
put(Packet)
class gestalt.packets.packetSet(Packet)

Bases: object

class gestalt.packets.packetToken

Bases: object

decode(*args, **kwargs)
encode(*args, **kwargs)

gestalt.setup module

gestalt.testMachine module

gestalt.utilities module

gestalt.utilities.bytesToInt(bytes)
gestalt.utilities.intToBytes(integer, numbytes)
class gestalt.utilities.intelHexParser

Bases: object

Parses Intel Hex Files for Bootloading and Memory Programming.

checkAddressContinuity()
dataList(data)
integerRecord(record)
loadHexFile()
openHexFile(filename=None)
processDataRecord(record)
processEndOfFileRecord(record)
processExtendedLinearAddressRecord(record)
processExtendedSegmentAddressRecord(record)
processStartLinearAddressRecord(record)
processStartSegmentAddressRecord(record)
recordParser(record)
resetParser()
returnPages(pageSize)
gestalt.utilities.listToString(numList)
gestalt.utilities.notice(source=None, message='')

Sends a notice to the user.

For now, this just prints to the screen. But eventually, could re-route via a web interface.

class gestalt.utilities.persistenceManager(filename=None, namespace=None)

Bases: object

Handles interacting with persistence files.

get(name)
readPersistenceDictionary()
set(name, value)
writePersistenceDictionary(persistenceDict)
gestalt.utilities.vectorAbs(vector)
gestalt.utilities.vectorDivide(vector1, vector2)
gestalt.utilities.vectorInt(vector)
gestalt.utilities.vectorLength(vector)
gestalt.utilities.vectorMCUSign(vector)
gestalt.utilities.vectorMax(vector)
gestalt.utilities.vectorMultiply(vector1, vector2)
gestalt.utilities.vectorSign(vector)

Module contents