EhowImportService.java
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                         // wait for Cyc to be available
00019                         // MT: does not work at the moment; there are lots of exceptions if a CycConnection
00020                         // has been tried to open while Cyc was not available and then successfully opened
00021                         //
00022 //                      System.out.print("Waiting for OpenCyc..");
00023 //                      int i=0;
00024 //                      while(true) {
00025 //                              try {
00026 //                                      if((i++)%100==0)
00027 //                                              System.out.print(".");
00028 //                                      CycConnection cyc = new CycConnection();
00029 //                                      System.out.println("\nCyc found: "+cyc.connectionInfo());
00030 //                                      cyc.close();
00031 //                                      break;
00032 //                                      
00033 //                              } catch (UnknownHostException e) { }
00034 //                              catch (CycApiException e) { }
00035 //                              catch (IOException e) { }
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 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


comp_ehow
Author(s): Moritz Tenorth, Daniel Nyga
autogenerated on Tue Apr 16 2013 00:18:02