Skip to content

Commit ec8bc73

Browse files
添加 CallRfidCenterSample
1 parent 2cd2e64 commit ec8bc73

15 files changed

+1077
-0
lines changed

CallRfidCenterSample/App.config

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
5+
</startup>
6+
</configuration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{B514ACFB-CAEB-4606-89C6-F2D5BED1A256}</ProjectGuid>
8+
<OutputType>WinExe</OutputType>
9+
<RootNamespace>CallRfidCenterSample</RootNamespace>
10+
<AssemblyName>CallRfidCenterSample</AssemblyName>
11+
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
12+
<FileAlignment>512</FileAlignment>
13+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
14+
<Deterministic>true</Deterministic>
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<PlatformTarget>AnyCPU</PlatformTarget>
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
27+
<PlatformTarget>AnyCPU</PlatformTarget>
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\Release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
</PropertyGroup>
35+
<ItemGroup>
36+
<Reference Include="System" />
37+
<Reference Include="System.Core" />
38+
<Reference Include="System.Xml.Linq" />
39+
<Reference Include="System.Data.DataSetExtensions" />
40+
<Reference Include="Microsoft.CSharp" />
41+
<Reference Include="System.Data" />
42+
<Reference Include="System.Deployment" />
43+
<Reference Include="System.Drawing" />
44+
<Reference Include="System.Net.Http" />
45+
<Reference Include="System.Windows.Forms" />
46+
<Reference Include="System.Xml" />
47+
</ItemGroup>
48+
<ItemGroup>
49+
<Compile Include="Form1.cs">
50+
<SubType>Form</SubType>
51+
</Compile>
52+
<Compile Include="Form1.Designer.cs">
53+
<DependentUpon>Form1.cs</DependentUpon>
54+
</Compile>
55+
<Compile Include="Program.cs" />
56+
<Compile Include="Properties\AssemblyInfo.cs" />
57+
<Compile Include="TagListForm.cs">
58+
<SubType>Form</SubType>
59+
</Compile>
60+
<Compile Include="TagListForm.Designer.cs">
61+
<DependentUpon>TagListForm.cs</DependentUpon>
62+
</Compile>
63+
<EmbeddedResource Include="Form1.resx">
64+
<DependentUpon>Form1.cs</DependentUpon>
65+
</EmbeddedResource>
66+
<EmbeddedResource Include="Properties\Resources.resx">
67+
<Generator>ResXFileCodeGenerator</Generator>
68+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
69+
<SubType>Designer</SubType>
70+
</EmbeddedResource>
71+
<Compile Include="Properties\Resources.Designer.cs">
72+
<AutoGen>True</AutoGen>
73+
<DependentUpon>Resources.resx</DependentUpon>
74+
</Compile>
75+
<EmbeddedResource Include="TagListForm.resx">
76+
<DependentUpon>TagListForm.cs</DependentUpon>
77+
</EmbeddedResource>
78+
<None Include="Properties\Settings.settings">
79+
<Generator>SettingsSingleFileGenerator</Generator>
80+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
81+
</None>
82+
<Compile Include="Properties\Settings.Designer.cs">
83+
<AutoGen>True</AutoGen>
84+
<DependentUpon>Settings.settings</DependentUpon>
85+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
86+
</Compile>
87+
</ItemGroup>
88+
<ItemGroup>
89+
<None Include="App.config" />
90+
</ItemGroup>
91+
<ItemGroup>
92+
<ProjectReference Include="..\DigitalPlatform.IO\DigitalPlatform.IO.csproj">
93+
<Project>{441CB814-AF78-4503-91EF-DCE5F3269502}</Project>
94+
<Name>DigitalPlatform.IO</Name>
95+
</ProjectReference>
96+
<ProjectReference Include="..\DigitalPlatform.RFID.Manager\DigitalPlatform.RFID.Manager.csproj">
97+
<Project>{e45f79df-041f-4da8-9365-909f53baee72}</Project>
98+
<Name>DigitalPlatform.RFID.Manager</Name>
99+
</ProjectReference>
100+
<ProjectReference Include="..\DigitalPlatform.RFID\DigitalPlatform.RFID.csproj">
101+
<Project>{9D26D2AD-EABB-4C32-8706-FB9E323FAF01}</Project>
102+
<Name>DigitalPlatform.RFID</Name>
103+
</ProjectReference>
104+
<ProjectReference Include="..\DigitalPlatform\4.0\DigitalPlatform.csproj">
105+
<Project>{BDD43275-EAA0-4670-8BA3-0DB5CD7598DD}</Project>
106+
<Name>DigitalPlatform</Name>
107+
</ProjectReference>
108+
</ItemGroup>
109+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
110+
</Project>

CallRfidCenterSample/Form1.Designer.cs

+63
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CallRfidCenterSample/Form1.cs

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.Data;
5+
using System.Drawing;
6+
using System.Linq;
7+
using System.Text;
8+
using System.Threading;
9+
using System.Threading.Tasks;
10+
using System.Windows.Forms;
11+
12+
using DigitalPlatform;
13+
using DigitalPlatform.IO;
14+
using DigitalPlatform.RFID;
15+
16+
namespace CallRfidCenterSample
17+
{
18+
public partial class Form1 : Form
19+
{
20+
public Form1()
21+
{
22+
InitializeComponent();
23+
}
24+
25+
private void button_tagListForm_Click(object sender, EventArgs e)
26+
{
27+
TagListForm dlg = new TagListForm();
28+
dlg.ShowDialog(this);
29+
}
30+
31+
private void Form1_Load(object sender, EventArgs e)
32+
{
33+
StartRfidManager("ipc://RfidChannel/RfidServer");
34+
}
35+
36+
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
37+
{
38+
StopRfidManager();
39+
}
40+
41+
CancellationTokenSource _cancelRfidManager = new CancellationTokenSource();
42+
43+
void StartRfidManager(string url)
44+
{
45+
_cancelRfidManager?.Cancel();
46+
47+
_cancelRfidManager = new CancellationTokenSource();
48+
RfidManager.Base.Name = "RFID 中心";
49+
RfidManager.Url = url;
50+
// RfidManager.AntennaList = "1|2|3|4"; // testing
51+
// RfidManager.SetError += RfidManager_SetError;
52+
RfidManager.ListTags += RfidManager_ListTags; ;
53+
RfidManager.Start(_cancelRfidManager.Token);
54+
}
55+
56+
public static event TagChangedEventHandler TagChanged = null;
57+
58+
private void RfidManager_ListTags(object sender, ListTagsEventArgs e)
59+
{
60+
// 标签总数显示
61+
if (e.Result.Results != null)
62+
{
63+
TagList.Refresh(sender as BaseChannel<IRfid>,
64+
e.ReaderNameList,
65+
e.Result.Results,
66+
(add_books, update_books, remove_books, add_patrons, update_patrons, remove_patrons) =>
67+
{
68+
TagChanged?.Invoke(sender, new TagChangedEventArgs
69+
{
70+
AddBooks = add_books,
71+
UpdateBooks = update_books,
72+
RemoveBooks = remove_books,
73+
AddPatrons = add_patrons,
74+
UpdatePatrons = update_patrons,
75+
RemovePatrons = remove_patrons
76+
});
77+
},
78+
(type, text) =>
79+
{
80+
RfidManager.TriggerSetError(this, new SetErrorEventArgs { Error = text });
81+
// TagSetError?.Invoke(this, new SetErrorEventArgs { Error = text });
82+
});
83+
84+
// 标签总数显示 图书+读者卡
85+
// this.Number = $"{TagList.Books.Count}:{TagList.Patrons.Count}";
86+
}
87+
}
88+
89+
void StopRfidManager()
90+
{
91+
_cancelRfidManager?.Cancel();
92+
RfidManager.Url = "";
93+
RfidManager.ListTags -= RfidManager_ListTags;
94+
}
95+
}
96+
97+
public delegate void TagChangedEventHandler(object sender,
98+
TagChangedEventArgs e);
99+
100+
/// <summary>
101+
/// 设置标签变化事件的参数
102+
/// </summary>
103+
public class TagChangedEventArgs : EventArgs
104+
{
105+
public List<TagAndData> AddBooks { get; set; }
106+
public List<TagAndData> UpdateBooks { get; set; }
107+
public List<TagAndData> RemoveBooks { get; set; }
108+
109+
public List<TagAndData> AddPatrons { get; set; }
110+
public List<TagAndData> UpdatePatrons { get; set; }
111+
public List<TagAndData> RemovePatrons { get; set; }
112+
}
113+
}

0 commit comments

Comments
 (0)