コード例 #1
0
    def __init__(self, definition, connection, asset=None):
        """
        create the object
        :param connection: the connection to use
        :param asset: the asset object, if none, the object will be created from the definition,
        :param definition: a json dict that contains the definition for the stats. (see examples in definitions dir)
        """
        if not asset:
            self.asset = Sensor(definition['asset'], connection=connection)
        else:
            self.asset = asset
        self.groups = []
        self.timers = []
        groupNames = set(
        )  # used to check that all the groupnames are unique, otherwise, we have an issue.
        for group in definition['groups']:
            groupname = group['name']
            if groupname in groupNames:
                raise Exception(
                    "duplicate groupname '{}' detected in {}".format(
                        groupname, definition['name']))
            groupNames.add(groupname)

            reset = group['reset'] if 'reset' in group else None
            startDate = group['start date'] if 'start date' in group else None
            stat = Statistician(group['name'], group['calculate'], reset,
                                startDate, self.asset)
            self.groups.append(stat)
            if "reset" in group:
                timer = Timer(self.asset, group['name'])
                self.timers.append(timer)
                timer.group = stat
コード例 #2
0
    def load(self):
        # load all the service-objects. They work as functions, don't wrap the data, cause the data objects can be scattered
        to_add = DeviceTemplate()
        Service.all_services[to_add.get_name()] = to_add
        Service.template_service = to_add

        to_add = Statistician()
        Service.all_services[to_add.get_name()] = to_add

        to_add = Delay()
        Service.all_services[to_add.get_name()] = to_add

        to_add = NN()
        Service.all_services[to_add.get_name()] = to_add

        to_add = Rule()
        Service.all_services[to_add.get_name()] = to_add

        to_add = DeviceMonitor()
        Service.all_services[to_add.get_name()] = to_add
コード例 #3
0
ファイル: RnwMaker.py プロジェクト: unshur/OpenPsyc
    def __init__(self,
                 db,
                 table,
                 title="Data Party",
                 author="Christian Battista",
                 human=""):
        if human:
            self.human = human
        else:
            self.human = Statistician(db)

        self.title = title
        self.author = author
        self.name = title
        self.fname = self.name.replace(' ', '_')

        path = os.path.join("output", self.fname)

        f = open("%s.Rnw" % path, "w")

        self.f = f
        self.lvl = 1

        self.WriteTitle()