Esempio n. 1
0
def init_radiobot(config_file):
    """
        Initialize the different radiobot components :
        - Configuration loader, which will parse the json conf file and check
          attributes conformity
        - Display Manager, which is in charge of controling the LCD screen 
          and all the display behaviors (timers and so on)
        - Player manager, which is in charge of controlling VLC and Alsa 
          (starting and stoping network streams, applying volume modifications)
        - Radio manager, which is the overall manager, in charge of radio 
          selection and communication between the display and the player. 
    """
    global displayManager, configLoader, radioManager, playerManager

    # Loading GPIO configuration
    configure_GPIO()

    try:  # Trying to load configuration file
        configLoader = ConfigLoader(config_file)
        configLoader.parse_config_file()
        print("Configuration file loaded successfully")
    except Exception as e:
        print("Invalid configuration : " + str(e))
        print("Exciting.")
        sys.exit(2)

    # Loading display manager
    displayManager = DisplayManager(
        serial.Serial(configLoader.serial_device,
                      configLoader.serial_baud_rate,
                      timeout=1), configLoader.name, configLoader.halt_message,
        configLoader.volume_timer, configLoader.scroll_time_interval,
        configLoader.scroll_time_pause)
    displayManager.start()

    # Loading player
    playerManager = PlayerManager(configLoader.volume)

    # Loading the radio manager
    radioManager = RadioManager(configLoader.radios, configLoader.volume,
                                configLoader.volume_step,
                                configLoader.radio_info_check_interval,
                                configLoader.full_radio_name_pause,
                                configLoader.radio_indice, playerManager,
                                displayManager)

    # Declare radiobot "ready"
    set_as_ready()

    # Starting first radio
    radioManager.play_radio()
Esempio n. 2
0
def main():
    qApp = QtWidgets.QApplication(sys.argv)
    backend = Backend()
    configLoader = ConfigLoader()
    window = uis.MainWindow(backend, configLoader)

    backend.register_instrument(vna.Config, vna.Driver)
    configLoader.registerInstrument(vna.Config)
    window.registerInsturmentType(
        "Vna", vna.DataWindow, vna.ConfigWindow,
        QIcon(getResourcePath('images/networkAnalyser.png')),
        vna.Config({
            'model': 'simulated',
            'segments': {
                'TM010': {
                    'type': 'Electric',
                    'f0': 2500700000.0,
                    'span': 1000000.0,
                    'points': 201,
                    'ifbw': 1000.0,
                    'power': 0.0
                }
            }
        }))
    backend.register_instrument(visaScript.Config, visaScript.Driver)
    configLoader.registerInstrument(visaScript.Config)
    window.registerInsturmentType(
        "visaScript", visaScript.DataWindow, visaScript.ConfigWindow,
        QIcon(getResourcePath('images/dcSupply.png')),
        visaScript.Config({'script': 'record_wait()\nlog("Record start")'}))

    backend.register_instrument(datalogger.Config, datalogger.Driver)
    configLoader.registerInstrument(datalogger.Config)
    window.registerInsturmentType(
        "Data Logger", datalogger.DataWindow, datalogger.ConfigWindow,
        QIcon(getResourcePath('images/dcSupply.png')),
        datalogger.Config({'model': '1365'}))
    window.show()

    if (len(sys.argv) > 1):
        window.openConfig(sys.argv[1])

    sys.exit(qApp.exec_())