コード例 #1
0
ファイル: SequenceTests.cs プロジェクト: Onkeliroh/DSA
        public void AddTest()
        {
            Sequence seq = new Sequence () {
                Pin = new DPin () {
                    Name = "Pin of Awesome",
                    Number = 13,
                    PlotColor = GUIHelper.ColorHelper.SystemColorToGdkColor (System.Drawing.Color.Yellow),
                    State = DPinState.HIGH
                },
                Name = "Sequence of Awesome",
                Repetitions = 3,
            };

            seq.AddSequenceOperation (new SequenceOperation () {
                State = DPinState.HIGH,
                Duration = TimeSpan.FromSeconds (30)
            });

            Assert.AreEqual (1, seq.Chain.Count);

            Assert.AreEqual (0, seq.Cycle);
            seq.Next ();
            Assert.AreEqual (1, seq.Cycle);
            seq.Next ();
            Assert.AreEqual (2, seq.Cycle);
            seq.Next ();
            Assert.AreEqual (3, seq.Cycle);

            seq.Reset ();
            Assert.AreEqual (0, seq.Cycle);
        }
コード例 #2
0
ファイル: SequenceTests.cs プロジェクト: Onkeliroh/DSA
        public void GetCurrentStateTest()
        {
            Sequence seq = new Sequence () {
                Pin = new DPin () {
                    Name = "Pin of Awesome",
                    Number = 13,
                    PlotColor = GUIHelper.ColorHelper.SystemColorToGdkColor (System.Drawing.Color.Yellow),
                    State = DPinState.HIGH
                },
                Name = "Sequence of Awesome",
                Repetitions = 3,
            };

            seq.AddSequenceOperation (new SequenceOperation () {
                State = DPinState.HIGH,
                Duration = TimeSpan.FromMilliseconds (10)
            });
            seq.AddSequenceOperation (new SequenceOperation () {
                State = DPinState.LOW,
                Duration = TimeSpan.FromMilliseconds (10)
            });

            Assert.AreEqual (2, seq.Chain.Count);

            Assert.AreEqual (0, seq.Chain [0].Moment.TotalMilliseconds);
            Assert.AreEqual (10, seq.Chain [1].Moment.TotalMilliseconds);

            Assert.AreEqual (DPinState.HIGH, seq.GetCurrentState (9));
            Assert.AreEqual (DPinState.LOW, seq.GetCurrentState (10));

            Assert.AreEqual (DPinState.LOW, seq.GetCurrentState (19));
            Assert.AreEqual (DPinState.HIGH, seq.GetCurrentState (20));

            Assert.AreEqual (DPinState.HIGH, seq.GetCurrentState (29));
            Assert.AreEqual (DPinState.LOW, seq.GetCurrentState (30));

            Assert.AreEqual (DPinState.LOW, seq.GetCurrentState (60));
            Assert.AreEqual (DPinState.LOW, seq.GetCurrentState (61));

            seq.Reset ();
        }
コード例 #3
0
ファイル: MainWindow.cs プロジェクト: Onkeliroh/DSA
		protected void OnBtnAlternateBlinkSetup2Clicked (object sender, EventArgs e)
		{
			con.Configuration.ClearPins ();
			con.Configuration.ClearSequences ();

			OnBtnFillDigitalOutputsClicked (null, null);

			int i = 0;
			while (i < con.Configuration.Pins.Count)
			{
				var seq = new Sequence () {
					Pin = (DPin)con.Configuration.Pins [i],
					Repetitions = 0,
				};

				seq.AddSequenceOperation (new SequenceOperation () {
					Duration = TimeSpan.FromSeconds (i / 100.0),
					State = DPinState.LOW
				});

				for (int j = 0; j < 100; j++)
				{
					seq.AddSequenceOperation (new SequenceOperation () {
						Duration = TimeSpan.FromSeconds (con.Configuration.Pins.Count / 100.0),
						State = DPinState.HIGH
					});
					seq.AddSequenceOperation (new SequenceOperation () {
						Duration = TimeSpan.FromSeconds (con.Configuration.Pins.Count / 100.0),
						State = DPinState.LOW
					});
				}

				con.Configuration.AddSequence (seq);

				i += 1;
			}
			Console.WriteLine ();
		}
コード例 #4
0
ファイル: MainWindow.cs プロジェクト: Onkeliroh/DSA
		protected void OnButton359Clicked (object sender, EventArgs e)
		{
			con.Configuration.ClearPins ();
			con.Configuration.ClearSequences ();

			OnBtnFillDigitalOutputsClicked (null, null);

			int i = 0;
			while (i < con.Configuration.Pins.Count)
			{
				var seq1 = new Sequence () {
					Pin = (DPin)con.Configuration.Pins [i],
					Repetitions = -1
				};
				var seq2 = new Sequence () {
					Pin = (DPin)con.Configuration.Pins [i + 1],
					Repetitions = -1
				};
				for (int j = 0; j < 1; j++)
				{

					seq1.AddSequenceOperation (new SequenceOperation () {
						Duration = TimeSpan.FromMilliseconds (1000),
						State = DPinState.HIGH
					});
					seq1.AddSequenceOperation (new SequenceOperation () {
						Duration = TimeSpan.FromMilliseconds (1000),
						State = DPinState.LOW
					});
					seq2.AddSequenceOperation (new SequenceOperation () {
						Duration = TimeSpan.FromMilliseconds (1000),
						State = DPinState.LOW
					});
					seq2.AddSequenceOperation (new SequenceOperation () {
						Duration = TimeSpan.FromMilliseconds (1000),
						State = DPinState.HIGH
					});
				}
				con.Configuration.AddSequence (seq1);
				con.Configuration.AddSequence (seq2);
				i += 2;
			}
		}
コード例 #5
0
ファイル: MainWindow.cs プロジェクト: Onkeliroh/DSA
		protected void OnBtnDoubleBlinkClicked (object sender, EventArgs e)
		{
			if (ArduinoController.IsConnected)
			{
				con.Configuration.Sequences.Clear ();

				var sequence = new Sequence () {
					Pin = new DPin ("Dings", 3),
					Repetitions = 10
				};
				sequence.AddSequenceOperation (new SequenceOperation () {
					Duration = TimeSpan.FromSeconds (1),
					State = DPinState.HIGH,
				});
				sequence.AddSequenceOperation (new SequenceOperation {
					Duration = TimeSpan.FromSeconds (1),
					State = DPinState.LOW,
				});
				con.Configuration.Sequences.Add (sequence);

				sequence = new Sequence () {
					Pin = new DPin ("Dings", 4),
					Repetitions = 10
				};
				sequence.AddSequenceOperation (new SequenceOperation () {
					Duration = TimeSpan.FromSeconds (1),
					State = DPinState.LOW,
				});
				sequence.AddSequenceOperation (new SequenceOperation {
					Duration = TimeSpan.FromSeconds (1),
					State = DPinState.HIGH,
				});
				con.Configuration.Sequences.Add (sequence);

				foreach (Sequence seq in con.Configuration.Sequences)
				{
					Console.WriteLine (seq.ToString ());
				}

				con.Start ();
			} else
			{
				MessageDialog dialog = new MessageDialog (this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Please connect first to a Arduino.");
				dialog.Run ();
				dialog.Destroy ();
			}
		}