#####
# 
# This class is part of the Programming the Internet of Things project.
# 
# It is provided as a simple shell to guide the student and assist with
# implementation for the Programming the Internet of Things exercises,
# and designed to be modified by the student as needed.
#


from programmingtheiot.data.SensorData import SensorData
import logging


class BaseSystemUtilTask():
    """
    Shell representation of class for student implementation.
    
    """
    
    def __init__(self):
        
        #Variables
        self.latestSensorData = None
        
    
    def generateTelemetry(self) -> SensorData:
        """
        senseData is an instance of SensorData reference to latest.
        """
        self.senseData = SensorData(self.latestSensorData)
        self.latestSensorData = self._getSystemUtil()
        return self.senseData
        
    def getTelemetryValue(self) -> float:
        """
        Retrieve the Telemetry Value as a float
        """
        if self.latestSensorData == None:
            self.latestSensorData = self.generateTelemetry()
        logging.info("The telemetry value %s is: %f",self.__class__.__name__,self.latestSensorData)
        return self.latestSensorData
        
    
    def _getSystemUtil(self) -> float:
        """
        Template method implemented by sub-class.
        
        Retrieve the system utilization value as a float.
        
        @return float
        """
        pass
        





#####
# 
# This class is part of the Programming the Internet of Things project.
# 
# It is provided as a simple shell to guide the student and assist with
# implementation for the Programming the Internet of Things exercises,
# and designed to be modified by the student as needed.
#


from programmingtheiot.data.SensorData import SensorData
import logging


class BaseSystemUtilTask():
    """
    Shell representation of class for student implementation.
    
    """
    
    def __init__(self):
        
        #Variables
        self.latestSensorData = None
        
    
    def generateTelemetry(self) -> SensorData:
        """
        senseData is an instance of SensorData reference to latest.
        """
        self.senseData = SensorData(self.latestSensorData)
        self.latestSensorData = self._getSystemUtil()
        return self.senseData
        
    def getTelemetryValue(self) -> float:
        """
        Retrieve the Telemetry Value as a float
        """
        if self.latestSensorData == None:
            self.latestSensorData = self.generateTelemetry()
        logging.info("The telemetry value %s is: %f",self.__class__.__name__,self.latestSensorData)
        return self.latestSensorData
        
    
    def _getSystemUtil(self) -> float:
        """
        Template method implemented by sub-class.
        
        Retrieve the system utilization value as a float.
        
        @return float
        """
        pass
        





##### # # This class is part of the Programming the Internet of Things project. # # It is provided as a simple shell to guide the student and assist with # implementation for the Programming the Internet of Things exercises, # and designed to be modified by the student as needed. # Shell representation of class for student implementation. #Variables senseData is an instance of SensorData reference to latest. Retrieve the Telemetry Value as a float Template method implemented by sub-class.                  Retrieve the system utilization value as a float.                  @return float