/// <summary>
 /// method to start listening on a given directory
 /// </summary>
 /// <param name="dirPath">path to given directory</param>
 public bool StartHandleDirectory(string dirPath)
 {
     this.MyPath = dirPath;
     if (!System.IO.Directory.Exists(dirPath))
     {
         this.MyLogging.Log("Directory does not exist: " + dirPath, MessageTypeEnum.FAIL);
         UpdateLog("Directory does not exist: " + dirPath, MessageTypeEnum.FAIL);
         LogChanged?.Invoke(this, new LogChangedEventArgs("Directory does not exist " + dirPath, MessageTypeEnum.FAIL));
         return(false);
     }
     //set the watchers and filter appropriate types so not every change event invokes the watcher
     MyDirectoryWWatcher[0] = new FileSystemWatcher(dirPath, "*.jpg");
     MyDirectoryWWatcher[1] = new FileSystemWatcher(dirPath, "*.gif");
     MyDirectoryWWatcher[2] = new FileSystemWatcher(dirPath, "*.bmp");
     MyDirectoryWWatcher[3] = new FileSystemWatcher(dirPath, "*.png");
     //set event
     foreach (FileSystemWatcher watcher in MyDirectoryWWatcher)
     {
         watcher.Created += new FileSystemEventHandler(OnCreated);
         //watcher.Changed += new FileSystemEventHandler(OnCreated);
         watcher.EnableRaisingEvents = true;
     }
     this.MyLogging.Log("Watching directory: " + dirPath, MessageTypeEnum.INFO);
     UpdateLog("Watching directory: " + dirPath, MessageTypeEnum.INFO);
     LogChanged?.Invoke(this, new LogChangedEventArgs("Watching directory " + dirPath, MessageTypeEnum.INFO));
     return(true);
 }
        /// <summary>
        /// the event to occur on new object creation
        /// </summary>
        /// <param name="source">the file system watcher</param>
        /// <param name="e">path of new photo</param>
        private void OnCreated(object source, FileSystemEventArgs e)
        {
            //set args for command
            string[] Args = new string[1];
            Args[0] = e.FullPath;
            bool          Result      = true;
            Task <string> NewFileTask = new Task <string>(() => {
                string message = this.MyController.ExecuteCommand((int)CommandEnum.NewFileCommand, Args, out Result);
                return(message);
            });

            NewFileTask.Start();
            NewFileTask.Wait();
            //check if successful and write to log
            if (!Result)
            {
                this.MyLogging.Log(NewFileTask.Result, MessageTypeEnum.FAIL);
                UpdateLog(NewFileTask.Result, MessageTypeEnum.FAIL);
                LogChanged?.Invoke(this, new LogChangedEventArgs("copy failed " + e.FullPath, MessageTypeEnum.FAIL));
                return;
            }
            this.MyLogging.Log(NewFileTask.Result, MessageTypeEnum.INFO);
            UpdateLog(NewFileTask.Result, MessageTypeEnum.INFO);
            LogChanged?.Invoke(this, new LogChangedEventArgs("copy succeeded " + e.FullPath, MessageTypeEnum.INFO));
        }
Beispiel #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Repository"/> class.
        /// </summary>
        /// <param name="localPath"></param>
        /// <param name="container"></param>
        public Repository(NPath localPath, ICacheContainer container)
        {
            Guard.ArgumentNotNull(localPath, nameof(localPath));

            LocalPath = localPath;

            cacheUpdateEvents = new Dictionary <CacheType, Action <CacheUpdateEvent> >
            {
                { CacheType.Branches, cacheUpdateEvent => {
                      LocalBranchListChanged?.Invoke(cacheUpdateEvent);
                      RemoteBranchListChanged?.Invoke(cacheUpdateEvent);
                      LocalAndRemoteBranchListChanged?.Invoke(cacheUpdateEvent);
                  } },
                { CacheType.GitAheadBehind, c => TrackingStatusChanged?.Invoke(c) },
                { CacheType.GitLocks, c => LocksChanged?.Invoke(c) },
                { CacheType.GitLog, c => LogChanged?.Invoke(c) },
                { CacheType.GitStatus, c => StatusEntriesChanged?.Invoke(c) },
                { CacheType.GitUser, cacheUpdateEvent => { } },
                { CacheType.RepositoryInfo, cacheUpdateEvent => {
                      CurrentBranchChanged?.Invoke(cacheUpdateEvent);
                      CurrentRemoteChanged?.Invoke(cacheUpdateEvent);
                      CurrentBranchAndRemoteChanged?.Invoke(cacheUpdateEvent);
                  } },
            };

            cacheContainer = container;
            cacheContainer.CacheInvalidated += CacheHasBeenInvalidated;
            cacheContainer.CacheUpdated     += (cacheType, offset) =>
            {
                cacheUpdateEvents[cacheType](new CacheUpdateEvent(cacheType, offset));
            };
        }
Beispiel #4
0
 private void RaiseLogChanged(string msg)
 {
     if (LogChanged != null)
     {
         LogChanged.Invoke(this, new EventTextLogArgs(_serviceName, _level, msg));
     }
 }
Beispiel #5
0
        public async Task <float[]> InferMainBBox(object image)
        {
            var res = await _mnssd.PlayMNSSD(image, Labels.Count, OUT_BB_COUNT);

            var startSelectBBTime = DateTimeOffset.UtcNow;

            _mainBB = SelectMainBB(res.Item1, res.Item2);
            if (_mainBB[0] < -99)
            {
                _mainBB = null;
            }

            var selectBBTime = DateTimeOffset.UtcNow - startSelectBBTime;

            var preTime   = _mnssd.PreprocessTime.TotalMilliseconds.ToString("F0");
            var inferTime = _mnssd.InferenceTime.TotalMilliseconds.ToString("F0");
            var postTime  = _mnssd.PostprocessTime.TotalMilliseconds.ToString("F0");
            var logParams = new LogParams
            {
                ShowIdx = 2,
                Color   = Color.LimeGreen,
                Text    = $"MNSSD: {preTime}ms, {inferTime}ms, {postTime}ms{Environment.NewLine}" +
                          $" - Select mainBB: {selectBBTime.TotalMilliseconds:F0}ms"
            };

            LogChanged?.Invoke(this, logParams);

            return(_mainBB);
        }
Beispiel #6
0
 private void InternalOnLogChanged(object sender, LogChangedEventArgs logChangedEventArgs)
 {
     lock (_lock)
     {
         _cache.Clear();
     }
     LogChanged?.Invoke(this, logChangedEventArgs);
 }
 internal static void Append(string Msg)
 {
     if (Msg.EndsWith("\n") == false)
     {
         Msg += "\n";
     }
     LogStr += "[" + DateTime.Now.ToString("HH:mm:ss.fff") + "] " + Msg;
     LogChanged?.Invoke(null, null);
 }
Beispiel #8
0
 private void OnLogChanged(LogChangedEventArgs logChangedEventArgs)
 {
     lock (_lock)
     {
         _lastCheckedIndex = 0;
         _mapping.Clear();
         Filter();
     }
     LogChanged?.Invoke(this, logChangedEventArgs);
 }
Beispiel #9
0
        public void Log(string command)
        {
            while (entries.Count > 10)
            {
                entries.RemoveAt(0);
            }

            entries.Add(command);

            LogChanged?.Invoke(this, new EventArgs());
        }
Beispiel #10
0
        public void AppendLogLine(string line)
        {
            if (scrollback.Count >= scrollbackSize)
            {
                scrollback.Dequeue();
            }
            scrollback.Enqueue(line);

            log = scrollback.ToArray();
            LogChanged?.Invoke(log);
        }
Beispiel #11
0
        public void ResumeEntities()
        {
            LogChanged?.Invoke(this, new LogParams()
            {
                ShowIdx = 0,
                Color   = Color.Violet,
                Text    = $"App version: {Helpers.AppVersion()}"
            });

            // --------------------------- //

            if (!_isStopped)
            {
                return;
            }

            _isStopped       = false;
            _vdTimer.Enabled = true;
        }
Beispiel #12
0
 public void Log(string message)
 {
     LogChanged?.Invoke(this, new LogChangedEventArgs(message));
 }
Beispiel #13
0
 private void Update(string msg)
 {
     LogMessage = msg;
     LogChanged?.Invoke(this, EventArgs.Empty);
 }
Beispiel #14
0
 private void OnLogChanged()
 {
     LogChanged?.Invoke(this, new EventArgs());
 }
Beispiel #15
0
 private void OnLogChanged(LogChangedEventArgs e)
 {
     LogChanged?.Invoke(this, e);
 }
Beispiel #16
0
 protected virtual void OnLogChanged(LogEventArgs e)
 {
     LogChanged?.Invoke(this, e);
 }
Beispiel #17
0
 public static void Clear()
 {
     LogList.Clear();
     _lastDisconnect = null;
     LogChanged?.Invoke(null, EventArgs.Empty);
 }
Beispiel #18
0
 private void HandleGitLogCacheUpdatedEvent(CacheUpdateEvent cacheUpdateEvent)
 {
     Logger.Trace("GitLogCache Updated {0}", cacheUpdateEvent.UpdatedTimeString);
     LogChanged?.Invoke(cacheUpdateEvent);
 }
        private void InvokeLogChanged(object state)
        {
            var message = (string)state;

            LogChanged?.Invoke(this, message);
        }
        public async Task FeedFrame(FrameEntry frame, RectangleF carBB, bool isFirst)
        {
            Rectangle bb = ScaleCarBBoxAddingMargins(frame, carBB);
            var croppedCar = _accessor.Helpers.CropImage(frame, bb);

            var orientNumber = _accessor.Helpers.DeviceOrientationAsNumber();
            croppedCar = _accessor.Helpers.RotateImage(croppedCar, orientNumber);

            LastCarImage = croppedCar;
            // _accessor.DumpService.SaveFrame(croppedCar);

            var carImage = _accessor.Helpers.ToNativeImage(croppedCar);

            await _accessor.CarModelClassifier.Classify(carImage);
            await _accessor.CarColorClassifier.Classify(carImage);

            if (carImage is IDisposable disposable)
            {
                disposable.Dispose();
            }

            if (isFirst)
            {
                //Array.Fill(_carModelProbSum, 0.0f);
                //Array.Fill(_carColorProbSum, 0.0f);
                for (int i = 0; i < _carModelProbSum.Length; i++)
                    _carModelProbSum[i] = 0;
                for (int i = 0; i < _carColorProbSum.Length; i++)
                    _carColorProbSum[i] = 0;
                _feedCount = 0;
            }

            _feedCount++;

            for (int idx = 0; idx < _accessor.CarModelClassifier.OutputSize(); idx++)
                _carModelProbSum[idx] += _accessor.CarModelClassifier.Probabilities[idx];

            for (int idx = 0; idx < _accessor.CarColorClassifier.OutputSize(); idx++)
                _carColorProbSum[idx] += _accessor.CarColorClassifier.Probabilities[idx];

            // ----------------------------------------- //
            // Throw events for the screen log

            var top3 = TopKFeatures(3);

            var colorPreTime = _accessor.CarColorClassifier.PreprocessTime.TotalMilliseconds.ToString("F0");
            var colorInferTime = _accessor.CarColorClassifier.InferenceTime.TotalMilliseconds.ToString("F0");
            var colorPostTime = _accessor.CarColorClassifier.PostprocessTime.TotalMilliseconds.ToString("F0");
            var logText = $"Color NN: {colorPreTime}ms, {colorInferTime}ms, {colorPostTime}ms{Environment.NewLine}" +
                          $" - {top3[0].ColorName} - {100 * top3[0].ColorProbability:F1}%{Environment.NewLine}" +
                          $" - {top3[1].ColorName} - {100 * top3[1].ColorProbability:F1}%{Environment.NewLine}" +
                          $" - {top3[2].ColorName} - {100 * top3[2].ColorProbability:F1}%{Environment.NewLine}";
            var mmPreTime = _accessor.CarModelClassifier.PreprocessTime.TotalMilliseconds.ToString("F0");
            var mmInferTime = _accessor.CarModelClassifier.InferenceTime.TotalMilliseconds.ToString("F0");
            var mmPostTime = _accessor.CarModelClassifier.PostprocessTime.TotalMilliseconds.ToString("F0");
            logText += $"M/m NN: {mmPreTime}ms, {mmInferTime}ms, {mmPostTime}ms{Environment.NewLine}" +
                       $" - {top3[0].ModelName} - {100 * top3[0].ModelProbability:F1}%{Environment.NewLine}" +
                       $" - {top3[1].ModelName} - {100 * top3[1].ModelProbability:F1}%{Environment.NewLine}" +
                       $" - {top3[2].ModelName} - {100 * top3[2].ModelProbability:F1}%{Environment.NewLine}";
            var logParams = new LogParams()
            {
                ShowIdx = 3,
                Color = Color.Cyan,
                Text = logText
            };
            LogChanged?.Invoke(this, logParams);

            // ----------------------------------------- //
        }
 internal void NotifyLogChanged(string containerId)
 {
     LogChanged?.Invoke(containerId);
 }