Exemple #1
0
    def restarthardware(self, device, hardwares):

        try:
            self.logger.info("try to restart device")
            self.stophardware(device, hardwares)
            # Give 10 seconds to stop
            self.logger.info("waiting for 10 sec to stop device")
            time.sleep(ConfigHelper.getstartinterval(device))
            self.logger.info("Device stopped")
            # Start Device again
            self.logger.info("try to again start device")
            self.starthardware(device, hardwares)
            self.logger.info("Device Restarted successfully ")

    # Method to disable a specific hardware based on name
        except:
            e = sys.exc_info()[0]
            self.logger.error("Exception in restarthardware() Method:" +
                              str(e))
            self.events.hardware_exception(e)
import uuid
import json
import time
from playhouse.shortcuts import model_to_dict, dict_to_model
from events import Events
from managers import hardwareevents,cloudevents




class deviceManager(BaseManager):
    pass
    
    
# Read the Config File
c = ConfigHelper('C:\\shunya\\IOT.Device.SmartTrack\\CONFIG_FILES\\Demo_Route_drop_15_tst.INI')
log = LoggingHelper(ConfigHelper.logconfig.disabled, ConfigHelper.logconfig.logtoconsole)



# Initialize the Database Specified as per the config file
localdb = pw.SqliteDatabase(ConfigHelper.dbfile)
log.info("setiing up Database file ")

md.proxy.initialize(localdb) 
log.info("Database initialize")

md.devicedata.create_table(True)
log.info("Creating table")

cm = cloudmanager(log)
import uuid
import json
import time
from playhouse.shortcuts import model_to_dict, dict_to_model
from events import Events
from managers import hardwareevents,cloudevents




class deviceManager(BaseManager):
    pass
    
    
# Read the Config File
c = ConfigHelper('C:\\shunya\\IOT.Device.SmartTrack\\CONFIG_FILES\\Demo_Route_pick_18.INI')
log = LoggingHelper(ConfigHelper.logconfig.disabled, ConfigHelper.logconfig.logtoconsole)



# Initialize the Database Specified as per the config file
localdb = pw.SqliteDatabase(ConfigHelper.dbfile)
log.info("setiing up Database file ")

md.proxy.initialize(localdb) 
log.info("Database initialize")

md.devicedata.create_table(True)
log.info("Creating table")

cm = cloudmanager(log)
from managers import *
import uuid
import json
import time
from playhouse.shortcuts import model_to_dict, dict_to_model
from events import Events
from managers import hardwareevents, cloudevents
from time import sleep


class deviceManager(BaseManager):
    pass


# Read the Config File
c = ConfigHelper('/home/pi/mycode/IOT.Device.SmartTrack/config/SmartTrack.INI')
log = LoggingHelper(ConfigHelper.logconfig.disabled,
                    ConfigHelper.logconfig.logtoconsole)

# Initialize the Database Specified as per the config file
localdb = pw.SqliteDatabase(ConfigHelper.dbfile)
log.info("setiing up Database file ")

md.proxy.initialize(localdb)
log.info("Database initialize")

md.devicedata.create_table(True)
log.info("Creating table")

cm = cloudmanager(log)
log.info("cloud manager class object created")
Exemple #5
0
 def disable(self):
     """ Disable hardware """
     self.enabled = False
     # Save the value
     ConfigHelper.disabledevice(self.name)
Exemple #6
0
 def enable(self):
     """ Enable hardware """
     self.enabled = True
     # Save the value in config file
     ConfigHelper.enabledevice(self.name)