示例#1
0
        PBTerm sendAtom(string commandName, string argument)
        {
            lock (this) {
                if (parentSession != null)
                {
                    return(parentSession.sendAtom(commandName, argument));
                }

                try {
                    initSend();

                    // Write a fastrw term
                    output.writeCompound(commandName, 1);
                    output.writeAtom(argument);
                    output.commit();
                    return(parser.parseProlog(input));
                } catch (System.IO.IOException e) {
                    if (PrologSession.debugging())
                    {
                        PrologSession.WriteStackTrace(e, Console.Error);
                    }
                    close();
                    return(null);
                } finally {
                    finishSend();
                }
            }
        }
示例#2
0
 // Close connection when things have gone wrong...
 void  close()
 {
     // System.out.println("Closing Connection...");
     try {
         sendTime = -1L;
         if (output != null)
         {
             output.close();
             output = null;
         }
         if (input != null)
         {
             input.Close();
             input = null;
         }
         if (connection != null)
         {
             connection.Close();
             connection = null;
         }
     } catch (Exception e) {
         if (PrologSession.debugging())
         {
             PrologSession.WriteStackTrace(e, Console.Error);
         }
     }
 }
示例#3
0
 /// <summary> Returns <code>true</code> if this {@link se.sics.prologbeans.PBTerm} is a
 /// proper list and all of its elements are character codes or one character
 /// atoms. Returns <code>false</code> otherwise.
 /// </summary>
 /// <returns> whether the argument is a string
 /// </returns>
 public virtual bool isString()
 {
     if (PrologSession.debugging())
     {
         Console.Error.WriteLine("Entering PBTerm.isString()");
     }
     return(false);
 }
示例#4
0
        public void  Run()
        {
            do
            {
                try {
                    Thread.Sleep(oneSecond);

                    checkQueries();
                } catch (Exception e) {
                    if (PrologSession.debugging())
                    {
                        Console.Error.WriteLine("PBMonitor: monitor caught an exception:");
                        PrologSession.WriteStackTrace(e, Console.Error);
                    }
                }
            } while (true);
        }