init
This commit is contained in:
403
DataPRO/SLICEDBCommands/NetworkCommands.cs
Normal file
403
DataPRO/SLICEDBCommands/NetworkCommands.cs
Normal file
@@ -0,0 +1,403 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DTS.Common.Enums.DASFactory;
|
||||
using DTS.Common.ICommunication;
|
||||
|
||||
namespace DTS.DASLib.Command.SLICEDB
|
||||
{
|
||||
public abstract class NetworkCommands : CommandBase
|
||||
{
|
||||
protected enum Commands
|
||||
{
|
||||
Reserved = 0x00,
|
||||
QueryIPAddress = 0x01,
|
||||
SetIPAddress = 0x02,
|
||||
QueryNetmask = 0x03,
|
||||
SetNetmask = 0x04,
|
||||
QueryDefaultRoute = 0x05,
|
||||
SetDefaultRoute = 0x06,
|
||||
QueryMACAddress = 0x07,
|
||||
SetMACAddress = 0x08,
|
||||
};
|
||||
protected abstract Commands _Command { get; }
|
||||
|
||||
protected NetworkCommands(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
command.Type = CommandPacket.CommandType.Network;
|
||||
command.SetCommand((byte)_Command, _Command.ToString());
|
||||
}
|
||||
|
||||
protected NetworkCommands(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
command.Type = CommandPacket.CommandType.Network;
|
||||
command.SetCommand((byte)_Command, _Command.ToString());
|
||||
}
|
||||
|
||||
public override void CommandToString(ref List<List<string>> list)
|
||||
{
|
||||
base.CommandToString(ref list);
|
||||
list[0].Add(recorder.ConnectString);
|
||||
}
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.ResponseToString(ref lines);
|
||||
lines[0].Add(recorder.ConnectString);
|
||||
}
|
||||
}
|
||||
|
||||
public class QueryIPAddress : NetworkCommands
|
||||
{
|
||||
protected override NetworkCommands.Commands _Command
|
||||
{
|
||||
get { return Commands.QueryIPAddress; }
|
||||
}
|
||||
public QueryIPAddress(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public QueryIPAddress(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private string _val;
|
||||
|
||||
/// <summary>
|
||||
/// The current IP address of the SLICE DB
|
||||
/// </summary>
|
||||
public string IPAddress
|
||||
{
|
||||
get { return _val; }
|
||||
}
|
||||
|
||||
protected override CommandReceiveAction WholePackage()
|
||||
{
|
||||
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
|
||||
{
|
||||
response.GetParameter(0, out _val);
|
||||
}
|
||||
else
|
||||
{
|
||||
_val = string.Empty;
|
||||
}
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
}
|
||||
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.ResponseToString(ref lines);
|
||||
lines.Add(new List<string>()
|
||||
{
|
||||
string.Format("IP Address: {0}", IPAddress)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class SetIPAddress : NetworkCommands
|
||||
{
|
||||
protected override NetworkCommands.Commands _Command
|
||||
{
|
||||
get { return Commands.SetIPAddress; }
|
||||
}
|
||||
public SetIPAddress(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public SetIPAddress(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private string _val;
|
||||
|
||||
/// <summary>
|
||||
/// The current IP address of the SLICE DB
|
||||
/// </summary>
|
||||
public string IPAddress
|
||||
{
|
||||
get { return _val; }
|
||||
set
|
||||
{
|
||||
_val = value;
|
||||
command.Parameter = new byte[_val.Length + 1];
|
||||
command.SetParameter(0, _val);
|
||||
}
|
||||
}
|
||||
|
||||
public override void CommandToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.CommandToString(ref lines);
|
||||
lines.Add(new List<string>() { string.Format("IP Address: {0}", IPAddress) });
|
||||
}
|
||||
}
|
||||
|
||||
public class QueryNetmask : NetworkCommands
|
||||
{
|
||||
protected override NetworkCommands.Commands _Command
|
||||
{
|
||||
get { return Commands.QueryNetmask; }
|
||||
}
|
||||
public QueryNetmask(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public QueryNetmask(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private string _val;
|
||||
|
||||
/// <summary>
|
||||
/// The current netmask of the SLICE DB
|
||||
/// </summary>
|
||||
public string Netmask
|
||||
{
|
||||
get { return _val; }
|
||||
}
|
||||
|
||||
protected override CommandReceiveAction WholePackage()
|
||||
{
|
||||
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
|
||||
{
|
||||
response.GetParameter(0, out _val);
|
||||
}
|
||||
else
|
||||
{
|
||||
_val = string.Empty;
|
||||
}
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
}
|
||||
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.ResponseToString(ref lines);
|
||||
lines.Add(new List<string>()
|
||||
{
|
||||
string.Format("Netmask: {0}", Netmask)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class SetNetmask : NetworkCommands
|
||||
{
|
||||
protected override NetworkCommands.Commands _Command
|
||||
{
|
||||
get { return Commands.SetNetmask; }
|
||||
}
|
||||
public SetNetmask(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public SetNetmask(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private string _val;
|
||||
|
||||
/// <summary>
|
||||
/// The current netmask of the SLICE DB
|
||||
/// </summary>
|
||||
public string Netmask
|
||||
{
|
||||
get { return _val; }
|
||||
set
|
||||
{
|
||||
_val = value;
|
||||
command.Parameter = new byte[_val.Length + 1];
|
||||
command.SetParameter(0, _val);
|
||||
}
|
||||
}
|
||||
|
||||
public override void CommandToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.CommandToString(ref lines);
|
||||
lines.Add(new List<string>() { string.Format("Netmask: {0}", Netmask) });
|
||||
}
|
||||
}
|
||||
|
||||
public class QueryDefaultRoute : NetworkCommands
|
||||
{
|
||||
protected override NetworkCommands.Commands _Command
|
||||
{
|
||||
get { return Commands.QueryDefaultRoute; }
|
||||
}
|
||||
|
||||
public QueryDefaultRoute(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public QueryDefaultRoute(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private string _val;
|
||||
|
||||
/// <summary>
|
||||
/// The current default route of the SLICE DB
|
||||
/// </summary>
|
||||
public string DefaultRoute
|
||||
{
|
||||
get { return _val; }
|
||||
}
|
||||
|
||||
protected override CommandReceiveAction WholePackage()
|
||||
{
|
||||
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
|
||||
{
|
||||
response.GetParameter(0, out _val);
|
||||
}
|
||||
else
|
||||
{
|
||||
_val = string.Empty;
|
||||
}
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
}
|
||||
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.ResponseToString(ref lines);
|
||||
lines.Add(new List<string>()
|
||||
{
|
||||
string.Format("Default route: {0}", DefaultRoute)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class SetDefaultRoute : NetworkCommands
|
||||
{
|
||||
protected override NetworkCommands.Commands _Command
|
||||
{
|
||||
get { return Commands.SetDefaultRoute; }
|
||||
}
|
||||
public SetDefaultRoute(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public SetDefaultRoute(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private string _val;
|
||||
|
||||
/// <summary>
|
||||
/// The current default route of the SLICE DB
|
||||
/// </summary>
|
||||
public string DefaultRoute
|
||||
{
|
||||
get { return _val; }
|
||||
set
|
||||
{
|
||||
_val = value;
|
||||
command.Parameter = new byte[_val.Length + 1];
|
||||
command.SetParameter(0, _val);
|
||||
}
|
||||
}
|
||||
|
||||
public override void CommandToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.CommandToString(ref lines);
|
||||
lines.Add(new List<string>() { string.Format("Default route: {0}", DefaultRoute) });
|
||||
}
|
||||
}
|
||||
|
||||
public class QueryMACAddress : NetworkCommands
|
||||
{
|
||||
protected override NetworkCommands.Commands _Command
|
||||
{
|
||||
get { return Commands.QueryMACAddress; }
|
||||
}
|
||||
public QueryMACAddress(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public QueryMACAddress(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private string _val;
|
||||
|
||||
/// <summary>
|
||||
/// The current MAC address (Ethernet hardware address) of the SLICE DB
|
||||
/// </summary>
|
||||
public string MACAddress
|
||||
{
|
||||
get { return _val; }
|
||||
}
|
||||
|
||||
protected override CommandReceiveAction WholePackage()
|
||||
{
|
||||
if (response.Status == DFConstantsAndEnums.CommandStatus.StatusNoError)
|
||||
{
|
||||
response.GetParameter(0, out _val);
|
||||
}
|
||||
else
|
||||
{
|
||||
_val = string.Empty;
|
||||
}
|
||||
return CommandReceiveAction.StopReceiving;
|
||||
}
|
||||
|
||||
public override void ResponseToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.ResponseToString(ref lines);
|
||||
lines.Add(new List<string>()
|
||||
{
|
||||
string.Format("MAC Address: {0}", MACAddress)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class SetMACAddress : NetworkCommands
|
||||
{
|
||||
protected override NetworkCommands.Commands _Command
|
||||
{
|
||||
get { return Commands.SetMACAddress; }
|
||||
}
|
||||
public SetMACAddress(DTS.Common.Interface.DASFactory.ICommunication sock)
|
||||
: base(sock)
|
||||
{
|
||||
}
|
||||
|
||||
public SetMACAddress(DTS.Common.Interface.DASFactory.ICommunication sock, int TimeoutMillisec)
|
||||
: base(sock, TimeoutMillisec)
|
||||
{
|
||||
}
|
||||
|
||||
private string _val;
|
||||
|
||||
/// <summary>
|
||||
/// The current MAC address (Ethernet hardware address) of the SLICE DB
|
||||
/// </summary>
|
||||
public string MACAddress
|
||||
{
|
||||
get { return _val; }
|
||||
set
|
||||
{
|
||||
_val = value;
|
||||
command.Parameter = new byte[_val.Length + 1];
|
||||
command.SetParameter(0, _val);
|
||||
}
|
||||
}
|
||||
|
||||
public override void CommandToString(ref List<List<string>> lines)
|
||||
{
|
||||
base.CommandToString(ref lines);
|
||||
lines.Add(new List<string>() { string.Format("MAC Address: {0}", MACAddress) });
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user