|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Collections;
|
|
|
using System.Threading;
|
|
|
using System.Net;
|
|
|
using System.Net.Sockets;
|
|
|
using System.Data.SqlClient;
|
|
|
using System.Runtime.Remoting;
|
|
|
using System.Runtime.Remoting.Channels;
|
|
|
using System.Runtime.Remoting.Channels.Tcp;
|
|
|
using System.Globalization;
|
|
|
using UPPLibs;
|
|
|
using RemoteObjects;
|
|
|
using System.Diagnostics;
|
|
|
using System.ServiceProcess;
|
|
|
|
|
|
namespace CommService
|
|
|
{
|
|
|
/*
|
|
|
*类名称:TCPServer
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*功能描述:集中器通信上层管理类
|
|
|
*/
|
|
|
class TCPServer
|
|
|
{
|
|
|
private int srvport;
|
|
|
|
|
|
private bool listenloop;
|
|
|
private Thread tListenner;
|
|
|
private IPAddress ipadd;
|
|
|
|
|
|
private static List<TCPHandler> TCPHandlerList = new List<TCPHandler>();
|
|
|
//private static Hashtable TCPHandlerTable = new Hashtable();
|
|
|
private static Mutex mut = new Mutex();
|
|
|
//private struRequestInQueue sCurrentReq;
|
|
|
private uint unTimeingCount = 0;
|
|
|
|
|
|
private string connectString = Common.configReader.sConnectString;
|
|
|
|
|
|
private DateTime dtPoint;
|
|
|
private DateTime dtPointBegin;
|
|
|
private DateTime dtPointEnd;
|
|
|
|
|
|
public bool bPointCollect = false;
|
|
|
|
|
|
private Mutex mutForHistoryData = new Mutex();
|
|
|
private Hashtable htRecordForHistoryData = new Hashtable();
|
|
|
private int nDaysofHistoryData = 7;
|
|
|
|
|
|
private Hashtable htOnline = new Hashtable();
|
|
|
private Mutex mutForOnline = new Mutex();
|
|
|
private int nOffLineHours;
|
|
|
|
|
|
/*
|
|
|
*方法名称:RefreshHeartBeat
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:string sTID 集中器ID
|
|
|
*返回描述:void
|
|
|
*功能描述:为离线告警刷新心跳值
|
|
|
*/
|
|
|
|
|
|
public void RefreshHeartBeat(string sTID)
|
|
|
{
|
|
|
mutForOnline.WaitOne();
|
|
|
if (htOnline.ContainsKey(sTID) == false)
|
|
|
{
|
|
|
htOnline.Add(sTID, DateTime.Now);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
htOnline[sTID] = DateTime.Now;
|
|
|
}
|
|
|
mutForOnline.ReleaseMutex();
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:CheckOnline
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:void
|
|
|
*返回描述:void
|
|
|
*功能描述:检查离线告警,存库
|
|
|
*/
|
|
|
private void CheckOnline()
|
|
|
{
|
|
|
string sTID = "";
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
TimeSpan ts = new TimeSpan();
|
|
|
bool res = false;
|
|
|
|
|
|
mutForOnline.WaitOne();
|
|
|
|
|
|
foreach (DictionaryEntry de in htOnline)
|
|
|
{
|
|
|
ts = dtNow - (DateTime)de.Value;
|
|
|
//达到告警时限
|
|
|
if (ts.Hours >= nOffLineHours)
|
|
|
{
|
|
|
sTID = (string)de.Key;
|
|
|
htOnline.Remove(de.Key);
|
|
|
res = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
mutForOnline.ReleaseMutex();
|
|
|
//存库
|
|
|
if (res == true)
|
|
|
{
|
|
|
MessageHandler messageHandler = new MessageHandler(null);
|
|
|
messageHandler.SaveOffLineWarning(sTID, ts.Hours);
|
|
|
}
|
|
|
}
|
|
|
/*
|
|
|
*方法名称:ReplaceSameClient
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:string clientName 集中器ID
|
|
|
*返回描述:void
|
|
|
*功能描述:如果有同名的处理实例,取代处理
|
|
|
*/
|
|
|
|
|
|
public void ReplaceSameClient(string clientName)
|
|
|
{
|
|
|
//lock
|
|
|
mut.WaitOne();
|
|
|
|
|
|
if (TCPHandlerList.Count > 0)
|
|
|
{
|
|
|
TCPHandlerList.ForEach(delegate(TCPHandler tcpHandler)
|
|
|
{
|
|
|
if (tcpHandler.tName == clientName)
|
|
|
{
|
|
|
tcpHandler.SetReplaceFlag(true);
|
|
|
|
|
|
tcpHandler.Close();
|
|
|
Common.logFile.write("[" + clientName + "] " + "连接被一个同名的终端取代", LogFile.LOGLVL_NORMAL);
|
|
|
|
|
|
return;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//unlock
|
|
|
mut.ReleaseMutex();
|
|
|
}
|
|
|
/*
|
|
|
*方法名称:AddTCPHandler
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:TCPHandler tcpHandler 集中器通信处理类实例
|
|
|
*返回描述:void
|
|
|
*功能描述:向列表中加入集中器通信处理类实例
|
|
|
*/
|
|
|
|
|
|
public void AddTCPHandler(TCPHandler tcpHandler)
|
|
|
{
|
|
|
//lock
|
|
|
mut.WaitOne();
|
|
|
|
|
|
//add
|
|
|
TCPHandlerList.Add(tcpHandler);
|
|
|
|
|
|
//unlock
|
|
|
mut.ReleaseMutex();
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:RemoveTCPHandler
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:TCPHandler tcpHandler 集中器通信处理类实例
|
|
|
*返回描述:void
|
|
|
*功能描述:从列表中删除集中器通信处理类实例
|
|
|
*/
|
|
|
public void RemoveTCPHandler(TCPHandler tcpHandler)
|
|
|
{
|
|
|
//lock
|
|
|
mut.WaitOne();
|
|
|
|
|
|
//remove
|
|
|
TCPHandlerList.Remove(tcpHandler);
|
|
|
|
|
|
//unlock
|
|
|
mut.ReleaseMutex();
|
|
|
}
|
|
|
//
|
|
|
/*
|
|
|
*方法名称:TCPServer
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:string ip 监听IP, int port 监听端口
|
|
|
*返回描述:void
|
|
|
*功能描述:TCPServer 构造函数,初始化处理
|
|
|
*/
|
|
|
|
|
|
public TCPServer(string ip, int port)
|
|
|
{
|
|
|
srvport = port;
|
|
|
listenloop = true;
|
|
|
ipadd = IPAddress.Parse(ip);
|
|
|
Common.logFile.write("TCPServer 初始化," + ip + " " + port, LogFile.LOGLVL_NORMAL);
|
|
|
nOffLineHours = Common.configReader.nOffLineHours;
|
|
|
|
|
|
if (nOffLineHours < 1)
|
|
|
{
|
|
|
nOffLineHours = 1;
|
|
|
}
|
|
|
else if (nOffLineHours > 24)
|
|
|
{
|
|
|
nOffLineHours = 24;
|
|
|
}
|
|
|
|
|
|
UpdateNewTimePoint();
|
|
|
}
|
|
|
/*
|
|
|
*方法名称:UpdateNewTimePoint
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:void
|
|
|
*返回描述:void
|
|
|
*功能描述:更新整点时间段,正负55秒
|
|
|
*/
|
|
|
private void UpdateNewTimePoint()
|
|
|
{
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
dtPoint = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, dtNow.Hour, 0, 0);
|
|
|
dtPoint = dtPoint.AddHours(1);
|
|
|
dtPointBegin = dtPoint.AddSeconds(-55);
|
|
|
dtPointEnd = dtPoint.AddSeconds(55);
|
|
|
|
|
|
UpdateNewTimePointForHistoryData();
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:UpdateNewTimePointForHistoryData
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:void
|
|
|
*返回描述:void
|
|
|
*功能描述:更新历史整点时间点,添加最新的,删除最久的
|
|
|
*/
|
|
|
private void UpdateNewTimePointForHistoryData()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
DateTime dtPoint = new DateTime(dtNow.Year, dtNow.Month, dtNow.Day, dtNow.Hour, 0, 0);
|
|
|
dtPoint = dtPoint.AddHours(1);
|
|
|
|
|
|
mutForHistoryData.WaitOne();
|
|
|
|
|
|
if (htRecordForHistoryData.Count >= nDaysofHistoryData * 24)
|
|
|
{
|
|
|
//加入最新时间点
|
|
|
htRecordForHistoryData.Add(dtPoint, new Hashtable());
|
|
|
Common.logFile.write("维护历史数据整点列表,添加:" + dtPoint, LogFile.LOGLVL_DEBUG);
|
|
|
//去掉时间点最早的一个
|
|
|
dtPoint = dtPoint.AddHours(-nDaysofHistoryData * 24);
|
|
|
htRecordForHistoryData.Remove(dtPoint);
|
|
|
Common.logFile.write("维护历史数据整点列表,移除:" + dtPoint, LogFile.LOGLVL_DEBUG);
|
|
|
}
|
|
|
else if (htRecordForHistoryData.Count == 0)
|
|
|
{
|
|
|
htRecordForHistoryData.Add(dtPoint, new Hashtable());
|
|
|
for (int i = 0; i < (nDaysofHistoryData * 24 - 1); i++)
|
|
|
{
|
|
|
dtPoint = dtPoint.AddHours(-1);
|
|
|
htRecordForHistoryData.Add(dtPoint, new Hashtable());
|
|
|
}
|
|
|
Common.logFile.write("初始化历史数据整点列表,整点数量:" + htRecordForHistoryData.Count, LogFile.LOGLVL_DEBUG);
|
|
|
}
|
|
|
|
|
|
//nDaysofHistoryData
|
|
|
mutForHistoryData.ReleaseMutex();
|
|
|
}
|
|
|
catch (Exception e1)
|
|
|
{
|
|
|
Common.logFile.write("UpdateNewTimePointForHistoryData出现例外,Exception:" + e1, LogFile.LOGLVL_ERROR);
|
|
|
}
|
|
|
}
|
|
|
/*
|
|
|
*方法名称:QueryTimePointForHistoryData
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:string sHistoryData 采集时间, string sMeterID 仪表编号
|
|
|
*返回描述:bool true 是,false 否
|
|
|
*功能描述:查询历史数据是否是整点数据
|
|
|
*/
|
|
|
|
|
|
public bool QueryTimePointForHistoryData(string sHistoryData, string sMeterID)
|
|
|
{
|
|
|
bool res = false;
|
|
|
try
|
|
|
{
|
|
|
IFormatProvider culture = new CultureInfo("zh-CN", true);
|
|
|
|
|
|
if (sHistoryData.Length == 21)
|
|
|
{
|
|
|
sHistoryData = sHistoryData.Substring(1, 19);
|
|
|
}
|
|
|
DateTime dtHistoryData = DateTime.Parse(sHistoryData, culture);
|
|
|
|
|
|
mutForHistoryData.WaitOne();
|
|
|
//htRecordForHistoryData
|
|
|
foreach (DictionaryEntry de in htRecordForHistoryData)
|
|
|
{
|
|
|
DateTime dtKey = (DateTime)de.Key;
|
|
|
if (dtHistoryData >= dtKey.AddSeconds(-55) && dtHistoryData <= dtKey.AddSeconds(55))
|
|
|
{
|
|
|
Hashtable ht = (Hashtable)de.Value;
|
|
|
if (ht.ContainsKey(sMeterID) == false)
|
|
|
{
|
|
|
res = true;
|
|
|
ht.Add(sMeterID, null);
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
mutForHistoryData.ReleaseMutex();
|
|
|
}
|
|
|
catch (Exception e1)
|
|
|
{
|
|
|
Common.logFile.write("QueryTimePointForHistoryData产生例外,Exception:" + e1.ToString(), LogFile.LOGLVL_ERROR);
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
/*
|
|
|
*方法名称:ListenThreadProc
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:void
|
|
|
*返回描述:void
|
|
|
*功能描述:通信监听线程函数
|
|
|
*/
|
|
|
|
|
|
public void ListenThreadProc()
|
|
|
{
|
|
|
|
|
|
Common.logDebugFile.write("=====ListenThreadProc 启动...", LogFile.LOGLVL_NORMAL);
|
|
|
listenloop = true;
|
|
|
Hashtable props = new Hashtable();
|
|
|
props.Add("useIpAddress", true);
|
|
|
props.Add("bindTo", Common.configReader.sRemotingIP);
|
|
|
props.Add("port", Common.configReader.nRemotingPort.ToString());
|
|
|
MessageHandler m = new MessageHandler();
|
|
|
MessageHandler.htEParams=new Hashtable();
|
|
|
//暂时不进行初始化
|
|
|
//while (MessageHandler.htEParams.Count == 0)
|
|
|
//{
|
|
|
// Thread.Sleep(30000);
|
|
|
// m.Init();
|
|
|
//}
|
|
|
Common.logDebugFile.write("进入监听循环...", LogFile.LOGLVL_NORMAL);
|
|
|
while (listenloop)
|
|
|
{
|
|
|
TcpListener tcpListener = null;
|
|
|
try
|
|
|
{
|
|
|
Common.logDebugFile.write("初始化TcpListener...", LogFile.LOGLVL_NORMAL);
|
|
|
tcpListener = new TcpListener(ipadd, srvport);
|
|
|
|
|
|
// Start listening for client requests
|
|
|
Common.logDebugFile.write("启动TcpListener...", LogFile.LOGLVL_NORMAL);
|
|
|
tcpListener.Start();
|
|
|
|
|
|
//props.Add( "exclusiveAddressUse", "false" );
|
|
|
|
|
|
TcpServerChannel channel = new TcpServerChannel(props, null);
|
|
|
|
|
|
//TcpServerChannel channel = new TcpServerChannel(Common.configReader.nRemotingPort);
|
|
|
|
|
|
ChannelServices.RegisterChannel(channel, false);
|
|
|
RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemoteObjects.ReqHandler),
|
|
|
"RemoteObject", WellKnownObjectMode.SingleCall);
|
|
|
|
|
|
//Enter the listening loop
|
|
|
|
|
|
Common.logDebugFile.write("进入连接循环...", LogFile.LOGLVL_NORMAL);
|
|
|
while (listenloop)
|
|
|
{
|
|
|
// Perform a blocking call to accept requests.
|
|
|
// You could also user server.AcceptSocket() here.
|
|
|
|
|
|
TcpClient client = null;
|
|
|
try
|
|
|
{
|
|
|
if (tcpListener.Pending() == false)
|
|
|
{
|
|
|
Thread.Sleep(500);
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
//Common.logDebugFile.write("1-等待连接请求...(1-2-3)", LogFile.LOGLVL_NORMAL);
|
|
|
client = tcpListener.AcceptTcpClient();
|
|
|
|
|
|
//Common.logDebugFile.write("2-建立新连接...", LogFile.LOGLVL_NORMAL);
|
|
|
|
|
|
TCPHandler tcpHandler = new TCPHandler(client);
|
|
|
|
|
|
tcpHandler.SetTimeOut(Common.configReader.nTerminalTimeOut);
|
|
|
tcpHandler.Start();
|
|
|
|
|
|
AddTCPHandler(tcpHandler);
|
|
|
|
|
|
//Common.logDebugFile.write("3-建立新连接完成。\r\n\r\n", LogFile.LOGLVL_NORMAL);
|
|
|
|
|
|
//if (count >= 5)
|
|
|
//{
|
|
|
// tcpListener.Stop();
|
|
|
// break;
|
|
|
//}
|
|
|
//count++;
|
|
|
|
|
|
}
|
|
|
catch (Exception e2)
|
|
|
{
|
|
|
Common.logErrFile.write("监听程序 e2---SocketException: " + e2.ToString(), LogFile.LOGLVL_ERROR);
|
|
|
if (listenloop == false)
|
|
|
{
|
|
|
break;
|
|
|
}
|
|
|
Thread.Sleep(1000);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
//if (tcpListener != null)
|
|
|
//{
|
|
|
// tcpListener.Stop();
|
|
|
//}
|
|
|
}
|
|
|
catch (Exception e1)
|
|
|
{
|
|
|
Common.logErrFile.write("监听程序 e1---Exception: " + e1.ToString(), LogFile.LOGLVL_ERROR);
|
|
|
if (listenloop == true)
|
|
|
{
|
|
|
Thread.Sleep(5000);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
Common.logDebugFile.write("<<<<<<监听程序 退出>>>>>>>>", LogFile.LOGLVL_NORMAL);
|
|
|
}
|
|
|
/*
|
|
|
*方法名称:Start
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:void
|
|
|
*返回描述:void
|
|
|
*功能描述:启动通信监听线程
|
|
|
*/
|
|
|
|
|
|
public void Start()
|
|
|
{
|
|
|
//start listening thread
|
|
|
//Thread.Sleep(60000);
|
|
|
tListenner = new Thread(new ThreadStart(ListenThreadProc));
|
|
|
tListenner.IsBackground = true;
|
|
|
tListenner.Start();
|
|
|
Common.logSystemFile.write("启动侦听 成功", LogFile.LOGLVL_NORMAL);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:Stop
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:void
|
|
|
*返回描述:void
|
|
|
*功能描述:停止通信监听线程,资源释放
|
|
|
*/
|
|
|
public void Stop()
|
|
|
{
|
|
|
Common.logFile.write("停止侦听,处理中...", LogFile.LOGLVL_NORMAL);
|
|
|
listenloop = false;
|
|
|
//tcpListener.Stop();
|
|
|
|
|
|
TCPHandler tw = null;
|
|
|
bool loop = true;
|
|
|
while (loop)
|
|
|
{
|
|
|
loop = false;
|
|
|
tw = null;
|
|
|
//lock
|
|
|
mut.WaitOne();
|
|
|
if (TCPHandlerList.Count > 0)
|
|
|
{
|
|
|
tw = TCPHandlerList.ElementAt(0);
|
|
|
|
|
|
loop = true;
|
|
|
tw.stoped = true;
|
|
|
}
|
|
|
//unlock
|
|
|
mut.ReleaseMutex();
|
|
|
if (tw != null)
|
|
|
{
|
|
|
tw.Close();
|
|
|
tw.tWorker.Join();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
TCPHandlerList.Clear();
|
|
|
|
|
|
//tListenner.Join();
|
|
|
|
|
|
Common.logFile.write("停止侦听 成功", LogFile.LOGLVL_NORMAL);
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:GetTCPHandler
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int hashCode 通信处理实例的哈希编码
|
|
|
*返回描述:TCPHandler 通信处理实例
|
|
|
*功能描述:从列表中查询通信处理实例
|
|
|
*/
|
|
|
public TCPHandler GetTCPHandler(int hashCode)
|
|
|
{
|
|
|
TCPHandler tcpHandler = null;
|
|
|
//lock
|
|
|
mut.WaitOne();
|
|
|
|
|
|
TCPHandlerList.ForEach(delegate(TCPHandler name)
|
|
|
{
|
|
|
if (name.tName.GetHashCode() == hashCode)
|
|
|
{
|
|
|
tcpHandler = name;
|
|
|
return;
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//unlock
|
|
|
mut.ReleaseMutex();
|
|
|
|
|
|
return tcpHandler;
|
|
|
}
|
|
|
/*
|
|
|
*方法名称:handleRSCommand
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:ref TCPHandler tw 通信处理实例,
|
|
|
*byte flagCtrlF 功能码,
|
|
|
*object param 对象参数,
|
|
|
*ref struFrame resp 应答消息帧结构
|
|
|
*返回描述:bool true,处理成功,false 失败
|
|
|
*功能描述:remoting命令处理函数
|
|
|
*/
|
|
|
|
|
|
private bool handleRSCommand(ref TCPHandler tw, byte flagCtrlF, object param, ref struFrame resp)
|
|
|
{
|
|
|
bool res = false;
|
|
|
struFrame sFrame = new struFrame();
|
|
|
if (UPPHandler.PreframePacking(flagCtrlF, param, ref sFrame) == true)
|
|
|
{
|
|
|
byte[] frame = null;
|
|
|
if (UPPHandler.framePacking(ref sFrame, ref frame) == true)
|
|
|
{
|
|
|
struRequestInQueue sReqInQ = new struRequestInQueue();
|
|
|
sReqInQ.frameInfo = sFrame;
|
|
|
sReqInQ.bMatchOK = false;
|
|
|
sReqInQ.frameBytes = frame;
|
|
|
sReqInQ.frameResp = new struFrame();
|
|
|
sReqInQ.handleReqEvent = new AutoResetEvent(false);
|
|
|
sReqInQ.handleReqEvent.Reset();
|
|
|
tw.PutNewReq(ref sReqInQ);
|
|
|
|
|
|
if (sReqInQ.handleReqEvent.WaitOne(16000, false) == true)
|
|
|
{
|
|
|
Common.logFile.write("消息匹配 OK", LogFile.LOGLVL_DEBUG);
|
|
|
res = true;
|
|
|
//Common.logFile.write("sReqInQ.frameResp:" + sReqInQ.frameResp.GetHashCode().ToString(), LogFile.LOGLVL_DEBUG);
|
|
|
UPPHandler.frameCopy(ref sReqInQ.frameResp, ref resp);
|
|
|
|
|
|
//Common.logFile.write("读时间 成功!!!");
|
|
|
}
|
|
|
|
|
|
sReqInQ.handleReqEvent.Close();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:TimeOut
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:void
|
|
|
*返回描述:void
|
|
|
*功能描述:定时处理函数
|
|
|
*/
|
|
|
|
|
|
public void TimeOut()
|
|
|
{
|
|
|
CheckOnline();
|
|
|
|
|
|
CheckPointTime();
|
|
|
|
|
|
CheckHeartBeatTimeout();
|
|
|
}
|
|
|
/*
|
|
|
*方法名称:CheckHeartBeatTimeout
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:void
|
|
|
*返回描述:void
|
|
|
*功能描述:检查集中器心跳超时,是则踢出
|
|
|
*/
|
|
|
private void CheckHeartBeatTimeout()
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
TCPHandler tw = null;
|
|
|
bool loop = true;
|
|
|
unTimeingCount++;
|
|
|
bool bTiming = false;
|
|
|
//0 不校时
|
|
|
if (Common.configReader.nIntervalHoursForTiming > 0
|
|
|
&& unTimeingCount >= 3600 * Common.configReader.nIntervalHoursForTiming)
|
|
|
{
|
|
|
bTiming = true;
|
|
|
unTimeingCount = 0;
|
|
|
}
|
|
|
|
|
|
while (loop)
|
|
|
{
|
|
|
loop = false;
|
|
|
tw = null;
|
|
|
//lock
|
|
|
mut.WaitOne();
|
|
|
for (int i = 0; i < TCPHandlerList.Count; i++)
|
|
|
{
|
|
|
tw = TCPHandlerList.ElementAt(i);
|
|
|
if (tw == null)
|
|
|
{
|
|
|
loop = true;
|
|
|
TCPHandlerList.RemoveAt(i);
|
|
|
break;
|
|
|
}
|
|
|
if (tw.CheckTimeOut() == false)
|
|
|
{
|
|
|
//TCPWorkerList.Remove(tw);
|
|
|
TCPHandlerList.RemoveAt(i);
|
|
|
loop = true;
|
|
|
break;
|
|
|
}
|
|
|
if (bTiming == true)
|
|
|
{
|
|
|
//ReqHandler reqHandler = new ReqHandler();
|
|
|
//reqHandler.SetTime(tw.tName);
|
|
|
tw.ExecuteTiming();
|
|
|
}
|
|
|
}
|
|
|
//unlock
|
|
|
mut.ReleaseMutex();
|
|
|
|
|
|
if (tw != null && loop == true)
|
|
|
{
|
|
|
Common.logFile.write("[" + tw.tName + "]" + " 无心跳等待超时,链接被踢出 Kickoff", LogFile.LOGLVL_NORMAL);
|
|
|
|
|
|
if (tw.tName.CompareTo("未知终端") != 0)
|
|
|
{
|
|
|
//tw.SaveKickoffInfo(DateTime.Now);
|
|
|
tw.bKickOff = true;
|
|
|
}
|
|
|
|
|
|
tw.Close();
|
|
|
|
|
|
if (tw.tWorker.IsAlive)
|
|
|
{
|
|
|
if (tw.tWorker.Join(5000) == false)
|
|
|
tw.tWorker.Abort();
|
|
|
}
|
|
|
|
|
|
tw = null;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
catch
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
/*
|
|
|
*方法名称:CheckPointTime
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:void
|
|
|
*返回描述:void
|
|
|
*功能描述:检查整点采集时间段,更新采集时间段
|
|
|
*/
|
|
|
|
|
|
private void CheckPointTime()
|
|
|
{
|
|
|
DateTime dtNow = DateTime.Now;
|
|
|
|
|
|
if ((dtNow >= dtPointBegin) && (dtNow <= dtPointEnd))
|
|
|
{
|
|
|
if (this.bPointCollect == false)
|
|
|
{
|
|
|
bPointCollect = true;
|
|
|
Common.logFile.write("Collect time now ON>>>>>>>>>>>>>>>>>>>>>>>>>>>>" + dtPoint + "|" + dtPointBegin + "-" + dtPointEnd, LogFile.LOGLVL_DEBUG);
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (this.bPointCollect == true)
|
|
|
{
|
|
|
bPointCollect = false;
|
|
|
UpdateNewTimePoint();
|
|
|
Common.logFile.write("Collect time now Off<<<<<<<<<<<<<<<<<<<<<<<<<<<<" + dtPoint + "|" + dtPointBegin + "-" + dtPointEnd, LogFile.LOGLVL_DEBUG);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:RS_AdjustTime
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 通信处理实例的哈希编码
|
|
|
*返回描述:bool true 校时成功,false 失败
|
|
|
*功能描述:对集中器校时,生成校时消息帧,判断应答是否成功
|
|
|
*/
|
|
|
private bool RS_AdjustTime(int nHashCode)
|
|
|
{
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struWriteData wrData = new struWriteData();
|
|
|
wrData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
wrData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (wrData.flagDTN != 'E')
|
|
|
//{
|
|
|
// MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return;
|
|
|
//}
|
|
|
//逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
wrData.addrDNL[0] = (byte)(n / 256);
|
|
|
wrData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
wrData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志(写对象)
|
|
|
wrData.flagCtrlF = 0x08;
|
|
|
//测量点标志 (终端)
|
|
|
wrData.flagPoint = 0x00;
|
|
|
|
|
|
//帧序号
|
|
|
wrData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//低级权限
|
|
|
wrData.flagAUT = 0x00;
|
|
|
//口令
|
|
|
wrData.passwd = new byte[3];
|
|
|
wrData.passwd[0] = 0x31;
|
|
|
wrData.passwd[1] = 0x32;
|
|
|
wrData.passwd[2] = 0x33;
|
|
|
|
|
|
//数据编号与数据
|
|
|
wrData.numPairs = new byte[8];
|
|
|
|
|
|
wrData.numPairs[0] = 0x80;
|
|
|
wrData.numPairs[1] = 0x30;
|
|
|
|
|
|
wrData.numPairs[2] = (byte)0; //秒
|
|
|
wrData.numPairs[3] = (byte)0; //分
|
|
|
|
|
|
wrData.numPairs[4] = (byte)0; //时
|
|
|
wrData.numPairs[5] = (byte)0; //日
|
|
|
|
|
|
wrData.numPairs[6] = (byte)0; //月
|
|
|
wrData.numPairs[7] = (byte)0; //年
|
|
|
|
|
|
wrData.isTimeCorrecting = true;
|
|
|
|
|
|
struFrame sFrame = new struFrame();
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, wrData.flagCtrlF, wrData, ref sFrame);
|
|
|
//Common.logFile.write("handleRSCommand ====================");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:RS_GetData
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 通信处理实例的哈希编码,
|
|
|
*object oParam 招唤设置参数,
|
|
|
*ref object oResp 招唤返回数据
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:对集中器进行数据招唤,生成招唤消息帧,判断应答是否成功
|
|
|
*/
|
|
|
private bool RS_GetData(int nHashCode, object oParam, ref object oResp)
|
|
|
{
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
struParam param = (struParam)oParam;
|
|
|
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struReadData rdData = new struReadData();
|
|
|
rdData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
rdData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (rdData.flagDTN != 'E')
|
|
|
//{
|
|
|
// //MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return false;
|
|
|
//}
|
|
|
////逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
rdData.addrDNL[0] = (byte)(n / 256);
|
|
|
rdData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
rdData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志
|
|
|
rdData.flagCtrlF = 0x01;
|
|
|
//测量点标志
|
|
|
rdData.flagPoint = Convert.ToByte(param.sMID, 16);
|
|
|
|
|
|
//帧序号
|
|
|
rdData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//数据项编号
|
|
|
int size = 2 * param.lstParams.Count;
|
|
|
rdData.numPairs = new byte[size];
|
|
|
int i = 0;
|
|
|
foreach (int id in param.lstParams)
|
|
|
{
|
|
|
rdData.numPairs[i] = (byte)(id / 0x100);//终端时间
|
|
|
rdData.numPairs[i + 1] = (byte)(id % 0x100);//
|
|
|
i += 2;
|
|
|
}
|
|
|
struFrame sRespFrame = new struFrame();
|
|
|
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, rdData.flagCtrlF, rdData, ref sRespFrame);
|
|
|
if (res == true)
|
|
|
{
|
|
|
struFrame sFrame = (struFrame)sRespFrame;
|
|
|
Hashtable htData = new Hashtable();
|
|
|
MessageHandler mh = new MessageHandler(null);//????????????????????????
|
|
|
sFrame.tName = tw.tName;
|
|
|
res = mh.DataParsing(ref sFrame, ref htData);
|
|
|
oResp = htData;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:RS_GetHeartBeatInterval
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 通信处理实例的哈希编码,
|
|
|
*ref object oResp 读对象返回数据
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:对集中器进行读心跳间隔,生成读消息帧,判断应答是否成功
|
|
|
*/
|
|
|
private bool RS_GetHeartBeatInterval(int nHashCode, ref object oResp)
|
|
|
{
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struReadData rdData = new struReadData();
|
|
|
rdData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
rdData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (rdData.flagDTN != 'E')
|
|
|
//{
|
|
|
// //MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return false;
|
|
|
//}
|
|
|
////逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
rdData.addrDNL[0] = (byte)(n / 256);
|
|
|
rdData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
rdData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志
|
|
|
rdData.flagCtrlF = 0x01;
|
|
|
//测量点标志
|
|
|
rdData.flagPoint = 0x00;
|
|
|
|
|
|
//帧序号
|
|
|
rdData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//数据项编号
|
|
|
rdData.numPairs = new byte[2];
|
|
|
|
|
|
rdData.numPairs[0] = 0xDB;//
|
|
|
rdData.numPairs[1] = 0x41;//
|
|
|
|
|
|
struFrame sRespFrame = new struFrame();
|
|
|
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, rdData.flagCtrlF, rdData, ref sRespFrame);
|
|
|
if (res == true)
|
|
|
{
|
|
|
struFrame sFrame = (struFrame)sRespFrame;
|
|
|
int pointer = 1;
|
|
|
uint ID = (uint)(sFrame.strData[pointer] * 0x100 + sFrame.strData[pointer + 1]);
|
|
|
if (ID == 0xDB41)
|
|
|
{
|
|
|
string sInterval = sFrame.strData[pointer + 2].ToString("D2");
|
|
|
oResp = (object)sInterval;
|
|
|
Common.logFile.write("获取终端[" + tw.tName + "]心跳间隔:" + sInterval, LogFile.LOGLVL_NORMAL);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:RS_GetAutoSendInterval
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 通信处理实例的哈希编码,
|
|
|
*ref object oResp 读对象返回数据
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:对集中器进行读主动上传间隔,生成读消息帧,判断应答是否成功
|
|
|
*/
|
|
|
private bool RS_GetAutoSendInterval(int nHashCode, ref object oResp)
|
|
|
{
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struReadData rdData = new struReadData();
|
|
|
rdData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
rdData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (rdData.flagDTN != 'E')
|
|
|
//{
|
|
|
// //MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return false;
|
|
|
//}
|
|
|
////逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
rdData.addrDNL[0] = (byte)(n / 256);
|
|
|
rdData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
rdData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志
|
|
|
rdData.flagCtrlF = 0x01;
|
|
|
//测量点标志
|
|
|
rdData.flagPoint = 0x00;
|
|
|
|
|
|
//帧序号
|
|
|
rdData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//数据项编号
|
|
|
rdData.numPairs = new byte[2];
|
|
|
|
|
|
rdData.numPairs[0] = 0xDB;//
|
|
|
rdData.numPairs[1] = 0x42;//
|
|
|
|
|
|
struFrame sRespFrame = new struFrame();
|
|
|
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, rdData.flagCtrlF, rdData, ref sRespFrame);
|
|
|
if (res == true)
|
|
|
{
|
|
|
struFrame sFrame = (struFrame)sRespFrame;
|
|
|
int pointer = 1;
|
|
|
uint ID = (uint)(sFrame.strData[pointer] * 0x100 + sFrame.strData[pointer + 1]);
|
|
|
if (ID == 0xDB42)
|
|
|
{
|
|
|
string sInterval = sFrame.strData[pointer + 2].ToString("D2");
|
|
|
oResp = (object)sInterval;
|
|
|
Common.logFile.write("获取终端[" + tw.tName + "]主动上传间隔:" + sInterval, LogFile.LOGLVL_NORMAL);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:RS_GetTime
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 通信处理实例的哈希编码,
|
|
|
*ref object oResp 读对象返回数据
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:对集中器进行读当前时间,生成读消息帧,判断应答是否成功
|
|
|
*/
|
|
|
|
|
|
private bool RS_GetTime(int nHashCode, ref object oResp)
|
|
|
{
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struReadData rdData = new struReadData();
|
|
|
rdData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
rdData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (rdData.flagDTN != 'E')
|
|
|
//{
|
|
|
// //MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return false;
|
|
|
//}
|
|
|
////逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
rdData.addrDNL[0] = (byte)(n / 256);
|
|
|
rdData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
rdData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志
|
|
|
rdData.flagCtrlF = 0x01;
|
|
|
//测量点标志
|
|
|
rdData.flagPoint = 0x00;
|
|
|
|
|
|
//帧序号
|
|
|
rdData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//数据项编号
|
|
|
rdData.numPairs = new byte[2];
|
|
|
|
|
|
rdData.numPairs[0] = 0x80;//终端时间
|
|
|
rdData.numPairs[1] = 0x30;//
|
|
|
|
|
|
struFrame sRespFrame = new struFrame();
|
|
|
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, rdData.flagCtrlF, rdData, ref sRespFrame);
|
|
|
if (res == true)
|
|
|
{
|
|
|
struFrame sFrame = (struFrame)sRespFrame;
|
|
|
int pointer = 1;
|
|
|
uint ID = (uint)(sFrame.strData[pointer] * 0x100 + sFrame.strData[pointer + 1]);
|
|
|
if (ID == 0x8030)
|
|
|
{
|
|
|
string strDateTime = "20" + sFrame.strData[pointer + 7].ToString("x2")
|
|
|
+ "-" + sFrame.strData[pointer + 6].ToString("x2")
|
|
|
+ "-" + sFrame.strData[pointer + 5].ToString("x2")
|
|
|
+ " " + sFrame.strData[pointer + 4].ToString("x2")
|
|
|
+ ":" + sFrame.strData[pointer + 3].ToString("x2")
|
|
|
+ ":" + sFrame.strData[pointer + 2].ToString("x2");
|
|
|
oResp = (object)strDateTime;
|
|
|
Common.logFile.write("获取终端[" + tw.tName + "]时间:" + strDateTime, LogFile.LOGLVL_NORMAL);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:HandleRemoteService
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nFID remoting处理内部编码,
|
|
|
*string sTName 集中器ID,
|
|
|
*object oParam 参数对象,
|
|
|
*ref object oResp 应答对象
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:remoting 处理接口函数
|
|
|
*/
|
|
|
public bool HandleRemoteService(int nFID, string sTName, object oParam, ref object oResp)
|
|
|
{
|
|
|
|
|
|
bool res = false;
|
|
|
int nHashCode = sTName.GetHashCode();
|
|
|
switch (nFID)
|
|
|
{
|
|
|
//对时
|
|
|
case 0:
|
|
|
res = RS_AdjustTime(nHashCode);
|
|
|
break;
|
|
|
//读时间
|
|
|
case 1:
|
|
|
res = RS_GetTime(nHashCode, ref oResp);
|
|
|
break;
|
|
|
//写IP和端口
|
|
|
case 2:
|
|
|
res = RS_SetIPPort(nHashCode, oParam);
|
|
|
break;
|
|
|
//招唤数据
|
|
|
case 3:
|
|
|
res = RS_GetData(nHashCode, oParam, ref oResp);
|
|
|
break;
|
|
|
//写主动上传间隔
|
|
|
case 4:
|
|
|
res = RS_SetAutoSendInterval(nHashCode, oParam);
|
|
|
break;
|
|
|
//写心跳间隔
|
|
|
case 5:
|
|
|
res = RS_SetHeartBeatInterval(nHashCode, oParam);
|
|
|
break;
|
|
|
//读主动上传间隔
|
|
|
case 6:
|
|
|
res = RS_GetAutoSendInterval(nHashCode, ref oResp);
|
|
|
break;
|
|
|
//读心跳间隔
|
|
|
case 7:
|
|
|
res = RS_GetHeartBeatInterval(nHashCode, ref oResp);
|
|
|
break;
|
|
|
//写集中器ID
|
|
|
case 8:
|
|
|
res = RS_SetTerminalName(nHashCode, oParam);
|
|
|
break;
|
|
|
//写集中器仪表地址
|
|
|
case 9:
|
|
|
res = RS_SetMeterAddr(nHashCode, oParam);
|
|
|
break;
|
|
|
//读集中器仪表地址
|
|
|
case 10:
|
|
|
res = RS_GetMeterAddr(nHashCode, ref oResp);
|
|
|
break;
|
|
|
//写集中器仪表置位
|
|
|
case 11:
|
|
|
res = RS_SetMeterAble(nHashCode, oParam);
|
|
|
break;
|
|
|
//读集中器仪表置位
|
|
|
case 12:
|
|
|
res = RS_GetMeterAble(nHashCode, ref oResp);
|
|
|
break;
|
|
|
//写蒸汽告警参数
|
|
|
case 13:
|
|
|
res = RS_SetStreamThreshold(nHashCode, oParam);
|
|
|
break;
|
|
|
//读蒸汽告警参数
|
|
|
case 14:
|
|
|
res = RS_GetStreamThreshold(nHashCode, oParam, ref oResp);
|
|
|
break;
|
|
|
//写电力告警参数
|
|
|
case 15:
|
|
|
res = RS_SetElectricThreshold(nHashCode, oParam);
|
|
|
break;
|
|
|
//读电力告警参数
|
|
|
case 16:
|
|
|
res = RS_GetElectricThreshold(nHashCode, oParam, ref oResp);
|
|
|
break;
|
|
|
//读集中器信息
|
|
|
case 17:
|
|
|
res = RS_GetInfo(nHashCode, oParam, ref oResp);
|
|
|
break;
|
|
|
//写集中器目标IP和Port
|
|
|
case 18:
|
|
|
res = RS_SetServerIPPort(nHashCode, oParam);
|
|
|
break;
|
|
|
//写电力PT CT
|
|
|
case 19:
|
|
|
res = RS_SetElecPTCT(nHashCode, oParam);
|
|
|
break;
|
|
|
//读电力PT CT
|
|
|
case 20:
|
|
|
res = RS_GetElecPTCT(nHashCode, oParam, ref oResp);
|
|
|
break;
|
|
|
case 21:
|
|
|
res = RS_SetSteamFailInterval(nHashCode, oParam);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
return res;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 设置蒸汽集中器采集数据失败时间间隔
|
|
|
/// </summary>
|
|
|
/// <param name="nHashCode">通信处理实例哈希编码</param>
|
|
|
/// <param name="oParam">参数对象</param>
|
|
|
/// <returns>bools设置成功 true</returns>
|
|
|
private bool RS_SetSteamFailInterval(int nHashCode, object oParam)
|
|
|
{
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struWriteData wrData = new struWriteData();
|
|
|
wrData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
wrData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (wrData.flagDTN != 'E')
|
|
|
//{
|
|
|
// MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return;
|
|
|
//}
|
|
|
//逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
wrData.addrDNL[0] = (byte)(n / 256);
|
|
|
wrData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
wrData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志(写对象)
|
|
|
wrData.flagCtrlF = 0x08;
|
|
|
//测量点标志 (终端)
|
|
|
wrData.flagPoint = 0x00;
|
|
|
|
|
|
//帧序号
|
|
|
wrData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//低级权限
|
|
|
wrData.flagAUT = 0x00;
|
|
|
//口令
|
|
|
wrData.passwd = new byte[3];
|
|
|
wrData.passwd[0] = 0x31;
|
|
|
wrData.passwd[1] = 0x32;
|
|
|
wrData.passwd[2] = 0x33;
|
|
|
|
|
|
Hashtable ht = (Hashtable)oParam;
|
|
|
|
|
|
byte byParams = (byte)ht["DB44"];
|
|
|
|
|
|
//数据编号与数据
|
|
|
wrData.numPairs = new byte[3];
|
|
|
|
|
|
wrData.numPairs[0] = 0xDB;
|
|
|
wrData.numPairs[1] = 0x44;
|
|
|
|
|
|
wrData.numPairs[2] = byParams; //分钟
|
|
|
|
|
|
struFrame sFrame = new struFrame();
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, wrData.flagCtrlF, wrData, ref sFrame);
|
|
|
//Common.logFile.write("handleRSCommand ====================");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:RS_SetHeartBeatInterval
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 通信处理实例哈希编码,
|
|
|
*object oParam 参数对象
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:设置心跳超时间隔
|
|
|
*/
|
|
|
|
|
|
public bool RS_SetHeartBeatInterval(int nHashCode, object oParam)
|
|
|
{
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struWriteData wrData = new struWriteData();
|
|
|
wrData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
wrData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (wrData.flagDTN != 'E')
|
|
|
//{
|
|
|
// MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return;
|
|
|
//}
|
|
|
//逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
wrData.addrDNL[0] = (byte)(n / 256);
|
|
|
wrData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
wrData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志(写对象)
|
|
|
wrData.flagCtrlF = 0x08;
|
|
|
//测量点标志 (终端)
|
|
|
wrData.flagPoint = 0x00;
|
|
|
|
|
|
//帧序号
|
|
|
wrData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//低级权限
|
|
|
wrData.flagAUT = 0x00;
|
|
|
//口令
|
|
|
wrData.passwd = new byte[3];
|
|
|
wrData.passwd[0] = 0x31;
|
|
|
wrData.passwd[1] = 0x32;
|
|
|
wrData.passwd[2] = 0x33;
|
|
|
|
|
|
Hashtable ht = (Hashtable)oParam;
|
|
|
|
|
|
byte byParams = (byte)ht["DB41"];
|
|
|
|
|
|
//数据编号与数据
|
|
|
wrData.numPairs = new byte[3];
|
|
|
|
|
|
wrData.numPairs[0] = 0xDB;
|
|
|
wrData.numPairs[1] = 0x41;
|
|
|
|
|
|
wrData.numPairs[2] = byParams; //分钟
|
|
|
|
|
|
struFrame sFrame = new struFrame();
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, wrData.flagCtrlF, wrData, ref sFrame);
|
|
|
//Common.logFile.write("handleRSCommand ====================");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:RS_SetAutoSendInterval
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 通信处理实例哈希编码,
|
|
|
*object oParam 参数对象
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:设置自动上传间隔时间
|
|
|
*/
|
|
|
public bool RS_SetAutoSendInterval(int nHashCode, object oParam)
|
|
|
{
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struWriteData wrData = new struWriteData();
|
|
|
wrData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
wrData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (wrData.flagDTN != 'E')
|
|
|
//{
|
|
|
// MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return;
|
|
|
//}
|
|
|
//逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
wrData.addrDNL[0] = (byte)(n / 256);
|
|
|
wrData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
wrData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志(写对象)
|
|
|
wrData.flagCtrlF = 0x08;
|
|
|
//测量点标志 (终端)
|
|
|
wrData.flagPoint = 0x00;
|
|
|
|
|
|
//帧序号
|
|
|
wrData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//低级权限
|
|
|
wrData.flagAUT = 0x00;
|
|
|
//口令
|
|
|
wrData.passwd = new byte[3];
|
|
|
wrData.passwd[0] = 0x31;
|
|
|
wrData.passwd[1] = 0x32;
|
|
|
wrData.passwd[2] = 0x33;
|
|
|
|
|
|
Hashtable ht = (Hashtable)oParam;
|
|
|
|
|
|
byte byParams = (byte)ht["DB42"];
|
|
|
|
|
|
//数据编号与数据
|
|
|
wrData.numPairs = new byte[3];
|
|
|
|
|
|
wrData.numPairs[0] = 0xDB;
|
|
|
wrData.numPairs[1] = 0x42;
|
|
|
|
|
|
wrData.numPairs[2] = byParams; //分钟
|
|
|
|
|
|
struFrame sFrame = new struFrame();
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, wrData.flagCtrlF, wrData, ref sFrame);
|
|
|
//Common.logFile.write("handleRSCommand ====================");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:RS_SetTerminalName
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 通信处理实例哈希编码,
|
|
|
*object oParam 参数对象
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:设置集中器ID
|
|
|
*/
|
|
|
public bool RS_SetTerminalName(int nHashCode, object oParam)
|
|
|
{
|
|
|
string sNewName = (string)oParam;
|
|
|
if (sNewName.Length != 5)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struWriteData wrData = new struWriteData();
|
|
|
wrData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
wrData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (wrData.flagDTN != 'E')
|
|
|
//{
|
|
|
// MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return;
|
|
|
//}
|
|
|
//逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
wrData.addrDNL[0] = (byte)(n / 256);
|
|
|
wrData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
wrData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志(写对象)
|
|
|
wrData.flagCtrlF = 0x08;
|
|
|
//测量点标志 (终端)
|
|
|
wrData.flagPoint = 0x00;
|
|
|
|
|
|
//帧序号
|
|
|
wrData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//低级权限
|
|
|
wrData.flagAUT = 0x00;
|
|
|
//口令
|
|
|
wrData.passwd = new byte[3];
|
|
|
wrData.passwd[0] = 0x31;
|
|
|
wrData.passwd[1] = 0x32;
|
|
|
wrData.passwd[2] = 0x33;
|
|
|
|
|
|
|
|
|
//数据编号与数据
|
|
|
wrData.numPairs = new byte[5];
|
|
|
|
|
|
wrData.numPairs[0] = 0x80;
|
|
|
wrData.numPairs[1] = 0x17;
|
|
|
|
|
|
wrData.numPairs[2] = (byte)sNewName[0];
|
|
|
wrData.numPairs[3] = Convert.ToByte(sNewName.Substring(1, 2), 16);
|
|
|
wrData.numPairs[4] = Convert.ToByte(sNewName.Substring(3, 2), 16);
|
|
|
|
|
|
struFrame sFrame = new struFrame();
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, wrData.flagCtrlF, wrData, ref sFrame);
|
|
|
//Common.logFile.write("handleRSCommand ====================");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
/*
|
|
|
*方法名称:RS_SetIPPort
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 通信处理实例哈希编码,
|
|
|
*object oParam 参数对象
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:设置集中器本地ip和端口
|
|
|
*/
|
|
|
|
|
|
public bool RS_SetIPPort(int nHashCode, object oParam)
|
|
|
{
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struWriteData wrData = new struWriteData();
|
|
|
wrData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
wrData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (wrData.flagDTN != 'E')
|
|
|
//{
|
|
|
// MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return;
|
|
|
//}
|
|
|
//逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
wrData.addrDNL[0] = (byte)(n / 256);
|
|
|
wrData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
wrData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志(写对象)
|
|
|
wrData.flagCtrlF = 0x08;
|
|
|
//测量点标志 (终端)
|
|
|
wrData.flagPoint = 0x00;
|
|
|
|
|
|
//帧序号
|
|
|
wrData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//低级权限
|
|
|
wrData.flagAUT = 0x00;
|
|
|
//口令
|
|
|
wrData.passwd = new byte[3];
|
|
|
wrData.passwd[0] = 0x31;
|
|
|
wrData.passwd[1] = 0x32;
|
|
|
wrData.passwd[2] = 0x33;
|
|
|
|
|
|
//数据编号与数据
|
|
|
wrData.numPairs = new byte[11];//DPT计算电压时用//DCT计算电流时用//DPQ计算功率时用
|
|
|
|
|
|
wrData.numPairs[0] = 0x80;
|
|
|
wrData.numPairs[1] = 0x10;
|
|
|
|
|
|
Hashtable ht = (Hashtable)oParam;
|
|
|
|
|
|
byte[] byParams = (byte[])ht["8010"];
|
|
|
|
|
|
wrData.numPairs[2] = 0x04;
|
|
|
wrData.numPairs[3] = 0xAA;
|
|
|
wrData.numPairs[4] = 0xAA;
|
|
|
wrData.numPairs[5] = byParams[0];//192
|
|
|
wrData.numPairs[6] = byParams[1];//168
|
|
|
wrData.numPairs[7] = byParams[2]; //0
|
|
|
wrData.numPairs[8] = byParams[3];//58
|
|
|
wrData.numPairs[9] = byParams[4]; //40
|
|
|
wrData.numPairs[10] = byParams[5]; //01
|
|
|
|
|
|
struFrame sFrame = new struFrame();
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, wrData.flagCtrlF, wrData, ref sFrame);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
/*
|
|
|
*方法名称:RS_SetServerIPPort
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 通信处理实例哈希编码,
|
|
|
*object oParam 参数对象
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:设置集中器目标ip和端口
|
|
|
*/
|
|
|
|
|
|
public bool RS_SetServerIPPort(int nHashCode, object oParam)
|
|
|
{
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struWriteData wrData = new struWriteData();
|
|
|
wrData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
wrData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (wrData.flagDTN != 'E')
|
|
|
//{
|
|
|
// MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return;
|
|
|
//}
|
|
|
//逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
wrData.addrDNL[0] = (byte)(n / 256);
|
|
|
wrData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
wrData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志(写对象)
|
|
|
wrData.flagCtrlF = 0x08;
|
|
|
//测量点标志 (终端)
|
|
|
wrData.flagPoint = 0x00;
|
|
|
|
|
|
//帧序号
|
|
|
wrData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//低级权限
|
|
|
wrData.flagAUT = 0x00;
|
|
|
//口令
|
|
|
wrData.passwd = new byte[3];
|
|
|
wrData.passwd[0] = 0x31;
|
|
|
wrData.passwd[1] = 0x32;
|
|
|
wrData.passwd[2] = 0x33;
|
|
|
|
|
|
//数据编号与数据
|
|
|
wrData.numPairs = new byte[8];
|
|
|
|
|
|
wrData.numPairs[0] = 0x80;
|
|
|
wrData.numPairs[1] = 0x1A;
|
|
|
|
|
|
Hashtable ht = (Hashtable)oParam;
|
|
|
|
|
|
byte[] byParams = (byte[])ht["801A"];
|
|
|
|
|
|
wrData.numPairs[2] = byParams[0];//192
|
|
|
wrData.numPairs[3] = byParams[1];//168
|
|
|
wrData.numPairs[4] = byParams[2]; //0
|
|
|
wrData.numPairs[5] = byParams[3];//58
|
|
|
wrData.numPairs[6] = byParams[4]; //40
|
|
|
wrData.numPairs[7] = byParams[5]; //01
|
|
|
|
|
|
struFrame sFrame = new struFrame();
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, wrData.flagCtrlF, wrData, ref sFrame);
|
|
|
//Common.logFile.write("handleRSCommand ====================");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:GetTerminalList
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:Hashtable htTerminal 集中器哈希表,
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:获得集中器列表
|
|
|
*/
|
|
|
public bool GetTerminalList(Hashtable htTerminal)
|
|
|
{
|
|
|
htTerminal.Clear();
|
|
|
|
|
|
List<string> lstTerminal = new List<string>();
|
|
|
Hashtable htTerminalForTest = new Hashtable();
|
|
|
Hashtable htTerminalAll = new Hashtable();
|
|
|
//lstTerminal.Clear();
|
|
|
bool res = true;
|
|
|
//lock
|
|
|
mut.WaitOne();
|
|
|
|
|
|
if (TCPHandlerList.Count > 0)
|
|
|
{
|
|
|
foreach (TCPHandler tcpHandler in TCPHandlerList)
|
|
|
{
|
|
|
if (tcpHandler.tName.CompareTo("未知终端") != 0)
|
|
|
{
|
|
|
lstTerminal.Add(tcpHandler.tName);
|
|
|
htTerminalForTest.Add(tcpHandler.tName, false);
|
|
|
htTerminalAll.Add(tcpHandler.tName, false);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//res = false;
|
|
|
lstTerminal.Add("null");
|
|
|
}
|
|
|
|
|
|
//unlock
|
|
|
mut.ReleaseMutex();
|
|
|
//Common.logFile.write("2.进入数据库查询", LogFile.LOGLVL_NORMAL);
|
|
|
|
|
|
|
|
|
if (res == true)
|
|
|
{
|
|
|
//string sTIDS = "('"+lstTerminal[0]+"'";
|
|
|
//for (int i = 1; i < lstTerminal.Count; i++)
|
|
|
//{
|
|
|
// sTIDS += ",'"+lstTerminal[i]+"'";
|
|
|
//}
|
|
|
//sTIDS += ")";
|
|
|
|
|
|
string queryString = string.Format("SELECT t2.[SettingAddress],t2.[collectdeviceid],[MonitorName] "
|
|
|
+ ",[MeterCommunicationID] "
|
|
|
+ "FROM [dbo].[T_Monitor] as t1 "
|
|
|
+ "Inner Join [dbo].[T_CollectDeviceInfo] as t2 "
|
|
|
+ "on t1.[collectdeviceid] = t2.[collectdeviceid] where t1.[MonitorType]={0} or t1.[MonitorType]={1} order by collectdeviceid", 2,3);//('E0001', 'S0001')
|
|
|
//Common.logFile.write("2.1进入数据库查询,queryString:" + queryString, LogFile.LOGLVL_NORMAL);
|
|
|
|
|
|
using (SqlConnection connection = new SqlConnection(connectString))
|
|
|
{
|
|
|
SqlCommand command = new SqlCommand(queryString, connection);
|
|
|
try
|
|
|
{
|
|
|
connection.Open();
|
|
|
try
|
|
|
{
|
|
|
SqlDataReader reader = command.ExecuteReader();
|
|
|
while (reader.Read())
|
|
|
{
|
|
|
if (!reader[1].ToString().ToUpper().StartsWith("XN"))//过滤 XN 虚拟节点
|
|
|
{
|
|
|
|
|
|
if (htTerminalAll.ContainsKey(reader[1].ToString()))
|
|
|
{
|
|
|
//online
|
|
|
htTerminal.Add(reader[3].ToString() + "\n" + reader[2].ToString(), reader[1].ToString() + "\n" + reader[0].ToString() + "\n" + "1");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//offline
|
|
|
htTerminal.Add(reader[3].ToString() + "\n" + reader[2].ToString(), reader[1].ToString() + "\n" + reader[0].ToString() + "\n" + "0");
|
|
|
}
|
|
|
|
|
|
htTerminalForTest.Remove(reader[1].ToString());
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
// Call Close when done reading.
|
|
|
reader.Close();
|
|
|
}
|
|
|
catch (SqlException e)
|
|
|
{
|
|
|
//info2Display += "\r\n蒸汽数据采集 SqlException:" + e.ToString() + "\r\n 原SQL语句:" + insertSQLString;
|
|
|
Common.logFile.write("原SQL语句:" + queryString + ",SQL语句错误:" + e.ToString(), LogFile.LOGLVL_ERROR);
|
|
|
res = false;
|
|
|
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e)
|
|
|
{
|
|
|
Common.logFile.write("数据库打开错误:" + e.ToString(), LogFile.LOGLVL_ERROR);
|
|
|
Common.logFile.write("数据库打开错误:详见err.txt", LogFile.LOGLVL_NORMAL);
|
|
|
res = false;
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//Common.logFile.write("2.2添加集中器测试", LogFile.LOGLVL_NORMAL);
|
|
|
|
|
|
//集中器测试
|
|
|
//
|
|
|
try
|
|
|
{
|
|
|
if (htTerminalForTest.Count > 0)
|
|
|
{
|
|
|
foreach (DictionaryEntry de in htTerminalForTest)
|
|
|
{
|
|
|
for (int i = 1; i <= 4; i++)
|
|
|
{
|
|
|
htTerminal.Add(i.ToString() + "\n" + de.Key.ToString(), de.Key.ToString() + "\n" + "测试" + "\n" + "1");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
catch (Exception e1)
|
|
|
{
|
|
|
Common.logFile.write("添加集中器测试,Exception:" + e1.ToString(), LogFile.LOGLVL_ERROR);
|
|
|
res = false;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
//Common.logFile.write("3.GetTerminalList结束:"+res.ToString(), LogFile.LOGLVL_NORMAL);
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:RS_GetMeterAble
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:Hashtable htTerminal 集中器哈希表,
|
|
|
*ref object oResp 应答数据对象
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:获得集中器仪表置位
|
|
|
*/
|
|
|
|
|
|
private bool RS_GetMeterAble(int nHashCode, ref object oResp)
|
|
|
{
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struReadData rdData = new struReadData();
|
|
|
rdData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
rdData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (rdData.flagDTN != 'E')
|
|
|
//{
|
|
|
// //MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return false;
|
|
|
//}
|
|
|
////逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
rdData.addrDNL[0] = (byte)(n / 256);
|
|
|
rdData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
rdData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志
|
|
|
rdData.flagCtrlF = 0x01;
|
|
|
//测量点标志
|
|
|
rdData.flagPoint = 0x00;
|
|
|
|
|
|
//帧序号
|
|
|
rdData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//数据项编号
|
|
|
rdData.numPairs = new byte[2];
|
|
|
|
|
|
rdData.numPairs[0] = 0x89;//
|
|
|
rdData.numPairs[1] = 0x00;//
|
|
|
|
|
|
struFrame sRespFrame = new struFrame();
|
|
|
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, rdData.flagCtrlF, rdData, ref sRespFrame);
|
|
|
if (res == true)
|
|
|
{
|
|
|
struFrame sFrame = (struFrame)sRespFrame;
|
|
|
int pointer = 1;
|
|
|
uint ID = (uint)(sFrame.strData[pointer] * 0x100 + sFrame.strData[pointer + 1]);
|
|
|
if (ID == 0x8900)
|
|
|
{
|
|
|
byte[] arrParam = new byte[16];
|
|
|
//string sInterval = sFrame.strData[pointer + 2].ToString("D2");
|
|
|
for (int i = 0; i < 16; i++)
|
|
|
{
|
|
|
arrParam[i] = sFrame.strData[pointer + 2 + i];
|
|
|
}
|
|
|
oResp = (object)arrParam;
|
|
|
Common.logFile.writeHexString("获取终端[" + tw.tName + "]仪表使能:", arrParam, LogFile.LOGLVL_NORMAL);// write("获取终端[" + tw.tName + "]主动上传间隔(分钟):" + sInterval, LogFile.LOGLVL_NORMAL);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
/*
|
|
|
*方法名称:RS_GetStreamThreshold
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 集中器哈希编码,
|
|
|
*object oParam 参数对象,
|
|
|
*ref object oResp 应答数据对象
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:获得蒸汽告警参数
|
|
|
*/
|
|
|
|
|
|
private bool RS_GetStreamThreshold(int nHashCode, object oParam, ref object oResp)
|
|
|
{
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
string sMID = (string)oParam;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struReadData rdData = new struReadData();
|
|
|
rdData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
rdData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (rdData.flagDTN != 'E')
|
|
|
//{
|
|
|
// //MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return false;
|
|
|
//}
|
|
|
////逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
rdData.addrDNL[0] = (byte)(n / 256);
|
|
|
rdData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
rdData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志
|
|
|
rdData.flagCtrlF = 0x01;
|
|
|
//测量点标志
|
|
|
rdData.flagPoint = Convert.ToByte(sMID, 16);//?????????????????????????
|
|
|
|
|
|
//帧序号
|
|
|
rdData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//数据项编号
|
|
|
rdData.numPairs = new byte[32];
|
|
|
|
|
|
rdData.numPairs[0] = 0x8C;//
|
|
|
rdData.numPairs[1] = 0x00;//
|
|
|
|
|
|
rdData.numPairs[2] = 0x8C;//
|
|
|
rdData.numPairs[3] = 0x01;//
|
|
|
|
|
|
rdData.numPairs[4] = 0x8C;//
|
|
|
rdData.numPairs[5] = 0x02;//
|
|
|
|
|
|
rdData.numPairs[6] = 0x8C;//
|
|
|
rdData.numPairs[7] = 0x03;//
|
|
|
|
|
|
rdData.numPairs[8] = 0x8D;//
|
|
|
rdData.numPairs[9] = 0x00;//
|
|
|
|
|
|
rdData.numPairs[10] = 0x8D;//
|
|
|
rdData.numPairs[11] = 0x01;//
|
|
|
|
|
|
rdData.numPairs[12] = 0x8D;//
|
|
|
rdData.numPairs[13] = 0x02;//
|
|
|
|
|
|
rdData.numPairs[14] = 0x8D;//
|
|
|
rdData.numPairs[15] = 0x03;//
|
|
|
|
|
|
rdData.numPairs[16] = 0x8E;//
|
|
|
rdData.numPairs[17] = 0x00;//
|
|
|
|
|
|
rdData.numPairs[18] = 0x8E;//
|
|
|
rdData.numPairs[19] = 0x01;//
|
|
|
|
|
|
rdData.numPairs[20] = 0x8E;//
|
|
|
rdData.numPairs[21] = 0x02;//
|
|
|
|
|
|
rdData.numPairs[22] = 0x8E;//
|
|
|
rdData.numPairs[23] = 0x03;//
|
|
|
|
|
|
rdData.numPairs[24] = 0x8F;//
|
|
|
rdData.numPairs[25] = 0x00;//
|
|
|
|
|
|
rdData.numPairs[26] = 0x8F;//
|
|
|
rdData.numPairs[27] = 0x01;//
|
|
|
|
|
|
rdData.numPairs[28] = 0x8F;//
|
|
|
rdData.numPairs[29] = 0x02;//
|
|
|
|
|
|
rdData.numPairs[30] = 0x8F;//
|
|
|
rdData.numPairs[31] = 0x03;//
|
|
|
|
|
|
struFrame sRespFrame = new struFrame();
|
|
|
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, rdData.flagCtrlF, rdData, ref sRespFrame);
|
|
|
if (res == true)
|
|
|
{
|
|
|
struFrame sFrame = (struFrame)sRespFrame;
|
|
|
string[] arrParam = new string[16];
|
|
|
MessageHandler mh = new MessageHandler(null);
|
|
|
res = mh.S_ThresholdParamParsing(ref sFrame, ref arrParam);
|
|
|
oResp = arrParam;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:RS_GetMeterAddr
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 集中器哈希编码,
|
|
|
*ref object oResp 应答数据对象
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:获得仪表地址
|
|
|
*/
|
|
|
|
|
|
private bool RS_GetMeterAddr(int nHashCode, ref object oResp)
|
|
|
{
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struReadData rdData = new struReadData();
|
|
|
rdData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
rdData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (rdData.flagDTN != 'E')
|
|
|
//{
|
|
|
// //MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return false;
|
|
|
//}
|
|
|
////逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
rdData.addrDNL[0] = (byte)(n / 256);
|
|
|
rdData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
rdData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志
|
|
|
rdData.flagCtrlF = 0x01;
|
|
|
//测量点标志
|
|
|
rdData.flagPoint = 0x00;
|
|
|
|
|
|
//帧序号
|
|
|
rdData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//数据项编号
|
|
|
rdData.numPairs = new byte[2];
|
|
|
|
|
|
rdData.numPairs[0] = 0x89;//
|
|
|
rdData.numPairs[1] = 0x01;//
|
|
|
|
|
|
struFrame sRespFrame = new struFrame();
|
|
|
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, rdData.flagCtrlF, rdData, ref sRespFrame);
|
|
|
if (res == true)
|
|
|
{
|
|
|
struFrame sFrame = (struFrame)sRespFrame;
|
|
|
int pointer = 1;
|
|
|
uint ID = (uint)(sFrame.strData[pointer] * 0x100 + sFrame.strData[pointer + 1]);
|
|
|
if (ID == 0x8901)
|
|
|
{
|
|
|
byte[] arrAddr = new byte[16];
|
|
|
//string sInterval = sFrame.strData[pointer + 2].ToString("D2");
|
|
|
for (int i = 0; i < 16; i++)
|
|
|
{
|
|
|
arrAddr[i] = sFrame.strData[pointer + 2 + i];
|
|
|
}
|
|
|
oResp = (object)arrAddr;
|
|
|
Common.logFile.writeHexString("获取终端[" + tw.tName + "]仪表地址:", arrAddr, LogFile.LOGLVL_NORMAL);// write("获取终端[" + tw.tName + "]主动上传间隔(分钟):" + sInterval, LogFile.LOGLVL_NORMAL);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:RS_SetMeterAble
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 集中器哈希编码,
|
|
|
*object oParam 参数对象
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:设置仪表置位
|
|
|
*/
|
|
|
public bool RS_SetMeterAble(int nHashCode, object oParam)
|
|
|
{
|
|
|
byte[] arrParams = (byte[])oParam;
|
|
|
if (arrParams.Length != 16)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struWriteData wrData = new struWriteData();
|
|
|
wrData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
wrData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (wrData.flagDTN != 'E')
|
|
|
//{
|
|
|
// MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return;
|
|
|
//}
|
|
|
//逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
wrData.addrDNL[0] = (byte)(n / 256);
|
|
|
wrData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
wrData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志(写对象)
|
|
|
wrData.flagCtrlF = 0x08;
|
|
|
//测量点标志 (终端)
|
|
|
wrData.flagPoint = 0x00;
|
|
|
|
|
|
//帧序号
|
|
|
wrData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//低级权限
|
|
|
wrData.flagAUT = 0x00;
|
|
|
//口令
|
|
|
wrData.passwd = new byte[3];
|
|
|
wrData.passwd[0] = 0x31;
|
|
|
wrData.passwd[1] = 0x32;
|
|
|
wrData.passwd[2] = 0x33;
|
|
|
|
|
|
|
|
|
//数据编号与数据
|
|
|
wrData.numPairs = new byte[18];
|
|
|
|
|
|
wrData.numPairs[0] = 0x89;
|
|
|
wrData.numPairs[1] = 0x00;
|
|
|
arrParams.CopyTo(wrData.numPairs, 2);
|
|
|
|
|
|
struFrame sFrame = new struFrame();
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, wrData.flagCtrlF, wrData, ref sFrame);
|
|
|
//Common.logFile.write("handleRSCommand ====================");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
/*
|
|
|
*方法名称:RS_SetMeterAddr
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 集中器哈希编码,
|
|
|
*object oParam 参数对象
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:设置仪表地址
|
|
|
*/
|
|
|
|
|
|
public bool RS_SetMeterAddr(int nHashCode, object oParam)
|
|
|
{
|
|
|
byte[] arrParams = (byte[])oParam;
|
|
|
if (arrParams.Length != 16)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struWriteData wrData = new struWriteData();
|
|
|
wrData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
wrData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (wrData.flagDTN != 'E')
|
|
|
//{
|
|
|
// MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return;
|
|
|
//}
|
|
|
//逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
wrData.addrDNL[0] = (byte)(n / 256);
|
|
|
wrData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
wrData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志(写对象)
|
|
|
wrData.flagCtrlF = 0x08;
|
|
|
//测量点标志 (终端)
|
|
|
wrData.flagPoint = 0x00;
|
|
|
|
|
|
//帧序号
|
|
|
wrData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//低级权限
|
|
|
wrData.flagAUT = 0x00;
|
|
|
//口令
|
|
|
wrData.passwd = new byte[3];
|
|
|
wrData.passwd[0] = 0x31;
|
|
|
wrData.passwd[1] = 0x32;
|
|
|
wrData.passwd[2] = 0x33;
|
|
|
|
|
|
//数据编号与数据
|
|
|
wrData.numPairs = new byte[18];
|
|
|
|
|
|
wrData.numPairs[0] = 0x89;
|
|
|
wrData.numPairs[1] = 0x01;
|
|
|
arrParams.CopyTo(wrData.numPairs, 2);
|
|
|
|
|
|
struFrame sFrame = new struFrame();
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, wrData.flagCtrlF, wrData, ref sFrame);
|
|
|
//Common.logFile.write("handleRSCommand ====================");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
/*
|
|
|
*方法名称:RS_SetStreamThreshold
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 集中器哈希编码,
|
|
|
*object oParam 参数对象
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:设置蒸汽告警参数
|
|
|
*/
|
|
|
|
|
|
public bool RS_SetStreamThreshold(int nHashCode, object oParam)
|
|
|
{
|
|
|
struParam struP = (struParam)oParam;
|
|
|
string[] arrParams = (string[])struP.oParam;
|
|
|
if (arrParams.Length != 16)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struWriteData wrData = new struWriteData();
|
|
|
wrData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
wrData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (wrData.flagDTN != 'E')
|
|
|
//{
|
|
|
// MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return;
|
|
|
//}
|
|
|
//逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
wrData.addrDNL[0] = (byte)(n / 256);
|
|
|
wrData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
wrData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志(写对象)
|
|
|
wrData.flagCtrlF = 0x08;
|
|
|
//测量点标志 (终端)
|
|
|
wrData.flagPoint = Convert.ToByte(struP.sMID, 16);
|
|
|
|
|
|
//帧序号
|
|
|
wrData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//低级权限
|
|
|
wrData.flagAUT = 0x00;
|
|
|
//口令
|
|
|
wrData.passwd = new byte[3];
|
|
|
wrData.passwd[0] = 0x31;
|
|
|
wrData.passwd[1] = 0x32;
|
|
|
wrData.passwd[2] = 0x33;
|
|
|
|
|
|
//Hashtable ht = (Hashtable)oParam;
|
|
|
|
|
|
//数据编号与数据
|
|
|
//wrData.numPairs = new byte[18];
|
|
|
|
|
|
//wrData.numPairs[0] = 0x89;
|
|
|
//wrData.numPairs[1] = 0x01;
|
|
|
//arrParams.CopyTo(wrData.numPairs, 2);
|
|
|
|
|
|
MessageHandler mh = new MessageHandler(null);
|
|
|
Hashtable htThreshold = new Hashtable();
|
|
|
res = mh.S_ThresholdParamTrans(ref arrParams, ref wrData.numPairs, htThreshold);
|
|
|
|
|
|
if (res == true)
|
|
|
{
|
|
|
struFrame sFrame = new struFrame();
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, wrData.flagCtrlF, wrData, ref sFrame);
|
|
|
|
|
|
//存库
|
|
|
if (res == true)
|
|
|
{
|
|
|
res = mh.saveAlarmThreshold(tw.tName, struP.sMID, htThreshold);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//Common.logFile.write("handleRSCommand ====================");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:RS_SetElectricThreshold
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 集中器哈希编码,
|
|
|
*object oParam 参数对象
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:设置电力告警参数
|
|
|
*/
|
|
|
|
|
|
public bool RS_SetElectricThreshold(int nHashCode, object oParam)
|
|
|
{
|
|
|
struParam struP = (struParam)oParam;
|
|
|
string[] arrParams = (string[])struP.oParam;
|
|
|
if (arrParams.Length != 24)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struWriteData wrData = new struWriteData();
|
|
|
wrData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
wrData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (wrData.flagDTN != 'E')
|
|
|
//{
|
|
|
// MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return;
|
|
|
//}
|
|
|
//逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
wrData.addrDNL[0] = (byte)(n / 256);
|
|
|
wrData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
wrData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志(写对象)
|
|
|
wrData.flagCtrlF = 0x08;
|
|
|
//测量点标志 (终端)
|
|
|
wrData.flagPoint = Convert.ToByte(struP.sMID, 16);
|
|
|
|
|
|
//帧序号
|
|
|
wrData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//低级权限
|
|
|
wrData.flagAUT = 0x00;
|
|
|
//口令
|
|
|
wrData.passwd = new byte[3];
|
|
|
wrData.passwd[0] = 0x31;
|
|
|
wrData.passwd[1] = 0x32;
|
|
|
wrData.passwd[2] = 0x33;
|
|
|
|
|
|
//Hashtable ht = (Hashtable)oParam;
|
|
|
|
|
|
//数据编号与数据
|
|
|
//wrData.numPairs = new byte[18];
|
|
|
|
|
|
//wrData.numPairs[0] = 0x89;
|
|
|
//wrData.numPairs[1] = 0x01;
|
|
|
//arrParams.CopyTo(wrData.numPairs, 2);
|
|
|
|
|
|
MessageHandler mh = new MessageHandler(null);
|
|
|
Hashtable htThreshold = new Hashtable();
|
|
|
res = mh.E_ThresholdParamTrans(ref arrParams, ref wrData.numPairs, htThreshold);
|
|
|
|
|
|
if (res == true)
|
|
|
{
|
|
|
struFrame sFrame = new struFrame();
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, wrData.flagCtrlF, wrData, ref sFrame);
|
|
|
|
|
|
//存库
|
|
|
if (res == true)
|
|
|
{
|
|
|
res = mh.E_saveAlarmThreshold(tw.tName, struP.sMID, htThreshold);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//Common.logFile.write("handleRSCommand ====================");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:RS_GetElectricThreshold
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 集中器哈希编码,
|
|
|
*object oParam 参数对象
|
|
|
*ref object oResp 应答数据对象
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:读取电力告警参数
|
|
|
*/
|
|
|
private bool RS_GetElectricThreshold(int nHashCode, object oParam, ref object oResp)
|
|
|
{
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
string sMID = (string)oParam;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struReadData rdData = new struReadData();
|
|
|
rdData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
rdData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (rdData.flagDTN != 'E')
|
|
|
//{
|
|
|
// //MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return false;
|
|
|
//}
|
|
|
////逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
rdData.addrDNL[0] = (byte)(n / 256);
|
|
|
rdData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
rdData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志
|
|
|
rdData.flagCtrlF = 0x01;
|
|
|
//测量点标志
|
|
|
rdData.flagPoint = Convert.ToByte(sMID, 16);//?????????????????????????
|
|
|
|
|
|
//帧序号
|
|
|
rdData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//数据项编号
|
|
|
rdData.numPairs = new byte[16];
|
|
|
|
|
|
rdData.numPairs[0] = 0xda;
|
|
|
rdData.numPairs[1] = 0x80;
|
|
|
rdData.numPairs[2] = 0xda;
|
|
|
rdData.numPairs[3] = 0x81;
|
|
|
rdData.numPairs[4] = 0xda;
|
|
|
rdData.numPairs[5] = 0x82;
|
|
|
rdData.numPairs[6] = 0xda;
|
|
|
rdData.numPairs[7] = 0x83;
|
|
|
|
|
|
rdData.numPairs[8] = 0xda;
|
|
|
rdData.numPairs[9] = 0x85;
|
|
|
rdData.numPairs[10] = 0xda;
|
|
|
rdData.numPairs[11] = 0x86;
|
|
|
rdData.numPairs[12] = 0xda;
|
|
|
rdData.numPairs[13] = 0x87;
|
|
|
rdData.numPairs[14] = 0xda;
|
|
|
rdData.numPairs[15] = 0x88;
|
|
|
|
|
|
struFrame sRespFrame = new struFrame();
|
|
|
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, rdData.flagCtrlF, rdData, ref sRespFrame);
|
|
|
if (res == true)
|
|
|
{
|
|
|
struFrame sFrame = (struFrame)sRespFrame;
|
|
|
string[] arrParam = new string[8];
|
|
|
MessageHandler mh = new MessageHandler(null);
|
|
|
res = mh.E_ThresholdParamParsing(ref sFrame, ref arrParam);
|
|
|
oResp = arrParam;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:RS_GetInfo
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 集中器哈希编码,
|
|
|
*object oParam 参数对象
|
|
|
*ref object oResp 信息数据对象
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:读取集中器信息
|
|
|
*/
|
|
|
|
|
|
private bool RS_GetInfo(int nHashCode, object oParam, ref object oResp)
|
|
|
{
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
string sMID = (string)oParam;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
TimeSpan ts = DateTime.Now - tw.dtLogin;
|
|
|
oResp = "\r\n\t\t\t\tIP和端口:" + tw.strIPPort
|
|
|
+ "\r\n\t\t\t\t登录时间:" + tw.sLoginTime
|
|
|
+ "\r\n\t\t\t\t在线时间:" + ts.Days + " 天, " + ts.Hours + " 小时, " + ts.Minutes + " 分, " + ts.Seconds + " 秒";
|
|
|
|
|
|
res = true;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
/*
|
|
|
*方法名称:RS_SetElecPTCT
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 集中器哈希编码,
|
|
|
*object oParam 参数对象
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:设置电力PT CT
|
|
|
*/
|
|
|
|
|
|
public bool RS_SetElecPTCT(int nHashCode, object oParam)
|
|
|
{
|
|
|
struParam struP = (struParam)oParam;
|
|
|
string[] arrParams = (string[])struP.oParam;
|
|
|
if (arrParams.Length != 2)
|
|
|
{
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struWriteData wrData = new struWriteData();
|
|
|
wrData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
wrData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (wrData.flagDTN != 'E')
|
|
|
//{
|
|
|
// MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return;
|
|
|
//}
|
|
|
//逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
wrData.addrDNL[0] = (byte)(n / 256);
|
|
|
wrData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
wrData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志(写对象)
|
|
|
wrData.flagCtrlF = 0x08;
|
|
|
//测量点标志 (终端)
|
|
|
wrData.flagPoint = Convert.ToByte(struP.sMID, 16);
|
|
|
|
|
|
//帧序号
|
|
|
wrData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//低级权限
|
|
|
wrData.flagAUT = 0x00;
|
|
|
//口令
|
|
|
wrData.passwd = new byte[3];
|
|
|
wrData.passwd[0] = 0x31;
|
|
|
wrData.passwd[1] = 0x32;
|
|
|
wrData.passwd[2] = 0x33;
|
|
|
|
|
|
//Hashtable ht = (Hashtable)oParam;
|
|
|
|
|
|
//数据编号与数据
|
|
|
//wrData.numPairs = new byte[18];
|
|
|
|
|
|
//wrData.numPairs[0] = 0x89;
|
|
|
//wrData.numPairs[1] = 0x01;
|
|
|
//arrParams.CopyTo(wrData.numPairs, 2);
|
|
|
|
|
|
MessageHandler mh = new MessageHandler(null);
|
|
|
Hashtable htPTCT = new Hashtable();
|
|
|
res = mh.E_PTCTParamTrans(ref arrParams, ref wrData.numPairs, htPTCT);//?????????????
|
|
|
|
|
|
if (res == true)
|
|
|
{
|
|
|
struFrame sFrame = new struFrame();
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, wrData.flagCtrlF, wrData, ref sFrame);
|
|
|
|
|
|
////存库
|
|
|
//if (res == true)
|
|
|
//{
|
|
|
// res = mh.E_saveAlarmThreshold(tw.tName, struP.sMID, htThreshold);
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
//Common.logFile.write("handleRSCommand ====================");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
*方法名称:RS_GetElecPTCT
|
|
|
*创建人:韩荣伟
|
|
|
*创建时间:2010-10-30
|
|
|
*参数描述:int nHashCode 集中器哈希编码,
|
|
|
*object oParam 参数对象
|
|
|
*ref object oResp 应答数据对象
|
|
|
*返回描述:bool true 成功,false 失败
|
|
|
*功能描述:读取电力PT CT
|
|
|
*/
|
|
|
private bool RS_GetElecPTCT(int nHashCode, object oParam, ref object oResp)
|
|
|
{
|
|
|
//查找链接信息(终端编号,帧序号)
|
|
|
TCPHandler tw = null;
|
|
|
bool res = false;
|
|
|
string sMID = (string)oParam;
|
|
|
if (nHashCode != 0)
|
|
|
{
|
|
|
tw = (TCPHandler)Common.platForm.tcpServer.GetTCPHandler(nHashCode);
|
|
|
}
|
|
|
|
|
|
if (tw != null)
|
|
|
{
|
|
|
if (tw.tName.Length == 5)
|
|
|
{
|
|
|
struReadData rdData = new struReadData();
|
|
|
rdData.addrDNL = new byte[2];
|
|
|
|
|
|
////终端类型
|
|
|
rdData.flagDTN = (byte)tw.tName[0];
|
|
|
//if (rdData.flagDTN != 'E')
|
|
|
//{
|
|
|
// //MessageBox.Show("终端类型错误,非电力终端!");
|
|
|
// return false;
|
|
|
//}
|
|
|
////逻辑编号
|
|
|
int n = Convert.ToInt32(tw.tName.Substring(1, 4), 16);
|
|
|
rdData.addrDNL[0] = (byte)(n / 256);
|
|
|
rdData.addrDNL[1] = (byte)(n % 256);
|
|
|
////主站地址
|
|
|
//public byte flagMSTA;
|
|
|
rdData.flagMSTA = 0x0;//???????????????????????????????????
|
|
|
//功能标志
|
|
|
rdData.flagCtrlF = 0x01;
|
|
|
//测量点标志
|
|
|
rdData.flagPoint = Convert.ToByte(sMID, 16);//?????????????????????????
|
|
|
|
|
|
//帧序号
|
|
|
rdData.flagFSEQ = tw.GetSeqFrame();
|
|
|
//数据项编号
|
|
|
rdData.numPairs = new byte[4];
|
|
|
|
|
|
rdData.numPairs[0] = 0x89;//PT
|
|
|
rdData.numPairs[1] = 0x11;
|
|
|
rdData.numPairs[2] = 0x89;//CT
|
|
|
rdData.numPairs[3] = 0x12;
|
|
|
|
|
|
struFrame sRespFrame = new struFrame();
|
|
|
|
|
|
//放入链接队列
|
|
|
res = handleRSCommand(ref tw, rdData.flagCtrlF, rdData, ref sRespFrame);
|
|
|
if (res == true)
|
|
|
{
|
|
|
struFrame sFrame = (struFrame)sRespFrame;
|
|
|
string[] arrParam = new string[2];
|
|
|
MessageHandler mh = new MessageHandler(null);
|
|
|
res = mh.E_PTCTParamParsing(ref sFrame, ref arrParam);
|
|
|
oResp = arrParam;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//未认证的链接
|
|
|
//MessageBox.Show("未知终端,无权接收请求!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|