Beispiel #1
0
 def testDefaultBus(self):
     self._load_time()
     
     self._load_default_bus(custom=False)
     bus = load_bus('INCORRECT_FOLDER_NAME')
     self.assertTrue(isinstance(bus,DefaultBus), 'Incorrect instance of the default bus was returned')
     
     #bus.start_bus()
     
     print '-------------------------'
     print 'RUNNING DEFAULT BUS'
     print '-------------------------'
     print
     
     while(True):
         self._time.advance_time()
         _ = self._aggregator_dict()
         _['price'] = np.random.normal(20.0,3.0)
         __out = bus.transaction(_)
         print str(self._time) + ':' + str(__out[AggregatorBusTranslator.OUT_P_RE_KEY]) + '+ ' + str(__out[AggregatorBusTranslator.OUT_P_IM_KEY]) + 'j'
             
         if not self._time.advance_time():
             break
         
     bus.stop_bus()
    def testDefaultBus(self):
        self._load_time()

        self._load_default_bus(custom=False)
        bus = load_bus('INCORRECT_FOLDER_NAME')
        self.assertTrue(isinstance(bus, DefaultBus),
                        'Incorrect instance of the default bus was returned')

        #bus.start_bus()

        print '-------------------------'
        print 'RUNNING DEFAULT BUS'
        print '-------------------------'
        print

        while (True):
            self._time.advance_time()
            _ = self._aggregator_dict()
            _['price'] = np.random.normal(20.0, 3.0)
            __out = bus.transaction(_)
            print str(self._time) + ':' + str(
                __out[AggregatorBusTranslator.OUT_P_RE_KEY]) + '+ ' + str(
                    __out[AggregatorBusTranslator.OUT_P_IM_KEY]) + 'j'

            if not self._time.advance_time():
                break

        bus.stop_bus()
Beispiel #3
0
    def testConstantBusManualOpen(self):
        '''
        Example using a ConstantBus.  Manually load, start, 
        and stop bus (instead of using 'with' statement)
        '''
        FILENAME = 'constant_bus.json'

        bus = load_bus('.', FILENAME)
        bus.start_bus()
        while not bus.finished:
            __out = bus.transaction(inputs=None)
            print out_to_string(__out)
        bus.stop_bus()
        print 'bus finished'
Beispiel #4
0
 def testConstantBusManualOpen(self):
     '''
     Example using a ConstantBus.  Manually load, start, 
     and stop bus (instead of using 'with' statement)
     '''
     FILENAME = 'constant_bus.json'
     
     bus = load_bus('.',FILENAME)
     bus.start_bus()
     while not bus.finished:
         __out = bus.transaction(inputs=None)
         print out_to_string(__out)
     bus.stop_bus()
     print 'bus finished'
Beispiel #5
0
    def testGridlabBusWithPath(self):
        '''
        Example using a GridlabBus.  Will change the base_power for the load
        house0_agg_R4-25-00-1_tm_1_R4-25-00-1_tn_141 at each timestep. Will
        then query the network_node power.
        '''
        FILENAME = 'gridlabd_bus.json'
        PATHNAME = 'C:\\Program Files (x86)\\GridLAB-D\\bin'

        bus = load_bus('.', FILENAME)
        bus.set_path(PATHNAME)
        bus.start_bus()
        while not bus.finished:
            __out = bus.transaction(inputs=message_gld_input())
            print out_to_string(__out)
        bus.stop_bus()

        print 'bus finished'
Beispiel #6
0
 def testGridlabBusWithPath(self):
     '''
     Example using a GridlabBus.  Will change the base_power for the load
     house0_agg_R4-25-00-1_tm_1_R4-25-00-1_tn_141 at each timestep. Will
     then query the network_node power.
     '''
     FILENAME = 'gridlabd_bus.json'
     PATHNAME = 'C:\\Program Files (x86)\\GridLAB-D\\bin'
     
     bus = load_bus('.',FILENAME)
     bus.set_path(PATHNAME)
     bus.start_bus()
     while not bus.finished:
         __out = bus.transaction(inputs=message_gld_input())
         print out_to_string(__out)
     bus.stop_bus()
 
     print 'bus finished'
Beispiel #7
0
 def testGldCrash(self):
     self._load_time()
     
     bus = load_bus(os.path.join(THIS_DIR,'gld_crash_test_bus'))
     
     print '-------------------------'
     print 'RUNNING BUS: ' + os.path.join(THIS_DIR,'gld_crash_test_bus', bus_name)
     print '-------------------------'
     print
     
     bus.start_bus()
     
     while(not (bus.finished or self._check_time())):
         self._time.advance_time()
         __out = bus.transaction(self._aggregator_dict())
         print str(self._time) + ':' + str(__out[AggregatorBusTranslator.OUT_P_RE_KEY]) + '+ ' + str(__out[AggregatorBusTranslator.OUT_P_IM_KEY]) + 'j'
             
     bus.stop_bus()
     
     
Beispiel #8
0
 def test(self):
     self._load_time()
     
     bus = load_bus(os.path.join(dir_name,fld_name))
     
     print '-------------------------'
     print 'RUNNING BUS: ' + os.path.join(dir_name, fld_name, bus_name)
     print '-------------------------'
     print
     
     bus.start_bus()
     
     while(not (bus.finished or self._check_time())):
         self._time.advance_time()
         __out = bus.transaction(self._aggregator_dict())
         print str(self._time) + ':' + str(__out[AggregatorBusTranslator.OUT_P_RE_KEY]) + '+ ' + str(__out[AggregatorBusTranslator.OUT_P_IM_KEY]) + 'j'
             
     bus.stop_bus()
     
     assert True
    def testGldCrash(self):
        self._load_time()

        bus = load_bus(os.path.join(THIS_DIR, 'gld_crash_test_bus'))

        print '-------------------------'
        print 'RUNNING BUS: ' + os.path.join(THIS_DIR, 'gld_crash_test_bus',
                                             bus_name)
        print '-------------------------'
        print

        bus.start_bus()

        while (not (bus.finished or self._check_time())):
            self._time.advance_time()
            __out = bus.transaction(self._aggregator_dict())
            print str(self._time) + ':' + str(
                __out[AggregatorBusTranslator.OUT_P_RE_KEY]) + '+ ' + str(
                    __out[AggregatorBusTranslator.OUT_P_IM_KEY]) + 'j'

        bus.stop_bus()
    def test(self):
        self._load_time()

        bus = load_bus(os.path.join(dir_name, fld_name))

        print '-------------------------'
        print 'RUNNING BUS: ' + os.path.join(dir_name, fld_name, bus_name)
        print '-------------------------'
        print

        bus.start_bus()

        while (not (bus.finished or self._check_time())):
            self._time.advance_time()
            __out = bus.transaction(self._aggregator_dict())
            print str(self._time) + ':' + str(
                __out[AggregatorBusTranslator.OUT_P_RE_KEY]) + '+ ' + str(
                    __out[AggregatorBusTranslator.OUT_P_IM_KEY]) + 'j'

        bus.stop_bus()

        assert True
Beispiel #11
0
 def testDefaultBusConstant(self):
     self._load_time()
     
     self._load_default_bus(custom=True)
     bus = load_bus('INCORRECT_FOLDER_NAME')
     self.assertTrue(isinstance(bus,ConstantBus), 'Incorrect instance of the default bus was returned')
     
     bus.start_bus()
     
     print '-------------------------'
     print 'RUNNING CUSTOM DEFAULT BUS'
     print '-------------------------'
     print
     
     while(not (bus.finished or self._check_time())):
         self._time.advance_time()
         __out = bus.transaction(self._aggregator_dict())
         p_re = __out[AggregatorBusTranslator.OUT_P_RE_KEY]
         p_im = __out[AggregatorBusTranslator.OUT_P_IM_KEY]
         print str(self._time) + ':' + str(p_re) + '+ ' + str(p_im) + 'j'
             
     bus.stop_bus()
    def testDefaultBusConstant(self):
        self._load_time()

        self._load_default_bus(custom=True)
        bus = load_bus('INCORRECT_FOLDER_NAME')
        self.assertTrue(isinstance(bus, ConstantBus),
                        'Incorrect instance of the default bus was returned')

        bus.start_bus()

        print '-------------------------'
        print 'RUNNING CUSTOM DEFAULT BUS'
        print '-------------------------'
        print

        while (not (bus.finished or self._check_time())):
            self._time.advance_time()
            __out = bus.transaction(self._aggregator_dict())
            p_re = __out[AggregatorBusTranslator.OUT_P_RE_KEY]
            p_im = __out[AggregatorBusTranslator.OUT_P_IM_KEY]
            print str(self._time) + ':' + str(p_re) + '+ ' + str(p_im) + 'j'

        bus.stop_bus()