def decode(self, m): m = np.rot90(m) # same shape as EFF format = dict(minutes=1, hour=4, day=5, month=6, year=7, serial=(12, 11, 10), unknown1=2, manufacturer=3, unknown3=8, unknown4=13, unknown5=14, printer=(13, 12, 11, 10)) decoded = {} for key, cols in format.items(): if not isinstance(cols, tuple): cols = (cols, ) decoded[key] = "".join( ["%02d" % int(array2str(m[col, 1:]), 2) for col in cols]) decoded["raw"] = "".join([ "%02d" % int(array2str(m[col + 1, 1:]), 2) for col in range(m.shape[0] - 1) ]) if decoded["manufacturer"].isdigit() \ and int(decoded["manufacturer"]) in self.manufacturers: decoded["manufacturer"] = self.manufacturers.get( int(decoded["manufacturer"])) else: decoded["manufacturer"] = "Xerox/Dell/Epson" if decoded["manufacturer"] == "Dell": decoded["serial"] = None else: decoded["serial"] = "-%s-" % decoded["serial"] return decoded
def decode(self,m): trans = {'0001':0, '0010':1, '0100':2, '1000':3} blocks = ["".join([str(trans[array2str(w)]) for w in words[0:4]]) for words in m] raw = "-".join(blocks) return dict(raw=raw, printer=raw, manufacturer=self.manufacturers.get(blocks[0]))
def decode(self,m): trans = {'000001':0, '000010':1, '000100':2, '001000':3, '010000':4, '100000':5} blocks = [str(trans[array2str(block)]) for block in m] raw = "--%s -%s %s %s %s"%( "".join(blocks[0:4]),"".join(blocks[4:9]),"".join(blocks[9:15]), "".join(blocks[15:21]),"".join(blocks[21:27])) return dict(raw=raw, printer=raw, manufacturer="Konica Minolta/Epson")
def decode(self,m): m = np.rot90(m) # same shape as EFF format = dict( minutes=1, hour=4, day=5, month=6, year=7, serial=(12,11,10), unknown1=2, manufacturer=3, unknown3=8, unknown4=13, unknown5=14, printer=(13,12,11,10)) decoded = {} for key,cols in format.items(): if not isinstance(cols,tuple): cols = (cols,) decoded[key] = "".join( ["%02d"%int(array2str(m[col,1:]),2) for col in cols]) decoded["raw"] = "".join(["%02d"%int(array2str(m[col+1,1:]),2) for col in range(m.shape[0]-1)]) if decoded["manufacturer"].isdigit() \ and int(decoded["manufacturer"]) in self.manufacturers: decoded["manufacturer"] = self.manufacturers.get( int(decoded["manufacturer"])) else: decoded["manufacturer"] = "Xerox/Dell/Epson" if decoded["manufacturer"] == "Dell": decoded["serial"] = None else: decoded["serial"] = "-%s-"%decoded["serial"] return decoded
def decode(self, aligned): m = np.array([[[aligned[x, y] for x, y in word] for word in words] for words in self.blocks]) trans = {'0001': 0, '0010': 1, '0100': 2, '1000': 3} blocks = [ "".join([str(trans[array2str(w)]) for w in words[0:4]]) for words in m ] raw = "-".join(blocks) return dict(raw=raw, printer=raw, manufacturer=self.manufacturers.get(blocks[0]))
def decodeItem(self, aligned, name): rows = self.format[name] if not isinstance(rows, tuple): rows = (rows, ) decoded = "".join( ["%02d" % int(array2str(aligned[1:, row]), 2) for row in rows]) if name == "manufacturer": if decoded.isdigit() and int(decoded) in self.manufacturers: return self.manufacturers.get(int(decoded)) else: return "Xerox/Dell/Epson" elif name == "serial": if self.decodeItem(aligned, "manufacturer") == "Dell": return None else: return "-%s-" % decoded else: return decoded
def decode(self, aligned): m = aligned[:, 0:16] m = np.array([[m[x, y] for x, y in b] for b in self.blocks]) trans = { '000001': 0, '000010': 1, '000100': 2, '001000': 3, '010000': 4, '100000': 5 } blocks = [str(trans[array2str(block)]) for block in m] raw = "--%s -%s %s %s %s" % ("".join(blocks[0:4]), "".join( blocks[4:9]), "".join(blocks[9:15]), "".join( blocks[15:21]), "".join(blocks[21:27])) return dict(raw=raw, printer=raw, manufacturer="Konica Minolta/Epson")
def decode(self, aligned): return dict(manufacturer="Canon", raw=array2str(aligned))