def __init__(self, serial_ports=None): # Module name self.moduleName = "moteConnector" # Module signals self.to_MoteProbe = "to_MoteProbe" self.from_MoteProbe = "from_MoteProbe" self.to_MoteParser = "to_MoteParser" self.from_MoteParser = "from_MoteParser" # Store the serial ports self.serial_ports = serial_ports # List to store all moteProbe objects self.moteProbes = [] for serial_port in self.serial_ports: # Creates the MoteProbe moteProbe = MoteProbe.MoteProbe(mote_connector=self.moduleName, serial_port=serial_port) # Appends the MoteProbe to the MoteProbe list self.moteProbes.append(moteProbe) # Connects the MoteProbe with the MoteConnector dispatcher.connect(self._from_MoteProbe, sender=moteProbe.moduleName, signal=moteProbe.from_MoteProbe) # Starts the current MoteProbe moteProbe.start() # Create the MoteParser object self.moteParser = MoteParser.MoteParser(mote_connector=self.moduleName) # Connects the MoteParser with the MoteConnector dispatcher.connect(self._from_MoteParser, sender=self.moteParser.moduleName, signal=self.from_MoteParser)
def __init__(self, mote_connector = None): # Module name self.moduleName = 'moteParser' # Module signals self.from_MoteConnector = 'from_MoteConnector' self.to_MoteConnector = 'to_MoteConnector' self.to_MoteParser = 'to_MoteParser' self.from_MoteParser = 'from_MoteParser' self.to_MainFrame = 'to_MainFrame' # Mote connector self.mote_connector = mote_connector # Connects the MoteProbe with the MoteConnector dispatcher.connect(self._from_MoteConnector, sender = self.mote_connector, signal = self.to_MoteParser)
def __init__(self): # Call constructor QtGui.QWidget.__init__(self) # Module name self.moduleName = 'mainFrame' # Module signals self.to_MainFrame = 'to_MainFrame' # Detect serial ports self.serial_ports = None while(not self.serial_ports): # Create the MoteProbe list, one for each serial port available self.serial_ports = MoteUtils.find_serial_ports() # If no serial ports are available if(not self.serial_ports): error_type = "Warning" error_msg = "No serial port available is available in your system." error_box = QtGui.QMessageBox.warning(self, error_type, error_msg, buttons = QtGui.QMessageBox.Retry | QtGui.QMessageBox.Close) if(error_box == QtGui.QMessageBox.Retry): pass elif(error_box == QtGui.QMessageBox.Close): sys.exit() # Create a MoteConector self.connector = MoteConnector.MoteConnector(serial_ports = self.serial_ports) # Obtain the MoteParser from the MoteConnector self.mote_parser = self.connector.get_parser() # Connects the MainFrame with the MoteParser dispatcher.connect(self._to_MainFrame, sender = self.mote_parser.moduleName, signal = self.to_MainFrame) # Create the widget that contains the frame self.graph = GraphFrame.GraphFrame("") # Arrange the frame horizontally self.layout = QtGui.QHBoxLayout(self) # Add the frame into the layout self.layout.addWidget(self.graph)
def __init__(self, mote_connector = None, serial_port = None): # Call constructor threading.Thread.__init__(self) # Set thread as daemon self.setDaemon(True) # Terminate thread event self._stopEvent = threading.Event() # Serial port name and data rate self.serial_name, self.serial_rate = serial_port self.serial_port = None # Module name self.moduleName = "moteProbe@" + self.serial_name self.from_MoteProbe = 'from_MoteProbe' # Signals self.to_MoteConnector = 'to_MoteConnector' self.from_MoteConnector = 'from_MoteConnector' self.to_MoteProbe = 'to_MoteProbe' self.from_MoteProbe = 'from_MoteProbe' # Mote connector self.mote_connector = mote_connector # HDLC driver self.hdlc = HDLC.HDLC() # Receive variables self.receive_buffer = '' self.is_receiving = False self.rx_byte = 0 self.last_rx_byte = 0 # Transmit variables self.transmit_buffer = '' # Attach the signal from the MoteConnector dispatcher.connect(receiver = self._from_MoteConnector, sender = self.mote_connector, signal = self.to_MoteProbe)