Example #1
0
        public static T2K Parse(byte[] data, int offset)
        {
            if (data == null || data.Length < 0x2FF + offset)
            {
                return(null);
            }

            var result = new T2K();

            result.Systems = data[offset + 0];
            for (int i = 0; i < 12; i++)
            {
                result.Type_g[i] = (TypeG)data[offset + 0x01 + i];
                result.Type_t[i] = (TypeT)data[offset + 0x0c + i];
            }
            result.Net_num = BitConverter.ToInt32(ConvertHelper.GetReversed(data, offset + 0x78, 4), 0);
            result.Number  = BitConverter.ToInt32(ConvertHelper.GetReversed(data, offset + 0x7c, 4), 0);

            for (int i = 0; i < 4; i++)
            {
                result.Diam[i]       = BitConverter.ToInt16(ConvertHelper.GetReversed(data, offset + 0xc4 + i * 2, 2), 0);
                result.G_max[i]      = BitConverter.ToSingle(ConvertHelper.GetReversed(data, offset + 0xcc + i * 4, 4), 0);
                result.G_pcnt_max[i] = data[offset + 0xdc + i];
                result.G_pcnt_min[i] = data[offset + 0xe0 + i];
            }

            for (int i = 0; i < 2; i++)
            {
                result.F_max[i]  = BitConverter.ToSingle(ConvertHelper.GetReversed(data, offset + 0xe4 + i * 4, 4), 0);
                result.Weight[i] = BitConverter.ToSingle(ConvertHelper.GetReversed(data, offset + 0xec + i * 4, 4), 0);//??? 74? EC?
            }

            result.SysInt_copy = SysInt.Parse(data, offset + 0x200);
            for (int i = 0; i < 4; i++)
            {
                result.SysConN[i] = SysCon.Parse(data, offset + 0x600 + i * 0x20);
            }

            return(result);
        }
Example #2
0
        public static SysCon Parse(byte[] data, int offset)
        {
            if (data == null || data.Length < 0x19 + offset)
            {
                return(null);
            }

            var result = new SysCon();

            result.sysType = (SysType)data[offset + 0x00];
            for (int i = 0; i < 4; i++)
            {
                result.Gprog[i] = data[offset + 0x01 + i];
                result.Gchan[i] = data[offset + 0x05 + i];
                result.Tprog[i] = data[offset + 0x09 + i];
                result.Tchan[i] = data[offset + 0x0d + i];
                result.Pprog[i] = data[offset + 0x11 + i];
                result.Pchan[i] = data[offset + 0x15 + i];
            }

            return(result);
        }
Example #3
0
        private IEnumerable <Data> ReadArchive(ArchiveType archiveType, IEnumerable <DateTime> dates)
        {
            var datas = new List <Data>();

            if (T2k == null)
            {
                return(null);
            }

            Show(string.Format("Чтение {0} архива", archiveType));

            if (GetVersion().Equals(DriverVersion))
            {
                foreach (var date in dates)
                {
                    Show(string.Format("Запрос даты {0:HH:mm dd.MM.yyyy}", date));
                    var answer = SendRequest(0x0d11, new byte[] { (byte)archiveType,
                                                                  archiveType == ArchiveType.Hourly? IntToBCD(date.Hour):(byte)0x00,
                                                                  archiveType != ArchiveType.Monthly? IntToBCD(date.Day):(byte)0x01,
                                                                  IntToBCD(date.Month),
                                                                  IntToBCD(date.Year - 2000) });

                    if (answer != null && answer.Length == 3)
                    {
                        var num = answer[1] << 8 | answer[2];
                        if (num == 0xFFFF)
                        {
                            Show("запись не обнаружена");
                        }
                        else
                        {
                            Show(string.Format("номер записи: {0} ({0:X})", num));
                            //Int64 addr = 0;
                            //var answer0 = SendRequest(0x0f03, new byte[] { 64, (byte)(addr >> 24), (byte)(addr >> 16), (byte)(addr >> 08), (byte)(addr) });
                            answer = new byte[256];
                            for (int i = 0; i < 4; i++)
                            {
                                var curanswer = SendRequest(0x0f03, new byte[] { 64, 0x00, ConvertHelper.ByteHigh(num), ConvertHelper.ByteLow(num) /*answer[1], answer[2]*/, (byte)(i * 0x40) }, 3333, 5);
                                if (curanswer == null || curanswer.Length != 65)
                                {
                                    Show("не удалось запросить запись, пропуск");
                                    answer = null;
                                    break;
                                }
                                Array.Copy(curanswer, 1, answer, 64 * i, 64);
                            }

                            if (answer != null)
                            {
                                var sysInt = SysInt.Parse(answer, 0);

                                if (T2k.Systems < 1 || T2k.Systems > 4)
                                {
                                    Show(string.Format("Некорректное число систем: {0}", T2k.Systems));
                                    return(null);
                                }

                                datas.Add(new Data(sysInt.Trab.Parameter, sysInt.Trab.MeasuringUnit, sysInt.date,
                                                   sysInt.Trab.Value[0]));
                                for (int sys = 0; sys < T2k.Systems; sys++)
                                {
                                    var systype = T2k.SysConN[sys].sysType;
                                    datas.Add(new Data(sysInt.IntV.Parameter, sysInt.IntV.MeasuringUnit, sysInt.date,
                                                       sysInt.IntV.Value[sys]));
                                    datas.Add(new Data(sysInt.IntM.Parameter, sysInt.IntM.MeasuringUnit, sysInt.date,
                                                       sysInt.IntM.Value[sys]));
                                    datas.Add(new Data(sysInt.IntQ.Parameter, sysInt.IntQ.MeasuringUnit, sysInt.date,
                                                       sysInt.IntQ.Value[sys]));
                                    datas.Add(new Data(sysInt.Tnar.Parameter, sysInt.Tnar.MeasuringUnit, sysInt.date,
                                                       sysInt.Tnar.Value[sys]));

                                    for (int i = 0; i < SysCon.GetChannelsPorT(systype); i++)
                                    {
                                        datas.Add(new Data(sysInt.T.Parameter, sysInt.T.MeasuringUnit, sysInt.date,
                                                           sysInt.T.Value[sys * 3 + i]));
                                        datas.Add(new Data(sysInt.P.Parameter, sysInt.P.MeasuringUnit, sysInt.date,
                                                           sysInt.P.Value[sys * 3 + i]));
                                    }

                                    datas.Add(new Data(sysInt.Rshv.Parameter, sysInt.Rshv.MeasuringUnit, sysInt.date,
                                                       sysInt.Rshv.Value[sys]));
                                }
                            }

                            //var answer0 = SendRequest(0x0f03, new byte[] { 64, 0x00, answer[1], answer[2], 0x00 });
                            //var answer1 = SendRequest(0x0f03, new byte[] { 64, 0x00, answer[1], answer[2], 0x40 });
                            //var answer2 = SendRequest(0x0f03, new byte[] { 64, 0x00, answer[1], answer[2], 0x80 });
                            //var answer3 = SendRequest(0x0f03, new byte[] { 64, 0x00, answer[1], answer[2], 0xC0 });
                        }
                    }
                    else
                    {
                        Show("ответ не получен");
                    }
                }
            }

            return(datas);
        }