Magentix2
2.1.1
|
Public Member Functions | |
Object | execute (TransitionSystem ts, Unifier un, Term[] args) throws Exception |
This class represents the internal action touse the Jason conversations logger for logging a text with adding the current pc name, and the currrent time mWater prototype
Definition at line 21 of file ia_save_log.java.
Object jason.stdlib.ia_save_log.execute | ( | TransitionSystem | ts, |
Unifier | un, | ||
Term[] | args | ||
) | throws Exception |
Definition at line 29 of file ia_save_log.java.
{ Calendar cal = Calendar.getInstance(); InetAddress add = InetAddress.getLocalHost(); int temp = add.toString().indexOf( "/" ); InetAddress address = InetAddress.getByName( add.toString().substring(temp+1) ); String hostname = address.getHostName(); try{ String text ; if (args[0].isAtom()){ text = ((Atom)args[0]).toString(); }else if (args[0].isString()){ text = ((StringTerm)args[0]).getString(); }else if (args[0].isNumeric()){ double tmp = ((NumberTerm)args[0]).solve(); text = Double.toString(tmp); }else if (args[0].isLiteral()){ text = ((LiteralImpl)args[0]).toString(); }else { text = args[0].toString(); } ConvJasonAgent myag = ((ConvMagentixAgArch)ts.getUserAgArch()).getJasonAgent(); myag.getconvlogger().info(text+" pc: "+hostname+ " time: "+cal.get(Calendar.HOUR)+":"+cal.get(Calendar.MINUTE)+":"+cal.get(Calendar.SECOND)+":"+cal.get(Calendar.MILLISECOND)); }catch(Exception e){ throw new JasonException("Bad arguments or internal error."); } // everything ok, so returns true return true; }