This commit is contained in:
2026-04-17 14:55:32 -04:00
commit bc3ac1d4c9
18017 changed files with 4371742 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Text;
using DTS.Common.Utils;
using DTS.DASLib.Command.SLICE;
namespace DTS.Slice.Service
{
public class Attribute
{
protected enum AttributeInterface { Arm, Event, System, User }
protected AttributeInterface Store { get; set; }
protected AttributeTypes.AttributeDataTypes datatype;
protected ushort key;
protected object value;
public const int MaxSingleAttributeSize = 500;
public const int BulkAttributeStartNumber = 3000;
//public AttributeStore Store { get { return _store; } }
//public UInt16 StoreNumber { get { return _storenumber; } set { _storenumber = value; } }
//public UInt16 Location { get { return _location; } set { _location = value; } }
//public AttributeTypes.AttributeDataTypes DataType { get { return _datatype; } }
//public string Description { get { return _description; } }
//public byte TypeValue { get { return _typevalue; } }
//protected byte[] Data { get { return _data; } set { _data = value; } }
//public int Length { get { if (null == _data) return 0; else return _data.Length; } }
protected Dictionary<byte, double> ByteArrayToDict(byte[] bytes)
{
// The dictionary will be transported as
// pairs consisting of one byte + 8 bytes for the double
byte k;
double val;
const int PairLength = sizeof(byte) + sizeof(double);
int NumberOfPairs = bytes.Length / PairLength;
int offset = 0;
var dict = new Dictionary<byte, double>(NumberOfPairs);
for (int idx = 0; idx < NumberOfPairs; idx++)
{
ByteConvertor.Convert(bytes, offset, out k);
offset += sizeof(byte);
ByteConvertor.Convert(bytes, offset, out val);
offset += sizeof(double);
dict.Add(k, val);
}
return dict;
}
protected byte[] DictToByteArray(Dictionary<byte, double> dict)
{
var NumberOfPairs = dict.Count;
var byteArray = new byte[(sizeof(byte) + sizeof(double)) * NumberOfPairs];
int offset = 0;
foreach (var pair in dict)
{
byteArray[offset] = pair.Key;
offset += sizeof(byte);
Array.Copy(ByteConvertor.ToByteArray(pair.Value), 0, byteArray, offset, sizeof(double));
offset += sizeof(double);
}
return byteArray;
}
protected Attribute()
{
}
}
}