smartwyy 8 months ago
parent c08ea1c183
commit 1c6520381d

11
.gitignore vendored

@ -1,6 +1,13 @@
/.idea/**
**/obj/**
**/bin/**
**/obj/
**/bin/
.vs/
WebStarter/obj
WebStarter/bin
WinFormStarter/obj
WinFormStarter/bin
/HybirdFrameworkCore/obj/
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

@ -0,0 +1,19 @@
namespace HybirdFrameworkCore.Autofac.Attribute;
public class ScopeAttribute : System.Attribute
{
public string scope;
public ScopeAttribute(string scope)
{
this.scope = scope;
}
}
public class ScopeConst
{
public static readonly string InstancePerLifetimeScope = "InstancePerLifetimeScope" ;
public static readonly string SingleInstance = "SingleInstance";
public static readonly string InstancePerDependency = "InstancePerDependency";
}

@ -1,19 +1,23 @@
using System.Reflection;
using Autofac;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
using Module = Autofac.Module;
namespace HybirdFrameworkCore.Autofac
{
public class AutofacModuleRegister : Module
{
private readonly ILog Log = LogManager.GetLogger(typeof(AutofacModuleRegister));
protected override void Load(ContainerBuilder builder)
{
var basePath = AppContext.BaseDirectory;
#region 带有接口层的服务注入
var servicesDllFile = Path.Combine(basePath, "HybirdFrameworkRepository.dll");
var repositoryDllFile = Path.Combine(basePath, "HybirdFrameworkServices.dll");
var repositoryDllFile = Path.Combine(basePath, "HybirdFrameworkRepository.dll");
var servicesDllFile = Path.Combine(basePath, "HybirdFrameworkServices.dll");
if (!(File.Exists(servicesDllFile) && File.Exists(repositoryDllFile)))
{
@ -35,17 +39,61 @@ namespace HybirdFrameworkCore.Autofac
//}
// 获取 Service.dll 程序集服务,并注册
var assemblysServices = Assembly.LoadFrom(servicesDllFile);
SplitInject(Assembly.LoadFrom(servicesDllFile), builder);
builder.RegisterTypes(assemblysServices.ExportedTypes.ToArray()).SingleInstance()
.PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies); //支持属性注入依赖重复
// 获取 Repository.dll 程序集服务,并注册
var assemblysRepository = Assembly.LoadFrom(repositoryDllFile);
builder.RegisterTypes(assemblysRepository.ExportedTypes.ToArray()).SingleInstance()
.PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies); //支持属性注入依赖重复
SplitInject(Assembly.LoadFrom(repositoryDllFile), builder);
#endregion
}
private void SplitInject(Assembly assemblysServices, ContainerBuilder builder)
{
List<Type> InstancePerLifetimeScopeList = new List<Type>();
List<Type> instancePerDependencyList = new List<Type>();
List<Type> defaultList = new List<Type>();
foreach (var type in assemblysServices.ExportedTypes)
{
ScopeAttribute? scope = type.GetCustomAttribute<ScopeAttribute>();
if (scope != null)
{
if (ScopeConst.InstancePerLifetimeScope == scope.scope)
{
InstancePerLifetimeScopeList.Add(type);
}
else if (ScopeConst.InstancePerDependency == scope.scope)
{
instancePerDependencyList.Add(type);
}
else
{
defaultList.Add(type);
}
}
else
{
defaultList.Add(type);
}
}
if (defaultList.Count > 0)
{
builder.RegisterTypes(defaultList.ToArray()).SingleInstance()
.PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies); //支持属性注入依赖重复
}
if (instancePerDependencyList.Count > 0)
{
builder.RegisterTypes(instancePerDependencyList.ToArray()).InstancePerDependency()
.PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies); //支持属性注入依赖重复
}
if (InstancePerLifetimeScopeList.Count > 0)
{
builder.RegisterTypes(InstancePerLifetimeScopeList.ToArray()).InstancePerMatchingLifetimeScope()
.PropertiesAutowired(PropertyWiringOptions.AllowCircularDependencies); //支持属性注入依赖重复
}
}
}
}

@ -8,6 +8,7 @@
<ItemGroup>
<PackageReference Include="Autofac" Version="7.0.1" />
<PackageReference Include="log4net" Version="2.0.15" />
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />

@ -1,275 +0,0 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v6.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v6.0": {
"HybirdFrameworkCore/1.0.0": {
"dependencies": {
"Autofac": "7.0.1",
"Microsoft.Extensions.Configuration.Abstractions": "7.0.0",
"Microsoft.Extensions.Configuration.Json": "7.0.0",
"Newtonsoft.Json": "13.0.3"
},
"runtime": {
"HybirdFrameworkCore.dll": {}
}
},
"Autofac/7.0.1": {
"dependencies": {
"System.Diagnostics.DiagnosticSource": "4.7.1"
},
"runtime": {
"lib/net6.0/Autofac.dll": {
"assemblyVersion": "7.0.1.0",
"fileVersion": "7.0.1.0"
}
}
},
"Microsoft.Extensions.Configuration/7.0.0": {
"dependencies": {
"Microsoft.Extensions.Configuration.Abstractions": "7.0.0",
"Microsoft.Extensions.Primitives": "7.0.0"
},
"runtime": {
"lib/net6.0/Microsoft.Extensions.Configuration.dll": {
"assemblyVersion": "7.0.0.0",
"fileVersion": "7.0.22.51805"
}
}
},
"Microsoft.Extensions.Configuration.Abstractions/7.0.0": {
"dependencies": {
"Microsoft.Extensions.Primitives": "7.0.0"
},
"runtime": {
"lib/net6.0/Microsoft.Extensions.Configuration.Abstractions.dll": {
"assemblyVersion": "7.0.0.0",
"fileVersion": "7.0.22.51805"
}
}
},
"Microsoft.Extensions.Configuration.FileExtensions/7.0.0": {
"dependencies": {
"Microsoft.Extensions.Configuration": "7.0.0",
"Microsoft.Extensions.Configuration.Abstractions": "7.0.0",
"Microsoft.Extensions.FileProviders.Abstractions": "7.0.0",
"Microsoft.Extensions.FileProviders.Physical": "7.0.0",
"Microsoft.Extensions.Primitives": "7.0.0"
},
"runtime": {
"lib/net6.0/Microsoft.Extensions.Configuration.FileExtensions.dll": {
"assemblyVersion": "7.0.0.0",
"fileVersion": "7.0.22.51805"
}
}
},
"Microsoft.Extensions.Configuration.Json/7.0.0": {
"dependencies": {
"Microsoft.Extensions.Configuration": "7.0.0",
"Microsoft.Extensions.Configuration.Abstractions": "7.0.0",
"Microsoft.Extensions.Configuration.FileExtensions": "7.0.0",
"Microsoft.Extensions.FileProviders.Abstractions": "7.0.0",
"System.Text.Json": "7.0.0"
},
"runtime": {
"lib/net6.0/Microsoft.Extensions.Configuration.Json.dll": {
"assemblyVersion": "7.0.0.0",
"fileVersion": "7.0.22.51805"
}
}
},
"Microsoft.Extensions.FileProviders.Abstractions/7.0.0": {
"dependencies": {
"Microsoft.Extensions.Primitives": "7.0.0"
},
"runtime": {
"lib/net6.0/Microsoft.Extensions.FileProviders.Abstractions.dll": {
"assemblyVersion": "7.0.0.0",
"fileVersion": "7.0.22.51805"
}
}
},
"Microsoft.Extensions.FileProviders.Physical/7.0.0": {
"dependencies": {
"Microsoft.Extensions.FileProviders.Abstractions": "7.0.0",
"Microsoft.Extensions.FileSystemGlobbing": "7.0.0",
"Microsoft.Extensions.Primitives": "7.0.0"
},
"runtime": {
"lib/net6.0/Microsoft.Extensions.FileProviders.Physical.dll": {
"assemblyVersion": "7.0.0.0",
"fileVersion": "7.0.22.51805"
}
}
},
"Microsoft.Extensions.FileSystemGlobbing/7.0.0": {
"runtime": {
"lib/net6.0/Microsoft.Extensions.FileSystemGlobbing.dll": {
"assemblyVersion": "7.0.0.0",
"fileVersion": "7.0.22.51805"
}
}
},
"Microsoft.Extensions.Primitives/7.0.0": {
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
},
"runtime": {
"lib/net6.0/Microsoft.Extensions.Primitives.dll": {
"assemblyVersion": "7.0.0.0",
"fileVersion": "7.0.22.51805"
}
}
},
"Newtonsoft.Json/13.0.3": {
"runtime": {
"lib/net6.0/Newtonsoft.Json.dll": {
"assemblyVersion": "13.0.0.0",
"fileVersion": "13.0.3.27908"
}
}
},
"System.Diagnostics.DiagnosticSource/4.7.1": {},
"System.Runtime.CompilerServices.Unsafe/6.0.0": {},
"System.Text.Encodings.Web/7.0.0": {
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.0.0"
},
"runtime": {
"lib/net6.0/System.Text.Encodings.Web.dll": {
"assemblyVersion": "7.0.0.0",
"fileVersion": "7.0.22.51805"
}
},
"runtimeTargets": {
"runtimes/browser/lib/net6.0/System.Text.Encodings.Web.dll": {
"rid": "browser",
"assetType": "runtime",
"assemblyVersion": "7.0.0.0",
"fileVersion": "7.0.22.51805"
}
}
},
"System.Text.Json/7.0.0": {
"dependencies": {
"System.Runtime.CompilerServices.Unsafe": "6.0.0",
"System.Text.Encodings.Web": "7.0.0"
},
"runtime": {
"lib/net6.0/System.Text.Json.dll": {
"assemblyVersion": "7.0.0.0",
"fileVersion": "7.0.22.51805"
}
}
}
}
},
"libraries": {
"HybirdFrameworkCore/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Autofac/7.0.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-J9Iz0Q+YU3uf82i8Lee0NpQOlRYfwHxwVV26jdG3zH3LFE5Y9Rx97Mju7Nswwzh/C7kVJALkTL860Y7e+mcLaw==",
"path": "autofac/7.0.1",
"hashPath": "autofac.7.0.1.nupkg.sha512"
},
"Microsoft.Extensions.Configuration/7.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-tldQUBWt/xeH2K7/hMPPo5g8zuLc3Ro9I5d4o/XrxvxOCA2EZBtW7bCHHTc49fcBtvB8tLAb/Qsmfrq+2SJ4vA==",
"path": "microsoft.extensions.configuration/7.0.0",
"hashPath": "microsoft.extensions.configuration.7.0.0.nupkg.sha512"
},
"Microsoft.Extensions.Configuration.Abstractions/7.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-f34u2eaqIjNO9YLHBz8rozVZ+TcFiFs0F3r7nUJd7FRkVSxk8u4OpoK226mi49MwexHOR2ibP9MFvRUaLilcQQ==",
"path": "microsoft.extensions.configuration.abstractions/7.0.0",
"hashPath": "microsoft.extensions.configuration.abstractions.7.0.0.nupkg.sha512"
},
"Microsoft.Extensions.Configuration.FileExtensions/7.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-xk2lRJ1RDuqe57BmgvRPyCt6zyePKUmvT6iuXqiHR+/OIIgWVR8Ff5k2p6DwmqY8a17hx/OnrekEhziEIeQP6Q==",
"path": "microsoft.extensions.configuration.fileextensions/7.0.0",
"hashPath": "microsoft.extensions.configuration.fileextensions.7.0.0.nupkg.sha512"
},
"Microsoft.Extensions.Configuration.Json/7.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-LDNYe3uw76W35Jci+be4LDf2lkQZe0A7EEYQVChFbc509CpZ4Iupod8li4PUXPBhEUOFI/rlQNf5xkzJRQGvtA==",
"path": "microsoft.extensions.configuration.json/7.0.0",
"hashPath": "microsoft.extensions.configuration.json.7.0.0.nupkg.sha512"
},
"Microsoft.Extensions.FileProviders.Abstractions/7.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-NyawiW9ZT/liQb34k9YqBSNPLuuPkrjMgQZ24Y/xXX1RoiBkLUdPMaQTmxhZ5TYu8ZKZ9qayzil75JX95vGQUg==",
"path": "microsoft.extensions.fileproviders.abstractions/7.0.0",
"hashPath": "microsoft.extensions.fileproviders.abstractions.7.0.0.nupkg.sha512"
},
"Microsoft.Extensions.FileProviders.Physical/7.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-K8D2MTR+EtzkbZ8z80LrG7Ur64R7ZZdRLt1J5cgpc/pUWl0C6IkAUapPuK28oionHueCPELUqq0oYEvZfalNdg==",
"path": "microsoft.extensions.fileproviders.physical/7.0.0",
"hashPath": "microsoft.extensions.fileproviders.physical.7.0.0.nupkg.sha512"
},
"Microsoft.Extensions.FileSystemGlobbing/7.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-2jONjKHiF+E92ynz2ZFcr9OvxIw+rTGMPEH+UZGeHTEComVav93jQUWGkso8yWwVBcEJGcNcZAaqY01FFJcj7w==",
"path": "microsoft.extensions.filesystemglobbing/7.0.0",
"hashPath": "microsoft.extensions.filesystemglobbing.7.0.0.nupkg.sha512"
},
"Microsoft.Extensions.Primitives/7.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-um1KU5kxcRp3CNuI8o/GrZtD4AIOXDk+RLsytjZ9QPok3ttLUelLKpilVPuaFT3TFjOhSibUAso0odbOaCDj3Q==",
"path": "microsoft.extensions.primitives/7.0.0",
"hashPath": "microsoft.extensions.primitives.7.0.0.nupkg.sha512"
},
"Newtonsoft.Json/13.0.3": {
"type": "package",
"serviceable": true,
"sha512": "sha512-HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==",
"path": "newtonsoft.json/13.0.3",
"hashPath": "newtonsoft.json.13.0.3.nupkg.sha512"
},
"System.Diagnostics.DiagnosticSource/4.7.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-j81Lovt90PDAq8kLpaJfJKV/rWdWuEk6jfV+MBkee33vzYLEUsy4gXK8laa9V2nZlLM9VM9yA/OOQxxPEJKAMw==",
"path": "system.diagnostics.diagnosticsource/4.7.1",
"hashPath": "system.diagnostics.diagnosticsource.4.7.1.nupkg.sha512"
},
"System.Runtime.CompilerServices.Unsafe/6.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-/iUeP3tq1S0XdNNoMz5C9twLSrM/TH+qElHkXWaPvuNOt+99G75NrV0OS2EqHx5wMN7popYjpc8oTjC1y16DLg==",
"path": "system.runtime.compilerservices.unsafe/6.0.0",
"hashPath": "system.runtime.compilerservices.unsafe.6.0.0.nupkg.sha512"
},
"System.Text.Encodings.Web/7.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-OP6umVGxc0Z0MvZQBVigj4/U31Pw72ITihDWP9WiWDm+q5aoe0GaJivsfYGq53o6dxH7DcXWiCTl7+0o2CGdmg==",
"path": "system.text.encodings.web/7.0.0",
"hashPath": "system.text.encodings.web.7.0.0.nupkg.sha512"
},
"System.Text.Json/7.0.0": {
"type": "package",
"serviceable": true,
"sha512": "sha512-DaGSsVqKsn/ia6RG8frjwmJonfos0srquhw09TlT8KRw5I43E+4gs+/bZj4K0vShJ5H9imCuXupb4RmS+dBy3w==",
"path": "system.text.json/7.0.0",
"hashPath": "system.text.json.7.0.0.nupkg.sha512"
}
}
}

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HybirdFrameworkServices.Netty
{
internal class Class1
{
}
}

@ -0,0 +1,15 @@
using DotNetty.Buffers;
using DotNetty.Codecs;
using DotNetty.Transport.Channels;
using HybirdFrameworkCore.Autofac.Attribute;
namespace HybirdFrameworkServices.Netty;
[Scope("InstancePerDependency")]
public class Decoder : ByteToMessageDecoder
{
protected override void Decode(IChannelHandlerContext context, IByteBuffer input, List<object> output)
{
throw new NotImplementedException();
}
}

@ -0,0 +1,15 @@
using DotNetty.Buffers;
using DotNetty.Codecs;
using DotNetty.Transport.Channels;
using HybirdFrameworkCore.Autofac.Attribute;
namespace HybirdFrameworkServices.Netty;
[Scope("InstancePerDependency")]
public class Encoder : MessageToByteEncoder<byte[]>
{
protected override void Encode(IChannelHandlerContext context, byte[] message, IByteBuffer output)
{
output.WriteBytes(message);
}
}

@ -0,0 +1,18 @@
using DotNetty.Buffers;
using DotNetty.Transport.Channels;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
namespace HybirdFrameworkServices.Netty;
[Scope("InstancePerDependency")]
public class MsgHandler : ChannelHandlerAdapter
{
private readonly ILog Log = LogManager.GetLogger(typeof(MsgHandler));
public override void ChannelRead(IChannelHandlerContext ctx, object msg)
{
Log.Info($"{this.GetHashCode()} read from {ctx.Channel.RemoteAddress}");
ctx.WriteAndFlushAsync(Unpooled.WrappedBuffer(new byte[] { 1, 2, 3, 4, 5, 6, 7 }));
}
}

@ -1,79 +1,57 @@
using System.Collections.Concurrent;
using System.Threading.Channels;
using DotNetty.Buffers;
using Autofac;
using DotNetty.Handlers.Logging;
using DotNetty.Handlers.Timeout;
using DotNetty.Transport.Bootstrapping;
using DotNetty.Transport.Channels;
using DotNetty.Transport.Channels.Sockets;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkServices.System;
using log4net;
using Module.Socket.Tool;
namespace HybirdFrameworkServices.Netty
{
/// <summary>
/// netty server
/// </summary>
[Scope("SingleInstance")]
public class Server : IDisposable
{
private readonly ILog Log = LogManager.GetLogger(typeof(Server));
/// <summary>
/// 接受客户端的连接
/// </summary>
static MultithreadEventLoopGroup? bossGroup;
/// <summary>
/// 处理已经被接受的连接
/// </summary>
static MultithreadEventLoopGroup? workerGroup;
/// <summary>
/// Netty服务器的启动辅助类用于配置和启动服务器
/// </summary>
static ServerBootstrap? bootstrap;
/// <summary>
/// 是一个线程安全的字典用于存储与客户端连接的通道IChannel
/// </summary>
static ConcurrentDictionary<IChannelId, IChannel> _container = ServerListenerHandler.Container;
private int _port = 9000;
public Server(int port)
public Server()
{
_port = port;
IByteBuffer delimiter = Unpooled.CopiedBuffer(new byte[] { 0xAA, 0xF5 });
bossGroup = new MultithreadEventLoopGroup();
workerGroup = new MultithreadEventLoopGroup();
bootstrap = new ServerBootstrap();
bootstrap
.Group(bossGroup, workerGroup) // 设置主和工作线程组
.Channel<TcpServerSocketChannel>() // 设置通道模式为TcpSocket
.Option(ChannelOption.SoKeepalive, true) //设置TCP连接socket,保持连接
.Handler(new LoggingHandler())//添加log处理日志
.Option(ChannelOption.SoKeepalive, true) //保持连接
.Handler(new LoggingHandler())
.ChildHandler(new ActionChannelInitializer<ISocketChannel>(channel =>
{
var serverListenerHandler = new ServerListenerHandler();
IChannelPipeline pipeline = channel.Pipeline;
pipeline.AddLast(new LoggingHandler(""));
pipeline.AddLast(serverListenerHandler);
//pipeline.AddLast(new FixedLengthFrameDecoder(12)); //定长数据12byte
pipeline.AddLast(new IdleStateHandler(0, 0, 180));//检测空闲连接
//pipeline.AddLast(msgHandler);
//业务handler 这里是实际处理业务的Handler
pipeline.AddLast(new CustomFrameDecoder4(new IByteBuffer[] { delimiter }, false, false));
pipeline.AddLast("idleStateHandler", new IdleStateHandler(30, 0, 0)); // 触发读取超时
//pipeline.AddLast(new ReconnectHandler(this));
//pipeline.AddLast(new ClientHandler(this));
pipeline.AddLast(AppInfo.Container.Resolve<ServerListenerHandler>());
pipeline.AddLast(AppInfo.Container.Resolve<Encoder>()); //定长数据12byte
pipeline.AddLast(new IdleStateHandler(0, 0, 180));
pipeline.AddLast(AppInfo.Container.Resolve<MsgHandler>());
//业务handler 这里是实际处理业务的Handler
}));
Begin(_port);
}
private void Begin(int port)
public void Begin(int port)
{
_port = port;
Log.Info(" Start Listen");
@ -81,18 +59,19 @@ namespace HybirdFrameworkServices.Netty
Log.Info($"netty success listen {_port}");
}
public static void Send(byte[] bytes)
public void Send(byte[] bytes)
{
foreach (IChannel channel in _container.Values)
{
channel.WriteAndFlushAsync(bytes);
channel.Flush();
}
}
/// <summary>
/// ??netty 释放资源
/// ??netty
/// </summary>
public void Dispose()
{

@ -1,9 +1,11 @@
using System.Collections.Concurrent;
using DotNetty.Transport.Channels;
using HybirdFrameworkCore.Autofac.Attribute;
using log4net;
namespace HybirdFrameworkServices.Netty
{
[Scope("InstancePerDependency")]
public class ServerListenerHandler : ChannelHandlerAdapter
{
private readonly ILog Log = LogManager.GetLogger(typeof(ServerListenerHandler));
@ -25,7 +27,6 @@ namespace HybirdFrameworkServices.Netty
public override void ChannelRegistered(IChannelHandlerContext context)
{
base.ChannelRegistered(context);
Container[context.Channel.Id] = context.Channel;
SendClientIp();
Log.Info("register " + context.Channel);
}
@ -33,8 +34,6 @@ namespace HybirdFrameworkServices.Netty
public override void ChannelUnregistered(IChannelHandlerContext context)
{
base.ChannelUnregistered(context);
IChannel? o;
Container.Remove(context.Channel.Id, out o);
SendClientIp();
Log.Info("unregister " + context.Channel);
}
@ -42,12 +41,15 @@ namespace HybirdFrameworkServices.Netty
public override void ChannelActive(IChannelHandlerContext context)
{
base.ChannelActive(context);
Container[context.Channel.Id] = context.Channel;
Log.Info("active " + context.Channel);
}
public override void ChannelInactive(IChannelHandlerContext context)
{
base.ChannelInactive(context);
IChannel? o;
Container.Remove(context.Channel.Id, out o);
Log.Info("inactive " + context.Channel);
}
@ -67,5 +69,4 @@ namespace HybirdFrameworkServices.Netty
Log.Info("exception " + context.Channel);
}
}
}
}

@ -0,0 +1,8 @@
using Autofac;
namespace HybirdFrameworkServices.System;
public class AppInfo
{
public static IContainer Container { get; set; }
}

@ -1,12 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HybirdFrameworkServices.System
{
internal class Class1
{
}
}

File diff suppressed because it is too large Load Diff

@ -28,694 +28,46 @@ partial class Form1
/// </summary>
private void InitializeComponent()
{
button1 = new Button();
groupBox10 = new GroupBox();
btnCmd113 = new Button();
lstRecvFrameInfo = new ListBox();
groupBox16 = new GroupBox();
btnCmd1021 = new Button();
btnCmd1011 = new Button();
btnCmd1009 = new Button();
btnCmd1005 = new Button();
btnCmd1001 = new Button();
btnCmd1003 = new Button();
btnCmd1007 = new Button();
groupBox15 = new GroupBox();
btnCmd421 = new Button();
btnCmd401 = new Button();
groupBox14 = new GroupBox();
btnCmd301 = new Button();
btnCmd303 = new Button();
groupBox13 = new GroupBox();
btnCmd221 = new Button();
btnCmd209 = new Button();
btnCmd205 = new Button();
btnCmd201 = new Button();
btnCmd203 = new Button();
btnCmd207 = new Button();
groupBox7 = new GroupBox();
btnCmd1401 = new Button();
btnCmd1406 = new Button();
groupBox6 = new GroupBox();
btnCmd1301 = new Button();
groupBox4 = new GroupBox();
btnCmd1105 = new Button();
btnCmd1101 = new Button();
btnCmd1103 = new Button();
btnCmd1107 = new Button();
groupBox9 = new GroupBox();
groupBox3 = new GroupBox();
label3 = new Label();
txtDestAddr = new TextBox();
label2 = new Label();
txtChargePort = new TextBox();
BtnCloseConnect = new Button();
BtnChrg01Connect = new Button();
groupBox5 = new GroupBox();
lstSendFrameInfo = new ListBox();
groupBox8 = new GroupBox();
btnCmd7 = new Button();
btnCmd3 = new Button();
btnCmd1 = new Button();
btnCmd5 = new Button();
groupBox10.SuspendLayout();
groupBox16.SuspendLayout();
groupBox15.SuspendLayout();
groupBox14.SuspendLayout();
groupBox13.SuspendLayout();
groupBox7.SuspendLayout();
groupBox6.SuspendLayout();
groupBox4.SuspendLayout();
groupBox9.SuspendLayout();
groupBox3.SuspendLayout();
groupBox5.SuspendLayout();
groupBox8.SuspendLayout();
SuspendLayout();
//
// button1
//
button1.Location = new Point(1087, -2);
button1.Margin = new Padding(2, 1, 2, 1);
button1.Name = "button1";
button1.Size = new Size(100, 28);
button1.TabIndex = 0;
button1.Text = "button1";
button1.UseVisualStyleBackColor = true;
button1.Click += button1_Click;
//
// groupBox10
//
groupBox10.Controls.Add(btnCmd113);
groupBox10.Location = new Point(599, 139);
groupBox10.Name = "groupBox10";
groupBox10.Size = new Size(136, 65);
groupBox10.TabIndex = 169;
groupBox10.TabStop = false;
groupBox10.Text = "答充电桩上报充电";
//
// btnCmd113
//
btnCmd113.Location = new Point(6, 17);
btnCmd113.Name = "btnCmd113";
btnCmd113.Size = new Size(115, 37);
btnCmd113.TabIndex = 136;
btnCmd113.Text = "113";
btnCmd113.UseVisualStyleBackColor = true;
btnCmd113.Click += btnCmd113_Click;
//
// lstRecvFrameInfo
//
lstRecvFrameInfo.Anchor = AnchorStyles.None;
lstRecvFrameInfo.FormattingEnabled = true;
lstRecvFrameInfo.ItemHeight = 20;
lstRecvFrameInfo.Location = new Point(12, 704);
lstRecvFrameInfo.Margin = new Padding(5);
lstRecvFrameInfo.Name = "lstRecvFrameInfo";
lstRecvFrameInfo.Size = new Size(1130, 124);
lstRecvFrameInfo.TabIndex = 158;
//
// groupBox16
//
groupBox16.Controls.Add(btnCmd1021);
groupBox16.Controls.Add(btnCmd1011);
groupBox16.Controls.Add(btnCmd1009);
groupBox16.Controls.Add(btnCmd1005);
groupBox16.Controls.Add(btnCmd1001);
groupBox16.Controls.Add(btnCmd1003);
groupBox16.Controls.Add(btnCmd1007);
groupBox16.Location = new Point(17, 316);
groupBox16.Name = "groupBox16";
groupBox16.Size = new Size(1007, 75);
groupBox16.TabIndex = 166;
groupBox16.TabStop = false;
groupBox16.Text = "升级命令";
//
// btnCmd1021
//
btnCmd1021.Location = new Point(870, 26);
btnCmd1021.Name = "btnCmd1021";
btnCmd1021.Size = new Size(115, 37);
btnCmd1021.TabIndex = 124;
btnCmd1021.Text = "1021";
btnCmd1021.UseVisualStyleBackColor = true;
btnCmd1021.Click += btnCmd1021_Click;
//
// btnCmd1011
//
btnCmd1011.Location = new Point(726, 26);
btnCmd1011.Name = "btnCmd1011";
btnCmd1011.Size = new Size(115, 37);
btnCmd1011.TabIndex = 123;
btnCmd1011.Text = "1011";
btnCmd1011.UseVisualStyleBackColor = true;
btnCmd1011.Click += btnCmd1011_Click;
//
// btnCmd1009
//
btnCmd1009.Location = new Point(582, 26);
btnCmd1009.Name = "btnCmd1009";
btnCmd1009.Size = new Size(115, 37);
btnCmd1009.TabIndex = 122;
btnCmd1009.Text = "1009";
btnCmd1009.UseVisualStyleBackColor = true;
btnCmd1009.Click += btnCmd1009_Click;
//
// btnCmd1005
//
btnCmd1005.Location = new Point(294, 26);
btnCmd1005.Name = "btnCmd1005";
btnCmd1005.Size = new Size(115, 37);
btnCmd1005.TabIndex = 120;
btnCmd1005.Text = "1005";
btnCmd1005.UseVisualStyleBackColor = true;
btnCmd1005.Click += btnCmd1005_Click;
//
// btnCmd1001
//
btnCmd1001.Location = new Point(6, 26);
btnCmd1001.Name = "btnCmd1001";
btnCmd1001.Size = new Size(115, 37);
btnCmd1001.TabIndex = 118;
btnCmd1001.Text = "1001";
btnCmd1001.UseVisualStyleBackColor = true;
btnCmd1001.Click += btnCmd1001_Click;
//
// btnCmd1003
//
btnCmd1003.Location = new Point(147, 26);
btnCmd1003.Name = "btnCmd1003";
btnCmd1003.Size = new Size(115, 37);
btnCmd1003.TabIndex = 119;
btnCmd1003.Text = "1003";
btnCmd1003.UseVisualStyleBackColor = true;
btnCmd1003.Click += btnCmd1003_Click;
//
// btnCmd1007
//
btnCmd1007.Location = new Point(438, 26);
btnCmd1007.Name = "btnCmd1007";
btnCmd1007.Size = new Size(115, 37);
btnCmd1007.TabIndex = 121;
btnCmd1007.Text = "1007";
btnCmd1007.UseVisualStyleBackColor = true;
btnCmd1007.Click += btnCmd1007_Click;
//
// groupBox15
//
groupBox15.Controls.Add(btnCmd421);
groupBox15.Controls.Add(btnCmd401);
groupBox15.Location = new Point(886, 139);
groupBox15.Name = "groupBox15";
groupBox15.Size = new Size(271, 75);
groupBox15.TabIndex = 167;
groupBox15.TabStop = false;
groupBox15.Text = "历史数据";
//
// btnCmd421
//
btnCmd421.Location = new Point(140, 26);
btnCmd421.Name = "btnCmd421";
btnCmd421.Size = new Size(115, 37);
btnCmd421.TabIndex = 123;
btnCmd421.Text = "421";
btnCmd421.UseVisualStyleBackColor = true;
btnCmd421.Click += btnCmd421_Click;
//
// btnCmd401
//
btnCmd401.Location = new Point(6, 26);
btnCmd401.Name = "btnCmd401";
btnCmd401.Size = new Size(115, 37);
btnCmd401.TabIndex = 122;
btnCmd401.Text = "401";
btnCmd401.UseVisualStyleBackColor = true;
btnCmd401.Click += btnCmd401_Click;
//
// groupBox14
//
groupBox14.Controls.Add(btnCmd301);
groupBox14.Controls.Add(btnCmd303);
groupBox14.Location = new Point(886, 235);
groupBox14.Name = "groupBox14";
groupBox14.Size = new Size(273, 75);
groupBox14.TabIndex = 168;
groupBox14.TabStop = false;
groupBox14.Text = "直流充电桩BMS信息数据预留";
//
// btnCmd301
//
btnCmd301.Location = new Point(6, 26);
btnCmd301.Name = "btnCmd301";
btnCmd301.Size = new Size(115, 37);
btnCmd301.TabIndex = 118;
btnCmd301.Text = "301";
btnCmd301.UseVisualStyleBackColor = true;
btnCmd301.Click += btnCmd301_Click;
//
// btnCmd303
//
btnCmd303.Location = new Point(140, 26);
btnCmd303.Name = "btnCmd303";
btnCmd303.Size = new Size(115, 37);
btnCmd303.TabIndex = 119;
btnCmd303.Text = "303";
btnCmd303.UseVisualStyleBackColor = true;
btnCmd303.Click += btnCmd303_Click;
//
// groupBox13
//
groupBox13.Controls.Add(btnCmd221);
groupBox13.Controls.Add(btnCmd209);
groupBox13.Controls.Add(btnCmd205);
groupBox13.Controls.Add(btnCmd201);
groupBox13.Controls.Add(btnCmd203);
groupBox13.Controls.Add(btnCmd207);
groupBox13.Location = new Point(17, 235);
groupBox13.Name = "groupBox13";
groupBox13.Size = new Size(858, 75);
groupBox13.TabIndex = 163;
groupBox13.TabStop = false;
groupBox13.Text = "充电信息数据";
//
// btnCmd221
//
btnCmd221.Location = new Point(147, 26);
btnCmd221.Name = "btnCmd221";
btnCmd221.Size = new Size(115, 37);
btnCmd221.TabIndex = 123;
btnCmd221.Text = "221";
btnCmd221.UseVisualStyleBackColor = true;
btnCmd221.Click += btnCmd221_Click;
//
// btnCmd209
//
btnCmd209.Location = new Point(726, 26);
btnCmd209.Name = "btnCmd209";
btnCmd209.Size = new Size(115, 37);
btnCmd209.TabIndex = 122;
btnCmd209.Text = "209";
btnCmd209.UseVisualStyleBackColor = true;
btnCmd209.Click += btnCmd209_Click;
//
// btnCmd205
//
btnCmd205.Location = new Point(438, 26);
btnCmd205.Name = "btnCmd205";
btnCmd205.Size = new Size(115, 37);
btnCmd205.TabIndex = 120;
btnCmd205.Text = "205";
btnCmd205.UseVisualStyleBackColor = true;
btnCmd205.Click += btnCmd205_Click;
//
// btnCmd201
//
btnCmd201.Location = new Point(6, 26);
btnCmd201.Name = "btnCmd201";
btnCmd201.Size = new Size(115, 37);
btnCmd201.TabIndex = 118;
btnCmd201.Text = "201";
btnCmd201.UseVisualStyleBackColor = true;
btnCmd201.Click += btnCmd201_Click;
//
// btnCmd203
//
btnCmd203.Location = new Point(294, 26);
btnCmd203.Name = "btnCmd203";
btnCmd203.Size = new Size(115, 37);
btnCmd203.TabIndex = 119;
btnCmd203.Text = "203";
btnCmd203.UseVisualStyleBackColor = true;
btnCmd203.Click += btnCmd203_Click;
//
// btnCmd207
//
btnCmd207.Location = new Point(582, 26);
btnCmd207.Name = "btnCmd207";
btnCmd207.Size = new Size(115, 37);
btnCmd207.TabIndex = 121;
btnCmd207.Text = "207";
btnCmd207.UseVisualStyleBackColor = true;
btnCmd207.Click += btnCmd207_Click;
//
// groupBox7
//
groupBox7.Controls.Add(btnCmd1401);
groupBox7.Controls.Add(btnCmd1406);
groupBox7.Location = new Point(743, 404);
groupBox7.Name = "groupBox7";
groupBox7.Size = new Size(281, 75);
groupBox7.TabIndex = 164;
groupBox7.TabStop = false;
groupBox7.Text = "FTP远程升级、FTP日志上传";
//
// btnCmd1401
//
btnCmd1401.Location = new Point(6, 26);
btnCmd1401.Name = "btnCmd1401";
btnCmd1401.Size = new Size(115, 37);
btnCmd1401.TabIndex = 123;
btnCmd1401.Text = "1401";
btnCmd1401.UseVisualStyleBackColor = true;
btnCmd1401.Click += btnCmd1401_Click;
//
// btnCmd1406
//
btnCmd1406.Location = new Point(144, 26);
btnCmd1406.Name = "btnCmd1406";
btnCmd1406.Size = new Size(115, 37);
btnCmd1406.TabIndex = 124;
btnCmd1406.Text = "1406";
btnCmd1406.UseVisualStyleBackColor = true;
btnCmd1406.Click += btnCmd1406_Click;
//
// groupBox6
//
groupBox6.Controls.Add(btnCmd1301);
groupBox6.Location = new Point(590, 404);
groupBox6.Name = "groupBox6";
groupBox6.Size = new Size(130, 75);
groupBox6.TabIndex = 165;
groupBox6.TabStop = false;
groupBox6.Text = "白名单报文";
//
// btnCmd1301
//
btnCmd1301.Location = new Point(6, 26);
btnCmd1301.Name = "btnCmd1301";
btnCmd1301.Size = new Size(115, 37);
btnCmd1301.TabIndex = 122;
btnCmd1301.Text = "1301";
btnCmd1301.UseVisualStyleBackColor = true;
btnCmd1301.Click += btnCmd1301_Click;
//
// groupBox4
//
groupBox4.Controls.Add(btnCmd1105);
groupBox4.Controls.Add(btnCmd1101);
groupBox4.Controls.Add(btnCmd1103);
groupBox4.Controls.Add(btnCmd1107);
groupBox4.Location = new Point(15, 404);
groupBox4.Name = "groupBox4";
groupBox4.Size = new Size(562, 75);
groupBox4.TabIndex = 162;
groupBox4.TabStop = false;
groupBox4.Text = "与计费策略相关的指令";
//
// btnCmd1105
//
btnCmd1105.Location = new Point(294, 26);
btnCmd1105.Name = "btnCmd1105";
btnCmd1105.Size = new Size(115, 37);
btnCmd1105.TabIndex = 120;
btnCmd1105.Text = "1105";
btnCmd1105.UseVisualStyleBackColor = true;
btnCmd1105.Click += btnCmd1105_Click;
//
// btnCmd1101
//
btnCmd1101.Location = new Point(6, 26);
btnCmd1101.Name = "btnCmd1101";
btnCmd1101.Size = new Size(115, 37);
btnCmd1101.TabIndex = 118;
btnCmd1101.Text = "1101";
btnCmd1101.UseVisualStyleBackColor = true;
btnCmd1101.Click += btnCmd1101_Click;
//
// btnCmd1103
//
btnCmd1103.Location = new Point(149, 26);
btnCmd1103.Name = "btnCmd1103";
btnCmd1103.Size = new Size(115, 37);
btnCmd1103.TabIndex = 119;
btnCmd1103.Text = "1103";
btnCmd1103.UseVisualStyleBackColor = true;
btnCmd1103.Click += btnCmd1103_Click;
//
// btnCmd1107
//
btnCmd1107.Location = new Point(439, 26);
btnCmd1107.Name = "btnCmd1107";
btnCmd1107.Size = new Size(115, 37);
btnCmd1107.TabIndex = 121;
btnCmd1107.Text = "1107";
btnCmd1107.UseVisualStyleBackColor = true;
btnCmd1107.Click += btnCmd1107_Click;
//
// groupBox9
//
groupBox9.Controls.Add(groupBox3);
groupBox9.Location = new Point(14, 35);
groupBox9.Name = "groupBox9";
groupBox9.Size = new Size(1161, 98);
groupBox9.TabIndex = 161;
groupBox9.TabStop = false;
groupBox9.Text = "站控发送指令";
//
// groupBox3
//
groupBox3.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
groupBox3.Controls.Add(label3);
groupBox3.Controls.Add(txtDestAddr);
groupBox3.Controls.Add(label2);
groupBox3.Controls.Add(txtChargePort);
groupBox3.Controls.Add(BtnCloseConnect);
groupBox3.Controls.Add(BtnChrg01Connect);
groupBox3.Font = new Font("微软雅黑", 9F, FontStyle.Regular, GraphicsUnit.Point);
groupBox3.Location = new Point(12, 27);
groupBox3.Margin = new Padding(5);
groupBox3.Name = "groupBox3";
groupBox3.Padding = new Padding(5);
groupBox3.Size = new Size(685, 63);
groupBox3.TabIndex = 80;
groupBox3.TabStop = false;
groupBox3.Text = "充电机连接";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(152, 35);
label3.Name = "label3";
label3.Size = new Size(94, 20);
label3.TabIndex = 20;
label3.Text = "DestAddr";
//
// txtDestAddr
//
txtDestAddr.Location = new Point(246, 24);
txtDestAddr.Name = "txtDestAddr";
txtDestAddr.Size = new Size(130, 27);
txtDestAddr.TabIndex = 19;
txtDestAddr.Text = "1";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(15, 33);
label2.Name = "label2";
label2.Size = new Size(55, 20);
label2.TabIndex = 18;
label2.Text = "Port";
//
// txtChargePort
//
txtChargePort.Location = new Point(74, 27);
txtChargePort.Name = "txtChargePort";
txtChargePort.Size = new Size(72, 27);
txtChargePort.TabIndex = 17;
txtChargePort.Text = "502";
//
// BtnCloseConnect
//
BtnCloseConnect.Location = new Point(528, 16);
BtnCloseConnect.Margin = new Padding(5);
BtnCloseConnect.Name = "BtnCloseConnect";
BtnCloseConnect.Size = new Size(130, 37);
BtnCloseConnect.TabIndex = 14;
BtnCloseConnect.Text = "关闭服务";
BtnCloseConnect.UseVisualStyleBackColor = true;
//
// BtnChrg01Connect
//
BtnChrg01Connect.Location = new Point(384, 16);
BtnChrg01Connect.Margin = new Padding(5);
BtnChrg01Connect.Name = "BtnChrg01Connect";
BtnChrg01Connect.Size = new Size(130, 37);
BtnChrg01Connect.TabIndex = 8;
BtnChrg01Connect.Text = "启动服务";
BtnChrg01Connect.UseVisualStyleBackColor = true;
BtnChrg01Connect.Click += BtnChrg01Connect_Click;
//
// groupBox5
//
groupBox5.Controls.Add(lstSendFrameInfo);
groupBox5.Font = new Font("微软雅黑", 9F, FontStyle.Regular, GraphicsUnit.Point);
groupBox5.Location = new Point(12, 500);
groupBox5.Margin = new Padding(5);
groupBox5.Name = "groupBox5";
groupBox5.Padding = new Padding(5);
groupBox5.Size = new Size(1154, 172);
groupBox5.TabIndex = 159;
groupBox5.TabStop = false;
groupBox5.Text = "发送数据帧信息";
//
// lstSendFrameInfo
//
lstSendFrameInfo.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
lstSendFrameInfo.FormattingEnabled = true;
lstSendFrameInfo.ItemHeight = 20;
lstSendFrameInfo.Location = new Point(16, 32);
lstSendFrameInfo.Margin = new Padding(5);
lstSendFrameInfo.Name = "lstSendFrameInfo";
lstSendFrameInfo.Size = new Size(1113, 124);
lstSendFrameInfo.TabIndex = 73;
//
// groupBox8
//
groupBox8.Controls.Add(btnCmd7);
groupBox8.Controls.Add(btnCmd3);
groupBox8.Controls.Add(btnCmd1);
groupBox8.Controls.Add(btnCmd5);
groupBox8.Location = new Point(15, 139);
groupBox8.Name = "groupBox8";
groupBox8.Size = new Size(555, 70);
groupBox8.TabIndex = 160;
groupBox8.TabStop = false;
groupBox8.Text = "设置/查询工作参数和命令";
//
// btnCmd7
//
btnCmd7.Location = new Point(440, 19);
btnCmd7.Name = "btnCmd7";
btnCmd7.Size = new Size(115, 37);
btnCmd7.TabIndex = 123;
btnCmd7.Text = "7";
btnCmd7.UseVisualStyleBackColor = true;
btnCmd7.Click += btnCmd7_Click;
//
// btnCmd3
//
btnCmd3.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
btnCmd3.Location = new Point(149, 17);
btnCmd3.Margin = new Padding(5);
btnCmd3.Name = "btnCmd3";
btnCmd3.Size = new Size(115, 37);
btnCmd3.TabIndex = 91;
btnCmd3.Text = "3";
btnCmd3.UseVisualStyleBackColor = true;
btnCmd3.Click += btnCmd3_Click;
//
// btnCmd1
//
btnCmd1.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
btnCmd1.Location = new Point(8, 17);
btnCmd1.Margin = new Padding(5);
btnCmd1.Name = "btnCmd1";
btnCmd1.Size = new Size(115, 37);
btnCmd1.TabIndex = 90;
btnCmd1.Text = "1";
btnCmd1.UseVisualStyleBackColor = true;
btnCmd1.Click += btnCmd1_Click;
//
// btnCmd5
//
btnCmd5.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point);
btnCmd5.Location = new Point(296, 17);
btnCmd5.Margin = new Padding(5);
btnCmd5.Name = "btnCmd5";
btnCmd5.Size = new Size(115, 37);
btnCmd5.TabIndex = 92;
btnCmd5.Text = "5";
btnCmd5.UseVisualStyleBackColor = true;
btnCmd5.Click += btnCmd5_Click;
//
// Form1
//
AutoScaleDimensions = new SizeF(9F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1186, 863);
Controls.Add(groupBox10);
Controls.Add(lstRecvFrameInfo);
Controls.Add(groupBox16);
Controls.Add(groupBox15);
Controls.Add(groupBox14);
Controls.Add(groupBox13);
Controls.Add(groupBox7);
Controls.Add(groupBox6);
Controls.Add(groupBox4);
Controls.Add(groupBox9);
Controls.Add(groupBox5);
Controls.Add(groupBox8);
Controls.Add(button1);
Margin = new Padding(2, 1, 2, 1);
Name = "Form1";
Text = "Form1";
Load += Form1_Load;
groupBox10.ResumeLayout(false);
groupBox16.ResumeLayout(false);
groupBox15.ResumeLayout(false);
groupBox14.ResumeLayout(false);
groupBox13.ResumeLayout(false);
groupBox7.ResumeLayout(false);
groupBox6.ResumeLayout(false);
groupBox4.ResumeLayout(false);
groupBox9.ResumeLayout(false);
groupBox3.ResumeLayout(false);
groupBox3.PerformLayout();
groupBox5.ResumeLayout(false);
groupBox8.ResumeLayout(false);
ResumeLayout(false);
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(332, 33);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(188, 58);
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button1
//
this.button2.Location = new System.Drawing.Point(332, 100);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(188, 58);
this.button2.TabIndex = 1;
this.button2.Text = "button2";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(17F, 41F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1538, 752);
this.Controls.Add(this.button1);
this.Controls.Add(this.button2);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
private Button button1;
private GroupBox groupBox10;
private Button btnCmd113;
private ListBox lstRecvFrameInfo;
private GroupBox groupBox16;
private Button btnCmd1021;
private Button btnCmd1011;
private Button btnCmd1009;
private Button btnCmd1005;
private Button btnCmd1001;
private Button btnCmd1003;
private Button btnCmd1007;
private GroupBox groupBox15;
private Button btnCmd421;
private Button btnCmd401;
private GroupBox groupBox14;
private Button btnCmd301;
private Button btnCmd303;
private GroupBox groupBox13;
private Button btnCmd221;
private Button btnCmd209;
private Button btnCmd205;
private Button btnCmd201;
private Button btnCmd203;
private Button btnCmd207;
private GroupBox groupBox7;
private Button btnCmd1401;
private Button btnCmd1406;
private GroupBox groupBox6;
private Button btnCmd1301;
private GroupBox groupBox4;
private Button btnCmd1105;
private Button btnCmd1101;
private Button btnCmd1103;
private Button btnCmd1107;
private GroupBox groupBox9;
private GroupBox groupBox3;
private Label label3;
private TextBox txtDestAddr;
private Label label2;
private TextBox txtChargePort;
private Button BtnCloseConnect;
private Button BtnChrg01Connect;
private GroupBox groupBox5;
private ListBox lstSendFrameInfo;
private GroupBox groupBox8;
private Button btnCmd7;
private Button btnCmd3;
private Button btnCmd1;
private Button btnCmd5;
private Button button2;
}

@ -1,18 +1,15 @@
using HybirdFrameworkEntity;
using Autofac;
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;
@ -21,394 +18,13 @@ public partial class Form1 : Form
private void button1_Click(object sender, EventArgs e)
{
_log.Info("this is a test");
MessageBox.Show(_sysUserServices.Query().Count.ToString());
}
private void Form1_Load(object sender, EventArgs e)
{
}
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;//类型 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);
}
}
#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);
}
Server server = AppInfo.Container.Resolve<Server>();
server.Begin(9000);
}
private void btnCmd301_Click(object sender, EventArgs e)
private void button2_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);
}
Server server = AppInfo.Container.Resolve<Server>();
server.Send(new byte[] { 1, 2, 3, 4, 9, 5, 6, 6, 7 });
}
}

@ -1,10 +1,11 @@
using Autofac;
using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Configuration;
using HybirdFrameworkServices.System;
using log4net.Config;
using SqlSugar;
using SqlSugar.IOC;
namespace WinFormStarter
{
}
@ -23,7 +24,7 @@ static class Program
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
log4net.Config.XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + @"\log4net.xml"));
XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + @"\log4net.xml"));
Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException);
// 创建容器
var builder = new ContainerBuilder();
@ -49,6 +50,7 @@ static class Program
builder.RegisterModule(new AutofacModuleRegister());
// 构建容器
Container = builder.Build();
AppInfo.Container = Container;
Application.Run(Container.ResolveNamed<Form>("Form1"));
}

@ -1,18 +0,0 @@
{
"ConnectionStrings": {
"DbType": "MySql", //SqlServer,MySql
"SqlConnection": "server=106.12.36.89;Port=3306;Database=test;Uid=remote_user;Pwd=Rszn123;Charset=utf8;"
},
"Update": {
"AutoUpdate": "false",
"Version": "1.1.0.1",
"Url": "http://121.4.95.243:8090/Updates/AutoUpdaterStarter.xml"//
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
}
}

@ -1,5 +0,0 @@
2024-04-02 13:30:58,721 INFO 1 WinFormStarter.Form1 - this is a test
2024-04-02 17:01:47,535 INFO 1 HybirdFrameworkServices.Netty.Server - Start Listen
2024-04-02 17:01:47,738 INFO 1 HybirdFrameworkServices.Netty.Server - netty success listen 502
2024-04-02 17:02:01,954 INFO SingleThreadEventExecutor worker HybirdFrameworkServices.Netty.ServerListenerHandler - register [id: 0x2c2f33c6, [::ffff:127.0.0.1]:1000 => [::ffff:127.0.0.1]:502]
2024-04-02 17:02:01,957 INFO SingleThreadEventExecutor worker HybirdFrameworkServices.Netty.ServerListenerHandler - active [id: 0x2c2f33c6, [::ffff:127.0.0.1]:1000 => [::ffff:127.0.0.1]:502]
Loading…
Cancel
Save