示例#1
0
        private void PowerOnBtn_Click(object sender, RoutedEventArgs e)
        {
            share.EventLog(null, "[Click]\t", "Power On");

            if (DelSerialCommandSendEventHandler != null)
            {
                DelSerialCommandSendEventHandler.Invoke(StaticDefine.COMMAND_POWER_ON, StaticDefine.SERIAL_CMD_PW_ON);
            }
        }
示例#2
0
        private void VoltApplyBtn_Click(object sender, RoutedEventArgs e)
        {
            //string selch = CHSelectCB.SelectionBoxItem.ToString();
            //string selvdd = VddSelectCB.SelectionBoxItem.ToString();
            //
            //string sendvalue = selch + " " + selvdd + " " + VoltValueTB.Text + " mV";

            if (VoltValueTB.Text == string.Empty)
            {
                MessageBox.Show("Please Enter a Voltage Value", null, MessageBoxButton.OK, MessageBoxImage.Exclamation);
                share.EventLog(null, "[Show]\t", "MessageBox > Please Enter a Voltage Value");
                return;
            }

            share.EventLog(null, "[Click]\t", string.Format("Apply {0} ", VoltValueTB.Text));

            //string SelectChannel = CHSelectCB.SelectedIndex.ToString() + VddSelectCB.SelectedIndex.ToString();

            if (DelCommandSendEventHandler != null)
            {
                DelCommandSendEventHandler.Invoke(StaticDefine.COMMAND_VOLTAGE_SET, Convert.ToInt32(VoltValueTB.Text));
            }
        }
示例#3
0
        //private void TestItemListSetting()
        //{
        //    string TempStr1 = "1111";
        //    string TempStr2 = "22";
        //    string TempStr3 = "333";
        //    string TempStr4 = "4444";
        //
        //    TestLB1.Content = "TEST #1 : " + TempStr1;
        //    TestLB2.Content = "TEST #2 : " + TempStr2;
        //    TestLB3.Content = "TEST #3 : " + TempStr3;
        //    TestLB4.Content = "TEST #4 : " + TempStr4;
        //
        //    ItemDic.Add(Test1CB, TempStr1);
        //    ItemDic.Add(Test2CB, TempStr2);
        //    ItemDic.Add(Test3CB, TempStr3);
        //    ItemDic.Add(Test4CB, TempStr4);
        //}
        //
        //public bool SelectItemSetting(BoardInfo boardInfo)
        //{
        //    //string SelectItem = string.Empty;  // ?? 협의 필요
        //
        //    boardInfo.TestItemList.Clear();
        //
        //    int itemcount = 0;
        //    bool ItemSelectCheck = false;
        //
        //    foreach (KeyValuePair<CheckBox, string> CB in ItemDic)
        //    {
        //        if (CB.Key.IsChecked.Value)
        //        {
        //            itemcount++;
        //
        //            TestItem TempTest = new TestItem();
        //            TempTest.ItemNumber = itemcount;
        //            TempTest.ItemName = CB.Value;
        //            TempTest.ItemState = "WAIT";
        //
        //            boardInfo.TestItemList.Add(TempTest);
        //            boardInfo.TestID = TestId;
        //
        //            //SelectItem += itemcount.ToString() + " ";
        //
        //            ItemSelectCheck = true;
        //        }
        //    }
        //
        //    //if (SelectItem == string.Empty)
        //    //    return false;
        //
        //    return ItemSelectCheck;
        //}

        private void TestRunBtn_Click(object sender, RoutedEventArgs e)
        {
            //string SelectItem = string.Empty;  // ?? 협의 필요

            //string TestId = TestIDTB.Text;

            // Test Setting
            //if (TestId == string.Empty)
            //{
            //    MessageBox.Show("Please Enter the Test ID", null, MessageBoxButton.OK, MessageBoxImage.Exclamation);
            //    share.EventLog(null, "[Show]\t", "MessageBox > Please Enter the Test ID");
            //    return;
            //}

            //foreach (KeyValuePair<int, BoardInfo> TempBD in share.BoardInfoDic)
            //{
            //    //// Pass by Non-Select Slot
            //    //if (!TempBD.Value.IsSelected)
            //    //    continue;
            //    //
            //    //// Pass by Disconnect Slot
            //    //if (!TempBD.Value.PowerState)
            //    //    continue;
            //
            //    // Pass by Testing Slot
            //    if (StaticDefine.TEST_STATE_TESTSTATE_START < TempBD.Value.State && TempBD.Value.State < StaticDefine.TEST_STATE_TESTSTATE_END)
            //        continue;
            //
            //    TempBD.Value.TestItemList.Clear();
            //
            //    int itemcount = 0;
            //
            //    foreach (KeyValuePair<CheckBox, string> CB in ItemDic)
            //    {
            //        if (CB.Key.IsChecked.Value)
            //        {
            //            itemcount++;
            //
            //            TestItem TempTest = new TestItem();
            //            TempTest.ItemNumber = itemcount;
            //            TempTest.ItemName = CB.Value;
            //            TempTest.ItemState = "WAIT";
            //
            //            TempBD.Value.TestItemList.Add(TempTest);
            //            TempBD.Value.TestID = TestId;
            //
            //            SelectItem += itemcount.ToString() + " ";
            //        }
            //    }
            //
            //    if (SelectItem == string.Empty)
            //    {
            //        MessageBox.Show("Please Select the Test Item", null, MessageBoxButton.OK, MessageBoxImage.Exclamation);
            //        share.EventLog(null, "[Show]\t", "MessageBox > Please Select the Test Item");
            //        return;  // continue???
            //    }
            //}

            ///////////////////////////////////////////////////////////////////////////////////////

            share.EventLog(null, "[Click]\t", "Test Run");

            if (DelCommandSendEventHandler != null)
            {
                DelCommandSendEventHandler.Invoke(StaticDefine.COMMAND_TEST_RUN, StaticDefine.BOARD_STATUS_RUN);
            }
        }
示例#4
0
        private void SocketProceeding()
        {
            LockObject = new object();

            while (!share.shutdown)
            {
                //lock (LockObject)
                {
                    try
                    {
                        // Check Network
                        bool NetConnected = TargetPingCheck();

                        // If Network is not connected, remove socket
                        if (!NetConnected)
                        {
                            RemoveSocket(ClientNum);
                            continue;
                        }

                        // If Socket is not exist, make socket
                        if (ClientSocket == null)
                        {
                            CreateSocket();
                        }


                        if (ClientSocket != null)
                        {
                            SocketSendRecv(new DataPacket(StaticDefine.MSG_CATEGORY_TEST, StaticDefine.MSG_ACTION_GET, StaticDefine.MSG_CONTENT_STATUS, StaticDefine.MSG_OPTION_NULL));

                            //if (share.BoardInfoDic[ClientNum].IsTesting)
                            if ((share.BoardInfoDic[ClientNum].TestState > StaticDefine.TEST_STATE_TESTSTATE_START) && (share.BoardInfoDic[ClientNum].TestState < StaticDefine.TEST_STATE_TESTSTATE_END))
                            {
                                lock (LockObject)
                                {
                                    SocketSendRecv(new DataPacket(StaticDefine.MSG_CATEGORY_TEST, StaticDefine.MSG_ACTION_GET, StaticDefine.MSG_CONTENT_ERROR_COUNT, StaticDefine.MSG_OPTION_NULL));

                                    System.Threading.Thread.Sleep(300);

                                    //if (share.BoardInfoDic[ClientNum].TestOccurErrorCount != 0)
                                    for (int cnt = 0; cnt < share.BoardInfoDic[ClientNum].TestOccurErrorCount; cnt++)
                                    {
                                        SocketSendRecv(new DataPacket(StaticDefine.MSG_CATEGORY_TEST, StaticDefine.MSG_ACTION_GET, StaticDefine.MSG_CONTENT_ERROR_DATA, share.BoardInfoDic[ClientNum].ErrorList.Count));
                                        System.Threading.Thread.Sleep(20);
                                    }

                                    SocketSendRecv(new DataPacket(StaticDefine.MSG_CATEGORY_TEST, StaticDefine.MSG_ACTION_GET, StaticDefine.MSG_CONTENT_PROGRESS, StaticDefine.MSG_OPTION_NULL));

                                    //System.Threading.Thread.Sleep(20);
                                    //SocketSendRecv(new DataPacket(StaticDefine.MSG_CATEGORY_TEST, StaticDefine.MSG_ACTION_GET, StaticDefine.MSG_CONTENT_STATUS, StaticDefine.MSG_OPTION_NULL));
                                }
                            }

                            System.Threading.Thread.Sleep(500);
                        }
                    }
                    catch (SocketException se)
                    {
                        share.EventLog(ClientNum, "[ERROR]\t", string.Format("{0} SocketException : {1}", MethodBase.GetCurrentMethod().Name, se.ToString()), true);
                        //RemoveSocket(ClientNum);
                    }
                    catch (InvalidOperationException opex)
                    {
                        share.EventLog(ClientNum, "[ERROR]\t", string.Format("{0} InvalidOperationException : {1}", MethodBase.GetCurrentMethod().Name, opex.ToString()), true);
                        //{"연결되지 않은 소켓에서 작업할 수 없습니다."}
                    }
                    catch (IOException ioex)
                    {
                        share.EventLog(ClientNum, "[ERROR]\t", string.Format("{0} IOException : {1}", MethodBase.GetCurrentMethod().Name, ioex.ToString()), true);
                    }
                    catch (Exception ex)
                    {
                        share.EventLog(ClientNum, "[ERROR]\t", string.Format("{0} Exception : {1}", MethodBase.GetCurrentMethod().Name, ex.ToString()), true);

                        //if (!ExcepMsg.Contains("응답이 없어 연결하지 못했거나"))
                        //if(!ClientSocket.Connected)
                        //    RemoveSocket(ClientNum);

                        // if Receive null ??
                    }

                    System.Threading.Thread.Sleep(1000);
                }
            }
        }
示例#5
0
        public bool SerialSendRecv(byte[] SendByteData, out byte[] ReadByteData, bool ReadCheck)
        {
            ReadByteData = new byte[64];

            object LockObject = new object();

            if (SerialHandle.IsOpen)
            {
                //lock (LockObject)
                {
                    try
                    {
                        //Before
                        //Base.Sleep(500);
                        //After
                        //System.Threading.Thread.Sleep(500);

                        //Before
                        //byte[] values = new byte[1];
                        //
                        //for (int i = 0; i < SendByteData.Length; i++)
                        //{
                        //    values[0] = SendByteData[i];
                        //    SerialHandle.Write(values, 0, 1);
                        //    System.Threading.Thread.Sleep(5);
                        //}

                        //After
                        //foreach (byte values in SendByteData)
                        //{
                        //    byte[] _values = new byte[] { values };
                        //    SerialHandle.Write(_values, 0, 1);
                        //    System.Threading.Thread.Sleep(5);
                        //}

                        SerialHandle.Write(SendByteData, 0, SendByteData.Count());
                        System.Threading.Thread.Sleep(100);

                        //Before
                        //Base.Sleep(100);
                        //After
                        //System.Threading.Thread.Sleep(10);
                        if (ReadCheck)
                        {
                            SerialHandle.Read(ReadByteData, 0, ReadByteData.Count());
                        }
                    }
                    catch (Exception ex)
                    {
                        share.EventLog(null, string.Empty, string.Format("\t{0} (0) > {1}", MethodBase.GetCurrentMethod().Name, ex.Message), false);

                        return(false);
                    }
                }
            }
            else
            {
                share.EventLog(null, "[ERROR]", string.Format("Serial Port is Not Open : {0}", SerialHandle.PortName));

                return(false);
            }

            return(true);
        }
示例#6
0
        private void InitSocket()
        {
            //server = new TcpListener(new IPEndPoint(IPAddress.Any, _serverPort));
            ////client = default(TcpClient);
            //server.Start();

            while (!shutdown)
            {
                try
                {
                    var Clients = server.AcceptTcpClientAsync();
                    Clients.Wait(cts.Token);
                    var AcceptClient = Clients.Result;

                    h_client = new HandleClient(AcceptClient);
                    //client = server.AcceptTcpClient();

                    if (_serverPort == 1010)
                    {
                        SocketName = "Common Socket";
                    }
                    else if (_serverPort == 1011)
                    {
                        SocketName = "Voltage Read Socket";
                    }

                    if (!ClientList.TryAdd(h_client, h_client))
                    {
                        share.EventLog(h_client.ClientNumber, "[Connect Fail]", SocketName);

                        throw new InvalidOperationException("Tried to add connection twice");
                    }
                    else
                    {
                        share.EventLog(h_client.ClientNumber, "[Connected]", SocketName);

                        if (DelClientConnectCheckHandler != null)
                        {
                            DelClientConnectCheckHandler.Invoke(_serverPort, h_client.ClientNumber, true);
                        }
                    }

                    //h_client = new HandleClient(client);
                    //h_client.OnReceived += new HandleClient.MessageDisplayHandler(DataReceived);    //  1 Client / 1 Thread
                    //h_client.OnDisconnected += new HandleClient.DisconnectedHandler(RemoveClient);
                    //h_client.StartHandle();
                }
                catch (SocketException se)
                {
                    //share.EventLog(string.Format("{0} (0) > {1}", MethodBase.GetCurrentMethod().Name, se.Message), false);
                    share.EventLog(null, string.Empty, string.Format("\t{0} (0) > {1}", MethodBase.GetCurrentMethod().Name, se.Message), false);

                    RemoveClient(h_client);
                }
                catch (Exception ex)
                {
                    //share.EventLog(string.Format("{0} (1) > {1}", MethodBase.GetCurrentMethod().Name, ex.Message), false);
                    share.EventLog(null, string.Empty, string.Format("\t{0} (1) > {1}", MethodBase.GetCurrentMethod().Name, ex.Message), false);

                    RemoveClient(h_client);
                }
            }
        }