コード例 #1
0
ファイル: WaitStdLib.cs プロジェクト: nasa03/Jasonity
            public WaitEvent(Trigger te, ILogicalFormula f, Unifier un, Reasoner ts, long timeout, ITerm elapsedTimeTerm)
            {
                this.te              = te;
                this.formula         = f;
                this.un              = un;
                this.ts              = ts;
                c                    = ts.GetCircumstance();
                si                   = c.GetSelectedIntention();
                this.elapsedTimeTerm = elapsedTimeTerm;

                // register listener
                c.AddEventListener(this);

                if (te != null)
                {
                    sEvt = te.ToString();
                }
                else if (formula != null)
                {
                    sEvt = formula.ToString();
                }
                else
                {
                    sEvt = "time" + (timeout);
                }
                sEvt = si.GetID() + "/" + sEvt;
                c.AddPendingIntention(sEvt, si);

                //startTime = System.currentTimeMillis(); //hay que usar el de c# o el de unity? MISTERIO
                startTime = DateTime.Now.Millisecond;
                // Seguramente lo que querramos en C# no son los milisegundos desde el año 1970... sino algo así: Environment.TickCount
                DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);

                startTime = (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;

                if (timeout >= 0)
                {
                    Agent.GetExecutor().AddTask(new MyRunnable1(this));

                    //agent.getscheduler().schedule(new runnable()
                    //{
                    //    public void run()
                    //    {
                    //        resume(true);
                    //    }
                    //    }, timeout, timeunit.milliseconds);
                }
            }