Commit 0f2fab40 by 陶然

init

parent 4c5d4b94
......@@ -4,3 +4,6 @@
/Src/obj/Debug
/Kivii.Client.SampleInbounds.V4.0.sln
/packages
/.vs
/Src/bin/Debug
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<connectionStrings>
<!--<add name="Database" providerName="Sqlite" connectionString="$ROOT\AppData\primary.sqlite"/>-->
</connectionStrings>
</configuration>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kivii.Client
{
internal class Configs
{
public const string DefaultBaseUrl = "http://k5.jst-gov.com";
public const string TableUiSetting = "ui_settings";
public const string RouteLocationQuery = "/Restful/Kivii.Samples.Entities.Location/Query";
public const string RouteSampleQuery = "/Restful/Kivii.Samples.Entities.Sample/Query";
public const string RouteSamplePrePackaging = "/Restful/Kivii.Samples.Entities.Sample/PrePackaging";
public const string RouteSampleAssign = "/Restful/Kivii.Samples.Entities.Sample/Assign";
public const string RouteSamplePackaging = "/Restful/Kivii.Samples.Entities.Sample/Packaging";
public const string RouteSampleUnPackaging = "/Restful/Kivii.Samples.Entities.Sample/UnPackaging";
}
}
using Kivii.Configuration;
using Kivii.DataAnnotations;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kivii.Client.SampleInbounds.Entities
{
[Alias(Configs.TableUiSetting)]
public class UiSetting : Entity
{
[Required]
[Unique("Form-Control")]
public string FormName { get; set; }
[Required]
[Unique("Form-Control")]
public string ControlName { get; set; }
[Default("")]
public string ControlValue { get; set; }
}
}
File added
This diff is collapsed. Click to expand it.
This source diff could not be displayed because it is too large. You can view the blob instead.
<?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>{F1CEFFAD-7EA4-4456-B1CA-68CAD975A693}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Kivii.Client.SampleInbounds</RootNamespace>
<AssemblyName>样品入库交接客户端</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<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>
<PropertyGroup>
<ApplicationIcon>F.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Kivii.Common.V4.0, Version=5.6.2023.4000, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Kivii.Common.5.6.2023.4000\lib\net40\Kivii.Common.V4.0.dll</HintPath>
</Reference>
<Reference Include="Kivii.Core.V4.0, Version=5.6.2023.4140, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Kivii.Core.5.6.2023.4140\lib\net40\Kivii.Core.V4.0.dll</HintPath>
</Reference>
<Reference Include="Kivii.Linq.Sqlite.V4.0, Version=5.6.2023.3000, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Kivii.Linq.Sqlite.5.6.2023.3000\lib\net40\Kivii.Linq.Sqlite.V4.0.dll</HintPath>
</Reference>
<Reference Include="Kivii.Linq.V4.0, Version=5.6.2023.4200, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Kivii.Linq.5.6.2023.4200\lib\net40\Kivii.Linq.V4.0.dll</HintPath>
</Reference>
<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.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Configs.cs" />
<Compile Include="Entities\Sample.Entities.cs" />
<Compile Include="Entities\UiSetting.cs" />
<Compile Include="FrmMain.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmMain.Designer.cs">
<DependentUpon>FrmMain.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Reader\InventoryBuffer.cs" />
<Compile Include="Reader\ITalker.cs" />
<Compile Include="Reader\MessageTran.cs" />
<Compile Include="Reader\Reader.cs" />
<Compile Include="Reader\Reader.Extensions.cs" />
<Compile Include="Reader\ReaderSetting.cs" />
<Compile Include="Reader\Talker.cs" />
<Compile Include="Requests\RestfulRequests.cs" />
<EmbeddedResource Include="FrmMain.resx">
<DependentUpon>FrmMain.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="App.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="F.ico" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ProjectFiles</ProjectView>
</PropertyGroup>
</Project>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace Kivii.Client.SampleInbounds.V4._0
{
internal static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmMain());
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Kivii.Client.SampleInbounds.V4.0")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Kivii.Client.SampleInbounds.V4.0")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("f1ceffad-7ea4-4456-b1ca-68cad975a693")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Kivii.Client.SampleInbounds.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Kivii.Client.SampleInbounds.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Kivii.Client.SampleInbounds.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.5.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
namespace Readers
{
public delegate void MessageReceivedEventHandler(byte[] btAryBuffer);
interface ITalker
{
event MessageReceivedEventHandler MessageReceived; // 接收到发来的消息
bool Connect(IPAddress ip, int port, out string strException); // 连接到服务端
bool SendMessage(byte[] btAryBuffer); // 发送数据包
void SignOut(); // 注销连接
bool IsConnect(); //校验是否连接服务器
}
}
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
namespace Kivii.Client.SampleAssigns
{
public class InventoryBuffer
{
public byte btRepeat;
public byte btSession;
public byte btTarget;
public List<byte> lAntenna;
public bool bLoopInventory;
public int nIndexAntenna;
public int nCommond;
public bool bLoopInventoryReal;
public bool bLoopCustomizedSession;
public int nTagCount;
public int nDataCount; //执行一次命令所返回的标签记录条数
public int nCommandDuration;
public int nReadRate;
public int nCurrentAnt;
public List<int> lTotalRead;
public DateTime dtStartInventory;
public DateTime dtEndInventory;
public int nMaxRSSI;
public int nMinRSSI;
public DataTable dtTagTable;
public DataTable dtTagDetailTable;
public InventoryBuffer()
{
btRepeat = 0x00;
lAntenna = new List<byte>();
bLoopInventory = false;
nIndexAntenna = 0;
nCommond = 0;
bLoopInventoryReal = false;
nTagCount = 0;
nReadRate = 0;
lTotalRead = new List<int>();
dtStartInventory = DateTime.Now;
dtEndInventory = DateTime.Now;
nMaxRSSI = 0;
nMinRSSI = 0;
dtTagTable = new DataTable();
dtTagTable.Columns.Add("COLPC", typeof(string));
dtTagTable.Columns.Add("COLCRC", typeof(string));
dtTagTable.Columns.Add("COLEPC", typeof(string));
dtTagTable.Columns.Add("COLANT", typeof(string));
dtTagTable.Columns.Add("COLRSSI", typeof(string));
dtTagTable.Columns.Add("COLINVCNT", typeof(string));
dtTagTable.Columns.Add("COLFREQ", typeof(string));
dtTagTable.Columns.Add("COLANT1", typeof(string));
dtTagTable.Columns.Add("COLANT2", typeof(string));
dtTagTable.Columns.Add("COLANT3", typeof(string));
dtTagTable.Columns.Add("COLANT4", typeof(string));
dtTagDetailTable = new DataTable();
dtTagDetailTable.Columns.Add("COLEPC", typeof(string));
dtTagDetailTable.Columns.Add("COLRSSI", typeof(string));
dtTagDetailTable.Columns.Add("COLANT", typeof(string));
dtTagDetailTable.Columns.Add("COLFRE", typeof(string));
}
public void ClearInventoryPar()
{
btRepeat = 0x00;
lAntenna.Clear();
//bLoopInventory = false;
nIndexAntenna = 0;
nCommond = 0;
bLoopInventoryReal = false;
}
public void ClearInventoryResult()
{
nTagCount = 0;
nReadRate = 0;
lTotalRead.Clear();
dtStartInventory = DateTime.Now;
dtEndInventory = DateTime.Now;
nMaxRSSI = 0;
nMinRSSI = 0;
dtTagTable.Rows.Clear();
}
public void ClearInventoryRealResult()
{
nTagCount = 0;
nReadRate = 0;
lTotalRead.Clear();
dtStartInventory = DateTime.Now;
dtEndInventory = DateTime.Now;
nMaxRSSI = 0;
nMinRSSI = 0;
dtTagTable.Rows.Clear();
dtTagDetailTable.Clear();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Readers
{
public class MessageTran
{
private byte btPacketType; //数据包头,默认为0xA0
private byte btDataLen; //数据包长度,数据包从‘长度’字节后面开始的字节数,不包含‘长度’字节本身
private byte btReadId; //读写器地址
private byte btCmd; //数据包命令代码
private byte[] btAryData; //数据包命令参数,部分命令无参数
private byte btCheck; //校验和,除校验和本身外所有字节的校验和
private byte[] btAryTranData; //完整数据包
//设置属性
public byte[] AryTranData
{
get
{
return btAryTranData;
}
}
public byte[] AryData
{
get
{
return btAryData;
}
}
public byte ReadId
{
get
{
return btReadId;
}
}
public byte Cmd
{
get
{
return btCmd;
}
}
public byte PacketType
{
get
{
return btPacketType;
}
}
public MessageTran()
{
}
public MessageTran(byte btReadId, byte btCmd, byte[] btAryData)
{
int nLen = btAryData.Length;
this.btPacketType = 0xA0;
this.btDataLen = Convert.ToByte(nLen + 3);
this.btReadId = btReadId;
this.btCmd = btCmd;
this.btAryData = new byte[nLen];
btAryData.CopyTo(this.btAryData, 0);
this.btAryTranData = new byte[nLen + 5];
this.btAryTranData[0] = this.btPacketType;
this.btAryTranData[1] = this.btDataLen;
this.btAryTranData[2] = this.btReadId;
this.btAryTranData[3] = this.btCmd;
this.btAryData.CopyTo(this.btAryTranData, 4);
this.btCheck = CheckSum(this.btAryTranData, 0, nLen + 4);
this.btAryTranData[nLen + 4] = this.btCheck;
}
public MessageTran(byte btReadId, byte btCmd)
{
this.btPacketType = 0xA0;
this.btDataLen = 0x03;
this.btReadId = btReadId;
this.btCmd = btCmd;
this.btAryTranData = new byte[5];
this.btAryTranData[0] = this.btPacketType;
this.btAryTranData[1] = this.btDataLen;
this.btAryTranData[2] = this.btReadId;
this.btAryTranData[3] = this.btCmd;
this.btCheck = CheckSum(this.btAryTranData, 0, 4);
this.btAryTranData[4] = this.btCheck;
}
public MessageTran(byte[] btAryTranData)
{
int nLen = btAryTranData.Length;
this.btAryTranData = new byte[nLen];
btAryTranData.CopyTo(this.btAryTranData, 0);
byte btCK = CheckSum(this.btAryTranData, 0, this.btAryTranData.Length - 1);
if (btCK != btAryTranData[nLen - 1])
{
return;
}
this.btPacketType = btAryTranData[0];
this.btDataLen = btAryTranData[1];
this.btReadId = btAryTranData[2];
this.btCmd = btAryTranData[3];
this.btCheck = btAryTranData[nLen - 1];
if (nLen > 5)
{
this.btAryData = new byte[nLen - 5];
for (int nloop = 0; nloop < nLen - 5; nloop++ )
{
this.btAryData[nloop] = btAryTranData[4 + nloop];
}
}
}
public byte CheckSum(byte[] btAryBuffer, int nStartPos, int nLen)
{
byte btSum = 0x00;
for (int nloop = nStartPos; nloop < nStartPos + nLen; nloop++ )
{
btSum += btAryBuffer[nloop];
}
return Convert.ToByte(((~btSum) + 1) & 0xFF);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kivii.Client.SampleAssigns
{
public class ReaderSetting
{
public byte btReadId;
public byte btMajor;
public byte btMinor;
public byte btIndexBaudrate;
public byte btPlusMinus;
public byte btTemperature;
public byte btOutputPower;
public byte btWorkAntenna;
public byte btDrmMode;
public byte btRegion;
public byte btFrequencyStart;
public byte btFrequencyEnd;
public byte btBeeperMode;
public byte btGpio1Value;
public byte btGpio2Value;
public byte btGpio3Value;
public byte btGpio4Value;
public byte btAntDetector;
public byte btMonzaStatus;
public string btReaderIdentifier;
public byte btAntImpedance;
public byte btImpedanceFrequency;
public int nUserDefineStartFrequency;
public byte btUserDefineFrequencyInterval;
public byte btUserDefineChannelQuantity;
public byte btLinkProfile;
public ReaderSetting()
{
btReadId = 0xFF;
btMajor = 0x00;
btMinor = 0x00;
btIndexBaudrate = 0x00;
btPlusMinus = 0x00;
btTemperature = 0x00;
btOutputPower = 0x00;
btWorkAntenna = 0x00;
btDrmMode = 0x00;
btRegion = 0x00;
btFrequencyStart = 0x00;
btFrequencyEnd = 0x00;
btBeeperMode = 0x00;
btGpio1Value = 0x00;
btGpio2Value = 0x00;
btGpio3Value = 0x00;
btGpio4Value = 0x00;
btAntDetector = 0x00;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.IO;
using System.Threading;
namespace Readers
{
public class Talker:ITalker
{
public event MessageReceivedEventHandler MessageReceived;
TcpClient client;
Stream streamToTran;
private Thread waitThread;
private bool bIsConnect = false;
public bool Connect(IPAddress ipAddress, int nPort, out string strException)
{
strException = string.Empty;
try
{
client = new TcpClient();
client.Connect(ipAddress, nPort);
streamToTran = client.GetStream(); // 获取连接至远程的流
//建立线程收取服务器发送数据
ThreadStart stThead = new ThreadStart(ReceivedData);
waitThread = new Thread(stThead);
waitThread.IsBackground = true;
waitThread.Start();
bIsConnect = true;
return true;
}
catch (System.Exception ex)
{
strException = ex.Message;
return false;
}
}
private void ReceivedData()
{
while (true)
{
try
{
byte[] btAryBuffer = new byte[4096];
int nLenRead = streamToTran.Read(btAryBuffer, 0, btAryBuffer.Length);
if (nLenRead == 0)
{
continue;
}
if (MessageReceived != null)
{
byte[] btAryReceiveData = new byte[nLenRead];
Array.Copy(btAryBuffer, btAryReceiveData, nLenRead);
MessageReceived(btAryReceiveData);
}
}
catch (System.Exception ex)
{
}
}
}
public bool SendMessage(byte[] btAryBuffer)
{
try
{
lock (streamToTran)
{
streamToTran.Write(btAryBuffer, 0, btAryBuffer.Length);
return true;
}
}
catch
{
return false;
}
}
public void SignOut()
{
if (streamToTran != null)
streamToTran.Dispose();
if (client != null)
client.Close();
waitThread.Abort();
bIsConnect = false;
}
public bool IsConnect()
{
return bIsConnect;
}
}
}
using Kivii.Client;
using Kivii.Samples.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Kivii.Samples.Transforms
{
[Route(Configs.RouteLocationQuery)]
public class LocationQuery : IReturn<RestfulQueryResponse<Location>>
{
public Guid OwnerKvid { get; set; }
}
[Route(Configs.RouteSampleQuery)]
public class SampleQuery : IReturn<RestfulQueryResponse<Sample>>
{
public string Name { get; set; }
public SampleType Type { get; set; }
//public Guid PackageKvid { get; set; }
}
[Route(Configs.RouteSampleQuery)]
public class SampleQuery2 : IReturn<RestfulQueryResponse<Sample>>
{
//public bool IncludeLocation { get; set; } = true;
public Guid PackageKvid { get; set; }
}
[Route(Configs.RouteSamplePrePackaging)]
public class SamplePrePackaging:IReturn<RestfulExecutionResponse<Sample>>
{
public string Tid { get; set; }
public string BizId { get; set; }
public Guid BizKvid { get; set; }
public Guid OwnerKvid { get; set; }//要打包的样品的所属信息
public bool IncludeLocation { get; set; } = true;
}
[Route(Configs.RouteSampleAssign)]
public class SampleAssign : IReturn<RestfulUpdateResponse<Sample>>
{
public List<Guid> Kvids { get; set; }//要流转样品信息
public Location Location { get; set; }//地点位置信息,只需要InternalCode
}
[Route(Configs.RouteSamplePackaging)]
public class SamplePackaging : IReturn<RestfulExecutionResponse<Sample>>
{
public List<Guid> Kvids { get; set; }//要流转样品信息
public Location Location { get; set; }//地点位置信息,只需要InternalCode
public Sample Package { get; set; }//指定包裹信息,Package.PackageName可传入包裹的区域信息,例如包裹A0001中的1号袋子
}
[Route(Configs.RouteSampleUnPackaging)]
public class SampleUnPackaging : IReturn<RestfulExecutionResponse<Sample>>
{
public Guid Kvid { get; set; }//要流转样品信息
public Location Location { get; set; }//地点位置信息,只需要InternalCode
}
}
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Kivii.Common" version="5.6.2023.4000" targetFramework="net40" />
<package id="Kivii.Core" version="5.6.2023.4140" targetFramework="net40" />
<package id="Kivii.Linq" version="5.6.2023.4200" targetFramework="net40" />
<package id="Kivii.Linq.Sqlite" version="5.6.2023.3000" targetFramework="net40" />
</packages>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment