Ejemplo n.º 1
0
    def handle(self, *args, **options):

        settings = Settings()
        active_well = settings.get_active_well()

        d = 100
        h = d
        for cnt in range(100):
            m = 1
            if int(random.uniform(1, 10)) == 1:
                m = -1

            d += int(random.uniform(1, 10)) * m

            if d - ((d / 100) * 100) <= 20 and d > 120:
                g = int(random.uniform(90, 110))
            else:
                g = int(random.uniform(30, 35))

            if d > h:
                h = d

            bd = WITS0(well=active_well, time_stamp=datetime.utcnow(), recid=1, itemid=8, value=d)
            bd.save()
            hd = WITS0(well=active_well, time_stamp=datetime.utcnow(), recid=1, itemid=10, value=h)
            hd.save()
            time.sleep(10)

            mdwrt = ToolMWDRealTime(well=active_well, time_stamp=datetime.utcnow(), type="gammaray", value=g)
            mdwrt.save()

            time.sleep(10)
Ejemplo n.º 2
0
    def handle(self, *args, **options):
        
        settings = Settings()
        active_well = settings.get_active_well()

        g = 30
        m = 1
        for cnt in range(100) :
            g += (int(random.uniform(1,15)) * m)
            print g
            mdwrt = ToolMWDRealTime(well=active_well, time_stamp=datetime.utcnow(), type='gammaray', value=g )
            mdwrt.save()
            if g>75 :
                m=-1
            if g<30 :
                m=1
            time.sleep(20)                        
Ejemplo n.º 3
0
    def addMWDRealTime(self,name,timestamp,value):

        logging.info(str("Processing:")+str(name)+repr(timestamp)+str(value))

        mwdrt = [name,timestamp,value]
        
        if mwdrt in last:
            logging.info(str('Duplicate Found! Ignoring'))            

        if name == '':
            logging.info(str("No Name attached to data!"))            
                
        
        logging.info(str("buffer size:"+str(len(last))))        

        #pop the first
        if len(last) > last_length:
            last.pop(0)

        #value = float(value)
            
        kwargs = {'well':db_settings.get_active_well(),
                  'time_stamp':timestamp}
        
        kwargs['type'], axis, value = convert(name, value)

        if axis != '':
            kwargs['value_'+axis] = str(value)
        else:
            kwargs['value'] = str(value)

        logging.info(str("Final Value:")+str(kwargs))
        
        t = ToolMWDRealTime(**kwargs)

        t.save()
            
        

        #append to the back
        last.append(mwdrt)

        return 'OK'