def handleBPM(bpm):
	theBPM = int(bpm)
	GlobalSettings.setBPM(bpm)
	print("BPM: "+str(bpm))
def handleColor(color):
    red, green, blue = rgb(color)
    GlobalSettings.setColor([red,green,blue])
    print("Red: "+str(red)+" Green: "+str(green)+" Blue: "+str(blue))
def handleSpeed(speed):
    theSpeed = float(speed)
    GlobalSettings.setSpeed(speed)
    print("Speed: "+str(theSpeed))
import DatetimeLib
import FileLib
import GlobalSettings
import LogLib
import NumberLib
import PlotLib
import TfLib

############################################################################################################################################################
# block, init
############################################################################################################################################################

harnessStartTime = datetime.datetime.utcnow()

# set up logging
rootResultsDir = GlobalSettings.GlobalSettings_GetRootResultsDir()
thisResultsDir = rootResultsDir + "Tf_Results/"
logResult = LogLib.StartUniqueLog(thisResultsDir)
print("logResult", str(logResult))

LocalPrintAndLogFunc = LogLib.MakeLogBothFunc(logResult['file'])

############################################################################################################################################################

LocalPrintAndLogFunc("SdaeTwo")
LocalPrintAndLogFunc("SdaeTwo harnessStartTime=" + str(harnessStartTime))
rseed = harnessStartTime.microsecond
random.seed(rseed)
np.random.seed(rseed)
LocalPrintAndLogFunc("after setting randomSeed=" + str(rseed))
def handleCommand(command):
    valid = True
    if command == "Flash":
        startRoutine(flash_example.flash,name="Flash")
    elif command == "Stop":
        stop()
        GlobalSettings.inProgress = False
    elif command == "Clear":
        startRoutine(flash_example.clear,name="Clear")
    elif command == "RoundAndRound":
        startRoutine(RoundAndRound.start,name="RoundAndRound")
    elif command == "Snake":
        startRoutine(RoundAndRound.startSnake,name="Snake")
    elif command == "OutsideIn":
        startRoutine(RoundAndRound.outsideIn,name="OutsideIn")
    elif command == "Random":
        startRoutine(flash_example.random,name="Random")
    elif command == "Solid":
        startRoutine(flash_example.solid,name="Solid")
    elif command == "Rainbow":
        startRoutine(flash_example.rainbow,name="Rainbow")
    elif command == "Beauty":
        startRoutine(Beauty.start,name="Beauty")
    elif command == "FourOnTheFloor":
        startRoutine(Dance.fourOnTheFloor,name="Four on the Floor")
    elif command == "AlternatePush":
        startRoutine(Dance.alternatePush,name="Alternate Push")
    elif command == "DownbeatPeaks":
        startRoutine(Dance.downbeatPeaks,name="Downbeat Peaks")
    elif command == "Dart":
        startRoutine(Dance.dart,name="Dart in Four")
    elif command == "Swarm":
        startRoutine(Dance.swarm,name="Swarm")
    elif command == "BrightDark":
        startRoutine(Dance.brightDark,name="Bright-Dark")
    elif command == "Christmas1":
    	startRoutine(Christmas.christmas1,name="Christmas1")
    elif command == "Christmas2":
    	startRoutine(Christmas.christmas2,name="Christmas2")
    elif command == "Christmas3":
    	startRoutine(Christmas.christmas3,name="Christmas3")
    elif command == "ChristmasDance":
    	startRoutine(Christmas.christmasDance,name="ChristmasDance")
    elif command == "Christmas4":
    	startRoutine(Christmas.christmas4,name="Christmas4")
    elif command == "FadeRed":
        startRoutine(Fading.fade_red,name="FadeRed")
    elif command == "FadeGreen":
        startRoutine(Fading.fade_green,name="FadeGreen")
    elif command == "FadeBlue":
        startRoutine(Fading.fade_blue,name="FadeBlue")
    elif command == "RocketCelebrate":
        startRoutine(Rocketz.celebrate,name="Celebrate")
    elif command == "RocketSave":
        startRoutine(Rocketz.epicSave,name="Save")
    elif command == "DCStart":
        startDC();
    elif command == "DCStop":
        stopDC();
    elif command == "OutsideInRemix":
        startRoutine(OutsideInRemix.start,name="OutsideInRemix")
    else:
        print("Unrecognized Command")
        valid = False
    if valid:
    	if command != "DCStart" and command != "DCStop":
			GlobalSettings.setCommand(command)
    print(command)
Exemple #6
0
import urllib
from GoogleAgendaCalendarUtils import GoogleAgendaCalendarUtils
from GoogleAgendaServiceBuilder import BuildGoogleAgendaService
import GlobalSettings
from CamsiCourseParser import CamsiCourseParser
from CamsiCourseToGoogleAgendaConverter import CamsiCourseToGoogleAgendaConverter

__author__ = 'Mattijs Korpershoek'

calendarName = GlobalSettings.GoogleCalendarSettings['calendarName']
timeZone = GlobalSettings.GoogleCalendarSettings['timeZone']
planningUrl = GlobalSettings.CamsiWebSettings['planningUrl']
localFileName = GlobalSettings.CamsiWebSettings['localFileName']

print '[*] Program started with following settings:'
GlobalSettings.printSettings()

service = BuildGoogleAgendaService()
calendarUtils = GoogleAgendaCalendarUtils(service)
myCalendar = calendarUtils.getCalendarIfAlreadyExists(calendarName)

if calendarUtils.isValidCalendar(myCalendar):
    print 'Calender', calendarName, 'already exists! Clearing it ...'
    numberOfItemsCleared = calendarUtils.deleteAllEventsFromCalendar(myCalendar)
    print '[-] Deleted', numberOfItemsCleared, 'item(s) from', calendarName, 'calendar'
else:
    newCalendar = calendarUtils.createNewCalendarFromName(calendarName, timeZone)
    print '[+] Added', calendarName, 'to Google Agenda account'
    myCalendar = newCalendar

print '[*] Downloading new planning file ...'
Exemple #7
0
def listen():
    print("Listening...")
    global bb
    global p
    global client_socket
    server = socket.socket()
    server.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    server.bind(('',4329))
    server.listen(4)
    client_socket, client_address = server.accept()
    while True:
        try:
            received_data = client_socket.recv(8192)
            if not received_data:
                print("Received empty packet from client")
                return
        except socket.error:
            print("Cannot receive data from client")
            return
        #print(received_data)
        jsonData = received_data
        try:
            dataDict = json.loads(jsonData)
        except ValueError:
            write('Malformed Data')
        else:
            left = 0 #Music
            right = 0 #Music
            if 'color' in dataDict:
                color = dataDict['color']
                GlobalSettings.setColor(color)
            if 'speed' in dataDict:
                speed = dataDict['speed']
                GlobalSettings.setSpeed(speed)
            if 'Music' in dataDict:
                left = dataDict['Music'][0]
                right = dataDict['Music'][1]
            if 'command' in dataDict:
                command = dataDict['command']
                if command == 'Flash':
                    startRoutine(flash_example.flash,name="Flash")
                elif command == 'Stop':
                    write("Stopping...")
                    print("Stopping...")
                    stop()
                    GlobalSettings.inProgress = False
                elif command == 'Clear':
                    startRoutine(flash_example.clear,name="Clear")
                elif command == 'RoundAndRound':
                    startRoutine(RoundAndRound.start,name="RoundAndRound")
                elif command == 'Snake':
                    startRoutine(RoundAndRound.startSnake,name="Snake")
                elif command == 'OutsideIn':
                    startRoutine(RoundAndRound.outsideIn,name="OutsideIn")
                elif command == 'Random':
                    startRoutine(flash_example.random,name="Random")
                elif command == "Solid":
                    startRoutine(flash_example.solid,name="Solid")
                elif command == "Rainbow":
                    startRoutine(flash_example.rainbow,name="Rainbow")
                elif command == "DCStart":
                    if GlobalSettings.dynaColor is False:
                        startDC();
                elif command == "DCStop":
                    stopDC();
                elif command == "Music":
                    write("Stopping...")
                    print("Stopping...")
                    stop()
                    write("Showing volume...")
                    print("Showing volume; left: "+str(left)+", right: "+str(right))
                    Music.showVolume(left,right,bb)
                elif command == "Show":
                    onLights = dataDict["onLights"]
                    showPixels(onLights)
                elif command == "OutsideInRemix":
                    startRoutine(OutsideInRemix.start,name="OutsideInRemix")
                else:
                    write('Unrecognized Command\n')
def Qref(Ts,T0) :
    return (Ts - T0)/ThermalImpedances.Rt * (GlobalSettings.kelvin(Tref)/GlobalSettings.kelvin(Ts))**2 * exp(tA * (1./GlobalSettings.kelvin(Ts) - 1./GlobalSettings.kelvin(Tref)))
def unref(qref,Ts) :
    return qref * (GlobalSettings.kelvin(Ts)/GlobalSettings.kelvin(Tref))**2 * exp(tA * (1./GlobalSettings.kelvin(Tref) - 1./GlobalSettings.kelvin(Ts)))
import serial
import GlobalSettings as GS
#import bluetooth
try:
    if GS.Settings['ComMode'] == "USB":
        from USBSerialSend import *
    if GS.Settings['ComMode'] == "Bluetooth":
        from BTSerialSend import *
except KeyError:
    GS.Settings['ComMode'] = "USB"
    print("assuming USB connection")
    from USBSerialSend import *
    GS.save_settings()

#simply import this, and use the following commands
#Connect("pp5x4")
#SerialSend(port,power)



#ser = serial.Serial(GS.Settings['port'],19200)#which baud rates