當前位置: 首頁>>代碼示例>>C#>>正文


C# Clock.Tick方法代碼示例

本文整理匯總了C#中System.Clock.Tick方法的典型用法代碼示例。如果您正苦於以下問題:C# Clock.Tick方法的具體用法?C# Clock.Tick怎麽用?C# Clock.Tick使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Clock的用法示例。


在下文中一共展示了Clock.Tick方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Main

 public static void Main()
 {
     // body chunk
      Clock c = new Clock();
      Console.WriteLine("Midnight " + c.GetTimeString());
      c.SetTime(23, 58);
      Console.WriteLine("Before midnight " + c.GetTimeString());
      for (int i = 0; i < 4; i++) {
     c.Tick ();
     Console.WriteLine ("Tick " + c.GetTimeString());
      }
 }
開發者ID:kaylenehung,項目名稱:introcs-csharp-examples,代碼行數:12,代碼來源:clock_demo.cs

示例2: Control_linear_mosquito_with_pid

        public void Control_linear_mosquito_with_pid()
        {
            var receivedSeries = new List<Timestamped<double>>();
            var t0 = 0.AsMinute();
            var setpoint = 10.0.At(t0);//.Add(5.min()));
            var pid = new PIDAlgorithm(0.5, 0.5, 0.5, 0.0);

            var mosquito = new LinearMosquito(2.0.In(1.min()), t0);
            var controlledMosqito = mosquito.ControlledBy(pid);

            controlledMosqito.Receive += (t) => receivedSeries.Add(t);
            controlledMosqito.Send(setpoint);

            var clock = new Clock(t0);
            clock.Subscribe(mosquito);

            clock.Tick(5.min());
            //while (true) clock.Tick(1.min());
            Assert.AreEqual(setpoint, receivedSeries.Last());
        }
開發者ID:ame89,項目名稱:Limbus,代碼行數:20,代碼來源:ControllerTest.cs

示例3: Control_swarm_of_10_with_pid

        public void Control_swarm_of_10_with_pid()
        {
            var receivedSeries = new List<Timestamped<double>>();
            var t0 = 0.AsMinute();
            var setpoint = 100.0.At(t0.Add(5.min()));

            var swarm = Enumerable.Range(0, 10).Select(i => new LinearMosquito(2.0.In(1.min()), t0)).ToList();
            // max.At(5.min)=10x10=100

            var specifiedSwarm = swarm.Select(m => m.WithSpec(new Engine<double>()
                { Gradient = m.Gradient, Stages = new SortedSet<double>() {0.0, 100.0} }));

            var swarmController = new SwarmController(
                specifiedSwarm, new PowerBasedAllocator(), new PIDAlgorithm(0.5, 0.5, 0.5, 0.0));

            swarmController.Receive += (t) => receivedSeries.Add(t);
            swarmController.Send(setpoint);

            var clock = new Clock(t0);
            swarm.ForEach(m => clock.Subscribe(m));

            clock.Tick(5.min());
            Assert.AreEqual(setpoint, receivedSeries.Last());
        }
開發者ID:ame89,項目名稱:Limbus,代碼行數:24,代碼來源:ControllerTest.cs


注:本文中的System.Clock.Tick方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。