Repository navigation
Expand file tree
/
Copy pathJobReader.cs
More file actions
1118 lines (944 loc) · 45 KB
/
Copy pathJobReader.cs
File metadata and controls
1118 lines (944 loc) · 45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using System;
using System.Collections.Generic;
using System.IO;
using System.Xml;
using System.Xml.XPath;
using EdiabasLib;
namespace BmwDeepObd
{
public class JobReader
{
public class DisplayInfo
{
public DisplayInfo(int originalPosition, string name, string result, string ecuJobId, string ecuJobResultId, string format, UInt32? displayOrder, GridModeType gridType, double minValue, double maxValue, string logTag)
{
OriginalPosition = originalPosition;
Name = name;
Result = result;
EcuJobId = ecuJobId;
EcuJobResultId = ecuJobResultId;
Format = format;
DisplayOrder = displayOrder;
GridType = gridType;
MinValue = minValue;
MaxValue = maxValue;
LogTag = logTag;
}
public enum GridModeType
{
Hidden,
Text,
// ReSharper disable InconsistentNaming
Simple_Gauge_Square,
Simple_Gauge_Round,
Simple_Gauge_Dot,
// ReSharper restore InconsistentNaming
}
public int OriginalPosition { get; }
public string Name { get; }
public string Result { get; }
public string EcuJobId { get; }
public string EcuJobResultId { get; }
public string Format { get; }
public UInt32? DisplayOrder { get; }
public GridModeType GridType { get; }
public double MinValue { get; }
public double MaxValue { get; }
public string LogTag { get; }
}
public class StringInfo
{
public StringInfo(string lang, Dictionary<string, string> stringDict)
{
Lang = lang;
StringDict = stringDict;
}
public string Lang { get; }
public Dictionary<string, string> StringDict { get; }
}
public class JobInfo
{
public JobInfo(string id, string sgbd, string name, string rawTelegrams, string fixedFuncStructId, string argsFirst, string args, string results, int argLimit)
{
Id = id;
Sgbd = sgbd;
Name = name;
RawTelegrams = rawTelegrams;
FixedFuncStructId = fixedFuncStructId;
ArgsFirst = argsFirst;
Args = args;
Results = results;
ArgLimit = argLimit;
UseCompatIds = false;
}
public string Id { get; }
public string Sgbd { get; }
public string Name { get; }
public string RawTelegrams { get; }
public string FixedFuncStructId { get; }
public string Args { get; }
public string ArgsFirst { get; }
public string Results { get; }
public int ArgLimit { get; set; }
public bool UseCompatIds { get; set; }
}
public class JobsInfo
{
public JobsInfo(string sgbd, string vagDataFileName, string vagUdsFileName, List<JobInfo> jobList)
{
Sgbd = sgbd;
VagDataFileName = vagDataFileName;
VagUdsFileName = vagUdsFileName;
JobList = jobList;
}
public string Sgbd { get; }
public string VagDataFileName { get; }
public string VagUdsFileName { get; }
public List<JobInfo> JobList { get; }
}
public class EcuInfo
{
public EcuInfo(string name, string sgbd, string vagDataFileName, string vagUdsFileName, string results)
{
Name = name;
Sgbd = sgbd;
VagDataFileName = vagDataFileName;
VagUdsFileName = vagUdsFileName;
Results = results;
}
public string Name { get; }
public string Sgbd { get; }
public string VagDataFileName { get; }
public string VagUdsFileName { get; }
public string Results { get; }
}
public class ErrorsInfo
{
public ErrorsInfo(string sgbdFunctional, string vehicleSeries, string bnType, string brandName, List<EcuInfo> ecuList)
{
SgbdFunctional = sgbdFunctional;
VehicleSeries = vehicleSeries;
BnType = bnType;
BrandName = brandName;
EcuList = ecuList;
}
public string SgbdFunctional { get; }
public string VehicleSeries { get; }
public string BnType { get; }
public string BrandName { get; }
public List<EcuInfo> EcuList { get; }
}
public class PageInfo
{
public PageInfo(string xmlFileName, string name, float weight, DisplayModeType displayMode, XmlToolActivity.DisplayFontSize? displayFontSize, int? gaugesPortrait, int? gaugesLandscape, string logFile, string dbName, bool jobActivate, string classCode, bool codeShowWarnings, JobsInfo jobsInfo, ErrorsInfo errorsInfo, List<DisplayInfo> displayList, List<StringInfo> stringList)
{
XmlFileName = xmlFileName;
Name = name;
Weight = weight;
DisplayMode = displayMode;
DisplayFontSize = displayFontSize;
GaugesPortrait = gaugesPortrait;
GaugesLandscape = gaugesLandscape;
LogFile = logFile;
DbName = dbName;
JobActivate = jobActivate;
ClassCode = classCode;
CodeShowWarnings = codeShowWarnings;
JobsInfo = jobsInfo;
ErrorsInfo = errorsInfo;
DisplayList = displayList;
StringList = stringList;
UpdateCompatIdUsage();
InfoObject = null;
ClassObject = null;
}
public enum DisplayModeType
{
List,
Grid,
}
public string XmlFileName { get; }
public string Name { get; }
public float Weight { get; }
public DisplayModeType DisplayMode { get; }
public XmlToolActivity.DisplayFontSize? DisplayFontSize { get; }
public int? TextResId
{
get
{
if (DisplayFontSize != null)
{
switch (DisplayFontSize.Value)
{
case XmlToolActivity.DisplayFontSize.Small:
return Android.Resource.Style.TextAppearanceSmall;
case XmlToolActivity.DisplayFontSize.Medium:
return Android.Resource.Style.TextAppearanceMedium;
case XmlToolActivity.DisplayFontSize.Large:
return Android.Resource.Style.TextAppearanceLarge;
}
}
return null;
}
}
public void UpdateCompatIdUsage()
{
UseCompatIds = false;
if (ActivityCommon.EcuFunctionsActive && ActivityCommon.EcuFunctionReader != null)
{
string dataId = ActivityCommon.EcuFunctionReader.FaultDataId;
if (string.Compare(DbName, dataId, StringComparison.OrdinalIgnoreCase) != 0)
{
UseCompatIds = true;
}
}
CompatIdsUsed = false;
if (JobsInfo != null)
{
foreach (JobInfo jobInfo in JobsInfo.JobList)
{
jobInfo.UseCompatIds = UseCompatIds;
if (UseCompatIds && !string.IsNullOrWhiteSpace(jobInfo.FixedFuncStructId))
{
CompatIdsUsed = true;
break;
}
}
}
}
public int? GaugesPortrait { get; }
public int GaugesPortraitValue => GaugesPortrait ?? GaugesPortraitDefault;
public int? GaugesLandscape { get; }
public int GaugesLandscapeValue => GaugesLandscape ?? GaugesLandscapeDefault;
public string LogFile { get; }
public string DbName { get; }
public bool JobActivate { get; }
public string ClassCode { get; }
public bool CodeShowWarnings { get; }
public JobsInfo JobsInfo { get; }
public ErrorsInfo ErrorsInfo { get; }
public List<DisplayInfo> DisplayList { get; }
public List<StringInfo> StringList { get; }
public bool UseCompatIds { get; private set; }
public bool CompatIdsUsed { get; private set; }
public object InfoObject { get; set; }
public object ClassObject { get; set; }
}
class DisplayInfoComparer : IComparer<DisplayInfo>
{
public int Compare(DisplayInfo x, DisplayInfo y)
{
if (x == null || y == null)
{
return 0;
}
if (x.DisplayOrder != null && y.DisplayOrder != null)
{
if (x.DisplayOrder.Value > y.DisplayOrder.Value)
{
return 1;
}
if (x.DisplayOrder.Value < y.DisplayOrder.Value)
{
return -1;
}
}
if (x.OriginalPosition > y.OriginalPosition)
{
return 1;
}
if (x.OriginalPosition < y.OriginalPosition)
{
return -1;
}
return 0;
}
}
public const string PageFontSize = "fontsize";
public const string PageGaugesPortrait = "gauges-portrait";
public const string PageGaugesLandscape = "gauges-landscape";
public const string DisplayNodeOrder = "display-order";
public const int GaugesPortraitDefault = 2;
public const int GaugesLandscapeDefault = 4;
private bool _configured;
private readonly List<PageInfo> _pageList = new List<PageInfo>();
private PageInfo _errorPage = null;
private string _ecuPath = string.Empty;
private string _simulationPath = string.Empty;
private string _logPath = string.Empty;
private bool _appendLog;
private bool _manualEdit;
private bool _logTagsPresent;
private bool _compatIdsUsed;
private bool _compatIdWarningShown;
private string _sgbdFunctional = string.Empty;
private string _interfaceName = string.Empty;
private string _vehicleSeries = string.Empty;
private string _bnType = string.Empty;
private string _brandName = string.Empty;
private string _manufacturerName = string.Empty;
private string _xmlFileNamePages = string.Empty;
private string _xmlFileName = string.Empty;
private ActivityCommon.ManufacturerType _manufacturerType = ActivityCommon.ManufacturerType.Bmw;
private ActivityCommon.InterfaceType _interfaceType = ActivityCommon.InterfaceType.None;
public bool Configured => _configured;
public List<PageInfo> PageList => _pageList;
public PageInfo ErrorPage => _errorPage;
public string EcuPath => _ecuPath;
public string SimulationPath => _simulationPath;
public string LogPath => _logPath;
public bool AppendLog => _appendLog;
public bool ManualEdit => _manualEdit;
public bool LogTagsPresent => _logTagsPresent;
public bool CompatIdsUsed => _compatIdsUsed;
public bool CompatIdWarningShown
{
get => _compatIdWarningShown;
set => _compatIdWarningShown = value;
}
public string SgbdFunctional => _sgbdFunctional;
public string ManufacturerName => _manufacturerName;
public string InterfaceName => _interfaceName;
public string VehicleSeries => _vehicleSeries;
public string BnType => _bnType;
public string BrandName => _brandName;
public string XmlFileNamePages => _xmlFileNamePages;
public string XmlFileName => _xmlFileName;
public ActivityCommon.ManufacturerType Manufacturer => _manufacturerType;
public ActivityCommon.InterfaceType Interface => _interfaceType;
public bool IsMotorbike
{
get
{
if (!string.IsNullOrEmpty(_bnType))
{
if (_bnType.Contains("MOTORBIKE", StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
if (!string.IsNullOrEmpty(_brandName))
{
if (_brandName.Contains("MOTORRAD", StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
return false;
}
}
public void UpdateCompatIdUsage()
{
_compatIdsUsed = false;
foreach (PageInfo pageInfo in _pageList)
{
pageInfo.UpdateCompatIdUsage();
if (pageInfo.CompatIdsUsed)
{
_compatIdsUsed = true;
}
}
}
public JobReader(bool configured)
{
_configured = configured;
}
private void Clear()
{
_pageList.Clear();
_errorPage = null;
_ecuPath = string.Empty;
_simulationPath = string.Empty;
_logPath = string.Empty;
_logTagsPresent = false;
_compatIdsUsed = false;
_compatIdWarningShown = false;
_sgbdFunctional = string.Empty;
_manufacturerName = string.Empty;
_interfaceName = string.Empty;
_vehicleSeries = string.Empty;
_bnType = string.Empty;
_brandName = string.Empty;
_xmlFileNamePages = string.Empty;
_xmlFileName = null;
}
public bool ReadXml(string xmlName, out string errorMessage)
{
errorMessage = null;
Clear();
if (string.IsNullOrEmpty(xmlName))
{
return false;
}
if (!File.Exists(xmlName))
{
return false;
}
string xmlDir = Path.GetDirectoryName(xmlName);
try
{
string prefix = string.Empty;
XmlDocument xdocConfig = XmlDocumentLoader.LoadWithIncludes(xmlName);
XmlNamespaceManager namespaceManager = new XmlNamespaceManager(xdocConfig.NameTable);
XPathNavigator xNav = xdocConfig.CreateNavigator();
if (xNav.MoveToFollowing(XPathNodeType.Element))
{
IDictionary<string, string> localNamespaces = xNav.GetNamespacesInScope(XmlNamespaceScope.Local);
if (localNamespaces.TryGetValue("", out string nameSpace))
{
namespaceManager.AddNamespace("carcontrol", nameSpace);
prefix = "carcontrol:";
}
}
XmlAttribute attrib;
XmlNode xnodeGlobal = xdocConfig.SelectSingleNode(string.Format("/{0}configuration/{0}global", prefix), namespaceManager);
if (xnodeGlobal?.Attributes != null)
{
attrib = xnodeGlobal.Attributes["ecu_path"];
if (attrib != null)
{
if (Path.IsPathRooted(attrib.Value))
{
_ecuPath = attrib.Value;
}
else
{
// ReSharper disable once AssignNullToNotNullAttribute
_ecuPath = string.IsNullOrEmpty(xmlDir) ? attrib.Value : Path.Combine(xmlDir, attrib.Value);
}
}
attrib = xnodeGlobal.Attributes["simulation_path"];
if (attrib != null)
{
if (Path.IsPathRooted(attrib.Value))
{
_simulationPath = attrib.Value;
}
else
{
// ReSharper disable once AssignNullToNotNullAttribute
_simulationPath = string.IsNullOrEmpty(xmlDir) ? attrib.Value : Path.Combine(xmlDir, attrib.Value);
}
}
attrib = xnodeGlobal.Attributes["log_path"];
if (attrib != null)
{
_logPath = attrib.Value;
}
attrib = xnodeGlobal.Attributes["append_log"];
if (attrib != null)
{
_appendLog = XmlConvert.ToBoolean(attrib.Value);
}
attrib = xnodeGlobal.Attributes["manual_edit"];
if (attrib != null)
{
_manualEdit = XmlConvert.ToBoolean(attrib.Value);
}
attrib = xnodeGlobal.Attributes["manufacturer"];
if (attrib != null)
{
_manufacturerName = attrib.Value;
}
attrib = xnodeGlobal.Attributes["interface"];
if (attrib != null)
{
_interfaceName = attrib.Value;
}
attrib = xnodeGlobal.Attributes["vehicle_series"];
if (attrib != null)
{
_vehicleSeries = attrib.Value;
}
attrib = xnodeGlobal.Attributes["bn_type"];
if (attrib != null)
{
_bnType = attrib.Value;
}
attrib = xnodeGlobal.Attributes["brand_name"];
if (attrib != null)
{
_brandName = attrib.Value;
}
}
if (string.Compare(_manufacturerName, "Audi", StringComparison.OrdinalIgnoreCase) == 0)
{
_manufacturerType = ActivityCommon.ManufacturerType.Audi;
}
else if (string.Compare(_manufacturerName, "Seat", StringComparison.OrdinalIgnoreCase) == 0)
{
_manufacturerType = ActivityCommon.ManufacturerType.Seat;
}
else if (string.Compare(_manufacturerName, "Skoda", StringComparison.OrdinalIgnoreCase) == 0)
{
_manufacturerType = ActivityCommon.ManufacturerType.Skoda;
}
else if (string.Compare(_manufacturerName, "VW", StringComparison.OrdinalIgnoreCase) == 0)
{
_manufacturerType = ActivityCommon.ManufacturerType.Vw;
}
else
{
_manufacturerType = ActivityCommon.ManufacturerType.Bmw;
}
bool isBmw = _manufacturerType == ActivityCommon.ManufacturerType.Bmw;
if (isBmw && string.Compare(_interfaceName, "ENET", StringComparison.OrdinalIgnoreCase) == 0)
{
_interfaceType = ActivityCommon.InterfaceType.Enet;
}
else if (isBmw && string.Compare(_interfaceName, "ELMWIFI", StringComparison.OrdinalIgnoreCase) == 0)
{
_interfaceType = ActivityCommon.InterfaceType.ElmWifi;
}
else if (string.Compare(_interfaceName, "DEEPOBDWIFI", StringComparison.OrdinalIgnoreCase) == 0)
{
_interfaceType = ActivityCommon.InterfaceType.DeepObdWifi;
}
else if (isBmw && string.Compare(_interfaceName, "FTDI", StringComparison.OrdinalIgnoreCase) == 0)
{
_interfaceType = ActivityCommon.InterfaceType.Ftdi;
}
else if (string.Compare(_interfaceName, "SIMULATION", StringComparison.OrdinalIgnoreCase) == 0)
{
_interfaceType = ActivityCommon.InterfaceType.Simulation;
}
else
{
_interfaceType = ActivityCommon.InterfaceType.Bluetooth;
}
XmlNode xnodePages = xdocConfig.SelectSingleNode(string.Format("/{0}configuration/{0}pages", prefix), namespaceManager);
if (xnodePages?.Attributes != null)
{
attrib = xnodePages.Attributes["include_filename"];
if (attrib != null) _xmlFileNamePages = attrib.Value;
}
XmlNodeList xnodesPage = xdocConfig.SelectNodes(string.Format("/{0}configuration/{0}pages/{0}page", prefix), namespaceManager);
if (xnodesPage != null)
{
foreach (XmlNode xnodePage in xnodesPage)
{
string pageName = string.Empty;
string xmlFileName = string.Empty;
float pageWeight = -1;
XmlToolActivity.DisplayFontSize? displayFontSize = null;
int? gaugesPortrait = null;
int? gaugesLandscape = null;
PageInfo.DisplayModeType displayMode = PageInfo.DisplayModeType.List;
string logFile = string.Empty;
string dbName = string.Empty;
bool jobActivate = false;
if (xnodePage.Attributes != null)
{
attrib = xnodePage.Attributes["include_filename"];
if (attrib != null) xmlFileName = attrib.Value;
attrib = xnodePage.Attributes["name"];
if (attrib != null) pageName = attrib.Value;
attrib = xnodePage.Attributes["weight"];
if (attrib != null)
{
try
{
pageWeight = XmlConvert.ToSingle(attrib.Value);
}
catch
{
// ignored
}
}
attrib = xnodePage.Attributes["display-mode"];
if (attrib != null)
{
if (!Enum.TryParse(attrib.Value, true, out displayMode))
{
displayMode = PageInfo.DisplayModeType.List;
}
}
attrib = xnodePage.Attributes[PageFontSize];
if (attrib != null)
{
string size = attrib.Value.ToLowerInvariant();
if (Enum.TryParse(size, true, out XmlToolActivity.DisplayFontSize fontSize))
{
displayFontSize = fontSize;
}
}
attrib = xnodePage.Attributes[PageGaugesPortrait];
if (attrib != null)
{
try
{
int gauges = XmlConvert.ToInt32(attrib.Value);
if (gauges >= 1)
{
gaugesPortrait = gauges;
}
}
catch
{
// ignored
}
}
attrib = xnodePage.Attributes[PageGaugesLandscape];
if (attrib != null)
{
try
{
int gauges = XmlConvert.ToInt32(attrib.Value);
if (gauges >= 1)
{
gaugesLandscape = gauges;
}
}
catch
{
// ignored
}
}
attrib = xnodePage.Attributes["logfile"];
if (attrib != null) logFile = attrib.Value;
attrib = xnodePage.Attributes["db_name"];
if (attrib != null) dbName = attrib.Value;
attrib = xnodePage.Attributes["activate"];
if (attrib != null)
{
try
{
jobActivate = XmlConvert.ToBoolean(attrib.Value);
}
catch (Exception)
{
// ignored
}
}
}
JobsInfo jobsInfo = null;
ErrorsInfo errorsInfo = null;
List<DisplayInfo> displayList = new List<DisplayInfo>();
List<StringInfo> stringList = new List<StringInfo>();
bool logEnabled = false;
string classCode = null;
bool codeShowWarnings = false;
foreach (XmlNode xnodePageChild in xnodePage.ChildNodes)
{
ReadDisplayNode(xnodePageChild, displayList, null, isBmw, ref logEnabled);
if (string.Compare(xnodePageChild.Name, "strings", StringComparison.OrdinalIgnoreCase) == 0)
{
string lang = null;
if (xnodePageChild.Attributes != null)
{
attrib = xnodePageChild.Attributes["lang"];
if (attrib != null) lang = attrib.Value;
}
Dictionary<string, string> stringDict = new Dictionary<string, string>();
foreach (XmlNode xnodeString in xnodePageChild.ChildNodes)
{
string text = xnodeString.InnerText;
string name = string.Empty;
if (xnodeString.Attributes != null)
{
attrib = xnodeString.Attributes["name"];
if (attrib != null) name = attrib.Value;
}
if (string.IsNullOrEmpty(name)) continue;
if (!stringDict.ContainsKey(name))
{
stringDict.Add(name, text);
}
}
stringList.Add(new StringInfo(lang, stringDict));
}
if (string.Compare(xnodePageChild.Name, "jobs", StringComparison.OrdinalIgnoreCase) == 0)
{
string sgbd = null;
string vagDataFileName = null;
string vagUdsFileName = null;
List<JobInfo> jobList = new List<JobInfo>();
if (xnodePageChild.Attributes != null)
{
attrib = xnodePageChild.Attributes["sgbd"];
if (attrib != null) sgbd = attrib.Value;
attrib = xnodePageChild.Attributes["vag_data_file"];
if (attrib != null) vagDataFileName = attrib.Value;
attrib = xnodePageChild.Attributes["vag_uds_file"];
if (attrib != null) vagUdsFileName = attrib.Value;
}
foreach (XmlNode xnodeJobsChild in xnodePageChild.ChildNodes)
{
if (string.Compare(xnodeJobsChild.Name, "job", StringComparison.OrdinalIgnoreCase) == 0)
{
string jobId = string.Empty;
string jobSgbd = string.Empty;
string jobName = string.Empty;
string jobRawTelegrams = string.Empty;
string jobFixedFuncStructId = string.Empty;
string jobArgsFirst = string.Empty;
string jobArgs = string.Empty;
string jobResults = string.Empty;
int argLimit = 0;
if (xnodeJobsChild.Attributes != null)
{
attrib = xnodeJobsChild.Attributes["id"];
if (attrib != null) jobId = attrib.Value;
attrib = xnodeJobsChild.Attributes["sgbd"];
if (attrib != null) jobSgbd = attrib.Value;
attrib = xnodeJobsChild.Attributes["name"];
if (attrib != null) jobName = attrib.Value;
attrib = xnodeJobsChild.Attributes["raw_telegrams"];
if (attrib != null) jobRawTelegrams = attrib.Value;
if (isBmw)
{
attrib = xnodeJobsChild.Attributes["fixed_func_struct_id"];
if (attrib != null) jobFixedFuncStructId = attrib.Value;
}
attrib = xnodeJobsChild.Attributes["args_first"];
if (attrib != null) jobArgsFirst = attrib.Value;
attrib = xnodeJobsChild.Attributes["args"];
if (attrib != null) jobArgs = attrib.Value;
attrib = xnodeJobsChild.Attributes["results"];
if (attrib != null) jobResults = attrib.Value;
attrib = xnodeJobsChild.Attributes["arg_limit"];
if (attrib != null)
{
try
{
argLimit = XmlConvert.ToInt32(attrib.Value);
}
catch
{
// ignored
}
}
}
jobList.Add(new JobInfo(jobId, jobSgbd, jobName, jobRawTelegrams, jobFixedFuncStructId, jobArgsFirst, jobArgs, jobResults, argLimit));
foreach (XmlNode xnodeJobChild in xnodeJobsChild.ChildNodes)
{
string nodePrefix = (string.IsNullOrEmpty(jobId) ? jobName : jobId);
if (!string.IsNullOrWhiteSpace(jobFixedFuncStructId))
{
nodePrefix = jobFixedFuncStructId;
}
ReadDisplayNode(xnodeJobChild, displayList, nodePrefix + "#", isBmw, ref logEnabled);
}
}
}
jobsInfo = new JobsInfo(sgbd, vagDataFileName, vagUdsFileName, jobList);
}
if (string.Compare(xnodePageChild.Name, "read_errors", StringComparison.OrdinalIgnoreCase) == 0)
{
string sgbdFunctional = string.Empty;
string vehicleSeries = string.Empty;
string bnType = string.Empty;
string brandName = string.Empty;
attrib = xnodePageChild.Attributes["sgbd_functional"];
if (attrib != null) sgbdFunctional = attrib.Value;
attrib = xnodePageChild.Attributes["vehicle_series"];
if (attrib != null) vehicleSeries = attrib.Value;
attrib = xnodePageChild.Attributes["bn_type"];
if (attrib != null) bnType = attrib.Value;
attrib = xnodePageChild.Attributes["brand_name"];
if (attrib != null) brandName = attrib.Value;
List<EcuInfo> ecuList = new List<EcuInfo>();
foreach (XmlNode xnodeErrorsChild in xnodePageChild.ChildNodes)
{
if (string.Compare(xnodeErrorsChild.Name, "ecu", StringComparison.OrdinalIgnoreCase) == 0)
{
string ecuName = string.Empty;
string sgbd = string.Empty;
string vagDataFileName = null;
string vagUdsFileName = null;
string results = "F_UW_KM";
if (xnodeErrorsChild.Attributes != null)
{
attrib = xnodeErrorsChild.Attributes["name"];
if (attrib != null) ecuName = attrib.Value;
attrib = xnodeErrorsChild.Attributes["sgbd"];
if (attrib != null) sgbd = attrib.Value;
attrib = xnodeErrorsChild.Attributes["vag_data_file"];
if (attrib != null) vagDataFileName = attrib.Value;
attrib = xnodeErrorsChild.Attributes["vag_uds_file"];
if (attrib != null) vagUdsFileName = attrib.Value;
attrib = xnodeErrorsChild.Attributes["results"];
if (attrib != null) results = attrib.Value;
}
ecuList.Add(new EcuInfo(ecuName, sgbd, vagDataFileName, vagUdsFileName, results));
}
}
errorsInfo = new ErrorsInfo(sgbdFunctional, vehicleSeries, bnType, brandName, ecuList);
}
if (string.Compare(xnodePageChild.Name, "code", StringComparison.OrdinalIgnoreCase) == 0)
{
classCode = xnodePageChild.InnerText;
attrib = xnodePageChild.Attributes["show_warnings"];
// ReSharper disable once ConvertIfStatementToNullCoalescingExpression
if (attrib == null)
{
// for backward compatibility
attrib = xnodePageChild.Attributes["show_warnigs"];
}
if (attrib != null)
{
try
{
codeShowWarnings = XmlConvert.ToBoolean(attrib.Value);
}
catch (Exception)
{
// ignored
}
}
}
}
if (!logEnabled)
{
logFile = string.Empty;
}
if (logEnabled)
{
_logTagsPresent = true;
}
if (string.IsNullOrEmpty(pageName))
{
continue;
}
if (string.IsNullOrWhiteSpace(classCode))
{
classCode = null;
}
_pageList.Add(new PageInfo(xmlFileName, pageName, pageWeight, displayMode, displayFontSize, gaugesPortrait, gaugesLandscape, logFile, dbName, jobActivate, classCode, codeShowWarnings, jobsInfo, errorsInfo, displayList, stringList));
}
}
UpdateCompatIdUsage();
foreach (PageInfo pageInfo in _pageList)
{
if (pageInfo.ErrorsInfo != null)
{
_errorPage = pageInfo;
if (string.IsNullOrEmpty(_vehicleSeries))
{
_vehicleSeries = pageInfo.ErrorsInfo.VehicleSeries;
}
if (string.IsNullOrEmpty(_sgbdFunctional))
{
_sgbdFunctional = pageInfo.ErrorsInfo.SgbdFunctional;
}
if (string.IsNullOrEmpty(_bnType))
{
_bnType = pageInfo.ErrorsInfo.BnType;
}
if (string.IsNullOrEmpty(_brandName))
{
_brandName = pageInfo.ErrorsInfo.BrandName;
}
}
}
_xmlFileName = xmlName;
return true;
}