def callbackCommandResponse(data): print "callbackCommandResponse name command:" + data.name rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.name) clipsFunctions.Assert('(BB_received "{0}" {1} {2} "{3}")'.format(data.name, data.id, data.successful, data.params)) clipsFunctions.PrintOutput() clipsFunctions.Run(BBFunctions.gui.getRunTimes()) clipsFunctions.PrintOutput()
def callbackCommandSendAndRunClips(data): print 'SEND AND RUN COMMAND' _clipsLock.acquire() clips.SendCommand(data.data, True) clipsFunctions.PrintOutput() _clipsLock.release() clipsFunctions.Run('') clipsFunctions.PrintOutput()
def RunCommand(c): clipsFunctions.Assert('(BB_cmd "{0}" {1} "{2}")'.format( c.name, c._id, c.params)) clipsFunctions.PrintOutput() clipsFunctions.Run() clipsFunctions.PrintOutput() time.sleep(1) return Response.FromCommandObject( c, False, 'CLIPS was busy or not able to handle the command.')
def callbackCommandResponse(data): print "callbackCommandResponse name command:" + data.name rospy.loginfo(rospy.get_caller_id() + "I heard %s", data.name) clipsFunctions.Assert('(BB_received "{0}" {1} {2} "{3}")'.format( data.name, data.id, data.successful, data.params)) clipsFunctions.PrintOutput() clipsFunctions.Run( '' ) # aqui se manda el numero de pasos que ejecutara CLIPS con [''] se ejecutan todos los pasos sin detenerse clipsFunctions.PrintOutput()
def str_query_KDB(req): print 'QUERY IN KDB ' + req.query _clipsLock.acquire() clips.SendCommand(req.query, True) clipsFunctions.PrintOutput() _clipsLock.release() clipsFunctions.Run('') result = str(clips.StdoutStream.Read()) print 'RESULT OF QUERY= ' + result print '' return StrQueryKDBResponse(result)
def str_query(req): print 'Query in KDB' + req.query _clipsLock.acquire() clips.SendCommand(req.query, True) clipsFunctions.PrintOutput() _clipsLock.release() clipsFunctions.Run('') result = str(clips.StdoutStream.Read()) if result.count('ROS') == 2: print 'ROS response' r = result.split('ROS') print r result = r[1] else: result = 'None' print 'Result of Query= ' + result print '' return StrQueryKDBResponse(result)
def init_KDB(req): print 'INIT KDB' print 'LOAD FILE' global file_gpsr rospack = rospkg.RosPack() #file_gpsr = rospack.get_path('simulator') + '/src/rules_base/oracle.dat' if not req.filePath: filePath = file_gpsr else: filepath = rospack.get_path('simulator') #clips.BatchStar(filepath + os.sep + 'CLIPS' + os.sep + 'BB_interface.clp') filePath = filepath + req.filePath #filePath = req.filePath print 'Load file in path' + filePath if filePath[-3:] == 'clp': _clipsLock.acquire() clips.BatchStar(filePath) clipsFunctions.PrintOutput() _clipsLock.release() print 'File Loaded!' return path = os.path.dirname(os.path.abspath(filePath)) f = open(filePath, 'r') line = f.readline() _clipsLock.acquire() while line: clips.BatchStar((path + os.sep + line).strip()) line = f.readline() f.close() clipsFunctions.PrintOutput() _clipsLock.release() print 'Files Loaded!' clipsFunctions.Reset() print 'Facts were reset!' setLogLevelTest() if req.run == True: clipsFunctions.Run('') return InitKDBResponse()
def init_KDB(req): print 'INIT KDB' print 'LOAD FILE' global file_gpsr if not req.filePath: filePath = file_gpsr else: filePath = req.filePath print 'Load file in path' + filePath if filePath[-3:] == 'clp': _clipsLock.acquire() clips.BatchStar(filePath) clipsFunctions.PrintOutput() _clipsLock.release() print 'File Loaded!' return path = os.path.dirname(os.path.abspath(filePath)) f = open(filePath, 'r') line = f.readline() _clipsLock.acquire() while line: clips.BatchStar((path + os.sep + line).strip()) line = f.readline() f.close() clipsFunctions.PrintOutput() _clipsLock.release() print 'Files Loaded!' clipsFunctions.Reset() print 'Facts were reset!' setLogLevelTest() if req.run == True: clipsFunctions.Run('') return InitKDBResponse()
def callbackCommandRunCLIPS(data): print "callbackCommandRUNCLIPS " clipsFunctions.Run('') # aqui se manda el numero de pasos que ejecutara CLIPS con [''] se ejecutan todos los pasos sin detenerse clipsFunctions.PrintOutput()
def runCLIPS(self, *args): clipsFunctions.Run(self.getRunTimes()) clipsFunctions.PrintOutput()
def ResponseReceived(r): clipsFunctions.Assert('(BB_received "{0}" {1} {2} "{3}")'.format( r.name, r._id, r.successful, r.params)) clipsFunctions.PrintOutput() clipsFunctions.Run(gui.getRunTimes()) clipsFunctions.PrintOutput()