Notifications
Clear all

python time accumulator

4 Posts
2 Users
0 Likes
309 Views
mr.meeseeks
(@mr-meeseeks)
Livingrimoire coder
Joined: 7 months ago
Posts: 19
Topic starter  

 

thug life

this class accumulates overtime. as time passes and the class ticks the accumulator increments its' value

in other words it is a counter that responds to the passage of time (in minutes).

from __future__ import annotations
from LivinGrimoireCoreV2 import *


class TimeAccumulator:
    def __init__(self, tick: int):
        self._timeGate: TimeGate = TimeGate(tick)
        self._accumulator: int = 0
        self._timeGate.openForPauseMinutes()

    def setTick(self, tick: int):
        self._timeGate.setPause(tick)

    def getAccumulator(self) -> int:
        return self._accumulator

    def reset(self):
        self._accumulator = 0

    def tick(self):
        if self._timeGate.isClosed():
            self._timeGate.openForPauseMinutes()
            self._accumulator += 1

usage in main :

 

    tg: TimeAccumulator = TimeAccumulator(2)
    for i in range(1, 60):
        tg.tick()
        b1.hardwareChobit.think(f'{tg.getAccumulator()}', "", "")  # print
        time.sleep(10)
This topic was modified 6 months ago by mr.meeseeks

Team Fuki


   
Quote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2502
 

I'm sorry, I don't know much about Python but I'm wondering ...

Posted by: @mr-meeseeks

 this class accumulates overtime.

What kind of overtime ? Work overtime, sports overtime ?

Posted by: @mr-meeseeks

 this class accumulates overtime. as time passes and the class ticks the accumulator increments its' value

in other words it is a counter that responds to the passage of time (in minutes). 

Why is it better than the time module ? That's already 'built in' and more accurate as well.

 

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
mr.meeseeks
(@mr-meeseeks)
Livingrimoire coder
Joined: 7 months ago
Posts: 19
Topic starter  

@will 

IDK I just personally find it comfortable to use it to recognize stand by phases in which

the program receives no data or no specific data for a certain duration.

 

kind of like when a parrot starts to chirp after a while of silence or bordom just to see if its' owner is still in the house.

the class builds on the time module actually:

https://github.com/yotamarker/public-livinGrimoire/blob/master/livingrimoire%20start%20here/LivinGrimoire%20python/python%20files/LivinGrimoireCoreV2.py

 

see TimeGate class

Team Fuki


   
ReplyQuote
mr.meeseeks
(@mr-meeseeks)
Livingrimoire coder
Joined: 7 months ago
Posts: 19
Topic starter  

by over time I meant over the course of passing time

just run the code and see

Team Fuki


   
ReplyQuote