示例#1
0
        public static POWResourcesInformation?Decode010b(byte[] response)
        {
            if (response.Length != 16)
            {
                return(null);
            }

            if ((response[2] & 0xE0) != 0x40)
            {
                return(null);
            }

            POWResourcesInformation decoded =
                new POWResourcesInformation {
                DataLength = (ushort)((response[0] << 8) + response[1])
            };

            if (decoded.DataLength + 2 != response.Length)
            {
                return(null);
            }

            decoded.DataType = (byte)((response[2] & 0xE0) >> 5);
            decoded.RemainingPOWReplacements =
                (ushort)((response[4] << 24) + (response[5] << 16) + (response[6] << 8) + response[7]);
            decoded.RemainingPOWReallocation =
                (ushort)((response[8] << 24) + (response[9] << 16) + (response[10] << 8) + response[11]);
            decoded.RemainingPOWUpdates =
                (ushort)((response[12] << 24) + (response[13] << 16) + (response[14] << 8) + response[15]);

            return(decoded);
        }
示例#2
0
        public static string Prettify010b(POWResourcesInformation?information)
        {
            if (!information.HasValue)
            {
                return(null);
            }

            POWResourcesInformation decoded = information.Value;

            if (decoded.DataType != 1)
            {
                return(null);
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("{0} remaining POW replacements", decoded.RemainingPOWReplacements).AppendLine();
            sb.AppendFormat("{0} remaining POW reallocation map entries", decoded.RemainingPOWReallocation)
            .AppendLine();
            sb.AppendFormat("{0} remaining POW updates", decoded.RemainingPOWUpdates).AppendLine();

            return(sb.ToString());
        }