Skip to content

Commit

Permalink
Basic threshold functionality should now be operational for sending
Browse files Browse the repository at this point in the history
  • Loading branch information
icook committed Mar 16, 2014
1 parent 4c7bd6e commit 70dca2d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ppagent/main.py
Expand Up @@ -92,7 +92,9 @@ class CGMiner(Miner):
keys = ['temps', 'hashrates']
valid_collectors = ['status']

def __init__(self, collectors, remotes, port=4028, address='127.0.0.1'):
def __init__(self, collectors, remotes, thresholds=None, port=4028,
address='127.0.0.1'):
self.thresholds = thresholds or {}
self.port = port
self.remotes = remotes
self.address = address
Expand All @@ -104,12 +106,14 @@ def __init__(self, collectors, remotes, port=4028, address='127.0.0.1'):
self.queue = []
self.authenticated = False
self.last_devs = []
self.sent_thresholds = False

def reset(self):
""" Called when connection to the miner is lost for some reason """
self.last_devs = []
self._worker = None
self.authenticated = False
self.sent_thresholds = False

def reset_timers(self):
now = int(time.time())
Expand All @@ -126,8 +130,12 @@ def worker(self):
def collect(self):
# trim queue to keep it from growing infinitely while disconnected
self.queue = self.queue[:10]

now = int(time.time())

if self.sent_thresholds is False:
self.queue.append([self.worker, 'thresholds', self.thresholds, now])
self.sent_thresholds = True

# if it's time to run, and we have status defined
if ('status' in self.collectors or
'temp' in self.collectors or
Expand Down

0 comments on commit 70dca2d

Please sign in to comment.