You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1636 lines
62 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Globalization;
using System.Collections;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using System.Timers;
using RemoteObjects;
using CommService;
namespace ClientTest
{
/*
*结构名称struIPPort
*创建人:韩荣伟
*创建时间2010-10-30
*功能描述ip port结构
*/
[Serializable]
struct struIPPort
{
public string sIP;
public int nPort;
};
/*
*类名称FrmMain
*创建人:韩荣伟
*创建时间2010-10-30
*功能描述:主窗口类
*/
public partial class FrmMain : Form
{
private ReqHandler remoteobj = null;
private Hashtable htTerminalIPPort = new Hashtable();
private Hashtable htRemotingIPPort = new Hashtable();
private string sFileTerminalIPPort;
private string sFileRemotingIPPort;
private Hashtable htTerminals;
private Hashtable htTerminalParams = null;
private string sSelectedTID;
private string sSelectedMID;
private ImageList myImageList = null;
private System.Timers.Timer aTimer = null;
private Hashtable htOldTerminals = null;
delegate void UpdateTreeViewCallback(object userData);
private bool bStartTimer = false;
/*
*方法名称FrmMain
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述void
*返回描述void
*功能描述:构造函数,初始化
*/
public FrmMain()
{
InitializeComponent();
//remoting通道注册
ChannelServices.RegisterChannel(new TcpClientChannel(), false);
sFileTerminalIPPort = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "TerminalIPPort.dat";
sFileRemotingIPPort = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "RemotingIPPort.dat";
LoadTerminalIPPort();
myImageList = new ImageList();
myImageList.Images.Add(Image.FromFile(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "集中器1.bmp"));
myImageList.Images.Add(Image.FromFile(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "电表.bmp"));
myImageList.Images.Add(Image.FromFile(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "电表-selected.bmp"));
myImageList.Images.Add(Image.FromFile(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "变压器.bmp"));
myImageList.Images.Add(Image.FromFile(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Home.ico"));
myImageList.Images.Add(Image.FromFile(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "集中器1_gray.bmp"));
myImageList.Images.Add(Image.FromFile(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "电表_gray.bmp"));
Common.frmMain = this;
Common.btRefresh = btnRefresh;
}
/*
*方法名称UpdTreeViewInfo
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object userData 按钮实例
*返回描述void
*功能描述:触发更新按钮
*/
public static void UpdTreeViewInfo(object userData)
{
Button bt = (Button)userData;
if (bt.InvokeRequired)
{
UpdateTreeViewCallback d = new UpdateTreeViewCallback(UpdTreeViewInfo);
Common.frmMain.Invoke(d, new object[] { userData});
}
else
{
bt.PerformClick();
}
}
/*
*方法名称LoadTerminalIPPort
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述void
*返回描述void
*功能描述加载上次的设置IP与端口
*/
private void LoadTerminalIPPort()
{
Common.configReader.Load(System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "\\config.xml");
if (File.Exists(sFileTerminalIPPort))
{
htTerminalIPPort.Clear();
FileStream fs = new FileStream(sFileTerminalIPPort, FileMode.OpenOrCreate);
BinaryFormatter bf = new BinaryFormatter();
htTerminalIPPort = (Hashtable)bf.Deserialize(fs);
fs.Close();
}
if (File.Exists(sFileRemotingIPPort))
{
htRemotingIPPort.Clear();
FileStream fs = new FileStream(sFileRemotingIPPort, FileMode.OpenOrCreate);
BinaryFormatter bf = new BinaryFormatter();
htRemotingIPPort = (Hashtable)bf.Deserialize(fs);
textBox1.Text = (string)htRemotingIPPort["RemotingIP"];
textBox2.Text = (string)htRemotingIPPort["RemotingPort"];
fs.Close();
}
}
/*
*方法名称SaveTerminalIPPort
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述void
*返回描述void
*功能描述保存上次的集中器设置IP与端口
*/
private void SaveTerminalIPPort()
{
FileStream fs = new FileStream(sFileTerminalIPPort, FileMode.Create);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, htRemotingIPPort);
fs.Close();
}
/*
*方法名称SaveRemotingIPPort
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述void
*返回描述void
*功能描述保存上次的remoting设置IP与端口
*/
private void SaveRemotingIPPort() //
{
htTerminalIPPort["RemotingIP"] = textBox1.Text.Trim();
htTerminalIPPort["RemotingPort"] = textBox2.Text.Trim();
FileStream fs = new FileStream(sFileRemotingIPPort, FileMode.Create);
BinaryFormatter bf = new BinaryFormatter();
bf.Serialize(fs, htTerminalIPPort);
fs.Close();
}
/*
*方法名称ExitToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 菜单命令发出者, EventArgs e 菜单命令事件参数
*返回描述void
*功能描述:系统退出
*/
private void ExitToolStripMenuItem_Click(object sender, EventArgs e)
{
this.Close();
}
/*
*方法名称WriteTextBoxInfo
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述string text
*返回描述void
*功能描述:信息输出
*/
private void WriteTextBoxInfo(string text)
{
DateTime dtNow = DateTime.Now;
string log = dtNow.ToString("yyyy-MM-dd HH:mm:ss ", CultureInfo.InvariantCulture);
log += text + "\r\n";
richTBInfo.Text += log;
richTBInfo.Refresh();
}
/*
*方法名称ReadTTimeToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 菜单命令发起者, EventArgs e 菜单命令事件
*返回描述void
*功能描述:读集中器时间
*/
private void ReadTTimeToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tbCurrentTerminal.Text == "")
{
MessageBox.Show("请选择终端编号");
return;
}
string strTerminalTime = "";
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始读时间...");
try
{
bool res = remoteobj.GetTime(sSelectedTID, ref strTerminalTime);
WriteTextBoxInfo(tbCurrentTerminal.Text + " 读时间 结果返回:" + res.ToString() + (res == true ? ",时间为:" + strTerminalTime : strTerminalTime));
}
catch (Exception e1)
{
Console.WriteLine("exeption: " + e1.ToString());
}
}
/*
*方法名称TimingToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 菜单命令发起者, EventArgs e 菜单命令事件
*返回描述void
*功能描述:给集中器校时
*/
private void TimingToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tbCurrentTerminal.Text == "")
{
MessageBox.Show("请选择终端编号");
return;
}
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始校时...");
try
{
WriteTextBoxInfo(tbCurrentTerminal.Text + " 校时 结果返回:" + remoteobj.SetTime(sSelectedTID).ToString());
}
catch (Exception e1)
{
Console.WriteLine("exeption: " + e1.ToString());
}
}
/*
*方法名称ReadSteamDataToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 菜单命令发起者, EventArgs e 菜单命令事件
*返回描述void
*功能描述:招唤蒸汽数据
*/
private void ReadSteamDataToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tbCurrentTerminal.Text == "" || sSelectedMID =="")
{
MessageBox.Show("请选择当前仪表");
return;
}
List<uint> lstParams;
Hashtable hsTable = null;
S_CallDataForm inputDialog = new S_CallDataForm();
inputDialog.sMID = sSelectedMID;
// Show testDialog as a modal dialog and determine if DialogResult = OK.
if (inputDialog.ShowDialog(this) == DialogResult.OK)
{
//string sMID = sSelectedMID;
// Read the contents of testDialog's TextBox.
//this.txtResult.Text = testDialog.TextBox1.Text;
lstParams = inputDialog.lstOBJID;
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始招唤数据...");
string sComment = "";
try
{
bool res = remoteobj.GetData(sSelectedTID, sSelectedMID, lstParams, ref hsTable);
sComment += sSelectedTID + " " + sSelectedMID + " 招唤数据 结果返回:" + res + "\r\n";
if (res == true)
{
//int key = 0;
//foreach (DictionaryEntry de in hsTable)
{
//key = (int)de.Key;
if (hsTable.ContainsKey((uint)0x8030))
{
sComment += "\t\t\t\t终端时间" + hsTable[(uint)0x8030] + "\r\n";
}
if (hsTable.ContainsKey((uint)0x9B07))
{
sComment += "\t\t\t\t蒸汽仪表累积热量" + hsTable[(uint)0x9B07] + "\r\n";
}
if (hsTable.ContainsKey((uint)0x9B06))
{
sComment += "\t\t\t\t蒸汽仪表瞬时热量" + hsTable[(uint)0x9B06] + "\r\n";
}
if (hsTable.ContainsKey((uint)0x9B05))
{
sComment += "\t\t\t\t蒸汽仪表累积流量值" + hsTable[(uint)0x9B05] + "\r\n";
}
if (hsTable.ContainsKey((uint)0x9B03))
{
sComment += "\t\t\t\t蒸汽仪表瞬时流量值" + hsTable[(uint)0x9B03] + "\r\n";
}
if (hsTable.ContainsKey((uint)0x9B01))
{
sComment += "\t\t\t\t蒸汽仪表温度值" + hsTable[(uint)0x9B01] + "\r\n";
}
//温度为负值情况
if (hsTable.ContainsKey((uint)0x9B11))
{
sComment += "\t\t\t\t蒸汽仪表温度值" + hsTable[(uint)0x9B11] + "\r\n";
}
if (hsTable.ContainsKey((uint)0x9B1F))
{
sComment += "\t\t\t\t蒸汽仪表压力值" + hsTable[(uint)0x9B1F] + "\r\n";
}
if (hsTable.ContainsKey((uint)0x9B00))
{
sComment += "\t\t\t\t蒸汽仪表压力值" + hsTable[(uint)0x9B00] + "\r\n";
}
if (hsTable.ContainsKey((uint)0x9B02))
{
sComment += "\t\t\t\t蒸汽仪表频率" + hsTable[(uint)0x9B02] + "\r\n";
}
if (hsTable.ContainsKey((uint)0x9B0E))
{
sComment += "\t\t\t\t蒸汽仪表密度" + hsTable[(uint)0x9B0E] + "\r\n";
}
if (hsTable.ContainsKey((uint)0x9B0F))
{
sComment += "\t\t\t\t蒸汽仪表差压" + hsTable[(uint)0x9B0F] + "\r\n";
}
}
}
WriteTextBoxInfo(sComment);
}
catch (Exception e1)
{
Console.WriteLine("exeption: " + e1.ToString());
}
}
}
/*
*方法名称btnRefresh_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 事件发起者, EventArgs e 点击事件参数
*返回描述void
*功能描述:刷新集中器列表
*/
private void btnRefresh_Click(object sender, EventArgs e)
{
int nTHDeviceCount = 0;
int nElecDeviceCount = 0;
int nSteamDeviceCount = 0;
//List<string> lstTerminal = new List<string>();
Hashtable htTerminals = new Hashtable();
bool res = false;
try
{
res = remoteobj.GetTerminalList(ref htTerminals);
}
catch (Exception e1)
{
WriteTextBoxInfo("不能取终端列表,未注册 或 服务可能未启动");
}
if (res == true)
{
TerminalParamParsing(htTerminals);
tvTerminalList.ImageList = myImageList;
tvTerminalList.Nodes.Clear();
//int nSeq = 0;
tvTerminalList.BeginUpdate();
tvTerminalList.Nodes.Add("NormalROOT", "采集终端与仪表", 4, 4);//struNodeOfTree
tvTerminalList.Nodes.Add("TestROOT", "测试", 4, 4);//struNodeOfTree
int nTestSeq = 0;
foreach (DictionaryEntry de in htTerminalParams)
{
//测试
if (de.Key.ToString().StartsWith("测试"))
{
//添加集中器
tvTerminalList.Nodes[1].Nodes.Add(de.Key.ToString(), de.Key.ToString(), 0);
struTerminal Terminal = (struTerminal)de.Value;
//nElecDeviceCount++;
//添加仪表
foreach (DictionaryEntry de2 in Terminal.htMeters)
{
tvTerminalList.Nodes[1].Nodes[nTestSeq].Nodes.Add(de2.Key.ToString(), de2.Key.ToString(), 1, 2);
}
nTestSeq++;
}
else
{
struTerminal Terminal = (struTerminal)de.Value;
if (Terminal.bOn == true)
{
//treeView1.Nodes[0].Nodes.Add(de.Key.ToString(), de.Key.ToString(), 0);
//int index=de.Key.ToString().IndexOf("-");
//string id = de.Key.ToString().Substring(index+1);
//if (id.StartsWith("S"))
//{
TreeNode tn = tvTerminalList.Nodes[0].Nodes.Insert(0, de.Key.ToString(), de.Key.ToString(), 0);
//添加仪表
foreach (DictionaryEntry de2 in Terminal.htMeters)
{
//treeView1.Nodes[0].Nodes[nSeq].Nodes.Add(de2.Key.ToString(), de2.Key.ToString(), 1, 2);
tn.Nodes.Add(de2.Key.ToString(), de2.Key.ToString(), 1, 2);
}
if (Terminal.sTID.StartsWith("E"))
{
nElecDeviceCount++;
}
else if (Terminal.sTID.StartsWith("T"))
{
nTHDeviceCount++;
}
if (Terminal.sTID.StartsWith("S"))
{
nSteamDeviceCount++;
}
//}
}
else
{
TreeNode tn = tvTerminalList.Nodes[0].Nodes.Add(de.Key.ToString(), de.Key.ToString(), 5, 5);
//添加仪表
foreach (DictionaryEntry de2 in Terminal.htMeters)
{
tn.Nodes.Add(de2.Key.ToString(), de2.Key.ToString(), 6, 6);
}
}
}
}
tvTerminalList.Nodes[0].Expand();
tvTerminalList.Nodes[1].Expand();
tvTerminalList.EndUpdate();
}
lblStreamDeviceCount.Text = "" + nSteamDeviceCount;
lblTHDeviceCount.Text = "" + nTHDeviceCount;
lblElectronicDeviceCount.Text = "" + nElecDeviceCount;
return;
}
/*
*方法名称TerminalParamParsing
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述Hashtable htTerminals 集中器哈希表
*返回描述void
*功能描述:集中器列表参数解析
*/
private void TerminalParamParsing(Hashtable htTerminals)
{
htTerminalParams = new Hashtable();
string sTName, sTID, sMName, sMID;
foreach (DictionaryEntry de in htTerminals)
{
sTName = "";
sTID = "";
sMName = "";
sMID = "";
string s = de.Key.ToString();
ParamParsing(ref s, ref sMID, ref sMName);
s = de.Value.ToString();
ParamParsing(ref s, ref sTID, ref sTName);// OnLine OffLine
struTerminal Terminal;
bool bTerminalOn = sTName.EndsWith("1");//0 1
sTName = sTName.Remove(sTName.Length-2,2);//
if (htTerminalParams[sTName + "-" + sTID] == null)
{
Terminal = new struTerminal();
Terminal.sTID = sTID;
Terminal.htMeters = new Hashtable();
Terminal.bOn = bTerminalOn;
htTerminalParams[sTName + "-" + sTID] = Terminal;
}
else
{
Terminal = (struTerminal)htTerminalParams[sTName + "-" + sTID];
}
Terminal.htMeters.Add(sMName +"-" +sMID, sMID);
}
return;
}
/*
*方法名称ParamParsing
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述ref string sOri 组合字符串, ref string s1 字符串1, ref string s2 字符串2
*返回描述void
*功能描述:集中器列表参数解析
*/
private void ParamParsing(ref string sOri, ref string s1, ref string s2)
{
int nIndex = sOri.IndexOf('\n');
if (nIndex != -1)
{
s1 = sOri.Substring(0, nIndex);
s2 = sOri.Substring(nIndex + 1, sOri.Length - nIndex - 1);
}
}
/*
*方法名称richTBInfo_TextChanged
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 事件发起者, EventArgs e 事件参数
*返回描述void
*功能描述:输出信息更新处理,滚动到末尾,字节数控制
*/
private void richTBInfo_TextChanged(object sender, EventArgs e)
{
//若内容长度过大,清空
if (richTBInfo.TextLength >= 65536)
{
richTBInfo.Clear();
return;
}
richTBInfo.SelectionStart = richTBInfo.TextLength;
richTBInfo.ScrollToCaret();
}
/*
*方法名称SetTerminalIPToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 事件发起者, EventArgs e 事件参数
*返回描述void
*功能描述设置终端IP Port
*/
private void SetTerminalIPToolStripMenuItem_Click(object sender, EventArgs e)
{
bool res = false;
if (tbCurrentTerminal.Text == "")
{
MessageBox.Show("请选择终端编号");
return;
}
IPPortInputForm inputDialog = new IPPortInputForm();
struIPPort struSavedIPPort;
if (htTerminalIPPort.ContainsKey(tbCurrentTerminal.Text))
{
struSavedIPPort = (struIPPort)htTerminalIPPort[tbCurrentTerminal.Text];
inputDialog.LoadIPPort(struSavedIPPort.sIP, struSavedIPPort.nPort);
}
else
{
struSavedIPPort = new struIPPort();
}
// Show testDialog as a modal dialog and determine if DialogResult = OK.
if (inputDialog.ShowDialog(this) == DialogResult.OK)
{
struSavedIPPort.sIP = inputDialog.sIP;
struSavedIPPort.nPort = inputDialog.nPort;
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始写IP和Port...");
try
{
res = remoteobj.SetIPPort(sSelectedTID, struSavedIPPort.sIP, struSavedIPPort.nPort);
WriteTextBoxInfo(tbCurrentTerminal.Text+ " 写IP和Port 结果返回:" + res.ToString());
if (res == true)
{
htTerminalIPPort[sSelectedTID] = struSavedIPPort;
SaveTerminalIPPort();
}
}
catch (Exception e1)
{
Console.WriteLine("exeption: " + e1.ToString());
}
}
inputDialog.Dispose();
}
/*
*方法名称MainForm_Load
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 事件发起者, EventArgs e 事件参数
*返回描述void
*功能描述:主窗口加载,初始化
*/
private void MainForm_Load(object sender, EventArgs e)
{
btnRefresh.Enabled = false;
}
/*
*方法名称SetHeartBeatIntervalToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 事件发起者, EventArgs e 事件参数
*返回描述void
*功能描述:设置心跳间隔
*/
private void SetHeartBeatIntervalToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tbCurrentTerminal.Text == "")
{
MessageBox.Show("请选择终端编号");
return;
}
int nInterval;
HeartBeatIntervalForm inputDialog = new HeartBeatIntervalForm();
// Show testDialog as a modal dialog and determine if DialogResult = OK.
if (inputDialog.ShowDialog(this) == DialogResult.OK)
{
// Read the contents of testDialog's TextBox.
//this.txtResult.Text = testDialog.TextBox1.Text;
nInterval = inputDialog.nInterval*Common.MULTIPLE;
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始写心跳间隔...");
try
{
WriteTextBoxInfo(tbCurrentTerminal.Text + " 写心跳间隔 结果返回:" + remoteobj.SetHeartBeatInterval(sSelectedTID, nInterval).ToString());
}
catch (Exception e1)
{
Console.WriteLine("写心跳间隔 exeption: " + e1.ToString());
}
}
inputDialog.Dispose();
}
/*
*方法名称SetAutoSendIntervalToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 事件发起者, EventArgs e 事件参数
*返回描述void
*功能描述:设置主动上传间隔
*/
private void SetAutoSendIntervalToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tbCurrentTerminal.Text == "")
{
MessageBox.Show("请选择终端编号");
return;
}
int nInterval;
AutoSendIntervalForm inputDialog = new AutoSendIntervalForm();
// Show testDialog as a modal dialog and determine if DialogResult = OK.
if (inputDialog.ShowDialog(this) == DialogResult.OK)
{
// Read the contents of testDialog's TextBox.
//this.txtResult.Text = testDialog.TextBox1.Text;
nInterval = inputDialog.nInterval*Common.MULTIPLE;
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始写主动上传间隔...");
try
{
WriteTextBoxInfo(tbCurrentTerminal.Text + " 写主动上传间隔 结果返回:" + remoteobj.SetAutoSendInterval(sSelectedTID, nInterval).ToString());
}
catch (Exception e1)
{
Console.WriteLine("写主动上传间隔 exeption: " + e1.ToString());
}
}
inputDialog.Dispose();
}
/*
*方法名称GetHeartIntervalToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 事件发起者, EventArgs e 事件参数
*返回描述void
*功能描述:获取心跳间隔
*/
private void GetHeartIntervalToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tbCurrentTerminal.Text == "")
{
MessageBox.Show("请选择终端编号");
return;
}
string sInterval = "";
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始读心跳间隔...");
try
{
bool res = remoteobj.GetHeartBeatInterval(sSelectedTID, ref sInterval);
WriteTextBoxInfo(tbCurrentTerminal.Text + " 读心跳间隔 结果返回:" + res.ToString() + (res == true ? ",心跳间隔为:" + (Convert.ToInt32(sInterval)/Common.MULTIPLE) : ""));
}
catch (Exception e1)
{
// Console.WriteLine("exeption: " + e1.ToString());
}
}
/*
*方法名称GetAutoSendIntervalToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 事件发起者, EventArgs e 事件参数
*返回描述void
*功能描述:获取主动上传间隔
*/
private void GetAutoSendIntervalToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tbCurrentTerminal.Text == "")
{
MessageBox.Show("请选择终端编号");
return;
}
string sInterval = "";
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始读主动上传间隔...");
try
{
bool res = remoteobj.GetAutoSendInterval(sSelectedTID, ref sInterval);
WriteTextBoxInfo(tbCurrentTerminal.Text + " 读主动上传间隔 结果返回:" + res.ToString() + (res == true ? ",主动上传间隔为:" + Convert.ToInt32(sInterval)/Common.MULTIPLE : ""));
}
catch (Exception e1)
{
// Console.WriteLine("exeption: " + e1.ToString());
}
}
/*
*方法名称SetTerminalIDToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 事件发起者, EventArgs e 事件参数
*返回描述void
*功能描述:设置终端编号
*/
private void SetTerminalIDToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tbCurrentTerminal.Text == "")
{
MessageBox.Show("请选择终端编号");
return;
}
string sNewName;
NewTerminalNameForm inputDialog = new NewTerminalNameForm();
inputDialog.SetTerminalName(sSelectedTID);
// Show testDialog as a modal dialog and determine if DialogResult = OK.
if (inputDialog.ShowDialog(this) == DialogResult.OK)
{
// Read the contents of testDialog's TextBox.
//this.txtResult.Text = testDialog.TextBox1.Text;
sNewName = inputDialog.sNewName;
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始设置采集终端编号...");
try
{
WriteTextBoxInfo(tbCurrentTerminal.Text + " 设置采集终端编号:"
+ remoteobj.SetTerminalName(sSelectedTID, sNewName).ToString());
}
catch (Exception e1)
{
Console.WriteLine("exeption: " + e1.ToString());
}
}
inputDialog.Dispose();
}
/*
*方法名称SetMeterIDAndEnableToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 事件发起者, EventArgs e 事件参数
*返回描述void
*功能描述:设置仪表地址和置位
*/
private void SetMeterIDAndEnableToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tbCurrentTerminal.Text == "")
{
MessageBox.Show("请选择终端编号");
return;
}
//string sNewName;
MeterAddrForm inputDialog = new MeterAddrForm();
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始读取仪表地址...");
byte[] arr = null;
bool res = remoteobj.GetMeterAddr(sSelectedTID, ref arr);
WriteTextBoxInfo(tbCurrentTerminal.Text + " 读取仪表地址 结果:" + res);
if (res == false || arr.Length != 16)
{
return;
}
for (int i = 0; i < 16; i++)
{
inputDialog.arrTextBox[i].Text = arr[i].ToString("X2");
//inputDialog.arrTextBox[i].Text = arr[i].ToString("D2");
}
res = remoteobj.GetMeterAble(sSelectedTID, ref arr);
WriteTextBoxInfo(tbCurrentTerminal.Text + " 读取仪表置位 结果:" + res);
if (res == false || arr.Length != 16)
{
return;
}
for (int i = 0; i < 16; i++)
{
if (arr[i] > 0)
{
inputDialog.checkedListBox.SetItemChecked(i, true);// arrTextBox[0].Text = arr[i].ToString("D3");
}
else
{
inputDialog.checkedListBox.SetItemChecked(i, false);// arrTextBox[0].Text = arr[i].ToString("D3");
}
}
// Show testDialog as a modal dialog and determine if DialogResult = OK.
if (inputDialog.ShowDialog(this) == DialogResult.OK)
{
Console.WriteLine("inputDialog.ShowDialog(this) == DialogResult.OK");
res = false;
byte[] arrAddr = null;
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始设置仪表地址...");
try
{
arrAddr = new byte[16];
for (int i = 0; i < 16; i++)
{
arrAddr[i] = Convert.ToByte(inputDialog.arrTextBox[i].Text, 16);
//arrAddr[i] = Convert.ToByte(inputDialog.arrTextBox[i].Text);
}
res = remoteobj.SetMeterAddr(sSelectedTID, ref arrAddr);
WriteTextBoxInfo(tbCurrentTerminal.Text + " 设置仪表地址:" + res);
}
catch (Exception e1)
{
Console.WriteLine("exeption: " + e1.ToString());
}
if (res == false)
{
return;
}
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始设置仪表置位...");
try
{
for (int i = 0; i < 16; i++)
{
arrAddr[i] = Convert.ToByte(inputDialog.checkedListBox.GetItemChecked(i) == true ? 1 : 0);
}
res = remoteobj.SetMeterAble(sSelectedTID, ref arrAddr);
WriteTextBoxInfo(tbCurrentTerminal.Text + " 设置设置仪表置位:" + res);
}
catch (Exception e1)
{
Console.WriteLine("exeption: " + e1.ToString());
}
}
inputDialog.Dispose();
}
/*
*方法名称btnRegister_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 事件发起者, EventArgs e 事件参数
*返回描述void
*功能描述remoting 注册
*/
private void btnRegister_Click(object sender, EventArgs e)
{
SaveRemotingIPPort();
try
{
remoteobj = (ReqHandler)Activator.GetObject(typeof(ReqHandler),
"tcp://" + textBox1.Text.Trim() + ":" + textBox2.Text.Trim() + "/RemoteObject");
btnRefresh.Enabled = true;
StartTimer();
}
catch (Exception e1)
{
MessageBox.Show("注册失败");
}
}
/*
*方法名称S_AlarmSettingToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 事件发起者, EventArgs e 事件参数
*返回描述void
*功能描述:蒸汽告警参数设置
*/
private void S_AlarmSettingToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tbCurrentTerminal.Text == "" || sSelectedMID == "")
{
MessageBox.Show("请选择当前仪表");
return;
}
//string sNewName;
AlarmSettingForm inputDialog = new AlarmSettingForm();
inputDialog.sMID = sSelectedMID;
bool res = false;
string[] arr = null;
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始读取蒸汽仪表上下限...");
res = remoteobj.GetStreamThreshold(sSelectedTID, sSelectedMID, ref arr);
WriteTextBoxInfo(tbCurrentTerminal.Text + " 读取蒸汽仪表上下限 结果:" + res);
if (res == false || arr.Length != 16)
{
return;
}
for (int i = 0; i < 16; i++)
{
inputDialog.arrTextBox[i].Text = arr[i];
}
// Show testDialog as a modal dialog and determine if DialogResult = OK.
inputDialog.Height = 419;
if (inputDialog.ShowDialog(this) == DialogResult.OK)
{
res = false;
string[] arrThreshold = null;
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始设置蒸汽仪表上下限...");
try
{
arrThreshold = new string[16];
for (int i = 0; i < 16; i++)
{
arrThreshold[i] = inputDialog.arrTextBox[i].Text;
}
res = remoteobj.SetStreamThreshold(sSelectedTID, sSelectedMID, ref arrThreshold);
WriteTextBoxInfo(tbCurrentTerminal.Text + " 蒸汽仪表上下限:" + res);
}
catch (Exception e1)
{
Console.WriteLine("exeption: " + e1.ToString());
}
}
inputDialog.Dispose();
}
/*
*方法名称tvTerminalList_AfterSelect
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 事件发起者, EventArgs e 事件参数
*返回描述void
*功能描述集中器树点击处理记录终端ID和仪表ID
*/
private void tvTerminalList_AfterSelect(object sender, TreeViewEventArgs e)
{
if (e.Action == TreeViewAction.ByKeyboard || e.Action == TreeViewAction.ByMouse)
{
struTerminal termianl;
if (e.Node.Level == 1)
{
termianl = (struTerminal)htTerminalParams[e.Node.Text];
if (termianl.bOn)
{
tbCurrentTerminal.Text = e.Node.Text;
sSelectedTID = termianl.sTID;
sSelectedMID = "";
}
else
{
tbCurrentTerminal.Text = "";
sSelectedTID = "";
sSelectedMID = "";
}
}
else if (e.Node.Level == 2)
{
termianl = (struTerminal)htTerminalParams[e.Node.Parent.Text];
if (termianl.bOn)
{
tbCurrentTerminal.Text = e.Node.Parent.Text;
sSelectedTID = termianl.sTID;
sSelectedMID = (string)termianl.htMeters[e.Node.Text];
}
else
{
tbCurrentTerminal.Text = "";
sSelectedTID = "";
sSelectedMID = "";
}
}
}
}
/*
*方法名称E_AlarmSettingToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 事件发起者, EventArgs e 事件参数
*返回描述void
*功能描述:电表告警参数设置
*/
private void E_AlarmSettingToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tbCurrentTerminal.Text == "" || sSelectedMID == "")
{
MessageBox.Show("请选择当前仪表");
return;
}
E_AlarmSettingForm inputDialog = new E_AlarmSettingForm();
bool res = false;
string[] arr = null;
WriteTextBoxInfo(tbCurrentTerminal.Text + " " + sSelectedMID + " 开始读取电表上下限...");
res = remoteobj.GetElectricThreshold(sSelectedTID, sSelectedMID, ref arr);
WriteTextBoxInfo(tbCurrentTerminal.Text + " " + sSelectedMID + " 读取电表上下限 结果:" + res);
if (res == false || arr.Length != 8)
{
return;
}
for (int i = 0; i < 8; i++)
{
inputDialog.arrTextBox[i].Text = arr[i];
}
// Show testDialog as a modal dialog and determine if DialogResult = OK.
inputDialog.sMID = sSelectedMID;
if (inputDialog.ShowDialog(this) == DialogResult.OK)
{
res = false;
string[] arrThreshold = null;
WriteTextBoxInfo(tbCurrentTerminal.Text + " " + sSelectedMID + " 开始设置电表上下限...");
try
{
arrThreshold = new string[8];
for (int i = 0; i < 8; i++)
{
arrThreshold[i] = inputDialog.arrTextBox[i].Text;
}
res = remoteobj.SetElectricThreshold(sSelectedTID, sSelectedMID, ref arrThreshold);
WriteTextBoxInfo(tbCurrentTerminal.Text + " " + sSelectedMID + " 电表上下限:" + res);
}
catch (Exception e1)
{
Console.WriteLine("exeption: " + e1.ToString());
}
}
inputDialog.Dispose();
}
/*
*方法名称E_CallDataToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 事件发起者, EventArgs e 事件参数
*返回描述void
*功能描述:电表招唤数据
*/
private void E_CallDataToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tbCurrentTerminal.Text == "" || sSelectedMID == "")
{
MessageBox.Show("请选择当前仪表");
return;
}
List<uint> lstParams;
Hashtable hsTable = null;
E_CallDataForm inputDialog = new E_CallDataForm();
inputDialog.sMID = sSelectedMID;
// Show testDialog as a modal dialog and determine if DialogResult = OK.
if (inputDialog.ShowDialog(this) == DialogResult.OK)
{
//string sMID = sSelectedMID;
// Read the contents of testDialog's TextBox.
//this.txtResult.Text = testDialog.TextBox1.Text;
lstParams = inputDialog.lstOBJID;
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始招唤数据...");
string sComment = "";
try
{
bool res = remoteobj.GetData(sSelectedTID, sSelectedMID, lstParams, ref hsTable);
sComment += sSelectedTID + " " + sSelectedMID + " 招唤数据 结果返回:" + res + "\r\n";
if (res == true)
{
//int key = 0;
//foreach (DictionaryEntry de in hsTable)
{
//key = (int)de.Key;
if (hsTable.ContainsKey(EMS_COMM_PARAMS.AU))
{
sComment += "\t\t\t\ta相电压" + hsTable[EMS_COMM_PARAMS.AU] + "\r\n";
}
if (hsTable.ContainsKey(EMS_COMM_PARAMS.BU))
{
sComment += "\t\t\t\tb相电压" + hsTable[EMS_COMM_PARAMS.BU] + "\r\n";
}
if (hsTable.ContainsKey(EMS_COMM_PARAMS.CU))
{
sComment += "\t\t\t\tc相电压" + hsTable[EMS_COMM_PARAMS.CU] + "\r\n";
}
if (hsTable.ContainsKey(EMS_COMM_PARAMS.AI))
{
sComment += "\t\t\t\ta相电流" + hsTable[EMS_COMM_PARAMS.AI] + "\r\n";
}
if (hsTable.ContainsKey(EMS_COMM_PARAMS.BI))
{
sComment += "\t\t\t\tb相电流" + hsTable[EMS_COMM_PARAMS.BI] + "\r\n";
}
if (hsTable.ContainsKey(EMS_COMM_PARAMS.CI))
{
sComment += "\t\t\t\tc相电流" + hsTable[EMS_COMM_PARAMS.CI] + "\r\n";
}
if (hsTable.ContainsKey(EMS_COMM_PARAMS.GLYS))
{
sComment += "\t\t\t\t总功率因数" + hsTable[EMS_COMM_PARAMS.GLYS] + "\r\n";
}
if (hsTable.ContainsKey(EMS_COMM_PARAMS.ZXYGZ))
{
sComment += "\t\t\t\t正向有功总电能" + hsTable[EMS_COMM_PARAMS.ZXYGZ] + "\r\n";
}
}
}
WriteTextBoxInfo(sComment);
}
catch (Exception e1)
{
Console.WriteLine("exeption: " + e1.ToString());
}
}
}
/*
*方法名称GetTerminalInfoToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 事件发起者, EventArgs e 事件参数
*返回描述void
*功能描述:获取终端信息
*/
private void GetTerminalInfoToolStripMenuItem_Click(object sender, EventArgs e)
{
bool res = false;
string sInfo = "";
if (tbCurrentTerminal.Text == "")
{
MessageBox.Show("请选择终端编号");
return;
}
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始获取终端基本信息...");
res = remoteobj.GetInfo(sSelectedTID, ref sInfo);
WriteTextBoxInfo(tbCurrentTerminal.Text + " 获取终端基本信息 结果:" + res + (res == true ? sInfo : ""));
}
/*
*方法名称GetAllTerminalInfoToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object sender 事件发起者, EventArgs e 事件参数
*返回描述void
*功能描述:获取全部终端信息
*/
private void GetAllTerminalInfoToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tvTerminalList.Nodes.Count == 0)
{
return;
}
else if (tvTerminalList.Nodes[0].Nodes.Count == 0)
{
return;
}
TreeNodeCollection myNodeCollection = tvTerminalList.Nodes[0].Nodes;
int myCount = myNodeCollection.Count;
// Create an Object array.
Object[] myArray = new Object[myCount];
// Copy the collection into an array.
myNodeCollection.CopyTo(myArray,0);
for(int i=0; i<myArray.Length; i++)
{
struTerminal termianl;
termianl = (struTerminal)htTerminalParams[((TreeNode)myArray[i]).Text];
bool res = false;
string sInfo = "";
WriteTextBoxInfo(((TreeNode)myArray[i]).Text + " 开始获取终端基本信息...");
res = remoteobj.GetInfo(termianl.sTID, ref sInfo);
WriteTextBoxInfo(((TreeNode)myArray[i]).Text + " 获取终端基本信息 结果:" + res + (res == true ? sInfo : ""));
}
}
/*
*方法名称OnTimedEvent
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述object source 事件发起者, ElapsedEventArgs e 事件参数
*返回描述void
*功能描述:定时器函数,刷新集中器列表
*/
private static void OnTimedEvent(object source, ElapsedEventArgs e)
{
FrmMain.UpdTreeViewInfo(Common.btRefresh);
}
/*
*方法名称StartTimer
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述void
*返回描述void
*功能描述:启动定时器
*/
private void StartTimer()
{
if (bStartTimer == false)
{
aTimer = new System.Timers.Timer(10000);
aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
if (aTimer.Enabled == false)
{
aTimer.Enabled = true;
}
bStartTimer = true;
}
}
/*
*方法名称StopTimer
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述void
*返回描述void
*功能描述:停止定时器
*/
private void StopTimer()
{
if (bStartTimer == true)
{
if (aTimer != null && aTimer.Enabled == true)
{
aTimer.Enabled = false;
}
bStartTimer = false;
}
}
/*
*方法名称SetTargetIPToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述void
*返回描述void
*功能描述设置目标IP和端口
*/
private void SetTargetIPToolStripMenuItem_Click(object sender, EventArgs e)
{
bool res = false;
if (tbCurrentTerminal.Text == "")
{
MessageBox.Show("请选择终端编号");
return;
}
string sIP;
int nPort;
ServerIPPortInputForm inputDialog = new ServerIPPortInputForm();
inputDialog.LoadIPPort(Common.configReader.sServerIP, Common.configReader.sServerPort);
// Show testDialog as a modal dialog and determine if DialogResult = OK.
if (inputDialog.ShowDialog(this) == DialogResult.OK)
{
// Read the contents of testDialog's TextBox.
sIP = inputDialog.sIP;
nPort = inputDialog.nPort;
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始写目标服务器IP和Port...");
try
{
res = remoteobj.SetServerIPPort(sSelectedTID, sIP, nPort);
WriteTextBoxInfo(tbCurrentTerminal.Text + " 写目标服务器IP和Port 结果返回:" + res.ToString());
// struIPPort struSavedIPPort = new struIPPort();
// struSavedIPPort.sIP = sIP;
}
catch (Exception e1)
{
Console.WriteLine("exeption: " + e1.ToString());
}
}
inputDialog.Dispose();
}
//
/*
*方法名称callToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述void
*返回描述void
*功能描述:温湿度招唤数据
*/
private void callToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tbCurrentTerminal.Text == "" || sSelectedMID == "")
{
MessageBox.Show("请选择当前仪表");
return;
}
List<uint> lstParams;
Hashtable hsTable = null;
T_CallDataForm inputDialog = new T_CallDataForm();
inputDialog.sMID = sSelectedMID;
// Show testDialog as a modal dialog and determine if DialogResult = OK.
if (inputDialog.ShowDialog(this) == DialogResult.OK)
{
lstParams = inputDialog.lstOBJID;
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始招唤数据...");
string sComment = "";
try
{
bool res = remoteobj.GetData(sSelectedTID, sSelectedMID, lstParams, ref hsTable);
sComment += sSelectedTID + " " + sSelectedMID + " 招唤数据 结果返回:" + res + "\r\n";
if (res == true)
{
//int key = 0;
//foreach (DictionaryEntry de in hsTable)
{
//key = (int)de.Key;
if (hsTable.ContainsKey(THS_COMM_PARAMS.TEMP))
{
sComment += "\t\t\t\t温度" + hsTable[THS_COMM_PARAMS.TEMP] + "\r\n";
}
if (hsTable.ContainsKey(THS_COMM_PARAMS.HUMI))
{
sComment += "\t\t\t\t相对湿度" + hsTable[THS_COMM_PARAMS.HUMI] + "\r\n";
}
}
}
WriteTextBoxInfo(sComment);
}
catch (Exception e1)
{
Console.WriteLine("exeption: " + e1.ToString());
}
}
}
/*
*方法名称setAlarmThToolStripMenuItem_Click
*创建人:韩荣伟
*创建时间2010-10-30
*参数描述void
*返回描述void
*功能描述:设置温湿度告警参数
*/
private void setAlarmThToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tbCurrentTerminal.Text == "" || sSelectedMID == "")
{
MessageBox.Show("请选择当前仪表");
return;
}
T_AlarmSettingForm inputDialog = new T_AlarmSettingForm();
bool res = false;
string[] arr = null;
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始读取温湿度上下限...");
res = remoteobj.GetTempHumiThreshold(sSelectedTID, sSelectedMID, ref arr);
WriteTextBoxInfo(tbCurrentTerminal.Text + " 读取温湿度上下限 结果:" + res);
if (res == false || arr.Length != 8)
{
return;
}
for (int i = 0; i < 8; i++)
{
inputDialog.arrTextBox[i].Text = arr[i];
}
// Show testDialog as a modal dialog and determine if DialogResult = OK.
inputDialog.sMID = sSelectedMID;
if (inputDialog.ShowDialog(this) == DialogResult.OK)
{
res = false;
string[] arrThreshold = null;
WriteTextBoxInfo(tbCurrentTerminal.Text + " " + sSelectedMID + " 开始设置温湿度上下限...");
try
{
arrThreshold = new string[8];
for (int i = 0; i < 8; i++)
{
arrThreshold[i] = inputDialog.arrTextBox[i].Text;
}
res = remoteobj.SetTempHumiThreshold(sSelectedTID, sSelectedMID, ref arrThreshold);
WriteTextBoxInfo(tbCurrentTerminal.Text + " " + sSelectedMID + " 温湿度上下限:" + res);
}
catch (Exception e1)
{
Console.WriteLine("exeption: " + e1.ToString());
}
}
inputDialog.Dispose();
}
private void PTToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tbCurrentTerminal.Text == "" || sSelectedMID == "")
{
MessageBox.Show("请选择当前仪表");
return;
}
E_CTPTSettingForm inputDialog = new E_CTPTSettingForm();
bool res = false;
string[] arr = null;
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始读电表PT CT...");
res = remoteobj.GetElecPTCT(sSelectedTID, sSelectedMID, ref arr);
WriteTextBoxInfo(tbCurrentTerminal.Text + " 读电表PT CT 结果:"+(res==true?"[PT]" + arr[0] + ",[CT]" + arr[1] : res.ToString()));
if (res == false || arr.Length != 2)
{
return;
}
for (int i = 0; i < 2; i++)
{
inputDialog.arrTextBox[i].Text = arr[i];
}
// Show testDialog as a modal dialog and determine if DialogResult = OK.
inputDialog.sMID = sSelectedMID;
if (inputDialog.ShowDialog(this) == DialogResult.OK)
{
res = false;
string[] arrThreshold = null;
WriteTextBoxInfo(tbCurrentTerminal.Text + " " + sSelectedMID + " 开始设置电表PT CT...");
try
{
arrThreshold = new string[2];
for (int i = 0; i < 2; i++)
{
arrThreshold[i] = inputDialog.arrTextBox[i].Text;
}
res = remoteobj.SetElecPTCT(sSelectedTID, sSelectedMID, ref arrThreshold);
WriteTextBoxInfo(tbCurrentTerminal.Text + " " + sSelectedMID + " 电表PT CT" + res);
}
catch (Exception e1)
{
Console.WriteLine("exeption: " + e1.ToString());
}
}
inputDialog.Dispose();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tbCurrentTerminal.Text == "")
{
MessageBox.Show("请选择终端编号");
return;
}
int nInterval;
HeartBeatIntervalForm inputDialog = new HeartBeatIntervalForm();
inputDialog.Text = "采集失败时间间隔";
inputDialog.label2.Text = "时间间隔";
// Show testDialog as a modal dialog and determine if DialogResult = OK.
if (inputDialog.ShowDialog(this) == DialogResult.OK)
{
// Read the contents of testDialog's TextBox.
//this.txtResult.Text = testDialog.TextBox1.Text;
nInterval = inputDialog.nInterval * Common.MULTIPLE;
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始写采集数据失败间隔...");
try
{
WriteTextBoxInfo(tbCurrentTerminal.Text + " 写采集数据失败间隔 结果返回:" + remoteobj.SetSteamFailInterval(sSelectedTID, nInterval).ToString());
}
catch (Exception e1)
{
Console.WriteLine("写采集数据失败间隔 exeption: " + e1.ToString());
}
}
inputDialog.Dispose();
}
private void ToolStripMenuItem_Click(object sender, EventArgs e)
{
if (tbCurrentTerminal.Text == "")
{
MessageBox.Show("请选择终端编号");
return;
}
WriteTextBoxInfo(tbCurrentTerminal.Text + " 开始校时...");
try
{
WriteTextBoxInfo(tbCurrentTerminal.Text + " 校时 结果返回:" + remoteobj.SetTime(sSelectedTID).ToString());
}
catch (Exception e1)
{
Console.WriteLine("exeption: " + e1.ToString());
}
}
}
/*
*结构名称struTerminal
*创建人:韩荣伟
*创建时间2010-10-30
*功能描述:终端信息结构
*/
struct struTerminal
{
public string sTID;
public Hashtable htMeters;
public bool bOn;
}
}
namespace CommService
{
/*
*结构名称EMS_COMM_PARAMS
*创建人:韩荣伟
*创建时间2010-10-30
*功能描述:电力对象编码
*/
struct EMS_COMM_PARAMS
{
//电类型
public const uint AI = 0x8E21;
public const uint BI = 0x8E22;
public const uint CI = 0x8E23;
public const uint AU = 0x8E11;
public const uint BU = 0x8E12;
public const uint CU = 0x8E13;
public const uint GLYS = 0xB650;
public const uint ZXYGZ = 0x9010;
}
/*
*结构名称THS_COMM_PARAMS
*创建人:韩荣伟
*创建时间2010-10-30
*功能描述:温湿度对象编码
*/
struct THS_COMM_PARAMS
{
//温湿度类型
public const uint TEMP = 0xB400;
public const uint HUMI = 0xB401;
}
}