/// <summary> /// A,J /// </summary> Item(SecsFormat format, string value, Encoding encoder) { Format = format; Count = value.Length; Value = value; _sml = Lazy.Create(value); _rawBytes = Lazy.Create(() => { string str = (string)Value; int headerLength; byte[] result = Format.EncodeItem(str.Length, out headerLength); encoder.GetBytes(str, 0, str.Length, result, headerLength); return(new RawData(result)); }); }
/// <summary> /// U2,U4,U8 /// I1,I2,I4,I8 /// F4,F8 /// Boolean /// </summary> Item(SecsFormat format, Array value, Func <string> sml) { Format = format; Count = value.Length; Value = value; _sml = Lazy.Create(sml); _rawBytes = Lazy.Create(() => { Array val = (Array)Value; int bytelength = Buffer.ByteLength(val); int headerLength; byte[] result = Format.EncodeItem(bytelength, out headerLength); Buffer.BlockCopy(val, 0, result, headerLength, bytelength); result.Reverse(headerLength, headerLength + bytelength, bytelength / val.Length); return(new RawData(result)); }); }