Example #1
0
    def __init__(self, **kwargs):
        required = {'User': str, 'Password': str, 'Name': str, 'ip': str}
        self.success, error = required_args(kwargs, required)
        if (self.success):
            try:
                self.port = kwargs['port']
            except KeyError:
                self.port = 1710  #standard port

            self.__dict__.update(**kwargs)
            self.logger = Log(log_path="./test_logs/",
                              name='Core_{ip}'.format(**self.__dict__),
                              level=1)
            self.logger.log(
                lineno() +
                "<qsys.classes.Core object - {}> initialized".format(
                    self.Name), 1)

            #store objects and change groups
            self.Objects = {}
            self.ChangeGroups = {}

            self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
            self.ConnectionMethods = ConnectionMethods(parent=self,
                                                       User=self.User,
                                                       Password=self.Password)
            self.StatusMethods = StatusMethods(parent=self)
            self._stop = False  #set stop state in threads
        else:
            init_logger.log(
                lineno() +
                "<qsys.classes.Core class> __init__ () | {}".format(error), 5)
Example #2
0
 def __init__(self, **kwargs):
     required = {'parent': Core}
     success, error = required_args(kwargs, required)
     if (success):
         self.__dict__.update(**kwargs)
     else:
         init_logger.log(
             lineno() +
             "<qsys.classes.ComponentControl class> __init__() | {}".format(
                 error), 5)
Example #3
0
 def __init__(self, **kwargs):
     required = {'parent': Core, 'User': str, 'Password': str}
     success, error = required_args(kwargs, required)
     if (success):
         self.__dict__.update(**kwargs)
     else:
         init_logger.log(
             lineno() +
             "<qsys.classes.ConnectionMethods class> __init__() | {}".
             format(error), 5)
Example #4
0
 def get(self, **kwargs):
     required = {'TransId': [int, float]}
     success, error = required_args(kwargs, required)
     if (success):
         return self.send(self.parent.sock,
                          self.parent.logger,
                          method='Control.Get',
                          id=kwargs['TransId'],
                          params=[self.Name])
     else:
         self.parent.logger.log(
             lineno() +
             "<qsys.classes.Control object - {}> get() | {}".format(
                 self.Name, error), 5)
         return False
Example #5
0
 def StatusGet(self, **kwargs):
     required = {'TransId': [int, float]}
     success, error = required_args(kwargs, required)
     if (success):
         return self.send(self.parent.sock,
                          self.parent.logger,
                          method='StatusGet',
                          id=kwargs['TransId'],
                          params=0)
     else:
         self.parent.logger.log(
             lineno() +
             "<qsys.classes.StatusMethods class> StatusGet() | {}".format(
                 error), 5)
         return False
Example #6
0
 def AutoPoll(self, **kwargs):
     required = {'Rate': [int, float]}
     success, error = required_args(kwargs, required)
     if (success):
         self.AutoPollState = True
         self.AutoPollRate = kwargs['Rate']
         return self.send(self.parent.sock,
                          self.parent.logger,
                          method='ChangeGroup.AutoPoll',
                          id=epoch(),
                          params={
                              'Id': self.Id,
                              'Rate': self.AutoPollRate
                          })
     else:
         self.parent.logger.log(
             lineno() +
             "<qsys.classes.qsys.ChangeGroup object - {}> AutoPoll() | {}".
             format(self.Id, error), 5)
Example #7
0
 def __init__(self, **kwargs):
     required = {'parent': Core, 'Id': str}
     success, error = required_args(kwargs, required)
     if (success):
         self.__dict__.update(**kwargs)
         if (self.__cast__()):
             self.AutoPollState = False
             self.AutoPollRate = False
             self.init = True
         else:
             self.init = False
             init_logger.log(
                 lineno() +
                 "<qsys.classes.ChangeGroup object> __init__() | failed to __cast__() to parent",
                 5)
     else:
         init_logger.log(
             lineno() +
             "<qsys.classes.ChangeGroup object> __init__() | {} | Args: {}".
             format(error, kwargs), 5)
         self.init = False
Example #8
0
 def set(self, **kwargs):
     required = {
         'TransId': [int, float],
         'Value': self.ValueType
     }  #optional 'Ramp' parameter - sets ramp time used to set the control
     success, error = required_args(kwargs, required)
     if (success):
         kwargs['Name'] = self.Name
         return self.send(self.parent.sock,
                          self.parent.logger,
                          method='Control.Set',
                          id=kwargs['TransId'],
                          params={
                              k: v
                              for k, v in kwargs.items()
                              if k not in IgnoreKeys
                          })
     else:
         self.parent.logger.log(
             lineno() +
             "<qsys.classes.Control object - {}> set() | {}".format(
                 self.Name, error), 5)
         return False
Example #9
0
 def __init__(self, **kwargs):
     required = {'parent': Core, 'Name': str, 'ValueType': '*'}
     success, error = required_args(kwargs, required)
     if (success):
         self.__dict__.update(**kwargs)
         if (self.__cast__()):
             self.init = True
             self.state = {}
             self.last_state = {}
             self.change = False
             self.get(TransId=epoch())
         else:
             init_logger.log(
                 lineno() +
                 "<qsys.classes.Control object> __init__() | failed to __cast__() to parent",
                 5)
             self.init = False
     else:
         init_logger.log(
             lineno() +
             "<qsys.classes.Control object> __init__() | {} | Args: {}".
             format(error, kwargs), 5)
         self.init = False