diff --git a/DAS/block.py b/DAS/block.py index e052fcb..228e743 100644 --- a/DAS/block.py +++ b/DAS/block.py @@ -35,10 +35,17 @@ class Block: self.data[columnID::self.blockSize] |= column def repairColumn(self, id): - """It repairs the entire column if it has at least blockSize/2 ones.""" - success = self.data[id::self.blockSize].count(1) + """It repairs the entire column if it has at least blockSize/2 ones. + Returns: list of repaired segments + """ + line = self.data[id::self.blockSize] + success = line.count(1) if success >= self.blockSize/2: + ret = ~line self.data[id::self.blockSize] = 1 + else: + ret = zeros(self.blockSize) + return ret def getRow(self, rowID): """It returns the block row corresponding to rowID.""" @@ -49,10 +56,17 @@ class Block: self.data[rowID*self.blockSize:(rowID+1)*self.blockSize] |= row def repairRow(self, id): - """It repairs the entire row if it has at least blockSize/2 ones.""" - success = self.data[id*self.blockSize:(id+1)*self.blockSize].count(1) + """It repairs the entire row if it has at least blockSize/2 ones. + Returns: list of repaired segments + """ + line = self.data[id*self.blockSize:(id+1)*self.blockSize] + success = line.count(1) if success >= self.blockSize/2: + ret = ~line self.data[id*self.blockSize:(id+1)*self.blockSize] = 1 + else: + ret = zeros(self.blockSize) + return ret def print(self): """It prints the block in the terminal (outside of the logger rules)).""" diff --git a/DAS/validator.py b/DAS/validator.py index d152472..5065e16 100644 --- a/DAS/validator.py +++ b/DAS/validator.py @@ -446,12 +446,28 @@ class Validator: def restoreRows(self): """It restores the rows assigned to the validator, that can be repaired.""" for id in self.rowIDs: - self.block.repairRow(id) + rep = self.block.repairRow(id) + if (rep.any()): + # If operation is based on send queues, segments should + # be queued after successful repair. + for i in range(len(rep)): + if rep[i]: + self.logger.debug("Rep: %d,%d", id, i, extra=self.format) + self.addToSendQueue(id, i) + # self.statsRepairInSlot += rep.count(1) def restoreColumns(self): """It restores the columns assigned to the validator, that can be repaired.""" for id in self.columnIDs: - self.block.repairColumn(id) + rep = self.block.repairColumn(id) + if (rep.any()): + # If operation is based on send queues, segments should + # be queued after successful repair. + for i in range(len(rep)): + if rep[i]: + self.logger.debug("Rep: %d,%d", i, id, extra=self.format) + self.addToSendQueue(i, id) + # self.statsRepairInSlot += rep.count(1) def checkStatus(self): """It checks how many expected/arrived samples are for each assigned row/column."""