コード例 #1
0
    def __init__(self, *args):
        options = ([("Undisclosed", "none"), ("Male", "male"),
                    ("Female", "female")])

        default = "none"

        Radio.__init__(self, options, default, *args)
コード例 #2
0
    def __init__(self, *args):
        options = ([
            ("Yes", 1),
            ("No",  0)
        ])

        default = 1

        Radio.__init__(self, options, default, *args)
コード例 #3
0
ファイル: Gender.py プロジェクト: javachengwc/many-ql
    def __init__(self, *args):
        options = ([
            ("Undisclosed", "none"),
            ("Male",  "male"),
            ("Female", "female")
        ])

        default = "none"

        Radio.__init__(self, options, default, *args)
コード例 #4
0
def RADIO_ENABLE():
    global radioDisabled
    global radio
    if radio is None:
        print("========================Radio start!=======================")
        radio = Radio(0.5, 0.001)
        sounds = [('harp.wav',40.0,80.0), ('island_music_x.wav',120.0,160.0), ('sounds/radioSolveKey.wav',200.0,240.0)]
        radio.init_sounds(sounds, 'noize.wav')
        radio.start()
    radioDisabled = False
コード例 #5
0
    def checkRadioRegisteration(self, msg, rmsg, timeval):
        r = self.Radios.checkIP(msg.sourceIP, return_type=Radio.object)
        print("%s: msg: %s  recived from %s return port %s" %
              (timeval, msg.command(), msg.sourceIP, msg.sourcePort))
        if r == None:
            r = Radio(RadioIP=msg.sourceIP, RadioIDtext=msg.RadioID(0))
            self.Radios.append(r)

            print("Radio %s with IP address %s add to List of Active Radios" %
                  (r.RadioIDtext(0), r.RadioIP(0)))
            rmsg.set_extra(rmsg.extra(0) + " Added to list of Active Radios")
        if r.SignedIn() == False:
            print("Radio %s not sign in with user!")
            rmsg.set_extra(rmsg.extra(0) + " Please Sign radio in!")

        return rmsg
コード例 #6
0
ファイル: Node.py プロジェクト: juhgarca/GarcaSimulator
 def __init__(self, _id, state='alive'):
     self._id = _id
     self.radio = Radio()
     self.state = state
     self.battery = Battery()
     self.ger_consumo = Consumo()
     self.pos_x = np.random.uniform(0, config.AREA_WIDTH)
     self.pos_y = np.random.uniform(0, config.AREA_LENGHT)
コード例 #7
0
ファイル: Radio.py プロジェクト: hpvdt/eta_prime
 def Receive(self):
     # TODO: Make more realistic outputs for this. Maybe add some randomness.
     #       t, speedKph, targetSpeedKph, cadence, distance, batteryPercentage, emergency
     time.sleep(1)
     random_offset = random.uniform(0, 10)
     return OriginalRadio.CommaSeparate(time.strftime("%H:%M:%S"),
                                        70 + random_offset, 80,
                                        60 + random_offset, 1.2,
                                        80 + random_offset, 0)
コード例 #8
0
ファイル: PetState.py プロジェクト: fkoehne/pixel-pet
    def __init__(self, sense):
        self.sense = sense
        self.FACE = 1, RobotFace(sense)
        self.RADIO = 2, Radio(sense)
        self.LIFE = 3, Life(sense, 8, 8)
        self.MUSICPLAYER = 4, MusicPlayer(sense)

        self.stateList = (self.FACE, self.RADIO, self.LIFE, self.MUSICPLAYER)

        # Start with some state
        self.current = self.MUSICPLAYER
        self.current[1].select()
コード例 #9
0
    def cargar_radios(self):
        # se llama al iniciar la actividad y al agregar o eliminar una radio

        for child in self.caja_radios:
            self.caja_radios.remove(child)

        radios = self.BasedeDatos.CargarRadios(
        )  # Devuelve una lista de tuplas
        self.listaderadios = []

        for radio in radios:
            self.listaderadios.append(Radio(radio, self.directoriodeiconos))

        for radio in self.listaderadios:
            radio.connect("button_press_event", self.handler_click_Radio)
            self.caja_radios.pack_start(radio, True, True, 5)
コード例 #10
0
def PatchWerk(config, options):

    dbUser   = config.get('database', 'user')
    dbPasswd = config.get('database', 'password')
    dbHost   = config.get('database', 'host')
    dbName   = config.get('database', 'dbname')
    dbI      = DbInterface(dbUser, dbPasswd, dbName, dbHost)

    log = Logger(dbI, options.verbose)

    #create mixing/streaming patch
    radio = Radio(config, options, dbI, log)
    radio.pause(1)
    
    #register handler for SIGTERM
    signal.signal(signal.SIGTERM, radio.terminate)

    #register handler for SIGINT
    signal.signal(signal.SIGINT, radio.terminate)
    
    #check that pure data is running fine
    if radio.check_pd():
        #register status with DB and turn DSP on
        radio.all_ok()
    else:
        sys.exit(1)
    
    #start streaming
    radio.streaming_setup()
    
    while True:
        #check to see if the control state is paused or not
        radio.control_check()

        #tell master PD to create the new patch
        radio.new_patch()
        
        if radio.loadError:
            #call function to deal with loading error
            radio.loading_error()
            
        else:
            #turn the DSP in the new patch on
            radio.activate_patch()
            
            #fade over to new patch
            radio.crossfade()
            
            #kill off old patch
            radio.kill_old_patch()
            
            #pause untill next patch needs to be loaded
            radio.play()
コード例 #11
0
            'Exiting application due to {0} event'.format(sig_num))
        hap_publisher.stop()
        api_manager.stop()
        update_scheduler.stop()


#register the signal handler for SIGINT and SIGTERM
signal.signal(signal.SIGINT, signal_handler)
main_logger.debug('Add handler for SIGINT event')
signal.signal(signal.SIGTERM, signal_handler)
main_logger.debug('Add handler for SIGTERM event')

try:
    main_logger.debug('Initializing components')
    #initialize radio instance
    radio = Radio(db.table('radio-stations'))
    main_logger.debug('Create {0} instance'.format(Radio.__name__))
    #initialize radio REST API controller
    radio_api_controller = RadioApiController(radio)
    main_logger.debug('Create {0} instance'.format(
        RadioApiController.__name__))
    #initialize radio buttons controller
    radio_buttons_controller = RadioButtonController(radio)
    main_logger.debug('Create {0} instance'.format(
        RadioButtonController.__name__))
    #initialize updaters
    sensor_updater = SensorUpdater(
        db.table('sensors-compensation').get(doc_id=1))
    main_logger.debug('Create {0} instance'.format(SensorUpdater.__name__))
    database_updater = DatabaseUpdater(
        db.table('influxdb-connection').get(doc_id=1), sensor_updater)
コード例 #12
0
ファイル: main.py プロジェクト: captbrogers/DigitalNightstand
# END: loop()

frontend = WebFrontend(port=config.WEB_FRONTENT_PORT)
frontend.serve()

settings_data = config.SETTINGS

radio_channels = None

with open(radio_config) as data_file:
    radio_data = json.load(data_file)

if "channels" in radio_data:
    radio_channels = radio_data['channels']

p = Radio(radio_channels=radio_channels, mplayer_path=config.MPLAYER_PATH)
if "radio" in settings_data:
    _radio_settings = settings_data['radio']
    p.change_country(_radio_settings['country'])
    if "radio_stations" in _radio_settings and len(
            _radio_settings['radio_stations']) > 0:
        p.radio_channels.extend(_radio_settings['radio_stations'])

web_frontend.radio = p
alarm = Alarm("res/sounds/Argon_48k.wav", settings=settings_data)
alarm.create_alarms()

web_frontend.alarm = alarm

last_state = config.load_last_state()
if last_state is not None:
コード例 #13
0
class Drone():

    __rotas = []
    __helices = 4
    __bateria = Bateria(False)
    __microfone = Microfone(True)
    __acelerometro = Acelerometro(False)
    __proximidade = Proximidade(False)
    __quimico = Quimico(True)
    __movimento = Movimento(True)
    __radio = Radio(True)

    def __init__(self):
        self.__modulo = Modulos()
        self.__modulo.setup()

    def getBateria(self):
        return self.__bateria

    def getMicrofone(self):
        return self.__microfone

    def getAcelerometro(self):
        return self.__acelerometro

    def getProximidade(self):
        return self.__proximidade

    def getQuimico(self):
        return self.__quimico

    def getMovimento(self):
        return self.__movimento

    def getRadio(self):
        return self.__radio

    def getVoo(self):
        return self.__voo

    def setRotas(self, latitude, longitude):
        self.__rotas.insert(self.__rotas.__len__(), [latitude, longitude])

    def setup(self):
        self.__modulo.setDrone(self)

    def run(self, i):
        if (i == -1):
            for i in range(1, 7):
                self.__modulo.getAbastecimento().abastecer()
                self.__modulo.getVoo().decolar()
                if (not self.getAcelerometro().check()):
                    if (self.getBateria().getLigado()):
                        self.__modulo.getVoo().irPara(self.__rotas[i][0],
                                                      self.__rotas[i][1])
                else:
                    self.__modulo.getVoo().pousar()
                    break
                self.__modulo.getVoo().pousar()
        else:
            self.__modulo.getAbastecimento().abastecer()
            self.__modulo.getVoo().decolar()
            if (not self.getAcelerometro().check()):
                if (self.getBateria().getLigado()):
                    self.__modulo.getVoo().irPara(self.__rotas[i][0],
                                                  self.__rotas[i][1])

            self.__modulo.getVoo().pousar()
コード例 #14
0
    def checkID(self, RID, return_type=Radio.object):
        i = 0
        for o in self.Radios:
            if o.ID==RID:
                if return_type==Radio.index:
                    return i
                elif return_type==Radio.object:
                    return o
                elif return_type==Radio.IP:
                    return o.IP
                elif return_type==Radio.Name:
                    return o.Name
            i += 1
        return None

    def sort(self):
        self.Radios = sorted(self.Radios, key=self.sort_key_Radio_ID)

    def sort_key_Radio_ID(self, i):
        return i._RadioID

if __name__ == "__main__":
    R = Radios()
    r = Radio(RadioID='PR0001', RadioIP='192.168.1.17')
    i =0
    while i<4:
        if R.checkIP(r.RadioIP())==None:
            R.append(r)
        i += 1
    print(len(R))
    print("Done")
コード例 #15
0
ファイル: main.py プロジェクト: alni/DigitalNightstand
# END: loop()

frontend = WebFrontend(port=config.WEB_FRONTENT_PORT)
frontend.serve()

settings_data = config.SETTINGS

radio_channels = None

with open(radio_config) as data_file:
    radio_data = json.load(data_file)

if "channels" in radio_data:
    radio_channels = radio_data['channels']

p = Radio(radio_channels=radio_channels, mplayer_path=config.MPLAYER_PATH)
if "radio" in settings_data:
    _radio_settings = settings_data['radio']
    p.change_country(_radio_settings['country'])
    if "radio_stations" in _radio_settings and len(_radio_settings['radio_stations']) > 0:
        p.radio_channels.extend(_radio_settings['radio_stations'])

web_frontend.radio = p
alarm = Alarm("res/sounds/Argon_48k.wav", settings=settings_data)
alarm.create_alarms()

web_frontend.alarm = alarm

last_state = config.load_last_state()
if last_state is not None:
    p.set_channel(last_state["last_radio_station"])
コード例 #16
0
# Class: 1321L
# Sec: 02
# Lab: Python
# Term: Fall 2018
# Instructor: Malcolm
# Name: Ly Pham

from Radio import Radio
radio1 = Radio()
radio1.turnOn(True)
print('Turn radio on:','\n',str(radio1.toString()))

radio1.turnOn(True)
radio1.volumeUp(3)
print('Turn volume up by 3:','\n',str(radio1.toString()))

radio1.turnOn(True)
radio1.stationUp(5)
print('Move station up by 5:','\n',str(radio1.toString()))

radio1.turnOn(True)
radio1.volumeDown(1)
print('Turn volume down by 1:','\n',str(radio1.toString()))

radio1.turnOn(True)
radio1.stationUp(3)
print('Move station up by 3:','\n',str(radio1.toString()))

radio1.turnOff(True)
print('Turn radio off.','\n',str(radio1.toString()))
コード例 #17
0
import os
from Error import Error
from Scene import Scene 
from Light import Light
from Radio import Radio
from Vegetables import Vegetables
from Wheel import Wheel

error = Error()
scene = Scene()
light = Light()
radio = Radio()
vegetables = Vegetables()
wheel = Wheel()

class Consumer:

	def __init__(self):
		print("init consumers")

	def new_data(self, dic):
		if dic["type"].lower() == "scene":
			print "it's Scene"
			scene.new_data(dic)

		elif dic["type"].lower() == "light":
			print "it's Light"
			light.new_data(dic)

		elif dic["type"].lower() == "radio":
			print "it's Radio"
コード例 #18
0
#############
# Constants
#############
CADENCE_PIN = 31  # GPIO.BOARD
SPEED_PIN = 29  # GPIO.BOARD
UPDATE_INTERVAL = 0.5  # Target amount of time between OSD updates
TX_INTERVAL = 3  # Time between radio transmits

#############
# Setup
#############
cadenceModule = Cadence(CADENCE_PIN)
speedAndDistanceModule = SpeedAndDistance(SPEED_PIN)
osdModule = Osd()
radioModule = Radio(1, 2)
batteryModule = Battery()

txIntervalCount = 0

emergency = 0

logFileName = "{}.log".format(time.strftime('%y%m%d-%H%M%S', time.localtime()))
logFile = open(logFileName, "w+")

#############
# Main
#############
try:
    while True:
        start_time = time.clock()
コード例 #19
0
ファイル: Main.py プロジェクト: GMIG/SchoolExhibit
        def begin(arduino: ArduinoUniversal):
            #arduino.ang.alpha(0.9)
            #arduino.rot.alpha(0.2)

            #arduino.ang.stop()
            #arduino.rad.stop()
            root = BaseTkContainer()
            tksupport.install(root.tk_instance)
            vlc_instance: vlc.Instance = vlc.Instance()
            print(vlc_instance.audio_output_enumerate_devices())

            main_scene = MainScene(root.tk_instance, "1920x1080+0+0",
                                   vlc_instance)
            #main_scene = MainScene(root.tk_instance, "500x509+0+0", vlc_instance)
            arduino.outs.allOff()
            arduino.outs.allFad(5)

            step = 0.02

            def fade(dt: int, from_b: float, to_b: float):
                current_brightness = from_b
                brightness_k = (to_b - from_b) / dt

                def setLedBrightness():
                    nonlocal current_brightness, brightness_k
                    current_brightness += step * brightness_k
                    if (current_brightness < to_b + step) and (
                            current_brightness > to_b - step):
                        current_brightness = to_b
                        fade_looper.stop()
                    arduino.outs.allSet(int(round(current_brightness * 255)))

                fade_looper = LoopingCall(setLedBrightness)
                fade_looper.start(step)

            #fade(1,0,1)

            def transition_to_main(num: int, led_name: str, from_scene: Scene,
                                   *vargs, **kwargs):
                main_scene.start_video(num)
                #[scene.activate() for scene in scenes]
                #from_scene.deactivate()
                arduino.outs.allFad(0)
                arduino.outs.allOff()
                arduino.outs.setFad(led_name + ",7")
                #arduino.outs.on(led_name)

            def to_main(num: int, led_name: str, from_scene: Scene, *vargs,
                        **kwargs) -> Callable:
                return partial(transition_to_main, num, led_name, from_scene,
                               *vargs, **kwargs)

            def setupTrigger(name: str,
                             num: int,
                             led_name: str,
                             on_what: str = "event"):
                trg = Trigger(name, arduino)
                trg.add_listener(on_what, to_main(num, led_name, trg))
                return trg

            scenes = []

            scenes.append(setupTrigger("shl", 1, "shl"))
            scenes.append(setupTrigger("vkl", 2, "vkl"))
            scenes.append(setupTrigger("bor", 3, "bo"))
            scenes.append(setupTrigger("alb", 4, "alb", "1"))
            scenes.append(setupTrigger("bin", 5, "bin"))

            naidenov = VolumeNaidenov()
            naidenov.on_volume(to_main(6, "vol", naidenov))
            arduino.on_vol(naidenov.dynamic_rotation)
            scenes.append(naidenov)

            ringer = Ringer()
            ringer.on_ring_end(to_main(7, "rin", ringer))
            arduino.on_rin(ringer.button)
            scenes.append(ringer)

            scenes.append(setupTrigger("box", 8, "box", "1"))

            radio = Radio()
            arduino.on_rad(radio.set_frequency)
            radio.on_death(to_main(9, "rad", radio))
            scenes.append(radio)

            scenes.append(setupTrigger("tel", 10, "tel", "1"))
            scenes.append(setupTrigger("fot", 11, "fot", "0"))
            scenes.append(setupTrigger("kom", 12, "kom"))
            scenes.append(setupTrigger("lif", 13, "lif", "1"))
            scenes.append(setupTrigger("fan", 14, "fan", "1"))

            golubeva = ScreenGolubeva()
            golubeva.on_sign(to_main(15, "sig", golubeva))
            scenes.append(golubeva)

            [scene.activate() for scene in scenes]

            def switch_all_off(*args, **kwargs):
                [scene.deactivate() for scene in scenes]

            def switch_all_on(*args, **kwargs):
                [scene.activate() for scene in scenes]
                arduino.outs.allFad(5)

            main_scene.on_started_video(switch_all_off)
            main_scene.on_started_titles(switch_all_on)

            def on_press(key):
                if key == keyboard.Key.space:
                    main_scene.stop_video()

            listener = keyboard.Listener(on_press=on_press)
            listener.start()
コード例 #20
0
from random import random
from numpy import array, append
import matplotlib
matplotlib.use('tkagg')
import matplotlib.pyplot as plt
from matplotlib import style
from matplotlib.widgets import Button
import os

#############
# Initialization
#############
logFileName = "{}.log".format(time.strftime('%y%m%d-%H%M%S', time.localtime()))
logFile = open(logFileName, "w+")

radio = Radio(2, 1)

timeList = array([0])
speedKphList = array([0])
speedMphList = array([0])
targetSpeedKphList = array([0])
targetSpeedMphList = array([0])
cadenceList = array([0])
distanceList = array([0])

#TODO: Ideally the receive function would try to decode as many values as
# possible and use the ones that are correct to partially update the graph.


def receive_value():
    invalidValue = True
コード例 #21
0
 def checkIPinList(self, msgAndAddress):
     r = self.Radios.checkIP(msgAndAddress[1][0], Radio.object)
     if not r:
         r = Radio()