Skip to content

Update ChannelBlock.cs #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
7527464
Update ChannelBlock.cs
BrightCaster Jul 26, 2023
ea192c5
Update README.md
BrightCaster Jul 26, 2023
8a8cc41
Update ChannelBlock.cs
BrightCaster Nov 29, 2023
6ce3685
Update to fix for uncorrect position
BrightCaster Nov 30, 2023
06f9e12
get support encoding 1251
BrightCaster Dec 21, 2023
907a982
Merge branch 'master' of https://github.com/BrightCaster/ASAM-MDF.NET
BrightCaster Dec 25, 2023
cd301e5
Merge branch 'master' of https://github.com/BrightCaster/ASAM-MDF.NET
BrightCaster Dec 25, 2023
b766dc7
Update ChannelBlock.cs
BrightCaster Dec 25, 2023
0a0701e
add validate address
BrightCaster Feb 21, 2024
fc15a91
Try update Asam mdf to deep copy
BrightCaster Apr 4, 2024
f2835c5
Fix some problem recurse
BrightCaster Apr 5, 2024
b96b75d
Revert "Fix some problem recurse"
BrightCaster Apr 5, 2024
9c6911a
Revert "Try update Asam mdf to deep copy"
BrightCaster Apr 5, 2024
2fea379
Try update to remove some channels
BrightCaster Apr 8, 2024
c3bddeb
refactoring and add removing channels
BrightCaster Apr 9, 2024
4edea27
Create INext.cs
BrightCaster Apr 10, 2024
3643a51
refactoring
BrightCaster Apr 10, 2024
b5b26ce
.
BrightCaster Apr 11, 2024
b39f28a
Update pointer
BrightCaster Apr 12, 2024
b479eab
Try to cut some channels
BrightCaster Apr 16, 2024
f80e9f0
Update to removing channelBlocks
BrightCaster Apr 17, 2024
063d5c4
Added func removing channels
BrightCaster Apr 18, 2024
3bec721
Fix some problem with TextBlock
BrightCaster Jul 4, 2024
01f7a59
Try create new writer mdf
BrightCaster Jul 16, 2024
a363724
return get size static
BrightCaster Jul 19, 2024
e843637
Update ChannelBlock.cs
BrightCaster Jul 23, 2024
c82be1c
Update TextBlock.cs
BrightCaster Jul 23, 2024
1571909
Update DataRecord.cs
BrightCaster Jul 24, 2024
eb9cf36
Added write longsignalName
BrightCaster Jul 25, 2024
7e0795a
Added write DisplayName block
BrightCaster Jul 26, 2024
1d41b09
Update ChannelBlock.cs
BrightCaster Jul 26, 2024
b83de2e
update read comment block and change setter property for write
BrightCaster Jul 26, 2024
58f8eb6
fix writer method for channel properties
BrightCaster Jul 26, 2024
aa1389e
Added validate writer encoding
BrightCaster Jul 26, 2024
5a75703
Update Mdf.cs
BrightCaster Sep 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions ASAM.MDF.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27703.2018
# Visual Studio Version 17
VisualStudioVersion = 17.9.34622.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASAM.MDF", "ASAM.MDF\ASAM.MDF.csproj", "{B48EFA8A-CCE6-486F-BD55-F8B8EB44E8DC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASAM.MDF.Tests", "ASAM.MDF.Tests\ASAM.MDF.Tests.csproj", "{8092B28D-5006-45E1-A489-32AE0FEBEE13}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASAM.MDF.Tests", "ASAM.MDF.Tests\ASAM.MDF.Tests.csproj", "{8092B28D-5006-45E1-A489-32AE0FEBEE13}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DebugOpenFileMdf", "DebugOpenFileMdf\DebugOpenFileMdf.csproj", "{E24CDFA8-18C8-47E5-ACFA-D1829C6A120F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -21,6 +22,10 @@ Global
{8092B28D-5006-45E1-A489-32AE0FEBEE13}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8092B28D-5006-45E1-A489-32AE0FEBEE13}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8092B28D-5006-45E1-A489-32AE0FEBEE13}.Release|Any CPU.Build.0 = Release|Any CPU
{E24CDFA8-18C8-47E5-ACFA-D1829C6A120F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E24CDFA8-18C8-47E5-ACFA-D1829C6A120F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E24CDFA8-18C8-47E5-ACFA-D1829C6A120F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E24CDFA8-18C8-47E5-ACFA-D1829C6A120F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion ASAM.MDF/ASAM.MDF.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<OutputType>Library</OutputType>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
Expand Down
44 changes: 34 additions & 10 deletions ASAM.MDF/Libary/Block.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
namespace ASAM.MDF.Libary
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

/// <summary>
/// The abstract block class
/// </summary>
public abstract class Block
{
internal List<PointerAddress<uint>> listAddressesV23;
internal List<PointerAddress<ulong>> listAddressesV4;
protected Block(Mdf mdf)
{
if (mdf == null)
Expand All @@ -22,10 +26,10 @@ protected Block(Mdf mdf)
public string Identifier { get; protected set; }
[MdfVersion(400, 0)]
public uint Reserved { get; set; }
public ulong Size { get; private set; }
public ulong Size { get; protected set; }
[MdfVersion(400, 0)]
public ulong LinksCount { get; private set; }
public ulong BlockAddress { get; private set; }
public int BlockAddress { get; set; }

internal virtual ushort GetSize()
{
Expand All @@ -35,29 +39,44 @@ internal virtual int GetSizeTotal()
{
return GetSize();
}
internal void Read()
internal virtual void Read()
{
BlockAddress = Mdf.position;

if (Mdf.IDBlock.Version >= 400)
{
ReadV4();
return;
}
else
ReadV23();
}

internal virtual void ReadV23()
{
Identifier = Mdf.GetString(2); // blockaddress = 0
Size = Mdf.ReadU16();

if (Size <= 4)
throw new FormatException();
}

internal virtual void Write(byte[] array, ref int index)
{
var bytesIdentifier = Encoding.UTF8.GetBytes(Identifier);
var bytesSize = BitConverter.GetBytes(GetSize());

ValidateEncodingLength(ref bytesIdentifier, 2);

Array.Copy(bytesIdentifier, 0, array, index, bytesIdentifier.Length);
Array.Copy(bytesSize, 0, array, index + 2, bytesSize.Length);
}

internal virtual void Write(List<byte> array)
{
var size = array.Count;

var bytesIdentifier = Encoding.UTF8.GetBytes(Identifier);
var bytesSize = BitConverter.GetBytes(size);

array.InsertRange(0, bytesIdentifier);
array.InsertRange(1, bytesSize);
}

/// <summary>
/// Sets the string value.
/// </summary>
Expand Down Expand Up @@ -89,13 +108,18 @@ protected MdfVersionAttribute RequiredVersion(Type type, string property)

return (MdfVersionAttribute)Attribute.GetCustomAttribute(type.GetProperty(property), typeof(MdfVersionAttribute));
}
private void ReadV4()
internal virtual void ReadV4()
{
IdHash = Mdf.ReadU16();
Identifier = Mdf.GetString(2); // blockaddress = 0
Reserved = Mdf.ReadU32();
Size = Mdf.ReadU64();
LinksCount = Mdf.ReadU64();
}
public void ValidateEncodingLength(ref byte[] bytes, int countConstraints)
{
if (bytes.Length > countConstraints)
bytes = bytes.Take(countConstraints).ToArray();
}
}
}
Loading