
from sense_hat import SenseHat
from calvin.runtime.south.plugins.io.sensors.environmental import base_environmental


class Environmental(base_environmental.EnvironmentalBase):

    """
    Raspberry Pi Sense HAT environmental sensors
    """

    def __init__(self):
        self.sense = SenseHat()

    def get_temperature(self):
        return self.sense.get_temperature()

    def get_humidity(self):
        return self.sense.get_humidity()

    def get_pressure(self):
        return self.sense.get_pressure()


from sense_hat import SenseHat
from calvin.runtime.south.plugins.io.sensors.environmental import base_environmental


class SenseHatResourceHandler(object):
    
    sense_hat = SenseHat()

    def __init__(self):
        pass
    
    def get_temperature(self):
        return self.sense_hat.get_temperature()
        
    def get_humidity(self):
        return self.sense_hat.get_humidity()
        
    def get_pressure(self):
        return self.sense_hat.get_pressure()


class Environmental(base_environmental.EnvironmentalBase):

    """
    Raspberry Pi Sense HAT environmental sensors
    """

    def __init__(self):
        self.sense = SenseHatResourceHandler()

    def get_temperature(self):
        return self.sense.get_temperature()

    def get_humidity(self):
        return self.sense.get_humidity()

    def get_pressure(self):
        return self.sense.get_pressure()

Allow use of sensors from more than one actor concurrenctly
Sensehat: Allow use of sensors from more than one actor concurrenctly

  
  from sense_hat import SenseHat
  from calvin.runtime.south.plugins.io.sensors.environmental import base_environmental
+ 
+ 
+ class SenseHatResourceHandler(object):
+     
+     sense_hat = SenseHat()
+ 
+     def __init__(self):
+         pass
+     
+     def get_temperature(self):
+         return self.sense_hat.get_temperature()
+         
+     def get_humidity(self):
+         return self.sense_hat.get_humidity()
+         
+     def get_pressure(self):
+         return self.sense_hat.get_pressure()
  
  
  class Environmental(base_environmental.EnvironmentalBase):
  
      """
      Raspberry Pi Sense HAT environmental sensors
      """
  
      def __init__(self):
-         self.sense = SenseHat()
+         self.sense = SenseHatResourceHandler()
  
      def get_temperature(self):
          return self.sense.get_temperature()
  
      def get_humidity(self):
          return self.sense.get_humidity()
  
      def get_pressure(self):
          return self.sense.get_pressure()
  
Allow use of sensors from more than one actor concurrenctly
## Code Before:

from sense_hat import SenseHat
from calvin.runtime.south.plugins.io.sensors.environmental import base_environmental


class Environmental(base_environmental.EnvironmentalBase):

    """
    Raspberry Pi Sense HAT environmental sensors
    """

    def __init__(self):
        self.sense = SenseHat()

    def get_temperature(self):
        return self.sense.get_temperature()

    def get_humidity(self):
        return self.sense.get_humidity()

    def get_pressure(self):
        return self.sense.get_pressure()

## Instruction:
Allow use of sensors from more than one actor concurrenctly
## Code After:

from sense_hat import SenseHat
from calvin.runtime.south.plugins.io.sensors.environmental import base_environmental


class SenseHatResourceHandler(object):
    
    sense_hat = SenseHat()

    def __init__(self):
        pass
    
    def get_temperature(self):
        return self.sense_hat.get_temperature()
        
    def get_humidity(self):
        return self.sense_hat.get_humidity()
        
    def get_pressure(self):
        return self.sense_hat.get_pressure()


class Environmental(base_environmental.EnvironmentalBase):

    """
    Raspberry Pi Sense HAT environmental sensors
    """

    def __init__(self):
        self.sense = SenseHatResourceHandler()

    def get_temperature(self):
        return self.sense.get_temperature()

    def get_humidity(self):
        return self.sense.get_humidity()

    def get_pressure(self):
        return self.sense.get_pressure()
