public void TestMethod1() { Assert.IsTrue(Verify("3439900168454")); String number = "99999956100000177"; String chksum = CheckSumHelper.CheckSum(number); Assert.IsTrue(CheckSumHelper.Verify(number + chksum)); }
protected override void SendAck(string message) { var messagesSplited = message.Split(';'); var idEquipamento = messagesSplited[messagesSplited.Length - 3]; var numeroMessage = messagesSplited[messagesSplited.Length - 2]; var ackMessage = string.Format(">ACK;{0};{1};", idEquipamento, numeroMessage); var ack = CheckSumHelper.Calculate(ackMessage); var ackToSend = string.Format("{0}*{1}<\n\r", ackMessage, ack); _logger.Information("ACK: {ackToSend}", ackToSend); var messageBuffer = Encoding.ASCII.GetBytes(ackToSend); _socket.SendTo(messageBuffer, _endPointFrom); }
public static string ToRGPProtocol(this string ruvProtocol) { var rgpMessage = string.Empty; if (ruvProtocol.Contains(">RUV00")) { var messagesSplited = ruvProtocol.Split(';'); var idEquipamento = messagesSplited[messagesSplited.Length - 3]; var numeroMessage = messagesSplited[messagesSplited.Length - 2]; var pm = messagesSplited[0].Split(','); var rpm = pm[8]; var latlong = pm[3]; var @event = string.Empty; var eventSize = pm[0].Length; if (eventSize == 8) { @event = pm[0].Substring(eventSize - 2, 2); } else if (eventSize == 9) { @event = pm[0].Substring(eventSize - 3, 3); } else { @event = "00"; } var ign = (int.Parse(rpm) == 0) ? "DE" : "DF"; var rgpMessageOriginal = string.Format(">RGP{0}00{1}{2}00;{3};{4};", latlong, ign, @event, idEquipamento, numeroMessage); var checkSum = CheckSumHelper.Calculate(rgpMessageOriginal); rgpMessage = string.Format("{0}*{1}<\n\r", rgpMessageOriginal, checkSum); } return(rgpMessage); }