修改TCP
This commit is contained in:
parent
1c981153a3
commit
8a15b4ee51
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,48 +1,31 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Sockets;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using static System.Net.WebRequestMethods;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace ShuiBiao
|
||||
{
|
||||
internal class ShuiBiao
|
||||
{
|
||||
/// <summary>
|
||||
/// 基数【前置位设备数据总数和】
|
||||
/// </summary>
|
||||
//public static int baseNum = 0;
|
||||
public static int length = 0;//接收数据长度
|
||||
|
||||
static log4net.ILog log;
|
||||
|
||||
public static Socket serverSocket;
|
||||
/// <summary>
|
||||
/// 在线用户列表
|
||||
/// </summary>
|
||||
public static List<string> idOnLine = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 存储IP及Socket--便于服务器与指定客户端通信
|
||||
/// </summary>
|
||||
public static Dictionary<string, Socket> OnLineDic = new Dictionary<string, Socket>();
|
||||
|
||||
public static Socket udpServer;//udp服务器
|
||||
public static bool memberReply;//是否回复消息
|
||||
//public static TypeFunctionCode LastType = TypeFunctionCode.默认;
|
||||
public static Encoding encoding = Encoding.Default;
|
||||
|
||||
public static int COMPort = 7000;//端口号
|
||||
public static string IP1 = "172.16.1.49";//连接IP
|
||||
public static EndPoint serverEnd; //服务端
|
||||
public static IPEndPoint ipEnd; //发送消息服务端
|
||||
public static Socket socket; //目标socket
|
||||
public static Thread connectThread; //连接线程
|
||||
public static byte[] sendData;//发送的数据
|
||||
public static Socket Socket;
|
||||
|
||||
|
||||
static log4net.ILog log;
|
||||
static void Main(string[] args)
|
||||
{
|
||||
//初始化日志
|
||||
|
@ -53,127 +36,150 @@ namespace ShuiBiao
|
|||
Console.ReadKey();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送接口初始化
|
||||
/// </summary>
|
||||
public static void InitSocket(EndPoint endP)
|
||||
{
|
||||
try
|
||||
{
|
||||
//定义连接的服务器ip和端口,可以是本机ip,局域网,互联网
|
||||
//ipEnd = new IPEndPoint(IPAddress.Parse(IP1), COMPort);
|
||||
ipEnd = (IPEndPoint)(endP);
|
||||
//定义套接字类型,在主线程中定义
|
||||
socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||
//定义服务端
|
||||
IPEndPoint sender = new IPEndPoint(IPAddress.Any, 0);
|
||||
serverEnd = (EndPoint)sender;
|
||||
//print("waiting for sending UDP dgram");
|
||||
|
||||
//建立初始连接,这句非常重要,第一次连接初始化了serverEnd后面才能收到消息
|
||||
//SocketSend("connection-successful signal");
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
Console.WriteLine("发送初始化:" + e.Message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发送数据
|
||||
/// </summary>
|
||||
/// <param name="sendStr"></param>
|
||||
public static void SocketSend(string sendStr)
|
||||
{
|
||||
//清空发送缓存
|
||||
sendData = new byte[1024 * 1024 * 2];
|
||||
//数据类型转换
|
||||
//sendData = Encoding.Default.GetBytes(sendStr);
|
||||
|
||||
StringBuilder stringBuilder = new StringBuilder("");
|
||||
for (int i = 0; i < sendStr.Length; i++)
|
||||
{
|
||||
if (i != 0 && i % 2 != 0) stringBuilder.Append(sendStr[i] + " ");
|
||||
else stringBuilder.Append(sendStr[i]);
|
||||
}
|
||||
log.Info("发送至 " + ipEnd.ToString() + ": " + stringBuilder);
|
||||
|
||||
sendData = hexStringToByteArray(sendStr);
|
||||
//发送给指定服务端
|
||||
socket.SendTo(sendData, sendData.Length, SocketFlags.None, ipEnd);
|
||||
//socket.SendTo(sendData, sendData.Length, SocketFlags.None, new IPEndPoint(IPAddress.Parse(ipEnd.Address.ToString()), 0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 连接关闭
|
||||
/// </summary>
|
||||
public static void SocketQuit()
|
||||
{
|
||||
//关闭线程
|
||||
if (connectThread != null)
|
||||
{
|
||||
connectThread.Interrupt();
|
||||
connectThread.Abort();
|
||||
}
|
||||
//最后关闭socket
|
||||
if (socket != null)
|
||||
socket.Close();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 接收接口初始化
|
||||
/// </summary>
|
||||
public static void init()
|
||||
{
|
||||
//TCP
|
||||
try
|
||||
{
|
||||
//var IP = "111.229.30.246";
|
||||
var ip = "172.17.0.9";
|
||||
var port = 12303;
|
||||
|
||||
var IP = "172.17.0.9";
|
||||
//string IP = "172.16.1.49";
|
||||
int Port = 12301;
|
||||
//var ip = "127.0.0.1";
|
||||
//var port = 12303;
|
||||
|
||||
//建立udp服务器,参数2:udp协议以数据报的方式传输,参数3:UDP协议
|
||||
udpServer = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||
//为服务器绑定IP
|
||||
IPAddress ip = IPAddress.Parse(IP);
|
||||
EndPoint ep = new IPEndPoint(ip, Port);
|
||||
udpServer.Bind(ep);
|
||||
//接收数据
|
||||
EndPoint endP = new IPEndPoint(IPAddress.Any, 0);
|
||||
//调用socket(函数创建一个用于通信的套接字。
|
||||
serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
|
||||
|
||||
string message;
|
||||
byte[] data = new byte[1024 * 1024 * 2];
|
||||
length = 0;
|
||||
//把数据的来源放到第二个参数上
|
||||
while (true)
|
||||
//给已经创建的套接宁绑定一个端口号
|
||||
IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse(ip), port);
|
||||
serverSocket.Bind(endPoint);
|
||||
|
||||
//调用listen(函数使套接宁成为—个监听
|
||||
serverSocket.Listen(1000);//最大连接数
|
||||
|
||||
//开启监听任务
|
||||
Task.Run(new Action(() =>
|
||||
{
|
||||
length = udpServer.ReceiveFrom(data, ref endP);
|
||||
//message = Encoding.Default.GetString(data, 0, length);
|
||||
message = byteArrayToHexString(data, length);
|
||||
log.Info("接收到 " + endP.ToString() + ": " + message);
|
||||
message = message.Replace(" ", "");
|
||||
InitSocket(endP);
|
||||
Console.WriteLine("地址:" + endP.ToString() + "\n");
|
||||
int baseNum = 0;//基数【前置位设备数据总数和】
|
||||
var LoginFrame = message[20].ToString() + message[21].ToString();//功能码C
|
||||
JudgmentFunctionCode(LoginFrame, message, baseNum);
|
||||
ListenConnection();
|
||||
}));
|
||||
|
||||
|
||||
//开启输入任务
|
||||
//Task.Run(new Action(() =>
|
||||
//{
|
||||
// BaudRate();
|
||||
//}));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("服务器初始化异常:" + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 监听任务
|
||||
/// </summary>
|
||||
private static void ListenConnection()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
//调用accept() 函数来接受客户端的连接
|
||||
Socket clientSocket = serverSocket.Accept();//新用户连接后触发返回新的socket
|
||||
string ipPort = clientSocket.RemoteEndPoint.ToString();//连接用户的IP及端口
|
||||
addOnLine(ipPort, clientSocket, true);
|
||||
Console.WriteLine(clientSocket.RemoteEndPoint.ToString() + "上线了");
|
||||
Task.Run(() => ReceiveMsg(clientSocket));//针对单个客户端开启线程(接收)
|
||||
//Task.Run(() =>
|
||||
//{
|
||||
// lock (o)
|
||||
// {
|
||||
// ReceiveMsg(clientSocket);
|
||||
// }
|
||||
//});//针对单个客户端开启线程(接收)
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新在线用户列表
|
||||
/// </summary>
|
||||
/// <param name="clientIp">用户IP端口号套接</param>
|
||||
/// <param name="clientSocket">Socket</param>
|
||||
/// <param name="isAdd">用是否增加</param>
|
||||
private static void addOnLine(string clientIp, Socket clientSocket, bool isAdd)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (isAdd)
|
||||
{
|
||||
idOnLine.Add(clientIp);
|
||||
OnLineDic.Add(clientIp, clientSocket);
|
||||
}
|
||||
else
|
||||
{
|
||||
idOnLine.Remove(clientIp);
|
||||
OnLineDic.Remove(clientIp);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
Console.WriteLine("接收初始化:" + e.Message);
|
||||
Console.WriteLine("更新在线用户异常:" + e.Message);
|
||||
}
|
||||
//Invoke(new Action(() =>
|
||||
//{
|
||||
// if (isAdd) { idOnLine.Add(clientIp); }
|
||||
// else { idOnLine.Remove(clientIp); }
|
||||
//}));
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 接收消息--接收到进入触发
|
||||
/// </summary>
|
||||
/// <param name="clientSocket"></param>
|
||||
private static void ReceiveMsg(Socket clientSocket)
|
||||
{
|
||||
StringBuilder builder_shuju = new StringBuilder("");//需校验字节
|
||||
StringBuilder builder_crc = new StringBuilder("");//收到检验位
|
||||
while (true)
|
||||
{
|
||||
byte[] bytes = new byte[1024];
|
||||
int length = -1;
|
||||
try
|
||||
{
|
||||
length = clientSocket.Receive(bytes);//返回字节数
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
//用户下线--更新在线列表
|
||||
addOnLine(clientSocket.RemoteEndPoint.ToString(), clientSocket, false);
|
||||
Console.WriteLine(clientSocket.RemoteEndPoint.ToString() + "下线了");
|
||||
break;//结束线程
|
||||
}
|
||||
if (length == 0)
|
||||
{
|
||||
//用户下线--更新在线列表
|
||||
addOnLine(clientSocket.RemoteEndPoint.ToString(), clientSocket, false);
|
||||
Console.WriteLine(clientSocket.RemoteEndPoint.ToString() + "下线了");
|
||||
break;//结束线程
|
||||
}
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
var message = byteArrayToHexString(bytes, length);
|
||||
log.Info("接收到 " + clientSocket.RemoteEndPoint + ": " + message);
|
||||
message = message.Replace(" ", "");
|
||||
Socket = clientSocket;
|
||||
Console.WriteLine("地址:" + clientSocket.RemoteEndPoint + "\n");
|
||||
int baseNum = 0;//基数【前置位设备数据总数和】
|
||||
var LoginFrame = message[20].ToString() + message[21].ToString();//功能码C
|
||||
JudgmentFunctionCode(LoginFrame, message, baseNum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// byte[]直接转Float**
|
||||
|
@ -361,34 +367,34 @@ namespace ShuiBiao
|
|||
public static string interconvert(int j, int k, string message, bool exchange = true)
|
||||
{
|
||||
StringBuilder parityBitCS = new StringBuilder("");//互换后的值
|
||||
//StringBuilder _parityBitH = new StringBuilder("");//高字节
|
||||
//StringBuilder _parityBitL = new StringBuilder("");//低字节
|
||||
//StringBuilder _parityBit = new StringBuilder("");//记录当前字节
|
||||
//int x = 0;
|
||||
//for (int i = j; i <= k; i++)//??
|
||||
//{
|
||||
// if (x == 4)
|
||||
// {
|
||||
// _parityBitL.Append(_parityBit);//记录低字节
|
||||
// parityBitCS.Append(_parityBitL).Append(_parityBitH);//低字节--高字节
|
||||
// _parityBitL.Clear();//清空低字节
|
||||
// _parityBitH.Clear();//清空高字节
|
||||
// _parityBit.Clear();
|
||||
// x = 0;
|
||||
// }
|
||||
// else if (x == 2)//记录高字节
|
||||
// {
|
||||
// _parityBitH.Append(_parityBit);
|
||||
// _parityBit.Clear();
|
||||
// }
|
||||
// _parityBit.Append(message[i]);
|
||||
// if (i == k)
|
||||
// {
|
||||
// _parityBitL.Append(_parityBit);//记录低字节
|
||||
// parityBitCS.Append(_parityBitL).Append(_parityBitH);//低字节--高字节
|
||||
// }
|
||||
// x++;
|
||||
//}
|
||||
//StringBuilder _parityBitH = new StringBuilder("");//高字节
|
||||
//StringBuilder _parityBitL = new StringBuilder("");//低字节
|
||||
//StringBuilder _parityBit = new StringBuilder("");//记录当前字节
|
||||
//int x = 0;
|
||||
//for (int i = j; i <= k; i++)//??
|
||||
//{
|
||||
// if (x == 4)
|
||||
// {
|
||||
// _parityBitL.Append(_parityBit);//记录低字节
|
||||
// parityBitCS.Append(_parityBitL).Append(_parityBitH);//低字节--高字节
|
||||
// _parityBitL.Clear();//清空低字节
|
||||
// _parityBitH.Clear();//清空高字节
|
||||
// _parityBit.Clear();
|
||||
// x = 0;
|
||||
// }
|
||||
// else if (x == 2)//记录高字节
|
||||
// {
|
||||
// _parityBitH.Append(_parityBit);
|
||||
// _parityBit.Clear();
|
||||
// }
|
||||
// _parityBit.Append(message[i]);
|
||||
// if (i == k)
|
||||
// {
|
||||
// _parityBitL.Append(_parityBit);//记录低字节
|
||||
// parityBitCS.Append(_parityBitL).Append(_parityBitH);//低字节--高字节
|
||||
// }
|
||||
// x++;
|
||||
//}
|
||||
string[] strings = new string[4] { message[0].ToString() + message[1].ToString(), message[2].ToString() + message[3].ToString(), message[4].ToString() + message[5].ToString(), message[6].ToString() + message[7].ToString() };
|
||||
for (int i = strings.Length - 1; i >= 0; i--)
|
||||
{
|
||||
|
@ -581,7 +587,7 @@ namespace ShuiBiao
|
|||
/// 登录帧解析
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
public static void LoginFrameAnalysis(string message, IPEndPoint ipEnd, Socket socket)
|
||||
public static void LoginFrameAnalysis(string message)
|
||||
{
|
||||
#region 登录帧解析
|
||||
|
||||
|
@ -793,7 +799,7 @@ namespace ShuiBiao
|
|||
|
||||
|
||||
#endregion
|
||||
longinDecompilation(SimID, ipEnd, socket);
|
||||
longinDecompilation(SimID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -812,7 +818,7 @@ namespace ShuiBiao
|
|||
/// 时钟解析
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
public static void clockAnalysis(string message, IPEndPoint ipEnd)
|
||||
public static void clockAnalysis(string message)
|
||||
{
|
||||
StringBuilder DataLength = new StringBuilder("");//数据部长度L
|
||||
for (int i = 4; i <= 7; i++)
|
||||
|
@ -885,14 +891,14 @@ namespace ShuiBiao
|
|||
/// 登录帧反编译
|
||||
/// </summary>
|
||||
/// <param name="SimID">客户端地址A</param>
|
||||
public static void longinDecompilation(StringBuilder SimID, IPEndPoint ipEnd, Socket socket)
|
||||
public static void longinDecompilation(StringBuilder SimID)
|
||||
{
|
||||
if (SimID.Length == 11) SimID.Append("F");
|
||||
StringBuilder parityBitCS = new StringBuilder("");
|
||||
StringBuilder message = new StringBuilder("403A" + "0009" + SimID + "01" + "00");
|
||||
parityBitCS.Append(binAccumulation(4, 23, message.ToString()));
|
||||
var a = message.Append(parityBitCS).ToString() + "0D0A";
|
||||
SocketSend(a);
|
||||
//SocketSend(a);
|
||||
|
||||
}
|
||||
|
||||
|
@ -902,13 +908,13 @@ namespace ShuiBiao
|
|||
/// <param name="SimID">sim码</param>
|
||||
/// <param name="code">功能码</param>
|
||||
/// <param name="versionNum">版本号</param>
|
||||
public static void dataFramesDecompilation(StringBuilder SimID, string code, IPEndPoint ipEnd, Socket socket, string versionNum = "01")
|
||||
public static void dataFramesDecompilation(StringBuilder SimID, string code, string versionNum = "01")
|
||||
{
|
||||
if (SimID.Length == 11) SimID.Append("F");
|
||||
StringBuilder parityBitCS = new StringBuilder("");
|
||||
StringBuilder message = new StringBuilder("403A" + "000B" + SimID + code + versionNum + "0100");
|
||||
parityBitCS.Append(binAccumulation(4, 27, message.ToString()));
|
||||
SocketSend(message.Append(parityBitCS) + "0D0A");
|
||||
//SocketSend(message.Append(parityBitCS) + "0D0A");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -928,7 +934,10 @@ namespace ShuiBiao
|
|||
StringBuilder sig = new StringBuilder("00");//有无后续帧标识 --0 无后续帧 1 有后续帧
|
||||
StringBuilder msg = new StringBuilder("403A" + "000F" + SimID + "05" + Clock + sig);
|
||||
parityBitCS.Append(binAccumulation(4, 35, msg.ToString()));
|
||||
SocketSend(msg.Append(parityBitCS).ToString() + "0D0A");
|
||||
//SocketSend(msg.Append(parityBitCS).ToString() + "0D0A");
|
||||
var str = msg.Append(parityBitCS).ToString() + "0D0A";
|
||||
Socket.Send(hexStringToByteArray(str));
|
||||
Socket = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1091,19 +1100,19 @@ namespace ShuiBiao
|
|||
{
|
||||
Console.WriteLine();
|
||||
phenotype84(message, baseNum);
|
||||
dataFramesDecompilation(SimID, code, ipEnd, socket);
|
||||
dataFramesDecompilation(SimID, code);
|
||||
}
|
||||
else if ((go.ToString() == "83"))
|
||||
{
|
||||
Console.WriteLine();
|
||||
phenotype83(message, baseNum);
|
||||
dataFramesDecompilation(SimID, code, ipEnd, socket);
|
||||
dataFramesDecompilation(SimID, code);
|
||||
}
|
||||
else if ((go.ToString() == "81"))
|
||||
{
|
||||
Console.WriteLine();
|
||||
phenotype81(message, baseNum);
|
||||
dataFramesDecompilation(SimID, code, ipEnd, socket);
|
||||
dataFramesDecompilation(SimID, code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1213,7 +1222,7 @@ namespace ShuiBiao
|
|||
_positiveFlow.Append(message[i]);
|
||||
}
|
||||
int positiveFlow = int.Parse(/*hexStr2Str*/(interconvert(56 + multiplier, 63 + multiplier, _positiveFlow.ToString()))) / 10;//???
|
||||
//Console.WriteLine("累积流量:" + positiveFlow + "m3");
|
||||
//Console.WriteLine("累积流量:" + positiveFlow + "m3");
|
||||
|
||||
StringBuilder waterTemperature = new StringBuilder("");//水温 --浮点型,单位: ℃
|
||||
for (int i = 64 + multiplier; i <= 71 + multiplier; i++)
|
||||
|
@ -1221,7 +1230,7 @@ namespace ShuiBiao
|
|||
waterTemperature.Append(message[i]);
|
||||
}
|
||||
var _waterTemperature = byteToFloat(waterTemperature.ToString());//???
|
||||
//Console.WriteLine("水温:" + _waterTemperature + "℃");
|
||||
//Console.WriteLine("水温:" + _waterTemperature + "℃");
|
||||
|
||||
StringBuilder _RunTime = new StringBuilder("");//累积运行时间 --带符号整型,低字节在前,高字节在后,单位: h
|
||||
for (int i = 72 + multiplier; i <= 79 + multiplier; i++)
|
||||
|
@ -1229,7 +1238,7 @@ namespace ShuiBiao
|
|||
_RunTime.Append(message[i]);
|
||||
}
|
||||
int RunTime = int.Parse(/*hexStr2Str*/(interconvert(72 + multiplier, 79 + multiplier, _RunTime.ToString())));//???
|
||||
//Console.WriteLine("累积运行时间:" + RunTime + "h");
|
||||
//Console.WriteLine("累积运行时间:" + RunTime + "h");
|
||||
|
||||
StringBuilder _cellVoltage = new StringBuilder("");//电池电压 --浮点型,低字节在前,高字节在后,单位: v。
|
||||
for (int i = 80 + multiplier; i <= 87 + multiplier; i++)
|
||||
|
@ -1238,7 +1247,7 @@ namespace ShuiBiao
|
|||
}
|
||||
//float cellVoltage = float.Parse(/*hexStr2Str*/(interconvert(80 + multiplier, 87 + multiplier, _cellVoltage.ToString())));
|
||||
float cellVoltage = byteToFloat(_cellVoltage.ToString());//???
|
||||
//Console.WriteLine("电池电压:" + cellVoltage + "v");
|
||||
//Console.WriteLine("电池电压:" + cellVoltage + "v");
|
||||
|
||||
StringBuilder _pipeSize = new StringBuilder("");//管径 --浮点型,单位: mm
|
||||
for (int i = 88 + multiplier; i <= 95 + multiplier; i++)
|
||||
|
@ -1247,7 +1256,7 @@ namespace ShuiBiao
|
|||
}
|
||||
//float pipeSize = float.Parse(_pipeSize.ToString());
|
||||
float pipeSize = byteToFloat(_pipeSize.ToString());//???
|
||||
//Console.WriteLine("管径:" + pipeSize + "mm");
|
||||
//Console.WriteLine("管径:" + pipeSize + "mm");
|
||||
|
||||
StringBuilder capacity = new StringBuilder("");//量程 --长整型,单位:单位缺失。
|
||||
for (int i = 96 + multiplier; i <= 103 + multiplier; i++)
|
||||
|
@ -1401,7 +1410,7 @@ namespace ShuiBiao
|
|||
waterTemperature.Append(message[i]);
|
||||
}
|
||||
var _waterTemperature = byteToFloat(waterTemperature.ToString());//???
|
||||
//Console.WriteLine("水温:" + _waterTemperature + "℃");
|
||||
//Console.WriteLine("水温:" + _waterTemperature + "℃");
|
||||
|
||||
StringBuilder _RunTime = new StringBuilder("");//累积运行时间 --带符号整型,低字节在前,高字节在后,单位: h
|
||||
for (int i = 88 + multiplier; i <= 95 + multiplier; i++)
|
||||
|
@ -1409,7 +1418,7 @@ namespace ShuiBiao
|
|||
_RunTime.Append(message[i]);
|
||||
}
|
||||
var RunTime = int.Parse(/*hexStr2Str*/(interconvert(88 + multiplier, 95 + multiplier, _RunTime.ToString())));//???
|
||||
//Console.WriteLine("累积运行时间:" + RunTime + "h");
|
||||
//Console.WriteLine("累积运行时间:" + RunTime + "h");
|
||||
|
||||
StringBuilder _cellVoltage = new StringBuilder("");//电池电压 --浮点型,低字节在前,高字节在后,单位: v。
|
||||
for (int i = 96 + multiplier; i <= 103 + multiplier; i++)
|
||||
|
@ -1491,7 +1500,7 @@ namespace ShuiBiao
|
|||
Console.WriteLine("管径:" + pipeSize + "mm");
|
||||
capacity.Clear().Append(interconvert(0, 0, capacity.ToString()));
|
||||
Console.WriteLine("量程:" + capacity);//???
|
||||
//Console.WriteLine("阻尼系数:" + hexToASCII(dampingFactor.ToString()));
|
||||
//Console.WriteLine("阻尼系数:" + hexToASCII(dampingFactor.ToString()));
|
||||
typeMalfunction(diagnose);
|
||||
|
||||
//数据校验 --版本号-故障代码
|
||||
|
@ -1691,13 +1700,13 @@ namespace ShuiBiao
|
|||
switch ((TypeFunctionCode)int.Parse(str))
|
||||
{
|
||||
case TypeFunctionCode.登录帧:
|
||||
LoginFrameAnalysis(message, ipEnd, socket);
|
||||
LoginFrameAnalysis(message);
|
||||
break;
|
||||
case TypeFunctionCode.数据帧1:
|
||||
dataFramesAnalysis(message, str, baseNum);
|
||||
break;
|
||||
case TypeFunctionCode.校时命令:
|
||||
clockAnalysis(message, ipEnd);
|
||||
clockAnalysis(message);
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("无此功能码: " + str);
|
||||
|
@ -1869,7 +1878,5 @@ namespace ShuiBiao
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
------------------------------------------------
|
||||
2023-02-27 16:55:04,179 [4] INFO loginfo - 接收到 127.0.0.1:59905: 40 3A 00 46 15 13 32 70 24 76 01 46 00 23 02 27 10 55 05 00 01 41 01 4A 26 48 5A 47 39 36 5F 32 30 31 32 30 37 56 31 2D 31 2E 31 23 4B 18 4C 0E 10 4D 66 34 31 35 31 33 33 32 37 30 32 34 37 36 4F 07 00 00 00 00 00 00 00 17 0D 0A 40 3A 00 22 15 13 32 70 24 76 08 01 01 01 41 01 00 23 02 27 10 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 83 0D 0A
|
||||
2023-02-27 16:55:04,188 [4] INFO loginfo - 登录帧校验失败: 403A0046151332702476014600230227105505000141014A26485A4739365F32303132303756312D312E31234B184C0E104D66343135313333323730323437364F0700000000000000170D0A403A0022151332702476080101014101002302271054000000000000000000000000000000830D0A
|
||||
2023-02-27 16:59:43,273 [4] INFO loginfo - 接收到 127.0.0.1:59905: 40 3A 00 46 15 13 32 70 24 76 01 46 00 23 02 27 10 55 05 00 01 41 01 4A 26 48 5A 47 39 36 5F 32 30 31 32 30 37 56 31 2D 31 2E 31 23 4B 18 4C 0E 10 4D 66 34 31 35 31 33 33 32 37 30 32 34 37 36 4F 07 00 00 00 00 00 00 00 17 0D 0A 40 3A 00 22 15 13 32 70 24 76 08 01 01 01 41 01 00 23 02 27 10 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 83 0D 0A
|
||||
2023-02-27 17:00:09,785 [4] INFO loginfo - 登录帧校验失败: 403A0046151332702476014600230227105505000141014A26485A4739365F32303132303756312D312E31234B184C0E104D66343135313333323730323437364F0700000000000000170D0A403A0022151332702476080101014101002302271054000000000000000000000000000000830D0A
|
||||
2023-02-27 17:00:18,585 [4] INFO loginfo - 接收到 127.0.0.1:59905: 40 3A 00 46 15 13 32 70 24 76 01 46 00 23 02 27 10 55 05 00 01 41 01 4A 26 48 5A 47 39 36 5F 32 30 31 32 30 37 56 31 2D 31 2E 31 23 4B 18 4C 0E 10 4D 66 34 31 35 31 33 33 32 37 30 32 34 37 36 4F 07 00 00 00 00 00 00 00 17 0D 0A 40 3A 00 22 15 13 32 70 24 76 08 01 01 01 41 01 00 23 02 27 10 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 83 0D 0A
|
||||
------------------------------------------------
|
||||
2023-02-27 17:01:28,034 [4] INFO loginfo - 接收到 127.0.0.1:59944: 40 3A 00 46 15 13 32 70 24 76 01 46 00 23 02 27 10 55 05 00 01 41 01 4A 26 48 5A 47 39 36 5F 32 30 31 32 30 37 56 31 2D 31 2E 31 23 4B 18 4C 0E 10 4D 66 34 31 35 31 33 33 32 37 30 32 34 37 36 4F 07 00 00 00 00 00 00 00 17 0D 0A 40 3A 00 22 15 13 32 70 24 76 08 01 01 01 41 01 00 23 02 27 10 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 83 0D 0A
|
||||
------------------------------------------------
|
||||
2023-02-27 17:10:42,313 [4] INFO loginfo - 接收到 127.0.0.1:60011: 40 3A 00 3B 15 13 04 90 07 14 08 01 01 01 41 84 00 20 03 27 06 50 26 0A 00 00 01 76 00 00 15 23 00 00 01
|
||||
------------------------------------------------
|
||||
2023-02-27 17:12:15,786 [4] INFO loginfo - 接收到 127.0.0.1:60017: 40 3A 00 46 15 13 04 90 07 14 01 49 00 20 03 27 06 50 46 00 01 41 84 4A 26 48 5A 47 39 36 5F 32 30 31 32 30 37 56 31 2D 31 2E 31 23 4B 18 4C 0E 10 4D 66 34 31 35 31 33 30 34 39 30 30 37 31 34 4F 07 00 00 00 00 00 00 00 3A 0D 0A
|
||||
2023-02-27 17:13:16,456 [5] INFO loginfo - 接收到 127.0.0.1:60022: 40 3A 00 3B 15 13 04 90 07 14 08 01 01 01 41 84 00 20 03 27 06 50 26 0A 00 00 01 76 00 00 15 23 00 00 01 00 00 00 12 00 00 00 01 50 00 00 28 32 00 00 09 01 10 91 CA 0D 0A
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1 +1 @@
|
|||
0f052d2ac195e501443374a694b72da723648431
|
||||
4c45faaedcb9e5670ec8ff8478bc1367530a318d
|
||||
|
|
|
@ -7,3 +7,14 @@ D:\XM\C#\ZHshuibiao\shuibiao\obj\Debug\ShuiBiao.csproj.CoreCompileInputs.cache
|
|||
D:\XM\C#\ZHshuibiao\shuibiao\obj\Debug\ShuiBiao.csproj.CopyComplete
|
||||
D:\XM\C#\ZHshuibiao\shuibiao\obj\Debug\ShuiBiao.exe
|
||||
D:\XM\C#\ZHshuibiao\shuibiao\obj\Debug\ShuiBiao.pdb
|
||||
D:\XM\C#\DianBiao_TCP\ZHshuibiao\shuibiao\bin\Debug\ShuiBiao.exe.config
|
||||
D:\XM\C#\DianBiao_TCP\ZHshuibiao\shuibiao\bin\Debug\ShuiBiao.exe
|
||||
D:\XM\C#\DianBiao_TCP\ZHshuibiao\shuibiao\bin\Debug\ShuiBiao.pdb
|
||||
D:\XM\C#\DianBiao_TCP\ZHshuibiao\shuibiao\bin\Debug\log4net.dll
|
||||
D:\XM\C#\DianBiao_TCP\ZHshuibiao\shuibiao\bin\Debug\log4net.xml
|
||||
D:\XM\C#\DianBiao_TCP\ZHshuibiao\shuibiao\obj\Debug\ShuiBiao.csproj.AssemblyReference.cache
|
||||
D:\XM\C#\DianBiao_TCP\ZHshuibiao\shuibiao\obj\Debug\ShuiBiao.csproj.SuggestedBindingRedirects.cache
|
||||
D:\XM\C#\DianBiao_TCP\ZHshuibiao\shuibiao\obj\Debug\ShuiBiao.csproj.CoreCompileInputs.cache
|
||||
D:\XM\C#\DianBiao_TCP\ZHshuibiao\shuibiao\obj\Debug\ShuiBiao.csproj.CopyComplete
|
||||
D:\XM\C#\DianBiao_TCP\ZHshuibiao\shuibiao\obj\Debug\ShuiBiao.exe
|
||||
D:\XM\C#\DianBiao_TCP\ZHshuibiao\shuibiao\obj\Debug\ShuiBiao.pdb
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue