Ejemplo n.º 1
0
    def getSignalStructure(self):
        structure = []
        try:
            response = self.connection.Get_Signal_Structure(self.config.getAttr('session_id'))
            if len(response) <= 1:
                if response["state"] == 0:
                    print "Success response state but with unespected results. Message: \"%s\"" % (response['str'])
                    return False
                else:
                    print "Error with message: \"%s\"" % (response['str'])
                    return False
            else:
                msg = response.pop(0)
                state = getStateFromResponse(msg['state'])
                if state['error']:
                    print "Error with message: \"%s\"" % (msg['str'])
                    return False
                else:
                    for index, val in enumerate(response):
                        struct = {}
                        # Gets the index which will be used to call other methods which wants the number of the signal
                        struct['number'] = index
                        struct['name'] = val['str']
                        struct['traces_num'] = val['i4']
                        struct['sample_time'] = val['d']
                        struct['traces_names'] = val['tstr']

                        # If 'traces_names' creates problems we can use:
                        #for k, v in val.iteritems():
                            #struct[k] = v

                        structure.append(struct)
                    return structure
        except:
            return False
Ejemplo n.º 2
0
 def getParameters(self):
     parameters = []
     try:
         response = self.connection.Get_Param(self.config.getAttr('session_id'))
         if len(response) <= 1:
             if response["state"] == 0:
                 print "Success response state but with unespected results. Message: \"%s\"" % (response['str'])
                 return False
             else:
                 print "Error with message: \"%s\"" % (response['str'])
                 return False
         else:
             msg = response.pop(0)
             state = getStateFromResponse(msg['state'])
             if state['error']:
                 print "Error with message: \"%s\"" % (msg['str'])
                 return False
             else:
                 for val in response:
                     struct = {}
                     struct['block_name'] = val[0]
                     struct['param_name'] = val[1]
                     struct['rows'] = val[2]
                     struct['cols'] = val[3]
                     struct['values'] = val[4]
                     parameters.append(struct)
                 return parameters
     except:
         return False
Ejemplo n.º 3
0
    def setParameters(self, params):
        values = [self.config.getAttr('session_id')]

        formatted_params = []
        for val in params:
            element = []
            element.append(val['block_name'])
            element.append(val['param_name'])
            element.append(val['rows'])
            element.append(val['cols'])
            element.append(val['values'])
            formatted_params.append(element)

        values.append(formatted_params)
        try:
            response = self.connection.Send_Param(values)
            # TODO: Fare il check controllando l'esistenza della chiave 'state' e non sulla lunghezza
            if len(response) <= 2:
                if response["state"] == 0:
                    print "Success response state but with unespected results. Message: \"%s\"" % (response['str'])
                    return False
                else:
                    print "Error with message: \"%s\"" % (response['str'])
                    return False
            else:
                msg = response.pop(0)
                state = getStateFromResponse(msg['state'])
                if state['error']:
                    print "Error with message: \"%s\"" % (msg['str'])
                    return False
                else:
                    return response
        except:
            return False
Ejemplo n.º 4
0
    def setParameters(self, params):
        values = [self.config.getAttr('session_id')]

        formatted_params = []
        for val in params:
            element = []
            element.append(val['block_name'])
            element.append(val['param_name'])
            element.append(val['rows'])
            element.append(val['cols'])
            element.append(val['values'])
            formatted_params.append(element)

        values.append(formatted_params)
        try:
            response = self.connection.Send_Param(values)
            # TODO: Fare il check controllando l'esistenza della chiave 'state' e non sulla lunghezza
            if len(response) <= 2:
                if response["state"] == 0:
                    print "Success response state but with unespected results. Message: \"%s\"" % (
                        response['str'])
                    return False
                else:
                    print "Error with message: \"%s\"" % (response['str'])
                    return False
            else:
                msg = response.pop(0)
                state = getStateFromResponse(msg['state'])
                if state['error']:
                    print "Error with message: \"%s\"" % (msg['str'])
                    return False
                else:
                    return response
        except:
            return False
Ejemplo n.º 5
0
 def getParameters(self):
     parameters = []
     try:
         response = self.connection.Get_Param(
             self.config.getAttr('session_id'))
         if len(response) <= 1:
             if response["state"] == 0:
                 print "Success response state but with unespected results. Message: \"%s\"" % (
                     response['str'])
                 return False
             else:
                 print "Error with message: \"%s\"" % (response['str'])
                 return False
         else:
             msg = response.pop(0)
             state = getStateFromResponse(msg['state'])
             if state['error']:
                 print "Error with message: \"%s\"" % (msg['str'])
                 return False
             else:
                 for val in response:
                     struct = {}
                     struct['block_name'] = val[0]
                     struct['param_name'] = val[1]
                     struct['rows'] = val[2]
                     struct['cols'] = val[3]
                     struct['values'] = val[4]
                     parameters.append(struct)
                 return parameters
     except:
         return False
Ejemplo n.º 6
0
 def disconnect(self):
     try:
         req = self.connection.Disconnect(self.config.getAttr('session_id'))
         state = getStateFromResponse(req['state'])
         if not state['error']:
             print("Server successfully disconnected with result %s" % req['str'])
             return True
         else:
             return False
     except:
         return False
Ejemplo n.º 7
0
 def stopAllData(self):
     try:
         req = self.connection.Stop_All_Data(self.config.getAttr('session_id'))
         state = getStateFromResponse(req['state'])
         if not state['error']:
             print("Data successfully stopped with result %s" % req['str'])
             return True
         else:
             return False
     except:
         return False
Ejemplo n.º 8
0
 def stopData(self, signal_number):
     try:
         req = self.connection.Stop_Data(self.config.getAttr('session_id'), signal_number)
         state = getStateFromResponse(req['state'])
         if not state['error']:
             print("Data successfully stopped for signal %d with result %s" % (signal_number, req['str']))
             return True
         else:
             return False
     except:
         return False
Ejemplo n.º 9
0
 def stopTarget(self):
     try:
         req = self.connection.Stop(self.config.getAttr('session_id'))
         # TODO: in case of error the response is {'state': 0, 'str': 'No TEST target or bad interface task identifier'} and not in the 4-bit format!
         state = getStateFromResponse(req['state'])
         if not state['error']:
             print("Server successfully stopped with result %s" % req['str'])
             return True
         else:
             return False
     except:
         return False
Ejemplo n.º 10
0
 def disconnect(self):
     try:
         req = self.connection.Disconnect(self.config.getAttr('session_id'))
         state = getStateFromResponse(req['state'])
         if not state['error']:
             print("Server successfully disconnected with result %s" %
                   req['str'])
             return True
         else:
             return False
     except:
         return False
Ejemplo n.º 11
0
 def stopAllData(self):
     try:
         req = self.connection.Stop_All_Data(
             self.config.getAttr('session_id'))
         state = getStateFromResponse(req['state'])
         if not state['error']:
             print("Data successfully stopped with result %s" % req['str'])
             return True
         else:
             return False
     except:
         return False
Ejemplo n.º 12
0
 def stopTarget(self):
     try:
         req = self.connection.Stop(self.config.getAttr('session_id'))
         # TODO: in case of error the response is {'state': 0, 'str': 'No TEST target or bad interface task identifier'} and not in the 4-bit format!
         state = getStateFromResponse(req['state'])
         if not state['error']:
             print("Server successfully stopped with result %s" %
                   req['str'])
             return True
         else:
             return False
     except:
         return False
Ejemplo n.º 13
0
 def stopData(self, signal_number):
     try:
         req = self.connection.Stop_Data(self.config.getAttr('session_id'),
                                         signal_number)
         state = getStateFromResponse(req['state'])
         if not state['error']:
             print(
                 "Data successfully stopped for signal %d with result %s" %
                 (signal_number, req['str']))
             return True
         else:
             return False
     except:
         return False
Ejemplo n.º 14
0
 def connectSlave(self):
     try:
         print("Connecting to slave at %s with session ID %s" % (self.config.getUrl(), self.config.getAttr('session_id')))
         print("Waiting 5 seconds to let the target start...")
         time.sleep(5)
         self.connection = ServerProxy(self.config.getUrl())
         req = self.connection.tConnect(self.config.getAttr('session_id'))
         state = getStateFromResponse(req['state'])
         if not state['error']:
             self.config.setAttr('slave_data_port', req['port'])
             print("Slave connected with result %s. Data port %s opened" % (req['str'], req['port']))
             return True
         else:
             return False
     except Exception, e:
         print e
         return False
Ejemplo n.º 15
0
 def connectSlave(self):
     try:
         print("Connecting to slave at %s with session ID %s" %
               (self.config.getUrl(), self.config.getAttr('session_id')))
         print("Waiting 5 seconds to let the target start...")
         time.sleep(5)
         self.connection = ServerProxy(self.config.getUrl())
         req = self.connection.tConnect(self.config.getAttr('session_id'))
         state = getStateFromResponse(req['state'])
         if not state['error']:
             self.config.setAttr('slave_data_port', req['port'])
             print("Slave connected with result %s. Data port %s opened" %
                   (req['str'], req['port']))
             return True
         else:
             return False
     except Exception, e:
         print e
         return False
Ejemplo n.º 16
0
    def getSignalStructure(self):
        structure = []
        try:
            response = self.connection.Get_Signal_Structure(
                self.config.getAttr('session_id'))
            if len(response) <= 1:
                if response["state"] == 0:
                    print "Success response state but with unespected results. Message: \"%s\"" % (
                        response['str'])
                    return False
                else:
                    print "Error with message: \"%s\"" % (response['str'])
                    return False
            else:
                msg = response.pop(0)
                state = getStateFromResponse(msg['state'])
                if state['error']:
                    print "Error with message: \"%s\"" % (msg['str'])
                    return False
                else:
                    for index, val in enumerate(response):
                        struct = {}
                        # Gets the index which will be used to call other methods which wants the number of the signal
                        struct['number'] = index
                        struct['name'] = val['str']
                        struct['traces_num'] = val['i4']
                        struct['sample_time'] = val['d']
                        struct['traces_names'] = val['tstr']

                        # If 'traces_names' creates problems we can use:
                        #for k, v in val.iteritems():
                        #struct[k] = v

                        structure.append(struct)
                    return structure
        except:
            return False