|
|
|
|
using Autofac;
|
|
|
|
|
using HybirdFrameworkEntity;
|
|
|
|
|
using HybirdFrameworkServices.Netty;
|
|
|
|
|
using HybirdFrameworkServices.System;
|
|
|
|
|
using log4net;
|
|
|
|
|
|
|
|
|
|
namespace WinFormStarter;
|
|
|
|
|
|
|
|
|
|
public partial class Form1 : Form
|
|
|
|
|
{
|
|
|
|
|
private ILog _log = LogManager.GetLogger(typeof(Form1));
|
|
|
|
|
private SysUserServices _sysUserServices;
|
|
|
|
|
|
|
|
|
|
Encode encode = new Encode();
|
|
|
|
|
|
|
|
|
|
private Server Server;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Form1(SysUserServices sysUserServices)
|
|
|
|
|
{
|
|
|
|
|
_sysUserServices = sysUserServices;
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//_log.Info("this is a test");
|
|
|
|
|
//MessageBox.Show(_sysUserServices.Query().Count.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void FrmChargeResult_Load(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//TcpClientChargerTool tcpClientChargerTool = new TcpClientChargerTool();
|
|
|
|
|
//tcpClientChargerTool.F_ClientIP = "127.0.0.1";
|
|
|
|
|
//tcpClientChargerTool.F_ClientPort = 9000;
|
|
|
|
|
//tcpClientChargerTool.Connect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnChrg01Connect_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int port = Convert.ToInt32(txtChargePort.Text);
|
|
|
|
|
Server = new Server(port);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region
|
|
|
|
|
private void btnCmd1_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
byte type = 1;//<2F><><EFBFBD><EFBFBD> 0-<2D><>ѯ/1-<2D><><EFBFBD><EFBFBD>
|
|
|
|
|
uint startAddress = 2;//<2F><><EFBFBD><EFBFBD>/<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
|
|
|
|
|
byte num = 2;//<2F><><EFBFBD><EFBFBD>/<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD>
|
|
|
|
|
byte[] setData = new byte[8];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
setData[0] = 0;
|
|
|
|
|
setData[1] = 1;
|
|
|
|
|
setData[2] = 2;
|
|
|
|
|
setData[3] = 3;
|
|
|
|
|
setData[4] = 4;
|
|
|
|
|
setData[5] = 5;
|
|
|
|
|
setData[6] = 6;
|
|
|
|
|
setData[7] = 7;
|
|
|
|
|
byte[] bytes = encode.Send1(type, startAddress, num, setData);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd3_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
byte type = 1;//0-<2D><>ѯ 1-<2D><><EFBFBD><EFBFBD>
|
|
|
|
|
uint startAddress = 1;//<2F><><EFBFBD><EFBFBD>/<2F><>ѯ<EFBFBD><D1AF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ
|
|
|
|
|
byte[] setData = new byte[8];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
setData[0] = 0;
|
|
|
|
|
setData[1] = 1;
|
|
|
|
|
setData[2] = 2;
|
|
|
|
|
setData[3] = 3;
|
|
|
|
|
setData[4] = 4;
|
|
|
|
|
setData[5] = 5;
|
|
|
|
|
setData[6] = 6;
|
|
|
|
|
setData[7] = 7;
|
|
|
|
|
byte[] bytes = encode.Send3(type, startAddress, setData);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd5_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
byte type = 1;//<2F><><EFBFBD><EFBFBD>ǹ<EFBFBD><C7B9>
|
|
|
|
|
uint startAddress = 1;//<2F><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
|
|
|
byte num = 2;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
byte[] setData = new byte[8];//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
setData[0] = 0;
|
|
|
|
|
setData[1] = 1;
|
|
|
|
|
setData[2] = 2;
|
|
|
|
|
setData[3] = 3;
|
|
|
|
|
setData[4] = 4;
|
|
|
|
|
setData[5] = 5;
|
|
|
|
|
setData[6] = 6;
|
|
|
|
|
setData[7] = 7;
|
|
|
|
|
byte[] bytes = encode.Send5(type, startAddress, num, setData);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd7_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CMD7 CMD = new CMD7();
|
|
|
|
|
CMD.Reserved1 = 0;
|
|
|
|
|
CMD.Reserved = 0;
|
|
|
|
|
CMD.ChargMuzzle = 1;
|
|
|
|
|
CMD.ChargeType = 2;
|
|
|
|
|
CMD.ChargeStopPassword = 3;
|
|
|
|
|
CMD.ChargStrategy = 4;
|
|
|
|
|
CMD.ChargStrategyPara = 5;
|
|
|
|
|
CMD.ScheduleStartupTime = 6;
|
|
|
|
|
CMD.OutTime = 7;
|
|
|
|
|
CMD.CardNumber = "123456789";
|
|
|
|
|
CMD.NetOutageSign = 9;
|
|
|
|
|
CMD.MaxElectric = 10;
|
|
|
|
|
CMD.SerialNum = "12345678";
|
|
|
|
|
CMD.BMSVoltage = 11;
|
|
|
|
|
CMD.Balance = 12;
|
|
|
|
|
CMD.DisOrChargeMark = 13;
|
|
|
|
|
byte[] bytes = encode.Send7(CMD);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd113_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
byte chargeNum = 0;
|
|
|
|
|
byte sign = 0;
|
|
|
|
|
byte[] bytes = encode.Send113(chargeNum, sign);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd201_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CMD201 CMD = new CMD201();
|
|
|
|
|
uint func = 0;
|
|
|
|
|
byte[] bytes = encode.Send201(CMD, func);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd1003_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string fileName = "";
|
|
|
|
|
byte[] bytes = encode.Send1003(fileName);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd1005_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uint fileLength = 0;
|
|
|
|
|
byte[] bytes = encode.Send1005(fileLength);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd1007_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string updata = "";
|
|
|
|
|
byte[] bytes = encode.Send1007(updata);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd1009_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uint Reserved1 = 0;
|
|
|
|
|
byte[] bytes = encode.Send1009(Reserved1);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd1011_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uint Reserved1 = 0;
|
|
|
|
|
byte[] bytes = encode.Send1011(Reserved1);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd1021_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uint results = 0;
|
|
|
|
|
string description = "";
|
|
|
|
|
byte[] bytes = encode.Send1021(results, description);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd401_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
string chargingSerialNum = "";
|
|
|
|
|
uint startIndex = 0;
|
|
|
|
|
byte[] bytes = encode.Send401(chargingSerialNum, startIndex);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd421_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
//byte[] bytes = encode.Send421(updata);
|
|
|
|
|
|
|
|
|
|
//if (server != null)
|
|
|
|
|
//{
|
|
|
|
|
// Server.Send(bytes);
|
|
|
|
|
//}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd1101_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
byte[] bytes = encode.Send1101();
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd1103_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CMD1103 CMD = new CMD1103();
|
|
|
|
|
byte[] bytes = encode.Send1103(CMD);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd1105_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CMD1105 CMD = new CMD1105();
|
|
|
|
|
byte[] bytes = encode.Send1105(CMD);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd1107_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
byte[] bytes = encode.Send1107();
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd1301_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CMD1301 CMD = new CMD1301();
|
|
|
|
|
byte[] bytes = encode.Send1301(CMD);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd1401_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CMD1401 CMD = new CMD1401();
|
|
|
|
|
byte[] bytes = encode.Send1401(CMD);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd1406_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CMD1406 CMD = new CMD1406();
|
|
|
|
|
byte[] bytes = encode.Send1406(CMD);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
private void btnCmd205_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uint value03 = 0;
|
|
|
|
|
uint value04 = 0;
|
|
|
|
|
byte[] bytes = encode.Send205(value03, value04);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd209_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CMD210 CMD210 = new CMD210();
|
|
|
|
|
string value05 = ";";
|
|
|
|
|
byte[] bytes = encode.Send209(CMD210, value05);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd203_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CMD203 CMD = new CMD203();
|
|
|
|
|
byte[] bytes = encode.Send203(CMD);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd207_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CMD208 CMD208 = new CMD208();
|
|
|
|
|
string value06 = "";
|
|
|
|
|
string value07 = "";
|
|
|
|
|
byte value08 = 0;
|
|
|
|
|
byte value09 = 0;
|
|
|
|
|
uint value10 = 0;
|
|
|
|
|
ulong value11 = 0;
|
|
|
|
|
byte[] bytes = encode.Send207(CMD208, value06, value07, value08, value09, value10, value11);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd1001_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
uint instruct = 0;
|
|
|
|
|
byte[] bytes = encode.Send1001(instruct);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd301_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
byte[] bytes = encode.Send301();
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd303_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
byte[] bytes = encode.Send303();
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnCmd221_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
CMD221 CMD221 = new CMD221();
|
|
|
|
|
uint value05 = 0;
|
|
|
|
|
byte[] bytes = encode.Send221(CMD221, value05);
|
|
|
|
|
|
|
|
|
|
if (Server != null)
|
|
|
|
|
{
|
|
|
|
|
Server.Send(bytes);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void BtnCloseConnect_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
Server.Dispose();
|
|
|
|
|
}
|
|
|
|
|
}
|