예제 #1
0
        public byte[] SetCounter(int address, string specialName, List <string> nameCounters, int add)
        {
            int _counterCount = nameCounters.Count();

            int addressCouOther = 100;

            byte[] _data = new byte[] { (byte)_counterCount };

            byte[] _temp;

            foreach (var s in nameCounters)
            {
                var lengData = _data.Length;
                _temp = new byte[lengData + s.Length * 4 + 2];

                Array.Copy(_data, _temp, lengData);
                //var add = dicKeyAdd.FirstOrDefault(m => m.Value.CounterID == s.Id).Key;
                byte byteAdd;
                if (add == 0)
                {
                    add = addressCouOther;
                    addressCouOther++;
                }

                byteAdd         = Convert.ToByte("" + add);
                _temp[lengData] = byteAdd;

                var _d = MRW_Common.ConvertStringToByte(s, true);

                Buffer.BlockCopy(_d, 0, _temp, lengData + 1, _d.Length);

                _data = _temp;
            }

            _temp = new byte[_data.Length + specialName.Length * 4 + 1];

            var _dSpecial = MRW_Common.ConvertStringToByte(specialName, true);

            Buffer.BlockCopy(_data, 0, _temp, _dSpecial.Length, _data.Length);
            Buffer.BlockCopy(_dSpecial, 0, _temp, 0, _dSpecial.Length);

            return(Build(deviceID, address, (int)RecivedCommand.SetCounter, _temp));
        }
예제 #2
0
        public byte[] SetService(int address, List <string> services)
        {
            int _serviceCount = services.Count();

            byte[] _data = new byte[] { (byte)_serviceCount };

            byte[] _temp;

            foreach (var s in services)
            {
                _temp = new byte[_data.Length + s.Length * 4 + 1];

                Array.Copy(_data, _temp, _data.Length);

                var _d = MRW_Common.ConvertStringToByte(s, true);

                Buffer.BlockCopy(_d, 0, _temp, _data.Length, _d.Length);

                _data = _temp;
            }

            return(Build(deviceID, address, (int)RecivedCommand.SetService, _data));
        }