From 3819f34662bcb0b3d409eea3049929f257e2c844 Mon Sep 17 00:00:00 2001 From: andreyserenkov Date: Tue, 10 Dec 2024 19:22:30 +0500 Subject: [PATCH] Fixes to pass unit tests. Some code warnings removed --- Asap2/.vs/Asap2.csproj.dtbcache.json | 2 +- Asap2/Asap2.Language.analyzer.lex | 1 + Asap2/Asap2.Language.grammar.y | 52 +++++++++++++++++++--- Asap2/Asap2.Parser.cs | 2 +- Asap2/Asap2.csproj | 1 + Asap2/Asap2Tree/AXIS_PTS.cs | 1 - Asap2/Asap2Tree/CAL_PARAM_GROUP.cs | 29 ++++++++++++ Asap2/Asap2Tree/CHARACTERISTIC.cs | 1 - Asap2/Asap2Tree/DAQ.cs | 19 ++++++++ Asap2/Asap2Tree/DAQ_EVENT.cs | 11 +++++ Asap2/Asap2Tree/DAQ_LIST.cs | 7 ++- Asap2/Asap2Tree/DEFAULT_EVENT_LIST.cs | 23 ++++++++++ Asap2/Asap2Tree/FileComment.cs | 1 + Asap2/Asap2Tree/MEASUREMENT.cs | 1 - Asap2/Asap2Tree/PROTOCOL_LAYER.cs | 31 +++++++++++++ Asap2/ShiftReduceParserCode.cs | 1 + Asap2/tools/Remover.cs | 1 - Asap2Test/Program.cs | 2 +- UnitTest/.vs/UnitTest.csproj.dtbcache.json | 2 +- 19 files changed, 171 insertions(+), 17 deletions(-) create mode 100644 Asap2/Asap2Tree/DEFAULT_EVENT_LIST.cs diff --git a/Asap2/.vs/Asap2.csproj.dtbcache.json b/Asap2/.vs/Asap2.csproj.dtbcache.json index dbb0e92..87d2a1f 100644 --- a/Asap2/.vs/Asap2.csproj.dtbcache.json +++ b/Asap2/.vs/Asap2.csproj.dtbcache.json @@ -1 +1 @@ -{"RootPath":"C:\\Users\\Ichiro\\source\\repos\\Asap2\\Asap2","ProjectFileName":"Asap2.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"Asap2Tree\\ADDRESS.cs"},{"SourceFile":"Asap2Tree\\Asap2Base.cs"},{"SourceFile":"Asap2Tree\\Asap2File.cs"},{"SourceFile":"Asap2Tree\\AXIS_PTS.cs"},{"SourceFile":"Asap2Tree\\COPY.cs"},{"SourceFile":"Asap2Tree\\DATA_ACCESS.cs"},{"SourceFile":"Asap2Tree\\CAN.cs"},{"SourceFile":"Asap2Tree\\CHECKSUM_PARAM.cs"},{"SourceFile":"Asap2Tree\\DAQ_EVENT.cs"},{"SourceFile":"Asap2Tree\\CAL_PARAM_GROUP.cs"},{"SourceFile":"Asap2Tree\\CHARACTERISTIC.cs"},{"SourceFile":"Asap2Tree\\CHECKSUM.cs"},{"SourceFile":"Asap2Tree\\COMPU_METHOD.cs"},{"SourceFile":"Asap2Tree\\DEFINED_PAGES.cs"},{"SourceFile":"Asap2Tree\\CODE_CHK.cs"},{"SourceFile":"Asap2Tree\\DIAG_BAUD.cs"},{"SourceFile":"Asap2Tree\\DISTAB_CFG.cs"},{"SourceFile":"Asap2Tree\\ETK_CFG.cs"},{"SourceFile":"Asap2Tree\\FLASH.cs"},{"SourceFile":"Asap2Tree\\KP_BLOB.cs"},{"SourceFile":"Asap2Tree\\PAGE_SWITCH.cs"},{"SourceFile":"Asap2Tree\\SESSION.cs"},{"SourceFile":"Asap2Tree\\TransportProtocolVersion.cs"},{"SourceFile":"Asap2Tree\\USDTP_TIMING_DEFAULTS.cs"},{"SourceFile":"Asap2Tree\\USDTP_TIMING.cs"},{"SourceFile":"Asap2Tree\\KWP_TIMING.cs"},{"SourceFile":"Asap2Tree\\K_LINE.cs"},{"SourceFile":"Asap2Tree\\NETWORK_LIMITS.cs"},{"SourceFile":"Asap2Tree\\PGM.cs"},{"SourceFile":"Asap2Tree\\PAG.cs"},{"SourceFile":"Asap2Tree\\DAQ_LIST.cs"},{"SourceFile":"Asap2Tree\\EVENT.cs"},{"SourceFile":"Asap2Tree\\RASTER.cs"},{"SourceFile":"Asap2Tree\\RESERVED_DISTAB_MEMORY.cs"},{"SourceFile":"Asap2Tree\\SECTOR.cs"},{"SourceFile":"Asap2Tree\\QP_BLOB.cs"},{"SourceFile":"Asap2Tree\\SEED_KEY.cs"},{"SourceFile":"Asap2Tree\\SOURCE.cs"},{"SourceFile":"Asap2Tree\\TIMESTAMP_SUPPORTED.cs"},{"SourceFile":"Asap2Tree\\DAQ.cs"},{"SourceFile":"Asap2Tree\\FileComment.cs"},{"SourceFile":"Asap2Tree\\IF_DATA.cs"},{"SourceFile":"Asap2Tree\\MEASUREMENT.cs"},{"SourceFile":"Asap2Tree\\PAGE.cs"},{"SourceFile":"Asap2Tree\\PROTOCOL_LAYER.cs"},{"SourceFile":"Asap2Tree\\SEGMENT.cs"},{"SourceFile":"Asap2Tree\\TIME_DEF.cs"},{"SourceFile":"Asap2Tree\\TP_BLOB.cs"},{"SourceFile":"Asap2Tree\\XCP_ON_CAN.cs"},{"SourceFile":"Attributes.cs"},{"SourceFile":"Asap2Tree\\DEF_CHARACTERISTIC.cs"},{"SourceFile":"Asap2Tree\\FRAME.cs"},{"SourceFile":"Asap2Tree\\FUNCTION.cs"},{"SourceFile":"Asap2Tree\\IN_MEASUREMENT.cs"},{"SourceFile":"Asap2Tree\\LOC_MEASUREMENT.cs"},{"SourceFile":"Asap2Tree\\MODULE.cs"},{"SourceFile":"Asap2Tree\\OUT_MEASUREMENT.cs"},{"SourceFile":"Asap2Tree\\REF_CHARACTERISTIC.cs"},{"SourceFile":"Asap2Tree\\SI_EXPONENTS.cs"},{"SourceFile":"Asap2Tree\\SUB_FUNCTION.cs"},{"SourceFile":"Asap2Tree\\UNIT.cs"},{"SourceFile":"Asap2Tree\\UNIT_CONVERSION.cs"},{"SourceFile":"Asap2Tree\\USER_RIGHTS.cs"},{"SourceFile":"Asap2Tree\\VARIANT_CODING.cs"},{"SourceFile":"Asap2Tree\\VAR_CHARACTERISTIC.cs"},{"SourceFile":"Asap2Tree\\VAR_CRITERION.cs"},{"SourceFile":"Asap2Tree\\VAR_FORBIDDEN_COMB.cs"},{"SourceFile":"GplexBuffers.cs"},{"SourceFile":"IErrorReporter.cs"},{"SourceFile":"Location.cs"},{"SourceFile":"Parser.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"ShiftReduceParserCode.cs"},{"SourceFile":"tools\\Remover.cs"},{"SourceFile":"tools\\Options.cs"},{"SourceFile":"tools\\Merger.cs"},{"SourceFile":"Asap2.Parser.cs"},{"SourceFile":"Asap2.Parser.Generated.cs"},{"SourceFile":"Asap2.Scanner.cs"},{"SourceFile":"Asap2.Scanner.Generated.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.8.AssemblyAttributes.cs"}],"References":[{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\Microsoft.CSharp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.DataSetExtensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"C:\\Users\\Ichiro\\source\\repos\\Asap2\\Asap2\\bin\\Debug\\Asap2.dll","OutputItemRelativePath":"Asap2.dll"},{"OutputItemFullPath":"","OutputItemRelativePath":""}],"CopyToOutputEntries":[]} \ No newline at end of file +{"RootPath":"C:\\Projects\\Tests\\Asap2\\Asap2","ProjectFileName":"Asap2.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"Asap2Tree\\ADDRESS.cs"},{"SourceFile":"Asap2Tree\\Asap2Base.cs"},{"SourceFile":"Asap2Tree\\Asap2File.cs"},{"SourceFile":"Asap2Tree\\AXIS_PTS.cs"},{"SourceFile":"Asap2Tree\\COPY.cs"},{"SourceFile":"Asap2Tree\\DATA_ACCESS.cs"},{"SourceFile":"Asap2Tree\\CAN.cs"},{"SourceFile":"Asap2Tree\\CHECKSUM_PARAM.cs"},{"SourceFile":"Asap2Tree\\DAQ_EVENT.cs"},{"SourceFile":"Asap2Tree\\CAL_PARAM_GROUP.cs"},{"SourceFile":"Asap2Tree\\CHARACTERISTIC.cs"},{"SourceFile":"Asap2Tree\\CHECKSUM.cs"},{"SourceFile":"Asap2Tree\\COMPU_METHOD.cs"},{"SourceFile":"Asap2Tree\\DEFINED_PAGES.cs"},{"SourceFile":"Asap2Tree\\CODE_CHK.cs"},{"SourceFile":"Asap2Tree\\DIAG_BAUD.cs"},{"SourceFile":"Asap2Tree\\DISTAB_CFG.cs"},{"SourceFile":"Asap2Tree\\ETK_CFG.cs"},{"SourceFile":"Asap2Tree\\FLASH.cs"},{"SourceFile":"Asap2Tree\\KP_BLOB.cs"},{"SourceFile":"Asap2Tree\\PAGE_SWITCH.cs"},{"SourceFile":"Asap2Tree\\SESSION.cs"},{"SourceFile":"Asap2Tree\\TransportProtocolVersion.cs"},{"SourceFile":"Asap2Tree\\USDTP_TIMING_DEFAULTS.cs"},{"SourceFile":"Asap2Tree\\USDTP_TIMING.cs"},{"SourceFile":"Asap2Tree\\KWP_TIMING.cs"},{"SourceFile":"Asap2Tree\\K_LINE.cs"},{"SourceFile":"Asap2Tree\\NETWORK_LIMITS.cs"},{"SourceFile":"Asap2Tree\\PGM.cs"},{"SourceFile":"Asap2Tree\\PAG.cs"},{"SourceFile":"Asap2Tree\\DAQ_LIST.cs"},{"SourceFile":"Asap2Tree\\EVENT.cs"},{"SourceFile":"Asap2Tree\\RASTER.cs"},{"SourceFile":"Asap2Tree\\RESERVED_DISTAB_MEMORY.cs"},{"SourceFile":"Asap2Tree\\SECTOR.cs"},{"SourceFile":"Asap2Tree\\QP_BLOB.cs"},{"SourceFile":"Asap2Tree\\SEED_KEY.cs"},{"SourceFile":"Asap2Tree\\SOURCE.cs"},{"SourceFile":"Asap2Tree\\TIMESTAMP_SUPPORTED.cs"},{"SourceFile":"Asap2Tree\\DAQ.cs"},{"SourceFile":"Asap2Tree\\FileComment.cs"},{"SourceFile":"Asap2Tree\\IF_DATA.cs"},{"SourceFile":"Asap2Tree\\MEASUREMENT.cs"},{"SourceFile":"Asap2Tree\\PAGE.cs"},{"SourceFile":"Asap2Tree\\PROTOCOL_LAYER.cs"},{"SourceFile":"Asap2Tree\\SEGMENT.cs"},{"SourceFile":"Asap2Tree\\TIME_DEF.cs"},{"SourceFile":"Asap2Tree\\TP_BLOB.cs"},{"SourceFile":"Asap2Tree\\XCP_ON_CAN.cs"},{"SourceFile":"Attributes.cs"},{"SourceFile":"Asap2Tree\\DEF_CHARACTERISTIC.cs"},{"SourceFile":"Asap2Tree\\FRAME.cs"},{"SourceFile":"Asap2Tree\\FUNCTION.cs"},{"SourceFile":"Asap2Tree\\IN_MEASUREMENT.cs"},{"SourceFile":"Asap2Tree\\LOC_MEASUREMENT.cs"},{"SourceFile":"Asap2Tree\\MODULE.cs"},{"SourceFile":"Asap2Tree\\OUT_MEASUREMENT.cs"},{"SourceFile":"Asap2Tree\\REF_CHARACTERISTIC.cs"},{"SourceFile":"Asap2Tree\\SI_EXPONENTS.cs"},{"SourceFile":"Asap2Tree\\SUB_FUNCTION.cs"},{"SourceFile":"Asap2Tree\\UNIT.cs"},{"SourceFile":"Asap2Tree\\UNIT_CONVERSION.cs"},{"SourceFile":"Asap2Tree\\USER_RIGHTS.cs"},{"SourceFile":"Asap2Tree\\VARIANT_CODING.cs"},{"SourceFile":"Asap2Tree\\VAR_CHARACTERISTIC.cs"},{"SourceFile":"Asap2Tree\\VAR_CRITERION.cs"},{"SourceFile":"Asap2Tree\\VAR_FORBIDDEN_COMB.cs"},{"SourceFile":"ErrorHandler.cs"},{"SourceFile":"GplexBuffers.cs"},{"SourceFile":"IErrorReporter.cs"},{"SourceFile":"Location.cs"},{"SourceFile":"Parser.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"ShiftReduceParserCode.cs"},{"SourceFile":"tools\\Remover.cs"},{"SourceFile":"tools\\Options.cs"},{"SourceFile":"tools\\Merger.cs"},{"SourceFile":"Asap2.Parser.cs"},{"SourceFile":"Asap2.Parser.Generated.cs"},{"SourceFile":"Asap2.Scanner.cs"},{"SourceFile":"Asap2.Scanner.Generated.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.8.AssemblyAttributes.cs"}],"References":[{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\Microsoft.CSharp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.DataSetExtensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"C:\\Projects\\Tests\\Asap2\\Asap2\\bin\\Debug\\Asap2.dll","OutputItemRelativePath":"Asap2.dll"},{"OutputItemFullPath":"","OutputItemRelativePath":""}],"CopyToOutputEntries":[]} \ No newline at end of file diff --git a/Asap2/Asap2.Language.analyzer.lex b/Asap2/Asap2.Language.analyzer.lex index 0431eb8..2949d13 100644 --- a/Asap2/Asap2.Language.analyzer.lex +++ b/Asap2/Asap2.Language.analyzer.lex @@ -217,6 +217,7 @@ TransportProtocolVersion { return Make(Token.TransportProtocolVersion); } USDTP_TIMING_DEFAULTS { return Make(Token.USDTP_TIMING_DEFAULTS); } USDTP_TIMING { return Make(Token.USDTP_TIMING); } KP_BLOB { return Make(Token.KP_BLOB); } +DEFAULT_EVENT_LIST { return Make(Token.DEFAULT_EVENT_LIST); } A2ML { yy_push_state (STATE_A2ML); yylval.sb = new StringBuilder(); } "\/include" { yy_push_state(STATE_INCL); } \" { yy_push_state(STATE_STRING); yylval.sb = new StringBuilder(); } diff --git a/Asap2/Asap2.Language.grammar.y b/Asap2/Asap2.Language.grammar.y index c82a64f..7704912 100644 --- a/Asap2/Asap2.Language.grammar.y +++ b/Asap2/Asap2.Language.grammar.y @@ -93,6 +93,7 @@ public PAGE_SWITCH page_switch; public SESSION session; public KP_BLOB kp_blob; + public DEFAULT_EVENT_LIST default_event_list; public TransportProtocolVersion transportProtocolVersion; } @@ -281,6 +282,7 @@ %token USDTP_TIMING_DEFAULTS %token USDTP_TIMING %token KP_BLOB +%token DEFAULT_EVENT_LIST %token maxParseToken COMMENT @@ -368,6 +370,7 @@ %type daq_list %type daq_list_data %type cal_param_group +%type cal_param_group_data %type protocol_layer %type protocol_layer_data %type page @@ -433,6 +436,8 @@ %type transportProtocolVersion_data %type kp_blob %type kp_blob_data +%type default_event_list +%type default_event_list_data %% Asap2File @@ -1487,6 +1492,27 @@ daq_event_data : IDENTIFIER IDENTIFIER NUMBER{ // TODO: Implement $$ = new DAQ_EVENT(@$, $3); } + | IDENTIFIER { + // TODO: Implement + $$ = new DAQ_EVENT(@$, $1); + } + | daq_event_data default_event_list { + $$ = $1; + $$.default_event_list = $2; + } + ; +default_event_list : BEGIN DEFAULT_EVENT_LIST default_event_list_data END DEFAULT_EVENT_LIST { + $$ = $3; + } + ; + +default_event_list_data : { + $$ = new DEFAULT_EVENT_LIST(@$); + } + | default_event_list_data IDENTIFIER NUMBER { + $$ = $1; + $$.events.Add($3); + } ; @@ -1495,9 +1521,9 @@ daq : BEGIN DAQ daq_data END DAQ { } ; -daq_data : IDENTIFIER NUMBER NUMBER NUMBER IDENTIFIER IDENTIFIER IDENTIFIER IDENTIFIER NUMBER IDENTIFIER IDENTIFIER{ +daq_data : IDENTIFIER NUMBER NUMBER NUMBER IDENTIFIER_list NUMBER IDENTIFIER_list{ //TODO: Implement constructor - $$ = new DAQ(@$); + $$ = new DAQ(@$, $1, $2, $3, $4, $5, $6, $7); } | daq_data timestamp_supported { $$ = $1; @@ -1522,6 +1548,10 @@ daq_list_data : NUMBER IDENTIFIER IDENTIFIER IDENTIFIER NUMBER IDENTIFIER NUMBER //TODO: Implement constructor $$ = new DAQ_LIST(@$, $1, $3, $5, $7, $9); } + | NUMBER IDENTIFIER IDENTIFIER IDENTIFIER NUMBER IDENTIFIER NUMBER IDENTIFIER NUMBER IDENTIFIER NUMBER{ + //TODO: Implement constructor + $$ = new DAQ_LIST(@$, $1, $3, $5, $7, $9, $11); + } ; event : BEGIN EVENT event_data END EVENT { @@ -1580,28 +1610,36 @@ page : BEGIN PAGE page_data END PAGE { } ; page_data : NUMBER IDENTIFIER IDENTIFIER IDENTIFIER { + //Todo: Implement PAGE constructor //$$ = $1; //$$ = new PAGE(@$, $1, $1, $1, $1, $1) } ; cal_param_group : BEGIN CAL_PARAM_GROUP cal_param_group_data END CAL_PARAM_GROUP { - //$$ = $3; + $$ = $3; } ; cal_param_group_data : IDENTIFIER QUOTED_STRING IDENTIFIER NUMBER IDENTIFIER NUMBER IDENTIFIER QUOTED_STRING NUMBER NUMBER NUMBER NUMBER{ - //$$ = new CAL_PARAM_GROUP(@$); + // Todo: Give good names to properties + $$ = new CAL_PARAM_GROUP(@$, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12); }; -protocol_layer : BEGIN PROTOCOL_LAYER protocol_layer_data END PROTOCOL_LAYER { +protocol_layer : BEGIN PROTOCOL_LAYER protocol_layer_data END PROTOCOL_LAYER { $$ = $3; } ; protocol_layer_data : NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER IDENTIFIER_list{ - //TODO: Implement constructor - //$$ = new CAL_PARAM_GROUP(@$); + $$ = new PROTOCOL_LAYER(@$, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11); + } + | NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER IDENTIFIER_list QUOTED_STRING{ + $$ = new PROTOCOL_LAYER(@$, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12); + } + | protocol_layer_data OPTIONAL_CMD IDENTIFIER { + $$ = $1; + $$.optional_cmd.Add($3); }; diff --git a/Asap2/Asap2.Parser.cs b/Asap2/Asap2.Parser.cs index 58c6273..557df3c 100644 --- a/Asap2/Asap2.Parser.cs +++ b/Asap2/Asap2.Parser.cs @@ -27,7 +27,7 @@ private object EnumToStringOrAbort(Type type, string strIn) { return Enum.Parse(type, strIn); } - catch (ArgumentException e) + catch (ArgumentException) { StringBuilder values = new StringBuilder(); string[] myArray = Enum.GetNames(type); diff --git a/Asap2/Asap2.csproj b/Asap2/Asap2.csproj index eda9776..67f4b72 100644 --- a/Asap2/Asap2.csproj +++ b/Asap2/Asap2.csproj @@ -80,6 +80,7 @@ + diff --git a/Asap2/Asap2Tree/AXIS_PTS.cs b/Asap2/Asap2Tree/AXIS_PTS.cs index aff0948..19642cb 100644 --- a/Asap2/Asap2Tree/AXIS_PTS.cs +++ b/Asap2/Asap2Tree/AXIS_PTS.cs @@ -42,7 +42,6 @@ public AXIS_PTS(Location location, string Name, string LongIdentifier, UInt64 Ad /// /// Reference to the relevant record of the description of the conversion method (see ). - /// If there is no conversion method, as in the case of , /// the parameter ‘Conversion’ should be set to “NO_COMPU_METHOD" (measurement and calibration systems must be able to handle this case). /// [Element(7, IsArgument = true, Comment = " Conversion ")] diff --git a/Asap2/Asap2Tree/CAL_PARAM_GROUP.cs b/Asap2/Asap2Tree/CAL_PARAM_GROUP.cs index 87b9782..5634e2a 100644 --- a/Asap2/Asap2Tree/CAL_PARAM_GROUP.cs +++ b/Asap2/Asap2Tree/CAL_PARAM_GROUP.cs @@ -21,5 +21,34 @@ public class CAL_PARAM_GROUP : Asap2Base public CAL_PARAM_GROUP(Location location) : base(location) { } + + public CAL_PARAM_GROUP(Location location, string s1, string s2, string s3, decimal d1, string s4, decimal d2, string s5, string s6, decimal d3, decimal d4, decimal d5, decimal d6) : this(location) + { + S1 = s1; + S2 = s2; + S3 = s3; + D1 = d1; + S4 = s4; + D2 = d2; + S5 = s5; + S6 = s6; + D3 = d3; + D4 = d4; + D5 = d5; + D6 = d6; + } + + public string S1 { get; } + public string S2 { get; } + public string S3 { get; } + public decimal D1 { get; } + public string S4 { get; } + public decimal D2 { get; } + public string S5 { get; } + public string S6 { get; } + public decimal D3 { get; } + public decimal D4 { get; } + public decimal D5 { get; } + public decimal D6 { get; } } } diff --git a/Asap2/Asap2Tree/CHARACTERISTIC.cs b/Asap2/Asap2Tree/CHARACTERISTIC.cs index 1a44c2d..a1291be 100644 --- a/Asap2/Asap2Tree/CHARACTERISTIC.cs +++ b/Asap2/Asap2Tree/CHARACTERISTIC.cs @@ -51,7 +51,6 @@ public CHARACTERISTIC(Location location, string Name, string LongIdentifier, Typ /// /// Reference to the relevant record of the description of the conversion method (see ). - /// If there is no conversion method, as in the case of , /// the parameter ‘Conversion’ should be set to “NO_COMPU_METHOD" (measurement and calibration systems must be able to handle this case). /// [Element(7, IsArgument = true, Comment = " Conversion ")] diff --git a/Asap2/Asap2Tree/DAQ.cs b/Asap2/Asap2Tree/DAQ.cs index 2f7b38a..54a5238 100644 --- a/Asap2/Asap2Tree/DAQ.cs +++ b/Asap2/Asap2Tree/DAQ.cs @@ -17,8 +17,27 @@ public DAQ(Location location) : base(location) { } + + public DAQ(Location location, string s, decimal d1, decimal d2, decimal d3, List iDENTIFIER_list1, decimal d4, List iDENTIFIER_list2) : this(location) + { + S = s; + D1 = d1; + D2 = d2; + D3 = d3; + IDENTIFIER_list1 = iDENTIFIER_list1; + D4 = d4; + IDENTIFIER_list2 = iDENTIFIER_list2; + } + public TIMESTAMP_SUPPORTED timestamp_supported { get; set; } public DAQ_LIST daq_list { get; set; } + public string S { get; } + public decimal D1 { get; } + public decimal D2 { get; } + public decimal D3 { get; } + public List IDENTIFIER_list1 { get; } + public decimal D4 { get; } + public List IDENTIFIER_list2 { get; } public List events = new List(); diff --git a/Asap2/Asap2Tree/DAQ_EVENT.cs b/Asap2/Asap2Tree/DAQ_EVENT.cs index 3c70744..9b86c94 100644 --- a/Asap2/Asap2Tree/DAQ_EVENT.cs +++ b/Asap2/Asap2Tree/DAQ_EVENT.cs @@ -23,7 +23,18 @@ public DAQ_EVENT(Location location, decimal eventid) : base(location) this.eventid = eventid; } + public DAQ_EVENT(Location location, string eventType) : base(location) + { + this.eventType = eventType; + } + [Element(1, IsArgument = true, Name = "EVENTID")] public decimal eventid { get; private set; } + + [Element(3, IsArgument = true, Name = "EVENT_TYPE")] + public string eventType { get; private set; } + + public List events = new List(); + public DEFAULT_EVENT_LIST default_event_list { get; set; } } } diff --git a/Asap2/Asap2Tree/DAQ_LIST.cs b/Asap2/Asap2Tree/DAQ_LIST.cs index 931c0cc..2741518 100644 --- a/Asap2/Asap2Tree/DAQ_LIST.cs +++ b/Asap2/Asap2Tree/DAQ_LIST.cs @@ -14,18 +14,19 @@ public class DAQ_LIST : Asap2Base /// Characteristic types /// - public DAQ_LIST(Location location, decimal listNumber, string daq_list_type, decimal maxOdt, decimal maxOdtEntries, decimal firstPid) : base(location) + public DAQ_LIST(Location location, decimal listNumber, string daq_list_type, decimal maxOdt, decimal maxOdtEntries, decimal firstPid, decimal? eventFixed = null) : base(location) { this.listNumber = listNumber; this.daq_list_type = daq_list_type; this.maxOdt = maxOdt; this.maxOdtEntries = maxOdtEntries; this.firstPid = firstPid; + this.eventFixed = eventFixed; } [Element(1, IsArgument = true)] - public decimal listNumber{ get; private set; } + public decimal listNumber { get; private set; } [Element(2, IsArgument = true)] public string daq_list_type { get; private set; } @@ -35,5 +36,7 @@ public DAQ_LIST(Location location, decimal listNumber, string daq_list_type, dec public decimal maxOdtEntries { get; private set; } [Element(5, IsArgument = true)] public decimal firstPid { get; private set; } + [Element(5, IsArgument = true)] + public decimal? eventFixed { get; private set; } } } diff --git a/Asap2/Asap2Tree/DEFAULT_EVENT_LIST.cs b/Asap2/Asap2Tree/DEFAULT_EVENT_LIST.cs new file mode 100644 index 0000000..e92e48d --- /dev/null +++ b/Asap2/Asap2Tree/DEFAULT_EVENT_LIST.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Asap2 +{ + public class DEFAULT_EVENT_LIST : Asap2Base + { + /// + /// Characteristic types + /// + + public DEFAULT_EVENT_LIST(Location location) : base(location) + { + + } + + public List events = new List(); + + } +} diff --git a/Asap2/Asap2Tree/FileComment.cs b/Asap2/Asap2Tree/FileComment.cs index f938868..53e013d 100644 --- a/Asap2/Asap2Tree/FileComment.cs +++ b/Asap2/Asap2Tree/FileComment.cs @@ -27,6 +27,7 @@ public FileComment(string comment = null, bool startNewLineWithStar = false) : b /// /// Default constructor. /// + /// /// First comment line. /// Indicates if each comment line shall start with a *. public FileComment(Location location, string comment = null, bool startNewLineWithStar = false) : base(location) diff --git a/Asap2/Asap2Tree/MEASUREMENT.cs b/Asap2/Asap2Tree/MEASUREMENT.cs index d72e495..6862c25 100644 --- a/Asap2/Asap2Tree/MEASUREMENT.cs +++ b/Asap2/Asap2Tree/MEASUREMENT.cs @@ -35,7 +35,6 @@ public MEASUREMENT(Location location, string Name, string LongIdentifier, DataTy /// /// Reference to the relevant record of the description of the conversion method (see ). - /// If there is no conversion method, as in the case of , /// the parameter ‘Conversion’ should be set to “NO_COMPU_METHOD" (measurement and calibration systems must be able to handle this case). /// [Element(4, IsArgument = true, Comment = " Conversion ")] diff --git a/Asap2/Asap2Tree/PROTOCOL_LAYER.cs b/Asap2/Asap2Tree/PROTOCOL_LAYER.cs index 25027af..46cae26 100644 --- a/Asap2/Asap2Tree/PROTOCOL_LAYER.cs +++ b/Asap2/Asap2Tree/PROTOCOL_LAYER.cs @@ -13,5 +13,36 @@ public class PROTOCOL_LAYER : Asap2Base public PROTOCOL_LAYER(Location location) : base(location) { } + + public PROTOCOL_LAYER(Location location, decimal d1, decimal d2, decimal d3, decimal d4, decimal d5, decimal d6, decimal d7, decimal d8, decimal d9, decimal d10, List iDENTIFIER_list, string SEED_AND_KEY_EXTERNAL_FUNCTION = null) : this(location) + { + this.D1 = d1; + this.D2 = d2; + this.D3 = d3; + this.D4 = d4; + this.D5 = d5; + this.D6 = d6; + this.D7 = d7; + this.D8 = d8; + this.D9 = d9; + this.D10 = d10; + this.IDENTIFIER_list = iDENTIFIER_list; + this.SEED_AND_KEY_EXTERNAL_FUNCTION = SEED_AND_KEY_EXTERNAL_FUNCTION; + } + + public List optional_cmd = new List(); + + public decimal D1 { get; } + public decimal D2 { get; } + public decimal D3 { get; } + public decimal D4 { get; } + public decimal D5 { get; } + public decimal D6 { get; } + public decimal D7 { get; } + public decimal D8 { get; } + public decimal D9 { get; } + public decimal D10 { get; } + public string SEED_AND_KEY_EXTERNAL_FUNCTION { get; private set; } + public List IDENTIFIER_list { get; } } } diff --git a/Asap2/ShiftReduceParserCode.cs b/Asap2/ShiftReduceParserCode.cs index ee4acff..adc5c73 100644 --- a/Asap2/ShiftReduceParserCode.cs +++ b/Asap2/ShiftReduceParserCode.cs @@ -66,6 +66,7 @@ protected ShiftReduceParser(AbstractScanner scanner) "QP_BLOB IDENTIFIER", "MEASUREMENT IDENTIFIER", "FLASH IDENTIFIER", + "ADDRESS IDENTIFIER", }; private void ReadReidentification() diff --git a/Asap2/tools/Remover.cs b/Asap2/tools/Remover.cs index 39df8c0..f14e004 100644 --- a/Asap2/tools/Remover.cs +++ b/Asap2/tools/Remover.cs @@ -14,7 +14,6 @@ public class Remover /// Asap2 to delete elements from. /// Element types to remove /// Common options - /// Name of module to remove elements from. If not specified the first module is used. static public void RemoveAllElements(ref MODULE module, Options.ElementTypes elementsToDelete, Options options) { { diff --git a/Asap2Test/Program.cs b/Asap2Test/Program.cs index 1d7c818..4aedeab 100644 --- a/Asap2Test/Program.cs +++ b/Asap2Test/Program.cs @@ -17,7 +17,7 @@ static void Main(string[] args) { var errorHandler = new ErrorHandler(); //var parser = new Asap2.Parser("../../../FCR-21_Dev.A2L", errorHandler); - var parser = new Asap2.Parser("../../../4.a2l", errorHandler); + var parser = new Asap2.Parser("../../../UnitTest/TestData/GDI-2.A2L", errorHandler); Asap2.FileComment comment = new Asap2.FileComment(Environment.NewLine + "A2l file for testing ASAP2 parser." + Environment.NewLine, true); Asap2.Asap2File tree = parser.DoParse(); if (tree != null) diff --git a/UnitTest/.vs/UnitTest.csproj.dtbcache.json b/UnitTest/.vs/UnitTest.csproj.dtbcache.json index 1f63b98..329fdcf 100644 --- a/UnitTest/.vs/UnitTest.csproj.dtbcache.json +++ b/UnitTest/.vs/UnitTest.csproj.dtbcache.json @@ -1 +1 @@ -{"RootPath":"C:\\Users\\Ichiro\\source\\repos\\CSI-PROM\\UnitTest","ProjectFileName":"UnitTest.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[],"References":[],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"C:\\Users\\Ichiro\\source\\repos\\CSI-PROM\\UnitTest\\bin\\Debug\\UnitTest.dll","OutputItemRelativePath":"UnitTest.dll"},{"OutputItemFullPath":"","OutputItemRelativePath":""}],"CopyToOutputEntries":[]} \ No newline at end of file +{"RootPath":"C:\\Projects\\Tests\\Asap2\\UnitTest","ProjectFileName":"UnitTest.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"A2LFileTests.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"Startup.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.8.AssemblyAttributes.cs"}],"References":[{"Reference":"C:\\Projects\\Tests\\Asap2\\Asap2\\bin\\Debug\\Asap2.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":true,"ProjectPath":"C:\\Projects\\Tests\\Asap2\\Asap2\\bin\\Debug\\Asap2.dll"},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\Common7\\IDE\\PublicAssemblies\\System.Numerics.Vectors.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"C:\\Projects\\Tests\\Asap2\\UnitTest\\bin\\Debug\\UnitTest.dll","OutputItemRelativePath":"UnitTest.dll"},{"OutputItemFullPath":"","OutputItemRelativePath":""}],"CopyToOutputEntries":[]} \ No newline at end of file