init
This commit is contained in:
parent
e48ea0e8de
commit
e98fbeadfd
Binary file not shown.
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
</configuration>
|
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" 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>{CA663F4F-3D66-454E-9C4A-1C1ED2A7B8C0}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>DianBiao</RootNamespace>
|
||||
<AssemblyName>DianBiao</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<Deterministic>true</Deterministic>
|
||||
</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="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ToolKit.cs" />
|
||||
<Compile Include="dianbiao.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.32929.386
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DianBiao", "DianBiao.csproj", "{CA663F4F-3D66-454E-9C4A-1C1ED2A7B8C0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{CA663F4F-3D66-454E-9C4A-1C1ED2A7B8C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CA663F4F-3D66-454E-9C4A-1C1ED2A7B8C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CA663F4F-3D66-454E-9C4A-1C1ED2A7B8C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CA663F4F-3D66-454E-9C4A-1C1ED2A7B8C0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {CD5CE7DD-0001-4A60-AE34-8E91E74534F4}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,36 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 有关程序集的一般信息由以下
|
||||
// 控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("DianBiao")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("DianBiao")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2023")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||
//请将此类型的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("ca663f4f-3d66-454e-9c4a-1c1ed2a7b8c0")]
|
||||
|
||||
// 程序集的版本信息由下列四个值组成:
|
||||
//
|
||||
// 主版本
|
||||
// 次版本
|
||||
// 生成号
|
||||
// 修订号
|
||||
//
|
||||
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||
//通过使用 "*",如下所示:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@ -0,0 +1,382 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ToolKitlib
|
||||
{
|
||||
#region 转换工具包【ToolKit】
|
||||
|
||||
/// <summary>
|
||||
/// 转换工具包
|
||||
/// </summary>
|
||||
internal class ToolKit
|
||||
{
|
||||
/// <summary>
|
||||
/// 16进制转字符串(十进制)**
|
||||
/// </summary>
|
||||
/// <param name="hexStr"></param>
|
||||
/// <returns></returns>
|
||||
public static string hexStr2Str(String hexStr)
|
||||
{
|
||||
String str = "0123456789ABCDEF";
|
||||
char[] hexs = hexStr.ToCharArray();
|
||||
byte[] bytes = new byte[hexStr.Length / 2];
|
||||
int n;
|
||||
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
n = str.IndexOf(hexs[2 * i]) * 16;
|
||||
n += str.IndexOf(hexs[2 * i + 1]);
|
||||
bytes[i] = (byte)(n & 0xff);
|
||||
}
|
||||
StringBuilder stringBuilder = new StringBuilder("");
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
stringBuilder.Append(bytes[i]);
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 16进制转ASCII码**
|
||||
/// </summary>
|
||||
/// <param name="hexStr">16进制字符</param>
|
||||
/// <returns></returns>
|
||||
public static StringBuilder hexToASCII(string hexStr)
|
||||
{
|
||||
String str = "0123456789ABCDEF";
|
||||
char[] hexs = hexStr.ToCharArray();
|
||||
byte[] bytes = new byte[hexStr.Length / 2];
|
||||
int n;
|
||||
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
n = str.IndexOf(hexs[2 * i]) * 16;
|
||||
n += str.IndexOf(hexs[2 * i + 1]);
|
||||
bytes[i] = (byte)(n & 0xff);
|
||||
}
|
||||
StringBuilder VersionNumber = new StringBuilder("");
|
||||
for (int i = 0; i < bytes.Length; i++)
|
||||
{
|
||||
VersionNumber.Append((char)bytes[i]);
|
||||
}
|
||||
return VersionNumber;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取高四位**
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static int getHeight4(byte data)
|
||||
{
|
||||
int height;
|
||||
height = ((data & 0xf0) >> 4);
|
||||
return height;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取低四位**
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static int getLow4(byte data)
|
||||
{
|
||||
int low;
|
||||
low = (data & 0x0f);
|
||||
return low;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// byte数组转string
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static string byteArrayToString(byte[] data, Encoding encoding)
|
||||
{
|
||||
return encoding.GetString(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将列表 转为byte[]
|
||||
/// </summary>
|
||||
/// <param name="matrix"></param>
|
||||
/// <returns></returns>
|
||||
public static byte[] listToBytes(List<byte> matrix)
|
||||
{
|
||||
if (matrix == null)
|
||||
{
|
||||
return new byte[0];
|
||||
}
|
||||
using (MemoryStream stream = new MemoryStream())
|
||||
{
|
||||
BinaryWriter bw = new BinaryWriter(stream);
|
||||
foreach (var item in matrix)
|
||||
{
|
||||
bw.Write(item);
|
||||
}
|
||||
return stream.ToArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// string转 byte数组
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="fromBase">传入数据进制</param>
|
||||
/// <returns></returns>
|
||||
public static byte[] stringToByteArray(string data, int fromBase)
|
||||
{
|
||||
if (data.Length < 2 || data.Length % 2 != 0) return null;
|
||||
byte[] bytes = new byte[(data.Length) / 2];
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
if (i != 0 && i % 2 != 0)
|
||||
{
|
||||
ushort a = (ushort)Convert.ToInt16((data[i - 1].ToString() + data[i].ToString()).ToString(), fromBase);
|
||||
|
||||
bytes[(i - 1) / 2] = (byte)(a);
|
||||
}
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// string转byte数组--针对校验位
|
||||
/// </summary>
|
||||
/// <param name="str"></param>
|
||||
/// <returns>[0]--高位;[1]地位--</returns>
|
||||
public static byte[] stringToByteArray(string str)
|
||||
{
|
||||
//var a = "332A";
|
||||
ushort u = (ushort)Convert.ToInt16(str, 16);//0x332A
|
||||
byte g = (byte)(u / 256);//0x33 高位
|
||||
byte d = (byte)(u % 256);//0x2A 地位
|
||||
return new byte[] { g, d };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// byte数组转16进制字符串
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static string byteArrayToHexString(byte[] data)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
builder.Append(string.Format("{0:X2} ", data[i]));
|
||||
}
|
||||
return builder.ToString().Trim();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// byte数组转16进制字符串--接收
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static string byteArrayToHexString(byte[] data, int length = 0)
|
||||
{
|
||||
int dataLength = 0;
|
||||
if (length != 0) dataLength = length;
|
||||
else dataLength = data.Length;
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < dataLength; i++)
|
||||
{
|
||||
builder.Append(string.Format("{0:X2} ", data[i]));
|
||||
}
|
||||
return builder.ToString().Trim();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 16进制字符串转byte数组
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static byte[] hexStringToByteArray(string data)
|
||||
{
|
||||
string[] chars = data.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
byte[] returnBytes = new byte[chars.Length];
|
||||
//逐个字符变为16进制字节数据
|
||||
for (int i = 0; i < chars.Length; i++)
|
||||
{
|
||||
returnBytes[i] = Convert.ToByte(chars[i], 16);
|
||||
}
|
||||
return returnBytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// byte数组转10进制字符串
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static string byteArrayToDecString(byte[] data)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
builder.Append(data[i] + " ");
|
||||
}
|
||||
return builder.ToString().Trim();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 10进制字符串转byte数组
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static byte[] decStringToByteArray(string data)
|
||||
{
|
||||
string[] chars = data.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
byte[] returnBytes = new byte[chars.Length];
|
||||
//逐个字符变为10进制字节数据
|
||||
for (int i = 0; i < chars.Length; i++)
|
||||
{
|
||||
returnBytes[i] = Convert.ToByte(chars[i], 10);
|
||||
}
|
||||
return returnBytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// byte数组转八进制字符串
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static string byteArrayToOtcString(byte[] data)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
builder.Append(Convert.ToString(data[i], 8) + " ");
|
||||
}
|
||||
return builder.ToString().Trim();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 八进制字符串转byte数组
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static byte[] otcStringToByteArray(string data)
|
||||
{
|
||||
string[] chars = data.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
byte[] returnBytes = new byte[chars.Length];
|
||||
//逐个字符变为8进制字节数据
|
||||
for (int i = 0; i < chars.Length; i++)
|
||||
{
|
||||
returnBytes[i] = Convert.ToByte(chars[i], 8);
|
||||
}
|
||||
return returnBytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 二进制字符串转byte数组
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static byte[] binStringToByteArray(string data)
|
||||
{
|
||||
string[] chars = data.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
byte[] returnBytes = new byte[chars.Length];
|
||||
//逐个字符变为2进制字节数据
|
||||
for (int i = 0; i < chars.Length; i++)
|
||||
{
|
||||
returnBytes[i] = Convert.ToByte(chars[i], 2);
|
||||
}
|
||||
return returnBytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// byte数组转二进制字符串
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static string byteArrayToBinString(byte[] data)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
builder.Append(Convert.ToString(data[i], 2) + " ");
|
||||
}
|
||||
return builder.ToString().Trim();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 每8bit高低位互换
|
||||
/// </summary>
|
||||
/// <param name="j">起始</param>
|
||||
/// <param name="k">终止</param>
|
||||
/// <param name="message">需要转换的16进制数据</param>
|
||||
/// <returns>新的16进制数据</returns>
|
||||
public static string interconvert(int j, int k, string message, bool exchange = true)
|
||||
{
|
||||
StringBuilder parityBitCS = new StringBuilder("");//互换后的值
|
||||
|
||||
string[] strings = new string[4] { message[0].ToString() + message[1].ToString(), message[2].ToString() + message[3].ToString(), message[4].ToString() + message[5].ToString(), message[6].ToString() + message[7].ToString() };
|
||||
for (int i = strings.Length - 1; i >= 0; i--)
|
||||
{
|
||||
parityBitCS.Append(strings[i].ToString());
|
||||
}
|
||||
return Convert.ToInt32(parityBitCS.ToString(), 16).ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// byte[]直接转Float**
|
||||
/// </summary>
|
||||
/// <param name="message"></param>
|
||||
/// <returns></returns>
|
||||
public static float byteToFloat(string message)
|
||||
{
|
||||
byte[] bFxianOrg = new byte[4];
|
||||
var a = Encoding.Default.GetBytes(message);
|
||||
StringBuilder zz = new StringBuilder("");
|
||||
StringBuilder _zz = new StringBuilder("");
|
||||
string[] s = new string[4];
|
||||
int x = 0;
|
||||
for (int i = 0; i < a.Length; i++)
|
||||
{
|
||||
if (x != 0 && i % 2 == 0)
|
||||
{
|
||||
zz.Append(int.Parse(hexStr2Str(_zz.ToString())).ToString()).Append("-");
|
||||
_zz.Clear();
|
||||
x = 0;
|
||||
}
|
||||
_zz.Append(((char)a[i]).ToString());
|
||||
if (i == a.Length - 1)
|
||||
{
|
||||
zz.Append(int.Parse(hexStr2Str(_zz.ToString())).ToString()).Append("-");
|
||||
_zz.Clear();
|
||||
}
|
||||
x++;
|
||||
}
|
||||
s = zz.ToString().Split('-');
|
||||
byte a0 = byte.Parse(s[0].ToString());
|
||||
byte a1 = byte.Parse(s[1].ToString());
|
||||
byte a2 = byte.Parse(s[2].ToString());
|
||||
byte a3 = byte.Parse(s[3].ToString());
|
||||
bFxianOrg = new byte[4] { a0, a1, a2, a3 };
|
||||
var b = BitConverter.ToSingle(bFxianOrg, 0);
|
||||
return b;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// string[]转string**
|
||||
/// </summary>
|
||||
/// <param name="vs"></param>
|
||||
/// <returns></returns>
|
||||
public static string strsTostring(string[] vs)
|
||||
{
|
||||
return String.Join("", vs);//引号中可加字符串分隔符
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ToolKitlib;
|
||||
|
||||
namespace DianBiao
|
||||
{
|
||||
class dianbiao
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue