Esempio n. 1
0
        /// <summary>
        /// Update the display to show the new array of aids
        /// </summary>
        /// <param name="aidList">Array of Aids to display</param>
        public void Update(Aid[] aidList)
        {
            int aidsIndex = 0;
            //clear all UIAids
            foreach (UIAid aid in this.aids)
            {
                aid.Clear();
            }
            //aid count label
            this.QueueCount.Text = aidList.Length.ToString() + " Aid(s) in queue";
            //set UIAid properties to that or aid in arrray
            foreach (Aid aid in aidList)
            {
                //more aids than UIaids
                if (aidsIndex == this.aids.Length)
                    break;

                //set the UIaid properties
                this.aids[aidsIndex].Serial = aid.SerialText;
                this.aids[aidsIndex].Ear = aid.Ear;
                this.aids[aidsIndex].Model = aid.ModelText;
                if (aid.Model != null)
                    this.aids[aidsIndex].Drawing = aid.Model.Name;

                aidsIndex ++;
            }
        }
Esempio n. 2
0
        private Aid waitingAid; //aid waiting to be lasered

        #endregion Fields

        #region Constructors

        private LaserMarker()
        {
            this.laserHardware = null;
            this.state = LaserMarkerState.WaitingForWork;
            //handle AidsQueueUpdated event
            AidQueue aidQueue = AidQueue.Instance;
            aidQueue.AidAdded += new EventHandler(AidsQueueUpdated);
            this.waitingAid = null;
        }
Esempio n. 3
0
 /// <summary>
 /// Called when hardware status changes
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void HardwareDoorChanged(object sender, DoorChangedEventArgs e)
 {
     if (e.Status == LaserHardwareDoorStatus.Closed)
     {
         //door now closed
         if (this.waitingAid != null)
         {
             //there is a waiting aid so mark it
             LaserMarkResult result = this.laserHardware.Mark(this.waitingAid.Model.Name, this.waitingAid.SerialText, this.waitingAid.ModelText);
             if (result == LaserMarkResult.Success)
             {
                 //mark successfull
                 this.waitingAid = null;
                 if (AidQueue.Instance.PeekHeadAid() == null)
                 {
                     this.state = LaserMarkerState.WaitingForWork;
                 }
                 else
                 {
                     this.state = LaserMarkerState.WaitingForDoorOpen;
                 }
                 this.StateModified();
             }
             else
             {
                 //mark unsuccessfull
                 if (this.MarkFailed != null)
                 {
                     MarkFailAction action = this.MarkFailed(this, new MarkFailEventArgs(result));
                     if (action == MarkFailAction.Cancel)
                     {
                         //mark canceled, remove aid
                         this.waitingAid = null;
                         if (AidQueue.Instance.PeekHeadAid() == null)
                         {
                             this.state = LaserMarkerState.WaitingForWork;
                         }
                         else
                         {
                             this.state = LaserMarkerState.WaitingForDoorOpen;
                         }
                     }
                     else
                     {
                         //retry mark
                         this.state = LaserMarkerState.WaitingForDoorOpen;
                     }
                     this.StateModified();
                 }
             }
         }
     }
     else if (e.Status == LaserHardwareDoorStatus.Open)
     {
         //door now open
         if (this.waitingAid == null)
         {
             //get a new aid to mark
             this.waitingAid = AidQueue.Instance.GetHeadAid();
             //if there is a aid to mark change state
             if (this.waitingAid != null)
                 this.state = LaserMarkerState.WaitingForDoorClose;
             this.StateModified();
         }
         else
         {
             //this might happen if mark fails and is retried
             if (this.state != LaserMarkerState.WaitingForDoorClose)
             {
                 this.state = LaserMarkerState.WaitingForDoorClose;
                 this.StateModified();
             }
         }
     }
     //door status unknown?
 }
Esempio n. 4
0
 /// <summary>
 /// Called when Aid added to aid queue
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void AidsQueueUpdated(object sender, EventArgs e)
 {
     AidQueue aidQueue = AidQueue.Instance;
     if (this.waitingAid == null)
     {
         if (this.laserHardware.GetDoorStatus() == LaserHardwareDoorStatus.Open)
         {
             this.waitingAid = aidQueue.GetHeadAid();
             this.state = LaserMarkerState.WaitingForDoorClose;
         }
         else
         {
             //waiting for door to open
             this.state = LaserMarkerState.WaitingForDoorOpen;
         }
         this.StateModified();
     }
 }
Esempio n. 5
0
 /// <summary>
 /// gets the incomplete aid from the tail of queue. if the aid at
 /// the back of the queue is complete modifyQueue controls if a new aid is added to
 /// the queue or if null is returned
 /// Note the caller is responsable for firing the AidsQueueUpdated event
 /// </summary>
 /// <param name="modifyQueue">is the method allowed to modify the queue?</param>
 /// <returns></returns>
 private Aid GetIncompleteAid(bool modifyQueue)
 {
     Aid aid;
     if (this.aids.Count == 0)
     {
         if (modifyQueue == true)
         {
             aid = new Aid();
             this.aids.Add(aid);
         }
         else
         {
             //return null instead of modifing the queue
             aid = null;
         }
     }
     else
     {
         aid = (Aid) this.aids[this.aids.Count -1];
         if (aid.IsComplete() == true)
         {
             if (modifyQueue == true)
             {
                 aid = new Aid();
                 this.aids.Add(aid);
             }
             else
             {
                 //return null instead of modifing the queue
                 aid = null;
             }
         }
     }
     return aid;
 }
Esempio n. 6
0
 /// <summary>
 /// Adds a model to an aid
 /// </summary>
 /// <param name="aid">aid to add model to</param>
 /// <param name="modelText">model text</param>
 /// <param name="model">model to add to aid</param>
 private void AddModelToAid(Aid aid, string modelText, Model model)
 {
     aid.Model = model;
     aid.ModelText = modelText;
     //also add models with no serial format
     if (model.SerialFormat == null)
     {
         aid.SerialText = modelText;
     }
     this.AidsQueueModified();
 }
Esempio n. 7
0
 /// <summary>
 /// Adds aid to the queue
 /// </summary>
 /// <param name="aid">Aid to add to the queue</param>
 private void Add(Aid aid)
 {
     this.aids.Add(aid);
 }