counter = 1


meter.disableStepper() # prevent the motor for burning up
while True:
    print "\n1: Run Schedule"
    print "2: Manage Schedules"
    print "3: Exit"
    option = int(raw_input("\nPlease select an option.\n"))

    #run schedule: set midnight time, set flow enable to high (off). 
    #Import a schedule or sort and use current schedule
    if option == 1:
        currentTime = datetime.datetime.time(datetime.datetime.now()).replace(microsecond = 0)
        midnight = currentTime.replace(hour = 23, minute = 59, second = 59)
        meter.currentTime = datetime.datetime.now().replace(microsecond = 0)
        meter.log()# start logging
        
        print "\n\nCtrl + Pause/Break at any time to stop operation.\n"
        
        if not workingSchedule.eventCount:#if no objects ask for a schedule to import
            workingSchedule.importSchedule()
            workingSchedule.displaySchedule()
        else:#sort and run
            workingSchedule.eventList.sort(key = lambda event: event.startTime)
            workingSchedule.displaySchedule()
        print ""
        
        nextEvent = workingSchedule.eventList[0]#grab first event
        nextStartTime = nextEvent.startTime
        print nextEvent.displayEvent() + " loaded."