Beispiel #1
0
    static void Main(string[] args)
    {
        var totalOfAllAges = 0D;
        var rows           = new ExcelRows();

        //calculate various statistics
        foreach (var item in rows.GetRow())
        {
            totalOfAllAges += item.Age;
        }
        Console.WriteLine("The total of all ages is {0}", totalOfAllAges);
    }
        private void NavigationModified2()
        {
            //if (useArdiuno)
            //{
            //    ardiunoAdapter.Send(trayCode);
            //}
            var    descMessage = "";
            string temp1;
            // var ImageLoadThread = new Thread(() => LoadImage(0));
            //ImageLoadThread.IsBackground = true;
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            TextBox.CheckForIllegalCrossThreadCalls    = false;
            PictureBox.CheckForIllegalCrossThreadCalls = false;
            bool iterationFlag = true;
            int  i             = 0;

            i = cycleDataPointer;
            //if (!ImageLoadThread.IsAlive)
            //{
            //  //  ImageLoadThread.Start();
            //}

            if (true)
            {
                trayCode    = ExcelRows[i].TryLed;
                temp1       = ExcelRows[i].CavityLed;
                ImagIndex   = Convert.ToInt32(ExcelRows[i].ImageId);
                imageFileId = ExcelRows[i].ImageFile;
                trayCode    = "000" + trayCode + "00" + temp1;
                Console.WriteLine("trayCode");
                Console.WriteLine(trayCode);
                if (useArdiuno)
                {
                    ardiunoAdapter.Send(trayCode);
                }
                string temp2 = ExcelRows[i].DesMessage;
                string temp3 = ExcelRows[i].ConnectorNo;
                Console.WriteLine("Description Message");
                descMessage             = "Take Wire From " + temp2 + " put it into connecter NO." + temp3;
                textBoxDescription.Text = descMessage;
                Console.WriteLine(descMessage);
                ImagIndex    = Convert.ToInt32(ExcelRows[i].ImageId);
                imageNewFile = ExcelRows[i].ImageFile;
                if (imageFileId != ExcelRows[i].ImageFile || imageFileId == null)
                {
                    imageFileId         = ExcelRows[i].ImageFile;
                    imageFileChangeFlag = true;
                }

                while (iterationFlag)
                {
                    // iterationFlag = false;
                    if (i >= ExcelRows.Count() - 1)
                    {
                        //For tac time
                        TimeSpan ts1 = stopWatch.Elapsed;
                        stopWatch.Stop();
                        ts1 = stopWatch.Elapsed;

                        textTackTime.Text = Convert.ToString(ts1.Seconds);
                        totalTacTime     += Convert.ToDouble(ts1.Seconds);
                        // textToTal.Text = Convert.ToString(totalTacTime);
                        TimeSpan totalTactimespan = TimeSpan.FromSeconds(totalTacTime);

                        textToTal.Text = string.Format("{1:D2}m:{2:D2}s",
                                                       totalTactimespan.Hours,
                                                       totalTactimespan.Minutes,
                                                       totalTactimespan.Seconds,
                                                       totalTactimespan.Milliseconds);
                        return;
                    }

                    switchCode = "SW" + ExcelRows[i].SwCode;
                    Console.WriteLine("Switch-Code From sheet--- " + switchCode);
                    sWInput = SwitchPress(Convert.ToInt32(ExcelRows[i].ImageId));
                    Console.WriteLine("Switch-Code From Ardiuno--- " + sWInput);

                    var temp11 = sWInput.Contains(switchCode);
                    if (temp11)
                    {
                        i++;
                        if (true)
                        {
                            trayCode = ExcelRows[i].TryLed;;
                            temp1    = ExcelRows[i].CavityLed;
                            trayCode = "000" + trayCode + "00" + temp1;
                            Console.WriteLine("trayCode");
                            Console.WriteLine(trayCode);
                            ImagIndex   = Convert.ToInt32(ExcelRows[i].ImageId);
                            imageFileId = ExcelRows[i].ImageFile;
                            if (useArdiuno)
                            {
                                ardiunoAdapter.Send(trayCode);
                            }
                            temp2 = ExcelRows[i].DesMessage;
                            temp3 = ExcelRows[i].ConnectorNo;
                            Console.WriteLine("Description Message");
                            descMessage = "Take Wire From " + temp2 + " put it into connecter NO." + temp3;
                            Console.WriteLine(descMessage);
                            textBoxDescription.Text = descMessage;
                            ImagIndex = Convert.ToInt32(ExcelRows[i].ImageId);

                            iterationFlag = true;
                        }
                    }
                }
            }

            TimeSpan ts = stopWatch.Elapsed;

            stopWatch.Stop();
            ts = stopWatch.Elapsed;
            string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
                                               ts.Hours, ts.Minutes, ts.Seconds,
                                               ts.Milliseconds / 10);

            textTackTime.Text = Convert.ToString(ts);
        }