void LoadFromSettings()
        {
            loading = true;
            Settings settings = Settings.Get <Settings>();

            if (settings != null)
            {
                this.Enabled = true;
                ILaserProxy laser = Settings.Get <ILaserProxy>();
                if (laser != null)
                {
                    int currentLaser = CurrentLaserIndex;
                    int lasercount   = laser.Count;
                    this.LaserComboBox.Items.Clear();
                    for (int i = 0; i < lasercount; i++)
                    {
                        int index = this.LaserComboBox.Items.Add(String.Format("Laser {0}", i));
                    }
                    this.LaserComboBox.SelectedIndex = Math.Max(0, currentLaser);
                    CurrentLaserIndex = this.LaserComboBox.Items.Count == 0 ? -1 : this.LaserComboBox.SelectedIndex;
                }
            }
            else
            {
                this.Enabled = false;
            }


            loading = false;
        }
Example #2
0
 /// <summary>
 /// Turn all the lasers  on or off together
 /// </summary>
 /// <param name="ctrl"></param>
 /// <param name="on"></param>
 public static void TurnAll(this ILaserProxy ctrl, bool on)
 {
     for (int i = 0; i < ctrl.Count; i++)
     {
         ctrl.Turn(i, on);
     }
 }
Example #3
0
        void LoadFromSettings()
        {
            loading = true;
            Settings settings = Settings.Get <Settings>();

            if (settings != null)
            {
                this.Enabled = true;
                Vector3d cam = new Vector3d(settings.Read(Settings.CAMERA, Settings.X, 0f), settings.Read(Settings.CAMERA, Settings.Y, 50f), settings.Read(Settings.CAMERA, Settings.Z, 220f));

                SetNumericUpDownValue(this.CameraZ, (decimal)cam.Z);
                SetNumericUpDownValue(this.CameraY, (decimal)cam.Y);
                ILaserProxy laser = Settings.Get <ILaserProxy>();
                if (laser != null)
                {
                    int currentLaser = this.LaserComboBox.Items.Count == 0 ? -1 : this.LaserComboBox.SelectedIndex;
                    int lasercount   = laser.Count;
                    this.LaserComboBox.Items.Clear();
                    for (int i = 0; i < lasercount; i++)
                    {
                        this.LaserComboBox.Items.Add(String.Format("Laser {0}", i));
                    }
                    currentLaser = Math.Max(0, currentLaser);
                    this.LaserComboBox.SelectedIndex = currentLaser;
                    Vector3d laserLoc = new Vector3d(
                        settings.Read(Settings.LASER(currentLaser), Settings.X, 50f),
                        settings.Read(Settings.LASER(currentLaser), Settings.Y, (double)this.CameraY.Value),
                        settings.Read(Settings.LASER(currentLaser), Settings.Z, (double)this.CameraZ.Value)
                        );

                    double angle = laserLoc.AngleInDegrees(cam);
                    if (cam.X < laserLoc.X)
                    {
                        angle = -angle;
                    }

                    SetNumericUpDownValue(this.LaserX, (decimal)laserLoc.X);
                    this.LaserYLabel.Text = string.Format("{0:.0}", laserLoc.Y);
                    SetNumericUpDownValue(this.LaserZ, (decimal)laserLoc.Z);
                    SetNumericUpDownValue(this.LaserAngle, (decimal)angle);
                }
            }
            else
            {
                this.Enabled = false;
            }


            loading = false;
        }
Example #4
0
 private void OnIdle(object sender, EventArgs e)
 {
     try
     {
         bool ignore = false;
         if (!ignore && Visible)
         {
             DateTime now     = DateTime.Now;
             bool     expired = (now - lastCheckTime).TotalMilliseconds > 500;
             if (expired)
             {
                 LaserProxy = Settings.Get <ILaserProxy>();
             }
         }
     }
     catch
     {
     }
 }
Example #5
0
        public void LoadInterface()
        {
            loading = true;
            ILaserProxy laser = Settings.Get <ILaserProxy>();

            if (laser != null && LastlaserProxy != laser)
            {
                LastlaserProxy = laser;
                int currentLaser = this.LaserComboBox.SelectedIndex;
                int lasercount   = laser.Count;
                this.LaserComboBox.Items.Clear();
                LoadFromSettings();
                for (int i = 0; i < lasercount; i++)
                {
                    this.LaserComboBox.Items.Add(String.Format("Laser {0}", i));
                }
                this.LaserComboBox.SelectedIndex = currentLaser;
            }
            loading = false;
        }
Example #6
0
 private void OnIdle(object sender, EventArgs e)
 {
     try
     {
         bool ignore = false;
         if (!ignore && Visible)
         {
             DateTime now     = DateTime.Now;
             bool     expired = (now - lastImageTime).TotalMilliseconds > 10;
             if (expired)
             {
                 ICameraProxy camera = Settings.Get <ICameraProxy>();
                 if (camera != null)
                 {
                     CurrentImage  = camera.AcquireImage();
                     lastImageTime = now;
                     ViewPanel.Invalidate();
                 }
                 else
                 {
                     bool lasthasImage = CurrentImage != null;
                     CurrentImage = null;
                     if (lasthasImage)
                     {
                         ViewPanel.Invalidate();
                     }
                 }
                 ILaserProxy laser = Settings.Get <ILaserProxy>();
                 expired = (now - lastImageTime).TotalMilliseconds > 750;
                 if (laser != null)
                 {
                     LaserControl.Proxy = laser;
                     LaserControl.AlignControls();
                 }
             }
         }
     }
     catch
     {
     }
 }
Example #7
0
		private void OnIdle(object sender, EventArgs e)
		{
			try
			{
				bool ignore = false;
				if (!ignore && Visible)
				{
					DateTime now = DateTime.Now;
					bool expired = (now - lastCheckTime).TotalMilliseconds > 500;
					if (expired)
					{
						LaserProxy = Settings.Get<ILaserProxy>();
					}
				}
			}
			catch
			{
			}
		}
Example #8
0
        public void LoadInterface()
        {
					loading = true;
            ILaserProxy laser = Settings.Get<ILaserProxy>();
            if (laser != null && LastlaserProxy!=laser)
            {
							LastlaserProxy=laser;
							int currentLaser = this.LaserComboBox.SelectedIndex;
                int lasercount = laser.Count;
                this.LaserComboBox.Items.Clear();
                LoadFromSettings();
                for (int i = 0; i < lasercount; i++)
                {
                    this.LaserComboBox.Items.Add(String.Format("Laser {0}", i));
                }
								this.LaserComboBox.SelectedIndex = currentLaser;
            }
					loading=false;
        }
        public static eHardware GetFromInstance(ICameraProxy cam, ITurnTableProxy table, ILaserProxy laser)
        {
            eHardware ret = eHardware.None;

            ret = GetModified(ret, eHardware.Camera, cam != null);
            ret = GetModified(ret, eHardware.Table, table != null);
            ret = GetModified(ret, eHardware.Laser, laser != null);
            return(ret);
        }