|
|
|
|
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.Xml;
|
|
|
|
|
|
|
|
|
|
namespace Mesnac.Equips.Connection.MPI
|
|
|
|
|
{
|
|
|
|
|
public partial class SetConfigForm : Form, Mesnac.Equips.Connection.ConnConfig
|
|
|
|
|
{
|
|
|
|
|
#region 单例模式
|
|
|
|
|
private static SetConfigForm _this;
|
|
|
|
|
public static SetConfigForm Instance
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (null == _this)
|
|
|
|
|
_this = new SetConfigForm();
|
|
|
|
|
return _this;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
public SetConfigForm()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConnType thisConnType = new ConnType();
|
|
|
|
|
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
thisConnType.Rack = Convert.ToInt32(this.txtRack.Text);
|
|
|
|
|
thisConnType.Slot = Convert.ToInt32(this.txtSlot.Text);
|
|
|
|
|
thisConnType.MPI = Convert.ToInt32(this.txtMPI.Text);
|
|
|
|
|
this.Close();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show(ex.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region SetConfig GetConfig
|
|
|
|
|
|
|
|
|
|
public Connection.ConnType SetConfig(Connection.ConnType connType)
|
|
|
|
|
{
|
|
|
|
|
ConnType Result = new ConnType();
|
|
|
|
|
if (connType != null)
|
|
|
|
|
{
|
|
|
|
|
Result = (ConnType)connType;
|
|
|
|
|
}
|
|
|
|
|
this.txtRack.Text = Result.Rack.ToString();
|
|
|
|
|
this.txtSlot.Text = Result.Slot.ToString();
|
|
|
|
|
this.txtMPI.Text = Result.MPI.ToString();
|
|
|
|
|
this.ShowDialog();
|
|
|
|
|
return thisConnType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool GetFirstNodeValue(XmlNode node, string path, string attribute, bool throwException, out string value)
|
|
|
|
|
{
|
|
|
|
|
value = string.Empty;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
value = node.SelectNodes(path)[0].Attributes[attribute.ToLower()].Value.ToString();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
if (throwException)
|
|
|
|
|
{
|
|
|
|
|
throw (ex);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
private bool GetNodeAttributeValue(XmlNode node, string attribute, bool throwException, out string value)
|
|
|
|
|
{
|
|
|
|
|
value = string.Empty;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
value = node.Attributes[attribute.ToLower()].Value.ToString();
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
if (throwException)
|
|
|
|
|
{
|
|
|
|
|
throw (ex);
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
public Connection.ConnType GetConfig(XmlNode node)
|
|
|
|
|
{
|
|
|
|
|
ConnType Result = new ConnType();
|
|
|
|
|
string rack = "0";
|
|
|
|
|
string slot = "2";
|
|
|
|
|
string mpi = "3";
|
|
|
|
|
GetFirstNodeValue(node, ".//Rack[@value]", "value", true, out rack);
|
|
|
|
|
GetFirstNodeValue(node, ".//Slot[@value]", "value", true, out slot);
|
|
|
|
|
GetFirstNodeValue(node, ".//MPI[@value]", "value", true, out mpi);
|
|
|
|
|
Result.Rack = Convert.ToInt32(rack);
|
|
|
|
|
Result.Slot = Convert.ToInt32(slot);
|
|
|
|
|
Result.MPI = Convert.ToInt32(mpi);
|
|
|
|
|
return Result;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class ConnType : Mesnac.Equips.Connection.ConnType
|
|
|
|
|
{
|
|
|
|
|
public ConnType()
|
|
|
|
|
{
|
|
|
|
|
this.Rack = 0; //机架号默认为0
|
|
|
|
|
this.Slot = 2; //槽号默认为2
|
|
|
|
|
this.MPI = 3; //MPI地址默认为3
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 机架号
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Rack { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 槽号
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int Slot { get; set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// MPI地址
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int MPI { get; set; }
|
|
|
|
|
}
|
|
|
|
|
}
|