Пример #1
0
        public void MoveTriggerPt(GTriggerPoint TPt, double dDistAdjust)
        {
            int    iTrigger     = _listTriggerPts.IndexOf(TPt);
            double proposedDist = TPt.Distance + dDistAdjust;

            if (dDistAdjust < 0.0)
            {
                if (iTrigger > 0)
                {
                    // Check that movement is not before previous trigger
                    if (proposedDist < _listTriggerPts[iTrigger - 1].Distance)
                    {
                        TPt.Distance.Val = _listTriggerPts[iTrigger - 1].Distance + 0.001;
                        return;
                    }
                }
            }
            else
            {
                if (iTrigger < _listTriggerPts.Count - 1)
                {
                    // Check that movement is not after next trigger
                    if (proposedDist > _listTriggerPts[iTrigger + 1].Distance)
                    {
                        TPt.Distance.Val = _listTriggerPts[iTrigger + 1].Distance - 0.001;
                        return;
                    }
                }
            }
            TPt.Distance.Val = proposedDist;
        }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="triggerPt"></param>
 public void RemoveTrigger(GTriggerPoint triggerPt)
 {
     if (_listTriggerPts.Contains(triggerPt))
     {
         _listTriggerPts.Remove(triggerPt);
         triggerPt.Dispose();
     }
 }
Пример #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="triggerPt"></param>
 public void AddTrigger(GTriggerPoint triggerPt)
 {
     if (!_listTriggerPts.Contains(triggerPt))
     {
         triggerPt.Initialize(this);
         _listTriggerPts.Add(triggerPt);
         SortTriggers();
     }
 }
Пример #4
0
 /// <summary>
 /// Called after a child trigger has completed successfuly
 /// </summary>
 /// <param name="trigger"></param>
 public virtual void TriggerCompleted(GTriggerPoint trigger)
 {
     //System.Diagnostics.Debug.WriteLine(string.Format("TriggerComplete for {0}", Nickname));
     if (LastInWorkpiece != null && Object.ReferenceEquals(trigger, _listTriggerPts[NumTriggerPts - 1]))
     {
         //System.Diagnostics.Debug.WriteLine(string.Format("TriggerComplete LastInWorkPiece Set for {0}", Name));
         LastInWorkpiece.Set();
     }
 }
Пример #5
0
        public void AutoFillTriggers(int numDots)
        {
            int minDots = 1;

            if (numDots > 0)
            {
                List <TrigGrp> trGrps   = new List <TrigGrp>();
                TrigGrp        trCurGrp = null;
                foreach (GTriggerPoint tPt in _listTriggerPts)
                {
                    tPt.LeadTime = 0.0;
                    Millimeters thisDist = new Millimeters(tPt.Distance.Val);
                    if (trCurGrp == null)
                    {
                        trCurGrp = new TrigGrp();
                        trGrps.Add(trCurGrp);
                    }
                    if (tPt.Anchor && minDots == 1)
                    {
                        minDots = 2;
                    }
                    if (tPt.Anchor && trCurGrp.Start != null)
                    {
                        // End of a group.  Signal to start a new one
                        trCurGrp.End = thisDist;
                        trCurGrp     = null;
                    }
                    else
                    {
                        // Contiue to add to a group
                        if (trCurGrp.Start == null)
                        {
                            trCurGrp.Start = thisDist;
                        }
                        trCurGrp.End = thisDist;
                    }
                }

                if (trGrps.Count == 0)
                {
                    trGrps.Add(new TrigGrp()
                    {
                        Start = 0.0, End = XYLength
                    });
                }
                // Handle case for not enough dots
                int numEachGrp = Math.Max(minDots, numDots / trGrps.Count);
                numDots = numEachGrp * trGrps.Count;
                int iTrg = 0;
                foreach (TrigGrp trGrp in trGrps)
                {
                    double gap = (trGrp.End - trGrp.Start) / (numEachGrp - 1);
                    for (int i = 0; i < numEachGrp; i++, iTrg++)
                    {
                        bool   bAnchor  = i == 0 || (i == numEachGrp - 1);
                        double thisDist = double.IsInfinity(gap) || double.IsNaN(gap) ? XYLength / 2.0 : (double)(gap * i + trGrp.Start);
                        if (iTrg < _listTriggerPts.Count)
                        {
                            _listTriggerPts[iTrg].Distance.Val = thisDist;
                            _listTriggerPts[iTrg].Anchor       = bAnchor;
                        }
                        else
                        {
                            GTriggerPoint newTriggerPt = CreateTrigger();
                            newTriggerPt.Distance.Val = thisDist;
                            newTriggerPt.Anchor       = bAnchor;
                            _listTriggerPts.Add(newTriggerPt);
                            newTriggerPt.Initialize(this);
                        }
                    }
                }
            }
            // Get rid of excess
            while (_listTriggerPts.Count > numDots)
            {
                RemoveTrigger(_listTriggerPts[numDots]);
            }
            U.LogChange(string.Format("{0}.AutoFillTriggers", Nickname));
            SortTriggers();
            FireOnChangedEvent();
        }