def initInterfaces(self):
     if self.providedInterface:
         self.fabnet = self.providedInterface  #providedInterface is defined in the virtualMachine class.
     else:
         self.fabnet = interfaces.gestaltInterface(
             'FABNET',
             interfaces.serialInterface(baudRate=115200,
                                        interfaceType='ftdi',
                                        portName='/dev/ttyUSB1'))
Ejemplo n.º 2
0
	def initInterfaces(self):
		if self.providedInterface: self.fabnet = self.providedInterface		#providedInterface is defined in the virtualMachine class.
		else: self.fabnet = interfaces.gestaltInterface('FABNET', interfaces.serialInterface(baudRate = 115200, interfaceType = 'ftdi', portName = '/dev/tty.usbserial-FTXW9L60'))
Ejemplo n.º 3
0
	def __init__(self, name = None, interface = None, filename = None, URL = None, module = None, persistence = lambda:None, **kwargs):
		'''	Initialization procedure for Gestalt Node Shell.
			
			name:		a unique name assigned by the user. This is used by the persistence algorithm to re-acquire the node.
			interface: 	the object thru which the virtual node communicates with its physical counterpart.
			**kwargs:	any additional arguments to be passed to the node during initialization
			
			Methods of Loading Virtual Node:
				filename: an import-able module containing the virtual node.
				URL: a URL pointing to a module as a resource containing the virtual node.
				module: a python module name containing the virtual node.
		
			Networked/Gestalt virtual nodes initialize by associating with their counterparts over the network. A URL pointing to their driver is 
			returned upon association. This driver is then loaded into the shell as the virtual node.
		'''

		#call base class __init__ method
		super(gestaltNodeShell, self).__init__()	#call init on baseNodeShell
		
		#assign parameters to variables
		self.name = name
		self.filename = filename
		self.URL = URL
		self.module = module
		self.persistence = persistence
		
		#connect to interface
		if interface:
			#make sure that node has a gestalt interface
			if type(interface) != interfaces.gestaltInterface:
				#wrap a gestalt interface around the provided interface
				self.interface.set(interfaces.gestaltInterface(interface = interface, owner = self), self)
			else: self.interface.set(interface, self)	#interface isn't shared with other nodes, so owner is self.		
		
			#import base node
			self.setNode(baseStandardGestaltNode())		
			
			if self.persistence(): address = self.persistence.get(self.name)
			else: address = None
			
			if address:	#an IP address was found
				self.interface.assignNode(self.node, address)	#assign node to interface with IP address
				nodeURL = self.node.urlRequest()	#get node URL
			else: #acquire node
				#set node IP address	-- this will be changed later once persistence is added
				address = self.generateIPAddress()	#generate random IP address
				self.interface.assignNode(self.node, address)	#assign node to interface with IP address	
				if type(self) == networkedGestaltNode: notice(self, "please identify me on the network.")
				nodeURL = self.node.setIPRequest(address)	#set real node's IP address, and retrieve URL.		
				if self.persistence(): self.persistence.set(self.name, address)
				
			notice(self, nodeURL)
	
			#try to start node in application mode
			nodeStatus, appValid = self.statusRequest()
			if nodeStatus == 'B' and appValid:	#node is in bootloader mode and application is valid
				if self.runApplication():	#need to reinitialize
					nodeURL = self.urlRequest()
					notice(self, " NOW RUNNING IN APPLICATION MODE")
					notice(self, nodeURL)	#remove
				else:
					notice(self, "ERROR STARTING APPLICATION MODE")
			elif nodeStatus == 'A': notice(self, "RUNNING IN APPLICATION MODE")
			else: notice(self, " RUNNING IN BOOTLOADER MODE")
			
		else:
			#No interface, this can be intentional to allow debugging offline
			notice(self, 'Error - please provide an interface.')		

		#acquire virtual node.
		#if a virtual node source is provided, use that. Otherwise acquire from URL provided by node.
		if filename:
			if not self.loadNodeFromFile(filename, **kwargs): return
		#load via URL
		elif URL:
			if not self.loadNodeFromURL(URL, **kwargs): return
		#load via module
		elif module:
			if not self.loadNodeFromModule(module, **kwargs): return
		#get URL from node
		else:
			if not self.loadNodeFromURL(nodeURL): return
		
		if interface:	
			#assign new node with old IP address to interface. This replaces the default node with the imported node.
			self.interface.assignNode(self.node, address)
Ejemplo n.º 4
0
from pygestalt.Nodes import printrboard
from pygestalt import nodes
from pygestalt.Nodes import dummyNode
from pygestalt import interfaces

#myPrintrboard = nodes.soloIndependentNode(name = 'myPrintrboard', module = printrboard)
#gsArduino = nodes.soloGestaltNode(name = 'gsArduino1')

myInterface = interfaces.gestaltInterface('myInterface', interfaces.serialInterface(baudRate = 115200, interfaceType = 'ftdi', portName = '/dev/tty.usbserial-FTVG67VT'))
myFabUnit = nodes.networkedGestaltNode('myFabUnit', myInterface, module = dummyNode)

#gsArduino = nodes.soloGestaltNode(name = 'gsArduino', interface = interfaces.serialInterface(baudRate = 76800, interfaceType = 'lufa', 
#																								portName = "/dev/tty.usbmodemfa131"), module = dummyNode)

#gsArduino.identifyRequest()

#print gsArduino.urlRequest()
Ejemplo n.º 5
0
    def __init__(self,
                 name=None,
                 interface=None,
                 filename=None,
                 URL=None,
                 module=None,
                 persistence=lambda: None,
                 **kwargs):
        '''	Initialization procedure for Gestalt Node Shell.
			
			name:		a unique name assigned by the user. This is used by the persistence algorithm to re-acquire the node.
			interface: 	the object thru which the virtual node communicates with its physical counterpart.
			**kwargs:	any additional arguments to be passed to the node during initialization
			
			Methods of Loading Virtual Node:
				filename: an import-able module containing the virtual node.
				URL: a URL pointing to a module as a resource containing the virtual node.
				module: a python module name containing the virtual node.
		
			Networked/Gestalt virtual nodes initialize by associating with their counterparts over the network. A URL pointing to their driver is 
			returned upon association. This driver is then loaded into the shell as the virtual node.
		'''

        #call base class __init__ method
        super(gestaltNodeShell, self).__init__()  #call init on baseNodeShell

        #assign parameters to variables
        self.name = name
        self.filename = filename
        self.URL = URL
        self.module = module
        self.persistence = persistence

        #connect to interface
        if interface:
            #make sure that node has a gestalt interface
            if type(interface) != interfaces.gestaltInterface:
                #wrap a gestalt interface around the provided interface
                self.interface.set(
                    interfaces.gestaltInterface(interface=interface,
                                                owner=self), self)
            else:
                self.interface.set(
                    interface, self
                )  #interface isn't shared with other nodes, so owner is self.

            #import base node
            self.setNode(baseStandardGestaltNode())

            if self.persistence(): address = self.persistence.get(self.name)
            else: address = None

            if address:  #an IP address was found
                self.interface.assignNode(
                    self.node,
                    address)  #assign node to interface with IP address
                nodeURL = self.node.urlRequest()  #get node URL
            else:  #acquire node
                #set node IP address	-- this will be changed later once persistence is added
                address = self.generateIPAddress()  #generate random IP address
                self.interface.assignNode(
                    self.node,
                    address)  #assign node to interface with IP address
                if type(self) == networkedGestaltNode:
                    notice(self, "please identify me on the network.")
                nodeURL = self.node.setIPRequest(
                    address)  #set real node's IP address, and retrieve URL.
                if self.persistence(): self.persistence.set(self.name, address)

            notice(self, nodeURL)

            #try to start node in application mode
            nodeStatus, appValid = self.statusRequest()
            if nodeStatus == 'B' and appValid:  #node is in bootloader mode and application is valid
                if self.runApplication():  #need to reinitialize
                    nodeURL = self.urlRequest()
                    notice(self, " NOW RUNNING IN APPLICATION MODE")
                    notice(self, nodeURL)  #remove
                else:
                    notice(self, "ERROR STARTING APPLICATION MODE")
            elif nodeStatus == 'A':
                notice(self, "RUNNING IN APPLICATION MODE")
            else:
                notice(self, " RUNNING IN BOOTLOADER MODE")

        else:
            #No interface, this can be intentional to allow debugging offline
            notice(self, 'Error - please provide an interface.')

        #acquire virtual node.
        #if a virtual node source is provided, use that. Otherwise acquire from URL provided by node.
        if filename:
            if not self.loadNodeFromFile(filename, **kwargs): return
        #load via URL
        elif URL:
            if not self.loadNodeFromURL(URL, **kwargs): return
        #load via module
        elif module:
            if not self.loadNodeFromModule(module, **kwargs): return
        #get URL from node
        else:
            if not self.loadNodeFromURL(nodeURL): return

        if interface:
            #assign new node with old IP address to interface. This replaces the default node with the imported node.
            self.interface.assignNode(self.node, address)