from hal_impl.data import hal_data

class PyFrcFakeHooks:
    '''
        Defines hal hooks that use the fake time object
    '''
    
    def __init__(self, fake_time):
        self.fake_time = fake_time
    #
    # Hook functions
    #
    
    def getTime(self):
        return self.fake_time.get()
    
    def getFPGATime(self):
        return int((self.fake_time.get() - hal_data['time']['program_start']) * 1000000)
    
    def delayMillis(self, ms):
        self.fake_time.increment_time_by(.001 * ms)
    
    def delaySeconds(self, s):
        self.fake_time.increment_time_by(s)
    
    def initializeDriverStation(self):
        pass
    
    @property
    def ds_cond(self):
        return self.fake_time.ds_cond
    
    @ds_cond.setter
    def ds_cond(self, value):
        pass # ignored
        

from hal_impl.sim_hooks import SimHooks

class PyFrcFakeHooks(SimHooks):
    '''
        Defines hal hooks that use the fake time object
    '''
    
    def __init__(self, fake_time):
        self.fake_time = fake_time
        super().__init__()
    
    #
    # Time related hooks
    #
    
    def getTime(self):
        return self.fake_time.get()
    
    def delayMillis(self, ms):
        self.fake_time.increment_time_by(.001 * ms)
    
    def delaySeconds(self, s):
        self.fake_time.increment_time_by(s)
    
    #
    # DriverStation related hooks
    #
    
    @property
    def ds_cond(self):
        return self.fake_time.ds_cond
    
    @ds_cond.setter
    def ds_cond(self, value):
        pass # ignored
        
Update sim hooks for 2018
Update sim hooks for 2018

- from hal_impl.data import hal_data
  
+ from hal_impl.sim_hooks import SimHooks
+ 
- class PyFrcFakeHooks:
+ class PyFrcFakeHooks(SimHooks):
      '''
          Defines hal hooks that use the fake time object
      '''
      
      def __init__(self, fake_time):
          self.fake_time = fake_time
+         super().__init__()
+     
      #
-     # Hook functions
+     # Time related hooks
      #
      
      def getTime(self):
          return self.fake_time.get()
-     
-     def getFPGATime(self):
-         return int((self.fake_time.get() - hal_data['time']['program_start']) * 1000000)
      
      def delayMillis(self, ms):
          self.fake_time.increment_time_by(.001 * ms)
      
      def delaySeconds(self, s):
          self.fake_time.increment_time_by(s)
      
-     def initializeDriverStation(self):
-         pass
+     #
+     # DriverStation related hooks
+     #
      
      @property
      def ds_cond(self):
          return self.fake_time.ds_cond
      
      @ds_cond.setter
      def ds_cond(self, value):
          pass # ignored
          
Update sim hooks for 2018
## Code Before:
from hal_impl.data import hal_data

class PyFrcFakeHooks:
    '''
        Defines hal hooks that use the fake time object
    '''
    
    def __init__(self, fake_time):
        self.fake_time = fake_time
    #
    # Hook functions
    #
    
    def getTime(self):
        return self.fake_time.get()
    
    def getFPGATime(self):
        return int((self.fake_time.get() - hal_data['time']['program_start']) * 1000000)
    
    def delayMillis(self, ms):
        self.fake_time.increment_time_by(.001 * ms)
    
    def delaySeconds(self, s):
        self.fake_time.increment_time_by(s)
    
    def initializeDriverStation(self):
        pass
    
    @property
    def ds_cond(self):
        return self.fake_time.ds_cond
    
    @ds_cond.setter
    def ds_cond(self, value):
        pass # ignored
        
## Instruction:
Update sim hooks for 2018
## Code After:

from hal_impl.sim_hooks import SimHooks

class PyFrcFakeHooks(SimHooks):
    '''
        Defines hal hooks that use the fake time object
    '''
    
    def __init__(self, fake_time):
        self.fake_time = fake_time
        super().__init__()
    
    #
    # Time related hooks
    #
    
    def getTime(self):
        return self.fake_time.get()
    
    def delayMillis(self, ms):
        self.fake_time.increment_time_by(.001 * ms)
    
    def delaySeconds(self, s):
        self.fake_time.increment_time_by(s)
    
    #
    # DriverStation related hooks
    #
    
    @property
    def ds_cond(self):
        return self.fake_time.ds_cond
    
    @ds_cond.setter
    def ds_cond(self, value):
        pass # ignored
        