示例#1
0
def main():
    while True:
        try:
            # Read Device List
            devices = utils.getDeviceList()
            # Loop of Device List
            for deviceInfo in devices:
                MAC_ADDR = deviceInfo[IDX_ADDRESS]
                DEV_NAME = deviceInfo[IDX_COMMENT]

                try:
                    lastSendDttm = utils.getLastSendDttmByMACADDR( MAC_ADDR )
                    # print ("MAC_ADDR:"+ MAC_ADDR + " lastSend:"+str(lastSendDttm) )
                    lastDttm = sendPayload( MAC_ADDR, DEV_NAME, lastSendDttm, HOST )
                    # print (" lastEndRead:"+str(lastDttm) )
                    # print ( "Going to next device. just sleep...Zzzzzz ("+ str( PAR_DEVICE_INTERVAL ) +")sec" )
                    time.sleep( PAR_DEVICE_INTERVAL )
                except Exception as e:
                    # print ( sys.exc_info() )
                    log.info('ExceptionCatch(2): '+ MAC_ADDR)
                    log.info(e)

        except KeyboardInterrupt:
            # print ( "Interrupt catch!!" )
            log.error("KeybordInterrupt(1) catch!!")
            break
        except:
            # print ( sys.exc_info() )
            log.exception('ExceptionCatch(2):')

    sys.exit(0)
示例#2
0
    def updateDevices(self):
        classes, devices = getDeviceList()
        self.powerBtn.setEnabled(True if len(devices) > 0 else False)

        for i, device in enumerate(devices):
            if self.deviceBox.findData(device) == -1:
                self.deviceBox.addItem(classes[i]['label'].split(' [')[0],
                                       device)

        for i in range(self.deviceBox.count()):
            if self.deviceBox.itemData(i) not in devices:
                self.deviceBox.removeItem(i)
示例#3
0
def main():
    while True:
        try:
            # Read Device List
            devices = utils.getDeviceList()
            # Loop of Device List
            for deviceInfo in devices:
                MAC_ADDR = deviceInfo[0]
                lastSendDttm = utils.getLastSendDttmByMACADDR(MAC_ADDR)
                print("MAC_ADDR:" + MAC_ADDR + " lastSend:" +
                      str(lastSendDttm))
                lastDttm = sendPayload(MAC_ADDR, lastSendDttm)
                print(" lastEndRead:" + str(lastDttm))

        except KeyboardInterrupt:
            print("Interrupt catch!!")
            break
        except:
            print(sys.exc_info())
    sys.exit(0)
示例#4
0
            log.info( str(len(result)) + " data readed" )
            return lastDttm
        elif( status == "100204" ):
            if( retry < (RETRY_COUNT-1) ):
                # Retry
                log.info('Going to retry('+str(retry)+')' )
                sleepLoop()
        else:
            break

#-------------------------

while True:
    try:
        # Read Device List
        devices = utils.getDeviceList()
        # Loop of Device List
        for deviceInfo in devices:

            log.info('===================================================================' )
            MAC_ADDR = deviceInfo[IDX_ADDRESS]
            DEV_NAME = deviceInfo[IDX_COMMENT]

            try:

                lastReadDttm = utils.getLastReadDttmByMACADDR( MAC_ADDR )
                if ( BEFORE_24H_MODE ):
                    before24HDttm = datetime.datetime.now() - timedelta(hours = DATA_PERIOD)
                    if ( lastReadDttm < before24HDttm ):
                        strDttm = before24HDttm.strftime('%Y-%m-%d %H:%M:%S')
                        before24HDttm = datetime.datetime.strptime( strDttm, '%Y-%m-%d %H:%M:%S')