Skip to content

Commit e6fe56e

Browse files
Merge pull request #110 from MEAT-Inc/develop
Changed to filter lists for configurations and added segmentation routine
2 parents 356161a + 61f0054 commit e6fe56e

6 files changed

Lines changed: 92 additions & 10 deletions

File tree

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.165")]
23-
[assembly: AssemblyFileVersion("0.4.4.165")]
22+
[assembly: AssemblyVersion("0.4.4.166")]
23+
[assembly: AssemblyFileVersion("0.4.4.166")]
2424
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
2525

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.15.452")]
23-
[assembly: AssemblyFileVersion("0.5.15.452")]
22+
[assembly: AssemblyVersion("0.5.15.453")]
23+
[assembly: AssemblyFileVersion("0.5.15.453")]
2424
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
2525

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.56")]
23-
[assembly: AssemblyFileVersion("0.2.4.56")]
22+
[assembly: AssemblyVersion("0.2.4.57")]
23+
[assembly: AssemblyFileVersion("0.2.4.57")]
2424
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
2525

SharpSimulator/PassThruSimulationSupport/PassThruSimChannelExtensions.cs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -453,5 +453,87 @@ public static PassThruStructs.PassThruMsg[] ConvertReadExpression(this PassThruR
453453
// Return the message
454454
return MessagesBuilt;
455455
}
456+
457+
// ------------------------------------------------------------------------------------------------------------------------------------------
458+
459+
/// <summary>
460+
/// Converts a given flow control message into a segmented message object
461+
/// Use the example blow to understand how this conversion routine is performed
462+
///
463+
/// Sent Input Message:
464+
/// 00 00 07 DF 02 09 02
465+
/// Response Message:
466+
/// 00 00 07 E8 49 02 01 34 54 31 4B 36 31 41 4B 30 50 55 37 38 30 32 32 33
467+
/// Response Segments:
468+
/// 00 00 07 E8 10 14 49 02 01 34 54 31 --> Start of Response
469+
/// 00 00 07 E0 30 00 00 00 00 00 00 00 --> Flow Control Identifier
470+
/// 00 00 07 E8 21 4B 36 31 41 4B 30 50 --> Message 1 of 2
471+
/// 00 00 07 E8 22 55 37 38 30 32 32 33 --> Message 2 of 2
472+
/// </summary>
473+
/// <param name="ResponseRead">The message we're looking to segment out</param>
474+
/// <returns>An array of messages holding the input message contents segmented out</returns>
475+
public static PassThruStructs.PassThruMsg[] SegmentMessage(this PassThruStructs.PassThruMsg ResponseRead, PassThruStructs.PassThruMsg CommandSent)
476+
{
477+
// First check if we need to segment this message or not
478+
if (ResponseRead.DataSize <= 12) return new[] { ResponseRead };
479+
480+
// Take our input content and slice it into a set of messages here
481+
int CommandSize = CommandSent.Data[5];
482+
List<PassThruStructs.PassThruMsg> MessageContentsSplit = new List<PassThruStructs.PassThruMsg>();
483+
484+
// Build the first segment of the message content here
485+
// 1. 00 00 07 E8 --> Message Start/Address
486+
// 2. 00 00 07 E8 10 14 --> Indicate Flow Control and size (Size of input minus 10)
487+
// 3. 00 00 07 E8 10 14 49 02 --> Tack on command response values here (Skip 4 on input command to find bytes)
488+
// 4. 00 00 07 E8 10 14 49 02 01 34 54 31 --> Append the start of our message contents here. Should only be 4 bytes of data
489+
List<byte> FirstSegment = new List<byte>();
490+
FirstSegment.AddRange(ResponseRead.Data.Take(4)); // 00 00 07 E8
491+
FirstSegment.AddRange(new byte[] { 0x10, (byte)(ResponseRead.DataSize - 10) }); // 00 00 07 E8 10 14
492+
FirstSegment.AddRange(ResponseRead.Data.Skip(4).Take(CommandSize)); // 00 00 07 E8 10 14 49 02
493+
FirstSegment.AddRange(ResponseRead.Data.Skip(4 + CommandSize).Take(4)); // 00 00 07 E8 10 14 49 02 01 34 54 31
494+
495+
// Convert the input segment to a PassThruMsg and store it
496+
MessageContentsSplit.Add(new PassThruStructs.PassThruMsg((uint)FirstSegment.Count)
497+
{
498+
ExtraDataIndex = 0,
499+
Data = FirstSegment.ToArray(),
500+
TxFlags = TxFlags.NO_TX_FLAGS,
501+
RxStatus = RxStatus.NO_RX_STATUS,
502+
DataSize = (uint)FirstSegment.Count,
503+
ProtocolId = ResponseRead.ProtocolId,
504+
});
505+
506+
// Now iterate through the rest of our message content and build segments for it
507+
// 1. 00 00 07 E8
508+
// 2. 00 00 07 E8 2X
509+
// 3. 00 00 07 E8 2X XX XX XX XX XX XX XX (or shorter based on content size)
510+
for (int MsgDataIndex = 12; MsgDataIndex < ResponseRead.DataSize; MsgDataIndex++)
511+
{
512+
// Start each message with 00 00 07 E8 2X
513+
List<byte> MessageSegment = new List<byte>();
514+
MessageSegment.AddRange(ResponseRead.Data.Take(4)); // 00 00 07 E8
515+
MessageSegment.Add((byte)MessageContentsSplit.Count); // 00 00 07 E8 21
516+
517+
// Check to see if we can take the max message size or not.
518+
int BytesToTake = MsgDataIndex + 7 < ResponseRead.DataSize
519+
? 7
520+
: (int)(ResponseRead.DataSize - MsgDataIndex);
521+
MessageSegment.AddRange(ResponseRead.Data.Skip(MsgDataIndex).Take(BytesToTake)); // 00 00 07 E8 21 4B 36 31 41 4B 30 50
522+
523+
// Add this segment to our collection of messages here and move onto the next loop
524+
MessageContentsSplit.Add(new PassThruStructs.PassThruMsg((uint)MessageSegment.Count)
525+
{
526+
ExtraDataIndex = 0,
527+
Data = FirstSegment.ToArray(),
528+
TxFlags = TxFlags.NO_TX_FLAGS,
529+
RxStatus = RxStatus.NO_RX_STATUS,
530+
DataSize = (uint)FirstSegment.Count,
531+
ProtocolId = ResponseRead.ProtocolId,
532+
});
533+
}
534+
535+
// Return our output list of message objects built
536+
return MessageContentsSplit.ToArray();
537+
}
456538
}
457539
}

SharpSimulator/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
[assembly: Guid("183F7A6A-E107-4209-8A11-044A08DEAEE4")]
2020

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

SharpWrapper/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
[assembly: InternalsVisibleTo("SharpWrap2534Tests")]
2121

2222
// Version information
23-
[assembly: AssemblyVersion("6.2.3.510")]
24-
[assembly: AssemblyFileVersion("6.2.3.510")]
23+
[assembly: AssemblyVersion("6.2.3.511")]
24+
[assembly: AssemblyFileVersion("6.2.3.511")]
2525
[assembly: NeutralResourcesLanguageAttribute( "en-US" )]
2626

0 commit comments

Comments
 (0)