Skip to content

Commit

Permalink
Merge pull request #94 from MEAT-Inc/bugfix/SWRAP-16/SWRAP-16-wrapper…
Browse files Browse the repository at this point in the history
…-unit-tests

Simulation Upgrades
  • Loading branch information
ZacharyWalsh57 committed Sep 6, 2023
2 parents 22f2b3c + 4ee0878 commit ba83b04
Show file tree
Hide file tree
Showing 11 changed files with 172 additions and 39 deletions.
4 changes: 2 additions & 2 deletions SharpAutoId/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
[assembly: Guid("73552094-035A-4DFB-BEC4-5116EC7993EF")]

// Version information
[assembly: AssemblyVersion("0.4.4.135")]
[assembly: AssemblyFileVersion("0.4.4.135")]
[assembly: AssemblyVersion("0.4.4.137")]
[assembly: AssemblyFileVersion("0.4.4.137")]
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]

2 changes: 1 addition & 1 deletion SharpAutoId/SharpAutoId.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<Version>2.7.8.334</Version>
</PackageReference>
<PackageReference Include="SharpWrapper">
<Version>6.1.10.468</Version>
<Version>6.1.11.469</Version>
</PackageReference>
</ItemGroup>
<ItemGroup />
Expand Down
4 changes: 2 additions & 2 deletions SharpExpressions/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
[assembly: Guid("73552094-035A-4DFB-BEC4-5116EC7993EF")]

// Version information
[assembly: AssemblyVersion("0.5.12.212")]
[assembly: AssemblyFileVersion("0.5.12.212")]
[assembly: AssemblyVersion("0.5.12.220")]
[assembly: AssemblyFileVersion("0.5.12.220")]
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]

2 changes: 1 addition & 1 deletion SharpExpressions/SharpExpressions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<Version>2.7.8.334</Version>
</PackageReference>
<PackageReference Include="SharpWrapper">
<Version>6.1.10.468</Version>
<Version>6.1.11.469</Version>
</PackageReference>
</ItemGroup>
<ItemGroup />
Expand Down
4 changes: 2 additions & 2 deletions SharpPipes/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
[assembly: Guid("73552094-035A-4DFB-BEC4-5116EC7993EF")]

// Version information
[assembly: AssemblyVersion("0.2.4.39")]
[assembly: AssemblyFileVersion("0.2.4.39")]
[assembly: AssemblyVersion("0.2.4.40")]
[assembly: AssemblyFileVersion("0.2.4.40")]
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]

64 changes: 48 additions & 16 deletions SharpSimulator/PassThruSimulationConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using Newtonsoft.Json;
Expand All @@ -24,27 +25,31 @@ public class PassThruSimulationConfiguration
private static ProtocolId[] _supportedProtocols; // Supported simulation default protocols
private static PassThruSimulationConfiguration[] _supportedConfigurations; // Supported default simulation configurations

// Simulation reader base configuration values pulled from JSON or defined by the user
public uint ReaderTimeout; // Timeout for each read routine
public uint ReaderMsgCount; // The number of messages to read
public uint ResponseTimeout; // The timeout for sending responses

// Basic Channel Configurations
public BaudRate ReaderBaudRate; // Baudrate for the current channel
public ProtocolId ReaderProtocol; // Protocol for the current channel
public PassThroughConnect ReaderChannelFlags; // Flags for the current channel

// Reader configuration filters and IOCTLs
public J2534Filter[] ReaderFilters; // Filters to apply to our reader channel
public PassThruStructs.SConfigList ReaderConfigs; // The configurations to apply as IOCTLs for the channel

#endregion // Fields

#region Properties

// Name of this simulation configuration
public string ConfigurationName { get; set; } // Name of the configuration. Defaults to protocol

// Simulation reader base configuration values pulled from JSON or defined by the user
public uint ReaderTimeout { get; set; } // Timeout for each read routine
public uint ReaderMsgCount { get; set; } // The number of messages to read
public uint ResponseTimeout { get; set; } // The timeout for sending responses

// Basic Channel Configurations
public BaudRate ReaderBaudRate { get; set; } // Baudrate for the current channel
public ProtocolId ReaderProtocol { get; set; } // Protocol for the current channel
public PassThroughConnect ReaderChannelFlags { get; set; } // Flags for the current channel

// Reader configuration filters and IOCTLs
public J2534Filter[] ReaderFilters { get; set; } // Filters to apply to our reader channel
public PassThruStructs.SConfigList ReaderConfigs { get; set; } // The configurations to apply as IOCTLs for the channel

// List of all configurations and all supported protocols for playback during simulations
public static ProtocolId[] SupportedProtocols => _supportedProtocols ??= _loadSupportedProtocols();
public static PassThruSimulationConfiguration[] SupportedConfigurations => _supportedConfigurations ??= _loadSupportedConfigurations();

#endregion // Properties

#region Structs and Classes
Expand All @@ -55,7 +60,10 @@ public class PassThruSimulationConfiguration
/// <summary>
/// Builds a new configuration object and sets defaults to null/empty
/// </summary>
public PassThruSimulationConfiguration(ProtocolId ProtocolInUse, BaudRate BaudRate)
/// <param name="ProtocolInUse">Protocol for the configuration</param>
/// <param name="BaudRate">BaudRate of the simulation</param>
/// <param name="ConfigurationName">Optional name of our configuration</param>
public PassThruSimulationConfiguration(ProtocolId ProtocolInUse, BaudRate BaudRate, string ConfigurationName = null)
{
// Setup a new configuration logger if possible
_configurationLogger ??= new SharpLogger(LoggerActions.UniversalLogger);
Expand All @@ -64,6 +72,10 @@ public PassThruSimulationConfiguration(ProtocolId ProtocolInUse, BaudRate BaudRa
this.ReaderBaudRate = BaudRate;
this.ReaderProtocol = ProtocolInUse;

// Configure the name of the simulation configuration
this.ConfigurationName = !string.IsNullOrWhiteSpace(ConfigurationName)
? ConfigurationName : $"{this.ReaderProtocol}_{this.ReaderProtocol}";

// Store basic values here
this.ReaderMsgCount = 1;
this.ReaderTimeout = 100;
Expand All @@ -74,6 +86,26 @@ public PassThruSimulationConfiguration(ProtocolId ProtocolInUse, BaudRate BaudRa
this.ReaderFilters = new J2534Filter[10];
this.ReaderConfigs = new PassThruStructs.SConfigList(0);
}

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

/// <summary>
/// Gets an auto ID routine for the given protocol value.
/// </summary>
/// <param name="ConfigurationName">Name of the configuration being returned</param>
/// <returns>Routine matching the given protocol or null</returns>
public static PassThruSimulationConfiguration LoadSimulationConfig(string ConfigurationName)
{
// Find our routine.
var RoutineLocated = SupportedConfigurations.FirstOrDefault(RoutineObj => RoutineObj.ConfigurationName == ConfigurationName);
_configurationLogger.WriteLog(
RoutineLocated == null ? "NO CONFIG WAS FOUND! RETURNING NULL!" : $"RETURNING CONFIG \"{ConfigurationName}\" NOW...",
RoutineLocated == null ? LogType.ErrorLog : LogType.InfoLog
);

// Return the located routine here
return RoutineLocated;
}
/// <summary>
/// Gets an auto ID routine for the given protocol value.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions SharpSimulator/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
[assembly: Guid("183F7A6A-E107-4209-8A11-044A08DEAEE4")]

// Version information
[assembly: AssemblyVersion("0.12.2.245")]
[assembly: AssemblyFileVersion("0.12.2.245")]
[assembly: AssemblyVersion("0.12.5.253")]
[assembly: AssemblyFileVersion("0.12.5.253")]
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]

103 changes: 102 additions & 1 deletion SharpSimulator/Properties/DefaultSimConfigurations.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
],
"SimulationConfigurations": [
{
"ConfigurationName": "ISO15765 - 11 Bit (Pass All)",
"ReaderTimeout": 100,
"ReaderMsgCount": 10,
"ResponseTimeout": 1000,
Expand All @@ -12,7 +13,7 @@
"ReaderProtocol": "ISO15765",
"ReaderFilters": [
{
"FilterId": 0,
"FilterId": 0,
"FilterFlags": "NO_TX_FLAGS",
"FilterMask": "00 00 07 00",
"FilterPattern": "00 00 07 00",
Expand All @@ -31,6 +32,106 @@
}
]
}
},
{
"ConfigurationName": "ISO15765 - 11 Bit (Flow Control)",
"ReaderTimeout": 100,
"ReaderMsgCount": 10,
"ResponseTimeout": 1000,
"ReaderBaudRate": 500000,
"ReaderChannelFlags": "NO_CONNECT_FLAGS",
"ReaderProtocol": "ISO15765",
"ReaderFilters": [
{
"FilterId": 0,
"FilterFlags": "ISO15765_FRAME_PAD",
"FilterMask": "FF FF FF FF",
"FilterPattern": "00 00 07 E0",
"FilterFlowCtl": "00 00 07 E8",
"FilterProtocol": "CAN",
"FilterType": "FLOW_CONTROL_FILTER",
"FilterStatus": "INITIALIZED"
},
{
"FilterId": 0,
"FilterFlags": "ISO15765_FRAME_PAD",
"FilterMask": "FF FF FF FF",
"FilterPattern": "00 00 07 E1",
"FilterFlowCtl": "00 00 07 E9",
"FilterProtocol": "CAN",
"FilterType": "FLOW_CONTROL_FILTER",
"FilterStatus": "INITIALIZED"
},
{
"FilterId": 0,
"FilterFlags": "ISO15765_FRAME_PAD",
"FilterMask": "FF FF FF FF",
"FilterPattern": "00 00 07 E2",
"FilterFlowCtl": "00 00 07 EA",
"FilterProtocol": "CAN",
"FilterType": "FLOW_CONTROL_FILTER",
"FilterStatus": "INITIALIZED"
},
{
"FilterId": 0,
"FilterFlags": "ISO15765_FRAME_PAD",
"FilterMask": "FF FF FF FF",
"FilterPattern": "00 00 07 E3",
"FilterFlowCtl": "00 00 07 EB",
"FilterProtocol": "CAN",
"FilterType": "FLOW_CONTROL_FILTER",
"FilterStatus": "INITIALIZED"
},
{
"FilterId": 0,
"FilterFlags": "ISO15765_FRAME_PAD",
"FilterMask": "FF FF FF FF",
"FilterPattern": "00 00 07 E4",
"FilterFlowCtl": "00 00 07 EC",
"FilterProtocol": "CAN",
"FilterType": "FLOW_CONTROL_FILTER",
"FilterStatus": "INITIALIZED"
},
{
"FilterId": 0,
"FilterFlags": "ISO15765_FRAME_PAD",
"FilterMask": "FF FF FF FF",
"FilterPattern": "00 00 07 E5",
"FilterFlowCtl": "00 00 07 ED",
"FilterProtocol": "CAN",
"FilterType": "FLOW_CONTROL_FILTER",
"FilterStatus": "INITIALIZED"
},
{
"FilterId": 0,
"FilterFlags": "ISO15765_FRAME_PAD",
"FilterMask": "FF FF FF FF",
"FilterPattern": "00 00 07 E6",
"FilterFlowCtl": "00 00 07 EE",
"FilterProtocol": "CAN",
"FilterType": "FLOW_CONTROL_FILTER",
"FilterStatus": "INITIALIZED"
},
{
"FilterId": 0,
"FilterFlags": "ISO15765_FRAME_PAD",
"FilterMask": "FF FF FF FF",
"FilterPattern": "00 00 07 E7",
"FilterFlowCtl": "00 00 07 EF",
"FilterProtocol": "CAN",
"FilterType": "FLOW_CONTROL_FILTER",
"FilterStatus": "INITIALIZED"
}
],
"ReaderConfigs": {
"NumberOfParams": 1,
"ConfigList": [
{
"SConfigParamId": 32768,
"SConfigValue": 1
}
]
}
}
]
}
4 changes: 2 additions & 2 deletions SharpSimulator/SharpSimulator.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="SharpExpressions">
<Version>0.5.12.210</Version>
<Version>0.5.12.216</Version>
</PackageReference>
<PackageReference Include="SharpLogger">
<Version>2.7.8.334</Version>
</PackageReference>
<PackageReference Include="SharpWrapper">
<Version>6.1.10.468</Version>
<Version>6.1.11.469</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
16 changes: 8 additions & 8 deletions SharpWrapper/J2534Objects/J2534Filter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ namespace SharpWrapper.J2534Objects
public class J2534Filter : IComparable
{
// Filter Type info
public TxFlags FilterFlags;
public FilterDef FilterType;
public ProtocolId FilterProtocol;
public SharpSessionStatus FilterStatus;
public TxFlags FilterFlags { get; set; }
public FilterDef FilterType { get; set; }
public ProtocolId FilterProtocol { get; set; }
public SharpSessionStatus FilterStatus { get; set; }

// Filter values.
public uint FilterId;
public string FilterMask;
public string FilterPattern;
public string FilterFlowCtl;
public uint FilterId { get; set; }
public string FilterMask { get; set; }
public string FilterPattern { get; set; }
public string FilterFlowCtl { get; set; }

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

Expand Down
4 changes: 2 additions & 2 deletions SharpWrapper/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
[assembly: InternalsVisibleTo("SharpWrap2534Tests")]

// Version information
[assembly: AssemblyVersion("6.1.10.468")]
[assembly: AssemblyFileVersion("6.1.10.468")]
[assembly: AssemblyVersion("6.1.11.471")]
[assembly: AssemblyFileVersion("6.1.11.471")]
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]

0 comments on commit ba83b04

Please sign in to comment.