Exemplo n.º 1
0
 def __init__(self, **kwargs):
     super(VirtualSim, self).__init__(**kwargs)
     #open a serial port for controller to hook into
     self.ser = SerialInterface()
     #display the name of the serial port to hook into
     self.ids.serial_label.text = self.ser.get_port_name()
     #set up a timer to regularly check for incoming commands over the serial port
     self.cmd_check = Clock.schedule_interval(self.check_for_commands, 1/10)
Exemplo n.º 2
0
    def __init__(self, util=None, standalone=False):
        """ Initializer
        
        :param util: utility object
        :param standalone: True - standalone version, False - part of Peppy player
        """
        ScreensaverMeter.__init__(self)
        if util:
            self.util = util
        else:
            self.util = MeterUtil()

        use_vu_meter = getattr(self.util, USE_VU_METER, None)
        self.name = "peppymeter"

        base_path = "."
        if __package__:
            pkg_parts = __package__.split(".")
            if len(pkg_parts) > 0:
                base_path = os.path.join(os.getcwd(), "screensaver", self.name)

        parser = ConfigFileParser(base_path)
        self.util.meter_config = parser.meter_config
        self.outputs = {}

        if standalone:
            if self.util.meter_config[USE_LOGGING]:
                logging.basicConfig(level=logging.NOTSET)
            else:
                logging.disable(logging.CRITICAL)

        # no VU Meter support for Windows
        if "win" in sys.platform and self.util.meter_config[DATA_SOURCE][
                TYPE] == SOURCE_PIPE:
            self.util.meter_config[DATA_SOURCE][TYPE] = SOURCE_NOISE

        self.data_source = DataSource(self.util)
        if self.util.meter_config[DATA_SOURCE][
                TYPE] == SOURCE_PIPE or use_vu_meter == True:
            self.data_source.start_data_source()

        if self.util.meter_config[OUTPUT_DISPLAY]:
            self.meter = self.output_display(self.data_source)

        if self.util.meter_config[OUTPUT_SERIAL]:
            self.outputs[OUTPUT_SERIAL] = SerialInterface(
                self.util.meter_config, self.data_source)

        if self.util.meter_config[OUTPUT_I2C]:
            self.outputs[OUTPUT_I2C] = I2CInterface(self.util.meter_config,
                                                    self.data_source)

        if self.util.meter_config[OUTPUT_PWM]:
            self.outputs[OUTPUT_PWM] = PWMInterface(self.util.meter_config,
                                                    self.data_source)

        self.start_interface_outputs()
Exemplo n.º 3
0
class VirtualSim(FloatLayout):
    def __init__(self, **kwargs):
        super(VirtualSim, self).__init__(**kwargs)
        #open a serial port for controller to hook into
        self.ser = SerialInterface()
        #display the name of the serial port to hook into
        self.ids.serial_label.text = self.ser.get_port_name()
        #set up a timer to regularly check for incoming commands over the serial port
        self.cmd_check = Clock.schedule_interval(self.check_for_commands, 1/10)

    def check_for_commands(self, dt):
        while (self.ser.has_packets()):
            cmd = self.ser.get_next_packet()
            #print "received: "+str([hex(ord(c)) for c in cmd])
            self.ids.node_field.process_cmd(ord(cmd[1]), cmd[2:])

    def gen_adjacencies(self):
        #print self.ids.node_field.gen_adjacencies()
        self.ids.node_field.pause_sim()
Exemplo n.º 4
0
    def __init__(self, util=None, standalone=False):
        """ Initializer
        
        :param util: utility object
        :param standalone: True - standalone version, False - part of Peppy player
        """
        ScreensaverMeter.__init__(self)
        if util:
            self.util = util
        else:
            self.util = MeterUtil()

        try:
            self.use_vu_meter = self.util.config[USAGE][USE_VU_METER]
        except:
            self.use_vu_meter = False

        self.name = "peppymeter"

        base_path = "."
        if __package__:
            pkg_parts = __package__.split(".")
            if len(pkg_parts) > 0:
                base_path = os.path.join(os.getcwd(), "screensaver", self.name)

        parser = ConfigFileParser(base_path)
        self.util.meter_config = parser.meter_config
        self.outputs = {}

        if standalone:
            if self.util.meter_config[USE_LOGGING]:
                log_handlers = []
                try:
                    log_handlers.append(logging.StreamHandler(sys.stdout))
                    log_handlers.append(
                        logging.FileHandler(filename="peppymeter.log",
                                            mode='w'))
                    logging.basicConfig(
                        level=logging.NOTSET,
                        format=
                        '[%(asctime)s] {%(filename)s:%(lineno)d} %(levelname)s - %(message)s',
                        handlers=log_handlers)
                except:
                    pass
            else:
                logging.disable(logging.CRITICAL)

        # no VU Meter support for Windows
        if "win" in sys.platform and self.util.meter_config[DATA_SOURCE][
                TYPE] == SOURCE_PIPE:
            self.util.meter_config[DATA_SOURCE][TYPE] = SOURCE_NOISE

        self.data_source = DataSource(self.util)
        if self.util.meter_config[DATA_SOURCE][
                TYPE] == SOURCE_PIPE and self.use_vu_meter == True:
            self.data_source.start_data_source()

        if self.util.meter_config[OUTPUT_DISPLAY]:
            self.meter = self.output_display(self.data_source)

        if self.util.meter_config[OUTPUT_SERIAL]:
            self.outputs[OUTPUT_SERIAL] = SerialInterface(
                self.util.meter_config, self.data_source)

        if self.util.meter_config[OUTPUT_I2C]:
            self.outputs[OUTPUT_I2C] = I2CInterface(self.util.meter_config,
                                                    self.data_source)

        if self.util.meter_config[OUTPUT_PWM]:
            self.outputs[OUTPUT_PWM] = PWMInterface(self.util.meter_config,
                                                    self.data_source)

        self.start_interface_outputs()
Exemplo n.º 5
0
 def __init__(self, **kwargs):
     super(Controller, self).__init__(**kwargs)
     self.comm = SerialInterface('/dev/tty.usbmodem1782091')