Example #1
0
        public override SurveyResultData ReadHourlyArchive(IEnumerable <DateTime> dates)
        {
            var data = new List <Data>();

            //читаем регистры 400060..400062 узнаем, а что же сохраняется масса или объем
            var consumptionProperties = new ConsumptionProperties();

            try
            {
                OnSendMessage("чтение настроек");

                var register400060 = new Response4AsByte(SendMessageToDevice(new Request4(NetworkAddress, 400060, 1)));
                var register400061 = new Response4AsByte(SendMessageToDevice(new Request4(NetworkAddress, 400061, 1)));
                var register400062 = new Response4AsByte(SendMessageToDevice(new Request4(NetworkAddress, 400062, 1)));

                consumptionProperties.IsMassByChannel1 = register400060.Value == 0;
                consumptionProperties.IsMassByChannel2 = register400061.Value == 0;
                consumptionProperties.IsMassByChannel3 = register400062.Value == 0;
            }
            catch (Exception ex)
            {
                OnSendMessage("не удалось определить что сохраняется как расход, по умолчанию - масса");
            }

            foreach (var date in dates)
            {
                log.DebugFormat("дата: {0:dd.MM.yyyy HH:mm}", date);

                try
                {
                    OnSendMessage(string.Format("чтение часовых данных за {0:dd.MM.yyyy HH:mm}", date));

                    var dataResponse = new Response65(SendMessageToDevice(new Request65ByDate(NetworkAddress, date, ArchiveType.HourlySystem1)), consumptionProperties);
                    foreach (var d in dataResponse.Data)
                    {
                        //убираем лишние 59:59
                        d.Date = d.Date.AddMinutes(-59).AddSeconds(-59);
                        log.DebugFormat("данные: {0}", d);
                        data.Add(d);
                    }
                }
                catch (Exception ex)
                {
                    OnSendMessage(string.Format("ошибка: {0}", ex.Message));
                }
            }
            return(new SurveyResultData {
                Records = data, State = SurveyResultState.Success
            });
        }
Example #2
0
        public Response65(byte[] data, ConsumptionProperties properties)
            : base(data)
        {
            RawData = new List <byte>(data);

            Data = new List <Common.Data>();

            var length = data[2];
            //скипаем три байта (сетевой адрес, функция и длина)
            int start = 3;

            var seconds = Helper.ToUInt32(data, start + 0);

            //если данные нулевые, игнорим их
            if (seconds == 0)
            {
                return;
            }

            var date = new DateTime(1970, 1, 1).AddSeconds(seconds);

            var heat1 = Helper.ToUInt32(data, start + 4) / 4.184 * 0.001;

            Data.Add(new Data(Glossary.W4, MeasuringUnitType.Gkal, date, heat1));

            var heat2 = Helper.ToUInt32(data, start + 8) / 4.184 * 0.001;

            Data.Add(new Data(Glossary.W5, MeasuringUnitType.Gkal, date, heat2));

            var heat3 = Helper.ToUInt32(data, start + 12) / 4.184 * 0.001;

            Data.Add(new Data(Glossary.W6, MeasuringUnitType.Gkal, date, heat3));

            var cons1 = Helper.ToUInt32(data, start + 16) * 0.001;

            if (properties.IsMassByChannel1)
            {
                Data.Add(new Data(Glossary.M1, MeasuringUnitType.tonn, date, cons1));
            }
            else
            {
                Data.Add(new Data(Glossary.V1, MeasuringUnitType.m3, date, cons1));
            }

            var cons2 = Helper.ToUInt32(data, start + 20) * 0.001;

            if (properties.IsMassByChannel2)
            {
                Data.Add(new Data(Glossary.M2, MeasuringUnitType.tonn, date, cons2));
            }
            else
            {
                Data.Add(new Data(Glossary.V2, MeasuringUnitType.m3, date, cons2));
            }

            var cons3 = Helper.ToUInt32(data, start + 24) * 0.001;

            if (properties.IsMassByChannel3)
            {
                Data.Add(new Data(Glossary.M3, MeasuringUnitType.tonn, date, cons3));
            }
            else
            {
                Data.Add(new Data(Glossary.V3, MeasuringUnitType.m3, date, cons3));
            }

            var temperature1 = Helper.ToInt16(data, start + 28) * 0.01;

            Data.Add(new Data(Glossary.T1, MeasuringUnitType.C, date, temperature1));

            var temperature2 = Helper.ToInt16(data, start + 30) * 0.01;

            Data.Add(new Data(Glossary.T2, MeasuringUnitType.C, date, temperature2));

            var temperature3 = Helper.ToInt16(data, start + 32) * 0.01;

            Data.Add(new Data(Glossary.T3, MeasuringUnitType.C, date, temperature3));

            var timeWork = Helper.ToUInt32(data, start + 36);

            Data.Add(new Data(Glossary.Tw, MeasuringUnitType.sec, date, timeWork));

            var timeOff = Helper.ToUInt32(data, start + 40);

            Data.Add(new Data(Glossary.Ts, MeasuringUnitType.sec, date, timeOff));
        }