/// <summary> /// Returns the next Operation to be done /// </summary> public SequenceOperation?Next() { CurrentOperation += 1; //one cycle is finished -> start new cycle if (CurrentOperation == Chain.Count) { CurrentOperation = 0; Cycle += 1; } //if sequence is done if (CurrentState == SequenceState.Done || ((Cycle > Repetitions || Chain.Count == 0) && Repetitions != -1)) { CurrentState = SequenceState.Done; return(null); } else { CurrentState = SequenceState.Running; LastOperation += Chain [CurrentOperation].Duration; SequenceOperation op = Chain [CurrentOperation]; return(op); } }
/// <summary> /// Gets the sequence state depending on the given time. /// </summary> /// <returns>The current state.</returns> /// <param name="milli">time in milliseconds</param> public DPinState GetCurrentState(double milli) { int multiplier = 0; if (milli >= Runtime.TotalMilliseconds) { multiplier = (int)(System.Math.Floor(milli / Runtime.TotalMilliseconds)); milli -= multiplier * Runtime.TotalMilliseconds; } SequenceOperation op = new SequenceOperation(); if (Chain.Count > 0) { if (multiplier >= Repetitions && Repetitions != -1 && multiplier != 0) { return(Chain.Last().State); } else { op = Chain [0]; foreach (SequenceOperation seqop in Chain) { if (seqop.Moment.TotalMilliseconds == milli) { return(seqop.State); } else if (seqop.Moment.TotalMilliseconds < milli) { if ((milli - seqop.Moment.TotalMilliseconds) < (milli - op.Moment.TotalMilliseconds)) { op = seqop; } } } return(op.State); } } return(DPinState.LOW); }
/// <summary> /// Adds a sequence operation. /// </summary> /// <param name="seqop">Sequenceoperation to be added</param> public void AddSequenceOperation(SequenceOperation seqop) { seqop.Moment = new TimeSpan(Chain.Sum(o => o.Duration.Ticks)); Chain.Add(seqop); }
/// <summary> /// Adds or changes a operation. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> protected void OnBtnApplyOperationClicked(object sender, EventArgs e) { var op = new SequenceOperation () { Duration = this.Duration, // State = (cbState.ActiveText == "HIGH") ? DPinState.HIGH : DPinState.LOW, State = (cbState.Active == 0) ? DPinState.HIGH : DPinState.LOW, }; if (ActiveNode == null) { AddOperation (op); cbState.Active = (cbState.Active == 0) ? 1 : 0; } else { pinSequence.Chain [ActiveNode.Index] = op; DisplaySequenceInfos (); SwitchToAddBtn (); } }
/// <summary> /// Adds a operation. /// </summary> /// <param name="SeqOp">Seq op.</param> private void AddOperation(SequenceOperation SeqOp) { pinSequence.AddSequenceOperation (SeqOp); XAxis.AbsoluteMaximum = pinSequence.Chain.Sum (o => o.Duration.TotalMilliseconds); DisplaySequenceInfos (); }
public SequenceOperationTreeNode(SequenceOperation seqop, int index = -1, double totalTime = -1) { SeqOp = seqop; Index = index; if (totalTime < 0) { TotalTime = ""; } else { TotalTime = "+" + TimeSpan.FromTicks ((long)totalTime).ToString ("g"); } }
public void SerializeSequenceOperation() { SequenceOperation SeqOp = new SequenceOperation () { Duration = TimeSpan.FromSeconds (42), State = DPinState.HIGH }; Formator.Serialize (MemStream, SeqOp); MemStream.Seek (0, SeekOrigin.Begin); SequenceOperation SeqOpClone = (SequenceOperation)Formator.Deserialize (MemStream); Assert.AreEqual (SeqOp, SeqOpClone); }
/// <summary> /// Gets the sequence state depending on the given time. /// </summary> /// <returns>The current state.</returns> /// <param name="milli">time in milliseconds</param> public DPinState GetCurrentState(double milli) { int multiplier = 0; if (milli >= Runtime.TotalMilliseconds) { multiplier = (int)(System.Math.Floor (milli / Runtime.TotalMilliseconds)); milli -= multiplier * Runtime.TotalMilliseconds; } SequenceOperation op = new SequenceOperation (); if (Chain.Count > 0) { if (multiplier >= Repetitions && Repetitions != -1 && multiplier != 0) { return Chain.Last ().State; } else { op = Chain [0]; foreach (SequenceOperation seqop in Chain) { if (seqop.Moment.TotalMilliseconds == milli) { return seqop.State; } else if (seqop.Moment.TotalMilliseconds < milli) { if ((milli - seqop.Moment.TotalMilliseconds) < (milli - op.Moment.TotalMilliseconds)) { op = seqop; } } } return op.State; } } return DPinState.LOW; }
/// <summary> /// Adds the sequence operation range. /// </summary> /// <param name="seqops">Seqops.</param> public void AddSequenceOperationRange(SequenceOperation[] seqops) { for (int i = 0; i < seqops.Length; i++) { AddSequenceOperation (seqops [i]); } }
/// <summary> /// Adds a sequence operation. /// </summary> /// <param name="seqop">Sequenceoperation to be added</param> public void AddSequenceOperation(SequenceOperation seqop) { seqop.Moment = new TimeSpan (Chain.Sum (o => o.Duration.Ticks)); Chain.Add (seqop); }