예제 #1
0
        public FakeCBT(string portName = null)
        {
            _stopwatch = new Stopwatch();
            _rnd = new Random();
            _timer = new MicroTimer(1000);
            _timer.MicroTimerElapsed += (s, args) =>
            {
                if (CanMessageReceived == null) return;

                // Generate random Can Message
                var msg = new CanMessage
                {
                    Bus = _rnd.Next(1, 3),
                    Id = _rnd.Next(0x294, 0x2A1),
                    Status = _rnd.Next(0, 3),
                    Data = new byte[] { (byte)_rnd.Next(0x00, 0xFF), (byte)_rnd.Next(0x00, 0xFF), (byte)_rnd.Next(0x00, 0xFF), (byte)_rnd.Next(0x00, 0xFF), (byte)_rnd.Next(0x00, 0xFF), (byte)_rnd.Next(0x00, 0xFF), (byte)_rnd.Next(0x00, 0xFF), (byte)_rnd.Next(0x00, 0xFF) },
                    DateTime = _startTime + _stopwatch.Elapsed
                };
                CanMessageReceived(msg);
            };
        }
예제 #2
0
        public FakeCBT(string portName = null)
        {
            _stopwatch = new Stopwatch();
            _rnd       = new Random();
            _timer     = new MicroTimer(1000);
            _timer.MicroTimerElapsed += (s, args) =>
            {
                if (CanMessageReceived == null)
                {
                    return;
                }

                // Generate random Can Message
                var msg = new CanMessage
                {
                    Bus      = _rnd.Next(1, 3),
                    Id       = _rnd.Next(0x294, 0x2A1),
                    Status   = _rnd.Next(0, 3),
                    Data     = new byte[] { (byte)_rnd.Next(0x00, 0xFF), (byte)_rnd.Next(0x00, 0xFF), (byte)_rnd.Next(0x00, 0xFF), (byte)_rnd.Next(0x00, 0xFF), (byte)_rnd.Next(0x00, 0xFF), (byte)_rnd.Next(0x00, 0xFF), (byte)_rnd.Next(0x00, 0xFF), (byte)_rnd.Next(0x00, 0xFF) },
                    DateTime = _startTime + _stopwatch.Elapsed
                };
                CanMessageReceived(msg);
            };
        }