"""
Implementation of an stateful OmniGraph node that counts to a number defined by countTo
"""


class OgnCountTo:
    @staticmethod
    def compute(db):

        if db.inputs.reset:
            db.outputs.count = 0
        else:
            db.outputs.count = db.outputs.count + db.inputs.increment
            if db.outputs.count > db.inputs.countTo:
                db.outputs.count = db.inputs.countTo
            else:
                db.node.set_compute_incomplete()

        return True
