1 地震仪告警记录中故障次数隐藏;电力载波机和光电交换机的供电状态隐藏; 2 除漏水和保护板事件的数据按照浮点数解析,别的按照整数解析; 3 解决TCP Server和Client存在的问题,包括无法监测到客户端连接,无法监测到服务端断开等问题;
77 lines
1.8 KiB
C#
77 lines
1.8 KiB
C#
using JiangsuEarthquake.Common;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace JiangsuEarthquake.Models
|
|
{
|
|
public class ComModel2 : NotifyBase
|
|
{
|
|
private RTUModel2 rtuInstance2 = null;
|
|
|
|
private VolCurCollectorModel2 volCurCollectorModel2 { get; set; } = new VolCurCollectorModel2();
|
|
|
|
private bool isConnected;
|
|
|
|
/// <summary>
|
|
/// 是否连接
|
|
/// </summary>
|
|
public bool IsConnected
|
|
{
|
|
get { return isConnected; }
|
|
set { isConnected = value; this.DoNotify(); }
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 建立连接
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public bool DoConnect(SerialInfo serialInfo)
|
|
{
|
|
rtuInstance2 = RTUModel2.GetInstance(serialInfo);
|
|
//rtuInstance2.ResponseData = new Action<List<byte>>(volCurCollectorModel2.ParsingData);
|
|
IsConnected = rtuInstance2.Connection();
|
|
return IsConnected;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 断开连接
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public bool DisConnect()
|
|
{
|
|
rtuInstance2.Dispose();
|
|
IsConnected = false;
|
|
return IsConnected;
|
|
}
|
|
|
|
|
|
public bool SendMessage(byte[] _send)
|
|
{
|
|
if (_send.Length == 0)
|
|
return false;
|
|
try
|
|
{
|
|
if (IsConnected)
|
|
{
|
|
rtuInstance2.Send(_send);
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|