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); }; }
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); }; }