123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using Edge.Core.Parser.BinaryParser.Attributes;
- using System;
- using System.Collections.Generic;
- namespace PetroChinaOnlineWatchPlugin.MessageEntity.Outgoing
- {
- public class HeartBeatOut : HeartBeatBase
- {
- [EnumerableFormat("%cascade", -9990)]
- public List<byte> IpAddressBytes { get; protected set; }
- [Format(2, EncodingType.BIN, -9980)]
- public int Port { get; set; }
- [Format(1, EncodingType.BIN, -9970)]
- [Range(0, 255, "Subnet must range in 1 to 255")]
- public byte Subnet { get; set; }
- [Format(1, EncodingType.BIN, -9960)]
- [Range(0, 127, "Node must range in 1 to 127, but now is {0}")]
- public byte Node { get; set; }
- [Format(1, EncodingType.BIN, -9950)]
- public MessageCode MessageCode { get { return MessageCode.IFSF_MESSAGE_CODE_HEARTBEAT; } }
- [Format(1, EncodingType.BIN, -9940)]
- public byte MessageState { get; protected set; }
- public string IpAddress
- {
- set
- {
- IpAddressBytes = new List<byte>();
- foreach (string item in value.Split('.'))
- {
- IpAddressBytes.Add(byte.Parse(item));
- }
- }
- }
- public bool NeedConfig
- {
- set
- {
- //02 = 0000 0010
- if (value)
- MessageState = (byte)(MessageState | 0x02);
- }
- }
- public bool NeedUpdate
- {
- set
- {
- //80 = 1000 0000
- if (value)
- MessageState = (byte)(MessageState | 0x80);
- }
- }
- public override string ToString()
- {
- string ipAddress = string.Empty;
- foreach (byte ip in IpAddressBytes)
- { ipAddress += " " + ip.ToString(); }
- return $"{ipAddress} {Port} {Subnet} {Node}";
- }
- }
- }
|