Skip to content

Commit 22f2b3c

Browse files
Merge pull request #93 from MEAT-Inc/bugfix/SWRAP-16/SWRAP-16-wrapper-unit-tests
Merging changes for Simulation playback
2 parents 77a7cf7 + d28fa07 commit 22f2b3c

30 files changed

Lines changed: 196851 additions & 118 deletions

SharpAutoId/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
[assembly: Guid("73552094-035A-4DFB-BEC4-5116EC7993EF")]
2020

2121
// Version information
22-
[assembly: AssemblyVersion("0.4.4.130")]
23-
[assembly: AssemblyFileVersion("0.4.4.130")]
22+
[assembly: AssemblyVersion("0.4.4.135")]
23+
[assembly: AssemblyFileVersion("0.4.4.135")]
2424
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
2525

SharpAutoId/SharpAutoId.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@
6262
</ItemGroup>
6363
<ItemGroup>
6464
<PackageReference Include="SharpLogger">
65-
<Version>2.7.3.327</Version>
65+
<Version>2.7.8.334</Version>
6666
</PackageReference>
6767
<PackageReference Include="SharpWrapper">
68-
<Version>6.1.9.459</Version>
68+
<Version>6.1.10.468</Version>
6969
</PackageReference>
7070
</ItemGroup>
7171
<ItemGroup />

SharpExpressions/PassThruExpression.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ protected internal bool SetExpressionProperties(FieldInfo[] FieldObjects, string
266266
// Make sure the count of properties matches the count of lines.
267267
if (FieldValueStrings.Length != FieldObjects.Length) {
268268
this._expressionLogger.WriteLog("EXPRESSIONS FOR FIELDS AND VALUES ARE NOT EQUAL SIZES! THIS IS FATAL!", LogType.FatalLog);
269+
this._expressionLogger.WriteLog($"INPUT PASSTHRU LOG LINES ARE BEING LOGGED BELOW\n\t{this.CommandLines}");
269270
return false;
270271
}
271272

@@ -279,6 +280,7 @@ protected internal bool SetExpressionProperties(FieldInfo[] FieldObjects, string
279280
{
280281
// Throw an exception output for this error type.
281282
this._expressionLogger.WriteLog($"EXCEPTION THROWN DURING EXPRESSION VALUE STORE FOR COMMAND TYPE {this.GetType().Name}!", LogType.ErrorLog);
283+
this._expressionLogger.WriteLog($"INPUT PASSTHRU LOG LINES ARE BEING LOGGED BELOW\n\t{this.CommandLines}");
282284
this._expressionLogger.WriteException("EXCEPTION IS BEING LOGGED BELOW", SetEx);
283285
return false;
284286
}

SharpExpressions/PassThruExpressionExtensions.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,14 @@ public static string FindMessageContents(this PassThruExpression ExpressionObjec
8888
List<string> OutputMessages = new List<string>();
8989
foreach (var MsgLineSet in SplitMessageLines)
9090
{
91+
// Clean out spaces from the input lines
92+
string CleanedMsgSet = MsgLineSet
93+
.Replace("\r ", " ")
94+
.Replace("\r", string.Empty);
95+
9196
// RegexMatch output here.
9297
var RegexResultTuples = new List<Tuple<string, string>>();
93-
bool MatchedContent = MessageContentRegex.Evaluate(MsgLineSet, out var MatchedMessageStrings);
98+
bool MatchedContent = MessageContentRegex.Evaluate(CleanedMsgSet, out var MatchedMessageStrings);
9499
if (!MatchedContent) continue;
95100

96101
// Make sure the value for Flags is not zero. If it is, then we need to insert a "No Value" object

SharpExpressions/PassThruExpressionGenerator.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,25 @@ public static PassThruExpressionsGenerator LoadPassThruLogFile(string PassThruLo
123123
return OutputGenerator;
124124
}
125125
/// <summary>
126+
/// Spawns a new PassThruExpressionGenerator from a collection of PassThru log files.
127+
/// </summary>
128+
/// <param name="PassThruLogFiles">The log files to load into expressions. This MUST be a normal PassThru log!</param>
129+
/// <returns>A new expressions generator ready to load all content inside of the input log file</returns>
130+
public static PassThruExpressionsGenerator LoadPassThruLogFiles(string[] PassThruLogFiles)
131+
{
132+
// Combine the content of all the log files and load it into a generator
133+
string CombinedLogFileContent = string.Empty;
134+
string CombinedLogFileName = Path.ChangeExtension(Path.GetTempFileName(), ".txt");
135+
136+
// Iterate the files and store their content in the output file content variable
137+
foreach (var LogFile in PassThruLogFiles) CombinedLogFileContent += File.ReadAllText(LogFile);
138+
File.WriteAllText(CombinedLogFileName, CombinedLogFileContent);
139+
140+
// Load a generator for our content here
141+
PassThruExpressionsGenerator OutputGenerator = new PassThruExpressionsGenerator(CombinedLogFileName);
142+
return OutputGenerator;
143+
}
144+
/// <summary>
126145
/// Spawns a new PassThruExpressionGenerator from a PassThru expressions file
127146
/// </summary>
128147
/// <param name="ExpressionsFile">The expressions file to load and convert. This MUST be an Expressions log!</param>

SharpExpressions/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
[assembly: Guid("73552094-035A-4DFB-BEC4-5116EC7993EF")]
2020

2121
// Version information
22-
[assembly: AssemblyVersion("0.5.6.147")]
23-
[assembly: AssemblyFileVersion("0.5.6.147")]
22+
[assembly: AssemblyVersion("0.5.12.212")]
23+
[assembly: AssemblyFileVersion("0.5.12.212")]
2424
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
2525

SharpExpressions/SharpExpressions.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@
7575
</ItemGroup>
7676
<ItemGroup>
7777
<PackageReference Include="SharpLogger">
78-
<Version>2.7.3.327</Version>
78+
<Version>2.7.8.334</Version>
7979
</PackageReference>
8080
<PackageReference Include="SharpWrapper">
81-
<Version>6.1.9.459</Version>
81+
<Version>6.1.10.468</Version>
8282
</PackageReference>
8383
</ItemGroup>
8484
<ItemGroup />

SharpPipes/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
[assembly: Guid("73552094-035A-4DFB-BEC4-5116EC7993EF")]
2020

2121
// Version information
22-
[assembly: AssemblyVersion("0.2.4.35")]
23-
[assembly: AssemblyFileVersion("0.2.4.35")]
22+
[assembly: AssemblyVersion("0.2.4.39")]
23+
[assembly: AssemblyFileVersion("0.2.4.39")]
2424
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
2525

SharpPipes/SharpPipes.csproj

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,13 @@
5959
</Content>
6060
</ItemGroup>
6161
<ItemGroup>
62-
<PackageReference Include="SharpLogger">
63-
<Version>2.7.3.327</Version>
64-
</PackageReference>
62+
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
6563
</ItemGroup>
6664
<ItemGroup>
67-
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
65+
<PackageReference Include="SharpLogger">
66+
<Version>2.7.8.334</Version>
67+
</PackageReference>
6868
</ItemGroup>
69-
<ItemGroup />
7069
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
7170
<PropertyGroup>
7271
<PostBuildEvent>copy /Y "$(TargetDir)*" "$(ProjectDir)$(ProjectName)Nuget\lib\net472"</PostBuildEvent>

SharpSimulator/PassThruSimulationGenerator.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,21 @@ public static PassThruSimulationGenerator LoadPassThruLogFile(string PassThruLog
173173
return new PassThruSimulationGenerator(ExpressionGenerator);
174174
}
175175
/// <summary>
176+
/// Spawns a new SimulationGenerator from a collection of PassThru log files.
177+
/// </summary>
178+
/// <param name="PassThruLogFiles">The log files to load into expressions. This MUST be a normal PassThru log!</param>
179+
/// <returns>A new expressions generator ready to load all content inside of the input log file</returns>
180+
public static PassThruSimulationGenerator LoadPassThruLogFiles(string[] PassThruLogFiles)
181+
{
182+
// Load a generator for our content here
183+
PassThruExpressionsGenerator ExpressionGenerator = PassThruExpressionsGenerator.LoadPassThruLogFiles(PassThruLogFiles);
184+
if (ExpressionGenerator.GenerateLogExpressions().Length == 0)
185+
throw new DataException($"Error! No expressions were able to be built from log file {ExpressionGenerator.PassThruLogFile}!");
186+
187+
// Build and return a new simulation generator from our built expressions objects
188+
return new PassThruSimulationGenerator(ExpressionGenerator);
189+
}
190+
/// <summary>
176191
/// Spawns a new SimulationGenerator from a PassThru expressions file
177192
/// </summary>
178193
/// <param name="ExpressionsFile">The expressions file to load and convert. This MUST be an Expressions log!</param>
@@ -222,6 +237,15 @@ public PassThruSimulationChannel[] GenerateLogSimulation()
222237
var PTFilterCommands = ExpressionSet.Value
223238
.Where(ExpObj => ExpObj.TypeOfExpression == PassThruExpressionTypes.PTStartMsgFilter)
224239
.Cast<PassThruStartMessageFilterExpression>()
240+
.GroupBy(FilterObj => new
241+
{
242+
FilterMask = FilterObj.MessageFilterContents[0].Last(),
243+
FilterPattern = FilterObj.MessageFilterContents[1].Last(),
244+
FilterFlow = FilterObj.MessageFilterContents.Count >= 3
245+
? FilterObj.MessageFilterContents[2].Last()
246+
: string.Empty
247+
})
248+
.Select(FilterGroup => FilterGroup.First())
225249
.ToArray();
226250
var PTReadCommands = ExpressionSet.Value
227251
.Where(ExpObj => ExpObj.TypeOfExpression == PassThruExpressionTypes.PTReadMsgs)

0 commit comments

Comments
 (0)