using Autofac; using HybirdFrameworkEntity; using HybirdFrameworkServices; using HybirdFrameworkServices.Charger.BatCharging.Manager; 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; ChargerMgrTool encode = new ChargerMgrTool(); private Server Server; public Form1(SysUserServices sysUserServices) { _sysUserServices = sysUserServices; InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { //_log.Info("this is a test"); //var lstSysUserServices = _sysUserServices.Query(); 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(); Server.connect(port); } #region 按钮方法 private void btnCmd1_Click(object sender, EventArgs e) { byte type = 1;//类型 0-查询/1-设置 uint startAddress = 2;//设置/查询参数起始地址 byte num = 2;//设置/查询个数 byte[] setData = new byte[8];//设置数据 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-查询 1-设置 uint startAddress = 1;//设置/查询参数启始地址 byte[] setData = new byte[8];//设置数据 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;//充电枪口 uint startAddress = 1;//启始命令地址 byte num = 2;//命令个数 byte[] setData = new byte[8];//命令参数 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); } } 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(); } private void btnCmd101_Click(object sender, EventArgs e) { ushort heartbeatNum = 0; byte[] bytes = encode.Send101(heartbeatNum); if (Server != null) { Server.Send(bytes); } } private void btnCmd103_Click(object sender, EventArgs e) { byte chargeNum = 0; bool reportMessage = false; byte[] bytes = encode.Send103(chargeNum, reportMessage); if (Server != null) { Server.Send(bytes); } } private void btnCmd105_Click(object sender, EventArgs e) { CMD105 CMD = new CMD105(); byte[] bytes = encode.Send105(CMD); if (Server != null) { Server.Send(bytes); } } private void btnCmd107_Click(object sender, EventArgs e) { byte[] bytes = encode.Send107(); if (Server != null) { Server.Send(bytes); } } private void btnCmd109_Click(object sender, EventArgs e) { byte[] bytes = encode.Send109(); if (Server != null) { Server.Send(bytes); } } private void btnCmd111_Click(object sender, EventArgs e) { byte messageType = 0; byte[] bytes = encode.Send111(messageType); if (Server != null) { Server.Send(bytes); } } private void btnCmd1502_Click(object sender, EventArgs e) { uint responseCode = 0; byte[] bytes = encode.Send1502(responseCode); if (Server != null) { Server.Send(bytes); } } private void btnCmd1504_Click(object sender, EventArgs e) { uint logo = 0; uint successReservedMessageNum = 0; byte[] bytes = encode.Send1504(logo, successReservedMessageNum); if (Server != null) { Server.Send(bytes); } } private void btnCmd1506_Click(object sender, EventArgs e) { byte[] bytes = encode.Send1506(); if (Server != null) { Server.Send(bytes); } } #endregion }