# Path: lib/baseClass.py
# class AbstractClass(object):
#     """
#     Generic parent class for all class
#     """
#     __metaclass__ = ABCMeta
# 
#     @classmethod
#     def get_config(cls):
#         return {}
# 
#     """
#     __init__ params'name must be the same with config
#     """
#     @classmethod
#     def get_instance(cls):
#         config = cls.get_config()
#         instance = cls(**config)
#         return instance
# 
#     @classmethod
#     @abstractmethod
#     def is_available(cls):
#         return true
# 
#     def __init__(self, **kwargs):
#         self._logger = lib.util.init_logger(__name__)


import sys,os,time
import yaml
import RPi.GPIO as GPIO
import lib.appPath
from lib.baseClass import AbstractClass
        config = {}
        config_path = os.path.join(lib.appPath.CONFIG_PATH, 'gpio.yml');
        if os.path.exists(config_path):
            with open(config_path, 'r') as f:
                profile = yaml.safe_load(f)
                if 'led' in profile:
                    profile = profile['led']
                    if 'green_bcm' in profile:
                        config['green_bcm'] = profile['green_bcm']
        return config

    def __init__(self,green_bcm):
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(green_bcm, GPIO.OUT)
        self.green_bcm = green_bcm
        self.on_state = GPIO.HIGH
        self.off_state = not self.on_state

    def get_bcm_port(self):
        return str(self.green_bcm)
    def set_on(self):
        GPIO.output(self.green_bcm, self.on_state)
    def set_off(self):
        GPIO.output(self.green_bcm, self.off_state)
    def is_on(self):
        return GPIO.input(self.green_bcm) == self.on_state
    def is_off(self):
        return GPIO.input(self.green_bcm) == self.off_state
    def toggle(self):
        if self.is_on():

# Path: lib/baseClass.py
# class AbstractClass(object):
#     """
#     Generic parent class for all class
#     """
#     __metaclass__ = ABCMeta
# 
#     @classmethod
#     def get_config(cls):
#         return {}
# 
#     """
#     __init__ params'name must be the same with config
#     """
#     @classmethod
#     def get_instance(cls):
#         config = cls.get_config()
#         instance = cls(**config)
#         return instance
# 
#     @classmethod
#     @abstractmethod
#     def is_available(cls):
#         return true
# 
#     def __init__(self, **kwargs):
#         self._logger = lib.util.init_logger(__name__)


# Path: lib/gpio/led.py
import sys,os,time
import yaml
import RPi.GPIO as GPIO
import lib.appPath
from lib.baseClass import AbstractClass

        config = {}
        config_path = os.path.join(lib.appPath.CONFIG_PATH, 'gpio.yml');
        if os.path.exists(config_path):
            with open(config_path, 'r') as f:
                profile = yaml.safe_load(f)
                if 'led' in profile:
                    profile = profile['led']
                    if 'green_bcm' in profile:
                        config['green_bcm'] = profile['green_bcm']
        return config

    def __init__(self,green_bcm):
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(green_bcm, GPIO.OUT)
        self.green_bcm = green_bcm
        self.on_state = GPIO.HIGH
        self.off_state = not self.on_state

    def get_bcm_port(self):
        return str(self.green_bcm)
    def set_on(self):
        GPIO.output(self.green_bcm, self.on_state)
    def set_off(self):
        GPIO.output(self.green_bcm, self.off_state)
    def is_on(self):
        return GPIO.input(self.green_bcm) == self.on_state
    def is_off(self):
        return GPIO.input(self.green_bcm) == self.off_state
    def toggle(self):
        if self.is_on():

            self.set_off()