Esempio n. 1
0
        public byte[] SetCounter(int address, string specialName, List <string> counters)
        {
            int _serviceCount = counters.Count();

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

            byte[] _temp;

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

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

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

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

                _data = _temp;
            }

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

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

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

            return(_modBus.Build(deviceID, address, (int)RecivedCommand.SetCounter, _temp));
        }
Esempio n. 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_Convert.ConvertStringToByte(s, true);

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

                _data = _temp;
            }

            return(_modBus.Build(deviceID, address, (int)RecivedCommand.SetService, _data));
        }
Esempio n. 3
0
 private string ConvertObjectToJson(ObjectSend objSend)
 {
     return((objSend == null) ? "" : MRW_Convert.ConvertObjectToJson(objSend));
 }
Esempio n. 4
0
 private string GenRandomString()
 {
     return(MRW_Convert.RandomString(ActionTicket.LENGH_RANDOM));
 }