예제 #1
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (myGlobal.switchDevice == null)
         {
             myGlobal.switchDevice = new ICT_VNPT.Func.Instrument.SwitchCard();
         }
         if (myGlobal.switchDevice.IsConnected == false)
         {
             int r = myGlobal.switchDevice.LoadLibrary(myGlobal.switchcardInfo.DLLFile, InstrumentType.Switcher);
             if (r == 0)
             {
                 int kq = AbstractExcute._openDevice(myGlobal.switchDevice, myGlobal.switchcardInfo);
                 if (kq == 0)
                 {
                     if (myGlobal.switchDevice.IsConnected == false)
                     {
                         MessageBox.Show("can't connect to switch card", "Connect switch card", MessageBoxButton.OK, MessageBoxImage.Error);
                     }
                     else
                     {
                         this.tbStatus.Text       = "Connected"; this.tbStatus.Foreground = Brushes.Lime;
                         this.grid_main.IsEnabled = true;
                     }
                 }
                 else
                 {
                     MessageBox.Show("can't open switch card", "Connect switch card", MessageBoxButton.OK, MessageBoxImage.Error);
                 }
             }
             else
             {
                 MessageBox.Show("can't load file dll switch card", "Connect switch card", MessageBoxButton.OK, MessageBoxImage.Error);
             }
         }
         else
         {
             this.tbStatus.Text       = "Connected"; this.tbStatus.Foreground = Brushes.Lime;
             this.grid_main.IsEnabled = true;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Connect switch card", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
예제 #2
0
        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            MenuItem itm = sender as MenuItem;

            switch (itm.Header.ToString())
            {
            case "New An Item": {
                try {
                    int index = myGlobal.duts[0].Cases[0].Items.Count + 1;
                    var item  = new TestItemInfo()
                    {
                        ItemName = string.Format("New Item {0}", index), OrderNo = index.ToString()
                    };
                    myGlobal.duts[0].Cases[0].Items.Add(item);
                    myGlobal.duts[0].Cases[0].ItemCount = myGlobal.duts[0].Cases[0].Items.Count;
                }
                catch { }
                break;
            }

            case "New Range Item": {
                NewRangeItemWindow window = new NewRangeItemWindow();
                window.ShowDialog();
                int rangeCount = window.numberItem;
                if (rangeCount == 0)
                {
                    break;
                }

                try {
                    for (int i = 0; i < rangeCount; i++)
                    {
                        var index = myGlobal.duts[0].Cases[0].Items.Count + 1;
                        var item  = new TestItemInfo()
                        {
                            ItemName = string.Format("New Item {0}", index), OrderNo = index.ToString()
                        };
                        myGlobal.duts[0].Cases[0].Items.Add(item);
                        myGlobal.duts[0].Cases[0].ItemCount = myGlobal.duts[0].Cases[0].Items.Count;
                    }
                }
                catch { }
                break;
            }

            case "Delete Item": {
                try {
                    var item = (TestItemInfo)trvItemTest.SelectedItem;
                    myGlobal.duts[0].Cases[0].Items.Remove(item);
                    myGlobal.duts[0].Cases[0].ItemCount = myGlobal.duts[0].Cases[0].Items.Count;

                    for (int i = 0; i < myGlobal.duts[0].Cases[0].Items.Count; i++)
                    {
                        myGlobal.duts[0].Cases[0].Items[i].OrderNo = string.Format("{0}", i + 1);
                    }
                }
                catch { }
                break;
            }

            case "Refresh": {
                break;
            }

            case "Run Test (F6)": {
                try {
                    var item = (TestItemInfo)trvItemTest.SelectedItem;
                    int idx  = myGlobal.duts[0].Cases[0].Items.IndexOf(item);

                    Thread t = new Thread(new ThreadStart(() => {
                            TestItem.Validating(myGlobal.duts[0].Cases[0].Items[idx]);

                            //off power supply
                            if (myGlobal.settingInfo.OFFPower == "Yes")
                            {
                                if (myGlobal.settingInfo.EnablePower.ToLower().Contains("yes"))
                                {
                                    if (myGlobal.powerDevice != null && myGlobal.powerDevice.IsConnected)
                                    {
                                        AbstractExcute.set_Power_Supply_OFF();
                                    }
                                }
                            }
                            //reset relay
                            if (myGlobal.settingInfo.ResetSwitch == "Yes")
                            {
                                if (myGlobal.switchDevice != null && myGlobal.switchDevice.IsConnected)
                                {
                                    myGlobal.switchDevice.Set_Card_Open();
                                }
                            }
                        }));
                    t.IsBackground = true;
                    t.Start();
                }
                catch {
                }
                break;
            }

            default: break;
            }
        }