blob: 7e2b0afd9b0f10541654bf2d2f45674e6c9bd486 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
from operationscore.SmootCoreObject import *
from logger import main_log
import pdb
class PixelMapper(SmootCoreObject):
def init(self):
self.mem = {} #Dictionary of all seen events
self.totalCalls = 0
self.cachehits = 0
def mapEvent(self, eventLocation, screen):
self.totalCalls += 1
if self.totalCalls % 100 == 0:
main_log.info('Cache percentage for :', self['Id'], self.cachehits /\
float(self.totalCalls))
if eventLocation in self.mem:
self.cachehits += 1
return self.mem[eventLocation]
else:
self.mem[eventLocation] = self.mappingFunction(eventLocation, screen)
return self.mem[eventLocation]
#Takes a Screen and returns a list of tuples
#(pixel, weight), with the sum of weights = 1
#TODO: consider abstracting away from pixels
def mappingFunction(self,eventLocation, screen):
pass
|