Beispiel #1
0
        public void Port_DataReceived()
        {
            var Data = new byte[Port.BytesToRead];

            try
            {
                Port.Read(Data, 0, Port.BytesToRead);
                if (TimeoutTimer != null)
                {
                    TimeoutTimer.Change(Timeout.Infinite, Timeout.Infinite);
                    ChangeCommunicationPauseState(false);
                }
                if (CurrentBuffer != null)
                {
                    CurrentBuffer.ReceiveData(Data);
                    CurrentBuffer = null;
                }
            }
            catch
            {
                Program.Log("Unable to read port data", ELogType.Error);
                // clear input data
                Port.ReadExisting();
            }
        }
Beispiel #2
0
        protected virtual bool ProcessPortResponse()
        {
            bool complete = false;

            TimeoutTimer.Disarm();

            if (Test.Steps[CurrentStep].Response != null)
            {
                if (!string.IsNullOrEmpty(Test.Steps[CurrentStep].Response.Header))
                {
                    int index = ResponseBuffer.LastIndexOf(Test.Steps[CurrentStep].Response.Header);
                    if (index >= 0)
                    {
                        ResponseBuffer = ResponseBuffer.Substring(index);
                    }
                }
            }

            if (!string.IsNullOrEmpty(ResponseBuffer))
            {
                qf4net.QF.Instance.Publish(new RecorderEvent(QFSignal.RecorderRecord, Name, CurrentStep + 1, ResponseBuffer));
            }

            ResponseProcessor.Process(Test.Name, Test.Steps[CurrentStep], ResponseBuffer);
            ResponseBuffer = string.Empty;
            complete       = true;

            return(complete);
        }
Beispiel #3
0
        protected virtual void Failed(TestEvent tEvent)
        {
            if (tEvent.Name == Name)
            {
                TimeoutTimer.Disarm();

                if (Test.Steps[CurrentStep].ContinueOnError)
                {
                    qf4net.QF.Instance.Publish(new TestEvent(QFSignal.Error, tEvent.Name, tEvent.Reason, tEvent.Step));
                    if (TestError != null)
                    {
                        TestError(null, new TestErrorEventArgs(tEvent.Name, tEvent.Reason, tEvent.Step));
                    }

                    CompleteStep();
                }
                else
                {
                    qf4net.QF.Instance.Publish(new TestEvent(QFSignal.TestResult, tEvent.Name, tEvent.Reason, tEvent.Step, tEvent.State));
                    if (TestFailed != null)
                    {
                        TestFailed(null, new TestFailedEventArgs(tEvent.Name, tEvent.Reason, tEvent.Step));
                    }

                    TransitionTo(m_StateEnded, s_TranIdx_Failed_Ended);
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Call handler once
        /// </summary>
        /// <param name="handler"></param>
        /// <param name="timeout"></param>
        /// <param name="ctx">The data objects passed to callback function.</param>
        /// <returns></returns>
        public int SetTimeout(Action <object[]> handler, int timeout, object[] ctx)
        {
            var timer = new TimeoutTimer(t =>
            {
                RaiseOnExecuting();
                handler(ctx);
                lock (_activeTimers)
                {
                    _activeTimers.Remove(t);
                }
                RaiseOnExecuted();
            }, exception =>
            {
                if (OnException != null)
                {
                    OnException(exception);
                }
            }, timeout, _getSyncObj);

            lock (_activeTimers)
            {
                _activeTimers.Add(timer);
            }

            timer.Start();

            return(timer.GetHashCode());
        }
Beispiel #5
0
        protected override void State_INIT()
        {
            switch (Step)
            {
            case 0:
                ResetAllEffects();
                // Echo test
                OutputEffectCommand = (long)0xFF;
                TimeoutTimer.Restart();
                GoToNextStep();
                break;

            case 1:
                if (TimeoutTimer.ElapsedMilliseconds > 1000)
                {
                    // Nop
                    OutputEffectCommand = (long)0x00;
                    TimeoutTimer.Restart();
                    GoToNextStep();
                }
                break;

            case 2:
                TransitionTo(FFBStates.DEVICE_READY);
                break;
            }
        }
Beispiel #6
0
        public void Start_CallsBackAfterTimeout()
        {
            TimeoutTimer<int> uut = new TimeoutTimer<int>(25, 999);
            uut.Elapsed += (sender, e) => 

            Assert.AreEqual("Here it's   a  set of <b>words</b>", result);
        }
Beispiel #7
0
        public void TimeoutTimespan()
        {
            int          nTime = 1000;
            TimeoutTimer t     = new TimeoutTimer(TimeSpan.FromMilliseconds(nTime));

            Assert.GreaterOrEqual(t.RemainingMilliseconds, 0);
            Assert.LessOrEqual(t.RemainingMilliseconds, nTime);
        }
Beispiel #8
0
 static PostClient()
 {
     _messages = new ConcurrentQueue <PostEntity>();
     //默认5秒轮询一次
     _timer       = new TimeoutTimer(Timeout);
     _timer.Tick += Timer_TimeoutEvent;
     _timer.Start();
 }
Beispiel #9
0
 protected override void OnTimerElapsed(TimeoutTimer timer)
 {
     if (timer == RaftTimer)
     {
         var raftOperationResult = Raft.OnTimerElapsed();
         ProcessRaftResult(raftOperationResult, null);
     }
 }
Beispiel #10
0
        public void Cancel(string from = "")
        {
            if (TimeoutTimer != null)
            {
                TimeoutTimer.Dispose();
            }

            ErrorCallback(new IPCErrorMessage("Cancelled" + (!string.IsNullOrEmpty(from) ? " from " + from : "")));
        }
Beispiel #11
0
 private static void DestroyTimer()
 {
     if (timerObject != null)
     {
         Destroy(timerObject.gameObject);
     }
     timerObject = null;
     timer       = null;
 }
Beispiel #12
0
        protected override void OnInitialized()
        {
            base.OnInitialized();
            Server.StartListening(Id);
            RaftTimer = new TimeoutTimer(this);
            var raftOperationResult = Raft.Start();

            ProcessRaftResult(raftOperationResult);
        }
Beispiel #13
0
        void TimeoutTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            logger.Alert("Transition Message " + typeof(T).Name + " timeout..");
            TimeoutTimer.Stop();

            if (ErrorCallback != null)
            {
                ErrorCallback();
            }
        }
Beispiel #14
0
 private static void ActivateTimer()
 {
     if (timerObject == null)
     {
         timerObject = new GameObject();
         timerObject.transform.parent = transformInstance;
         timer = timerObject.AddComponent <TimeoutTimer>();
         timer.StartTimer(30, transformInstance.gameObject);
     }
 }
Beispiel #15
0
        /// <summary>
        /// Specific lemans
        /// </summary>
        protected override void State_INIT()
        {
            switch (Step)
            {
            case 0:
                ResetAllEffects();
                // Echo test
                OutputEffectCommand = (int)GenericModel3CMD.PING;
                TimeoutTimer.Restart();
                GoToNextStep();
                break;

            case 1:
                if (TimeoutTimer.ElapsedMilliseconds > 500)
                {
                    // Play sequence ?
                    OutputEffectCommand = (int)LemansCMD.SEQU;
                    TimeoutTimer.Restart();
                    GoToNextStep();
                }
                break;

            case 2:
                if (TimeoutTimer.ElapsedMilliseconds > 500)
                {
                    // 0xCB: reset board - SendStopAll
                    OutputEffectCommand = (int)LemansCMD.NO_EFFECT;
                    TimeoutTimer.Restart();
                    GoToNextStep();
                }
                break;

            case 3:
                if (TimeoutTimer.ElapsedMilliseconds > 100)
                {
                    // Maximum power set to 100%
                    OutputEffectCommand = (long)GenericModel3CMD.MOTOR_LEVEL100;
                    TimeoutTimer.Restart();
                    GoToNextStep();
                }
                break;

            case 4:
                if (TimeoutTimer.ElapsedMilliseconds > 100)
                {
                    GoToNextStep();
                }
                break;

            case 5:
                TransitionTo(FFBStates.DEVICE_READY);
                break;
            }
        }
 public void DownloadFileAsyncWithTimeout(Uri address, string fileName, object userToken)
 {
     if (this._timer == null)
     {
         this._timer           = new TimeoutTimer(this);
         this._timer.Timeout   = this.Timeout;
         this._timer.TimeOver += new TimeoutCaller(this._timer_TimeOver);
         base.add_DownloadProgressChanged(new DownloadProgressChangedEventHandler(this.CNNWebClient_DownloadProgressChanged));
     }
     base.DownloadFileAsync(address, fileName, userToken);
     this._timer.Start();
 }
Beispiel #17
0
        public async Task TimeoutElapse()
        {
            int          nTime = 50;
            TimeoutTimer t     = new TimeoutTimer(nTime);

            Assert.GreaterOrEqual(t.RemainingMilliseconds, 0);
            Assert.LessOrEqual(t.RemainingMilliseconds, nTime);

            await Task.Delay(nTime * 2);

            Assert.AreEqual(0, t.RemainingMilliseconds);
            Assert.IsTrue(t.TimedOut);
        }
Beispiel #18
0
        public async Task TimeoutInfinite()
        {
            TimeoutTimer t = new TimeoutTimer(Timeout.Infinite);

            Assert.AreEqual(int.MaxValue, t.RemainingMilliseconds);
            await Task.Delay(50);

            Assert.AreEqual(int.MaxValue, t.RemainingMilliseconds);
            Assert.IsFalse(t.TimedOut);

            t.Reset(0);
            Assert.AreEqual(t.RemainingMilliseconds, 0);
            Assert.AreEqual(t.RemainingTimeSpan, TimeSpan.Zero);
            Assert.IsTrue(t.TimedOut);
        }
Beispiel #19
0
        public async Task DefaultTimeout()
        {
            TimeoutTimer t = new TimeoutTimer();

            Assert.AreEqual(t.RemainingMilliseconds, 0);
            Assert.AreEqual(t.RemainingTimeSpan, TimeSpan.Zero);
            Assert.IsTrue(t.TimedOut);

            int nDelay = 100;
            await Task.Delay(2 *nDelay);

            Assert.AreEqual(t.RemainingMilliseconds, 0);
            Assert.AreEqual(t.RemainingTimeSpan, TimeSpan.Zero);
            Assert.IsTrue(t.TimedOut);
        }
Beispiel #20
0
        protected virtual void Passed(TestEvent tEvent)
        {
            if (tEvent.Name == Name)
            {
                TimeoutTimer.Disarm();

                qf4net.QF.Instance.Publish(new TestEvent(QFSignal.TestResult, tEvent.Name, TestState.Passed));
                if (TestPassed != null)
                {
                    TestPassed(null, new TestPassedEventArgs(tEvent.Name));
                }

                TransitionTo(m_StateEnded, s_TranIdx_Passed_Ended);
            }
        }
Beispiel #21
0
        protected virtual void Step(TestEvent tEvent, int retries)
        {
            if (tEvent.Name == Name)
            {
                Retries        = retries;
                ResponseBuffer = string.Empty;

                string augmentedCommand = Test.Steps[CurrentStep].Actor.Action;
                if (TestStepping != null)
                {
                    try
                    {
                        TestStepping(Name, Test.Steps[CurrentStep], ref augmentedCommand);
                        if (string.IsNullOrEmpty(augmentedCommand))
                        {
                            augmentedCommand = Test.Steps[CurrentStep].Actor.Action;
                        }
                    }
                    catch (Exception ex)
                    {
                        TransitionToFailed(ex.Message);
                        return;
                    }
                }

                TransitionTo(m_StateStepping, s_TranIdx_Running_Stepping);
                bool complete = Request(augmentedCommand);

                // DESIGN NOTE:
                // If the Actor explicitly controls step completion (such as Prompt), ignore timeout settings
                if (complete)
                {
                    // DESIGN NOTE:
                    // If no timeout has been specified, continue directly regardless of whether response processing has been requested
                    if (Test.Steps[CurrentStep].Timeout == 0)
                    {
                        CompleteStep();
                    }
                    else
                    {
                        TimeoutTimer.FireIn(new TimeSpan(0, 0, Test.Steps[CurrentStep].Timeout), new TestEvent(QFSignal.Timeout, Name));
                    }
                }
            }
        }
        protected override void OnConnect(TSession session)
        {
            // Start the timeout timer.
            var pingFrequency = Config.PingFrequency;

            if (pingFrequency > 0)
            {
                _pingTimer.Change(pingFrequency / 2, pingFrequency);
            }

            if (TimeoutTimerRunning == false)
            {
                TimeoutTimer.Change(0, Config.PingTimeout);
                TimeoutTimerRunning = true;
            }

            base.OnConnect(session);
        }
Beispiel #23
0
    void Start()
    {
        Debug.Log("Starting app ...");
        Debug.Log("Screen size: " + Screen.width + ", " + Screen.height);

        camOrthoSize = mainCamera.orthographicSize;

        Debug.Log("Camera ortho size: " + camOrthoSize);
        Debug.Log("World size: " + ((float)Screen.width / Screen.height * camOrthoSize * 2.0f) + ", " + (camOrthoSize * 2.0f));

        // set initial states
        inTest             = false;
        abortTest          = false;
        stimulusSeen       = false;
        lastTouchStartTime = 0;

        //mainMenuPanel = GameObject.Find("MainMenuPanel");
        //testConfigPanel = GameObject.Find("TestConfigPanel");

        mainMenuPanel.SetActive(true);
        testConfigPanel.SetActive(false);
        patientDataPanel.SetActive(false);
        testResultsPanel.SetActive(false);



        // create the timeout timer
        tot = new TimeoutTimer();

        // create the stimulus field objects
        buildStimulusField();

        // setup the Android Java objects that let us communicate to the SmartHVF-Input project and
        // receive bluetooth comms

        /*
         * AndroidJavaClass player = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
         * unityContext = player.GetStatic<AndroidJavaObject>("currentActivity");
         *
         * btLib = new AndroidJavaObject("com.example.testlibrary.TestClass");
         * //btLib.Call("InitBluetooth", new object[] { unityContext });
         */
    }
Beispiel #24
0
        public async Task TimeoutMilliseconds()
        {
            int          nTime = 1000;
            TimeoutTimer t     = new TimeoutTimer(nTime);

            Assert.GreaterOrEqual(t.RemainingMilliseconds, 0);
            Assert.LessOrEqual(t.RemainingMilliseconds, nTime);
            Assert.GreaterOrEqual(t.RemainingTimeSpan, TimeSpan.Zero);
            Assert.LessOrEqual(t.RemainingTimeSpan, new TimeSpan(0, 0, 0, 0, nTime));
            Assert.IsFalse(t.TimedOut);

            int nDelay = 100;
            await Task.Delay(2 *nDelay);

            Assert.GreaterOrEqual(t.RemainingMilliseconds, 0);
            Assert.GreaterOrEqual(t.RemainingTimeSpan, TimeSpan.Zero);
            Assert.LessOrEqual(t.RemainingMilliseconds, nTime - nDelay);
            Assert.LessOrEqual(t.RemainingTimeSpan, new TimeSpan(0, 0, 0, 0, nTime - nDelay));
        }
Beispiel #25
0
 internal SqlInternalConnectionTds(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, object providerInfo, string newPassword, SqlConnection owningObject, bool redirectedUserInstance) : base(connectionOptions)
 {
     this._instanceName = string.Empty;
     if (connectionOptions.UserInstance && InOutOfProcHelper.InProc)
     {
         throw SQL.UserInstanceNotAvailableInProc();
     }
     this._identity = identity;
     this._poolGroupProviderInfo = (SqlConnectionPoolGroupProviderInfo)providerInfo;
     this._fResetConnection      = connectionOptions.ConnectionReset;
     if (this._fResetConnection)
     {
         this._originalDatabase = connectionOptions.InitialCatalog;
         this._originalLanguage = connectionOptions.CurrentLanguage;
     }
     RuntimeHelpers.PrepareConstrainedRegions();
     try
     {
         TimeoutTimer timeout = TimeoutTimer.StartSecondsTimeout(connectionOptions.ConnectTimeout);
         this.OpenLoginEnlist(owningObject, timeout, connectionOptions, newPassword, redirectedUserInstance);
     }
     catch (OutOfMemoryException)
     {
         base.DoomThisConnection();
         throw;
     }
     catch (StackOverflowException)
     {
         base.DoomThisConnection();
         throw;
     }
     catch (ThreadAbortException)
     {
         base.DoomThisConnection();
         throw;
     }
     if (Bid.AdvancedOn)
     {
         Bid.Trace("<sc.SqlInternalConnectionTds.ctor|ADV> %d#, constructed new TDS internal connection\n", base.ObjectID);
     }
 }
Beispiel #26
0
        private void OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, string newPassword, bool redirectedUserInstance)
        {
            string     failoverPartner;
            bool       useFailoverPartner;
            ServerInfo primaryServerInfo = new ServerInfo(connectionOptions);

            if (this.PoolGroupProviderInfo != null)
            {
                useFailoverPartner = this.PoolGroupProviderInfo.UseFailoverPartner;
                failoverPartner    = this.PoolGroupProviderInfo.FailoverPartner;
            }
            else
            {
                useFailoverPartner = false;
                failoverPartner    = base.ConnectionOptions.FailoverPartner;
            }
            bool flag2 = !ADP.IsEmpty(failoverPartner);

            try
            {
                if (flag2)
                {
                    this.LoginWithFailover(useFailoverPartner, primaryServerInfo, failoverPartner, newPassword, redirectedUserInstance, owningObject, connectionOptions, timeout);
                }
                else
                {
                    this.LoginNoFailover(primaryServerInfo, newPassword, redirectedUserInstance, owningObject, connectionOptions, timeout);
                }
            }
            catch (Exception exception)
            {
                if (ADP.IsCatchableExceptionType(exception))
                {
                    this.LoginFailure();
                }
                throw;
            }
        }
Beispiel #27
0
        public bool ProcessMessage(IPCMessage message)
        {
            if (TimeoutTimer != null)
            {
                TimeoutTimer.Dispose();
            }

            if (message is T)
            {
                Callback(message as T);
            }
            else if (message is IIPCErrorMessage)
            {
                logger.Warn("IPC Error on message recv {0}", message);
                ErrorCallback(message as IIPCErrorMessage);
            }
            else
            {
                DefaultCallback(message);
            }

            return(true);
        }
Beispiel #28
0
        private void Login(ServerInfo server, TimeoutTimer timeout, string newPassword)
        {
            SqlLogin rec = new SqlLogin();

            base.CurrentDatabase    = server.ResolvedDatabaseName;
            this._currentPacketSize = base.ConnectionOptions.PacketSize;
            this._currentLanguage   = base.ConnectionOptions.CurrentLanguage;
            int num2 = 0;

            if (!timeout.IsInfinite)
            {
                long num = timeout.MillisecondsRemaining / 0x3e8L;
                if (0x7fffffffL > num)
                {
                    num2 = (int)num;
                }
            }
            rec.timeout         = num2;
            rec.userInstance    = base.ConnectionOptions.UserInstance;
            rec.hostName        = base.ConnectionOptions.ObtainWorkstationId();
            rec.userName        = base.ConnectionOptions.UserID;
            rec.password        = base.ConnectionOptions.Password;
            rec.applicationName = base.ConnectionOptions.ApplicationName;
            rec.language        = this._currentLanguage;
            if (!rec.userInstance)
            {
                rec.database         = base.CurrentDatabase;
                rec.attachDBFilename = base.ConnectionOptions.AttachDBFilename;
            }
            rec.serverName     = server.UserServerName;
            rec.useReplication = base.ConnectionOptions.Replication;
            rec.useSSPI        = base.ConnectionOptions.IntegratedSecurity;
            rec.packetSize     = this._currentPacketSize;
            rec.newPassword    = newPassword;
            rec.readOnlyIntent = base.ConnectionOptions.ApplicationIntent == ApplicationIntent.ReadOnly;
            this._parser.TdsLogin(rec);
        }
        protected override void State_INIT()
        {
            switch (Step)
            {
            case 0:
                ResetAllEffects();
                // Echo test
                OutputEffectCommand = (long)GenericModel3CMD.PING;
                TimeoutTimer.Restart();
                GoToNextStep();
                break;

            case 1:
                if (TimeoutTimer.ElapsedMilliseconds > 1000)
                {
                    // Play sequence ?
                    OutputEffectCommand = (long)GenericModel3CMD.NO_EFFECT;
                    TimeoutTimer.Restart();
                    GoToNextStep();
                }
                break;

            case 7:
                if (TimeoutTimer.ElapsedMilliseconds > 100)
                {
                    // Maximum power set to 100%
                    OutputEffectCommand = (long)75;
                    GoToNextStep();
                }
                break;

            case 8:
                TransitionTo(FFBStates.DEVICE_READY);
                break;
            }
        }
Beispiel #30
0
 public PVPMode(PVPEvent pvpevent)
 {
     m_pvpevent     = pvpevent;
     m_timeoutTimer = new TimeoutTimer(this);
 }