コード例 #1
0
ファイル: Sequence.cs プロジェクト: Onkeliroh/DSA
 /// <summary>
 /// Initializes a new instance of the <see cref="PrototypeBackend.Sequence"/> class.
 /// </summary>
 /// <param name="copy">Copy.</param>
 public Sequence(Sequence copy) : base()
 {
     Pin         = new DPin(copy.Pin);
     Name        = copy.Name;
     Chain       = new List <SequenceOperation> (copy.Chain);
     Repetitions = copy.Repetitions;
 }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PrototypeBackend.DPin"/> class.
 /// </summary>
 /// <param name="copy">Copy.</param>
 public DPin(DPin copy) : base()
 {
     Name         = copy.Name;
     Number       = copy.Number;
     AnalogNumber = copy.AnalogNumber;
     PlotColor    = copy.PlotColor;
 }
コード例 #3
0
ファイル: Sequence.cs プロジェクト: Onkeliroh/DSA
 /// <summary>
 /// Initializes a new instance of the <see cref="PrototypeBackend.Sequence"/> class.
 /// </summary>
 /// <param name="copy">Copy.</param>
 public Sequence(Sequence copy)
     : base()
 {
     Pin = new DPin (copy.Pin);
     Name = copy.Name;
     Chain = new List<SequenceOperation> (copy.Chain);
     Repetitions = copy.Repetitions;
 }
コード例 #4
0
ファイル: DPin.cs プロジェクト: Onkeliroh/DSA
 /// <summary>
 /// Initializes a new instance of the <see cref="PrototypeBackend.DPin"/> class.
 /// </summary>
 /// <param name="copy">Copy.</param>
 public DPin(DPin copy)
     : base()
 {
     Name = copy.Name;
     Number = copy.Number;
     AnalogNumber = copy.AnalogNumber;
     PlotColor = copy.PlotColor;
 }
コード例 #5
0
ファイル: DPinTests.cs プロジェクト: Onkeliroh/DSA
        public void DPinConstructorTests()
        {
            var pin = new DPin ();

            Assert.AreEqual (Backend.PinType.DIGITAL, pin.Type);
            Assert.AreEqual (Backend.PinMode.OUTPUT, pin.Mode);

            Assert.AreEqual (Color.Zero, pin.PlotColor);
            pin.PlotColor = new Gdk.Color (255, 0, 0);
            Assert.AreEqual (new Gdk.Color (255, 0, 0), pin.PlotColor);
        }
コード例 #6
0
ファイル: DPinTests.cs プロジェクト: Onkeliroh/DSA
        public void DPinEqualsTest()
        {
            var pin1 = new DPin ();
            var pin2 = new DPin ();

            Assert.AreEqual (true, pin1.Equals (pin2));

            pin1.PlotColor = new Color (0, 255, 0);

            Assert.AreEqual (false, pin1.Equals (pin2));
        }
コード例 #7
0
ファイル: BoardConfiguration.cs プロジェクト: Onkeliroh/DSA
 /// <summary>
 /// Gets the coresponding sequence.
 /// </summary>
 /// <returns>The coresponding sequence.</returns>
 /// <param name="pin">Pin</param>
 public Sequence GetCorespondingSequence(DPin pin)
 {
     foreach (Sequence seq in Sequences)
     {
         if (seq.Pin == pin)
         {
             return(seq);
         }
     }
     return(null);
 }
コード例 #8
0
ファイル: Sequence.cs プロジェクト: Onkeliroh/DSA
 /// <summary>
 /// Initializes a new instance of the <see cref="PrototypeBackend.Sequence"/> class.
 /// </summary>
 public Sequence()
 {
     Pin              = new DPin();
     Name             = "";
     GroupName        = "";
     Chain            = new List <SequenceOperation> ();
     Repetitions      = 0;
     Cycle            = 0;
     CurrentOperation = 0;
     CurrentState     = SequenceState.New;
     LastOperation    = new TimeSpan(0);
 }
コード例 #9
0
ファイル: Sequence.cs プロジェクト: Onkeliroh/DSA
 /// <summary>
 /// Initializes a new instance of the <see cref="PrototypeBackend.Sequence"/> class.
 /// </summary>
 public Sequence()
 {
     Pin = new DPin ();
     Name = "";
     GroupName = "";
     Chain = new List<SequenceOperation> ();
     Repetitions = 0;
     Cycle = 0;
     CurrentOperation = 0;
     CurrentState = SequenceState.New;
     LastOperation = new TimeSpan (0);
 }
コード例 #10
0
ファイル: Sequence.cs プロジェクト: Onkeliroh/DSA
        /// <summary>
        /// Initializes a new instance of the <see cref="PrototypeBackend.Sequence"/> class.
        /// </summary>
        /// <param name="info">Info.</param>
        /// <param name="context">Context.</param>
        public Sequence(SerializationInfo info, StreamingContext context)
        {
            Pin = new DPin();
            Pin = (DPin)info.GetValue("Pin", Pin.GetType());

            Name = info.GetString("Name");

            GroupName = info.GetString("GroupName");

            Chain = new List <SequenceOperation> ();
            Chain = (List <SequenceOperation>)info.GetValue("Chain", Chain.GetType());

            Repetitions = info.GetInt32("Repetitions");

            Color = new Gdk.Color(info.GetByte("RED"), info.GetByte("GREEN"), info.GetByte("BLUE"));
        }
コード例 #11
0
ファイル: Sequence.cs プロジェクト: Onkeliroh/DSA
        /// <summary>
        /// Initializes a new instance of the <see cref="PrototypeBackend.Sequence"/> class.
        /// </summary>
        /// <param name="info">Info.</param>
        /// <param name="context">Context.</param>
        public Sequence(SerializationInfo info, StreamingContext context)
        {
            Pin = new DPin ();
            Pin = (DPin)info.GetValue ("Pin", Pin.GetType ());

            Name = info.GetString ("Name");

            GroupName = info.GetString ("GroupName");

            Chain = new List<SequenceOperation> ();
            Chain = (List<SequenceOperation>)info.GetValue ("Chain", Chain.GetType ());

            Repetitions = info.GetInt32 ("Repetitions");

            Color = new Gdk.Color (info.GetByte ("RED"), info.GetByte ("GREEN"), info.GetByte ("BLUE"));
        }
コード例 #12
0
ファイル: SeqConfigDialog.cs プロジェクト: Onkeliroh/DSA
        /// <summary>
        /// Initializes a new instance of the <see cref="SequenceConfigurationsDialog.SequenceConfiguration"/> class.
        /// </summary>
        /// <param name="pins">Pins.</param>
        /// <param name="groups">Groups.</param>
        /// <param name="seq">Seq.</param>
        /// <param name="RefPin">Reference pin.</param>
        /// <param name="parent">Parent.</param>
        public SeqConfigDialog(DPin[] pins, List<string> groups, Sequence seq = null, DPin RefPin = null, Gtk.Window parent = null)
            : base("Digital Sequences - Dialog", parent, Gtk.DialogFlags.Modal, new object[0])
        {
            this.Build ();

            sbRadioBtnStopAfter.Adjustment.Upper = int.MaxValue;
            sbRadioBtnStopAfter.Adjustment.Lower = 0;

            DPins = pins;

            //no DPin no Sequence
            if (DPins.Length > 0) {
                for (int i = 0; i < DPins.Length; i++) {
            //					cbPin.AppendText (string.Format ("{0}(D{1})", DPins [i].Name, DPins [i].Number));
                    cbPin.AppendText (DPins [i].DisplayNumber);
                }
            }
            SetupNodeView ();
            SetupOxyPlot ();

            if (seq != null) {
                PinSequence = seq;
                if (seq.Repetitions == -1) {
                    rbRepeateContinously.Active = true;
                } else {
                    rbStopAfter.Active = true;
                    sbRadioBtnStopAfter.Sensitive = true;
                    sbRadioBtnStopAfter.Value = seq.Repetitions;
                }

                buttonOk.Label = "Apply";
                buttonOk.Image = new Image (Gtk.Stock.Apply, IconSize.Button);
            } else {
                pinSequence = new Sequence ();
                pinSequence.Repetitions = -1;
            }
            if (RefPin == null) {
                cbPin.Active = 0;
            } else {
                cbPin.Active = pins.ToList ().IndexOf (RefPin);
            }

            SetupGroups (groups);
            DisplaySequenceInfos ();
            BuildEvents ();
        }
コード例 #13
0
ファイル: DPinConfigDialog.cs プロジェクト: Onkeliroh/DSA
        /// <summary>
        /// Initializes a new instance of the <see cref="DigitalPinConfigurationDialog.DigitalPinConfiguration"/> class.
        /// </summary>
        /// <param name="availablePins">Available pins.</param>
        /// <param name="dpin">Dpin.</param>
        /// <param name="parent">Parent.</param>
        public DPinConfigDialog(DPin[] availablePins, DPin dpin = null, Gtk.Window parent = null)
            : base("Digital Output - Dialog", parent, Gtk.DialogFlags.Modal, new object[0])
        {
            this.Build ();

            this.FocusChain = new Widget[]{ entryName, cbPin, cbColor, buttonOk, buttonCancel };

            if (dpin != null)
            {
                //change to ApplyBtn to singal change instead of addition of a new instance
                buttonOk.Label = "Apply";
                buttonOk.Image = new Image (Gtk.Stock.Apply, IconSize.Button);

                AvailablePins = new DPin[availablePins.Length + 1];
                Array.Copy (availablePins, AvailablePins, availablePins.Length);
                AvailablePins [availablePins.Length] = dpin;

                Pin = new DPin (dpin);
            } else
            {
                AvailablePins = availablePins;

                if (AvailablePins.Length > 0)
                {
                    pin = AvailablePins [0];
                }
                pin.PlotColor = GUIHelper.ColorHelper.GetRandomGdkColor ();
                cbColor.Color = pin.PlotColor;
            }

            for (int i = 0; i < availablePins.Length; i++)
            {
                cbPin.AppendText (availablePins [i].DisplayNumber);
            }
            if (AvailablePins.Length > 0)
            {
                cbPin.Active = 0;
            } else
            {
                buttonOk.Sensitive = false;
                buttonOk.TooltipText = "There are no more Pins left to configure.";
            }

            BindEvents ();
        }
コード例 #14
0
ファイル: BoardConfiguration.cs プロジェクト: Onkeliroh/DSA
        /// <summary>
        /// Clones a pin.
        /// </summary>
        /// <returns><c>true</c>, if pin was cloned, <c>false</c> otherwise.</returns>
        /// <param name="pin">Pin.</param>
        public bool ClonePin(IPin pin)
        {
            Console.WriteLine("Cloning: " + pin);
            if ((pin as APin) != null)
            {
                if (AvailableAnalogPins.Length != 0)
                {
                    APin newPin = new APin(pin as APin);
                    newPin.Number        = AvailableAnalogPins [0].Number;
                    newPin.DigitalNumber = AvailableAnalogPins [0].DigitalNumber;

                    AddPin(newPin);
                }
                else
                {
                    return(false);
                }
            }
            else if ((pin as DPin) != null)
            {
                if (AvailableDigitalPins.Length != 0)
                {
                    DPin newPin = new DPin(pin as DPin);
                    newPin.Number       = AvailableDigitalPins [0].Number;
                    newPin.AnalogNumber = AvailableDigitalPins [0].AnalogNumber;

                    AddPin(newPin);
                }
                else
                {
                    return(false);
                }
            }
//			CheckPins ();
            return(true);
        }
コード例 #15
0
ファイル: SeqConfigDialog.cs プロジェクト: Onkeliroh/DSA
 /// <summary>
 /// Changes the pin.
 /// </summary>
 /// <param name="sender">Sender.</param>
 /// <param name="e">E.</param>
 protected void OnCbPinChanged(object sender, EventArgs e)
 {
     try {
         if (cbPin.ActiveText != null && selectedPin != null) {
             if (cbPin.ActiveText.Length > 0) {
                 int nr = 0;
     //						var reg = Regex.Match (cbPin.ActiveText, @"\(D([0-9]+)\)");
     //						reg = Regex.Match (reg.Value, @"\d+");
     //						if (reg.Success) {
     //							nr = Convert.ToInt32 (reg.Value);
     //
     //							for (int i = 0; i < DPins.Length; i++) {
     //								if (DPins [i].Number == nr) {
     //									selectedPin = DPins [i];
     //									sequenceSeries.Color = ColorHelper.GdkColorToOxyColor (selectedPin.PlotColor);
     //									repeateSeries.Color = ColorHelper.GdkColorToOxyColor (selectedPin.PlotColor);
     //									plotView.InvalidatePlot (true);
     //									plotView.ShowAll ();
     //									break;
     //								}
     //							}
     //						}
                 var pin = DPins.ToList ().Single (p => p.DisplayNumber == cbPin.ActiveText);
                 if (pin != null) {
                     selectedPin = pin;
                     sequenceSeries.Color = ColorHelper.GdkColorToOxyColor (selectedPin.PlotColor);
                     repeateSeries.Color = ColorHelper.GdkColorToOxyColor (selectedPin.PlotColor);
                     plotView.InvalidatePlot (true);
                     plotView.ShowAll ();
                 }
             }
         }
         // Analysis disable once EmptyGeneralCatchClause
     } catch (Exception) {
     }
 }
コード例 #16
0
ファイル: SerializeTests.cs プロジェクト: Onkeliroh/DSA
        public void SerializeSequence()
        {
            DPin TestPin = new DPin () {
                Number = 42,
                Name = "Testor the Destroyer"
            };

            Sequence Seq = new Sequence () {
                Pin = TestPin,
                Chain = new System.Collections.Generic.List<SequenceOperation> () {
                    new SequenceOperation () {
                        Duration = TimeSpan.FromSeconds (42),
                        State = DPinState.HIGH
                    },
                    new SequenceOperation () {
                        Duration = TimeSpan.FromSeconds (42),
                        State = DPinState.LOW
                    }
                },
                Repetitions = -1
            };

            Formator.Serialize (MemStream, Seq);
            MemStream.Seek (0, SeekOrigin.Begin);
            Sequence SeqEvilClone = (Sequence)Formator.Deserialize (MemStream);

            Console.WriteLine (Seq.ToStringLong ());
            Console.WriteLine (SeqEvilClone.ToStringLong ());

            Assert.AreEqual (Seq, SeqEvilClone);
        }
コード例 #17
0
ファイル: SerializeTests.cs プロジェクト: Onkeliroh/DSA
        public void SerializeDPin()
        {
            DPin TestPin = new DPin () {
                Number = 42,
                Name = "TestPin",
                PlotColor = GUIHelper.ColorHelper.GetRandomGdkColor (),
            };

            Formator.Serialize (MemStream, TestPin);

            MemStream.Seek (0, SeekOrigin.Begin);

            DPin TestPinClone = (DPin)Formator.Deserialize (MemStream);

            Assert.AreEqual (TestPin, TestPinClone);
        }
コード例 #18
0
ファイル: NodeViews.cs プロジェクト: Onkeliroh/DSA
 public DPinTreeNode(DPin pin, int index = -1, Sequence seq = null)
 {
     Sequence = seq;
     Index = index;
     Pin = pin;
 }
コード例 #19
0
ファイル: MainWindow.cs プロジェクト: Onkeliroh/DSA
		private void RunAddDPinDialog (DPin pin = null)
		{
			var dings = con.Configuration.AvailableDigitalPins;

			DPinConfigDialog dialog = new DPinConfigDialog (dings, pin, this);

			dialog.Response += (o, args) =>
			{
				if (args.ResponseId == ResponseType.Apply)
				{
					if (pin == null)
					{
						con.Configuration.AddPin (dialog.Pin);
					} else
					{
						for (int i = 0; i < con.Configuration.Pins.Count; i++)
						{
							if (con.Configuration.Pins [i] == pin)
							{
								con.Configuration.EditPin (i, dialog.Pin);
								break;
							}
						}
					}
				}
			};
			dialog.Run ();
			dialog.Destroy ();
		}
コード例 #20
0
ファイル: MainWindow.cs プロジェクト: Onkeliroh/DSA
		private void RunSequenceDialog (Sequence seq = null, DPin RefPin = null)
		{
			SeqConfigDialog dialog;
			if (seq != null)
			{
				dialog = new SeqConfigDialog (
					con.Configuration.GetPinsWithoutSequence (), 
					con.Configuration.SequenceGroups, 
					new Sequence (seq), 
					RefPin, 
					this
				);
			} else
			{
				dialog = new SeqConfigDialog (
					con.Configuration.GetPinsWithoutSequence (), 
					con.Configuration.SequenceGroups, 
					null, 
					RefPin, 
					this
				);
			}

			dialog.Response += (o, args) =>
			{
				if (args.ResponseId == ResponseType.Apply)
				{
					if (seq == null)
					{
						con.Configuration.AddSequence (dialog.PinSequence);
					} else
					{
						con.Configuration.EditSequence (con.Configuration.Sequences.IndexOf (seq), dialog.PinSequence);
					}
				}
			};
			dialog.Run ();
			dialog.Destroy ();
		}
コード例 #21
0
ファイル: BoardConfiguration.cs プロジェクト: Onkeliroh/DSA
        /// <summary>
        /// Clones a pin.
        /// </summary>
        /// <returns><c>true</c>, if pin was cloned, <c>false</c> otherwise.</returns>
        /// <param name="pin">Pin.</param>
        public bool ClonePin(IPin pin)
        {
            Console.WriteLine ("Cloning: " + pin);
            if ((pin as APin) != null)
            {
                if (AvailableAnalogPins.Length != 0)
                {
                    APin newPin = new APin (pin as APin);
                    newPin.Number = AvailableAnalogPins [0].Number;
                    newPin.DigitalNumber = AvailableAnalogPins [0].DigitalNumber;

                    AddPin (newPin);
                } else
                {
                    return false;
                }
            } else if ((pin as DPin) != null)
            {
                if (AvailableDigitalPins.Length != 0)
                {
                    DPin newPin = new DPin (pin as DPin);
                    newPin.Number = AvailableDigitalPins [0].Number;
                    newPin.AnalogNumber = AvailableDigitalPins [0].AnalogNumber;

                    AddPin (newPin);
                } else
                {
                    return false;
                }
            }
            //			CheckPins ();
            return true;
        }
コード例 #22
0
ファイル: BoardConfiguration.cs プロジェクト: Onkeliroh/DSA
 /// <summary>
 /// Gets the coresponding sequence.
 /// </summary>
 /// <returns>The coresponding sequence.</returns>
 /// <param name="pin">Pin</param>
 public Sequence GetCorespondingSequence(DPin pin)
 {
     foreach (Sequence seq in Sequences)
     {
         if (seq.Pin == pin)
         {
             return seq;
         }
     }
     return null;
 }