示例#1
0
        private void ThreadRefresh()
        {
            HiPerfTimer timer = new HiPerfTimer();

            System.Threading.Thread.Sleep(1000);

            while (!MainModule.formMain.bExit)
            {
                System.Threading.Thread.Sleep(10);
                if (!omronFinsAPI.bConnectOmronPLC)
                {
                    //MainModule.alarmManage.InsertAlarm(AlarmKeys.PLCOmron连接断开, "与PLC[" + plcData.Name + "]断开连接。");
                    //ReConnectToPlc();
                    //if (omronFinsAPI.bConnectOmronPLC)
                    //{
                    //    MainModule.alarmManage.RemoveAlarm(AlarmKeys.PLCOmron连接断开);
                    //}
                    continue;
                }

                try
                {
                    ThreadRefreshHandler();
                }
                catch
                {
                }
            }
            return;
        }
示例#2
0
        private static void UseLuceneSearch(IHostEnvironment env, IHangfireBackJob hangfire, LuceneIndexerOptions luceneIndexerOptions)
        {
            Task.Run(() =>
            {
                Console.WriteLine("正在导入自定义词库...");
                double time = HiPerfTimer.Execute(() =>
                {
                    var set       = ServiceProvider.GetRequiredService <DataContext>().Post.Select(p => $"{p.Title},{p.Label},{p.Keyword}").AsEnumerable().SelectMany(s => s.Split(new[] { ',', ' ', '+', '—' }, StringSplitOptions.RemoveEmptyEntries)).ToHashSet();
                    var lines     = File.ReadAllLines(Path.Combine(env.ContentRootPath, "App_Data", "CustomKeywords.txt")).Union(set);
                    var segmenter = new JiebaSegmenter();
                    foreach (var word in lines)
                    {
                        segmenter.AddWord(word);
                    }
                });
                Console.WriteLine($"导入自定义词库完成,耗时{time}s");
            });

            string lucenePath = Path.Combine(env.ContentRootPath, luceneIndexerOptions.Path);

            if (!Directory.Exists(lucenePath) || Directory.GetFiles(lucenePath).Length < 1)
            {
                Console.WriteLine("索引库不存在,开始自动创建Lucene索引库...");
                hangfire.CreateLuceneIndex();
                Console.WriteLine("索引库创建完成!");
            }
        }
示例#3
0
        /// <summary>
        ///
        /// </summary>

        #endregion

        #region Main function
        public NNTrainPatterns(NeuralNetwork neuronNet, MnistDatabase trainingSet, Preferences preferences, bool trainingDataReady,
                               ManualResetEvent eventStop,
                               ManualResetEvent eventStopped,
                               HandwrittenRecogniration.Mainform form, List <Mutex> mutexs)
        {
            m_currentPatternIndex = 0;
            _bDataReady           = trainingDataReady;
            _NN                = neuronNet;
            _MnistDataSet      = trainingSet;
            m_Preferences      = preferences;
            m_nImages          = (uint)_MnistDataSet.m_pImagePatterns.Count;
            _form              = form;
            m_EventStop        = eventStop;
            m_EventStopped     = eventStopped;
            m_Mutexs           = mutexs;
            m_cMisrecognitions = 0;
            _iNextPattern      = 0;
            m_bNeedHessian     = true;
            m_cBackprops       = 0;
            _dMSE              = 0;
            _nn                = 0;
            _dMSE200           = 0;
            m_HiPerfTime       = new HiPerfTimer();
            GetGaussianKernel(m_Preferences.m_dElasticSigma);
        }
示例#4
0
 public CommonSerialPort()
 {
     // this.TextBoxCurrentBarCode = TextBoxCurrentBarCode;
     timeM      = new HiPerfTimer();
     serialPort = new System.IO.Ports.SerialPort();
     bInitOK    = false;
 }
示例#5
0
        public void SimpleTest()
        {
            var timer = new HiPerfTimer();

            // Initial duration is set to zero
            Assert.AreEqual(0, timer.Duration);

            timer.Start();

            // If we did not stop the timer, Duration sould be zero
            Assert.AreEqual(0, timer.Duration);

            timer.Stop();

            // After stop, Duration is > 0
            Assert.Less(0, timer.Duration);

            var lastTime = timer.Duration;

            // Duration should be the same as before
            Assert.AreEqual(lastTime, timer.Duration);

            timer.Stop();

            // Now it should be updated
            Assert.Less(lastTime, timer.Duration);

            timer.Start();

            // Should equals to zero
            Assert.AreEqual(0, timer.Duration);
            Assert.AreEqual("0 seconds", timer.ToString());
        }
示例#6
0
        internal static void UseLuceneSearch(this IApplicationBuilder app, IHostEnvironment env, IHangfireBackJob hangfire, LuceneIndexerOptions luceneIndexerOptions)
        {
            Task.Run(() =>
            {
                Console.WriteLine("正在导入自定义词库...");
                double time = HiPerfTimer.Execute(() =>
                {
                    var posts     = app.ApplicationServices.GetRequiredService <DataContext>().Post;
                    var set       = posts.Select(p => p.Title).AsEnumerable().SelectMany(s => s.Split(',', ',', ' ', '+', '—', '(', ')', ':', '&', '(', ')', '-', '_', '[', ']')).Where(s => s.Length > 1).Union(posts.Select(p => $"{p.Label},{p.Keyword}").AsEnumerable().SelectMany(s => s.Split(','))).ToHashSet();
                    var lines     = File.ReadAllLines(Path.Combine(env.ContentRootPath, "App_Data", "CustomKeywords.txt")).Union(set);
                    var segmenter = new JiebaSegmenter();
                    foreach (var word in lines)
                    {
                        segmenter.AddWord(word);
                    }
                });
                Console.WriteLine($"导入自定义词库完成,耗时{time}s");
                Windows.ClearMemorySilent();
            });

            string lucenePath = Path.Combine(env.ContentRootPath, luceneIndexerOptions.Path);

            if (!Directory.Exists(lucenePath) || Directory.GetFiles(lucenePath).Length < 1)
            {
                Console.WriteLine("索引库不存在,开始自动创建Lucene索引库...");
                hangfire.CreateLuceneIndex();
                Console.WriteLine("索引库创建完成!");
            }
        }
示例#7
0
        static void Main()
        {
            HiPerfTimer timer = new HiPerfTimer();

            foreach (Type exercise in Assembly.GetEntryAssembly().GetTypes()
                     .Where(x => x.Name.StartsWith("Exercise3"))
                     .OrderByDescending(x => Int32.Parse(x.Name.Replace("Exercise", String.Empty))))
            {
                Console.WriteLine("===========================");
                Console.WriteLine(exercise.Name);
                Console.WriteLine("===========================");

                // Solve exercise
                timer.Start();
                var solution = exercise.InvokeMember("Solve", BindingFlags.InvokeMethod, null, null, null);
                timer.Stop();

                // Show solution
                Console.WriteLine("Solution: " + solution);
                Console.WriteLine("Duration: " + timer.DurationFormatted);
                Console.WriteLine();
                Console.ReadKey();
                Console.WriteLine();
            }
        }
示例#8
0
 public BaslerCamera(IVisionCameraInfo info) : base(info)
 {
     this.UserID = Info.UserID;
     Image       = new HImage();
     timer       = new HiPerfTimer();
     try
     {
         Image = new HImage();
         // 枚举相机列表,获取固定相机名称
         List <ICameraInfo> allCameraInfos = CameraFinder.Enumerate();
         foreach (ICameraInfo cameraInfo in allCameraInfos)
         {
             if (this.UserID == cameraInfo[CameraInfoKey.UserDefinedName])
             {
                 camera         = new Camera(cameraInfo);
                 Info.CameraIP  = cameraInfo[CameraInfoKey.DeviceIpAddress].ToString();
                 info.CameraMac = cameraInfo[CameraInfoKey.DeviceMacAddress].ToString();
             }
         }
         if (camera == null)
         {
             WriteErrorLog("It can not recognite the camera of  " + UserID);
         }
     }
     catch (Exception e)
     {
         WriteErrorLog(e.ToString());
     }
 }
示例#9
0
        private static void UseLuceneSearch(IHostEnvironment env, IHangfireBackJob hangfire, LuceneIndexerOptions luceneIndexerOptions)
        {
            Task.Run(() =>
            {
                Console.WriteLine("正在导入自定义词库...");
                double time = HiPerfTimer.Execute(() =>
                {
                    var lines     = File.ReadAllLines(Path.Combine(env.ContentRootPath, "App_Data", "CustomKeywords.txt"));
                    var segmenter = new JiebaSegmenter();
                    foreach (var word in lines)
                    {
                        segmenter.AddWord(word);
                    }
                });
                Console.WriteLine($"导入自定义词库完成,耗时{time}s");
            });

            string lucenePath = Path.Combine(env.ContentRootPath, luceneIndexerOptions.Path);

            if (!Directory.Exists(lucenePath) || Directory.GetFiles(lucenePath).Length < 1)
            {
                Console.WriteLine("索引库不存在,开始自动创建Lucene索引库...");
                hangfire.CreateLuceneIndex();
                Console.WriteLine("索引库创建完成!");
            }
        }
示例#10
0
        static void Main()
        {
            HiPerfTimer timer = new HiPerfTimer();

            foreach (Type day in Assembly.GetEntryAssembly().GetTypes()
                     .Where(x => x.IsInterface is false && typeof(IDay).IsAssignableFrom(x) && !x.Name.EndsWith("99") && x.Namespace.Contains("2021"))
                     .OrderByDescending(x => int.Parse(x.Name.Replace("Day", string.Empty))))
            {
                Console.WriteLine("=======================================");
                Console.WriteLine(day.Namespace + "." + day.Name);
                Console.WriteLine("=======================================");

                IDay puzzle = (IDay)Activator.CreateInstance(day);

                // Solve part 1
                string puzzleInput = "0";
                using (var webClient = new WebClient())
                {
                    webClient.Headers.Add(HttpRequestHeader.Cookie, "session=" + Environment.GetEnvironmentVariable("AoC-Session"));
                    var puzzleDay = day.Name.Replace("Day", string.Empty);
                    try
                    {
                        puzzleInput = webClient.DownloadString($"https://adventofcode.com/2021/day/{puzzleDay}/input");
                        puzzleInput = puzzleInput.Trim(' ', '\r', '\n');
                    }
                    catch
                    {
                        Console.WriteLine("Could not find puzzle input for " + day.Name);
                    }
                }

                Console.WriteLine("Example : " + puzzle.SolvePart1(puzzle.ExampleInput));
                timer.Start();
                long solutionPart1 = puzzle.SolvePart1(puzzleInput);
                timer.Stop();
                if (solutionPart1 > 0)
                {
                    TextCopy.ClipboardService.SetText(solutionPart1.ToString());
                }
                Console.WriteLine("Solution: " + solutionPart1);
                Console.WriteLine("Duration: " + timer.DurationFormatted);
                Console.WriteLine();

                Console.WriteLine("Example : " + puzzle.SolvePart2(puzzle.ExampleInput));
                timer.Start();
                long solutionPart2 = puzzle.SolvePart2(puzzleInput);
                timer.Stop();
                if (solutionPart2 > 0)
                {
                    TextCopy.ClipboardService.SetText(solutionPart2.ToString());
                }
                Console.WriteLine("Solution: " + solutionPart2);
                Console.WriteLine("Duration: " + timer.DurationFormatted);
                Console.WriteLine();

                Console.ReadKey();
                Console.WriteLine();
            }
        }
示例#11
0
        public static string CheckBoxListBtstsr(string propertyName, int columns, List <int> selectedValues)
        {
            HiPerfTimer a = new HiPerfTimer();
            HiPerfTimer b = new HiPerfTimer();


            int cultureId = Convert.ToInt32(System.Web.HttpContext.Current.Session["___APPCU"].ToString());

            a.Start();
            b.Start();
            List <PropertyItem> l = currentList(propertyName, cultureId, false);

            b.Stop();
            StringBuilder sb = new StringBuilder();

            sb.Append("<table style=\"text-align:left\"><tr>");
            for (int i = 0; i < l.Count; i++)
            {
                sb.Append("<td><input type=\"checkbox\" name=\"");
                sb.Append(propertyName);
                sb.Append("\" id=\"cbl");
                sb.Append(propertyName);
                sb.Append("_");
                sb.Append(i.ToString());
                sb.Append("\" value=\"");
                sb.Append(l[i].Value);
                sb.Append("\"");
                for (int j = 0; j < selectedValues.Count; j++)
                {
                    if (l[i].Value == selectedValues[j].ToString())
                    {
                        sb.Append(" checked=\"checked\" ");
                    }
                }
                sb.Append(" />&nbsp;<label class=\"input-sm\" for=\"cbl");
                sb.Append(propertyName);
                sb.Append("_");
                sb.Append(i.ToString());
                sb.Append("\">");
                sb.Append(l[i].Text);
                sb.Append("</label></td>");

                if (Math.IEEERemainder((i + 1), columns) == 0)
                {
                    sb.Append("</tr><tr>");
                }
            }
            sb.Append("</tr>");
            sb.Append("</table>");

            a.Stop();

            string a1 = (a.Duration * 1000000).ToString();

            string b1 = (b.Duration * 1000000).ToString();


            return(sb.ToString());
        }
示例#12
0
        //string strFilePath = "D:\\dropBox\\";
        //string strFileStart1 = "Start1.txt";
        //string strFileStart2 = "Start2.txt";
        //string strFileDone1 = "Done1.txt";
        //string strFileDone2 = "Done2.txt";
        //string strSn1 = "";
        //string strSn2 = "";

        public Datalogic_Scanner()
        {
            m_BarcodeQueue = new Queue <string>();
            // this.TextBoxCurrentBarCode = TextBoxCurrentBarCode;
            timeM      = new HiPerfTimer();
            serialPort = new System.IO.Ports.SerialPort();
            bInitOK    = false;
        }
示例#13
0
文件: Test.cs 项目: andromede76/RNC
 public Test(ReseauNeurone neuronet, MnistDatabase baseTest, FormPrincipal frm)
 {
     _RNN = neuronet;
     BaseApprentissage     = baseTest;
     nombre                = BaseApprentissage.imageCount;
     erreurReconnaissances = 0;
     _form        = frm;
     m_HiPerfTime = new HiPerfTimer();
 }
示例#14
0
        static void Main(string[] args)
        {
            //精度 100纳秒
            HiPerfTimer pt = new HiPerfTimer();

            Console.ReadLine();

            pt.Start();
            //System.Threading.Thread.Sleep(100);           // 需要计时的代码
            int count = 5;

            pt.Stop();
            Console.WriteLine("HiPerfTimer duration: {0} sec", pt.Duration);
            Console.WriteLine("HiPerfTimer duration: {0} ms", pt.Duration * 1000);
            Console.WriteLine("HiPerfTimer duration: {0} μs", pt.Duration * 1000000);
            Console.WriteLine("HiPerfTimer duration: {0} ns", pt.Duration * 1000000000);

            Console.ReadLine();

            //精度 100纳秒
            // 若要为线程指定处理器关联,请使用 ProcessThread.ProcessorAffinity 方法。
            System.Diagnostics.Stopwatch myStopwatch = new System.Diagnostics.Stopwatch();
            myStopwatch.Start();
            //System.Threading.Thread.Sleep(100);           // 需要计时的代码
            int count2 = 5;

            myStopwatch.Stop();

            var elspsedSeconds = myStopwatch.ElapsedTicks / (decimal)System.Diagnostics.Stopwatch.Frequency;

            Console.WriteLine("Stopwatch duration: {0} sec", elspsedSeconds);
            Console.WriteLine("Stopwatch duration: {0} ms", elspsedSeconds * 1000);
            Console.WriteLine("Stopwatch duration: {0} μs", elspsedSeconds * 1000000);
            Console.WriteLine("Stopwatch duration: {0} ns", elspsedSeconds * 1000000000);

            Console.WriteLine("Stopwatch duration: {0} ms", myStopwatch.ElapsedMilliseconds);


            Console.ReadLine();

            //精度 秒
            var begintime = DateTime.Now.Ticks;
            //System.Threading.Thread.Sleep(100);           // 需要计时的代码
            int count3   = 5;
            var stoptime = DateTime.Now.Ticks;

            var costTicks = stoptime - begintime;

            Console.WriteLine("DateTime.Now.Ticks duration: {0} sec", costTicks / (double)10000000);
            Console.WriteLine("DateTime.Now.Ticks duration: {0} ms", costTicks / (double)10000);
            Console.WriteLine("DateTime.Now.Ticks duration: {0} μs", costTicks / (double)10);
            Console.WriteLine("DateTime.Now.Ticks duration: {0} ns", costTicks * (double)100);

            Console.ReadLine();
        }
示例#15
0
        private Tuple <FrameInfo, Stream> PreloadFile(FrameInfo frameInfo)
        {
            // TODO: Consider using CopyStreamToStreamAsync from TPL extensions
            var timer = new HiPerfTimer();

            timer.Start();

            var    filename          = frameInfo.Filename;
            var    bufferSize        = frameInfo.BufferSize;
            var    cancellationToken = frameInfo.Token;
            Stream memoryStream      = null;
            var    buffer            = FMemoryPool.ManagedPool.GetMemory(bufferSize);

            try
            {
                cancellationToken.ThrowIfCancellationRequested();

                using (var fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read, bufferSize, FileOptions.SequentialScan))
                {
                    var length = fileStream.Length;
                    memoryStream = FMemoryPool.StreamPool.GetStream((int)length);
                    //memoryStream.Position = 0;

                    while (fileStream.Position < length)
                    {
                        cancellationToken.ThrowIfCancellationRequested();

                        int numBytesRead = fileStream.Read(buffer, 0, buffer.Length);
                        memoryStream.Write(buffer, 0, numBytesRead);
                    }

                    memoryStream.Position = 0;
                }
            }
            catch (OperationCanceledException)
            {
                // That's fine
            }
            catch (Exception e)
            {
                // Log the exception
                FLogger.Log(e);
            }
            finally
            {
                // Put the buffer back in the pool so other blocks can use it
                FMemoryPool.ManagedPool.PutMemory(buffer);
            }

            timer.Stop();
            frameInfo.DurationIO = timer.Duration;

            return(Tuple.Create(frameInfo, memoryStream));
        }
示例#16
0
        private void ScanThreadFunction()
        {
            HiPerfTimer timer = new HiPerfTimer();

            System.Threading.Thread.Sleep(1000);
            while (true)
            {
                System.Threading.Thread.Sleep(50);
                GetAllIOStatus();
            }
        }
        private void ScanThreadFunction()
        {
            HiPerfTimer timer = new HiPerfTimer();

            System.Threading.Thread.Sleep(1000);
            while (!MainModule.formMain.bExit)
            {
                System.Threading.Thread.Sleep(10);
                GetAllMotionStatus();
                GetAllIOStatus();
            }
        }
示例#18
0
        /// <summary>
        /// Функция передачи массива байт
        /// </summary>
        /// <param name="buf">Массив для пердачи.</param>
        /// <param name="index">Индекс в массиве, с которого начинаеися передача.</param>
        /// <param name="count">Количество байт для передачи.</param>
        /// <param name="result">Ссылка на строку, в которую записывается результат передачи.</param>
        /// <returns>Возвращает количество переданных байт.</returns>
        public int Write(byte[] buf, int index, int count, ref string result)
        {
            result = "";
            //
            Log("Старт записи...");
            if (!IsConnected)
            {
                Log("\tОшибка, порт закрыт...");
                result = m_spParams.Name + " закрыт.";
                return(0);
            }
            //
            HiPerfTimer tmr  = new HiPerfTimer();
            double      time = 0;
            bool        err  = false;

            try
            {
                lock (m_syncObj)
                {
                    tmr.Start();
                    m_serialPort.Write(buf, index, count);
                    m_serialPort.BaseStream.Flush();
                    tmr.Stop();
                    time = tmr.Duration * 1000;
                    if (WriteTimeout != System.IO.Ports.SerialPort.InfiniteTimeout)
                    {
                        if ((time + 10) > WriteTimeout)
                        {
                            err = true;
                            throw new TimeoutException("Ошибка: Истекло время передачи ( " + WriteTimeout.ToString() + " мс. )");
                        }
                    }
                    result    = count.ToString() + " bytes written.";
                    m_IsError = false;
                    Log("\tЗаписано " + count.ToString() + " Байт.");
                    Log(buf, index, count);
                }
                //
                return(count);
            }
            catch (Exception ex)
            {
                result = ex.Message;
                if (!err)
                {
                    m_IsError = true;
                }
                //
                Log(ex.Message);
                return(0);
            }
        }
示例#19
0
        private void ThreadRefreshStaHandler()
        {
            HiPerfTimer timer = new HiPerfTimer();

            System.Threading.Thread.Sleep(1000);

            int iStep = 0;

            while (true)
            {
                System.Threading.Thread.Sleep(1);
                switch (iStep)
                {
                case 0:
                {
                    timer.Start();
                    iStep = 10;
                }
                break;

                case 10:
                {
                    if (timer.TimeUp(1))
                    {
                        timer.Start();
                        for (int i = 0; i < 128; i++)
                        {
                            _bArrayInputSta[i] = true;
                        }
                        iStep = 20;
                    }
                }
                break;

                case 20:
                {
                    if (timer.TimeUp(1))
                    {
                        for (int i = 0; i < 128; i++)
                        {
                            _bArrayInputSta[i] = false;
                        }
                        iStep = 0;
                    }
                }
                break;

                default:
                    break;
                }
            }
        }
示例#20
0
文件: Test.cs 项目: andromede76/RNC
        public Test(ReseauNeurone neuronet, MnistDatabase baseTest, FormPrincipal frm, int entree, int sortie, int taille)
        {
            _RNN = neuronet;
            BaseApprentissage     = baseTest;
            nombre                = BaseApprentissage.imageCount;
            erreurReconnaissances = 0;
            _form        = frm;
            m_HiPerfTime = new HiPerfTimer();

            this.Entree = entree;
            this.Sortie = sortie;
            this.Taille = taille;
        }
示例#21
0
 public BaslerCamera()
 {
     try
     {
         Image       = new HImage();
         camera      = new Camera();
         timer       = new HiPerfTimer();
         this.UserID = camera.CameraInfo[CameraInfoKey.UserDefinedName];
     }
     catch (Exception e)
     {
         WriteErrorLog(e.ToString());
     }
 }
示例#22
0
        private void ScanThreadFunction()
        {
            HiPerfTimer timer = new HiPerfTimer();

            System.Threading.Thread.Sleep(1000);
            while (true)
            {
                System.Threading.Thread.Sleep(10);
                //if (Global.bClosing)
                //    break;
                GetAllMotionStatus();
                GetAllIOStatus();
            }
        }
示例#23
0
        private Frame PreloadFrame(Tuple <FrameInfo, Stream> tuple)
        {
            var timer = new HiPerfTimer();

            timer.Start();

            var frameInfo         = tuple.Item1;
            var stream            = tuple.Item2;
            var cancellationToken = frameInfo.Token;

            var frame = new Frame(
                frameInfo,
                CreateTexture,
                UpdateTexture,
                DestroyTexture);

            var cleanupStream = false;

            try
            {
                cancellationToken.ThrowIfCancellationRequested();
                frameInfo.Decoder = FrameDecoder.Create(frameInfo.Filename, CreateTextureForDecoder, FMemoryPool, stream);
            }
            catch (OperationCanceledException)
            {
                // That's fine, just make sure to cleanup
                cleanupStream = true;
            }
            catch (Exception e)
            {
                // Log the exception
                FLogger.Log(e);
                // And don't forget to cleanup
                cleanupStream = true;
            }
            finally
            {
                // We're done with this frame, put used memory stream back in the pool
                if (stream != null && cleanupStream)
                {
                    FMemoryPool.StreamPool.PutStream(stream);
                }
            }

            timer.Stop();
            frameInfo.DurationTexture = timer.Duration;

            return(frame);
        }
示例#24
0
        private ToolResult ApplyMetrology(HMetrologyModel hMetrology, int index, string measureName)
        {
            HiPerfTimer timer = new HiPerfTimer();

            timer.Start();
            try
            {
                hMetrology.ApplyMetrologyModel(Image);
                double   circleCenterRow, circleCenterCol, radius;
                HTuple   circleResult = hMetrology.GetMetrologyObjectResult(new HTuple(index), new HTuple("all"), new HTuple("result_type"), new HTuple("all_param"));
                HXLDCont circleXLD    = hMetrology.GetMetrologyObjectResultContour(new HTuple("all"), new HTuple("all"), new HTuple(1.5));
                HXLDCont modelXLD     = hMetrology.GetMetrologyObjectMeasures(index, "all", out HTuple Row, out HTuple Col);

                if (circleResult.Length < 3)
                {
                    return(new ToolResult()
                    {
                        ResultName = measureName, Errormessage = "圆形测量失败", GetResultTime = DateTime.Now, IsSuccess = false
                    });
                }
                circleCenterRow = circleResult[0].D;
                circleCenterCol = circleResult[1].D;
                radius          = circleResult[2].D;
                if (info.IsShowResult)
                {
                    Window.SetColor("blue");
                    circleXLD.DispXld(Window.Window);
                }
                if (info.IsShowFindRegion)
                {
                    Window.SetColor("green");
                    Window.DisplayCircle(info.ToolName, info.CircleRow, info.CircleCol, info.CircleRadius, true);
                }
                hMetrology.ClearMetrologyObject(new HTuple(index));
                return(new ToolResult()
                {
                    ResultName = measureName, ImageX = circleCenterCol, ImageY = circleCenterRow, ImageRadius = radius, GetResultTime = DateTime.Now, ElapsedTime = timer.Duration, IsSuccess = true
                });
            }
            catch (Exception e)
            {
                WriteErrorLog("VisionTool", e.ToString());
                return(new ToolResult()
                {
                    ResultName = measureName, Errormessage = e.ToString(), GetResultTime = DateTime.Now, IsSuccess = false
                });
            }
        }
示例#25
0
        public void TestParsing()
        {
            HiPerfTimer handRolledTimer = new HiPerfTimer();

            handRolledTimer.Start();

            for (int i = 0; i < EVALUATION_COUNT; i++)
            {
                OPathParser.Parse(EXPRESSION);
            }

            handRolledTimer.Stop();

            Console.WriteLine("Hand-rolled parsing did {0} in {1:0.000} millis",
                              EVALUATION_COUNT, (handRolledTimer.Duration * 1000));
        }
        protected PointD m_TrackingVPos; // virtual position

        #endregion Fields

        #region Constructors

        public VirtualMousePosition(System.Drawing.Point startPosition)
        {
            m_StartPos = startPosition;

            // real position
            m_LastPhysicalPos = startPosition;
            m_CurPhysicalPos = startPosition;

            // virtual position
            m_TrackingVPos = new PointD( startPosition.X, startPosition.Y );
            m_LastVPos = new PointD(startPosition.X, startPosition.Y);

            m_LastTime = Environment.TickCount;
            m_Timer = new HiPerfTimer();
            m_Timer.Start();
        }
示例#27
0
        public Apprentissage(ReseauNeurone neuronet, MnistDatabase baseApprentissage, int nombreSorties, FormPrincipal frm, Boolean distorsion)
        {
            _RNN = neuronet;
            BaseApprentissage     = baseApprentissage;
            nombre                = baseApprentissage.imageCount;
            NombreSorties         = nombreSorties;
            erreurReconnaissances = 0;
            bonneReconnaissances  = 0;
            nombreBackPropagation = 0;
            _iEpochsCompleted     = 0;
            _form        = frm;
            m_HiPerfTime = new HiPerfTimer();
            archive      = new Archive();

            this.Distorsion = distorsion;
        }
示例#28
0
        public Apprentissage(ReseauNeurone neuronet, double[][] trainMatrix, int nombreSorties, FormPrincipal frm, Boolean distorsion)
        {
            _RNN        = neuronet;
            TrainMatrix = trainMatrix;
            SizePattern = Convert.ToInt32(Math.Sqrt(TrainMatrix[0].Length));
            // nombre = baseApprentissage.imageCount;
            NombreSorties         = nombreSorties;
            erreurReconnaissances = 0;
            bonneReconnaissances  = 0;
            nombreBackPropagation = 0;
            _iEpochsCompleted     = 0;
            _form        = frm;
            m_HiPerfTime = new HiPerfTimer();
            archive      = new Archive();

            this.Distorsion = distorsion;
        }
示例#29
0
 public void WhileTrue(Action callable, long timeoutMs)
 {
     _task = Task.Factory.StartNew(() =>
     {
         var hiPerfTimer = new HiPerfTimer();
         while (!this._cts.IsCancellationRequested)
         {
             hiPerfTimer.Start();
             callable();
             hiPerfTimer.Stop();
             double remain = timeoutMs - hiPerfTimer.DurationDouble;
             if (remain > 0)
             {
                 Thread.Sleep((int)(remain));
             }
         }
     }, TaskCreationOptions.LongRunning);
 }
        public void Start()
        {
            var timer = new HiPerfTimer();

            _mapper.Initialize();
            _mapper.Map();

            timer.Start();

            for (int i = 0; i < 1000000; i++)
            {
                _mapper.Map();
            }

            timer.Stop();

            Console.WriteLine("{0}: - {1} - Mapping time: \t{2}s", _mapper.Name, _mode, timer.Duration);
        }
示例#31
0
        public static bool RetryUntilTrueWithTimeout(Func <bool> callable, double timeoutMs)
        {
            var    hiPerfTimer = new HiPerfTimer();
            double remaining;

            do
            {
                hiPerfTimer.Start();
                Thread.Sleep(1000);
                if (callable())
                {
                    return(true);
                }
                hiPerfTimer.Stop();
                remaining = timeoutMs - hiPerfTimer.DurationDouble;
            } while (remaining > 0);
            return(false);
        }
示例#32
0
        public void TestOPathPerformance()
        {
            HiPerfTimer rawTimer = new HiPerfTimer();

            rawTimer.Start();

            for (int i = 0; i < EVALUATION_COUNT; i++)
            {
                OPathExpression opathExpression = OPathExpression.Compile(EXPRESSION);

                OPathDocument opathDocument = new OPathDocument();
                opathDocument.Add("listDictionary", m_ListDictionary);

                OPathNavigator opathNavigator = OPathNavigator.CreateNavigator(opathDocument);

                opathNavigator.Evaluate(opathExpression);
            }

            rawTimer.Stop();

            Console.WriteLine("Uncompiled OPath performance {0} evaluations in {1:0.000} millis",
                              EVALUATION_COUNT, (rawTimer.Duration * 1000));

            HiPerfTimer cachedTimer = new HiPerfTimer();

            cachedTimer.Start();

            OPathExpression cachedOPathExpression = OPathExpression.Compile(EXPRESSION);

            for (int i = 0; i < EVALUATION_COUNT; i++)
            {
                OPathDocument opathDocument = new OPathDocument();
                opathDocument.Add("listDictionary", m_ListDictionary);

                OPathNavigator opathNavigator = OPathNavigator.CreateNavigator(opathDocument);

                opathNavigator.Evaluate(cachedOPathExpression);
            }

            cachedTimer.Stop();

            Console.WriteLine("Compiled OPath performance {0} evaluations in {1:0.000} millis",
                              EVALUATION_COUNT, (cachedTimer.Duration * 1000));
        }
示例#33
0
        public static ResultType RetryUntilTrueWithTimeout(Func <ResultType> callable, double timeoutMs)
        {
            var    hiPerfTimer = new HiPerfTimer();
            double remaining;

            do
            {
                hiPerfTimer.Start();
                Thread.Sleep(1000);
                var callableResultType = callable();
                if (callableResultType != ResultType.Continue)
                {
                    return(callableResultType);
                }
                hiPerfTimer.Stop();
                remaining = timeoutMs - hiPerfTimer.DurationDouble;
            } while (remaining > 0);
            return(ResultType.Timeout);
        }
示例#34
0
 public TaskInfo()
 {
     _timer = new HiPerfTimer();
 }
示例#35
0
 /// <summary>
 /// Field constructor
 /// </summary>
 /// <param name="taskName">the name of the task</param>
 public TaskInfo(string taskName)
 {
     Name = taskName;
     _timer = new HiPerfTimer();
 }
示例#36
0
 /// <summary>
 /// Field constructor
 /// </summary>
 /// <param name="taskName">the name of the task</param>
 /// <param name="timer">the timer</param>
 public TaskInfo(string taskName, HiPerfTimer timer)
 {
     Name = taskName;
     Timer = timer;
 }