Пример #1
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?
 }
Пример #2
0
 /// <summary>
 /// toggle the door status
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void ButtonDoorToggleClick(object sender, System.EventArgs e)
 {
     if (this.doorStatus == LaserHardwareDoorStatus.Closed)
     {
         this.doorStatus = LaserHardwareDoorStatus.Open;
     }
     else
     {
         this.doorStatus = LaserHardwareDoorStatus.Closed;
     }
     //fire door changed event
     this.labelDoorStatus.Text = this.doorStatus.ToString();
     DoorChangedEventArgs args = new DoorChangedEventArgs(this.doorStatus);
     if (this.DoorChanged != null)
     {
         this.DoorChanged(this, args);
     }
 }
Пример #3
0
 /// <summary>
 /// Gets the door status when the timer ticks
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Timer_Tick(object sender, EventArgs e)
 {
     if (this.connected == true)
     {
         short result = this.synrad.GetDigitalBit(3);
         if (result == 1)
         {
             this.doorStatus = LaserHardwareDoorStatus.Closed;
         }
         else
         {
             this.doorStatus = LaserHardwareDoorStatus.Open;
         }
         this.labelDoorStatus.Text = this.doorStatus.ToString();
         //fire door changed event
         DoorChangedEventArgs args = new DoorChangedEventArgs(this.doorStatus);
         if (this.DoorChanged != null)
         {
             this.DoorChanged(this, args);
         }
     }
 }
Пример #4
0
 /// <summary>
 /// Toggle the door status
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 void ChkDoorClick(object sender, System.EventArgs e)
 {
     if (this.chkDoor.Checked)
     {
         this.chkDoor.Text = "Door Closed";
         this.doorStatus = LaserHardwareDoorStatus.Closed;
     }
     else
     {
         this.chkDoor.Text = "Door Open";
         this.doorStatus = LaserHardwareDoorStatus.Open;
     }
     //fire door changed event
     DoorChangedEventArgs args = new DoorChangedEventArgs(this.doorStatus);
     if (this.DoorChanged != null)
     {
         this.DoorChanged(this, args);
     }
 }