Skip to content

Commit 59df161

Browse files
committed
qos server demos: fix reporting over client reboots.
1 parent 0e9f01e commit 59df161

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

iot/qos/check_mid.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,24 @@
1212
# message is missing after n have been received, it is assumed lost.
1313

1414
class CheckMid:
15-
def __init__(self, buff=5):
15+
def __init__(self, buff=10):
1616
self._buff = buff
1717
self._mids = set()
1818
self.miss = 0 # Count missing message ID's
1919
self.dupe = 0 # Duplicates
2020
self.oord = 0 # Received out of order
21-
self.bcnt = 0 # Reboot count
21+
self.bcnt = 0 # Client reboot count. Running totals over reboots:
22+
self.tot_miss = 0 # Missing
23+
self.tot_dupe = 0 # Dupes
24+
self.tot_oord = 0 # Out of order
2225

2326
def __call__(self, mid):
2427
mids = self._mids
2528
if mid <= 1 and len(mids) > 1: # Target has rebooted
2629
self._mids.clear()
30+
self.tot_miss += self.miss
31+
self.tot_dupe += self.dupe
32+
self.tot_oord += self.oord
2733
self.miss = 0
2834
self.dupe = 0
2935
self.oord = 0

iot/qos/s_qos_cp.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ async def start(self):
5252
outages = self.conn.nconns - 1
5353
ut = (time.time() - st) / 3600 # Uptime in hrs
5454
print('Uptime {:6.2f}hr outages {}'.format(ut, outages))
55-
print('Dupes ignored {} local {} remote. '.format(cm.dupe, data[3]), end='')
56-
print('Missed msg {} local {} remote.'.format(cm.miss, data[4]))
55+
print('Dupes ignored {} local {} remote. '.format(cm.tot_dupe, data[3]), end='')
56+
print('Missed msg {} local {} remote.'.format(cm.tot_miss, data[4]), end='')
57+
print('Client reboots', cm.bcnt)
5758

5859
async def reader(self):
5960
print('Started reader')

iot/qos/s_qos_fast.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ async def start(self):
5454
outages = self.conn.nconns - 1
5555
ut = (time.time() - st) / 3600 # Uptime in hrs
5656
print('Uptime {:6.2f}hr outages {}'.format(ut, outages))
57-
print('Dupes ignored {} local {} remote. '.format(cm.dupe, data[3]), end='')
58-
print('Missed msg {} local {} remote.'.format(cm.miss, data[4]))
57+
print('Dupes ignored {} local {} remote. '.format(cm.tot_dupe, data[3]), end='')
58+
print('Missed msg {} local {} remote.'.format(cm.tot_miss, data[4]), end='')
59+
print('Client reboots', cm.bcnt)
5960

6061
async def reader(self):
6162
print('Started reader')
62-
cm = CheckMid() # Check message ID's for dupes, missing etc.
6363
while True:
6464
line = await self.conn.readline() # Pause in event of outage
6565
data = json.loads(line)

0 commit comments

Comments
 (0)