Open aarmando73 opened 10 months ago
Sorry, ValueTimeStampArray fix (no Vlq in items):
public static ValueTimestampArray Deserialize(Stream buffer, byte flags, bool disableVlq)
{
UInt64[] value;
UInt32 size = 0;
if (!disableVlq)
{
S7p.DecodeUInt32Vlq(buffer, out size);
}
else
{
S7p.DecodeUInt32(buffer, out size);
}
value = new UInt64[size];
for (int i = 0; i < size; i++)
{
S7p.DecodeUInt64(buffer, out value[i]);
}
return new ValueTimestampArray(value, flags);
}
Hi Alberto, thank you for the code, I'll add this. The "disableVlq" option is kind of "addon", which is (so far) only needed in the SystemEvents. And I'm not sure if it's then allowed for all values, or if the Siemens programmer who implemented the SystemEvents, didn't know how other methods do the encoding (it seems to be that there are other codeparts in a similar manner, e.g. switching the endianess).
Is there a way to produce these arrays? I've never seen them.
Yes, with an array of LTIME(ValueTimeSpanArray) and LDT (ValueTimeStampArray) I know, may be it is not really necessary in a SCADA environment, but I'm testing systematically all these data types (combined in different sequences and array or not):
BOOL
BYTE
WORD
DWORD
LWORD
SINT
INT
DINT
USINT
UINT
UDINT
LINT
ULINT
REAL
LREAL
S5TIME
TIME
LTIME
DATE
TIME_OF_DAY (TOD)
TIME_OF_DAY (LTOD)
DATE_AND_TIME (DT)
LDT
DTL
CHAR
WCHAR
STRING
WSTRING
another error of mine in TimestampArray (forgot array length): public override int Serialize(Stream buffer) { int ret = 0; ret += S7p.EncodeByte(buffer, DatatypeFlags); ret += S7p.EncodeByte(buffer, Datatype.Timestamp); ret += S7p.EncodeUInt32Vlq(buffer, (uint)Value.Length); for (int i = 0; i < Value.Length; i++) { ret += S7p.EncodeUInt64(buffer, Value[i]); } return ret; }__
Here is the code I'm using, you will probably need to verify it before merging...
I shared the ToString method (so I modified also ValueTimestamp and ValueTimeSpan):