新疆站现场调试更改

master
CZ 2 months ago
parent aa0543ac6b
commit 515109ef78

@ -1,5 +0,0 @@
namespace Repository.System;
internal class Class1
{
}

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?><configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.DependencyInjection.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Logging.Abstractions" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="adb9793829ddae60" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

@ -0,0 +1,26 @@
using System;
using System.IO;
using DotNetty.Handlers.Logging;
using log4net.Config;
namespace RfidInfo
{
internal class Program
{
public static void Main(string[] args)
{
XmlConfigurator.ConfigureAndWatch(new FileInfo(AppDomain.CurrentDomain.BaseDirectory + @"\log4net.xml"));
RfidServer rfidServer = new RfidServer()
{
LogLevel = LogLevel.TRACE
};
rfidServer.Start(5037);
string? readLine = Console.In.ReadLine();
while (true)
{
readLine= Console.In.ReadLine();
}
}
}
}

@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RfidInfo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RfidInfo")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5B73AD86-5EB9-4C1C-8906-D820C9299C43")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -0,0 +1,160 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')"/>
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5B73AD86-5EB9-4C1C-8906-D820C9299C43}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RfidInfo</RootNamespace>
<AssemblyName>RfidInfo</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<LangVersion>8</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="DotNetty.Buffers, Version=0.7.5.0, Culture=neutral, PublicKeyToken=bc13ca065fa06c29, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetty.Buffers.0.7.5\lib\net472\DotNetty.Buffers.dll</HintPath>
</Reference>
<Reference Include="DotNetty.Codecs, Version=0.7.5.0, Culture=neutral, PublicKeyToken=bc13ca065fa06c29, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetty.Codecs.0.7.5\lib\net472\DotNetty.Codecs.dll</HintPath>
</Reference>
<Reference Include="DotNetty.Codecs.Http, Version=0.7.5.0, Culture=neutral, PublicKeyToken=bc13ca065fa06c29, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetty.Codecs.Http.0.7.5\lib\net472\DotNetty.Codecs.Http.dll</HintPath>
</Reference>
<Reference Include="DotNetty.Common, Version=0.7.5.0, Culture=neutral, PublicKeyToken=bc13ca065fa06c29, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetty.Common.0.7.5\lib\net472\DotNetty.Common.dll</HintPath>
</Reference>
<Reference Include="DotNetty.Handlers, Version=0.7.5.0, Culture=neutral, PublicKeyToken=bc13ca065fa06c29, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetty.Handlers.0.7.5\lib\net472\DotNetty.Handlers.dll</HintPath>
</Reference>
<Reference Include="DotNetty.Transport, Version=0.7.5.0, Culture=neutral, PublicKeyToken=bc13ca065fa06c29, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetty.Transport.0.7.5\lib\net472\DotNetty.Transport.dll</HintPath>
</Reference>
<Reference Include="log4net, Version=2.0.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.15\lib\net45\log4net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.5.0.0\lib\net461\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Configuration, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Configuration.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Configuration.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Configuration.Abstractions.2.2.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Configuration.Binder, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Configuration.Binder.2.2.4\lib\netstandard2.0\Microsoft.Extensions.Configuration.Binder.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.5.0.0\lib\net461\Microsoft.Extensions.DependencyInjection.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.5.0.0\lib\net461\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Logging, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Logging.5.0.0\lib\net461\Microsoft.Extensions.Logging.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Logging.Abstractions.5.0.0\lib\net461\Microsoft.Extensions.Logging.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Logging.Log4Net.AspNetCore, Version=8.0.0.0, Culture=neutral, PublicKeyToken=5d1104efbd0e675d, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Logging.Log4Net.AspNetCore.8.0.0\lib\netstandard2.0\Microsoft.Extensions.Logging.Log4Net.AspNetCore.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Options, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Options.5.0.0\lib\net461\Microsoft.Extensions.Options.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.Primitives, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.Primitives.5.0.0\lib\net461\Microsoft.Extensions.Primitives.dll</HintPath>
</Reference>
<Reference Include="mscorlib" />
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="ReaderAPI">
<HintPath>..\..\RFID\通用读写开发包20240525\通用读写开发包\通用读写器开发包(C#)V.2.0.10\示例代码\示例代码\RFIDTest_GRP\bin\Debug\ReaderAPI.dll</HintPath>
</Reference>
<Reference Include="System"/>
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
</Reference>
<Reference Include="System.Collections.Immutable, Version=1.2.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll</HintPath>
</Reference>
<Reference Include="System.Configuration" />
<Reference Include="System.Core"/>
<Reference Include="System.Data"/>
<Reference Include="System.Diagnostics.DiagnosticSource, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Diagnostics.DiagnosticSource.5.0.0\lib\net46\System.Diagnostics.DiagnosticSource.dll</HintPath>
</Reference>
<Reference Include="System.Memory, Version=4.0.1.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll</HintPath>
</Reference>
<Reference Include="System.Numerics" />
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
</Reference>
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.5.0.0\lib\net45\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Xml"/>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs"/>
<Compile Include="RfidInfo\Common.cs" />
<Compile Include="RfidInfo\HttpHandler.cs" />
<Compile Include="RfidInfo\RfidMgr.cs" />
<Compile Include="RfidInfo\RfidReadModel.cs" />
<Compile Include="RfidInfo\RfidServer.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Content Include="log4net.config">
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

@ -0,0 +1,8 @@
namespace RfidInfo
{
public class Common
{
public static object LockRxdTagData = new object();
public static ReaderAPI.EntityClass.ScanTagParameter ScanParam = new ReaderAPI.EntityClass.ScanTagParameter();
}
}

@ -0,0 +1,102 @@
using System;
using System.Text;
using DotNetty.Buffers;
using DotNetty.Codecs.Http;
using DotNetty.Common.Utilities;
using DotNetty.Transport.Channels;
using log4net;
using Newtonsoft.Json;
namespace RfidInfo
{
public class HttpHandler : SimpleChannelInboundHandler<DefaultHttpRequest>
{
private static readonly ILog Log = LogManager.GetLogger(typeof(HttpHandler));
static readonly AsciiString TypePlain = AsciiString.Cached("text/plain; charset=utf-8");
static readonly AsciiString TypeJson = AsciiString.Cached("application/json; charset=utf-8");
static readonly AsciiString OkLength = AsciiString.Cached(Encoding.UTF8.GetBytes("true").Length.ToString());
static readonly AsciiString FailLength = AsciiString.Cached(Encoding.UTF8.GetBytes("false").Length.ToString());
static readonly AsciiString ServerName = AsciiString.Cached("Netty");
static readonly AsciiString ContentTypeEntity = HttpHeaderNames.ContentType;
static readonly AsciiString DateEntity = HttpHeaderNames.Date;
static readonly AsciiString ContentLengthEntity = HttpHeaderNames.ContentLength;
static readonly AsciiString ServerEntity = HttpHeaderNames.Server;
protected override void ChannelRead0(IChannelHandlerContext ctx, DefaultHttpRequest req)
{
Log.Info($"{req.Uri}, {req}");
DefaultFullHttpResponse response = null;
switch (req.Uri)
{
case "/Api/ReadRfidData":
RfidReadModel? model = null;
if ((DateTime.Now - RfidMgr.date).TotalSeconds <= 10)
{
model = RfidMgr.ReadRifd();
}
if (model != null)
{
byte[] json = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(model));
this.WriteResponse(ctx, Unpooled.WrappedBuffer(json), TypeJson,
new AsciiString(json.Length.ToString()));
}
else
{
response = new DefaultFullHttpResponse(HttpVersion.Http11, HttpResponseStatus.NoContent,
Unpooled.Empty, false);
ctx.WriteAndFlushAsync(response);
}
break;
case "/Api/BeginRead"://开始读
bool beginRead = RfidMgr.BeginRead();
this.WriteResponse(ctx, Unpooled.WrappedBuffer(Encoding.UTF8.GetBytes(beginRead.ToString())),
TypePlain, beginRead ? OkLength : FailLength);
break;
case "/Api/StopRead"://停读
var stopRead = RfidMgr.StopRead();
this.WriteResponse(ctx, Unpooled.WrappedBuffer(Encoding.UTF8.GetBytes(stopRead.ToString())),
TypePlain, stopRead ? OkLength : FailLength);
break;
case "/Api/Open"://连接
var connected = RfidMgr.Connect();
this.WriteResponse(ctx, Unpooled.WrappedBuffer(Encoding.UTF8.GetBytes(connected.ToString())),
TypePlain, connected ? OkLength : FailLength);
break;
case "/Api/Close"://断开
var closeRfid = RfidMgr.CloseRfid();
this.WriteResponse(ctx, Unpooled.WrappedBuffer(Encoding.UTF8.GetBytes(closeRfid.ToString())),
TypePlain, closeRfid ? OkLength : FailLength);
break;
default:
response = new DefaultFullHttpResponse(HttpVersion.Http11, HttpResponseStatus.NotFound,
Unpooled.Empty, false);
ctx.WriteAndFlushAsync(response);
break;
}
}
void WriteResponse(IChannelHandlerContext ctx, IByteBuffer buf, ICharSequence contentType,
ICharSequence contentLength)
{
DateTime dateTime = DateTime.UtcNow;
// Build the response object.
var response = new DefaultFullHttpResponse(HttpVersion.Http11, HttpResponseStatus.OK, buf, false);
HttpHeaders headers = response.Headers;
headers.Set(ContentTypeEntity, contentType);
headers.Set(ServerEntity, ServerName);
headers.Set(DateEntity, AsciiString.Cached($"{dateTime.DayOfWeek}, {dateTime:dd MMM yyyy HH:mm:ss z}"));
headers.Set(ContentLengthEntity, contentLength);
// Close the non-keep-alive connection after the write operation is done.
ctx.WriteAsync(response);
}
public override void ExceptionCaught(IChannelHandlerContext context, Exception exception) =>
context.CloseAsync();
public override void ChannelReadComplete(IChannelHandlerContext context) => context.Flush();
}
}

@ -0,0 +1,188 @@
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Xml;
using ReaderAPI;
namespace RfidInfo
{
public class RfidMgr
{
#region 字段
public static CommonReader reader = null;
static object LockRxdTagData = new object();
#endregion
#region
static XmlNode root = null;
static string fileName = APIPath.folderName + "\\ReaderConfigFile.xml";
static XmlDocument xmlDoc = new XmlDocument();
private static string ip = "172.0.40.11";
private static int port = 9090;
#endregion
public static DateTime date = DateTime.Now;
public static RfidReadModel? RfidReadModel;
/// <summary>
/// 连接
/// </summary>
/// <returns></returns>
public static bool Connect()
{
xmlDoc.Load(fileName);
root = xmlDoc.DocumentElement;
XmlNode node = root.SelectSingleNode("Client[@Name='Reader1']//Port");
node.Attributes["Protocol"].Value = port.ToString();
node.Attributes["Type"].Value = "TcpClient";
node.InnerText = ip.ToString() + ":" + port;
bool isSuc = false;
string errStr = "";
reader = new CommonReader("Reader1");
reader.SubProtocol = ProtocolVersion.GRP;
reader.PortNum = port;
if (reader.Connect(out errStr))
{
isSuc = true;
reader.OnTagDataReceived += Reader_OnTagDataReceived;
}
return isSuc;
}
/// <summary>
/// 断开
/// </summary>
/// <returns></returns>
public static bool CloseRfid()
{
string errStr = "";
if (reader != null)
{
reader.Disconnect(out errStr);
// 删除事件
reader.OnTagDataReceived -= Reader_OnTagDataReceived;
reader = null;
}
return true;
}
/// <summary>
/// 开始读
/// </summary>
/// <returns></returns>
public static bool BeginRead()
{
string errStr = "";
bool isSuc = false;
reader.Stop(out errStr);
if (reader.TagInventory(Common.ScanParam, out errStr))
isSuc = true;
if (isSuc)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// 停止读
/// </summary>
/// <returns></returns>
public static bool StopRead()
{
string errStr = "";
bool isSuc = false;
if (reader.Stop(out errStr)) // && reader2.Stop(out errStr))
isSuc = true;
return isSuc;
}
/// <summary>
/// 读取信息
/// </summary>
/// <returns></returns>
public static RfidReadModel? ReadRifd()
{
return RfidReadModel;
}
#region 接收事件
private static void Reader_OnTagDataReceived(string readerName, ReaderAPI.EntityClass.RxdTagData tagData)
{
if (tagData != null)
display(readerName, tagData);
}
private static void display(string readerName, ReaderAPI.EntityClass.RxdTagData tagData)
{
lock (LockRxdTagData)
{
var userDatas = tagData.UserData;
string strResult = "";
string[] strTemps = null;
string strVelNo = "";
if (userDatas != null)
{
string strUser = System.Text.Encoding.ASCII.GetString(userDatas);
if (!string.IsNullOrEmpty(strUser))
{
strResult = strUser.Replace("\0", "").Replace(" ", "");
}
strTemps = strResult.Split(';');
if (strTemps.Length == 4)
{
if (strTemps[3] != "")
{
date = DateTime.Now;
byte[] bytesVelNo = ToByteByHexStr(strTemps[3]);
Encoding gbEcoding = Encoding.GetEncoding("gb2312");
strVelNo = gbEcoding.GetString(bytesVelNo);
RfidReadModel = new RfidReadModel();
RfidReadModel.Result = 1;
RfidReadModel.VelVin = strTemps[0];
RfidReadModel.VelMac = strTemps[2];
RfidReadModel.VelNo = strVelNo;
}
}
}
}
}
#endregion
/// <summary>
/// 获取16进制字符串的字节数组
/// </summary>
/// <param name="hexString">hexString 16进制字符串</param>
/// <returns>字节数组</returns>
public static byte[] ToByteByHexStr(string hexString)
{
if (hexString == null)
return null;
hexString = hexString.Replace(" ", "");
if ((hexString.Length % 2) != 0)
hexString += " ";
byte[] returnBytes = new byte[hexString.Length / 2];
for (int i = 0; i < returnBytes.Length; i++)
returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16);
return returnBytes;
}
}
}

@ -0,0 +1,26 @@
namespace RfidInfo
{
public class RfidReadModel
{
/// <summary>
/// 1成功 0:失败
/// </summary>
public int Result { get; set; }
/// <summary>
/// 车辆VIN码
/// </summary>
public string VelVin { get; set; }
/// <summary>
/// 车辆MAC地址
/// </summary>
public string? VelMac { set; get; }
/// <summary>
/// 车辆车牌号
/// </summary>
public string VelNo { set; get; }
}
}

@ -0,0 +1,72 @@
using System;
using DotNetty.Codecs.Http;
using DotNetty.Common.Internal.Logging;
using DotNetty.Handlers.Logging;
using DotNetty.Handlers.Streams;
using DotNetty.Handlers.Timeout;
using DotNetty.Transport.Bootstrapping;
using DotNetty.Transport.Channels;
using DotNetty.Transport.Channels.Sockets;
using log4net;
using Microsoft.Extensions.Logging;
using LogLevel = DotNetty.Handlers.Logging.LogLevel;
namespace RfidInfo
{
public class RfidServer: IDisposable
{
private static readonly ILog Log = LogManager.GetLogger(typeof(RfidServer));
private static MultithreadEventLoopGroup? bossGroup;
private static MultithreadEventLoopGroup? workerGroup;
private static ServerBootstrap? bootstrap;
public LogLevel? LogLevel { get; set; }
private void InitBootstrap()
{
if (LogLevel != null)
{
InternalLoggerFactory.DefaultFactory.AddProvider(new Log4NetProvider());
}
bossGroup = new MultithreadEventLoopGroup();
workerGroup = new MultithreadEventLoopGroup();
bootstrap = new ServerBootstrap();
bootstrap
.Group(bossGroup, workerGroup) // 设置主和工作线程组
.Channel<TcpServerSocketChannel>() // 设置通道模式为TcpSocket
.Option(ChannelOption.SoKeepalive, true) //保持连接
.Handler(new LoggingHandler())
.ChildHandler(new ActionChannelInitializer<ISocketChannel>(channel =>
{
var pipeline = channel.Pipeline;
pipeline.AddLast(new LoggingHandler());
//业务handler 这里是实际处理业务的Handler
pipeline.AddLast(new HttpServerCodec());
pipeline.AddLast(new HttpHandler());
}));
}
public void Start(int port = 9000)
{
if (bossGroup == null)
{
InitBootstrap();
}
RfidMgr.Connect();
IChannel channel = bootstrap.BindAsync(port).Result;
Log.Info($"server listen {port}");
}
public void Dispose()
{
bossGroup.ShutdownGracefullyAsync().Wait();
workerGroup.ShutdownGracefullyAsync().Wait();
}
}
}

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<log4net>
<!-- 控制台日志配置 -->
<appender name="Console" type="log4net.Appender.ConsoleAppender">
<!-- 日志输出格式 -->
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %5level [%thread] (%file:%line) - %message%newline"/>
</layout>
</appender>
<!-- 文件存储日志配置 -->
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<!-- 保存文件的名称 -->
<file value="logs\WebApi.log"/>
<appendToFile value="true"/>
<!-- 文件的编码方式 -->
<param name="Encoding" value="UTF-8"/>
<!-- 每个文件的大小 -->
<maximumFileSize value="100MB"/>
<!-- 保存文件数量 -->
<maxSizeRollBackups value="2"/>
<lockingModel type="log4net.Appender.FileAppender+MinimalLock"/>
<!-- 日志输出格式 -->
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %thread %logger - %message%newline"/>
</layout>
</appender>
<root>
<level value="ALL"/>
<appender-ref ref="Console"/>
<appender-ref ref="RollingFile"/>
</root>
</log4net>

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DotNetty.Buffers" version="0.7.5" targetFramework="net48" />
<package id="DotNetty.Codecs" version="0.7.5" targetFramework="net48" />
<package id="DotNetty.Codecs.Http" version="0.7.5" targetFramework="net48" />
<package id="DotNetty.Common" version="0.7.5" targetFramework="net48" />
<package id="DotNetty.Handlers" version="0.7.5" targetFramework="net48" />
<package id="DotNetty.Transport" version="0.7.5" targetFramework="net48" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="5.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.Configuration" version="2.2.0" targetFramework="net48" />
<package id="Microsoft.Extensions.Configuration.Abstractions" version="2.2.0" targetFramework="net48" />
<package id="Microsoft.Extensions.Configuration.Binder" version="2.2.4" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection" version="5.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="5.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.Logging" version="5.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="5.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.Logging.Log4Net.AspNetCore" version="8.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.Options" version="5.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.Primitives" version="5.0.0" targetFramework="net48" />
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
<package id="System.Collections.Immutable" version="1.5.0" targetFramework="net48" />
<package id="System.Diagnostics.DiagnosticSource" version="5.0.0" targetFramework="net48" />
<package id="System.Memory" version="4.5.4" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="5.0.0" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
<package id="log4net" version="2.0.15" targetFramework="net48" />
</packages>

@ -26,4 +26,9 @@ public class CarInfoResp
/// 车辆状态信息
/// </summary>
public CarStatus? CarStatus { get; set; }
/// <summary>
/// 车辆心跳数据
/// </summary>
public HeartBeatMsg? HeartBeatMsg { get; set; }
}

@ -0,0 +1,73 @@
namespace Service.Api.Resp;
public class CarNewInfoResp
{
/// <summary>
/// 1.解锁状态
/// 2 上锁状态
///0 未解锁未上锁
/// </summary>
public byte LockStatus { get; set; }
/// <summary>
/// 钥匙状态 0: OFF 1: ACC 2: ON 0xFF: 不支持
/// </summary>
public byte KeyStatus { get; set; }
/// <summary>
/// 电磁阀驱动状态 0驱动关闭 1驱动打开
/// </summary>
public byte SolenoidValveStatus { get; set; }
/// <summary>
/// 放电连接器状态 0未连接1连接
/// </summary>
public byte DischargeConnectorStatus { get; set; }
/// <summary>
/// 充电连接器状态 0未连接1连接
/// </summary>
public byte ChargingConnectorStatus { get; set; }
/// <summary>
/// 档位
/// 0 空挡
/// 1 倒挡 2 1 档 3 2 档 4 3 档 5 4 档 6 5 档 7 6 档 8 7 档 15 挡位错误
/// </summary>
public byte EarPosition { get; set; }
/// <summary>
/// 车速 最小值0最大值 255
/// </summary>
public byte SpeedVehicle { get; set; }
/// <summary>
/// 手刹 0无效 1有效
/// </summary>
public byte handbrake { get; set; }
/// <summary>
/// 里程 单位Km
/// </summary>
public uint Mileage { get; set; }
/// <summary>
/// 高压上下电状态 0 预留1 高压上电 2 高压下电 3 无效
/// </summary>
public byte HighVoltage { get; set; }
/// <summary>
/// 货箱帽檐状态 1 帽檐落下2 帽檐升起运动中 3 帽檐提升到位 其他:无效
/// </summary>
public byte CrateBrimStatus { get; set; }
/// <summary>
/// 整车换电准备状态 1 待机2 换电就绪
/// </summary>
public byte SwapStatus { get; set; }
/// <summary>
/// 拓展备用
/// </summary>
public byte ExtendedReserve { get; set; }
}

@ -9,6 +9,7 @@ using Service.Car.Common;
using Service.Car.Msg;
using Service.Car.Msg.Car.Req;
using Service.Car.Msg.Car.Resp;
using Service.Car.Msg.Host.Req;
namespace Service.Car.Codec;
@ -61,6 +62,10 @@ public class Decoder : ByteToMessageDecoder
byte[] data = new byte[length];
buffer.ReadBytes(data);
if (data.Length <= 44)
{
return new BaseMsg();
}
BaseMsg msg = data[5] switch
{

@ -27,7 +27,8 @@ public class Encoder : MessageToByteEncoder<BaseMsg>
List<byte> list = new List<byte>(bytes);
list.AddRange(CarConst.EndChar);
byte[] result = list.ToArray();
Log.Info($"send {BitUtls.BytesToHexStr(result)}");
Log.Info($"send "+obj.Cmd+" :{BitUtls.BytesToHexStr(result)}: {BitUtls.BytesToHexStr(result)}");
output.WriteBytes(result);
}
}

@ -39,14 +39,29 @@ public class HeartBeatMsgHandler : SimpleChannelInboundHandler<HeartBeatMsg>, IB
ioSession = CarServerMgr.CarServer?.SessionMgr.GetSession(msg.CarNo);
}
ioSession.BusinessMap.AddOrUpdate("HeartBeatMsg", msg, ((s, o) => msg));
ioSession?.BusinessMap.AddOrUpdate("Connected", true, ((s, o) => true));
if (ioSession != null)
{
ioSession.BusinessMap.AddOrUpdate("HeartBeatMsg", msg, ((s, o) => msg));
ioSession?.BusinessMap.AddOrUpdate("Connected", true, ((s, o) => true));
}
HeartBeatMsgResp resp = new HeartBeatMsgResp(CarServerMgr.CarServer.StationStatus)
if (msg.CarNo==CarServerMgr.CarServer.VIN)
{
CarNo = msg.CarNo
};
resp.InitCurrentTime();
ctx.Channel.WriteAndFlushAsync(resp);
HeartBeatMsgResp resp = new HeartBeatMsgResp(CarServerMgr.CarServer.StationStatus)
{
CarNo = msg.CarNo
};
resp.InitCurrentTime();
ctx.Channel.WriteAndFlushAsync(resp);
}
else
{
HeartBeatMsgResp resp = new HeartBeatMsgResp(1)
{
CarNo = msg.CarNo
};
resp.InitCurrentTime();
ctx.Channel.WriteAndFlushAsync(resp);
}
}
}

@ -2,23 +2,87 @@
namespace Service.Car.Msg.Car.Req;
public class HeartBeatMsg: BaseMsg
public class HeartBeatMsg : BaseMsg
{
/// <summary>
/// 1.解锁状态
// 2 上锁状态
//0 未解锁未上锁
/// 2 上锁状态
///0 未解锁未上锁
/// </summary>
[Property(248, 8)]
public byte LockStatus { get; set; }
/// <summary>
/// 钥匙状态 0: OFF 1: ACC 2: ON 0xFF: 不支持
/// </summary>
[Property(256, 8)]
public byte KeyStatus { get; set; }
/// <summary>
/// 电磁阀驱动状态 0驱动关闭 1驱动打开
/// </summary>
[Property(264, 8)]
public byte SolenoidValveStatus { get; set; }
/// <summary>
/// 放电连接器状态 0未连接1连接
/// </summary>
[Property(272, 8)]
public byte DischargeConnectorStatus { get; set; }
/// <summary>
/// 充电连接器状态 0未连接1连接
/// </summary>
[Property(280, 8)]
public byte ChargingConnectorStatus { get; set; }
/// <summary>
/// 档位
/// 0 空挡
/// 1 倒挡 2 1 档 3 2 档 4 3 档 5 4 档 6 5 档 7 6 档 8 7 档 15 挡位错误
/// </summary>
[Property(288, 8)]
public byte EarPosition { get; set; }
/// <summary>
/// 车速 最小值0最大值 255
/// </summary>
[Property(296, 8)]
public byte SpeedVehicle { get; set; }
/// <summary>
/// 手刹 0无效 1有效
/// </summary>
[Property(304, 8)]
public byte handbrake { get; set; }
/// <summary>
/// 里程 单位Km
/// </summary>
[Property(312, 32)]
public uint Mileage { get; set; }
/// <summary>
/// 高压上下电状态 0 预留1 高压上电 2 高压下电 3 无效
/// </summary>
[Property(344, 8)]
public byte HighVoltage { get; set; }
/// <summary>
/// 货箱帽檐状态 1 帽檐落下2 帽檐升起运动中 3 帽檐提升到位 其他:无效
/// </summary>
[Property(352, 8)]
public byte CrateBrimStatus { get; set; }
/// <summary>
/// 整车换电准备状态 1 待机2 换电就绪
/// </summary>
[Property(360, 8)]
public byte SwapStatus { get; set; }
/// <summary>
/// 拓展备用
/// </summary>
[Property(368, 8)]
public byte ExtendedReserve { get; set; }
}

@ -5,7 +5,7 @@ namespace Service.Car.Msg.Host.Resp;
public class HeartBeatMsgResp : BaseMsg
{
/// <summary>
/// 锁止状态 1 待机 2 换电
/// 1 换电站待机2 开始换电 3 换电进行中 4 换电完成 5 换电站故障
/// </summary>
[Property(248, 8)]
public byte HostStatus { get; set; }

@ -21,9 +21,10 @@ public class CarServer : TcpServer<IBaseHandler, Decoder, Encoder>
public MsgPair<SettleConfirmMsg, SettleConfirmMsgResp> SettleConfirmMsgPair { get; set; } = new ();
/// <summary>
/// 1 待机 2 换电
/// 1 换电站待机2 开始换电 3 换电进行中 4 换电完成 5 换电站故障
/// </summary>
public byte StationStatus { get; set; } = 1;
public string VIN { get; set; }=null;
public CarServer() : base()

@ -0,0 +1,26 @@
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Const;
using HybirdFrameworkDriver.ModbusTcpMaster;
namespace Service.Help.ElectricMeter.ElectricClient;
[Scope]
public class ElectricClient:ModbusTcpMaster
{
public ElectricClient()
{
ReadAction = BatchRead;
Ip = "";
Port = 502;
Duration = 1000;
AutoReConnect = true;
ByteSeq = EndingConst.ByteSeq.BA;
WordSeq= EndingConst.WordSeq.CD;
}
private bool BatchRead(ModbusTcpMaster master)
{
return true;
}
}

@ -0,0 +1,6 @@
namespace Service.Help.ElectricMeter.ElectricClient;
public class ElectricMgr
{
}

@ -0,0 +1,6 @@
namespace Service.HelpRight.ElectricMeter;
public class ElectricMsg
{
}

@ -12,7 +12,7 @@ public class HumiturePlcClient:ModbusTcpMaster
public HumiturePlcClient()
{
ReadAction = BatchRead;
Ip = "172.0.20.66";
Ip = "172.0.20.51";
Port = 502;
Duration = 1000;
AutoReConnect = true;
@ -20,7 +20,7 @@ public class HumiturePlcClient:ModbusTcpMaster
WordSeq= EndingConst.WordSeq.CD;
}
private void BatchRead(ModbusTcpMaster master)
private bool BatchRead(ModbusTcpMaster master)
{
var bytes01 = master.BatchReadHolderRegister(0, 32);
if (bytes01 != null)
@ -28,5 +28,7 @@ public class HumiturePlcClient:ModbusTcpMaster
ModbusDecoder.Decode<HumitureMsg>(bytes01, HumiturePlcMgr.HumitureMsg, EndingConst.ByteSeq.AB,
EndingConst.WordSeq.DC);
}
return true;
}
}

@ -0,0 +1,20 @@
using Autofac;
using HybirdFrameworkCore.Autofac;
namespace Service.Humiture.Client;
public class HumiturePlcMgr
{
public static HumiturePlcClient HumiturePlcClient;
public static HumitureMsg HumitureMsg = new HumitureMsg();
public static void Init()
{
if (HumiturePlcClient == null)
{
HumiturePlcClient = AppInfo.Container.Resolve<HumiturePlcClient>();
}
Task.Run(() => HumiturePlcClient.Connect());
}
}

@ -7,11 +7,11 @@ public class HumitureMsg
/// <summary>
/// 湿度
/// </summary>
public ModbusProperty<short> Humidness { get; set; } = new(0x0000);
public ModbusProperty<short> Humidness { get; set; } = new(0000,offset:0.1);
/// <summary>
/// 温度
/// </summary>
public ModbusProperty<short> Temperature { get; set; } = new(0x0001);
public ModbusProperty<short> Temperature { get; set; } = new(0001,offset:0.1);
public ModbusProperty<short> Reserve02 { get; set; } = new(0x0002);
public ModbusProperty<short> Reserve03 { get; set; } = new(0x0003);
public ModbusProperty<short> Reserve04 { get; set; } = new(0x0004);

@ -0,0 +1,40 @@
using HslCommunication;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.Const;
using HybirdFrameworkDriver.ModbusTcpMaster;
using Service.Humiture;
using Service.Humiture.Client;
using Service.Ups.UpsMsg;
namespace Service.Ups.Client;
[Scope]
public class UpsClient:ModbusTcpMaster
{
public UpsClient()
{
ReadAction = BatchRead;
Ip = "172.0.20.54";
Port = 502;
Duration = 1000;
AutoReConnect = true;
ByteSeq = EndingConst.ByteSeq.BA;
WordSeq= EndingConst.WordSeq.CD;
}
private bool BatchRead(ModbusTcpMaster master)
{
OperateResult<byte[]> bytes01 = master.Read("s=3;x=3;170", (ushort)1366);
if (bytes01.Content != null)
{
ModbusDecoder.Decode<UpsInfoMsg>(bytes01.Content, UpsMgr.UpsInfoMsg, EndingConst.ByteSeq.AB,
EndingConst.WordSeq.DC);
//TODO::bit报警手动处理
}
return true;
}
}

@ -0,0 +1,24 @@
using Autofac;
using HybirdFrameworkCore.Autofac;
using Service.Ups.UpsMsg;
//using HslCommunication;
namespace Service.Ups.Client;
public class UpsMgr
{
public static UpsClient UpsClient;
public static UpsInfoMsg UpsInfoMsg=new ();
//TODO::需要提供写入那些数据,一个不是全部写入方法都需要
public static void Init()
{
if (UpsClient == null)
{
UpsClient = AppInfo.Container.Resolve<UpsClient>();
}
Task.Run(() => UpsClient.Connect());
}
}

@ -3,133 +3,136 @@
namespace Service.Ups.UpsMsg;
public class UpsInfoMsg
{
{/*
#region 1警告项目
/// <summary>
/// 0:FALSE/1:TRUE
/// </summary>
public ModbusProperty<short> Battery { get; set; } = new(0x0000,start:15,length:1);
public ModbusProperty<bool> Battery { get; set; } = new(0x0000,start:15,length:1);
/// <summary>
/// 电池电量过量
/// </summary>
public ModbusProperty<short> BatteryOverCharge { get; set; } = new(0x0000,start:9,length:1);
public ModbusProperty<bool> BatteryOverCharge { get; set; } = new(0x0000,start:9,length:1);
/// <summary>
/// Battery低
/// </summary>
public ModbusProperty<short> BatteryLow { get; set; } = new(0x0000,start:8,length:1);
public ModbusProperty<bool> BatteryLow { get; set; } = new(0x0000,start:8,length:1);
/// <summary>
/// 过载警告
/// </summary>
public ModbusProperty<short> OverloadWarning { get; set; } = new(0x0000,start:7,length:1);
public ModbusProperty<bool> OverloadWarning { get; set; } = new(0x0000,start:7,length:1);
/// <summary>
/// 保留
/// </summary>
public ModbusProperty<short> Reservation02 { get; set; } = new(0x0000,start:6,length:1);
public ModbusProperty<bool> Reservation02 { get; set; } = new(0x0000,start:6,length:1);
/// <summary>
/// EPO活跃
/// </summary>
public ModbusProperty<short> EPOActive { get; set; } = new(0x0000,start:5,length:1);
public ModbusProperty<bool> EPOActive { get; set; } = new(0x0000,start:5,length:1);
public ModbusProperty<bool> Reservation05 { get; set; } = new(0x0000,start:0,length:1);
public ModbusProperty<bool> Reservation04 { get; set; } = new(0x0000,start:1,length:1);
/// <summary>
/// 保留
/// 充电器故障
/// </summary>
public ModbusProperty<short> Reservation03{ get; set; } = new(0x0000,start:4,length:1);
public ModbusProperty<bool> ChargerFail { get; set; } = new(0x0000,start:2,length:1);
/// <summary>
/// 过温
/// </summary>
public ModbusProperty<short> OverTemperature{ get; set; } = new(0x0000,start:3,length:1);
public ModbusProperty<bool> OverTemperature{ get; set; } = new(0x0000,start:3,length:1);
/// <summary>
/// 充电器故障
/// 保留
/// </summary>
public ModbusProperty<short> ChargerFail { get; set; } = new(0x0000,start:2,length:1);
public ModbusProperty<short> Reservation04 { get; set; } = new(0x0000,start:1,length:1);
public ModbusProperty<short> Reservation05 { get; set; } = new(0x0000,start:0,length:1);
public ModbusProperty<bool> Reservation03{ get; set; } = new(0x0000,start:4,length:1);
/// <summary>
/// 警告Battery放回
/// </summary>
public ModbusProperty<short> WarningForBatteryReplace { get; set; } = new(0x0003,start:8,length:1);
public ModbusProperty<bool> WarningForBatteryReplace { get; set; } = new(0x0003,start:8,length:1);
/// <summary>
/// EEPROM操作Eeror
/// </summary>
public ModbusProperty<short> EepromOperationEeror { get; set; } = new(0x0003,start:2,length:1);
public ModbusProperty<bool> EepromOperationEeror { get; set; } = new(0x0003,start:2,length:1);
/// <summary>
/// 更换电池
/// </summary>
public ModbusProperty<short> ReplaceBattery { get; set; } = new(0x0004,start:15,length:1);
public ModbusProperty<bool> ReplaceBattery { get; set; } = new(0x0004,start:15,length:1);
/// <summary>
/// 电池电量不足
/// </summary>
public ModbusProperty<short> LowBattery { get; set; } = new(0x0004,start:14,length:1);
public ModbusProperty<bool> LowBattery { get; set; } = new(0x0004,start:14,length:1);
/// <summary>
/// 过载输出
/// </summary>
public ModbusProperty<short> OverloadOutput { get; set; } = new(0x0004,start:13,length:1);
public ModbusProperty<bool> OverloadOutput { get; set; } = new(0x0004,start:13,length:1);
/// <summary>
/// 电池模式
/// </summary>
public ModbusProperty<short> OnBatteryMode { get; set; } = new(0x0004,start:12,length:1);
public ModbusProperty<bool> OnBatteryMode { get; set; } = new(0x0004,start:12,length:1);
/// <summary>
/// 在线模式
/// </summary>
public ModbusProperty<short> OnlineMode { get; set; } = new(0x0004,start:11,length:1);
public ModbusProperty<bool> OnlineMode { get; set; } = new(0x0004,start:11,length:1);
/// <summary>
/// UPS准备在用户命令下加载电源或 返回 正常线路电压
/// </summary>
public ModbusProperty<short> UpsReady1 { get; set; } = new(0x0004,start:7,length:1);
public ModbusProperty<bool> UpsReady1 { get; set; } = new(0x0004,start:7,length:1);
/// <summary>
/// UPS准备在用户命令下加载电源
/// </summary>
public ModbusProperty<short> UpsReady2 { get; set; } = new(0x0004,start:6,length:1);
public ModbusProperty<bool> UpsReady2 { get; set; } = new(0x0004,start:6,length:1);
/// <summary>
/// UPS正在从旁路模式返回
/// </summary>
public ModbusProperty<short> UPSReady { get; set; } = new(0x0004,start:4,length:1);
public ModbusProperty<bool> UPSReady { get; set; } = new(0x0004,start:4,length:1);
/// <summary>
/// UPS因UPS-Link而处于旁路模式或钥匙 指挥权
/// </summary>
public ModbusProperty<short> UPSBypass { get; set; } = new(0x0004,start:3,length:1);
public ModbusProperty<bool> UPSBypass { get; set; } = new(0x0004,start:3,length:1);
/// <summary>
/// 由于内部故障UPS处于旁路模式
/// </summary>
/// <returns></returns>
public ModbusProperty<short> UPSBypassModeDueInternaFault { get; set; } = new(0x0004,start:1,length:1);
public ModbusProperty<bool> UPSBypassModeDueInternaFault { get; set; } = new(0x0004,start:1,length:1);
/// <summary>
/// 输出电压差
/// </summary>
public ModbusProperty<short> BadOutputVoltage { get; set; } = new(0x0005,start:15,length:1);
public ModbusProperty<bool> BadOutputVoltage { get; set; } = new(0x0005,start:15,length:1);
/// <summary>
/// UPS故障-直流不平衡UPS处于旁路
/// </summary>
public ModbusProperty<short> UPSFaultDCImbalance { get; set; } = new(0x0005,start:12,length:1);
public ModbusProperty<bool> UPSFaultDCImbalance { get; set; } = new(0x0005,start:12,length:1);
/// <summary>
/// Bit7 = 内部温度已超过标称温度限制
/// </summary>
public ModbusProperty<short> InternalTemperatureHasExceededNominalLimits{ get; set; } = new(0x0005,start:7,length:1);
public ModbusProperty<bool> InternalTemperatureHasExceededNominalLimits{ get; set; } = new(0x0005,start:7,length:1);
/// <summary>
/// Battery充电器故障
/// </summary>
public ModbusProperty<short> BatteryChargerFailure { get; set; } = new(0x0005,start:5,length:1);
public ModbusProperty<bool> BatteryChargerFailure { get; set; } = new(0x0005,start:5,length:1);
/// <summary>
/// UPS通过“S”命令处于关机模式
/// </summary>
public ModbusProperty<short> UPSShutDownModeViaCommand { get; set; } = new(0x0005,start:4,length:1);
public ModbusProperty<bool> UPSShutDownModeViaCommand { get; set; } = new(0x0005,start:4,length:1);
/// <summary>
/// Bit3 = UPS在“睡眠”模式下通过“@Ddd”命令
/// </summary>
public ModbusProperty<short> UPSSleepModeViaCommand { get; set; } = new(0x0005,start:3,length:1);
public ModbusProperty<bool> UPSSleepModeViaCommand { get; set; } = new(0x0005,start:3,length:1);
/// <summary>
/// Bit0 = UPS的输出因电池电量不足而无法供电关闭
/// </summary>
public ModbusProperty<short> UPSOutputUnpoweredDueToLowBatteryshutDown { get; set; } = new(0x0005,start:0,length:1);
public ModbusProperty<bool> UPSOutputUnpoweredDueToLowBatteryshutDown { get; set; } = new(0x0005,start:0,length:1);
#endregion
@ -137,41 +140,41 @@ public class UpsInfoMsg
/// <summary>
/// 启用/禁用声音警报
/// </summary>
public ModbusProperty<short> EnableAudibleAlarm { get; set; } = new(0x000E,start:15,length:1);
public ModbusProperty<bool> EnableAudibleAlarm { get; set; } = new(0x000E,start:15,length:1);
/// <summary>
/// 启用/禁用自动重新启动
/// </summary>
public ModbusProperty<short> EnableAutoRestart { get; set; } = new(0x000E,start:10,length:1);
public ModbusProperty<bool> EnableAutoRestart { get; set; } = new(0x000E,start:10,length:1);
/// <summary>
/// 启用/禁用代码启动
/// </summary>
public ModbusProperty<short> EnableDodeStart { get; set; } = new(0x000E,start:7,length:1);
public ModbusProperty<bool> EnableDodeStart { get; set; } = new(0x000E,start:7,length:1);
/// <summary>
/// 启用/禁用旁路禁止
/// </summary>
public ModbusProperty<short> EnableBypassForBiding { get; set; } = new(0x000E,start:6,length:1);
public ModbusProperty<bool> EnableBypassForBiding { get; set; } = new(0x000E,start:6,length:1);
/// <summary>
/// Bit3=设备时启用/禁用旁路关掉。
/// </summary>
public ModbusProperty<short> EnableBypassWhenDeviceTurnOff { get; set; } = new(0x000E,start:3,length:1);
public ModbusProperty<bool> EnableBypassWhenDeviceTurnOff { get; set; } = new(0x000E,start:3,length:1);
/// <summary>
/// Bit2=启用/禁用旁路可听警告
/// </summary>
public ModbusProperty<short> EnableBypassAudibleWarning { get; set; } = new(0x000E,start:2,length:1);
public ModbusProperty<bool> EnableBypassAudibleWarning { get; set; } = new(0x000E,start:2,length:1);
/// <summary>
/// 启用/禁用高效模式
/// </summary>
public ModbusProperty<short> EnableHighEfficiencyMode { get; set; } = new(0x000E,start:1,length:1);
public ModbusProperty<bool> EnableHighEfficiencyMode { get; set; } = new(0x000E,start:1,length:1);
/// <summary>
/// 启用/禁用节能
/// </summary>
public ModbusProperty<short> EnableEnergySaving { get; set; } = new(0x000E,start:0,length:1);
public ModbusProperty<bool> EnableEnergySaving { get; set; } = new(0x000E,start:0,length:1);
/// <summary>
/// 启用/禁用转换器模式
/// </summary>
public ModbusProperty<short> EnableConverterMode { get; set; } = new(0x000F,start:12,length:1);
public ModbusProperty<bool> EnableConverterMode { get; set; } = new(0x000F,start:12,length:1);
#endregion
@ -180,41 +183,41 @@ public class UpsInfoMsg
/// <summary>
/// 启用/禁用声音警报
/// </summary>
public ModbusProperty<short> EnableAudibleAlarm1 { get; set; } = new(0x0010,start:15,length:1);
public ModbusProperty<bool> EnableAudibleAlarm1 { get; set; } = new(0x0010,start:15,length:1);
/// <summary>
/// 启用/禁用自动重新启动。
/// </summary>
public ModbusProperty<short> EnableAutoRestart1 { get; set; } = new(0x0010,start:10,length:1);
public ModbusProperty<bool> EnableAutoRestart1 { get; set; } = new(0x0010,start:10,length:1);
/// <summary>
/// 启用/禁用代码启动
/// </summary>
public ModbusProperty<short> EnableCodeStart { get; set; } = new(0x0010,start:7,length:1);
public ModbusProperty<bool> EnableCodeStart { get; set; } = new(0x0010,start:7,length:1);
/// <summary>
/// 启用/禁用旁路禁止
/// </summary>
public ModbusProperty<short> EnableBypassForbidding { get; set; } = new(0x0010,start:6,length:1);
public ModbusProperty<bool> EnableBypassForbidding { get; set; } = new(0x0010,start:6,length:1);
/// <summary>
/// 在设备时启用/禁用旁路关掉。
/// </summary>
public ModbusProperty<short> EnableBypassWhenDeviceTurnOff1 { get; set; } = new(0x0010,start:3,length:1);
public ModbusProperty<bool> EnableBypassWhenDeviceTurnOff1 { get; set; } = new(0x0010,start:3,length:1);
/// <summary>
/// 启用/禁用旁路声音警告
/// </summary>
public ModbusProperty<short> EnableBypassAudibleWarning1 { get; set; } = new(0x0010,start:2,length:1);
public ModbusProperty<bool> EnableBypassAudibleWarning1 { get; set; } = new(0x0010,start:2,length:1);
/// <summary>
/// 启用/禁用高效率形式
/// </summary>
public ModbusProperty<short> EnableHighEfficiencyMode1 { get; set; } = new(0x0010,start:1,length:1);
public ModbusProperty<bool> EnableHighEfficiencyMode1 { get; set; } = new(0x0010,start:1,length:1);
/// <summary>
/// 支持:启用/禁用节能
/// </summary>
public ModbusProperty<short> EnableEnergySaving1 { get; set; } = new(0x0010,start:0,length:1);
public ModbusProperty<bool> EnableEnergySaving1 { get; set; } = new(0x0010,start:0,length:1);
/// <summary>
/// 启用/禁用转换器模式
/// </summary>
public ModbusProperty<short> EnableConverterMode1 { get; set; } = new(0x0011,start:0,length:1);
public ModbusProperty<bool> EnableConverterMode1 { get; set; } = new(0x0011,start:0,length:1);
#endregion
@ -223,43 +226,43 @@ public class UpsInfoMsg
/// <summary>
/// Bit15=静音蜂鸣器嘟嘟声
/// </summary>
public ModbusProperty<short> SilenceBuzzerBeep { get; set; } = new(0x001A,start:15,length:1);
public ModbusProperty<bool> SilenceBuzzerBeep { get; set; } = new(0x001A,start:15,length:1);
/// <summary>
/// Bit14=蜂鸣器蜂鸣器打开
/// </summary>
public ModbusProperty<short> BuzzerBeepOpen { get; set; } = new(0x001A,start:14,length:1);
public ModbusProperty<bool> BuzzerBeepOpen { get; set; } = new(0x001A,start:14,length:1);
/// <summary>
/// Bit13=测试直到电池电量不足
/// </summary>
public ModbusProperty<short> TestUntilBatteryLow { get; set; } = new(0x001A,start:13,length:1);
public ModbusProperty<bool> TestUntilBatteryLow { get; set; } = new(0x001A,start:13,length:1);
/// <summary>
/// bit12=关闭UPS
/// </summary>
public ModbusProperty<short> TurnOnUps { get; set; } = new(0x001A,start:12,length:1);
public ModbusProperty<bool> TurnOnUps { get; set; } = new(0x001A,start:12,length:1);
/// <summary>
/// bit11=打开UPS
/// </summary>
public ModbusProperty<short> CancelShutdown { get; set; } = new(0x001A,start:11,length:1);
public ModbusProperty<bool> CancelShutdown { get; set; } = new(0x001A,start:11,length:1);
/// <summary>
/// Bit10=取消关机
/// </summary>
public ModbusProperty<short> CancelTest { get; set; } = new(0x001A,start:10,length:1);
public ModbusProperty<bool> CancelTest { get; set; } = new(0x001A,start:10,length:1);
/// <summary>
/// Bit9=取消测试
/// </summary>
public ModbusProperty<short> SecondsTest { get; set; } = new(0x001A,start:9,length:1);
public ModbusProperty<bool> SecondsTest { get; set; } = new(0x001A,start:9,length:1);
/// <summary>
/// Bit8=10秒测试
/// </summary>
public ModbusProperty<short> TurnOffAfterDelay1 { get; set; } = new(0x001A,start:8,length:1);
public ModbusProperty<bool> TurnOffAfterDelay1 { get; set; } = new(0x001A,start:8,length:1);
/// <summary>
/// Bit3 = 之后关掉延迟
/// </summary>
public ModbusProperty<short> ShutdownUpsOnBattery { get; set; } = new(0x001A,start:3,length:1);
public ModbusProperty<bool> ShutdownUpsOnBattery { get; set; } = new(0x001A,start:3,length:1);
/// <summary>
/// 位2 = 关闭UPS Battery
/// </summary>
public ModbusProperty<short> Reservation { get; set; } = new(0x001A,start:2,length:1);
public ModbusProperty<bool> Reservation { get; set; } = new(0x001A,start:2,length:1);
#endregion
@ -268,43 +271,43 @@ public class UpsInfoMsg
/// <summary>
/// 位15=旗帜:沉默蜂鸣器蜂鸣声
/// </summary>
public ModbusProperty<short> SilenceBuzzerBeep1 { get; set; } = new(0x0025,start:15,length:1);
public ModbusProperty<bool> SilenceBuzzerBeep1 { get; set; } = new(0x0025,start:15,length:1);
/// <summary>
/// 位14=旗帜:蜂鸣器哔哔声打开
/// </summary>
public ModbusProperty<short> buzzerBeepOpen1 { get; set; } = new(0x0025,start:14,length:1);
public ModbusProperty<bool> buzzerBeepOpen1 { get; set; } = new(0x0025,start:14,length:1);
/// <summary>
/// 位13=旗帜:测试直到电池电量不足
/// </summary>
public ModbusProperty<short> TestUntilBatteryLow1 { get; set; } = new(0x0025,start:13,length:1);
public ModbusProperty<bool> TestUntilBatteryLow1 { get; set; } = new(0x0025,start:13,length:1);
/// <summary>
/// Bit12=旗帜转关闭UPS
/// </summary>
public ModbusProperty<short> TurnOffUps1 { get; set; } = new(0x0025,start:12,length:1);
public ModbusProperty<bool> TurnOffUps1 { get; set; } = new(0x0025,start:12,length:1);
/// <summary>
/// Bit11=旗帜转在UPS上
/// </summary>
public ModbusProperty<short> TurnOnUps1 { get; set; } = new(0x0025,start:11,length:1);
public ModbusProperty<bool> TurnOnUps1 { get; set; } = new(0x0025,start:11,length:1);
/// <summary>
/// Bit10=标志:取消停工
/// </summary>
public ModbusProperty<short> CancelShutdown1 { get; set; } = new(0x0025,start:10,length:1);
public ModbusProperty<bool> CancelShutdown1 { get; set; } = new(0x0025,start:10,length:1);
/// <summary>
/// Bit9=标志:取消测试
/// </summary>
public ModbusProperty<short> CancelTest1 { get; set; } = new(0x0025,start:9,length:1);
public ModbusProperty<bool> CancelTest1 { get; set; } = new(0x0025,start:9,length:1);
/// <summary>
/// bit8=Flag10秒测试
/// </summary>
public ModbusProperty<short> SecondsTest10 { get; set; } = new(0x0025,start:8,length:1);
public ModbusProperty<bool> SecondsTest10 { get; set; } = new(0x0025,start:8,length:1);
/// <summary>
/// 位3 = 旗帜:转离开 延迟后
/// </summary>
public ModbusProperty<short> TurnOffAfterDelay { get; set; } = new(0x0025,start:3,length:1);
public ModbusProperty<bool> TurnOffAfterDelay { get; set; } = new(0x0025,start:3,length:1);
/// <summary>
/// 位2 = 旗帜:关闭 UPS在Battery
/// </summary>
public ModbusProperty<short> ShutdownUpsOnBattery1 { get; set; } = new(0x0025,start:2,length:1);
public ModbusProperty<bool> ShutdownUpsOnBattery1 { get; set; } = new(0x0025,start:2,length:1);
#endregion
@ -313,13 +316,14 @@ public class UpsInfoMsg
/// <summary>
/// 位15=设置控制参数到默认值
/// </summary>
public ModbusProperty<short> SetingControlParameterDefaultValue1 { get; set; } = new(0x0030,start:15,length:1);
public ModbusProperty<bool> SetingControlParameterDefaultValue1 { get; set; } = new(0x0030,start:15,length:1);
/// <summary>
/// 位15=设置控制参数到默认值
/// </summary>
public ModbusProperty<short> SetingControlParameterDefaultValue2 { get; set; } = new(0x003B,start:15,length:1);
public ModbusProperty<bool> SetingControlParameterDefaultValue2 { get; set; } = new(0x003B,start:15,length:1);
#endregion
*/
#region 7设置参数项
@ -544,7 +548,7 @@ public class UpsInfoMsg
/// <summary>
/// 主CPU固件版本
/// </summary>
public ModbusProperty<string> MainCPUFirmwareVersion { get; set; } = new(0x03E1,length:10);
public ModbusProperty<string> MainCpuFirmwareVersion { get; set; } = new(0x03E1,length:10);
#endregion

@ -0,0 +1,668 @@
/*namespace Service.Ups.UpsMsg;
/// <summary>
/// UPS读取到的二次处理数据
/// </summary>
public class UpsInfoMsgHandling
{
#region 1警告项目
/// <summary>
/// 0:FALSE/1:TRUE
/// </summary>
public bool Battery { get; set; } = new(0x0000,start:15,length:1);
/// <summary>
/// 电池电量过量
/// </summary>
public bool BatteryOverCharge { get; set; } = new(0x0000,start:9,length:1);
/// <summary>
/// Battery低
/// </summary>
public bool BatteryLow { get; set; } = new(0x0000,start:8,length:1);
/// <summary>
/// 过载警告
/// </summary>
public bool OverloadWarning { get; set; } = new(0x0000,start:7,length:1);
/// <summary>
/// 保留
/// </summary>
public bool Reservation02 { get; set; } = new(0x0000,start:6,length:1);
/// <summary>
/// EPO活跃
/// </summary>
public bool EPOActive { get; set; } = new(0x0000,start:5,length:1);
public bool Reservation05 { get; set; } = new(0x0000,start:0,length:1);
public bool Reservation04 { get; set; } = new(0x0000,start:1,length:1);
/// <summary>
/// 充电器故障
/// </summary>
public bool ChargerFail { get; set; } = new(0x0000,start:2,length:1);
/// <summary>
/// 过温
/// </summary>
public bool OverTemperature{ get; set; } = new(0x0000,start:3,length:1);
/// <summary>
/// 保留
/// </summary>
public bool Reservation03{ get; set; } = new(0x0000,start:4,length:1);
/// <summary>
/// 警告Battery放回
/// </summary>
public bool WarningForBatteryReplace { get; set; } = new(0x0003,start:8,length:1);
/// <summary>
/// EEPROM操作Eeror
/// </summary>
public bool EepromOperationEeror { get; set; } = new(0x0003,start:2,length:1);
/// <summary>
/// 更换电池
/// </summary>
public bool ReplaceBattery { get; set; } = new(0x0004,start:15,length:1);
/// <summary>
/// 电池电量不足
/// </summary>
public bool LowBattery { get; set; } = new(0x0004,start:14,length:1);
/// <summary>
/// 过载输出
/// </summary>
public bool OverloadOutput { get; set; } = new(0x0004,start:13,length:1);
/// <summary>
/// 电池模式
/// </summary>
public bool OnBatteryMode { get; set; } = new(0x0004,start:12,length:1);
/// <summary>
/// 在线模式
/// </summary>
public bool OnlineMode { get; set; } = new(0x0004,start:11,length:1);
/// <summary>
/// UPS准备在用户命令下加载电源或 返回 正常线路电压
/// </summary>
public bool UpsReady1 { get; set; } = new(0x0004,start:7,length:1);
/// <summary>
/// UPS准备在用户命令下加载电源
/// </summary>
public bool UpsReady2 { get; set; } = new(0x0004,start:6,length:1);
/// <summary>
/// UPS正在从旁路模式返回
/// </summary>
public bool UPSReady { get; set; } = new(0x0004,start:4,length:1);
/// <summary>
/// UPS因UPS-Link而处于旁路模式或钥匙 指挥权
/// </summary>
public bool UPSBypass { get; set; } = new(0x0004,start:3,length:1);
/// <summary>
/// 由于内部故障UPS处于旁路模式
/// </summary>
/// <returns></returns>
public bool UPSBypassModeDueInternaFault { get; set; } = new(0x0004,start:1,length:1);
/// <summary>
/// 输出电压差
/// </summary>
public bool BadOutputVoltage { get; set; } = new(0x0005,start:15,length:1);
/// <summary>
/// UPS故障-直流不平衡UPS处于旁路
/// </summary>
public bool UPSFaultDCImbalance { get; set; } = new(0x0005,start:12,length:1);
/// <summary>
/// Bit7 = 内部温度已超过标称温度限制
/// </summary>
public bool InternalTemperatureHasExceededNominalLimits{ get; set; } = new(0x0005,start:7,length:1);
/// <summary>
/// Battery充电器故障
/// </summary>
public bool BatteryChargerFailure { get; set; } = new(0x0005,start:5,length:1);
/// <summary>
/// UPS通过“S”命令处于关机模式
/// </summary>
public bool UPSShutDownModeViaCommand { get; set; } = new(0x0005,start:4,length:1);
/// <summary>
/// Bit3 = UPS在“睡眠”模式下通过“@Ddd”命令
/// </summary>
public bool UPSSleepModeViaCommand { get; set; } = new(0x0005,start:3,length:1);
/// <summary>
/// Bit0 = UPS的输出因电池电量不足而无法供电关闭
/// </summary>
public bool UPSOutputUnpoweredDueToLowBatteryshutDown { get; set; } = new(0x0005,start:0,length:1);
#endregion
#region 2能力设置
/// <summary>
/// 启用/禁用声音警报
/// </summary>
public bool EnableAudibleAlarm { get; set; } = new(0x000E,start:15,length:1);
/// <summary>
/// 启用/禁用自动重新启动
/// </summary>
public bool EnableAutoRestart { get; set; } = new(0x000E,start:10,length:1);
/// <summary>
/// 启用/禁用代码启动
/// </summary>
public bool EnableDodeStart { get; set; } = new(0x000E,start:7,length:1);
/// <summary>
/// 启用/禁用旁路禁止
/// </summary>
public bool EnableBypassForBiding { get; set; } = new(0x000E,start:6,length:1);
/// <summary>
/// Bit3=设备时启用/禁用旁路关掉。
/// </summary>
public bool EnableBypassWhenDeviceTurnOff { get; set; } = new(0x000E,start:3,length:1);
/// <summary>
/// Bit2=启用/禁用旁路可听警告
/// </summary>
public bool EnableBypassAudibleWarning { get; set; } = new(0x000E,start:2,length:1);
/// <summary>
/// 启用/禁用高效模式
/// </summary>
public bool EnableHighEfficiencyMode { get; set; } = new(0x000E,start:1,length:1);
/// <summary>
/// 启用/禁用节能
/// </summary>
public bool EnableEnergySaving { get; set; } = new(0x000E,start:0,length:1);
/// <summary>
/// 启用/禁用转换器模式
/// </summary>
public bool EnableConverterMode { get; set; } = new(0x000F,start:12,length:1);
#endregion
#region 3支持能力列表
/// <summary>
/// 启用/禁用声音警报
/// </summary>
public bool EnableAudibleAlarm1 { get; set; } = new(0x0010,start:15,length:1);
/// <summary>
/// 启用/禁用自动重新启动。
/// </summary>
public bool EnableAutoRestart1 { get; set; } = new(0x0010,start:10,length:1);
/// <summary>
/// 启用/禁用代码启动
/// </summary>
public bool EnableCodeStart { get; set; } = new(0x0010,start:7,length:1);
/// <summary>
/// 启用/禁用旁路禁止
/// </summary>
public bool EnableBypassForbidding { get; set; } = new(0x0010,start:6,length:1);
/// <summary>
/// 在设备时启用/禁用旁路关掉。
/// </summary>
public bool EnableBypassWhenDeviceTurnOff1 { get; set; } = new(0x0010,start:3,length:1);
/// <summary>
/// 启用/禁用旁路声音警告
/// </summary>
public bool EnableBypassAudibleWarning1 { get; set; } = new(0x0010,start:2,length:1);
/// <summary>
/// 启用/禁用高效率形式
/// </summary>
public bool EnableHighEfficiencyMode1 { get; set; } = new(0x0010,start:1,length:1);
/// <summary>
/// 支持:启用/禁用节能
/// </summary>
public bool EnableEnergySaving1 { get; set; } = new(0x0010,start:0,length:1);
/// <summary>
/// 启用/禁用转换器模式
/// </summary>
public bool EnableConverterMode1 { get; set; } = new(0x0011,start:0,length:1);
#endregion
#region 4控制项
/// <summary>
/// Bit15=静音蜂鸣器嘟嘟声
/// </summary>
public bool SilenceBuzzerBeep { get; set; } = new(0x001A,start:15,length:1);
/// <summary>
/// Bit14=蜂鸣器蜂鸣器打开
/// </summary>
public bool BuzzerBeepOpen { get; set; } = new(0x001A,start:14,length:1);
/// <summary>
/// Bit13=测试直到电池电量不足
/// </summary>
public bool TestUntilBatteryLow { get; set; } = new(0x001A,start:13,length:1);
/// <summary>
/// bit12=关闭UPS
/// </summary>
public bool TurnOnUps { get; set; } = new(0x001A,start:12,length:1);
/// <summary>
/// bit11=打开UPS
/// </summary>
public bool CancelShutdown { get; set; } = new(0x001A,start:11,length:1);
/// <summary>
/// Bit10=取消关机
/// </summary>
public bool CancelTest { get; set; } = new(0x001A,start:10,length:1);
/// <summary>
/// Bit9=取消测试
/// </summary>
public bool SecondsTest { get; set; } = new(0x001A,start:9,length:1);
/// <summary>
/// Bit8=10秒测试
/// </summary>
public bool TurnOffAfterDelay1 { get; set; } = new(0x001A,start:8,length:1);
/// <summary>
/// Bit3 = 之后关掉延迟
/// </summary>
public bool ShutdownUpsOnBattery { get; set; } = new(0x001A,start:3,length:1);
/// <summary>
/// 位2 = 关闭UPS Battery
/// </summary>
public bool Reservation { get; set; } = new(0x001A,start:2,length:1);
#endregion
#region 5控制的结果
/// <summary>
/// 位15=旗帜:沉默蜂鸣器蜂鸣声
/// </summary>
public bool SilenceBuzzerBeep1 { get; set; } = new(0x0025,start:15,length:1);
/// <summary>
/// 位14=旗帜:蜂鸣器哔哔声打开
/// </summary>
public bool buzzerBeepOpen1 { get; set; } = new(0x0025,start:14,length:1);
/// <summary>
/// 位13=旗帜:测试直到电池电量不足
/// </summary>
public bool TestUntilBatteryLow1 { get; set; } = new(0x0025,start:13,length:1);
/// <summary>
/// Bit12=旗帜转关闭UPS
/// </summary>
public bool TurnOffUps1 { get; set; } = new(0x0025,start:12,length:1);
/// <summary>
/// Bit11=旗帜转在UPS上
/// </summary>
public bool TurnOnUps1 { get; set; } = new(0x0025,start:11,length:1);
/// <summary>
/// Bit10=标志:取消停工
/// </summary>
public bool CancelShutdown1 { get; set; } = new(0x0025,start:10,length:1);
/// <summary>
/// Bit9=标志:取消测试
/// </summary>
public bool CancelTest1 { get; set; } = new(0x0025,start:9,length:1);
/// <summary>
/// bit8=Flag10秒测试
/// </summary>
public bool SecondsTest10 { get; set; } = new(0x0025,start:8,length:1);
/// <summary>
/// 位3 = 旗帜:转离开 延迟后
/// </summary>
public bool TurnOffAfterDelay { get; set; } = new(0x0025,start:3,length:1);
/// <summary>
/// 位2 = 旗帜:关闭 UPS在Battery
/// </summary>
public bool ShutdownUpsOnBattery1 { get; set; } = new(0x0025,start:2,length:1);
#endregion
#region 6将参数设置为默认值
/// <summary>
/// 位15=设置控制参数到默认值
/// </summary>
public bool SetingControlParameterDefaultValue1 { get; set; } = new(0x0030,start:15,length:1);
/// <summary>
/// 位15=设置控制参数到默认值
/// </summary>
public bool SetingControlParameterDefaultValue2 { get; set; } = new(0x003B,start:15,length:1);
#endregion
#region 7设置参数项
public ModbusProperty<short> VoltageHigh { get; set; } = new(0x0350);
public ModbusProperty<short> VoltageLow { get; set; } = new(0x0351);
#endregion
#region 8设置参数成功或失败
/// <summary>
/// 标志旁路Freq高损点
/// </summary>
public ModbusProperty<short> BypassFreqHigh { get; set; } = new(0x0385,start:11,length:1);
/// <summary>
/// 标志旁路Freq低损耗点
/// </summary>
public ModbusProperty<short> BypassFreqLow { get; set; } = new(0x0385,start:10,length:1);
/// <summary>
/// 标志:旁路电压高损耗点
/// </summary>
public ModbusProperty<short> BypassVoltageHigh { get; set; } = new(0x0385,start:9,length:1);
/// <summary>
/// 标志:旁路电压低损耗点
/// </summary>
public ModbusProperty<short> BypassVoltageLow { get; set; } = new(0x0385,start:8,length:1);
#endregion
#region 9UPS工作状态
/// <summary>
/// Battery电流
/// </summary>
public ModbusProperty<short> BatteryCurrent { get; set; } = new(0x00A9);
/// <summary>
/// 线路电压
/// </summary>
public ModbusProperty<short> LineVoltage { get; set; } = new(0x00AA);
/// <summary>
/// 输入频率
/// </summary>
public ModbusProperty<short> InputFrequency { get; set; } = new(0x00AB);
/// <summary>
/// 输出电压
/// </summary>
public ModbusProperty<short> OutputVoltage { get; set; } = new(0x00AC);
/// <summary>
/// 输出Ut频率交流输出频率
/// </summary>
public ModbusProperty<short> OutputFrequency { get; set; } = new(0x00AD);
/// <summary>
/// 输出电流
/// </summary>
public ModbusProperty<short> OutputCurrent { get; set; } = new(0x00AE);
/// <summary>
/// 输出负载百分比
/// </summary>
public ModbusProperty<short> OutputLoadPercent { get; set; } = new(0x00AF);
/// <summary>
/// P 电池电压
/// </summary>
public ModbusProperty<short> PBatteryVoltage { get; set; } = new(0x00B2);
/// <summary>
/// UPS内部温度
/// </summary>
public ModbusProperty<short> UpsInternalTemperature { get; set; } = new(0x00B4);
/// <summary>
/// Ups状态
/// </summary>
public ModbusProperty<short> UpsStatus { get; set; } = new(0x00B5);
/// <summary>
/// Battery能力
/// </summary>
public ModbusProperty<short> BatteryCapacity { get; set; } = new(0x00BF);
/// <summary>
/// Battery保持时间
/// </summary>
public ModbusProperty<short> BatteryRemainTime { get; set; } = new(0x00C0);
/// <summary>
/// L线1L2电压
/// </summary>
public ModbusProperty<short> LineL1L2Voltage { get; set; } = new(0x00C1);
/// <summary>
/// 字母lIne L2L3电压
/// </summary>
public ModbusProperty<short> LineL2L3Voltage { get; set; } = new(0x00C2);
/// <summary>
/// 字母lIne L3L1电压
/// </summary>
public ModbusProperty<short> LineL3L1Voltage { get; set; } = new(0x00C3);
/// <summary>
/// 线路L1电压
/// </summary>
public ModbusProperty<short> LineL1Voltage { get; set; } = new(0x00C4);
/// <summary>
/// 字母lIne L2电压
/// </summary>
public ModbusProperty<short> LineL2Voltage { get; set; } = new(0x00C5);
/// <summary>
/// 字母lIne L3电压
/// </summary>
public ModbusProperty<short> LineL3Voltage { get; set; } = new(0x00C6);
/// <summary>
/// UPS模式查询
/// </summary>
public ModbusProperty<short> UpsModeInquiry { get; set; } = new(0x00D0);
/// <summary>
/// 输出L1电压
/// </summary>
public ModbusProperty<short> OutputL1Voltage { get; set; } = new(0x00D8);
/// <summary>
/// L1负载电流
/// </summary>
public ModbusProperty<short> L1LoadCurrent { get; set; } = new(0x00DC);
/// <summary>
/// L1负载百分比s
/// </summary>
public ModbusProperty<short> L1LoadPercents { get; set; } = new(0x00DD);
/// <summary>
/// L2负载电流
/// </summary>
public ModbusProperty<short> L2LoadCurrent { get; set; } = new(0x00EF);
/// <summary>
/// L3负载电流
/// </summary>
public ModbusProperty<short> L3LoadCurrent { get; set; } = new(0x00F0);
/// <summary>
/// 输出L2电压
/// </summary>
public ModbusProperty<short> OutputL2Voltage { get; set; } = new(0x00F7);
/// <summary>
/// 输出L3电压
/// </summary>
public ModbusProperty<short> OutputL3Voltage { get; set; } = new(0x00F8);
/// <summary>
/// 输出信息字母l1L2电压
/// </summary>
public ModbusProperty<short> OutputL1L2Voltage { get; set; } = new(0x00F9);
/// <summary>
/// 输出信息字母l2L3电压
/// </summary>
public ModbusProperty<short> OutputL2L3Voltage { get; set; } = new(0x00FA);
/// <summary>
/// 输出信息字母l3L1电压
/// </summary>
public ModbusProperty<short> OutputL3L1Voltage { get; set; } = new(0x00FB);
/// <summary>
/// L2负载百分比
/// </summary>
public ModbusProperty<short> L2LoadPercent { get; set; } = new(0x00FC);
/// <summary>
/// L3负载百分比
/// </summary>
public ModbusProperty<short> L3LoadPercent { get; set; } = new(0x00FD);
/// <summary>
/// 整个负载百分比
/// </summary>
public ModbusProperty<short> WholeLoadPercent { get; set; } = new(0x00FE);
/// <summary>
/// 表观负载功率
/// </summary>
public ModbusProperty<short> ApparentLoadPower { get; set; } = new(0x0127);
#endregion
#region 10UPS电池信息
/// <summary>
///Battery更换日期 单位Battery容量AH SP6KSP10K仅支持 下面的设置
/// </summary>
public ModbusProperty<long> BatteryReplacementDate { get; set; } = new(0x036B);
/// <summary>
/// 7, 9,10,12,17,26,40,65,100 SP1KSP2K仅支持以下设置7 SP3K支持以下设置9
/// </summary>
public ModbusProperty<short> SupportBelowSetting { get; set; } = new(0x036F);
#endregion
#region 11设置UPS电池信息成功或失败
/// <summary>
/// 设置电池更换数据
/// </summary>
public ModbusProperty<short> SetBatteryReplacementData { get; set; } = new(0x0386,start:0,length:1);
/// <summary>
/// 设置单位电池容量AH
/// </summary>
public ModbusProperty<short> SetUnitBatteryCapacity { get; set; } = new(0x0387, start: 15, length: 1);
#endregion
#region 12UPS故障信息
/// <summary>
/// 故障种类
/// </summary>
public ModbusProperty<short> FaultKind { get; set; } = new(0x02A3);
#endregion
#region 13远程关机和测试
/// <summary>
/// 在指定时间内进行测试 分钟ASCII
/// </summary>
public ModbusProperty<short> TestForSpecifiedTime { get; set; } = new(0x03AC);
/// <summary>
/// 关机和恢复M 0.1小时ASCII
/// </summary>
public ModbusProperty<short> ShutdownRestore1 { get; set; } = new(0x03AE);
/// <summary>
/// 在指定时间内测试
/// </summary>
public ModbusProperty<short> TestForSpecifiedTime1 { get; set; } = new(0x03DA, start: 14, length: 1);
/// <summary>
/// 关闭和恢复
/// </summary>
public ModbusProperty<short> ShutdownRestore { get; set; } = new(0x03DA,start:13,length:1);
#endregion
#region 14CPU信息
/// <summary>
/// 主CPU固件版本
/// </summary>
public ModbusProperty<string> MainCpuFirmwareVersion { get; set; } = new(0x03E1,length:10);
#endregion
#region 15UPS型号和评级信息
/// <summary>
/// 制造商ID
/// </summary>
public ModbusProperty<string> ManufacturerID { get; set; } = new(0x03EB,length:7);
/// <summary>
/// Battery件数
/// </summary>
public ModbusProperty<short> BatteryPieceNumber { get; set; } = new(0x03F2);
/// <summary>
/// 输入阶段
/// </summary>
public ModbusProperty<short> InputPhase { get; set; } = new(0x03F4);
/// <summary>
/// 输出阶段
/// </summary>
public ModbusProperty<short> OutputPhase { get; set; } = new(0x03F5);
/// <summary>
/// 标称I/P电压
/// </summary>
public ModbusProperty<short> NominalIPVoltage { get; set; } = new(0x03F6);
/// <summary>
/// 标称O/P电压
/// </summary>
public ModbusProperty<short> NominalOPVoltage { get; set; } = new(0x03F7);
/// <summary>
/// 输出额定VA
/// </summary>
public ModbusProperty<short> OutputRatedVA { get; set; } = new(0x03F9);
/// <summary>
/// 设备型号
/// </summary>
public ModbusProperty<short> DeviceModel { get; set; } = new(0x03FB);
/// <summary>
/// Battery电压
/// </summary>
public ModbusProperty<short> BatteryVoltage { get; set; } = new(0x048A);
/// <summary>
/// 额定输出电流
/// </summary>
public ModbusProperty<short> RatingOutputCurrent { get; set; } = new(0x048B);
/// <summary>
/// 额定输出频率
/// </summary>
public ModbusProperty<short> RatingOutputFrequency { get; set; } = new(0x048C);
#endregion
#region 16读取可配置参数
/// <summary>
/// 声音警报
/// </summary>
public ModbusProperty<short> AudibleAlarm { get; set; } = new(0x04F0);
/// <summary>
/// 关机延迟
/// </summary>
public ModbusProperty<short> ShutdownDelay { get; set; } = new(0x04F1);
/// <summary>
/// 打开延迟
/// </summary>
public ModbusProperty<short> Turn0nDelay { get; set; } = new(0x04F2);
#endregion
#region 17设置可配置参数成功或失败
/// <summary>
/// 旗帜:声音警报
/// </summary>
public ModbusProperty<short> AudibleAlarm1 { get; set; } = new(0x0516,start:15,length:1);
/// <summary>
/// 标志:关机延迟
/// </summary>
public ModbusProperty<short> ShutdownDelay1 { get; set; } = new(0x0516,start:14,length:1);
/// <summary>
/// 标志:打开延迟
/// </summary>
public ModbusProperty<short> TurnOnDelay { get; set; } = new(0x0516,start:13,length:1);
#endregion
#region 18阅读可配置EEPROM Parameters范围
/// <summary>
/// 旁路上部转移的注册地址电压
/// </summary>
public ModbusProperty<short> BypassUpperTransferVoltage { get; set; } = new(0x0538);
/// <summary>
/// 旁路下转移的注册地址电压
/// </summary>
public ModbusProperty<short> BypassLowerTransferVoltage { get; set; } = new(0x0539);
/// <summary>
/// 声音警报的注册地址
/// </summary>
public ModbusProperty<short> RegisterAddressOfAudibleAlarm { get; set; } = new(0x0540);
/// <summary>
/// 关机延迟的注册地址
/// </summary>
public ModbusProperty<short> RegisterAddressOfShutdownDelay { get; set; } = new(0x0541);
/// <summary>
/// 开启延迟的注册地址
/// </summary>
public ModbusProperty<short> RegisterAddressOfTurnOnDelay { get; set; } = new(0x0542);
/// <summary>
/// 参数预订的注册地址
/// </summary>
public ModbusProperty<string> ParameterReservation { get; set; } = new(0x0539,length:25);
/// <summary>
/// 参数缓冲区
/// </summary>
public ModbusProperty<string> ParameterBuffer { get; set; } = new(0x0556,length:80);
#endregion
}*/

@ -1,7 +0,0 @@
namespace Service.Humiture.Client;
public class HumiturePlcMgr
{
public static HumiturePlcClient HumiturePlcClient;
public static HumitureMsg HumitureMsg;
}

@ -29,6 +29,9 @@
</ItemGroup>
<ItemGroup>
<Reference Include="HslCommunication">
<HintPath>C:\Users\CZ\.nuget\packages\hslcommunication\11.1.1\lib\netstandard2.1\HslCommunication.dll</HintPath>
</Reference>
<Reference Include="HybirdFrameworkCore">
<HintPath>..\Common\lib\HybirdFrameworkCore.dll</HintPath>
</Reference>
@ -40,4 +43,8 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Folder Include="HelpLeft\" />
</ItemGroup>
</Project>

@ -50,6 +50,7 @@ public class TBoxService
carStatus.LockStatus = beatMsg.LockStatus;
carStatus.Keys = beatMsg.KeyStatus;
carInfoResp.CarStatus = carStatus;
carInfoResp.HeartBeatMsg = beatMsg;
}
}

@ -1,31 +0,0 @@
using HybirdFrameworkCore.Const;
using HybirdFrameworkDriver.ModbusTcpMaster;
using Service.Humiture;
using Service.Humiture.Client;
using Service.Ups.UpsMsg;
namespace Service.Ups.Client;
public class UpsClient:ModbusTcpMaster
{
public UpsClient()
{
ReadAction = BatchRead;
Ip = "172.0.20.66";
Port = 502;
Duration = 1000;
AutoReConnect = true;
ByteSeq = EndingConst.ByteSeq.BA;
WordSeq= EndingConst.WordSeq.CD;
}
private void BatchRead(ModbusTcpMaster master)
{
var bytes01 = master.BatchReadHolderRegister(0, 32);
if (bytes01 != null)
{
ModbusDecoder.Decode<UpsInfoMsg>(bytes01, UpsMgr.UpsInfoMsg, EndingConst.ByteSeq.AB,
EndingConst.WordSeq.DC);
}
}
}

@ -1,9 +0,0 @@
using Service.Ups.UpsMsg;
namespace Service.Ups.Client;
public class UpsMgr
{
public static UpsClient UpsClient;
public static UpsInfoMsg UpsInfoMsg;
}

@ -21,6 +21,28 @@ public class CarController : ControllerBase
{
private static readonly ILog Log = LogManager.GetLogger(typeof(CarController));
/// <summary>
/// 设置心跳返回信息
/// </summary>
/// <param name="status">
/// 1 换电站待机
/// 2 开始换电
/// 3 换电进行中
/// 4 换电完成
/// 5 换电站故障</param>
/// <returns></returns>
[HttpGet("Vin/{VIN}/SetStatus/{status}")]
public bool SetStatus(string VIN,byte status)
{
if (CarServerMgr.CarServer != null)
{
CarServerMgr.CarServer.VIN = VIN;
CarServerMgr.CarServer.StationStatus = status;
return true;
}
return false;
}
/// <summary>
/// 获取车辆数据
/// </summary>
@ -63,6 +85,7 @@ public class CarController : ControllerBase
carStatus.LockStatus = beatMsg.LockStatus;
carStatus.Keys = beatMsg.KeyStatus;
carInfoResp.CarStatus = carStatus;
carInfoResp.HeartBeatMsg = beatMsg;
}
result.Add(carInfoResp);
@ -209,4 +232,25 @@ public class CarController : ControllerBase
CarServerMgr.CarServer.Clean();
return true;
}
/// <summary>
/// 货箱降下并且就绪
/// </summary>
/// <param name="carNo"></param>
/// <returns></returns>
[HttpGet("BoxDown/{carNo}")]
public bool BoxDown(string carNo)
{
Log.Info($"BoxDown {carNo} ");
var carInfo = TBoxService.GetHnCZCarInfo(carNo);
if (carInfo != null)
{
if (carInfo.HeartBeatMsg != null)
{
return carInfo.HeartBeatMsg.CrateBrimStatus == 3 && carInfo.HeartBeatMsg.SwapStatus == 2;
}
}
return false;
}
}

@ -7,7 +7,9 @@ using HybirdFrameworkCore.Entity;
using HybirdFrameworkCore.Redis;
using log4net;
using Service.Car.Server;
using Service.Humiture.Client;
using Service.TBox.Server;
using Service.Ups.Client;
using SqlSugar;
using SqlSugar.IOC;
@ -98,12 +100,19 @@ foreach (var s in list.Split(";"))
AppInfo.Container = app.Services.GetAutofacRoot();
//var listen = builder.Configuration.GetSection("Listen");
//CarServerMgr.InitServer(int.Parse(listen.GetSection("Port").Value ?? "5588"));
var listen = builder.Configuration.GetSection("Listen");
CarServerMgr.InitServer(int.Parse(listen.GetSection("Port").Value ?? "5588"));
var tBoxListen = builder.Configuration.GetSection("TBoxListen");
TBoxServerMgr.InitTBoxServer(int.Parse(tBoxListen.GetSection("Port").Value ?? "9999"));
//UPS
UpsMgr.Init();
//温湿度
HumiturePlcMgr.Init();
//电表
TaskInit.Init();
app.Run();

@ -32,15 +32,6 @@
</Content>
</ItemGroup>
<ItemGroup>
<Reference Include="HybirdFrameworkCore">
<HintPath>..\Common\lib\HybirdFrameworkCore.dll</HintPath>
</Reference>
<Reference Include="HybirdFrameworkDriver">
<HintPath>..\Common\lib\HybirdFrameworkDriver.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<None Update="HybirdFrameworkCore.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
@ -51,4 +42,16 @@
<Folder Include="Dto\Resp\" />
</ItemGroup>
<ItemGroup>
<Reference Include="HslCommunication">
<HintPath>C:\Users\CZ\.nuget\packages\hslcommunication\11.1.1\lib\netstandard2.1\HslCommunication.dll</HintPath>
</Reference>
<Reference Include="HybirdFrameworkCore">
<HintPath>..\Common\lib\HybirdFrameworkCore.dll</HintPath>
</Reference>
<Reference Include="HybirdFrameworkDriver">
<HintPath>..\Common\lib\HybirdFrameworkDriver.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

@ -25,6 +25,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rfid", "Rfid\Rfid.csproj",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Common", "Common\Common.csproj", "{3CD91BB6-C472-45D1-B0EC-6C96DF603CC0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RfidInfo", "RfidInfo\RfidInfo.csproj", "{5B73AD86-5EB9-4C1C-8906-D820C9299C43}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -67,6 +69,10 @@ Global
{3CD91BB6-C472-45D1-B0EC-6C96DF603CC0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3CD91BB6-C472-45D1-B0EC-6C96DF603CC0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3CD91BB6-C472-45D1-B0EC-6C96DF603CC0}.Release|Any CPU.Build.0 = Release|Any CPU
{5B73AD86-5EB9-4C1C-8906-D820C9299C43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B73AD86-5EB9-4C1C-8906-D820C9299C43}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B73AD86-5EB9-4C1C-8906-D820C9299C43}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B73AD86-5EB9-4C1C-8906-D820C9299C43}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -81,6 +87,7 @@ Global
{A6C2AA7F-B2A2-4AE0-AE84-49BE36B990EC} = {C9515084-B676-4C33-9FE7-E0B860493A4F}
{053079C7-C9EE-49F4-B9CB-F06D14AEB027} = {E0B949DC-17FE-414D-8898-937A317BB853}
{3CD91BB6-C472-45D1-B0EC-6C96DF603CC0} = {C9515084-B676-4C33-9FE7-E0B860493A4F}
{5B73AD86-5EB9-4C1C-8906-D820C9299C43} = {E0B949DC-17FE-414D-8898-937A317BB853}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3E10BF3D-9914-44B1-A6AA-FCF013C3F155}

Loading…
Cancel
Save