@@ -20,6 +20,7 @@ namespace S7CommPlusDriver.Alarming
2020{
2121 public class AlarmsAlarmTexts
2222 {
23+ public int LanguageId ;
2324 public string Infotext = String . Empty ;
2425 public string AlarmText = String . Empty ;
2526 public string AdditionalText1 = String . Empty ;
@@ -31,65 +32,74 @@ public class AlarmsAlarmTexts
3132 public string AdditionalText7 = String . Empty ;
3233 public string AdditionalText8 = String . Empty ;
3334 public string AdditionalText9 = String . Empty ;
34-
35+
3536 // These two values we get in addition when browsing for the alarmtexts
3637 // Don't know if they are useful for something.
3738 public ushort UnknownValue1 ;
3839 public ushort UnknownValue2 ;
3940
40- public static AlarmsAlarmTexts FromNotificationBlob ( ValueBlobSparseArray blob )
41+ public static AlarmsAlarmTexts FromNotificationBlob ( ValueBlobSparseArray blob , int languageId )
4142 {
4243 var at = new AlarmsAlarmTexts ( ) ;
4344 string s ;
45+ int lcid ;
46+ int textid ;
47+ at . LanguageId = languageId ;
4448 foreach ( var v in blob . Value )
4549 {
4650 s = Utils . GetUtfString ( v . Value . value , 0 , ( uint ) v . Value . value . Length ) ;
4751 // Values in older CPUs, from: 0xa09c8001..0xa09c800b (2694610945..2694610955)
4852 // Current CPUs use: 0x04070001..0x0407000b ( 67567617.. 67567627)
49- // Did they change the key-values? Or depending on CPU?
50- switch ( v . Key )
53+ // Where the left word is the language ID, 0x0407 = 1031, and the right word is the text id.
54+ // The blob may contain several languages. If you need them all, you need to call this multiple times.
55+ lcid = ( int ) ( v . Key >> 16 ) ;
56+ textid = ( int ) ( v . Key & 0xffff ) ;
57+ if ( lcid == languageId )
5158 {
52- case 67567617 :
53- at . Infotext = s ;
54- break ;
55- case 67567618 :
56- at . AlarmText = s ;
57- break ;
58- case 67567619 :
59- at . AdditionalText1 = s ;
60- break ;
61- case 67567620 :
62- at . AdditionalText2 = s ;
63- break ;
64- case 67567621 :
65- at . AdditionalText3 = s ;
66- break ;
67- case 67567622 :
68- at . AdditionalText4 = s ;
69- break ;
70- case 67567623 :
71- at . AdditionalText5 = s ;
72- break ;
73- case 67567624 :
74- at . AdditionalText6 = s ;
75- break ;
76- case 67567625 :
77- at . AdditionalText7 = s ;
78- break ;
79- case 67567626 :
80- at . AdditionalText8 = s ;
81- break ;
82- case 67567627 :
83- at . AdditionalText9 = s ;
84- break ;
59+ switch ( textid )
60+ {
61+ case 1 :
62+ at . Infotext = s ;
63+ break ;
64+ case 2 :
65+ at . AlarmText = s ;
66+ break ;
67+ case 3 :
68+ at . AdditionalText1 = s ;
69+ break ;
70+ case 4 :
71+ at . AdditionalText2 = s ;
72+ break ;
73+ case 5 :
74+ at . AdditionalText3 = s ;
75+ break ;
76+ case 6 :
77+ at . AdditionalText4 = s ;
78+ break ;
79+ case 7 :
80+ at . AdditionalText5 = s ;
81+ break ;
82+ case 8 :
83+ at . AdditionalText6 = s ;
84+ break ;
85+ case 9 :
86+ at . AdditionalText7 = s ;
87+ break ;
88+ case 10 :
89+ at . AdditionalText8 = s ;
90+ break ;
91+ case 11 :
92+ at . AdditionalText9 = s ;
93+ break ;
94+ }
8595 }
8696 }
8797 return at ;
8898 }
8999
90100 public override string ToString ( )
91101 {
92- string s = "<AlarmsAlarmTexts>" + Environment . NewLine ;
102+ string s = "<AlarmsAlarmTexts LanguageId= \" " + LanguageId . ToString ( ) + " \" >" + Environment . NewLine ;
93103 s += "<Infotext>" + Infotext . ToString ( ) + "</Infotext>" + Environment . NewLine ;
94104 s += "<AlarmText>" + AlarmText . ToString ( ) + "</AlarmText>" + Environment . NewLine ;
95105 s += "<AdditionalText1>" + AdditionalText1 . ToString ( ) + "</AdditionalText1>" + Environment . NewLine ;
0 commit comments