Example #1
0
 private void Light_Mode(bool state = false)
 {
     if (!Serial_Light.IsOpen)
     {
         Serial_Light.Open();
     }
     byte[] a = state ? new byte[] { 0xab, 0xba, 0x03, 0x32, 0x00, 0x01 } : new byte[] { 0xab, 0xba, 0x03, 0x32, 0x00, 0x00 };
     Serial_Light.Write(a, 0, a.Length);
 }
Example #2
0
 private void trackBar1_Scroll(object sender, EventArgs e)
 {
     if (!Serial_Light.IsOpen)
     {
         Serial_Light.Open();
     }
     label9.Text = trackBar1.Value.ToString();
     byte[] a = { 0xab, 0xba, 0x03, 0x31, 0x00, 0x09 };
     a[5] = (byte)trackBar1.Value;
     Serial_Light.Write(a, 0, a.Length);
 }
Example #3
0
        private bool OpenDevice()
        {
            ShowLog("Update parameter!", Color.Green);
            UpdateParameter(true);;
            ShowLog("Connecting COM port for light!", Color.Green);
            if (!Serial_Light.IsOpen)
            {
                Serial_Light.Open();
            }
            ORG.SetPointO(Config.Parameter.ROTATION_CENTER);
            GetOriginImage();
            ShowLog("Connecting to Camera", Color.Green);
            bool response = OpenCamera();

            if (response)
            {
                ShowLog("Connecting to PLC 1", Color.Green);
                response = plc.Open(10000);
                if (response)
                {
                    ShowLog("Connecting to PLC 2", Color.Green);
                    response = plc2.Open(10000);
                    if (response)
                    {
                        ShowLog("Starting success", Color.Green);
                    }
                    else
                    {
                        MessageBox.Show("Can't Connecting to PLC 2 ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        ShowLog("Can't Connecting to PLC 2 ", Color.Red);
                    }
                }
                else
                {
                    MessageBox.Show("Can't Connecting to PLC 1 ", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    ShowLog("Can't Connecting to PLC 1 ", Color.Red);
                }
            }
            else
            {
                ShowLog("Can't open Camera", Color.Red);
                MessageBox.Show("Can't Connecting to Camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            if (!response)
            {
                Release();
            }
            return(response);
        }
Example #4
0
 private void LoadUI()
 {
     comboCamera.Items.Clear();
     string[] _ListDevice = Camera.SearchDevice();
     if (_ListDevice.Length > 0)
     {
         comboCamera.Items.AddRange(_ListDevice);
         comboCamera.SelectedIndex = 0;
     }
     else
     {
         _ListDevice = null;
         DialogResult result = MessageBox.Show("Camera not found!", "Information", MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning);
         if (result == DialogResult.Retry)
         {
             Thread.Sleep(1000);
             LoadUI();
         }
         else
         {
             Start.Enabled = false;
         }
     }
     if (Serial_Light.IsOpen == false)
     {
         Serial_Light.Open();
     }
     Config.Init();
     UpdateParameter();
     modeCamera_CheckedChanged(null, null);
     ORG.SetPointO(Config.Parameter.ROTATION_CENTER);
     GetOriginImage();
     for (int i = 0; i < LabelResut.Length; i++)
     {
         LabelResut[i] = string.Empty;
     }
 }