コード例 #1
0
def uploadLastLog():
    try:
        # local log file.
        datetext = (datetime.datetime.now()).strftime("%Y%b%d")                
        dbxFileName = "data_%s.csv" % (datetext)
        dbxFullFileName = '/%s/%s' % ('test', dbxFileName)# dropbox path and file.
        
        localFileName = "data_%s.csv" % (datetext)
        localFullFileName = "%s/%s" % (log_path, localFileName)          
            
        try:                        
            print 'Uploading...\n'          
            memo.appendNote("Uploading")
            
            upload_cmd = ['/home/multiply/Dropbox-Uploader/dropbox_uploader.sh' , 'upload']
            delete_cmd = ['/home/multiply/Dropbox-Uploader/dropbox_uploader.sh' , 'delete']

            upload_cmd.append(localFullFileName)
            upload_cmd.append(dbxFullFileName)
            
            delete_cmd.append(dbxFullFileName)
            
            print "%s\n" % (delete_cmd)
            print "%s\n" % (upload_cmd)
            
           
            
            print "%s\n" % (upload_cmd)
            memo.appendNote(upload_cmd)
            
            out = subprocess.check_output(upload_cmd) # Upload
            #print out        
            #memo.appendNote(out)        
        
                        
        except Exception as err:
            print repr(err)
    
    except Exception as ex:
        print repr(ex)
コード例 #2
0
ファイル: lux_lib.py プロジェクト: nhoppasit/co2-pi
def getState(serial_port):
    try:

        MSG = TARGET_NBR + QUERY_SUF
        logtext = "...........Read DHTs .........."
        print logtext
        memo.appendNote(logtext + '\n')

        print "<< " + MSG
        memo.TargetMemo[nTARGET]("<< " + MSG + '\n')
        serial_port.write(MSG)
        rcv = uart.readlineCR(serial_port)
        memo.TargetMemo[nTARGET](">> " + ''.join(rcv) + '\n')
        print ">> " + ''.join(rcv)

        print rcv
        print len(rcv)
        memo.appendNote(''.join(rcv) + '\n')

        # incomming pattern
        # [ 0         2    3              6         8              11            14             17             20             23
        # ['*', ':', '?', '2', '0', '1', '7', '|', '0', '6', '|', '1', '1', '|', '1', '5', '|', '0', '3', '|', '3', '9', '|', '0', '3', '6']
        # Length = 26

        if ''.join(rcv[0:3]) == "*+?":
            serial_port.write(uart.ACK)

            # Check return message
            if (4 <= len(rcv) and len(rcv) <= 6):
                if (len(rcv) == 4):
                    lx = ''.join(rcv[3:4])
                    return lx

                if (len(rcv) == 5):
                    lx = ''.join(rcv[3:5])
                    return lx

                if (len(rcv) == 6):
                    lx = ''.join(rcv[3:6])
                    return lx
            else:
                return '0'

        else:
            serial_port.write(uart.NAK)
            return rcv

    except Exception as ex:
        print repr(ex)
        memo.appendNote(repr(ex) + '\n')
        raise ex
コード例 #3
0
ファイル: temp_ctrl_lib.py プロジェクト: nhoppasit/co2-pi
def getState(serial_port):
    try:
        
        MSG = TARGET_NBR + QUERY_SUF
        logtext = "...........Read DHTs .........." 
        print logtext
        memo.appendNote(logtext + '\n') 
    
        print "<< " + MSG
        memo.TargetMemo[nTARGET]("<< " + MSG + '\n')        
        serial_port.write(MSG)
        rcv = uart.readlineCR(serial_port)
        memo.TargetMemo[nTARGET](">> " + ''.join(rcv) + '\n')
        print ">> " + ''.join(rcv)
    
        print rcv
        print len(rcv)
        memo.appendNote(''.join(rcv) + '\n')
        
        # incomming pattern
        # [ 0         2    3              6         8              11            14             17             20             23                
        # ['*', ':', '?', '2', '0', '1', '7', '|', '0', '6', '|', '1', '1', '|', '1', '5', '|', '0', '3', '|', '3', '9', '|', '0', '3', '6']
        # Length = 26
        
        if len(rcv)==42 and ''.join(rcv[0:3])=="*~?":                
            serial_port.write(uart.ACK)
            
            # Check return message
            h1 = ''.join(rcv[3:6])
            t1 = ''.join(rcv[7:10])
            h2 = ''.join(rcv[11:14]) 
            t2 = ''.join(rcv[15:18])
            h3 = ''.join(rcv[19:22])
            t3 = ''.join(rcv[23:26])
            h4 = ''.join(rcv[27:30])
            t4 = ''.join(rcv[31:34])
            return h1, t1, h2, t2, h3, t3, h4, t4
        
        else:
            serial_port.write(uart.NAK)      
            return rcv
        
    except Exception as ex:
        print repr(ex)
        memo.appendNote(repr(ex) + '\n')        
        raise ex  
コード例 #4
0
ファイル: timery.py プロジェクト: nhoppasit/co2-pi
def getTime(serial_port):
    try:
        
        MSG = TARGET_NBR + TIME_SUF
        logtext = "...........Read .........." 
        print logtext
        memo.appendNote(logtext + '\n') 
    
        print "<< " + MSG
        memo.TargetMemo[nTARGET]("<< " + MSG + '\n')        
        serial_port.write(MSG)
        rcv = uart.readlineCR(serial_port)
        memo.TargetMemo[nTARGET](">> " + ''.join(rcv) + '\n')
        print ">> " + ''.join(rcv)
    
        # print rcv
        # print len(rcv)
        memo.appendNote(''.join(rcv) + '\n')
        
        # incomming pattern
        # [ 0         2    3              6         8              11            14             17             20             23                
        # ['*', ':', '?', '2', '0', '1', '7', '|', '0', '6', '|', '1', '1', '|', '1', '5', '|', '0', '3', '|', '3', '9', '|', '0', '3', '6']
        # Length = 26
        
        if len(rcv)==26 and ''.join(rcv[0:3])=="*:?":                
            serial_port.write(uart.ACK)
            
            # Check return message
            strYear   = ''.join(rcv[3:7])
            strMonth  = ''.join(rcv[8:10])
            strDay    = ''.join(rcv[11:13]) 
            strHour   = ''.join(rcv[14:16])
            strMinute = ''.join(rcv[17:19])
            strSecond = ''.join(rcv[20:22])
            iRelayState = int(''.join(rcv[23:26]))            
            return strYear, strMonth, strDay, strHour, strMinute, strSecond, iRelayState
        
        else:
            serial_port.write(uart.NAK)      
            return rcv
        
    except Exception as ex:
        print repr(ex)
        memo.appendNote(repr(ex) + '\n')        
        raise ex  
コード例 #5
0
ファイル: timery.py プロジェクト: nhoppasit/co2-pi
def setYear(serial_port,valText):
    try:
        
        MSG = TARGET_NBR + SET_YEAR_CMD + valText + ETX_SUF
        logtext = "........... SET YEAR to TIMERRY..........." 
        print logtext
        memo.appendNote(logtext + '\n') 
    
        print "<< " + MSG
        memo.TargetMemo[nTARGET]("<< " + MSG + '\n')        
        serial_port.write(MSG)
        rcv = uart.readlineCR(serial_port)
        memo.TargetMemo[nTARGET](">> " + ''.join(rcv) + '\n')
        print ">> " + ''.join(rcv)
    
        print rcv
        print len(rcv)
        memo.appendNote(''.join(rcv) + '\n')
        
        # incomming pattern
        # *:[2017*
        # Length = 8
        
        if len(rcv)==8 and ''.join(rcv[0:3])=="*:[":                
            serial_port.write(uart.ACK)   
            print "Send ACK"                 
            return True
        
        else:
            print "Send NAK"
            serial_port.write(uart.NAK)      
            return False
        
    except Exception as ex:
        print repr(ex)
        memo.appendNote(repr(ex) + '\n')        
        raise ex  
コード例 #6
0
ファイル: main3.py プロジェクト: nhoppasit/co2-pi
memo.checkNoteFolder()
memo.checkMemoFolder[1]()

data_store.checkSystemNote()
data_store.checkNoteFolder()

#---------------------------------------------
# Program header
#---------------------------------------------

print "\n\n\n"
print "***************************************************************"
print " ME FARM"
print " (c)2017, Designed by RED FILE"
print "***************************************************************"
memo.appendNote(
    "***************************************************************\n")
memo.appendNote(" ME FARM\n")
memo.appendNote(
    "***************************************************************\n")

serviceState = -2
try:
    cl = Client('http://farmboxwebhop.dyndns.org:8080/api/Control.asmx?WSDL',
                timeout=10)
    print 'Service success\n'
    memo.appendNote('Service success\n')
    serviceState = 0

except Exception as ex:
    print 'Service failed\n'
    memo.appendNote('Service failed\n')
コード例 #7
0
#--------------------------------------------------------------

memo.checkSystemNote()
memo.checkNoteFolder()
memo.checkMemoFolder[1]()

#---------------------------------------------
# Program header
#---------------------------------------------

print "\n\n\n"
print "***************************************************************"
print " ME FARM"
print " (c)2017, Designed by RED FILE"
print "***************************************************************"
memo.appendNote(
    "***************************************************************\n")
memo.appendNote(" ME FARM\n")
memo.appendNote(
    "***************************************************************\n")

#---------------------------------------------
# Setup GPIO
#---------------------------------------------
thegpio.setupGPIO()

#---------------------------------------------
# Serial port name
#---------------------------------------------
serial_port = serial.Serial()

try:
コード例 #8
0
ファイル: kasetfms01.py プロジェクト: nhoppasit/co2-pi
data_store.checkSystemNote()
data_store.checkNoteFolder()

data_store_forward.checkSystemNote()
data_store_forward.checkNoteFolder()

#---------------------------------------------
# Program header
#---------------------------------------------

print "\n\n\n"
print "***************************************************************"
print " KASET FMS"
print " (c)2018, Designed by RED LASER"
print "***************************************************************"
memo.appendNote(
    "***************************************************************\n")
memo.appendNote(" KASET FMS\n")
memo.appendNote(
    "***************************************************************\n")

urlPush = 'http://api.kasetfms.com/Onfield.asmx?WSDL'

#===============================================================================
# MAIN SETUP
#===============================================================================

serviceState = -2
try:
    cl = Client(urlPush, timeout=10)
    print 'Service success\n'
    memo.appendNote('Service success\n')
コード例 #9
0
memo.checkNoteFolder()
memo.checkMemoFolder[1]()

data_store.checkSystemNote()
data_store.checkNoteFolder()

#---------------------------------------------
# Program header
#---------------------------------------------

print "\n\n\n"
print "***************************************************************"
print " ME FARM"
print " (c)2017, Designed by RED FILE"
print "***************************************************************"
memo.appendNote(
    "***************************************************************\n")
memo.appendNote(" ME FARM\n")
memo.appendNote(
    "***************************************************************\n")
mylcd.lcd_display_string_pos(
    datetime.datetime.now().strftime("%a, %d %b %Y %H:%M:%S.%f [OPEN]"), 1, 0)

#---------------------------------------------
# Setup GPIO
#---------------------------------------------
thegpio.setupGPIO()

# ------------------------------------------------
# Test host and open station
# ------------------------------------------------
loop = 1
コード例 #10
0
ファイル: timery.py プロジェクト: nhoppasit/co2-pi
def setDateTime(serial_port,lcd,key):
    iProg = 0        
    if not (key == ""):
        lcd.lcd_display_string_pos("Check key...     ",4,4)
        print "Check key..."                    
        memo.appendNote("Check key...\n")                       
        try:
            iProg = int(key)
        except Exception as ex:
            print repr(ex)                
            iProg = 0                
        
        if iProg>0:            
            textLog = "Program is %d." % iProg
            print textLog
            memo.appendNote(textLog + '\n')
            
            # ------------ 1. SET YEAR ------------------
            if iProg == 1:
                print "SET YEAR..."
                memo.appendNote("SET YEAR...\n")                    
                key = thegpio.trackKey(lcd,
                                       "    THE PROFILER",
                                       "",
                                       "SET YEAR: ",
                                       "",
                                       3,10,True) # 1.0 Sec scanning
                iVal = 0
                if not(key==""):
                    textLog = "Check year number..."
                    print textLog
                    memo.appendNote(textLog + '\n')
                    try:
                        iVal = int(key)
                    except Exception as ex:
                        print repr(ex)
                        iVal=0
                    if 2016<iVal and iVal<=9999:
                        lcd.lcd_display_string_pos("Setting...",4,10)
                        if setYear(serial_port, "%04d" % iVal):
                            lcd.lcd_display_string_pos("                Done",4,0)
                        else:
                            lcd.lcd_display_string_pos("Fail!     ",4,11)
                        sleep(2)
                            
                    else:
                        lcd.lcd_display_string_pos("Invalid!",4,11)
                        sleep(2)
                
            # ------------ 2. SET MONTH ------------------
            if iProg == 2:
                print "SET MONTH..."
                memo.appendNote("SET MONTH...\n")                    
                key = thegpio.trackKey(lcd,
                                       "    THE PROFILER",
                                       "",
                                       "SET MONTH: ",
                                       "",
                                       3,11,True) # 1.0 Sec scanning
                iVal = 0
                if not(key==""):
                    textLog = "Check month number..."
                    print textLog
                    memo.appendNote(textLog + '\n')
                    try:
                        iVal = int(key)
                    except Exception as ex:
                        print repr(ex)
                        iVal=0
                    if 1<=iVal and iVal<=12:
                        lcd.lcd_display_string_pos("Setting...",4,10)
                        if setMonth(serial_port, "%02d" % iVal):
                            lcd.lcd_display_string_pos("                Done",4,0)
                        else:
                            lcd.lcd_display_string_pos("Fail!     ",4,11)
                        sleep(2)
                            
                    else:
                        lcd.lcd_display_string_pos("Invalid!",4,11)
                        sleep(2)

            # ------------ 3. SET DAY ------------------
            if iProg == 3:
                print "SET DAY..."
                memo.appendNote("SET DAY...\n")                    
                key = thegpio.trackKey(lcd,
                                       "    THE PROFILER",
                                       "",
                                       "SET DAY: ",
                                       "",
                                       3,9,True) # 1.0 Sec scanning
                iVal = 0
                if not(key==""):
                    textLog = "Check day number..."
                    print textLog
                    memo.appendNote(textLog + '\n')
                    try:
                        iVal = int(key)
                    except Exception as ex:
                        print repr(ex)
                        iVal=0
                    if 1<=iVal and iVal<=31:
                        lcd.lcd_display_string_pos("Setting...",4,10)
                        if setDay(serial_port, "%02d" % iVal):
                            lcd.lcd_display_string_pos("                Done",4,0)
                        else:
                            lcd.lcd_display_string_pos("Fail!     ",4,11)
                        sleep(2)
                            
                    else:
                        lcd.lcd_display_string_pos("Invalid!",4,11)
                        sleep(2)
                                    
            # ------------ 4. SET HOUR ------------------
            if iProg == 4:
                print "SET HOUR..."
                memo.appendNote("SET HOUR...\n")                    
                key = thegpio.trackKey(lcd,
                                       "    THE PROFILER",
                                       "",
                                       "SET HOUR: ",
                                       "",
                                       3,10,True) # 1.0 Sec scanning
                iVal = 0
                if not(key==""):
                    textLog = "Check hour number..."
                    print textLog
                    memo.appendNote(textLog + '\n')
                    try:
                        iVal = int(key)
                    except Exception as ex:
                        print repr(ex)
                        iVal=0
                    if 0<=iVal and iVal<=23:
                        lcd.lcd_display_string_pos("Setting...",4,10)
                        if setHour(serial_port, "%02d" % iVal):
                            lcd.lcd_display_string_pos("                Done",4,0)
                        else:
                            lcd.lcd_display_string_pos("Fail!     ",4,11)
                        sleep(2)
                            
                    else:
                        lcd.lcd_display_string_pos("Invalid!",4,11)
                        sleep(2)
                                   
            # ------------ 5. SET MINUTE ------------------
            if iProg == 5:
                print "SET MINUTE..."
                memo.appendNote("SET MINUTE...\n")                    
                key = thegpio.trackKey(lcd,
                                       "    THE PROFILER",
                                       "",
                                       "SET MINUTE: ",
                                       "",
                                       3,12,True) # 1.0 Sec scanning
                iVal = 0
                if not(key==""):
                    textLog = "Check minute number..."
                    print textLog
                    memo.appendNote(textLog + '\n')
                    try:
                        iVal = int(key)
                    except Exception as ex:
                        print repr(ex)
                        iVal=0
                    if 0<=iVal and iVal<=59:
                        lcd.lcd_display_string_pos("Setting...",4,10)
                        if setMinute(serial_port, "%02d" % iVal):
                            lcd.lcd_display_string_pos("                Done",4,0)
                        else:
                            lcd.lcd_display_string_pos("Fail!     ",4,11)
                        sleep(2)
                            
                    else:
                        lcd.lcd_display_string_pos("Invalid!",4,11)
                        sleep(2)
                                   
            # ------------ 6. SET SECOND ------------------
            if iProg == 6:
                print "SET SECOND..."
                memo.appendNote("SET SECOND...\n")                    
                key = thegpio.trackKey(lcd,
                                       "    THE PROFILER",
                                       "",
                                       "SET SECOND: ",
                                       "",
                                       3,12,True) # 1.0 Sec scanning
                iVal = 0
                if not(key==""):
                    textLog = "Check second number..."
                    print textLog
                    memo.appendNote(textLog + '\n')
                    try:
                        iVal = int(key)
                    except Exception as ex:
                        print repr(ex)
                        iVal=0
                    if 0<=iVal and iVal<=59:
                        lcd.lcd_display_string_pos("Setting...",4,10)
                        if setSecond(serial_port, "%02d" % iVal):
                            lcd.lcd_display_string_pos("                Done",4,0)
                        else:
                            lcd.lcd_display_string_pos("Fail!     ",4,11)
                        sleep(2)
                            
                    else:
                        lcd.lcd_display_string_pos("Invalid!",4,11)
                        sleep(2)
                                   
                                                  
                                                                              
        # Clear lcd once
        lcd.lcd_clear()                            
        
コード例 #11
0
import datetime
        
thegpio.setupGPIO()

ryPin = [4,17,18,27,22,23,24,25]

for idx in range(8):
    thegpio.setAsOutput(ryPin[idx])
    thegpio.offPin(ryPin[idx])

memo.checkSystemNote()
memo.checkNoteFolder()
memo.checkMemoFolder[1]()

memo.appendNote("***************************************************************\n")
memo.appendNote(" RELAY 01\n")
memo.appendNote("***************************************************************\n")

try:
    idx = 0
    while(True):
        try:
            now = datetime.datetime.now()
            todayOnTime = now.replace(hour=7, minute=0, second=0, microsecond=0)
            todayOffTime = now.replace(hour=18, minute=0, second=0, microsecond=0)
            if todayOnTime<now and now<todayOffTime:            
                thegpio.onPin(ryPin[idx])
                #print "ON\n"
                print "ON-RY%d {GPIO%d}\n" % (idx+1, ryPin[idx])
                memo.appendNote("ON-RY%d {GPIO%d}\n" % (idx+1, ryPin[idx]))
コード例 #12
0
ファイル: test_ac_control01.py プロジェクト: nhoppasit/co2-pi
#--------------------------------------------------------------

memo.checkSystemNote()
memo.checkNoteFolder()
memo.checkMemoFolder[1]()

#---------------------------------------------
# Program header
#---------------------------------------------

print "\n\n\n"
print "***************************************************************"
print " ME FARM"
print " (c)2017, Designed by RED FILE"
print "***************************************************************"
memo.appendNote(
    "***************************************************************\n")
memo.appendNote(" ME FARM\n")
memo.appendNote(
    "***************************************************************\n")

#---------------------------------------------
# Setup GPIO
#---------------------------------------------
thegpio.setupGPIO()

#---------------------------------------------
# Serial port name
#---------------------------------------------
serial_port = serial.Serial()

try: