# Path: sydpy/_util/_injector.py
# class RequiredFeature(object):
#     def __init__(self, feature, assertion=NoAssertion):
#         self.feature = feature
#         self.assertion = assertion
#     def __get__(self, obj, T):
#         return self.result # <-- will request the feature upon first call
#     def __getattr__(self, name):
#         assert name == 'result', "Unexpected attribute request other then 'result'"
#         self.result = self.Request()
#         return self.result
#     def Request(self):
#         obj = features[self.feature]
#         assert self.assertion(obj), \
#                  "The value %r of %r does not match the specified criteria" \
#                  % (obj, self.feature)
#         return obj


from sydpy._util._injector import RequiredFeature
#  This file is part of sydpy.
# 
#  Copyright (C) 2014-2015 Bogdan Vukobratovic
#
#  sydpy is free software: you can redistribute it and/or modify 
#  it under the terms of the GNU Lesser General Public License as 
#  published by the Free Software Foundation, either version 2.1 
#  of the License, or (at your option) any later version.
# 
#  sydpy is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Lesser General Public License for more details.
# 
#  You should have received a copy of the GNU Lesser General 
#  Public License along with sydpy.  If not, see 
#  <http://www.gnu.org/licenses/>.


class SimtimeProgress(object):
    
    configurator = RequiredFeature('Configurator')

    def log_begin_timestep(self, time, sim):
        if time > (self.old_time + self.step):
            self.old_time = (time // self.step) * self.step

# Path: sydpy/_util/_injector.py
# class RequiredFeature(object):
#     def __init__(self, feature, assertion=NoAssertion):
#         self.feature = feature
#         self.assertion = assertion
#     def __get__(self, obj, T):
#         return self.result # <-- will request the feature upon first call
#     def __getattr__(self, name):
#         assert name == 'result', "Unexpected attribute request other then 'result'"
#         self.result = self.Request()
#         return self.result
#     def Request(self):
#         obj = features[self.feature]
#         assert self.assertion(obj), \
#                  "The value %r of %r does not match the specified criteria" \
#                  % (obj, self.feature)
#         return obj


# Path: sydpy/extens/simprog.py
from sydpy._util._injector import RequiredFeature

#  This file is part of sydpy.
# 
#  Copyright (C) 2014-2015 Bogdan Vukobratovic
#
#  sydpy is free software: you can redistribute it and/or modify 
#  it under the terms of the GNU Lesser General Public License as 
#  published by the Free Software Foundation, either version 2.1 
#  of the License, or (at your option) any later version.
# 
#  sydpy is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU Lesser General Public License for more details.
# 
#  You should have received a copy of the GNU Lesser General 
#  Public License along with sydpy.  If not, see 
#  <http://www.gnu.org/licenses/>.


class SimtimeProgress(object):
    
    configurator = RequiredFeature('Configurator')

    def log_begin_timestep(self, time, sim):
        if time > (self.old_time + self.step):
            self.old_time = (time // self.step) * self.step

            print("--{0}--".format(self.old_time))