Go to the documentation of this file.00001 package instruction.ros;
00002 
00003 import ros.*;
00004 import ros.pkg.comp_ehow.srv.EhowToOWL;
00005 import instruction.exporter.owl.OWLExporter;
00006 
00007 
00008 public class EhowImportService {
00009 
00010         Ros ros;
00011         NodeHandle n;
00012         OWLExporter owl_ex;
00013         
00014         public EhowImportService() {
00015                 
00016                 try {
00017 
00018                         
00019                         
00020                         
00021                         
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 
00032 
00033 
00034 
00035 
00036 
00037                         
00038                         owl_ex = new OWLExporter();
00039                         
00040                         ros = Ros.getInstance();
00041                         ros.init("ehow_importer");
00042                         n = ros.createNodeHandle();
00043                         
00044                         n.advertiseService("/ehow_importer/ehow_to_owl",  new EhowToOWL(),  new EhowToOWLCallback());
00045                         ros.logInfo("Started ehow import service.");
00046                         
00047                         while(n.isValid())
00048                                 ros.spinOnce();
00049                         
00050                 } catch(RosException e) {
00051                         e.printStackTrace();
00052                 }
00053         }
00054         
00062         class EhowToOWLCallback implements ServiceServer.Callback<EhowToOWL.Request, EhowToOWL.Response> {
00063                 
00064                 @Override
00065                 public EhowToOWL.Response call(EhowToOWL.Request req) {
00066 
00067                         EhowToOWL.Response res = new EhowToOWL.Response();
00068                         res.owl_instructions="";
00069 
00070                         if (req.command != null && req.command.length() > 0) {
00071                                 res.owl_instructions = owl_ex.convertHowtoToOWLOntology(req.command);
00072                         }
00073 
00074                         return res;
00075                 }
00076         }
00077 
00078         public static void main(String args[]) {
00079                 new EhowImportService();
00080         }
00081 }