Ejemplo n.º 1
0
        public static DeltaItem CreateStrValDeltaItem(int addressInChannel,
                                                      int lastUpdateTimestamp,
                                                      TmNativeDefs.DeltaItemsFlags deltaFlags,
                                                      string valueString,
                                                      string additionalInfo,
                                                      TmAddr tmAddr)
        {
            var enumShift  = deltaFlags.HasFlag(TmNativeDefs.DeltaItemsFlags.ZeroEnum) ? 0 : 1;
            var updateTime = lastUpdateTimestamp == 0
                         ? (DateTime?)null
                         : DateUtil.GetDateTimeFromTimestamp(lastUpdateTimestamp);

            return(new DeltaItem
            {
                AddressInChannelString = deltaFlags.HasFlag(TmNativeDefs.DeltaItemsFlags.Hex)
                                          ? $"0x{addressInChannel:X}"
                                          : $"{addressInChannel + enumShift}",
                Type = DeltaItemTypes.Analog,
                TypeString = "СТР",
                UpdateTime = updateTime,
                ValueString = valueString,
                AdditionalInfo = additionalInfo,
                TmAddress = tmAddr
            });
        }
Ejemplo n.º 2
0
        public static DeltaItem CreateControlDeltaItem(int addressInChannel,
                                                       int lastUpdateTimestamp,
                                                       TmNativeDefs.DeltaItemsFlags deltaFlags,
                                                       int controlBlock,
                                                       int controlGroup,
                                                       int controlPoint,
                                                       string additionalInfo,
                                                       TmAddr tmAddr,
                                                       string objectName)
        {
            var enumShift  = deltaFlags.HasFlag(TmNativeDefs.DeltaItemsFlags.ZeroEnum) ? 0 : 1;
            var updateTime = lastUpdateTimestamp == 0
                         ? (DateTime?)null
                         : DateUtil.GetDateTimeFromTimestamp(lastUpdateTimestamp);

            return(new DeltaItem
            {
                AddressInChannelString = deltaFlags.HasFlag(TmNativeDefs.DeltaItemsFlags.Hex)
                                          ? $"0x{addressInChannel:X}"
                                          : $"{addressInChannel + enumShift}",
                Type = DeltaItemTypes.Control,
                TypeString = "ТУ",
                UpdateTime = updateTime,
                ValueString = controlBlock != 0xffff
                               ? $"{controlBlock + enumShift}-{controlGroup + enumShift}-{controlPoint + enumShift}"
                               : string.Empty,
                AdditionalInfo = additionalInfo,
                TmAddress = tmAddr,
                ObjectName = objectName
            });
        }
Ejemplo n.º 3
0
        public static DeltaItem CreateAccumFloatDeltaItem(int addressInChannel,
                                                          int lastUpdateTimestamp,
                                                          TmNativeDefs.DeltaItemsFlags deltaFlags,
                                                          float value,
                                                          string additionalInfo,
                                                          TmAddr tmAddr,
                                                          string objectName)
        {
            var enumShift  = deltaFlags.HasFlag(TmNativeDefs.DeltaItemsFlags.ZeroEnum) ? 0 : 1;
            var updateTime = lastUpdateTimestamp == 0
                         ? (DateTime?)null
                         : DateUtil.GetDateTimeFromTimestamp(lastUpdateTimestamp);

            return(new DeltaItem
            {
                AddressInChannelString = deltaFlags.HasFlag(TmNativeDefs.DeltaItemsFlags.Hex)
                                          ? $"0x{addressInChannel:X}"
                                          : $"{addressInChannel + enumShift}",
                Type = DeltaItemTypes.AccumFloat,
                TypeString = "ТИИ",
                UpdateTime = updateTime,
                ValueString = deltaFlags.HasFlag(TmNativeDefs.DeltaItemsFlags.Reliable)
                               ? $"{value:N6}"
                               : $"{value:N6} ?",
                AdditionalInfo = additionalInfo,
                TmAddress = tmAddr,
                ObjectName = objectName
            });
        }
Ejemplo n.º 4
0
        public static DeltaItem CreateStatusDeltaItem(int addressInChannel,
                                                      int lastUpdateTimestamp,
                                                      TmNativeDefs.DeltaItemsFlags deltaFlags,
                                                      int value,
                                                      string additionalInfo,
                                                      TmAddr tmAddr,
                                                      string objectName)
        {
            var deltaItem = new DeltaItem
            {
                Type       = DeltaItemTypes.Status,
                TypeString = "ТС",
                TmAddress  = tmAddr,
                ObjectName = objectName
            };

            if (deltaFlags.HasFlag(TmNativeDefs.DeltaItemsFlags.ZeroEnum))
            {
                deltaItem.AddressInChannelString = deltaFlags.HasFlag(TmNativeDefs.DeltaItemsFlags.Hex)
                                             ? $"0x{addressInChannel:X}"
                                             : $"{addressInChannel}";
            }
            else
            {
                var addressQuotient = Math.DivRem(addressInChannel, 8, out var addressRemainder);
                deltaItem.AddressInChannelString = $"{addressQuotient + 1}-{addressRemainder}";
            }

            deltaItem.ValueString = deltaFlags.HasFlag(TmNativeDefs.DeltaItemsFlags.Reliable)
                                ? $"{value & 0xF}"
                                : $"{value & 0xF} ?";

            if (deltaFlags.HasFlag(TmNativeDefs.DeltaItemsFlags.DestVal))
            {
                deltaItem.ValueString = deltaFlags.HasFlag(TmNativeDefs.DeltaItemsFlags.DestReli)
                                  ? $"{deltaItem.ValueString} ({value >> 4})"
                                  : $"{deltaItem.ValueString} ({value >> 4} ?)";
            }

            deltaItem.UpdateTime = lastUpdateTimestamp == 0
                               ? (DateTime?)null
                               : DateUtil.GetDateTimeFromTimestamp(lastUpdateTimestamp);

            deltaItem.AdditionalInfo = additionalInfo;

            if (deltaFlags.HasFlag(TmNativeDefs.DeltaItemsFlags.S2Break))
            {
                deltaItem.AdditionalInfo = $"{deltaItem.AdditionalInfo} <Обрыв>";
            }

            if (deltaFlags.HasFlag(TmNativeDefs.DeltaItemsFlags.S2Malfn))
            {
                deltaItem.AdditionalInfo = $"{deltaItem.AdditionalInfo} <Неисп>";
            }

            return(deltaItem);
        }
Ejemplo n.º 5
0
        public TmAlert(byte[]                 id,
                       int importance,
                       bool isActive,
                       bool isUnacked,
                       DateTime?onTime,
                       DateTime?offTime,
                       string type,
                       string name,
                       string currentValueString,
                       DateTime?currentValueTime,
                       float currentValue,
                       float?initialValue,
                       DateTime?ackTime,
                       string ackUser,
                       int tmClassId,
                       TmAddr tmAddr,
                       ITmAnalogRetro[]       microSeries,
                       TmAnalogTechParameters analogTechParameters)
        {
            Id                 = id;
            Importance         = importance;
            IsActive           = isActive;
            IsUnacked          = isUnacked;
            OnTime             = onTime;
            OffTime            = offTime;
            Type               = type;
            Name               = name;
            CurrentValueString = currentValueString;
            CurrentValueTime   = currentValueTime;
            CurrentValue       = currentValue;
            AckTime            = ackTime;
            AckUser            = ackUser;
            TmClassId          = tmClassId;
            TmAddr             = tmAddr;
            MicroSeries        = microSeries.ToList();

            if (tmAddr.Type == TmType.Analog)
            {
                AnalogTechParameters = analogTechParameters;
            }

            if (tmAddr.Type == TmType.Analog && initialValue != null)
            {
                Reference = initialValue.Value;
            }
        }
Ejemplo n.º 6
0
 public static TmAlert CreateFromDto(TmAlertDto dto)
 {
     return(new TmAlert(dto.AlertId,
                        dto.Importance,
                        dto.Active,
                        dto.Unack,
                        dto.OnTime,
                        dto.OffTime.NullIfEpoch(),
                        dto.TypeName,
                        dto.Name.RemoveMultipleWhitespaces(),
                        dto.ValueText.Trim(),
                        dto.CurTime,
                        dto.CurValue,
                        dto.ActValue,
                        dto.AckTime,
                        dto.AckUser,
                        dto.ClassId ?? 0,
                        TmAddr.CreateFromSqlTmaAndTmaType((ushort)(dto.TmType ?? 0), dto.Tma),
                        dto.MapToTmAnalogMicroSeriesDto().MapToITmAnalogRetroArray(),
                        TmAnalogTechParameters.CreateFromDto(dto.MapToTmAnalogTechParametersDto())
                        ));
 }
Ejemplo n.º 7
0
 public static TmAlarmExpression CreateTmAlarmExpressionFromDto(TmAlarmDto dto)
 {
     return(CreateTmAlarmExpressionFromDto(dto, new TmAnalog(TmAddr.CreateFromSqlTma(TmType.Analog, dto.Tma))));
 }