public void BasicLoggerConnect() { MockEcuStream mock = MockEcuStream.CreateInstance(); FragmentedStream stream = FragmentedStream.GetInstance(mock); this.logger = SsmBasicLogger.GetInstance(Environment.CurrentDirectory, stream); IAsyncResult result = logger.BeginConnect(null, null); result.AsyncWaitHandle.WaitOne(); ParameterSource source = logger.EndConnect(result); Assert.AreEqual("2F12785206", this.logger.EcuIdentifier, "EcuIdentifier"); Assert.IsNotNull(source); Assert.IsNotNull(source.Parameters); }
public void ManualLoggingTest(Action <ParameterDatabase> callback) { MockEcuStream stream = MockEcuStream.CreateInstance(); FragmentedStream fragStream = FragmentedStream.GetInstance(stream); this.logger = SsmBasicLogger.GetInstance(Environment.CurrentDirectory, fragStream); IAsyncResult result = logger.BeginConnect(null, null); result.AsyncWaitHandle.WaitOne(); ParameterSource source = logger.EndConnect(result); ParameterDatabase database = ParameterDatabase.GetInstance(); database.Add(source); LogProfile Profile = LogProfile.CreateInstance(); foreach (SsmParameter parameter in database.Parameters) { Profile.Add(parameter, parameter.Conversions[0]); if (Profile.Columns.Count > 3) { break; } } this.logStartCalls = 0; this.logEntryCalls = 0; this.logEndCalls = 0; this.logErrorCalls = 0; this.logger.SetProfile(Profile, database); this.logger.LogStart += this.LogStart; this.logger.LogEntry += this.LogEntry; this.logger.LogStop += this.LogStop; this.logger.LogError += this.LogError; this.logger.StartLogging(); System.Threading.Thread.Sleep(TimeSpan.FromSeconds(0.25)); callback(database); this.logger.BeginStopLogging(NoOp, null); System.Threading.Thread.Sleep(TimeSpan.FromSeconds(0.1)); }
private void ReadFromStream(bool fragmented) { IList <int> addresses = new int[] { 1, 2, 3 }; SsmPacket request = SsmPacket.CreateMultipleReadRequest(addresses); IList <byte> values = new byte[] { 1, 2, 3 }; SsmPacket response = SsmPacket.CreateMultipleReadResponse(values); List <byte> buffer = new List <byte>(request.Data); buffer.AddRange(response.Data); MemoryStream stream = new MemoryStream(buffer.ToArray()); if (fragmented) { stream = FragmentedStream.GetInstance(stream); } SsmPacket actual = SsmPacketParser.ReadFromStream(stream); Utility.CompareArrays("ReadFromStream", response.Data, actual.Data); }
private void ReadFromStreamAsync(bool fragmented) { IList <int> addresses = new int[] { 1, 2, 3 }; SsmPacket request = SsmPacket.CreateMultipleReadRequest(addresses); IList <byte> values = new byte[] { 1, 2, 3 }; SsmPacket response = SsmPacket.CreateMultipleReadResponse(values); List <byte> buffer = new List <byte>(request.Data); buffer.AddRange(response.Data); MemoryStream stream = new MemoryStream(buffer.ToArray()); if (fragmented) { stream = FragmentedStream.GetInstance(stream); } SsmPacketParser parser = SsmPacketParser.CreateInstance(); IAsyncResult asyncResult = parser.BeginReadFromStream(stream, ReadCompleted, parser); asyncResult.AsyncWaitHandle.WaitOne(); Utility.CompareArrays("ReadFromStreamAsync", response.Data, this.packet.Data); }