Beispiel #1
0
 def run(self):
     while True:
         self.event.wait()
         self.logger.info("QueueuFiller: started in thread %s.", self.ident)
         self.publish(actions.message("queueuFiller: started in "
                                                     "server thread %s." %
                                                     self.ident))
         alert_counter = 0
         while self.number_of_listeners() > 0:
             self.logger.info("QueueFiller: %s listeners, %s threads.",
                   self.number_of_listeners(), threading.active_count())
             self.publish(actions.add_point("memusage",
                                            int(time.time()) * 1000,
                                            random.random()))
             self.publish(actions.add_point("listeners",
                                            int(time.time()) * 1000,
                                            random.random()))
             tweetdata = offline_tweets.cache[int(random.random() * 200)][4]
             try:
                 self.publish(actions.add_tweetlist_tweet("allTweets",
                     json.loads(tweetdata)))
             except ValueError:
                 # json.loads throws a ValueError for some tweets that
                 # apparantly contain invalid json.
                 pass
             if random.random() > .9:
                 alert_counter += 1
                 self.publish(actions.alert("Random alert %s!" %
                                                           alert_counter,
                                                           "myAlerter"))
             time.sleep(1)
         self.logger.info("QueueFiller: stopped in thread %s.", self.ident)
Beispiel #2
0
 def run(self):
     print("queueuFiller: started in thread %s." % self.ident)
     self._send_to_all_listeners(actions.message("queueuFiller: started in "
                                                 "server thread %s." %
                                                 self.ident))
     self._send_to_all_listeners(actions.create_general_chart("chart1",
                                                     self.chart_options))
     while True:
         self._send_to_all_listeners(actions.add_point("mychart",
                                                 int(time.time()) * 1000,
                                                 random.random()))
         time.sleep(1)
 def run(self):
     while True:
         self.event.wait()
         self.logger.info("QueueuFiller: started in thread %s.", self.ident)
         self.publish(
             actions.message("queueuFiller: started in "
                             "server thread %s." % self.ident))
         alert_counter = 0
         while self.number_of_listeners() > 0:
             self.logger.info("QueueFiller: %s listeners, %s threads.",
                              self.number_of_listeners(),
                              threading.active_count())
             self.publish(
                 actions.add_point("memusage",
                                   int(time.time()) * 1000,
                                   random.random()))
             self.publish(
                 actions.add_point("listeners",
                                   int(time.time()) * 1000,
                                   random.random()))
             tweetdata = offline_tweets.cache[int(random.random() * 200)][4]
             try:
                 self.publish(
                     actions.add_tweetlist_tweet("allTweets",
                                                 json.loads(tweetdata)))
             except ValueError:
                 # json.loads throws a ValueError for some tweets that
                 # apparantly contain invalid json.
                 pass
             if random.random() > .9:
                 alert_counter += 1
                 self.publish(
                     actions.alert("Random alert %s!" % alert_counter,
                                   "myAlerter"))
             time.sleep(1)
         self.logger.info("QueueFiller: stopped in thread %s.", self.ident)
Beispiel #4
0
import logging
logging.basicConfig(level=logging.DEBUG)

from temperature import read_temp, initialise_temperature_probe
from actions import message, raise_temperature_for, action

initialise_temperature_probe()

action("Confirm Start")

message("Boiling for 1 minute")

exit(0)
raise_temperature_for(target_temperature=95, target_minutes=1)

message("Reached {}".format(read_temp()))
Beispiel #5
0
from temperature import read_temp
from tidy_pump import manage

logging.basicConfig(level=logging.DEBUG,
                    format='%(asctime)s %(levelname)-8s %(message)s',
                    datefmt='%m/%d/%Y %I:%M:%S')

from actions import message, wait_until_temperature_has_fallen_to, switch_off_boiler, create_pump

MAX_TEMPERATURE = 20
MIN_TEMPERATURE = 19.8

CYCLE_MINUTES = 10

with manage(create_pump()) as pump:
    message("Cooling initiated : target temp {}C".format(MAX_TEMPERATURE))

    try:
        while (True):
            switch_off_boiler()
            if (read_temp() > MAX_TEMPERATURE):
                message('Cooling.  temp {} : target {}'.format(
                    read_temp(), MIN_TEMPERATURE))

                wait_until_temperature_has_fallen_to(MIN_TEMPERATURE,
                                                     pump=pump)

                message(
                    "Target Temperature ( {}C ) reached.  Current temperature {}"
                    .format(MIN_TEMPERATURE, read_temp()))
            logging.debug('Waiting {} mins : temp {} C : max {}'.format(
Beispiel #6
0
#
#message('Cooling liquor to mashing temperature')
#wait_until_temperature_has_fallen_to(MASH_TEMPERATURE)
#raise_temperature(target_temperature=STRIKE_TEMPERATURE)
raise_temperature(target_temperature=STRIKE_TEMPERATURE)

action('Add Grain')
raise_temperature_for(target_temperature=MASH_TEMPERATURE,
                      target_minutes=MASH_MINUTES)

action('Replace  Grain')

raise_temperature_for(target_temperature=MASH_TEMPERATURE,
                      target_minutes=MASH_MINUTES)

message('Mash Out')
raise_temperature_for(target_temperature=MASH_OUT_TEMPERATURE)

action('Remove Grain, add hops')

message('Bring to boiling point')
raise_temperature_for(target_temperature=BOILING_TEMPERATURE)

boil_for(minutes=45)

action('Add t-15 min  Hops, protofloc, cooling coil')
raise_temperature_for(target_temperature=BOILING_TEMPERATURE)
boil_for(minutes=.15)

action('Add Post Boil  Hops and cool')
Beispiel #7
0
 def test_message(self):
     self.assertEqual(actions.message("This is a message."),
                      {"event": "message",
                       "data": ['{"messageText":"This is a message."}']},
                      "Message should be exactly like second arg.")