Example #1
0
 public LogReceivedTreeNode(ILogFileItem logFile)
 {
     Text             = CultureService.Instance.GetString(CultureText.node_Received_Text) + ": ";
     Text            += logFile.Statistics.ReceivedMessageCount.ToString();
     SelectedImageKey = ImageKey = "arrow_down";
     logFile.Statistics.PropertyChanged += (o, e) =>
     {
         Text  = CultureService.Instance.GetString(CultureText.node_Received_Text) + ": ";
         Text += logFile.Statistics.ReceivedMessageCount.ToString();
     };
 }
 public LogTransmittedTreeNode(ILogFileItem file)
 {
     Text             = CultureService.Instance.GetString(CultureText.node_Transmitted_Text) + ": ";
     Text            += file.Statistics.TransmittedMessageCount.ToString();
     SelectedImageKey = ImageKey = "arrow_up";
     file.Statistics.PropertyChanged += (o, e) =>
     {
         if (e.PropertyName == "TransmittedMessageCount")
         {
             Text  = CultureService.Instance.GetString(CultureText.node_Transmitted_Text) + ": ";
             Text += file.Statistics.TransmittedMessageCount.ToString();
         }
     };
 }
        public LogMessagesTreeNode(ILogFileItem logFile)
        {
            Text             = CultureService.Instance.GetString(CultureText.node_MessagesStatistics_Text);
            Name             = "messsage1";
            SelectedImageKey = ImageKey = "mails16";

            var arbIds = logFile.Statistics.GetArbitationIds();


            for (int i = 0; i < arbIds.Count; i++)
            {
                Nodes.Add(new LogMessageNameTreeNode(logFile, arbIds[i],
                                                     new LogArbitrationIdTreeNode(arbIds[i])));
            }
        }
Example #4
0
        public void _0009_PropretyTest()
        {
            ILogFileCollection logfiles = new LogFileCollection();

            logfiles.ProgressChanged += (o, e) => { Console.WriteLine("Percent:" + e.ProgressPercentage + "%" + " Message:" + e.UserState); };
            logfiles.Load(LogLocation, ProjectName);

            var logFileName = DateTime.Now.ToString("yyMMdd HHmmss") + "_0006_PropretyTest_" + Guid.NewGuid().ToString();

            ILogFileItem log = null;

            if (!System.IO.File.Exists(LogLocation + logFileName + ".s3db"))
            {
                log = new LogFileItem(LogLocation, ProjectName, logFileName);
                Assert.IsTrue(System.IO.File.Exists(log.Path), "Nem hozta létre a log fájlt.");
                log.Messages.AddToStorageBegin();
                for (int i = 0; i < 2; i++)
                {
                    log.Messages.AddToStorage("Proba", DateTime.Now, MessageDirection.Transmitted, ArbitrationIdType.Standard, 0x0FF, false, new byte[] { 0x00, 0x01, 0x02, 0x03, 0x05 }, "nincs", "nincs");
                    log.Messages.AddToStorage("Proba", DateTime.Now, MessageDirection.Received, ArbitrationIdType.Standard, 0x0FF, false, new byte[] { 0x00, 0x01, 0x02, 0x03, 0x05 }, "nincs", "nincs");
                }
                log.Messages.AddToStorageEnd();
            }



            AutoResetEvent completeEvetn = new AutoResetEvent(false);

            log.Statistics.PropertyChanged += (o, e) =>
            {
                Assert.True(e.PropertyName == "ReceivedMessageCount" || e.PropertyName == "TransmittedMessageCount");
                completeEvetn.Set();
            };

            var logFile = (logfiles as LogFileCollection).FirstOrDefault(n => n.Name == logFileName);

            log.Load();

            Assert.False(completeEvetn.WaitOne(1000) == false, "Nem jött esemény.");

            Assert.AreEqual(2, log.Statistics.ReceivedMessageCount);
            Assert.AreEqual(2, log.Statistics.TransmittedMessageCount);

            foreach (var item in log.Messages)
            {
                Console.WriteLine(item.ToString());
            }
        }
Example #5
0
 public LogFileNameTreeNode(ILogFileCollection logs, ILogFileItem log, ILogDescriptionView description, TreeNode[] subNodes)
 {
     Text = log.Name;
     Nodes.AddRange(subNodes);
     Logs                      = logs;
     Log                       = log;
     SelectedImageKey          = ImageKey = @"database16";
     Name                      = log.Guid; /* Figyelem ez kell a az elem törléséhez. */
     log.PropertyChanged      += (s, e) => { Text = log.Name; };
     log.Info.PropertyChanged += (o, e) =>
     {
         if (e.PropertyName == "Description")
         {
             description.Content = log.Info.Description;
         }
     };
 }
        public EditDescriptionCommand()
        {
            Image = Resources.article16x16;
            Text  = CultureService.Instance.GetString(CultureText.menuItem_EditDescription_Text);

            EventAggregator.Instance.Subscribe <TreeViewSelectionChangedAppEvent>(e =>
            {
                if (e.SelectedNode is LogFileNameTreeNode)
                {
                    _logFile = (e.SelectedNode as LogFileNameTreeNode).Log;
                    Visible  = true;
                }
                else
                {
                    Visible = false;
                }
            });
        }
Example #7
0
        public LogMessageNameTreeNode(ILogFileItem logFile, uint arbitrationId, TreeNode subNode)
        {
            var messageName = logFile.Messages.GetMessageNameByArbId(arbitrationId);
            var arbid       = new ArbitrationIdConverter().ConvertTo(arbitrationId, typeof(string)) as string;

            if (string.IsNullOrEmpty(messageName))
            {
                /*Message: No Name [{0}]*/
                Text = string.Format(CultureService.Instance.GetString(CultureText.node_MessageNoNameArbId_Text), arbid);
            }
            else
            {
                /*Message: {0} [{1}]*/
                Text = string.Format(CultureService.Instance.GetString(CultureText.node_MessageNameArbId_Text), messageName, arbid);
            }

            SelectedImageKey = ImageKey = "Mail_16x16";
            Nodes.Add(subNode);
        }
        public RenameFileCommand(ILogFileCollection logFiles)
        {
            Text      = CultureService.Instance.GetString(CultureText.menuItem_Rename_Text);
            Image     = Resources.rename16;
            _logFiles = logFiles;

            /*Látható és érték átvétel*/
            EventAggregator.Instance.Subscribe <TreeViewSelectionChangedAppEvent>(e =>
            {
                if (e.SelectedNode is LogFileNameTreeNode)
                {
                    _dbFile = (e.SelectedNode as LogFileNameTreeNode).Log;
                    Visible = true;
                }
                else
                {
                    Visible = false;
                }
            });
        }
Example #9
0
        public void _0008_CreateNew_and_Load()
        {
            /*Egyedi fáljnév*/
            var          logFileName = "_0005_CreateNew_and_Load" + Guid.NewGuid().ToString();
            ILogFileItem newLog      = null;

            if (!System.IO.File.Exists(LogLocation + logFileName + ".s3db"))
            {
                newLog = new LogFileItem(LogLocation, ProjectName, logFileName);
                Assert.IsTrue(System.IO.File.Exists(newLog.Path), "Nem hozta létre a log fájlt.");
                newLog.Messages.AddToStorageBegin();
                for (int i = 0; i < 1000; i++)
                {
                    newLog.Messages.AddToStorage("Proba", DateTime.Now, MessageDirection.Received, ArbitrationIdType.Standard, 0x0FF, false, new byte[] { 0x00, 0x01, 0x02, 0x03, 0x05 }, "nincs", "nincs");
                }
                newLog.Messages.AddToStorageEnd();
            }

            var loadedLog = new LogFileItem(newLog.Path);

            loadedLog.ProgressChanged += (o, e) => { Console.WriteLine("Percent:" + e.ProgressPercentage + "%" + " Message:" + e.UserState); };
            loadedLog.Load();
            Assert.AreEqual(1000, loadedLog.Messages.Count, "Beirt és várt üzenetek száma nem egyezik.");
        }
Example #10
0
        /// <summary>
        ///
        /// </summary>
        public void Play()
        {
            /*Ha engdélyezve van a törlés, akkor indulás előtt törli az előzményeket.*/
            if (_paramters.PlayHistoryClearEnabled)
            {
                _adapterStat.Reset();
                _messageStat.Default();
                _messageTrace.Clear();
                _filters.Default();
            }

            Debug.WriteLine(GetType().Namespace + "." + GetType().Name + "." + MethodBase.GetCurrentMethod().Name + "()");

            _shutdownEvent       = new AutoResetEvent(false);
            _readyToDisposeEvent = new AutoResetEvent(false);



            uint baudrate = 0;

            if (_paramters.Baudrate.Contains("Custom"))
            {
                /*Baudrate = "B003D007 Custom Baud"*/
                baudrate = UInt32.Parse(_paramters.Baudrate.Remove(_paramters.Baudrate.IndexOf(@"Custom")).Trim(), System.Globalization.NumberStyles.HexNumber);
            }
            else
            {
                /*Baudrate = 5.000kBaud*/
                baudrate = CanBaudRateCollection.GetBaudRates().First(n => n.Name == _paramters.Baudrate).Value;
            }

            if (_paramters.DeviceName != VirtualDeviceName)
            {
                try
                {
                    _adapter = new CanAdapterDevice();
                    _adapter.ConnectTo(_paramters.DeviceName);
                    _adapter.Services.Reset();
                    _adapter.Attributes.ListenOnly            = _paramters.ListenOnly;
                    _adapter.Attributes.Loopback              = _paramters.Loopback;
                    _adapter.Attributes.NonAutoRetransmission = _paramters.NonAutoReTx;
                    _adapter.Attributes.Termination           = _paramters.Termination;
                    _adapter.Open(baudrate);
                    _statusUpdateTimestamp = 0;
                }
                catch (Exception)
                {
                    _adapter.Dispose();
                    OnStopped();
                    throw;
                }
            }
            else
            {
                _virtualAdapterFrameCounter = 0;
            }

            try
            {
                if (_project.Parameters.LogEnabled)
                {
                    _log = new LogFileItem(_project.Loaction, _project.FileName, DateTime.Now.ToString(AppConstants.FileNameTimestampFormat));
                    _log.Messages.AddToStorageBegin();
                }

                var th = new Thread(new ThreadStart(DoWork))
                {
                    Name     = "Adapter",
                    Priority = Settings.Default.AdapterThreadPriority
                };
                th.Start();
                _toolTables.SetTxQueue(_txQueue);
                _toolTables.Start();
            }
            catch
            {
                OnStopped();
                throw;
            }
        }
Example #11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="collection"></param>
 public LogFileAppEvent(ILogFileItem logFile, FileChangingType changingType)
 {
     ChangingType = changingType;
     LogFile      = logFile;
 }