def recordPerformance(self, req):
     try:
         res = recordUserCognitiveTestPerformanceSrvResponse()
         userOntologyAlias = CognitiveExerciseHelperFunctions.getUserOntologyAlias(
             req.username)
         serv_topic = rospy.get_param(
             'rapp_knowrob_wrapper_record_user_cognitive_tests_performance')
         knowrob_service = rospy.ServiceProxy(
             serv_topic, recordUserPerformanceCognitiveTestsSrv)
         userPerformanceEntry = recordUserPerformanceCognitiveTestsSrvRequest(
         )
         userPerformanceEntry.test = req.test
         userPerformanceEntry.patient_ontology_alias = userOntologyAlias
         userPerformanceEntry.timestamp = int(time.time())
         userPerformanceEntry.score = req.score
         userPerformanceEntryResponse = knowrob_service(
             userPerformanceEntry)
         if (userPerformanceEntryResponse.success != True):
             error = userPerformanceEntryResponse.error + "Submitting query to ontology failed, either test or user ontology alias do not exist or test not of the given type"
             raise AppError(error, error)
         else:
             res.success = True
             res.userCognitiveTestPerformanceEntry = userPerformanceEntryResponse.cognitive_test_performance_entry
     except IndexError, e:
         res.trace.append("IndexError: " + str(e))
         res.error = "IndexError: " + str(e)
         res.success = False
         CognitiveExerciseHelperFunctions.traceError(res.error, res.trace)
Beispiel #2
0
    def recordPerformance(self, req):
        try:
            res = recordUserCognitiveTestPerformanceSrvResponse()

            serv_topic = rospy.get_param(
                'rapp_knowrob_wrapper_create_ontology_alias')
            knowrob_service = rospy.ServiceProxy(serv_topic,
                                                 createOntologyAliasSrv)
            createOntologyAliasReq = createOntologyAliasSrvRequest()
            createOntologyAliasReq.username = req.username
            createOntologyAliasResponse = knowrob_service(
                createOntologyAliasReq)
            if (createOntologyAliasResponse.success != True):
                res.trace = createOntologyAliasResponse.trace
                res.error = createOntologyAliasResponse.error
                res.success = False
                return res

            serv_topic = rospy.get_param(
                'rapp_knowrob_wrapper_record_user_cognitive_tests_performance')
            knowrob_service = rospy.ServiceProxy(
                serv_topic, recordUserPerformanceCognitiveTestsSrv)
            userPerformanceEntry = recordUserPerformanceCognitiveTestsSrvRequest(
            )
            userPerformanceEntry.test = req.test
            userPerformanceEntry.patient_ontology_alias = createOntologyAliasResponse.ontology_alias
            userPerformanceEntry.timestamp = int(time.time())
            userPerformanceEntry.score = req.score
            userPerformanceEntryResponse = knowrob_service(
                userPerformanceEntry)

            if (userPerformanceEntryResponse.success != True):
                res.trace = userPerformanceEntryResponse.trace
                res.trace.append(
                    "Submitting query to ontology failed, either test or user ontology alias do not exist or test not of the given type"
                )
                res.error = userPerformanceEntryResponse.error + "Submitting query to ontology failed, either test or user ontology alias do not exist or test not of the given type"
                res.success = False
                return res
            else:
                res.success = True
                res.userCognitiveTestPerformanceEntry = userPerformanceEntryResponse.cognitive_test_performance_entry

        except IndexError:
            res.trace.append(
                "Wrong Query Input Format, check for empty required columns list or wrong/incomplete Query data format"
            )
            res.success = False
        except IOError:
            print "Error: can\'t find login file or read data"
            res.success = False
            res.trace.append("Error: can\'t find login file or read data")
        return res
  def recordPerformance(self,req):
    try:
      res = recordUserCognitiveTestPerformanceSrvResponse()
      
      serv_topic = rospy.get_param('rapp_knowrob_wrapper_create_ontology_alias')
      knowrob_service = rospy.ServiceProxy(serv_topic, createOntologyAliasSrv)
      createOntologyAliasReq = createOntologyAliasSrvRequest()
      createOntologyAliasReq.username=req.username
      createOntologyAliasResponse = knowrob_service(createOntologyAliasReq)
      if(createOntologyAliasResponse.success!=True):
        res.trace=createOntologyAliasResponse.trace
        res.error=createOntologyAliasResponse.error
        res.success=False
        return res

      serv_topic = rospy.get_param('rapp_knowrob_wrapper_record_user_cognitive_tests_performance')
      knowrob_service = rospy.ServiceProxy(serv_topic, recordUserPerformanceCognitiveTestsSrv)
      userPerformanceEntry = recordUserPerformanceCognitiveTestsSrvRequest()
      userPerformanceEntry.test=req.test
      userPerformanceEntry.patient_ontology_alias=createOntologyAliasResponse.ontology_alias
      userPerformanceEntry.timestamp=int(time.time())
      userPerformanceEntry.score=req.score
      userPerformanceEntryResponse = knowrob_service(userPerformanceEntry)
      
      if(userPerformanceEntryResponse.success!=True):
        res.trace=userPerformanceEntryResponse.trace
        res.trace.append("Submitting query to ontology failed, either test or user ontology alias do not exist or test not of the given type")
        res.error=userPerformanceEntryResponse.error+"Submitting query to ontology failed, either test or user ontology alias do not exist or test not of the given type"
        res.success=False
        return res
      else:
        res.success=True
        res.userCognitiveTestPerformanceEntry=userPerformanceEntryResponse.cognitive_test_performance_entry

    except IndexError:
      res.trace.append("Wrong Query Input Format, check for empty required columns list or wrong/incomplete Query data format")
      res.success=False
    except IOError:
      print "Error: can\'t find login file or read data"
      res.success=False
      res.trace.append("Error: can\'t find login file or read data")
    return res
 def recordPerformance(self,req):
   try:
     res = recordUserCognitiveTestPerformanceSrvResponse()
     userOntologyAlias=CognitiveExerciseHelperFunctions.getUserOntologyAlias(req.username)      
     serv_topic = rospy.get_param('rapp_knowrob_wrapper_record_user_cognitive_tests_performance')
     knowrob_service = rospy.ServiceProxy(serv_topic, recordUserPerformanceCognitiveTestsSrv)
     userPerformanceEntry = recordUserPerformanceCognitiveTestsSrvRequest()
     userPerformanceEntry.test=req.test    
     userPerformanceEntry.patient_ontology_alias=userOntologyAlias
     userPerformanceEntry.timestamp=int(time.time())
     userPerformanceEntry.score=req.score
     userPerformanceEntryResponse = knowrob_service(userPerformanceEntry)      
     if(userPerformanceEntryResponse.success!=True):
       error=userPerformanceEntryResponse.error+"Submitting query to ontology failed, either test or user ontology alias do not exist or test not of the given type"        
       raise AppError(error,error)
     else:
       res.success=True
       res.userCognitiveTestPerformanceEntry=userPerformanceEntryResponse.cognitive_test_performance_entry
   except IndexError, e:
     res.trace.append("IndexError: " +str(e))
     res.error="IndexError: "+str(e)
     res.success=False
     CognitiveExerciseHelperFunctions.traceError(res.error,res.trace)
Beispiel #5
0
 def recordUserCognitiveTestPerformanceDataHandler(self,req):
   res = recordUserCognitiveTestPerformanceSrvResponse()
   it = RecordUserCognitiveTestPerformance()
   res=it.recordPerformance(req)
   return res